TotalFreedomMod/src/main/java/me/totalfreedom/totalfreedommod/command/Command_purgeall.java

86 lines
2.4 KiB
Java
Raw Normal View History

package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
2019-12-24 03:26:40 +00:00
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
2019-12-24 03:26:40 +00:00
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
2013-07-02 20:31:05 +00:00
import org.bukkit.potion.PotionEffect;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
2018-07-25 22:06:19 +00:00
@CommandParameters(description = "Purge everything! (except for bans).", usage = "/<command>")
public class Command_purgeall extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, 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
2019-12-24 03:26:40 +00:00
for (World world : Bukkit.getWorlds())
{
for (Entity entity : world.getEntities())
{
2019-12-24 04:21:52 +00:00
if (!(entity instanceof Player))
{
entity.remove();
}
2019-12-24 03:26:40 +00:00
}
}
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 fPlayer = plugin.pl.getPlayer(player);
2013-07-02 20:31:05 +00:00
// Unmute all players
if (fPlayer.isMuted())
2013-07-02 20:31:05 +00:00
{
fPlayer.setMuted(false);
2013-07-02 20:31:05 +00:00
}
// Unblock all commands
if (fPlayer.allCommandsBlocked())
2013-07-02 20:31:05 +00:00
{
fPlayer.setCommandsBlocked(false);
2013-07-02 20:31:05 +00:00
}
// Stop orbiting
if (fPlayer.isOrbiting())
2013-07-02 20:31:05 +00:00
{
fPlayer.stopOrbiting();
2013-07-02 20:31:05 +00:00
}
// Unfreeze
if (fPlayer.getFreezeData().isFrozen())
2013-07-02 20:31:05 +00:00
{
fPlayer.getFreezeData().setFrozen(false);
2013-07-02 20:31:05 +00:00
}
// 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 (fPlayer.getCageData().isCaged())
{
fPlayer.getCageData().setCaged(false);
}
2013-07-02 20:31:05 +00:00
}
// Unfreeze all players
plugin.fm.setGlobalFreeze(false);
2013-07-02 20:31:05 +00:00
// Remove all mobs
2020-01-25 06:27:16 +00:00
plugin.ew.purgeMobs(null);
return true;
}
2013-05-16 18:18:39 +00:00
}