diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java index 0bce76706..96c733f8b 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java @@ -59,6 +59,7 @@ import mineplex.gemhunters.scoreboard.ScoreboardModule; import mineplex.gemhunters.shop.ShopModule; import mineplex.gemhunters.spawn.SpawnModule; import mineplex.gemhunters.supplydrop.SupplyDropModule; +import mineplex.gemhunters.world.WorldListeners; import mineplex.gemhunters.worldevent.WorldEventModule; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.condition.ConditionManager; @@ -218,6 +219,8 @@ public class GemHunters extends JavaPlugin require(SupplyDropModule.class); require(WorldEventModule.class); + new WorldListeners(this); + // UpdateEvent!!! new Updater(this); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/WorldListeners.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/WorldListeners.java new file mode 100644 index 000000000..c4511d7b9 --- /dev/null +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/world/WorldListeners.java @@ -0,0 +1,42 @@ +package mineplex.gemhunters.world; + +import org.bukkit.GameMode; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.plugin.java.JavaPlugin; + +public class WorldListeners implements Listener +{ + + public WorldListeners(JavaPlugin plugin) + { + plugin.getServer().getPluginManager().registerEvents(this, plugin); + } + + @EventHandler + public void blockBreak(BlockBreakEvent event) + { + if (shouldBlock(event.getPlayer())) + { + event.setCancelled(true); + } + } + + @EventHandler + public void blockPlace(BlockPlaceEvent event) + { + if (shouldBlock(event.getPlayer())) + { + event.setCancelled(true); + } + } + + public boolean shouldBlock(Player player) + { + return player.getGameMode() != GameMode.CREATIVE; + } + +}