Created at 23.11.2020 + *
Created at 23.11.2020 */ public class PluginEvents implements Listener { @@ -49,9 +55,28 @@ public PluginEvents(Main plugin) { plugin.getServer().getPluginManager().registerEvents(this, plugin); } + @EventHandler + public void onJoinCheckBases(PlayerJoinEvent event) { + if(!event.getPlayer().hasPermission(plugin.getPluginNamePrefixLong() + ".admin") || !event.getPlayer().isOp()) { + return; + } + Bukkit.getScheduler().runTaskLater(plugin, () -> { + for(Arena arena : plugin.getArenaRegistry().getPluginArenas()) { + for(Base base : arena.getBases()) { + if(!(arena.getArenaBorder().isIn(base.getBaseCuboid().getMinPoint()) && (arena.getArenaBorder().isIn(base.getBaseCuboid().getMaxPoint())))) { + event.getPlayer().sendMessage(""); + event.getPlayer().sendMessage(ChatColor.BOLD + plugin.getPluginMessagePrefix() + "Your arena setup is broken. Please adjust your arena cuboid."); + event.getPlayer().sendMessage(new MessageBuilder("VALIDATOR_INVALID_ARENA_CONFIGURATION").asKey().arena(arena).value("YOUR BASE CUBOIDS ARE NOT INSIDE ARENA CUBOID").build()); + event.getPlayer().sendMessage(ChatColor.YELLOW + plugin.getPluginMessagePrefix() + "[CHECK BASE INSIDE ARENA] " + arena.getId() + base.getColor() + " Locations amin" + arena.getArenaBorder().getMinPoint() + "amax" + arena.getArenaBorder().getMaxPoint() + "bmin" + base.getBaseCuboid().getMinPoint() + "bma" + base.getBaseCuboid().getMaxPoint()); + } + } + } + }, 25); + } + @EventHandler public void onDrop(PlayerDropItemEvent event) { - if (plugin.getArenaRegistry().isInArena(event.getPlayer())) { + if(plugin.getArenaRegistry().isInArena(event.getPlayer())) { event.setCancelled(true); } } @@ -60,10 +85,10 @@ public void onDrop(PlayerDropItemEvent event) { public void onAppleConsume(PlayerItemConsumeEvent event) { Player player = event.getPlayer(); Arena arena = plugin.getArenaRegistry().getArena(player); - if (arena == null) { + if(arena == null) { return; } - if (event.getItem().getType() == XMaterial.GOLDEN_APPLE.parseMaterial()) { + if(event.getItem().getType() == XMaterial.GOLDEN_APPLE.parseMaterial()) { player.setFoodLevel(20); player.setHealth(VersionUtils.getMaxHealth(player)); player.removePotionEffect(XPotion.REGENERATION.getPotionEffectType()); @@ -73,9 +98,9 @@ public void onAppleConsume(PlayerItemConsumeEvent event) { @EventHandler(priority = EventPriority.HIGH) // highest priority to fully protect our game public void onBlockBreakEvent(BlockBreakEvent event) { - if (plugin.getArenaRegistry().isInArena(event.getPlayer()) - && plugin.getArenaRegistry().getArena(event.getPlayer()).getArenaState() - != IArenaState.IN_GAME) { + if(plugin.getArenaRegistry().isInArena(event.getPlayer()) + && plugin.getArenaRegistry().getArena(event.getPlayer()).getArenaState() + != IArenaState.IN_GAME) { event.setCancelled(true); } } @@ -83,22 +108,22 @@ public void onBlockBreakEvent(BlockBreakEvent event) { @EventHandler(priority = EventPriority.HIGH) // highest priority to fully protect our game public void onBuild(BlockPlaceEvent event) { - if (plugin.getArenaRegistry().isInArena(event.getPlayer()) - && plugin.getArenaRegistry().getArena(event.getPlayer()).getArenaState() - != IArenaState.IN_GAME) { + if(plugin.getArenaRegistry().isInArena(event.getPlayer()) + && plugin.getArenaRegistry().getArena(event.getPlayer()).getArenaState() + != IArenaState.IN_GAME) { event.setCancelled(true); } } @EventHandler public void onPlayerTeleport(PlayerTeleportEvent event) { - if (!plugin.getArenaRegistry().isInArena(event.getPlayer())) { + if(!plugin.getArenaRegistry().isInArena(event.getPlayer())) { return; } - if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)) { + if(event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)) { event.setCancelled(true); } - if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL)) { + if(event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL)) { event.setCancelled(true); } } diff --git a/src/main/java/plugily/projects/thebridge/handlers/setup/LocationCategory.java b/src/main/java/plugily/projects/thebridge/handlers/setup/LocationCategory.java index 832ca08b..a6950404 100644 --- a/src/main/java/plugily/projects/thebridge/handlers/setup/LocationCategory.java +++ b/src/main/java/plugily/projects/thebridge/handlers/setup/LocationCategory.java @@ -42,7 +42,7 @@ public void addItems(NormalFastInv gui) { gui.setItem((getInventoryLine() * 9) + 4, midLocation); getItemList().add(midLocation); - LocationSelectorItem arenaBorder = new LocationSelectorItem(getSetupInventory(), new ItemBuilder(XMaterial.BEDROCK.parseMaterial()), "Arena", "Location where all bases and lines are in \n (players will be able to build inside)", "arenalocation"); + LocationSelectorItem arenaBorder = new LocationSelectorItem(getSetupInventory(), new ItemBuilder(XMaterial.BEDROCK.parseMaterial()), "Arena", "Location where all bases and lines are in \n (players will be able to build inside) \n MAKE SURE TO SET IT OUTSIDE \n OF THE BASES WHICH YOU SET BEFORE!", "arenalocation"); gui.setItem((getInventoryLine() * 9) + 5, arenaBorder); getItemList().add(arenaBorder); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index d50f71cc..1b86c940 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -98,6 +98,9 @@ Block: # Setting it to false means on all stages of the game the event will be cancelled. # Setting it to true means only while IN_GAME the event will be cancelled. Check: true + # Should all interactions with interactive materials such as doors / buttons / fences / redstone be blocked during ingame + # Full list see https://github.com/CryptoMorin/XSeries/blob/e84000a2bead7367d893cf8661f8d5432116adaa/core/src/main/java/com/cryptomorin/xseries/XTag.java#L2793 + Interact: false # Enable this option when you're using MySQL, otherwise it won't work. @@ -210,6 +213,9 @@ Natural-Regeneration: false # Should blocks when broken drop items during a game Block-Break-Drop: true +# How long should be the blindness effect after death? +Death: + Blindness: 30 # Settings about cages on all bases Cage: @@ -230,5 +236,5 @@ Update-Notifier: # Really, don't edit ;p # You edited it, huh? Next time hurt yourself! Do-Not-Edit: - File-Version: 2 - Core-Version: 5 + File-Version: 3 + Core-Version: 6