World Listeners

This commit is contained in:
Sam 2017-01-21 14:46:05 +00:00
parent 24d71e09fe
commit 0827ea2da0
2 changed files with 45 additions and 0 deletions

View File

@ -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);

View File

@ -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;
}
}