Remove blacklist and purge subcommand

This commit is contained in:
HappyPikachu 2018-04-25 02:42:21 -04:00
parent e88d7159fe
commit 172d5ffeee
8 changed files with 99 additions and 191 deletions

View File

@ -19,7 +19,6 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
@ -32,8 +31,6 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.scheduler.BukkitRunnable;
import me.blackvein.quests.util.ItemUtil; import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang; import me.blackvein.quests.util.Lang;
import me.blackvein.quests.util.QuestMob; import me.blackvein.quests.util.QuestMob;

View File

@ -111,7 +111,7 @@ public class EventFactory implements ConversationAbandonedListener {
context.setSessionData(CK.E_OLD_EVENT, ""); context.setSessionData(CK.E_OLD_EVENT, "");
return new EventNamePrompt(); return new EventNamePrompt();
} else { } else {
player.sendMessage(ChatColor.RED + Lang.get("eventEditorCreatePermisssions")); player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
return new MenuPrompt(); return new MenuPrompt();
} }
} else if (input.equalsIgnoreCase("2")) { } else if (input.equalsIgnoreCase("2")) {
@ -123,7 +123,7 @@ public class EventFactory implements ConversationAbandonedListener {
return new SelectEditPrompt(); return new SelectEditPrompt();
} }
} else { } else {
player.sendMessage(ChatColor.RED + Lang.get("eventEditorEditPermisssions")); player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
return new MenuPrompt(); return new MenuPrompt();
} }
} else if (input.equalsIgnoreCase("3")) { } else if (input.equalsIgnoreCase("3")) {
@ -135,7 +135,7 @@ public class EventFactory implements ConversationAbandonedListener {
return new SelectDeletePrompt(); return new SelectDeletePrompt();
} }
} else { } else {
player.sendMessage(ChatColor.RED + Lang.get("eventEditorDeletePermisssions")); player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
return new MenuPrompt(); return new MenuPrompt();
} }
} else if (input.equalsIgnoreCase("4")) { } else if (input.equalsIgnoreCase("4")) {

View File

@ -94,81 +94,79 @@ public class NpcListener implements Listener {
} }
} }
if (plugin.questNPCs.contains(evt.getNPC()) && delivery == false) { if (plugin.questNPCs.contains(evt.getNPC()) && delivery == false) {
if (plugin.checkQuester(player.getUniqueId()) == false) { boolean hasObjective = false;
boolean hasObjective = false; for (Quest quest : quester.currentQuests.keySet()) {
for (Quest quest : quester.currentQuests.keySet()) { if (quester.hasObjective(quest, "talkToNPC")) {
if (quester.hasObjective(quest, "talkToNPC")) { if (quester.getQuestData(quest) != null && quester.getQuestData(quest).citizensInteracted.containsKey(evt.getNPC().getId()) && quester.getQuestData(quest).citizensInteracted.get(evt.getNPC().getId()) == false) {
if (quester.getQuestData(quest) != null && quester.getQuestData(quest).citizensInteracted.containsKey(evt.getNPC().getId()) && quester.getQuestData(quest).citizensInteracted.get(evt.getNPC().getId()) == false) { hasObjective = true;
hasObjective = true;
}
quester.interactWithNPC(quest, evt.getNPC());
} }
quester.interactWithNPC(quest, evt.getNPC());
} }
if (!hasObjective) { }
LinkedList<Quest> npcQuests = new LinkedList<Quest>(); if (!hasObjective) {
for (Quest q : plugin.getQuests()) { LinkedList<Quest> npcQuests = new LinkedList<Quest>();
if (quester.currentQuests.containsKey(q)) for (Quest q : plugin.getQuests()) {
continue; if (quester.currentQuests.containsKey(q))
if (q.npcStart != null && q.npcStart.getId() == evt.getNPC().getId()) { continue;
if (plugin.ignoreLockedQuests && (quester.completedQuests.contains(q.name) == false || q.cooldownPlanner > -1)) { if (q.npcStart != null && q.npcStart.getId() == evt.getNPC().getId()) {
if (q.testRequirements(quester)) { if (plugin.ignoreLockedQuests && (quester.completedQuests.contains(q.name) == false || q.cooldownPlanner > -1)) {
npcQuests.add(q); if (q.testRequirements(quester)) {
}
} else if (quester.completedQuests.contains(q.name) == false || q.cooldownPlanner > -1) {
npcQuests.add(q); npcQuests.add(q);
} }
} else if (quester.completedQuests.contains(q.name) == false || q.cooldownPlanner > -1) {
npcQuests.add(q);
} }
} }
if (npcQuests.isEmpty() == false && npcQuests.size() >= 1) { }
if (plugin.questNPCGUIs.contains(evt.getNPC().getId())) { if (npcQuests.isEmpty() == false && npcQuests.size() >= 1) {
quester.showGUIDisplay(evt.getNPC(), npcQuests); if (plugin.questNPCGUIs.contains(evt.getNPC().getId())) {
return; quester.showGUIDisplay(evt.getNPC(), npcQuests);
} return;
Conversation c = plugin.NPCConversationFactory.buildConversation(player); }
c.getContext().setSessionData("quests", npcQuests); Conversation c = plugin.NPCConversationFactory.buildConversation(player);
c.getContext().setSessionData("npc", evt.getNPC().getName()); c.getContext().setSessionData("quests", npcQuests);
c.begin(); c.getContext().setSessionData("npc", evt.getNPC().getName());
} else if (npcQuests.size() == 1) { c.begin();
Quest q = npcQuests.get(0); } else if (npcQuests.size() == 1) {
if (!quester.completedQuests.contains(q.name)) { Quest q = npcQuests.get(0);
if (quester.currentQuests.size() < plugin.maxQuests || plugin.maxQuests < 1) { if (!quester.completedQuests.contains(q.name)) {
quester.questToTake = q.name; if (quester.currentQuests.size() < plugin.maxQuests || plugin.maxQuests < 1) {
String s = extracted(quester); quester.questToTake = q.name;
for (String msg : s.split("<br>")) { String s = extracted(quester);
player.sendMessage(msg); for (String msg : s.split("<br>")) {
} player.sendMessage(msg);
plugin.conversationFactory.buildConversation(player).begin();
} else if (quester.currentQuests.containsKey(q) == false) {
String msg = Lang.get(player, "questMaxAllowed");
msg = msg.replaceAll("<number>", String.valueOf(plugin.maxQuests));
player.sendMessage(ChatColor.YELLOW + msg);
}
} else if (quester.currentQuests.size() < plugin.maxQuests || plugin.maxQuests < 1) {
if (quester.getDifference(q) > 0) {
String early = Lang.get(player, "questTooEarly");
early = early.replaceAll("<quest>", ChatColor.AQUA + q.name + ChatColor.YELLOW);
early = early.replaceAll("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(q)) + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + early);
} else if (q.cooldownPlanner < 0) {
String completed = Lang.get(player, "questAlreadyCompleted");
completed = completed.replaceAll("<quest>", ChatColor.AQUA + q.name + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + completed);
} else {
quester.questToTake = q.name;
String s = extracted(quester);
for (String msg : s.split("<br>")) {
player.sendMessage(msg);
}
plugin.conversationFactory.buildConversation(player).begin();
} }
plugin.conversationFactory.buildConversation(player).begin();
} else if (quester.currentQuests.containsKey(q) == false) { } else if (quester.currentQuests.containsKey(q) == false) {
String msg = Lang.get(player, "questMaxAllowed"); String msg = Lang.get(player, "questMaxAllowed");
msg = msg.replaceAll("<number>", String.valueOf(plugin.maxQuests)); msg = msg.replaceAll("<number>", String.valueOf(plugin.maxQuests));
player.sendMessage(ChatColor.YELLOW + msg); player.sendMessage(ChatColor.YELLOW + msg);
} }
} else if (npcQuests.isEmpty()) { } else if (quester.currentQuests.size() < plugin.maxQuests || plugin.maxQuests < 1) {
evt.getClicker().sendMessage(ChatColor.YELLOW + Lang.get(player, "noMoreQuest")); if (quester.getDifference(q) > 0) {
String early = Lang.get(player, "questTooEarly");
early = early.replaceAll("<quest>", ChatColor.AQUA + q.name + ChatColor.YELLOW);
early = early.replaceAll("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(q)) + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + early);
} else if (q.cooldownPlanner < 0) {
String completed = Lang.get(player, "questAlreadyCompleted");
completed = completed.replaceAll("<quest>", ChatColor.AQUA + q.name + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + completed);
} else {
quester.questToTake = q.name;
String s = extracted(quester);
for (String msg : s.split("<br>")) {
player.sendMessage(msg);
}
plugin.conversationFactory.buildConversation(player).begin();
}
} else if (quester.currentQuests.containsKey(q) == false) {
String msg = Lang.get(player, "questMaxAllowed");
msg = msg.replaceAll("<number>", String.valueOf(plugin.maxQuests));
player.sendMessage(ChatColor.YELLOW + msg);
} }
} else if (npcQuests.isEmpty()) {
evt.getClicker().sendMessage(ChatColor.YELLOW + Lang.get(player, "noMoreQuest"));
} }
} }
} }

View File

@ -106,21 +106,21 @@ public class QuestFactory implements ConversationAbandonedListener {
if (player.hasPermission("quests.editor.*") || player.hasPermission("quests.editor.create")) { if (player.hasPermission("quests.editor.*") || player.hasPermission("quests.editor.create")) {
return new QuestNamePrompt(); return new QuestNamePrompt();
} else { } else {
player.sendMessage(ChatColor.RED + Lang.get("questEditorNoPermsCreate")); player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
return new MenuPrompt(); return new MenuPrompt();
} }
} else if (input.equalsIgnoreCase("2")) { } else if (input.equalsIgnoreCase("2")) {
if (player.hasPermission("quests.editor.*") || player.hasPermission("quests.editor.edit")) { if (player.hasPermission("quests.editor.*") || player.hasPermission("quests.editor.edit")) {
return new SelectEditPrompt(); return new SelectEditPrompt();
} else { } else {
player.sendMessage(ChatColor.RED + Lang.get("questEditorNoPermsCreate")); player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
return new MenuPrompt(); return new MenuPrompt();
} }
} else if (input.equalsIgnoreCase("3")) { } else if (input.equalsIgnoreCase("3")) {
if (player.hasPermission("quests.editor.*") || player.hasPermission("quests.editor.delete")) { if (player.hasPermission("quests.editor.*") || player.hasPermission("quests.editor.delete")) {
return new SelectDeletePrompt(); return new SelectDeletePrompt();
} else { } else {
player.sendMessage(ChatColor.RED + Lang.get("questEditorNoPermsDelete")); player.sendMessage(ChatColor.RED + Lang.get("noPermission"));
return new MenuPrompt(); return new MenuPrompt();
} }
} else if (input.equalsIgnoreCase("4")) { } else if (input.equalsIgnoreCase("4")) {

View File

@ -70,6 +70,7 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
@ -137,7 +138,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
public HashMap<String, Integer> commands = new HashMap<String, Integer>(); public HashMap<String, Integer> commands = new HashMap<String, Integer>();
public HashMap<String, Integer> adminCommands = new HashMap<String, Integer>(); public HashMap<String, Integer> adminCommands = new HashMap<String, Integer>();
public final Map<UUID, Quester> questers = new HashMap<UUID, Quester>(); public final Map<UUID, Quester> questers = new HashMap<UUID, Quester>();
public final List<String> questerBlacklist = new LinkedList<String>();
public final List<CustomRequirement> customRequirements = new LinkedList<CustomRequirement>(); public final List<CustomRequirement> customRequirements = new LinkedList<CustomRequirement>();
public final List<CustomReward> customRewards = new LinkedList<CustomReward>(); public final List<CustomReward> customRewards = new LinkedList<CustomReward>();
public final List<CustomObjective> customObjectives = new LinkedList<CustomObjective>(); public final List<CustomObjective> customObjectives = new LinkedList<CustomObjective>();
@ -317,7 +317,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_FINISH"), 3); // finish [player] [quest] adminCommands.put(Lang.get("COMMAND_QUESTADMIN_FINISH"), 3); // finish [player] [quest]
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_NEXTSTAGE"), 3); // nextstage [player] [quest] 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_SETSTAGE"), 4); // setstage [player] [quest] [stage]
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_PURGE"), 2); // purge [player]
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_RESET"), 2); // reset [player] adminCommands.put(Lang.get("COMMAND_QUESTADMIN_RESET"), 2); // reset [player]
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_TOGGLEGUI"), 2); // togglegui [npc id] adminCommands.put(Lang.get("COMMAND_QUESTADMIN_TOGGLEGUI"), 2); // togglegui [npc id]
adminCommands.put(Lang.get("COMMAND_QUESTADMIN_RELOAD"), 1); // reload adminCommands.put(Lang.get("COMMAND_QUESTADMIN_RELOAD"), 1); // reload
@ -342,7 +341,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
adminCommands.put("finish", 3); // finish [player] [quest] adminCommands.put("finish", 3); // finish [player] [quest]
adminCommands.put("nextstage", 3); // nextstage [player] [quest] adminCommands.put("nextstage", 3); // nextstage [player] [quest]
adminCommands.put("setstage", 4); // setstage [player] [quest] [stage] adminCommands.put("setstage", 4); // setstage [player] [quest] [stage]
adminCommands.put("purge", 2); // purge [player]
adminCommands.put("reset", 2); // reset [player] adminCommands.put("reset", 2); // reset [player]
adminCommands.put("togglegui", 2); // togglegui [npc id] adminCommands.put("togglegui", 2); // togglegui [npc id]
adminCommands.put("reload", 1); // reload adminCommands.put("reload", 1); // reload
@ -426,10 +424,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
public void onDisable() { public void onDisable() {
getLogger().info("Saving Quester data."); getLogger().info("Saving Quester data.");
for (Player p : getServer().getOnlinePlayers()) { for (Player p : getServer().getOnlinePlayers()) {
if (!questerBlacklist.contains(p.getUniqueId().toString())) { Quester quester = getQuester(p.getUniqueId());
Quester quester = getQuester(p.getUniqueId()); quester.saveData();
quester.saveData();
}
} }
updateData(); updateData();
} }
@ -514,11 +510,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
showQuestTitles = config.getBoolean("show-titles", true); showQuestTitles = config.getBoolean("show-titles", true);
translateSubCommands = config.getBoolean("translate-subcommands", false); translateSubCommands = config.getBoolean("translate-subcommands", false);
useCompass = config.getBoolean("use-compass", true); useCompass = config.getBoolean("use-compass", true);
for (String s : config.getStringList("quester-blacklist")) {
if (!s.equalsIgnoreCase("UUID")) {
questerBlacklist.add(s);
}
}
try { try {
config.save(new File(this.getDataFolder(), "config.yml")); config.save(new File(this.getDataFolder(), "config.yml"));
} catch (IOException e) { } catch (IOException e) {
@ -681,7 +672,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
public boolean onCommand(final CommandSender cs, Command cmd, String label, String[] args) { public boolean onCommand(final CommandSender cs, Command cmd, String label, String[] args) {
if (cs instanceof Player) { if (cs instanceof Player) {
if (checkQuester(((Player) cs).getUniqueId()) == true) { if (checkQuester(((Player) cs).getUniqueId()) == true) {
cs.sendMessage(ChatColor.RED + Lang.get((Player) cs, "questBlacklisted")); cs.sendMessage(ChatColor.RED + Lang.get((Player) cs, "noPermission"));
return true; return true;
} }
} }
@ -725,8 +716,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
adminNextStage(cs, args); adminNextStage(cs, args);
} else if (args[0].equalsIgnoreCase(translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_SETSTAGE") : "setstage")) { } else if (args[0].equalsIgnoreCase(translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_SETSTAGE") : "setstage")) {
adminSetStage(cs, args); adminSetStage(cs, args);
} else if (args[0].equalsIgnoreCase(translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_PURGE") : "purge")) {
adminPurge(cs, args);
} else if (args[0].equalsIgnoreCase(translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_RESET") : "reset")) { } else if (args[0].equalsIgnoreCase(translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_RESET") : "reset")) {
adminReset(cs, args); adminReset(cs, args);
} else if (args[0].equalsIgnoreCase(translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_REMOVE") : "remove")) { } else if (args[0].equalsIgnoreCase(translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_REMOVE") : "remove")) {
@ -745,7 +734,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin")) { if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin")) {
printAdminHelp(cs); printAdminHelp(cs);
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("questCmdNoPerms")); cs.sendMessage(ChatColor.RED + Lang.get("NoPermission"));
} }
} }
@ -757,7 +746,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
msg = msg.replaceAll("<number>", ChatColor.DARK_PURPLE + String.valueOf(quests.size()) + ChatColor.GOLD); msg = msg.replaceAll("<number>", ChatColor.DARK_PURPLE + String.valueOf(quests.size()) + ChatColor.GOLD);
cs.sendMessage(ChatColor.GOLD + msg); cs.sendMessage(ChatColor.GOLD + msg);
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("questCmdNoPerms")); cs.sendMessage(ChatColor.RED + Lang.get("NoPermission"));
} }
} }
@ -789,7 +778,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
cs.sendMessage(ChatColor.RED + Lang.get("unknownError")); cs.sendMessage(ChatColor.RED + Lang.get("unknownError"));
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("questCmdNoPerms")); cs.sendMessage(ChatColor.RED + Lang.get("NoPermission"));
} }
} }
@ -824,7 +813,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} }
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("questCmdNoPerms")); cs.sendMessage(ChatColor.RED + Lang.get("NoPermission"));
} }
} }
@ -860,7 +849,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
quester.saveData(); quester.saveData();
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("questCmdNoPerms")); cs.sendMessage(ChatColor.RED + Lang.get("NoPermission"));
} }
} }
@ -896,7 +885,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
quester.saveData(); quester.saveData();
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("questCmdNoPerms")); cs.sendMessage(ChatColor.RED + Lang.get("NoPermission"));
} }
} }
@ -953,7 +942,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} }
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("questCmdNoPerms")); cs.sendMessage(ChatColor.RED + Lang.get("NoPermission"));
} }
} }
@ -1028,7 +1017,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} }
thread.start(); thread.start();
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("questCmdNoPerms")); cs.sendMessage(ChatColor.RED + Lang.get("NoPermission"));
} }
} }
@ -1068,7 +1057,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} }
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("questCmdNoPerms")); cs.sendMessage(ChatColor.RED + Lang.get("NoPermission"));
} }
} }
@ -1126,7 +1115,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} }
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("questCmdNoPerms")); cs.sendMessage(ChatColor.RED + Lang.get("NoPermission"));
} }
} }
@ -1166,7 +1155,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} }
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("questCmdNoPerms")); cs.sendMessage(ChatColor.RED + Lang.get("NoPermission"));
} }
} }
@ -1208,44 +1197,13 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} }
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("questCmdNoPerms")); cs.sendMessage(ChatColor.RED + Lang.get("NoPermission"));
} }
} catch (NullPointerException npe) { } catch (NullPointerException npe) {
npe.printStackTrace(); npe.printStackTrace();
} }
} }
private void adminPurge(final CommandSender cs, String[] args) {
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.purge")) {
Quester quester = getQuester(args[1]);
if (quester == null) {
cs.sendMessage(ChatColor.YELLOW + Lang.get("playerNotFound"));
return;
}
try {
quester.hardClear();
quester.saveData();
quester.updateJournal();
final File dataFolder = new File(this.getDataFolder(), "data" + File.separator);
final File found = new File(dataFolder, quester.id + ".yml");
found.delete();
addToBlacklist(quester.id);
String msg = Lang.get("questPurged");
if (Bukkit.getOfflinePlayer(quester.id).getName() != null) {
msg = msg.replaceAll("<player>", ChatColor.GREEN + Bukkit.getOfflinePlayer(quester.id).getName() + ChatColor.GOLD);
} else {
msg = msg.replaceAll("<player>", ChatColor.GREEN + args[1] + ChatColor.GOLD);
}
cs.sendMessage(ChatColor.GOLD + msg);
cs.sendMessage(ChatColor.DARK_PURPLE + " UUID: " + ChatColor.DARK_AQUA + quester.id);
} catch (Exception e) {
getLogger().info("Data file does not exist for " + quester.id.toString());
}
} else {
cs.sendMessage(ChatColor.RED + Lang.get("questCmdNoPerms"));
}
}
private void adminReset(final CommandSender cs, String[] args) { private void adminReset(final CommandSender cs, String[] args) {
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.reset")) { if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.reset")) {
Quester quester = getQuester(args[1]); Quester quester = getQuester(args[1]);
@ -1278,7 +1236,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
quester.saveData(); quester.saveData();
questers.put(id, quester); questers.put(id, quester);
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("questCmdNoPerms")); cs.sendMessage(ChatColor.RED + Lang.get("NoPermission"));
} }
} }
@ -1286,7 +1244,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (cs.hasPermission("quests.admin.*") && cs.hasPermission("quests.admin.stats")) { if (cs.hasPermission("quests.admin.*") && cs.hasPermission("quests.admin.stats")) {
questsStats(cs, args); questsStats(cs, args);
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("questCmdNoPerms")); cs.sendMessage(ChatColor.RED + Lang.get("NoPermission"));
} }
} }
@ -1315,7 +1273,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
quester.saveData(); quester.saveData();
quester.updateJournal(); quester.updateJournal();
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("questCmdNoPerms")); cs.sendMessage(ChatColor.RED + Lang.get("NoPermission"));
} }
} }
@ -1367,7 +1325,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (cs.hasPermission("quests.editor.*") || cs.hasPermission("quests.editor.events.editor")) { if (cs.hasPermission("quests.editor.*") || cs.hasPermission("quests.editor.events.editor")) {
eventFactory.convoCreator.buildConversation((Conversable) cs).begin(); eventFactory.convoCreator.buildConversation((Conversable) cs).begin();
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("eventEditorNoPerms")); cs.sendMessage(ChatColor.RED + Lang.get("NoPermission"));
} }
return true; return true;
} }
@ -1376,7 +1334,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
if (cs.hasPermission("quests.editor.*") || cs.hasPermission("quests.editor.editor")) { if (cs.hasPermission("quests.editor.*") || cs.hasPermission("quests.editor.editor")) {
questFactory.convoCreator.buildConversation((Conversable) cs).begin(); questFactory.convoCreator.buildConversation((Conversable) cs).begin();
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("questEditorNoPerms")); cs.sendMessage(ChatColor.RED + Lang.get("NoPermission"));
} }
return true; return true;
} }
@ -1560,7 +1518,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
return true; return true;
} }
} else { } else {
player.sendMessage(ChatColor.RED + Lang.get(player, "questQuitNoPerms")); player.sendMessage(ChatColor.RED + Lang.get(player, "NoPermission"));
return true; return true;
} }
} else { } else {
@ -1678,7 +1636,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} }
} }
} else { } else {
player.sendMessage(ChatColor.RED + Lang.get(player, "questTakeNoPerms")); player.sendMessage(ChatColor.RED + Lang.get(player, "NoPermission"));
} }
} else { } else {
player.sendMessage(ChatColor.YELLOW + Lang.get(player, "questTakeDisabled")); player.sendMessage(ChatColor.YELLOW + Lang.get(player, "questTakeDisabled"));
@ -1704,7 +1662,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
listQuests((Player) cs, page); listQuests((Player) cs, page);
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("questListNoPerms")); cs.sendMessage(ChatColor.RED + Lang.get("NoPermission"));
} }
} }
@ -1713,7 +1671,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
Player p = (Player) cs; Player p = (Player) cs;
printHelp(p); printHelp(p);
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("questCmdNoPerms")); cs.sendMessage(ChatColor.RED + Lang.get("NoPermission"));
} }
} }
@ -1726,7 +1684,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
showQuestDetails(cs, args); showQuestDetails(cs, args);
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("questCmdNoPerms")); cs.sendMessage(ChatColor.RED + Lang.get("NoPermission"));
return true; return true;
} }
} else { } else {
@ -1870,7 +1828,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
cs.sendMessage(ChatColor.YELLOW + Lang.get("questNotFound")); cs.sendMessage(ChatColor.YELLOW + Lang.get("questNotFound"));
} }
} else { } else {
cs.sendMessage(ChatColor.RED + Lang.get("questInfoNoPerms")); cs.sendMessage(ChatColor.RED + Lang.get("NoPermission"));
} }
} }
@ -1928,8 +1886,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
.replace("<command>", translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_NEXTSTAGE") : "nextstage")); .replace("<command>", translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_NEXTSTAGE") : "nextstage"));
cs.sendMessage(ChatColor.DARK_RED + "/questadmin " + ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_SETSTAGE_HELP") cs.sendMessage(ChatColor.DARK_RED + "/questadmin " + ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_SETSTAGE_HELP")
.replace("<command>", translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_SETSTAGE") : "setstage")); .replace("<command>", translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_SETSTAGE") : "setstage"));
cs.sendMessage(ChatColor.DARK_RED + "/questadmin " + ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_PURGE_HELP")
.replace("<command>", translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_PURGE") : "purge"));
cs.sendMessage(ChatColor.DARK_RED + "/questadmin " + ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_RESET_HELP") cs.sendMessage(ChatColor.DARK_RED + "/questadmin " + ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_RESET_HELP")
.replace("<command>", translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_RESET") : "reset")); .replace("<command>", translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_RESET") : "reset"));
cs.sendMessage(ChatColor.DARK_RED + "/questadmin " + ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_REMOVE_HELP") cs.sendMessage(ChatColor.DARK_RED + "/questadmin " + ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_REMOVE_HELP")
@ -1979,10 +1935,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
cs.sendMessage(ChatColor.DARK_RED + "/questadmin " + ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_SETSTAGE_HELP") cs.sendMessage(ChatColor.DARK_RED + "/questadmin " + ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_SETSTAGE_HELP")
.replace("<command>", translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_SETSTAGE") : "setstage")); .replace("<command>", translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_SETSTAGE") : "setstage"));
} }
if (cs.hasPermission("quests.admin.purge")) {
cs.sendMessage(ChatColor.DARK_RED + "/questadmin " + ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_PURGE_HELP")
.replace("<command>", translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_PURGE") : "purge"));
}
if (cs.hasPermission("quests.admin.reset")) { if (cs.hasPermission("quests.admin.reset")) {
cs.sendMessage(ChatColor.DARK_RED + "/questadmin " + ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_RESET_HELP") cs.sendMessage(ChatColor.DARK_RED + "/questadmin " + ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_RESET_HELP")
.replace("<command>", translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_RESET") : "reset")); .replace("<command>", translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_RESET") : "reset"));
@ -2036,7 +1988,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
public void reloadQuests() { public void reloadQuests() {
quests.clear(); quests.clear();
events.clear(); events.clear();
questerBlacklist.clear();
loadQuests(); loadQuests();
loadData(); loadData();
loadEvents(); loadEvents();
@ -3826,18 +3777,16 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
} }
/** /**
* Checks whether player has been blacklisted from Quests * Checks whether player meets criteria to use Quests
* *
* @param uuid the entity UUID to be checked * @param uuid the entity UUID to be checked
* @return {@code true} if UUID is blacklisted * @return {@code true} if UUID is blacklisted
*/ */
public boolean checkQuester(UUID uuid) { public boolean checkQuester(UUID uuid) {
for (String s : questerBlacklist) { Player p = Bukkit.getPlayer(uuid);
try { for (PermissionAttachmentInfo pm : p.getEffectivePermissions()) {
uuid.equals(UUID.fromString(s)); if (pm.getPermission().startsWith("quests")) {
return true; return true;
} catch (IllegalArgumentException e) {
getLogger().warning(s + " in config.yml is not a valid UUID for quester-blacklist");
} }
} }
return false; return false;
@ -4111,16 +4060,4 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
e.printStackTrace(); e.printStackTrace();
} }
} }
public void addToBlacklist(UUID id) {
List<String> blacklist = getConfig().getStringList("quester-blacklist");
if (!blacklist.contains(id.toString())) {
blacklist.add(id.toString());
getConfig().set("quester-blacklist", blacklist);
saveConfig();
}
if (!questerBlacklist.contains(id.toString())) {
questerBlacklist.add(id.toString());
}
}
} }

