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

46 lines
1.9 KiB
Java
Raw Normal View History

package me.totalfreedom.totalfreedommod.command;
2014-05-11 17:03:11 +00:00
import java.io.File;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Bukkit;
import org.bukkit.World;
2014-05-11 17:03:11 +00:00
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
2020-08-15 22:42:46 +00:00
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
@CommandParameters(description = "Removes all essentials playerdata", usage = "/<command>")
public class Command_wipeuserdata extends FreedomCommand
2014-05-11 17:03:11 +00:00
{
2014-05-11 17:03:11 +00:00
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
2014-05-11 17:03:11 +00:00
{
if (!server.getPluginManager().isPluginEnabled("Essentials"))
{
msg("Essentials is not enabled on this server.");
2014-05-11 17:03:11 +00:00
return true;
}
2020-08-15 22:42:46 +00:00
FUtil.staffAction(sender.getName(), "Wiping Essentials and worlds playerdata", true);
2014-05-11 17:03:11 +00:00
for (World w : Bukkit.getWorlds())
{
2020-08-15 22:42:46 +00:00
if (w.getName().equals(plugin.wm.staffworld.getWorld().getName()))
{
continue;
}
FUtil.deleteFolder(new File(server.getPluginManager().getPlugin("Essentials").getDataFolder(), "userdata"));
FUtil.deleteFolder(new File(Bukkit.getServer().getWorld(plugin.wm.flatlands.getName()).getWorldFolder().getName() + "playerdata"));
FUtil.deleteFolder(new File(Bukkit.getServer().getWorld(plugin.wm.flatlands.getName()).getWorldFolder().getName() + "stats"));
FUtil.deleteFolder(new File(Bukkit.getServer().getWorld(w.getName()).getWorldFolder().getName() + "stats"));
FUtil.deleteFolder(new File(Bukkit.getServer().getWorld(w.getName()).getWorldFolder().getName() + "playerdata"));
msg("All playerdata deleted.");
return true;
}
return false;
2014-05-11 17:03:11 +00:00
}
}