diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/data/CakeTeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/data/CakeTeam.java index 224c29da7..5c52763b7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/data/CakeTeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/data/CakeTeam.java @@ -31,17 +31,19 @@ public class CakeTeam private final GameTeam _team; private final Location _edgeHologram; private final Location _shopHologram; + private final Location _chest; private final Location _cake; private final Map _upgrades; private Hologram _cakeHologram; - public CakeTeam(CakeWars game, GameTeam team, Location edgeHologram, Location shopHologram) + public CakeTeam(CakeWars game, GameTeam team, Location edgeHologram, Location shopHologram, Location chest) { _game = game; _team = team; _edgeHologram = edgeHologram.add(0, 2, 0); _shopHologram = shopHologram.add(0, 2, 0); + _chest = chest.getBlock().getLocation(); _cake = game.WorldData.GetDataLocs(team.GetName().toUpperCase()).get(0).getBlock().getLocation(); _cake.getBlock().setType(Material.CAKE_BLOCK); @@ -81,6 +83,11 @@ public class CakeTeam return _cake.getBlock().getType() == Material.CAKE_BLOCK; } + public Location getChest() + { + return _chest; + } + public Location getCake() { return _cake; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/module/CakeShopModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/module/CakeShopModule.java index 138bd693d..0033df850 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/module/CakeShopModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/module/CakeShopModule.java @@ -34,7 +34,6 @@ import nautilus.game.arcade.game.games.cakewars.CakeWars; import nautilus.game.arcade.game.games.cakewars.data.CakeItem; import nautilus.game.arcade.game.games.cakewars.data.CakeResource; import nautilus.game.arcade.game.games.cakewars.data.CakeShopItem; -import nautilus.game.arcade.game.games.cakewars.data.CakeTeam; import nautilus.game.arcade.game.games.cakewars.ui.CakeResourcePage; import nautilus.game.arcade.game.games.cakewars.ui.CakeResourceShop; import nautilus.game.arcade.game.games.cakewars.ui.CakeResourceStarPage; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/module/CakeSpawnerModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/module/CakeSpawnerModule.java index 66db8c5e1..25930df5d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/module/CakeSpawnerModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/module/CakeSpawnerModule.java @@ -26,13 +26,6 @@ import nautilus.game.arcade.game.games.cakewars.data.CakeTeamItem; public class CakeSpawnerModule extends CakeModule { - private static final Map SPAWNER_CONVERTERS = ImmutableMap.builder() - .put("RED", "PINK") - .put("BLUE", "LIGHT_BLUE") - .put("GREEN", "LIME") - .put("YELLOW", "ORANGE") - .build(); - public CakeSpawnerModule(CakeWars game) { super(game); @@ -76,7 +69,7 @@ public class CakeSpawnerModule extends CakeModule ItemStack itemStack = resource.getItemStack().clone(); itemStack.setAmount(amount); - Location location = _game.WorldData.GetDataLocs(SPAWNER_CONVERTERS.get(team.GetName().toUpperCase())).get(0); + Location location = _game.WorldData.GetCustomLocs("GEN " + (team.GetName().toUpperCase())).get(0); boolean drop = true; List players = new ArrayList<>(); Item item = null; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/module/CakeTeamModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/module/CakeTeamModule.java index c88da3402..6734e2bc0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/module/CakeTeamModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cakewars/module/CakeTeamModule.java @@ -18,6 +18,8 @@ import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.F; import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTextMiddle; @@ -76,6 +78,7 @@ public class CakeTeamModule extends CakeModule WorldData worldData = _game.WorldData; List edgeHolograms = worldData.GetDataLocs("BLACK"); List shopHolograms = worldData.GetDataLocs("GRAY"); + List chestLocations = worldData.GetCustomLocs(String.valueOf(Material.CHEST.getId())); _game.GetTeamList().forEach(team -> { @@ -97,6 +100,10 @@ public class CakeTeamModule extends CakeModule UtilAlg.findClosest( average, shopHolograms + ), + UtilAlg.findClosest( + average, + chestLocations ) ) ); @@ -201,6 +208,37 @@ public class CakeTeamModule extends CakeModule event.setCancelled(true); } + @EventHandler + public void chestInteract(PlayerInteractEvent event) + { + if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) + { + return; + } + + Player player = event.getPlayer(); + Location block = event.getClickedBlock().getLocation(); + + if (UtilPlayer.isSpectator(player)) + { + return; + } + + GameTeam team = _game.GetTeam(player); + + for (CakeTeam cakeTeam : _teams.values()) + { + if (!cakeTeam.canRespawn() || !cakeTeam.getChest().equals(block) || team.equals(cakeTeam.getGameTeam())) + { + continue; + } + + event.setCancelled(true); + player.sendMessage(F.main("Game", "You cannot open another team's chest while their Cake hasn't been eaten.")); + return; + } + } + @EventHandler public void kitGiveItems(PlayerKitGiveEvent event) {