diff options
author | KHobbits <rob@khobbits.co.uk> | 2012-09-14 02:30:24 +0100 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2012-09-14 02:30:24 +0100 |
commit | cc0a65bacefded3ef91282c77653bfbf1f1e4668 (patch) | |
tree | 33be05139846d4e018537d7f47aa5320e8d54232 /Essentials | |
parent | d988546ef31fda13d8113bd30401931e73793da3 (diff) | |
download | Essentials-cc0a65bacefded3ef91282c77653bfbf1f1e4668.tar Essentials-cc0a65bacefded3ef91282c77653bfbf1f1e4668.tar.gz Essentials-cc0a65bacefded3ef91282c77653bfbf1f1e4668.tar.lz Essentials-cc0a65bacefded3ef91282c77653bfbf1f1e4668.tar.xz Essentials-cc0a65bacefded3ef91282c77653bfbf1f1e4668.zip |
/ess reset <player> - Clears stored data about a user.
Diffstat (limited to 'Essentials')
-rw-r--r-- | Essentials/src/com/earth2me/essentials/UserData.java | 11 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandessentials.java | 16 |
2 files changed, 25 insertions, 2 deletions
diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java index 383c0ccf4..be25cf665 100644 --- a/Essentials/src/com/earth2me/essentials/UserData.java +++ b/Essentials/src/com/earth2me/essentials/UserData.java @@ -13,13 +13,14 @@ import org.bukkit.inventory.ItemStack; public abstract class UserData extends PlayerExtension implements IConf { protected final transient IEssentials ess; - private final EssentialsConf config; + private EssentialsConf config; + private final File folder; protected UserData(Player base, IEssentials ess) { super(base); this.ess = ess; - File folder = new File(ess.getDataFolder(), "userdata"); + folder = new File(ess.getDataFolder(), "userdata"); if (!folder.exists()) { folder.mkdirs(); @@ -27,6 +28,12 @@ public abstract class UserData extends PlayerExtension implements IConf config = new EssentialsConf(new File(folder, Util.sanitizeFileName(base.getName()) + ".yml")); reloadConfig(); } + + public final void reset () { + config.getFile().delete(); + config = new EssentialsConf(new File(folder, Util.sanitizeFileName(base.getName()) + ".yml")); + reloadConfig(); + } @Override public final void reloadConfig() diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java index d030ec5fb..fe33aebd7 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java @@ -1,6 +1,7 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; +import com.earth2me.essentials.User; import com.earth2me.essentials.metrics.Metrics; import java.io.IOException; import java.util.HashMap; @@ -41,6 +42,10 @@ public class Commandessentials extends EssentialsCommand { run_moo(server, sender, commandLabel, args); } + else if (args[0].equalsIgnoreCase("reset")) + { + run_reset(server, sender, commandLabel, args); + } else if (args[0].equalsIgnoreCase("opt-out")) { run_optout(server, sender, commandLabel, args); @@ -69,6 +74,17 @@ public class Commandessentials extends EssentialsCommand } } + private void run_reset(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + { + if (args.length < 2) + { + throw new NotEnoughArgumentsException("/<command> reset <player>"); + } + final User user = getPlayer(server, args, 1, true); + user.reset(); + sender.sendMessage("Reset Essentials userdata for player: " + user.getDisplayName()); + } + private void run_debug(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { ess.getSettings().setDebug(!ess.getSettings().isDebug()); |