TotalFreedomMod/src/me/totalfreedom/totalfreedommod/commands/Command_purgeall.java

81 lines
2.4 KiB
Java
Raw Normal View History

package me.totalfreedom.totalfreedommod.commands;
import me.totalfreedom.totalfreedommod.permission.PlayerRank;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
2013-07-02 20:31:05 +00:00
import org.bukkit.potion.PotionEffect;
@CommandPermissions(level = PlayerRank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Superadmin command - Purge everything! (except for bans).", usage = "/<command>")
public class Command_purgeall extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
FUtil.adminAction(sender.getName(), "Purging all player data", true);
2013-07-02 20:31:05 +00:00
// Purge entities
FUtil.TFM_EntityWiper.wipeEntities(true, true);
2013-07-02 20:31:05 +00:00
2013-08-14 14:01:42 +00:00
for (Player player : server.getOnlinePlayers())
2013-07-02 20:31:05 +00:00
{
FPlayer playerdata = plugin.pl.getPlayer(player);
2013-07-02 20:31:05 +00:00
// Unmute all players
if (playerdata.isMuted())
{
playerdata.setMuted(false);
}
// Unblock all commands
if (playerdata.allCommandsBlocked())
{
playerdata.setCommandsBlocked(false);
}
// Unhalt all players
if (playerdata.isHalted())
{
playerdata.setHalted(false);
}
// Stop orbiting
if (playerdata.isOrbiting())
{
playerdata.stopOrbiting();
}
// Unfreeze
if (playerdata.isFrozen())
{
playerdata.setFrozen(false);
}
// Purge potion effects
2013-08-14 14:01:42 +00:00
for (PotionEffect potion_effect : player.getActivePotionEffects())
2013-07-02 20:31:05 +00:00
{
2013-08-14 14:01:42 +00:00
player.removePotionEffect(potion_effect.getType());
2013-07-02 20:31:05 +00:00
}
// Uncage
if (playerdata.isCaged())
{
playerdata.setCaged(false);
playerdata.regenerateHistory();
playerdata.clearHistory();
}
2013-07-02 20:31:05 +00:00
}
// Unfreeze all players
Command_fr.setAllFrozen(false);
2013-07-02 20:31:05 +00:00
// Remove all mobs
Command_mp.purgeMobs();
return true;
}
2013-05-16 18:18:39 +00:00
}