View File

@ -4,7 +4,6 @@ allow-command-questing: true
allow-command-quests-with-npcs: false allow-command-quests-with-npcs: false
allow-quitting: true allow-quitting: true
ask-confirmation: true ask-confirmation: true
convert-data-on-startup: false
generate-files-on-join: true generate-files-on-join: true
ignore-locked-quests: false ignore-locked-quests: false
kill-delay: 600 kill-delay: 600
@ -17,8 +16,4 @@ npc-effects:
show-requirements: true show-requirements: true
show-titles: true show-titles: true
translate-subcommands: false translate-subcommands: false
use-compass: true use-compass: true
quester-blacklist:
- UUID
- UUID
- UUID

View File

@ -68,9 +68,6 @@ permissions:
quests.admin.nextstage: quests.admin.nextstage:
description: Immediately force Stage completion for a player description: Immediately force Stage completion for a player
default: op default: op
quests.admin.purge:
description: Clear all Quests data of a player AND BLACKLISTS THEM
default: op
quests.admin.reset: quests.admin.reset:
description: Clear all Quests data of a player description: Clear all Quests data of a player
default: op default: op

View File

@ -42,8 +42,6 @@ COMMAND_QUESTADMIN_NEXTSTAGE_HELP: "<command> [player] [quest] - Immediately for
COMMAND_QUESTADMIN_SETSTAGE: "setstage" COMMAND_QUESTADMIN_SETSTAGE: "setstage"
COMMAND_QUESTADMIN_SETSTAGE_HELP: "<command> [player] [quest] [stage] - Set the current Stage for a player" COMMAND_QUESTADMIN_SETSTAGE_HELP: "<command> [player] [quest] [stage] - Set the current Stage for a player"
COMMAND_QUESTADMIN_SETSTAGE_USAGE: 'Usage: /questadmin setstage [player] [quest] [stage]' COMMAND_QUESTADMIN_SETSTAGE_USAGE: 'Usage: /questadmin setstage [player] [quest] [stage]'
COMMAND_QUESTADMIN_PURGE: "purge"
COMMAND_QUESTADMIN_PURGE_HELP: "<command> [player] - Clear all Quests data of a player AND BLACKLISTS THEM"
COMMAND_QUESTADMIN_RESET: "reset" COMMAND_QUESTADMIN_RESET: "reset"
COMMAND_QUESTADMIN_RESET_HELP: "<command> [player] - Clear all Quests data of a player" COMMAND_QUESTADMIN_RESET_HELP: "<command> [player] - Clear all Quests data of a player"
COMMAND_QUESTADMIN_REMOVE: "remove" COMMAND_QUESTADMIN_REMOVE: "remove"
@ -107,9 +105,6 @@ questEditorNeedStages: "Your Quest has no Stages!"
questEditorSaved: "%bold%Quest saved! %reset%(You will need to perform %red%<command> %reset% for it to appear in-game)" questEditorSaved: "%bold%Quest saved! %reset%(You will need to perform %red%<command> %reset% for it to appear in-game)"
questEditorExited: "Are you sure you want to exit without saving?" questEditorExited: "Are you sure you want to exit without saving?"
questEditorDeleted: "Are you sure you want to delete the Quest" questEditorDeleted: "Are you sure you want to delete the Quest"
questEditorNoPermsCreate: "You do not have permission to create Quests."
questEditorNoPermsEdit: "You do not have permission to edit Quests."
questEditorNoPermsDelete: "You do not have permission to delete Quests."
stageEditorEditStage: "Edit Stage" stageEditorEditStage: "Edit Stage"
stageEditorNewStage: "Add new Stage" stageEditorNewStage: "Add new Stage"
stageEditorStages: "Stages" stageEditorStages: "Stages"
@ -309,9 +304,6 @@ allListsNotSameSize: "All of your lists are not the same size!"
eventEditorCreate: "Create new Event" eventEditorCreate: "Create new Event"
eventEditorEdit: "Edit an Event" eventEditorEdit: "Edit an Event"
eventEditorDelete: "Delete an Event" eventEditorDelete: "Delete an Event"
eventEditorCreatePermisssions: "You do not have permission to create new Events."
eventEditorEditPermisssions: "You do not have permission to edit Events."
eventEditorDeletePermisssions: "You do not have permission to delete Events."
eventEditorNoneToEdit: "No Events currently exist to be edited!" eventEditorNoneToEdit: "No Events currently exist to be edited!"
eventEditorNoneToDelete: "No Events currently exist to be deleted!" eventEditorNoneToDelete: "No Events currently exist to be deleted!"
eventEditorNotFound: "Event not found!" eventEditorNotFound: "Event not found!"
@ -703,18 +695,11 @@ questNoEquip: "You may not equip Quest items."
questNoDispense: "You may not put Quest items in dispensers." questNoDispense: "You may not put Quest items in dispensers."
questNoEnchant: "You may not enchant Quest items." questNoEnchant: "You may not enchant Quest items."
questNoSmelt: "You may not smelt using Quest items." questNoSmelt: "You may not smelt using Quest items."
questInfoNoPerms: "You do not have permission to view a Quest's information."
questCmdNoPerms: "You do not have access to that command."
pageSelectionNum: "Page selection must be a number." pageSelectionNum: "Page selection must be a number."
pageSelectionPosNum: "Page selection must be a positive number." pageSelectionPosNum: "Page selection must be a positive number."
questListNoPerms: "You do not have permission to view the Quests list."
questTakeNoPerms: "You do not have permission to take Quests via commands."
questTakeDisabled: "Taking Quests via commands has been disabled." questTakeDisabled: "Taking Quests via commands has been disabled."
questQuit: "You have quit <quest>" questQuit: "You have quit <quest>"
questQuitNoPerms: "You do not have permission to quit Quests."
questQuitDisabled: "Quitting Quests has been disabled." questQuitDisabled: "Quitting Quests has been disabled."
questEditorNoPerms: "You do not have permission to use the Quests Editor."
eventEditorNoPerms: "You do not have permission to use the Events Editor."
questsUnknownCommand: "Unknown Quests command. Type /quests for help." questsUnknownCommand: "Unknown Quests command. Type /quests for help."
pageNotExist: "Page does not exist." pageNotExist: "Page does not exist."
pageFooter: "- Page <current> of <all> -" pageFooter: "- Page <current> of <all> -"
@ -728,7 +713,6 @@ questForceFinish: "<player> has forcibly finished their Quest <quest>."
questForcedFinish: "<player> has forced you to finish your Quest <quest>." questForcedFinish: "<player> has forced you to finish your Quest <quest>."
questForceNextStage: "<player> has advanced to the next Stage in the Quest <quest>." questForceNextStage: "<player> has advanced to the next Stage in the Quest <quest>."
questForcedNextStage: "<player> has advanced you to the next Stage in your Quest <quest>." questForcedNextStage: "<player> has advanced you to the next Stage in your Quest <quest>."
questPurged: "<player> has been purged and blacklisted."
questReset: "<player> has been reset." questReset: "<player> has been reset."
questRemoved: "Quest <quest> has been removed from player <player>'s completed Quests." questRemoved: "Quest <quest> has been removed from player <player>'s completed Quests."
settingAllQuestPoints: "Setting all players' Quest Points..." settingAllQuestPoints: "Setting all players' Quest Points..."
@ -873,4 +857,4 @@ timerMessage: "%green%Time left to finish the quest/stage:%red% <time> seconds"
timerStart: "%green%You have%red% <time> seconds%green% to finish this quest/stage" timerStart: "%green%You have%red% <time> seconds%green% to finish this quest/stage"
questErrorReadingFile: "Error reading Quests file." questErrorReadingFile: "Error reading Quests file."
questSaveError: "An error occurred while saving." questSaveError: "An error occurred while saving."
questBlacklisted: "You are blacklisted. Contact an admin if this is in error." noPermission: "You do not have permission to do that."