Creative kill applies outside spawn

This commit is contained in:
alisolarflare 2016-12-26 23:23:47 -05:00
parent a026fc5e60
commit f665665fcd
2 changed files with 39 additions and 28 deletions

View file

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

View file

@ -1,6 +1,7 @@
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;
@ -16,12 +17,21 @@ public class CreativeKillLoop extends BukkitRunnable implements Listener {
@Override
public void run() {
Location location;
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);
}
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);
}
}
}