Fully disabled Creative in World

This commit is contained in:
alisolarflare 2016-12-21 19:02:48 -05:00
parent 341fb1be2e
commit 4cf65fefa1
2 changed files with 30 additions and 0 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,6 +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));
}

View file

@ -0,0 +1,28 @@
package buttondevteam.alipresents.components.hotfix.hotfixes;
import org.bukkit.GameMode;
import org.bukkit.Server;
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 Server server;
public CreativeKillLoop(JavaPlugin plugin){
this.server = plugin.getServer();
this.runTaskTimer(plugin, 40, 40);
}
@Override
public void run() {
for (Player player : server.getOnlinePlayers()){
if(player.getGameMode() != GameMode.SURVIVAL && player.getWorld().getName() == "World" && player.isOp() == false){
player.sendMessage("[Hotfix] Every Gamemode other than survival is disabled in the new world!");
player.setGameMode(GameMode.SURVIVAL);
}
}
}
}