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.architecture.Component;
import buttondevteam.alipresents.components.hotfix.hotfixes.CowSpawnLoop; 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.GrassBreakListener;
import buttondevteam.alipresents.components.hotfix.hotfixes.MobKillListener; import buttondevteam.alipresents.components.hotfix.hotfixes.MobKillListener;
import buttondevteam.alipresents.components.hotfix.hotfixes.NetherDisableListener; import buttondevteam.alipresents.components.hotfix.hotfixes.NetherDisableListener;
@ -19,7 +20,7 @@ public class HotfixComponent extends Component {
registerListener(plugin, new CowSpawnLoop(plugin)); registerListener(plugin, new CowSpawnLoop(plugin));
registerListener(plugin, new MobKillListener((Essentials) Bukkit.getPluginManager().getPlugin("Essentials"))); registerListener(plugin, new MobKillListener((Essentials) Bukkit.getPluginManager().getPlugin("Essentials")));
registerListener(plugin, new GrassBreakListener()); registerListener(plugin, new GrassBreakListener());
//registerListener(plugin, new CreativeKillLoop(plugin)); registerListener(plugin, new CreativeKillLoop(plugin));
} }

View file

@ -1,27 +1,37 @@
package buttondevteam.alipresents.components.hotfix.hotfixes; package buttondevteam.alipresents.components.hotfix.hotfixes;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.entity.Player; import org.bukkit.Location;
import org.bukkit.event.Listener; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.event.Listener;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
public class CreativeKillLoop extends BukkitRunnable implements Listener {
private JavaPlugin plugin; public class CreativeKillLoop extends BukkitRunnable implements Listener {
private JavaPlugin plugin;
public CreativeKillLoop(JavaPlugin plugin){
this.plugin = plugin; public CreativeKillLoop(JavaPlugin plugin){
this.runTaskTimer(plugin, 40, 40); this.plugin = plugin;
} this.runTaskTimer(plugin, 40, 40);
}
@Override
public void run() { @Override
for (Player player : plugin.getServer().getOnlinePlayers()){ public void run() {
if(player.getGameMode() != GameMode.SURVIVAL && player.getWorld().getName().equalsIgnoreCase("world") && player.isOp() == false){ Location location;
player.sendMessage("[Hotfix] Every Gamemode other than survival is disabled in the new world!"); for (Player player : plugin.getServer().getOnlinePlayers()){
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);
}
}
}