From f665665fcd4f678bcc18629ddf1c0e93b0fe2c6f Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Mon, 26 Dec 2016 23:23:47 -0500 Subject: [PATCH] Creative kill applies outside spawn --- .../components/hotfix/HotfixComponent.java | 3 +- .../hotfix/hotfixes/CreativeKillLoop.java | 64 +++++++++++-------- 2 files changed, 39 insertions(+), 28 deletions(-) diff --git a/src/buttondevteam/alipresents/components/hotfix/HotfixComponent.java b/src/buttondevteam/alipresents/components/hotfix/HotfixComponent.java index c9ac0c2..708d127 100644 --- a/src/buttondevteam/alipresents/components/hotfix/HotfixComponent.java +++ b/src/buttondevteam/alipresents/components/hotfix/HotfixComponent.java @@ -7,6 +7,7 @@ import com.earth2me.essentials.Essentials; import buttondevteam.alipresents.architecture.Component; import buttondevteam.alipresents.components.hotfix.hotfixes.CowSpawnLoop; +import buttondevteam.alipresents.components.hotfix.hotfixes.CreativeKillLoop; import buttondevteam.alipresents.components.hotfix.hotfixes.GrassBreakListener; import buttondevteam.alipresents.components.hotfix.hotfixes.MobKillListener; import buttondevteam.alipresents.components.hotfix.hotfixes.NetherDisableListener; @@ -19,7 +20,7 @@ public class HotfixComponent extends Component { registerListener(plugin, new CowSpawnLoop(plugin)); registerListener(plugin, new MobKillListener((Essentials) Bukkit.getPluginManager().getPlugin("Essentials"))); registerListener(plugin, new GrassBreakListener()); - //registerListener(plugin, new CreativeKillLoop(plugin)); + registerListener(plugin, new CreativeKillLoop(plugin)); } diff --git a/src/buttondevteam/alipresents/components/hotfix/hotfixes/CreativeKillLoop.java b/src/buttondevteam/alipresents/components/hotfix/hotfixes/CreativeKillLoop.java index e90ea0a..7e759b2 100644 --- a/src/buttondevteam/alipresents/components/hotfix/hotfixes/CreativeKillLoop.java +++ b/src/buttondevteam/alipresents/components/hotfix/hotfixes/CreativeKillLoop.java @@ -1,27 +1,37 @@ -package buttondevteam.alipresents.components.hotfix.hotfixes; - -import org.bukkit.GameMode; -import org.bukkit.entity.Player; -import org.bukkit.event.Listener; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.scheduler.BukkitRunnable; - -public class CreativeKillLoop extends BukkitRunnable implements Listener { - private JavaPlugin plugin; - - public CreativeKillLoop(JavaPlugin plugin){ - this.plugin = plugin; - this.runTaskTimer(plugin, 40, 40); - } - - @Override - public void run() { - for (Player player : plugin.getServer().getOnlinePlayers()){ - if(player.getGameMode() != GameMode.SURVIVAL && player.getWorld().getName().equalsIgnoreCase("world") && player.isOp() == false){ - player.sendMessage("[Hotfix] Every Gamemode other than survival is disabled in the new world!"); - player.setGameMode(GameMode.SURVIVAL); - } - } - } - -} +package buttondevteam.alipresents.components.hotfix.hotfixes; + +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.Listener; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; + +public class CreativeKillLoop extends BukkitRunnable implements Listener { + private JavaPlugin plugin; + + public CreativeKillLoop(JavaPlugin plugin){ + this.plugin = plugin; + this.runTaskTimer(plugin, 40, 40); + } + + @Override + public void run() { + Location location; + for (Player player : plugin.getServer().getOnlinePlayers()){ + if (player.getGameMode() == GameMode.SURVIVAL) continue; + if (player.getWorld().getName().equalsIgnoreCase("world")) continue; + if (player.isOp()) continue; + + location = player.getLocation(); + if (250 > location.getBlockX() && location.getBlockX() > -250) continue; + if (250 > location.getBlockZ() && location.getBlockZ() > -250) continue; + + player.sendMessage("[Hotfix] Every Gamemode other than survival is disabled in the new world!"); + player.setGameMode(GameMode.SURVIVAL); + + } + + } + +}