2016-03-02 19:28:01 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
2013-05-16 06:59:08 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
2016-03-06 15:56:15 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
2019-12-24 03:26:40 +00:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.World;
|
2013-05-16 06:59:08 +00:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
2019-12-24 03:26:40 +00:00
|
|
|
import org.bukkit.entity.Entity;
|
2013-05-16 06:59:08 +00:00
|
|
|
import org.bukkit.entity.Player;
|
2013-07-02 20:31:05 +00:00
|
|
|
import org.bukkit.potion.PotionEffect;
|
2013-05-16 06:59:08 +00:00
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
@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>")
|
2015-10-19 17:43:46 +00:00
|
|
|
public class Command_purgeall extends FreedomCommand
|
2013-05-16 06:59:08 +00:00
|
|
|
{
|
2015-11-22 18:26:47 +00:00
|
|
|
|
2013-05-16 06:59:08 +00:00
|
|
|
@Override
|
2015-11-22 18:26:47 +00:00
|
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
2013-05-16 06:59:08 +00:00
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
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())
|
|
|
|
{
|
|
|
|
entity.remove();
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
{
|
2015-11-15 23:32:04 +00:00
|
|
|
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
2013-07-02 20:31:05 +00:00
|
|
|
|
|
|
|
// Unmute all players
|
2015-11-15 23:32:04 +00:00
|
|
|
if (fPlayer.isMuted())
|
2013-07-02 20:31:05 +00:00
|
|
|
{
|
2015-11-15 23:32:04 +00:00
|
|
|
fPlayer.setMuted(false);
|
2013-07-02 20:31:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Unblock all commands
|
2015-11-15 23:32:04 +00:00
|
|
|
if (fPlayer.allCommandsBlocked())
|
2013-07-02 20:31:05 +00:00
|
|
|
{
|
2015-11-15 23:32:04 +00:00
|
|
|
fPlayer.setCommandsBlocked(false);
|
2013-07-02 20:31:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Stop orbiting
|
2015-11-15 23:32:04 +00:00
|
|
|
if (fPlayer.isOrbiting())
|
2013-07-02 20:31:05 +00:00
|
|
|
{
|
2015-11-15 23:32:04 +00:00
|
|
|
fPlayer.stopOrbiting();
|
2013-07-02 20:31:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Unfreeze
|
2015-11-15 23:32:04 +00:00
|
|
|
if (fPlayer.getFreezeData().isFrozen())
|
2013-07-02 20:31:05 +00:00
|
|
|
{
|
2015-11-15 23:32:04 +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
|
|
|
}
|
2013-07-27 21:49:25 +00:00
|
|
|
|
|
|
|
// Uncage
|
2015-11-15 23:32:04 +00:00
|
|
|
if (fPlayer.getCageData().isCaged())
|
2013-07-27 21:49:25 +00:00
|
|
|
{
|
2015-11-15 23:32:04 +00:00
|
|
|
fPlayer.getCageData().setCaged(false);
|
2013-07-27 21:49:25 +00:00
|
|
|
}
|
2013-07-02 20:31:05 +00:00
|
|
|
}
|
|
|
|
|
2014-11-20 22:20:31 +00:00
|
|
|
// Unfreeze all players
|
2015-11-15 23:32:04 +00:00
|
|
|
plugin.fm.setGlobalFreeze(false);
|
2013-07-02 20:31:05 +00:00
|
|
|
|
|
|
|
// Remove all mobs
|
2019-01-28 01:49:07 +00:00
|
|
|
Command_mobpurge.purgeMobs(null);
|
2013-05-16 06:59:08 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2013-05-16 18:18:39 +00:00
|
|
|
}
|