mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-27 21:26:29 +01:00
Add /questsadmin reset command
This commit is contained in:
parent
21b0a8ade8
commit
6bb17a08f4
@ -336,6 +336,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_NEXTSTAGE"), 3); // nextstage [player] [quest]
|
||||
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_SETSTAGE"), 4); // setstage [player] [quest] [stage]
|
||||
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_PURGE"), 2); // purge [player]
|
||||
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_RESET"), 2); // purge [player]
|
||||
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_TOGGLEGUI"), 2); // togglegui [npc id]
|
||||
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_RELOAD"), 1); // reload
|
||||
|
||||
@ -847,6 +848,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
|
||||
adminPurge(cs, args);
|
||||
|
||||
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_RESET"))) {
|
||||
|
||||
adminReset(cs, args);
|
||||
|
||||
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUESTADMIN_STATS"))) {
|
||||
|
||||
adminStats(cs, args);
|
||||
@ -1582,6 +1587,44 @@ try{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void adminReset(final CommandSender cs, String[] args) {
|
||||
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.reset")) {
|
||||
|
||||
Quester quester = getQuester(args[1]);
|
||||
|
||||
if (quester == null) {
|
||||
cs.sendMessage(YELLOW + Lang.get("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
quester.hardClear();
|
||||
quester.saveData();
|
||||
quester.updateJournal();
|
||||
final File dataFolder = new File(this.getDataFolder(), "data/");
|
||||
final File found = new File(dataFolder, quester.id + ".yml");
|
||||
found.delete();
|
||||
|
||||
String msg = Lang.get("questReset");
|
||||
if (Bukkit.getOfflinePlayer(quester.id).getName() != null) {
|
||||
msg = msg.replaceAll("<player>", GREEN + Bukkit.getOfflinePlayer(quester.id).getName() + GOLD);
|
||||
} else {
|
||||
msg = msg.replaceAll("<player>", GREEN + args[1] + GOLD);
|
||||
}
|
||||
cs.sendMessage(GOLD + msg);
|
||||
cs.sendMessage(PURPLE + " UUID: " + DARKAQUA + quester.id);
|
||||
} catch (Exception e) {
|
||||
getLogger().info("Data file does not exist for " + quester.id.toString());
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
cs.sendMessage(RED + Lang.get("questCmdNoPerms"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void adminStats(final CommandSender cs, String[] args) {
|
||||
|
||||
@ -2492,6 +2535,7 @@ try{
|
||||
cs.sendMessage(DARKRED + "/questadmin " + RED + Lang.get("COMMAND_QUESTADMIN_NEXTSTAGE_HELP"));
|
||||
cs.sendMessage(DARKRED + "/questadmin " + RED + Lang.get("COMMAND_QUESTADMIN_SETSTAGE_HELP"));
|
||||
cs.sendMessage(DARKRED + "/questadmin " + RED + Lang.get("COMMAND_QUESTADMIN_PURGE_HELP"));
|
||||
cs.sendMessage(DARKRED + "/questadmin " + RED + Lang.get("COMMAND_QUESTADMIN_RESET_HELP"));
|
||||
cs.sendMessage(DARKRED + "/questadmin " + RED + Lang.get("COMMAND_QUESTADMIN_REMOVE_HELP"));
|
||||
cs.sendMessage(DARKRED + "/questadmin " + RED + Lang.get("COMMAND_QUESTADMIN_TOGGLEGUI_HELP"));
|
||||
cs.sendMessage(DARKRED + "/questadmin " + RED + Lang.get("COMMAND_QUESTADMIN_RELOAD_HELP"));
|
||||
@ -2529,6 +2573,9 @@ try{
|
||||
if (cs.hasPermission("quests.admin.purge")) {
|
||||
cs.sendMessage(DARKRED + "/questadmin " + RED + Lang.get("COMMAND_QUESTADMIN_PURGE_HELP"));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.reset")) {
|
||||
cs.sendMessage(DARKRED + "/questadmin " + RED + Lang.get("COMMAND_QUESTADMIN_RESET_HELP"));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.remove")) {
|
||||
cs.sendMessage(DARKRED + "/questadmin " + RED + Lang.get("COMMAND_QUESTADMIN_REMOVE_HELP"));
|
||||
}
|
||||
|
@ -162,7 +162,10 @@ public class Lang {
|
||||
langMap.put("COMMAND_QUESTADMIN_SETSTAGE_USAGE", "Usage: /questadmin setstage [player] [quest] [stage]");
|
||||
|
||||
langMap.put("COMMAND_QUESTADMIN_PURGE", "purge");
|
||||
langMap.put("COMMAND_QUESTADMIN_PURGE_HELP", "purge [player] - Clear all Quests data of a player");
|
||||
langMap.put("COMMAND_QUESTADMIN_PURGE_HELP", "purge [player] - Clear all Quests data of a player AND BLACKLISTS THEM");
|
||||
|
||||
langMap.put("COMMAND_QUESTADMIN_RESET", "reset");
|
||||
langMap.put("COMMAND_QUESTADMIN_RESET_HELP", "reset [player] - Clear all Quests data of a player");
|
||||
|
||||
langMap.put("COMMAND_QUESTADMIN_REMOVE", "remove");
|
||||
langMap.put("COMMAND_QUESTADMIN_REMOVE_HELP", "remove [player] [quest] - Remove a completed Quest from a player");
|
||||
@ -927,6 +930,7 @@ public class Lang {
|
||||
langMap.put("questForceNextStage", "<player> has advanced to the next Stage in the Quest <quest>.");
|
||||
langMap.put("questForcedNextStage", "<player> has advanced you to the next Stage in your Quest <quest>.");
|
||||
langMap.put("questPurged", "<player> has been purged and blacklisted.");
|
||||
langMap.put("questReset", "<player> has been reset.");
|
||||
langMap.put("questRemoved", "Quest <quest> has been removed from player <player>'s completed Quests.");
|
||||
langMap.put("settingAllQuestPoints", "Setting all players' Quest Points...");
|
||||
langMap.put("allQuestPointsSet", "All players' Quest Points have been set to <number>!");
|
||||
|
@ -68,6 +68,9 @@ permissions:
|
||||
description: Immediately force Stage completion for a player
|
||||
default: op
|
||||
quests.admin.purge:
|
||||
description: Clear all Quests data of a player AND BLACKLISTS THEM
|
||||
default: op
|
||||
quests.admin.reset:
|
||||
description: Clear all Quests data of a player
|
||||
default: op
|
||||
quests.admin.remove:
|
||||
|
Loading…
Reference in New Issue
Block a user