mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-15 07:05:51 +01:00
Remove /questadmin togglegui command and unnecessary utility methods
This commit is contained in:
parent
a7c03b55c0
commit
fff4a9ad61
@ -705,15 +705,6 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
ConfigurationSection newSection = questSection.createSection("custom" + customNum);
|
||||
saveQuest(context, newSection);
|
||||
data.save(new File(plugin.getDataFolder(), "quests.yml"));
|
||||
if (context.getSessionData(CK.Q_START_NPC) != null && context.getSessionData(CK.Q_GUIDISPLAY) != null) {
|
||||
int i = (Integer) context.getSessionData(CK.Q_START_NPC);
|
||||
if (!plugin.getQuestNpcGuis().contains(i)) {
|
||||
LinkedList<Integer> temp = plugin.getQuestNpcGuis();
|
||||
temp.add(i);
|
||||
plugin.setQuestNpcGuis(temp);
|
||||
}
|
||||
plugin.updateData();
|
||||
}
|
||||
context.getForWhom().sendRawMessage(ChatColor.GREEN
|
||||
+ Lang.get("questEditorSaved").replaceAll("<command>", "/questadmin " + Lang.get("COMMAND_QUESTADMIN_RELOAD")));
|
||||
} catch (IOException e) {
|
||||
|
@ -45,7 +45,6 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -71,8 +70,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.codisimus.plugins.phatloots.PhatLootsAPI;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
@ -110,7 +107,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
private LinkedList<Quest> quests = new LinkedList<Quest>();
|
||||
private LinkedList<Action> events = new LinkedList<Action>();
|
||||
private LinkedList<NPC> questNpcs = new LinkedList<NPC>();
|
||||
private LinkedList<Integer> questNpcGuis = new LinkedList<Integer>();
|
||||
private CommandExecutor cmdExecutor;
|
||||
private ConversationFactory conversationFactory;
|
||||
private ConversationFactory npcConversationFactory;
|
||||
@ -172,28 +168,24 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
// 6 - Save resources from jar
|
||||
saveResourceAs("quests.yml", "quests.yml", false);
|
||||
saveResourceAs("actions.yml", "actions.yml", false);
|
||||
saveResourceAs("data.yml", "data.yml", false);
|
||||
|
||||
// 7 - Load player data
|
||||
loadData();
|
||||
|
||||
// 8 - Save config with any new options
|
||||
// 7 - Save config with any new options
|
||||
getConfig().options().copyDefaults(true);
|
||||
saveConfig();
|
||||
|
||||
// 9 - Setup commands
|
||||
// 8 - Setup commands
|
||||
getCommand("quests").setExecutor(cmdExecutor);
|
||||
getCommand("questadmin").setExecutor(cmdExecutor);
|
||||
getCommand("quest").setExecutor(cmdExecutor);
|
||||
|
||||
// 10 - Setup conversation factory after timeout has loaded
|
||||
// 9 - Setup conversation factory after timeout has loaded
|
||||
this.conversationFactory = new ConversationFactory(this).withModality(false).withPrefix(new QuestsPrefix())
|
||||
.withFirstPrompt(new QuestPrompt()).withTimeout(settings.getAcceptTimeout())
|
||||
.thatExcludesNonPlayersWithMessage("Console may not perform this conversation!").addConversationAbandonedListener(this);
|
||||
this.npcConversationFactory = new ConversationFactory(this).withModality(false).withFirstPrompt(new QuestAcceptPrompt(this))
|
||||
.withTimeout(settings.getAcceptTimeout()).withLocalEcho(false).addConversationAbandonedListener(this);
|
||||
|
||||
// 11 - Register listeners
|
||||
// 10 - Register listeners
|
||||
getServer().getPluginManager().registerEvents(playerListener, this);
|
||||
if (depends.getCitizens() != null) {
|
||||
getServer().getPluginManager().registerEvents(npcListener, this);
|
||||
@ -208,18 +200,17 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
getServer().getPluginManager().registerEvents(partiesListener, this);
|
||||
}
|
||||
|
||||
// 12 - Delay loading of Quests, Actions and modules
|
||||
// 11 - Delay loading of Quests, Actions and modules
|
||||
delayLoadQuestInfo(5L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getLogger().info("Saving Quester data.");
|
||||
getLogger().info("Saving Quester data...");
|
||||
for (Player p : getServer().getOnlinePlayers()) {
|
||||
Quester quester = getQuester(p.getUniqueId());
|
||||
quester.saveData();
|
||||
}
|
||||
updateData();
|
||||
}
|
||||
|
||||
public String getDetectedBukkitVersion() {
|
||||
@ -315,14 +306,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
this.questNpcs = questNpcs;
|
||||
}
|
||||
|
||||
public LinkedList<Integer> getQuestNpcGuis() {
|
||||
return questNpcGuis;
|
||||
}
|
||||
|
||||
public void setQuestNpcGuis(LinkedList<Integer> questNpcGuis) {
|
||||
this.questNpcGuis = questNpcGuis;
|
||||
}
|
||||
|
||||
public ConversationFactory getConversationFactory() {
|
||||
return conversationFactory;
|
||||
}
|
||||
@ -508,24 +491,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
}, ticks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load player and NPC GUI data from file
|
||||
*/
|
||||
public void loadData() {
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
File dataFile = new File(this.getDataFolder(), "data.yml");
|
||||
try {
|
||||
config.load(dataFile);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (config.contains("npc-gui")) {
|
||||
List<Integer> ids = config.getIntegerList("npc-gui");
|
||||
questNpcGuis.clear();
|
||||
questNpcGuis.addAll(ids);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load modules from file
|
||||
*/
|
||||
@ -1374,7 +1339,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
events.clear();
|
||||
|
||||
loadQuests();
|
||||
loadData();
|
||||
loadActions();
|
||||
// Reload config from disc in-case a setting was changed
|
||||
reloadConfig();
|
||||
@ -3172,34 +3136,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
return info;
|
||||
}
|
||||
|
||||
public static Effect getEffect(String eff) {
|
||||
if (eff.equalsIgnoreCase("BLAZE_SHOOT")) {
|
||||
return Effect.BLAZE_SHOOT;
|
||||
} else if (eff.equalsIgnoreCase("BOW_FIRE")) {
|
||||
return Effect.BOW_FIRE;
|
||||
} else if (eff.equalsIgnoreCase("CLICK1")) {
|
||||
return Effect.CLICK1;
|
||||
} else if (eff.equalsIgnoreCase("CLICK2")) {
|
||||
return Effect.CLICK2;
|
||||
} else if (eff.equalsIgnoreCase("DOOR_TOGGLE")) {
|
||||
return Effect.DOOR_TOGGLE;
|
||||
} else if (eff.equalsIgnoreCase("EXTINGUISH")) {
|
||||
return Effect.EXTINGUISH;
|
||||
} else if (eff.equalsIgnoreCase("GHAST_SHOOT")) {
|
||||
return Effect.GHAST_SHOOT;
|
||||
} else if (eff.equalsIgnoreCase("GHAST_SHRIEK")) {
|
||||
return Effect.GHAST_SHRIEK;
|
||||
} else if (eff.equalsIgnoreCase("ZOMBIE_CHEW_IRON_DOOR")) {
|
||||
return Effect.ZOMBIE_CHEW_IRON_DOOR;
|
||||
} else if (eff.equalsIgnoreCase("ZOMBIE_CHEW_WOODEN_DOOR")) {
|
||||
return Effect.ZOMBIE_CHEW_WOODEN_DOOR;
|
||||
} else if (eff.equalsIgnoreCase("ZOMBIE_DESTROY_DOOR")) {
|
||||
return Effect.ZOMBIE_DESTROY_DOOR;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static EntityType getMobType(String mob) {
|
||||
return MiscUtil.getProperMobType(mob);
|
||||
}
|
||||
@ -3253,60 +3189,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
return message;
|
||||
}
|
||||
|
||||
public static PotionEffect getPotionEffect(String type, int duration, int amplifier) {
|
||||
PotionEffectType potionType;
|
||||
if (type.equalsIgnoreCase("ABSORPTION")) {
|
||||
potionType = PotionEffectType.ABSORPTION;
|
||||
} else if (type.equalsIgnoreCase("BLINDNESS")) {
|
||||
potionType = PotionEffectType.BLINDNESS;
|
||||
} else if (type.equalsIgnoreCase("CONFUSION")) {
|
||||
potionType = PotionEffectType.CONFUSION;
|
||||
} else if (type.equalsIgnoreCase("DAMAGE_RESISTANCE")) {
|
||||
potionType = PotionEffectType.DAMAGE_RESISTANCE;
|
||||
} else if (type.equalsIgnoreCase("FAST_DIGGING")) {
|
||||
potionType = PotionEffectType.FAST_DIGGING;
|
||||
} else if (type.equalsIgnoreCase("FIRE_RESISTANCE")) {
|
||||
potionType = PotionEffectType.FIRE_RESISTANCE;
|
||||
} else if (type.equalsIgnoreCase("HARM")) {
|
||||
potionType = PotionEffectType.HARM;
|
||||
} else if (type.equalsIgnoreCase("HEAL")) {
|
||||
potionType = PotionEffectType.HEAL;
|
||||
} else if (type.equalsIgnoreCase("HEALTH_BOOST")) {
|
||||
potionType = PotionEffectType.HEALTH_BOOST;
|
||||
} else if (type.equalsIgnoreCase("HUNGER")) {
|
||||
potionType = PotionEffectType.HUNGER;
|
||||
} else if (type.equalsIgnoreCase("INCREASE_DAMAGE")) {
|
||||
potionType = PotionEffectType.INCREASE_DAMAGE;
|
||||
} else if (type.equalsIgnoreCase("INVISIBILITY")) {
|
||||
potionType = PotionEffectType.INVISIBILITY;
|
||||
} else if (type.equalsIgnoreCase("JUMP")) {
|
||||
potionType = PotionEffectType.JUMP;
|
||||
} else if (type.equalsIgnoreCase("NIGHT_VISION")) {
|
||||
potionType = PotionEffectType.NIGHT_VISION;
|
||||
} else if (type.equalsIgnoreCase("POISON")) {
|
||||
potionType = PotionEffectType.POISON;
|
||||
} else if (type.equalsIgnoreCase("REGENERATION")) {
|
||||
potionType = PotionEffectType.REGENERATION;
|
||||
} else if (type.equalsIgnoreCase("SATURATION")) {
|
||||
potionType = PotionEffectType.SATURATION;
|
||||
} else if (type.equalsIgnoreCase("SLOW")) {
|
||||
potionType = PotionEffectType.SLOW;
|
||||
} else if (type.equalsIgnoreCase("SLOW_DIGGING")) {
|
||||
potionType = PotionEffectType.SLOW_DIGGING;
|
||||
} else if (type.equalsIgnoreCase("SPEED")) {
|
||||
potionType = PotionEffectType.SPEED;
|
||||
} else if (type.equalsIgnoreCase("WATER_BREATHING")) {
|
||||
potionType = PotionEffectType.WATER_BREATHING;
|
||||
} else if (type.equalsIgnoreCase("WEAKNESS")) {
|
||||
potionType = PotionEffectType.WEAKNESS;
|
||||
} else if (type.equalsIgnoreCase("WITHER")) {
|
||||
potionType = PotionEffectType.WITHER;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return new PotionEffect(potionType, duration, amplifier);
|
||||
}
|
||||
|
||||
public static SkillType getMcMMOSkill(String s) {
|
||||
return SkillType.getSkill(s);
|
||||
}
|
||||
@ -3615,18 +3497,4 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
||||
Hero hero = getHero(uuid);
|
||||
return hero.getSecondClass().getName().equalsIgnoreCase(secondaryClass);
|
||||
}
|
||||
|
||||
public void updateData() {
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
File dataFile = new File(this.getDataFolder(), "data.yml");
|
||||
try {
|
||||
config.load(dataFile);
|
||||
config.set("npc-gui", questNpcGuis);
|
||||
config.save(dataFile);
|
||||
} catch (Exception e) {
|
||||
getLogger().severe("Unable to update data.yml file");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -31,6 +31,7 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import me.blackvein.quests.Quest;
|
||||
import me.blackvein.quests.QuestMob;
|
||||
@ -465,7 +466,7 @@ public class Action {
|
||||
List<String> effectList = data.getStringList(actionKey + "effects");
|
||||
List<String> effectLocs = data.getStringList(actionKey + "effect-locations");
|
||||
for (String s : effectList) {
|
||||
Effect effect = Quests.getEffect(s);
|
||||
Effect effect = Effect.valueOf(s.toUpperCase());
|
||||
Location l = Quests.getLocation(effectLocs.get(effectList.indexOf(s)));
|
||||
if (effect == null) {
|
||||
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + s + ChatColor.GOLD + " inside " + ChatColor.GREEN + "effects: " + ChatColor.GOLD + "inside Action " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid effect name!");
|
||||
@ -633,11 +634,12 @@ public class Action {
|
||||
List<Integer> durations = data.getIntegerList(actionKey + "potion-effect-durations");
|
||||
List<Integer> amplifiers = data.getIntegerList(actionKey + "potion-effect-amplifiers");
|
||||
for (String s : types) {
|
||||
PotionEffect effect = Quests.getPotionEffect(s, durations.get(types.indexOf(s)), amplifiers.get(types.indexOf(s)));
|
||||
if (effect == null) {
|
||||
PotionEffectType type = PotionEffectType.getByName(s);
|
||||
if (type == null) {
|
||||
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + s + ChatColor.GOLD + " inside " + ChatColor.GREEN + " lightning-strikes: " + ChatColor.GOLD + "inside Action " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid potion effect name!");
|
||||
return null;
|
||||
}
|
||||
PotionEffect effect = new PotionEffect(type, durations.get(types.indexOf(s)), amplifiers.get(types.indexOf(s)));
|
||||
action.potionEffects.add(effect);
|
||||
}
|
||||
} else {
|
||||
|
@ -1379,7 +1379,7 @@ public class ActionFactory implements ConversationAbandonedListener {
|
||||
public Prompt acceptInput(ConversationContext context, String input) {
|
||||
Player player = (Player) context.getForWhom();
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
if (Quests.getEffect(input.toUpperCase()) != null) {
|
||||
if (Effect.valueOf(input.toUpperCase()) != null) {
|
||||
LinkedList<String> effects;
|
||||
if (context.getSessionData(CK.E_EFFECTS) != null) {
|
||||
effects = (LinkedList<String>) context.getSessionData(CK.E_EFFECTS);
|
||||
|
@ -275,8 +275,6 @@ public class CmdExecutor implements CommandExecutor {
|
||||
adminReset(cs, args);
|
||||
} else if (args[0].equalsIgnoreCase(translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_REMOVE") : "remove")) {
|
||||
adminRemove(cs, args);
|
||||
} else if (args[0].equalsIgnoreCase(translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_TOGGLEGUI") : "togglegui")) {
|
||||
adminToggieGUI(cs, args);
|
||||
} else if (args[0].equalsIgnoreCase(translateSubCommands ? Lang.get("COMMAND_QUESTADMIN_RELOAD") : "reload")) {
|
||||
adminReload(cs);
|
||||
} else {
|
||||
@ -783,42 +781,6 @@ public class CmdExecutor implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
private void adminToggieGUI(final CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.togglegui")) {
|
||||
try {
|
||||
int i = Integer.parseInt(args[1]);
|
||||
if (plugin.getDependencies().getCitizens().getNPCRegistry().getById(i) == null) {
|
||||
String msg = Lang.get("errorNPCID");
|
||||
msg = msg.replace("errorNPCID", ChatColor.DARK_PURPLE + "" + i + ChatColor.RED);
|
||||
cs.sendMessage(ChatColor.RED + msg);
|
||||
} else if (plugin.getQuestNpcGuis().contains(i)) {
|
||||
LinkedList<Integer> temp = plugin.getQuestNpcGuis();
|
||||
temp.remove(plugin.getQuestNpcGuis().indexOf(i));
|
||||
plugin.setQuestNpcGuis(temp);
|
||||
plugin.updateData();
|
||||
String msg = Lang.get("disableNPCGUI");
|
||||
msg = msg.replace("<npc>", ChatColor.DARK_PURPLE + plugin.getDependencies().getCitizens().getNPCRegistry().getById(i).getName() + ChatColor.YELLOW);
|
||||
cs.sendMessage(ChatColor.YELLOW + msg);
|
||||
} else {
|
||||
LinkedList<Integer> temp = plugin.getQuestNpcGuis();
|
||||
temp.add(i);
|
||||
plugin.setQuestNpcGuis(temp);
|
||||
plugin.updateData();
|
||||
String msg = Lang.get("enableNPCGUI");
|
||||
msg = msg.replace("<npc>", ChatColor.DARK_PURPLE + plugin.getDependencies().getCitizens().getNPCRegistry().getById(i).getName() + ChatColor.YELLOW);
|
||||
cs.sendMessage(ChatColor.YELLOW + msg);
|
||||
}
|
||||
} catch (NumberFormatException nfe) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("inputNum"));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("unknownError"));
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
|
||||
private void adminGivePoints(final CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.givepoints")) {
|
||||
Player target = getPlayer(args[1]);
|
||||
|
@ -18,7 +18,6 @@ import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -183,15 +182,10 @@ public class NpcListener implements Listener {
|
||||
}
|
||||
}
|
||||
if (npcQuests.isEmpty() == false && npcQuests.size() >= 1) {
|
||||
if (plugin.getQuestNpcGuis().contains(evt.getNPC().getId())) {
|
||||
quester.showGUIDisplay(evt.getNPC(), npcQuests);
|
||||
return;
|
||||
}
|
||||
Conversation c = plugin.getNpcConversationFactory().buildConversation(player);
|
||||
c.getContext().setSessionData("quests", npcQuests);
|
||||
c.getContext().setSessionData("npc", evt.getNPC().getName());
|
||||
c.begin();
|
||||
} else if (npcQuests.size() == 1) {
|
||||
// TODO can this block even be reached?
|
||||
Quest q = npcQuests.get(0);
|
||||
if (!quester.getCompletedQuests().contains(q.getName())) {
|
||||
if (quester.getCurrentQuests().size() < plugin.getSettings().getMaxQuests() || plugin.getSettings().getMaxQuests() < 1) {
|
||||
|
@ -1 +0,0 @@
|
||||
#Kindly do not manually edit GUI data!
|
@ -77,9 +77,6 @@ permissions:
|
||||
quests.admin.remove:
|
||||
description: Remove a completed quest from a player
|
||||
default: op
|
||||
quests.admin.togglegui:
|
||||
description: Toggle GUI Quest Display on an NPC
|
||||
default: op
|
||||
quests.admin.reload:
|
||||
description: Safely reload the plugin
|
||||
default: op
|
||||
|
@ -46,8 +46,6 @@ COMMAND_QUESTADMIN_RESET: "reset"
|
||||
COMMAND_QUESTADMIN_RESET_HELP: "<command> [player] - Clear all Quests data of a player"
|
||||
COMMAND_QUESTADMIN_REMOVE: "remove"
|
||||
COMMAND_QUESTADMIN_REMOVE_HELP: "<command> [player] [quest] - Remove a completed quest from a player"
|
||||
COMMAND_QUESTADMIN_TOGGLEGUI: "togglegui"
|
||||
COMMAND_QUESTADMIN_TOGGLEGUI_HELP: "<command> [npc id] - Toggle GUI Quest Display on an NPC"
|
||||
COMMAND_QUESTADMIN_RELOAD: "reload"
|
||||
COMMAND_QUESTADMIN_RELOAD_HELP: "<command> - Safely reload the plugin"
|
||||
questEditorHeader: "Create Quest"
|
||||
@ -710,8 +708,6 @@ takeQuestPoints: "Took away <number> Quest Points from <player>."
|
||||
questPointsTaken: "<player> took away <number> Quest Points."
|
||||
giveQuestPoints: "Gave <number> Quest Points from <player>."
|
||||
questPointsGiven: "<player> gave you <number> Quest Points."
|
||||
enableNPCGUI: "<npc> will now provide a GUI Quest Display."
|
||||
disableNPCGUI: "<npc> will no longer provide a GUI Quest Display."
|
||||
invalidMinimum: "Input must be at least <number>!"
|
||||
invalidRange: "Input must be between <least> and <greatest>!"
|
||||
invalidOption: "Invalid option!"
|
||||
|
Loading…
Reference in New Issue
Block a user