TotalFreedomMod/src/me/StevenLawson/TotalFreedomMod/Commands/Command_purgeall.java

80 lines
2.3 KiB
Java
Raw Normal View History

package me.StevenLawson.TotalFreedomMod.Commands;
2013-07-02 20:31:05 +00:00
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
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 = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Superadmin command - Purge everything! (except for bans).", usage = "/<command>")
public class Command_purgeall extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
2013-07-02 20:31:05 +00:00
TFM_Util.adminAction(sender.getName(), "Purging all player data", true);
// Purge entities
TFM_Util.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
{
2013-08-14 14:01:42 +00:00
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(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
}