Skip to content

Commit

Permalink
Fix some issues with LockTeamChest
Browse files Browse the repository at this point in the history
  • Loading branch information
MetallicGoat committed Aug 9, 2024
1 parent 6b3a6ea commit a149cbf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ public class MainConfig {

@Config(
description = {
"Prevents player from opening a bases' chest if bases team is still alive"
"Prevents player from opening a bases' chest if bases team is still alive",
"Note: You may want to disable team chests in MBedwars, as it works like a shared team Ender Chest"
}
)
public static boolean lock_team_chest_enabled = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@
import de.marcely.bedwars.tools.location.XYZYP;
import me.metallicgoat.tweaksaddon.config.MainConfig;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

public class LockTeamChest implements Listener {

// Many people will want team chests disabled, use this with only regular chests
@EventHandler
public void playerOpenArenaChest(PlayerOpenArenaChestEvent event) {
// Dont mess with TeamChests, handled by MBedwars
if (!MainConfig.lock_team_chest_enabled || event.isTeamChest())
final Block teamChestBlock = event.getChestBlock();

if (!MainConfig.lock_team_chest_enabled || teamChestBlock.getType() == Material.ENDER_CHEST)
return;

final Arena arena = event.getArena();
Expand All @@ -26,12 +29,11 @@ public void playerOpenArenaChest(PlayerOpenArenaChestEvent event) {
final Team chestTeam = getChestTeam(arena, event.getChestBlock());

if (chestTeam != null && !arena.getPlayersInTeam(chestTeam).isEmpty() && chestTeam != playerTeam) {
final String failOpen = Message.build(MainConfig.lock_team_chest_fail_open)
Message.build(MainConfig.lock_team_chest_fail_open)
.placeholder("team-name", chestTeam.getDisplayName())
.placeholder("team", chestTeam.getDisplayName())
.done();
.send(player);

player.sendMessage(failOpen);
event.setCancelled(true);
}
}
Expand Down

0 comments on commit a149cbf

Please sign in to comment.