From 8b57d1e83a4df3ead5b82794b73f95fb15e6486f Mon Sep 17 00:00:00 2001 From: Blackvein Date: Wed, 18 Sep 2013 17:51:36 -0700 Subject: [PATCH] Fixed more bugs. --- src/main/java/me/blackvein/quests/Quest.java | 35 +++++++++-------- src/main/java/me/blackvein/quests/Quests.java | 24 ++++++------ .../quests/prompts/CreateStagePrompt.java | 12 +++--- .../java/me/blackvein/quests/util/Lang.java | 38 +++++++++---------- 4 files changed, 53 insertions(+), 56 deletions(-) diff --git a/src/main/java/me/blackvein/quests/Quest.java b/src/main/java/me/blackvein/quests/Quest.java index 62ea02055..2d8be85a1 100644 --- a/src/main/java/me/blackvein/quests/Quest.java +++ b/src/main/java/me/blackvein/quests/Quest.java @@ -76,10 +76,10 @@ public class Quest { completeQuest(q); }else { - + q.currentStageIndex++; setStage(q, q.currentStageIndex); - + } q.delayStartTime = 0; @@ -91,21 +91,21 @@ public class Quest { } } - + public void setStage(Quester q, int stage) { - + if (stages.size() - 1 < stage) { return; } - + q.reset(); - + if(q.currentStage.script != null) plugin.trigger.parseQuestTaskTrigger(q.currentStage.script, q.getPlayer()); - + if(q.currentStage.event != null) q.currentStage.event.happen(q); - + q.currentStage = stages.get(stage); q.addEmpties(); @@ -120,7 +120,7 @@ public class Quest { if (stageStartMessage != null) { q.getPlayer().sendMessage(Quests.parseString(stageStartMessage, q.currentQuest)); } - + } public String getName(){ @@ -188,13 +188,13 @@ public class Quest { q.reset(); q.completedQuests.add(name); String none = ChatColor.GRAY + "- (None)"; - + String ps = Quests.parseString(finished, q.currentQuest); - + for (String msg : ps.split("
")) { player.sendMessage(msg); } - + if(moneyReward > 0 && Quests.economy != null){ Quests.economy.depositPlayer(q.name, moneyReward); none = null; @@ -267,7 +267,7 @@ public class Quest { player.sendMessage("- " + ChatColor.DARK_GREEN + exp + ChatColor.DARK_PURPLE + " Experience"); none = null; } - + if (mcmmoSkills.isEmpty() == false) { for (String s : mcmmoSkills) { player.sendMessage("- " + ChatColor.DARK_GREEN + mcmmoAmounts.get(mcmmoSkills.indexOf(s)) + " " + ChatColor.DARK_PURPLE + s + " Experience"); @@ -278,8 +278,7 @@ public class Quest { player.sendMessage(none); } q.currentQuest = null; - - System.out.println(plugin.getQuester(q.name).currentQuest.getName()); + q.currentStage = null; q.currentStageIndex = 0; @@ -304,12 +303,12 @@ public class Quest { return false; if(commands.size() == other.commands.size()){ - + for (int i = 0; i < commands.size(); i++) { - if (commands.get(i).equals(other.commands.get(i)) == false) + if (commands.get(i).equals(other.commands.get(i)) == false) return false; } - + }else{ return false; } diff --git a/src/main/java/me/blackvein/quests/Quests.java b/src/main/java/me/blackvein/quests/Quests.java index 89a074c36..fbf5b140c 100644 --- a/src/main/java/me/blackvein/quests/Quests.java +++ b/src/main/java/me/blackvein/quests/Quests.java @@ -1,5 +1,7 @@ package me.blackvein.quests; +import com.gmail.nossr50.datatypes.skills.SkillType; +import com.gmail.nossr50.mcMMO; import java.io.File; import java.sql.Connection; import java.sql.DriverManager; @@ -18,7 +20,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.logging.Level; import java.util.logging.Logger; - import me.ThaH3lper.com.EpicBoss; import me.ThaH3lper.com.LoadBosses.LoadBoss; import me.blackvein.quests.prompts.QuestAcceptPrompt; @@ -32,7 +33,6 @@ import net.citizensnpcs.api.npc.NPC; import net.milkbowl.vault.Vault; import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.permission.Permission; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.DyeColor; @@ -63,9 +63,6 @@ import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.datatypes.skills.SkillType; - public class Quests extends JavaPlugin implements ConversationAbandonedListener, ColorUtil { public final static Logger log = Logger.getLogger("Minecraft"); @@ -271,7 +268,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener, } } - + public static Quests getInstance() { return instance; } @@ -335,13 +332,13 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener, debug = config.getBoolean("debug-mode"); killDelay = config.getInt("kill-delay"); acceptTimeout = config.getInt("accept-timeout"); - + if (config.contains("language")) { Lang.lang = config.getString("language"); } else { config.set("language", "en"); } - + if (config.contains("ignore-locked-quests")) { ignoreLockedQuests = config.getBoolean("ignore-locked-quests"); } else { @@ -802,7 +799,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener, for (String msg : s.split("
")) { cs.sendMessage(msg); } - + conversationFactory.buildConversation((Conversable) cs).begin(); } else { @@ -3272,9 +3269,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener, return parsed; } - + public static String parseString(String s) { - + String parsed = s; parsed = parsed.replaceAll("", BLACK.toString()); @@ -3604,7 +3601,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener, Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(milliseconds); - + Calendar epoch = Calendar.getInstance(); epoch.setTimeInMillis(0); @@ -3787,6 +3784,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener, public static String getCurrency(boolean plural) { + if(Quests.economy == null) + return "Money"; + if (plural) { if (Quests.economy.currencyNamePlural().trim().isEmpty()) { return "Money"; diff --git a/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java b/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java index 21f1dfdcd..2af226f47 100644 --- a/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java +++ b/src/main/java/me/blackvein/quests/prompts/CreateStagePrompt.java @@ -1608,7 +1608,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { text = text.substring(0, text.length() - 1); return text + "\n" + YELLOW + Lang.get("stageEditorEnchantTypePrompt"); - + } @Override @@ -1789,7 +1789,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { } } - + } else { for (ItemStack is : getItems(context)) { @@ -1827,10 +1827,10 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { } } - + text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("clear") + "\n"; text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("done"); - + return text; } @@ -3661,7 +3661,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { LoadBoss found = null; for (LoadBoss b : Quests.epicBoss.BossLoadList) { - if (b.getName().equalsIgnoreCase(input)) { + if (b.getName().equalsIgnoreCase(id)) { found = b; break; } @@ -3704,7 +3704,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - String[] amounts = input.split(","); + String[] amounts = input.split(" "); LinkedList amountList = new LinkedList(); for (String amount : amounts) { diff --git a/src/main/java/me/blackvein/quests/util/Lang.java b/src/main/java/me/blackvein/quests/util/Lang.java index 8727aff71..82b7795d2 100644 --- a/src/main/java/me/blackvein/quests/util/Lang.java +++ b/src/main/java/me/blackvein/quests/util/Lang.java @@ -92,8 +92,6 @@ public class Lang { //create prompt en.put("stageEditorStages", "Stages"); en.put("stageEditorStage", "Stage"); - en.put("stageEditorEditStage", "Edit Stage"); - en.put("stageEditorNewStage", "Add new Stage"); en.put("stageEditorBreakBlocks", "Break Blocks"); en.put("stageEditorDamageBlocks", "Damage Blocks"); en.put("stageEditorPlaceBlocks", "Place Blocks"); @@ -137,9 +135,9 @@ public class Lang { en.put("stageEditorSetItemIds", "Set item ids"); en.put("stageEditorSetKillIds", "Set NPC IDs"); en.put("stageEditorSetMobTypes", "Set mob types"); - en.put("stageEditorSetKillLocations", "Set kill locations"); - en.put("stageEditorSetKillLocationRadii", "Set kill location radii"); - en.put("stageEditorSetKillLocationNames", "Set kill location names"); + en.put("stageEditorSetKillLocations", "Set kill locations"); + en.put("stageEditorSetKillLocationRadii", "Set kill location radii"); + en.put("stageEditorSetKillLocationNames", "Set kill location names"); en.put("stageEditorSetLocations", "Set locations"); en.put("stageEditorSetLocationRadii", "Set location radii"); en.put("stageEditorSetLocationNames", "Set location names"); @@ -148,7 +146,7 @@ public class Lang { en.put("stageEditorSetShearAmounts", "Set shear amounts"); en.put("stageEditorSetBosses", "Set Bosses"); en.put("stageEditorAddMiniEvent", "Add mini-event"); - + en.put("stageEditorEnterBlockIds", "Enter block IDs, separating each one by a space, or enter \'cancel\' to return."); en.put("stageEditorBreakBlocksPrompt", "Enter block amounts (numbers), separating each one by a space, or enter \'cancel\' to return."); en.put("stageEditorDamageBlocksPrompt", "Enter damage amounts (numbers), separating each one by a space, or enter \'cancel\' to return."); @@ -183,11 +181,11 @@ public class Lang { en.put("stageEditorBossAmountPrompt", "Enter kill amounts (numbers), separating each one by a space, or \"cancel\" to return."); en.put("stageEditorStartMessagePrompt", "Enter start message, or enter \"clear\" to clear the message, or \"cancel\" to return"); en.put("stageEditorCompleteMessagePrompt", "Enter complete message, or enter \"clear\" to clear the message, or \"cancel\" to return"); - + en.put("stageEditorDeliveryAddItem", "Add item"); en.put("stageEditorDeliveryNPCs", "Set NPC IDs"); en.put("stageEditorDeliveryMessages", "Set delivery messages"); - + en.put("stageEditorContainsDuplicates", "List contains duplicates!"); en.put("stageEditorInvalidBlockID", "is not a valid block ID!"); en.put("stageEditorInvalidEnchantment", "is not a valid enchantment name!"); @@ -200,11 +198,11 @@ public class Lang { en.put("stageEditorInvalidDelay", "Delay must be at least one second!"); en.put("stageEditorInvalidScript", "Denizen script not found!"); en.put("stageEditorInvalidBoss", "Could not find Boss with the name:"); - + en.put("stageEditorNoCitizens", "Citizens is not installed!"); en.put("stageEditorNoEpicBoss", "EpicBoss is not installed!"); en.put("stageEditorNoDenizen", "Denizen is not installed!"); - + en.put("stageEditorPositiveAmount", "You must enter a positive number!"); en.put("stageEditorNoNumber", "Input was not a number!"); en.put("stageEditorNotGreaterThanZero", "is not greater than 0!"); @@ -218,14 +216,14 @@ public class Lang { en.put("stageEditorNoMobTypes", "You must set mob types first!"); en.put("stageEditorNoKillLocations", "You must set kill locations first!"); en.put("stageEditorNoBlockSelected", "You must select a block first."); - en.put("stageEditorNoColors", "You must set colors first!"); - + en.put("stageEditorNoColors", "You must set colors first!"); + en.put("stageEditorNoEnchantmentsSet", "No enchantments set"); en.put("stageEditorNoItemsSet", "No items set"); en.put("stageEditorNoMobTypesSet", "No mob types set"); en.put("stageEditorNoLocationsSet", "No locations set"); en.put("stageEditorNoColorsSet", "No colors set"); - + en.put("stageEditorListNotSameSize", "The block IDs list and the amounts list are not the same size!"); en.put("stageEditorEnchantmentNotSameSize", "The enchantments list, the item id list and the enchant amount list are not the same size!"); en.put("stageEditorDeliveriesNotSameSize", "The item list and the NPC list are not equal in size!"); @@ -233,11 +231,11 @@ public class Lang { en.put("stageEditorAllListsNotSameSize", "All of your lists are not the same size!"); en.put("stageEditorMobTypesNotSameSize", "The mob types list and the mob amounts list are not the same size!"); en.put("stageEditorTameMobsNotSameSize", "The mob types list and the tame amounts list are not the same size!"); - en.put("stageEditorShearNotSameSize", "The sheep colors list and the shear amounts list are not the same size!"); - en.put("stageEditorBossesNotSameSize", "The Boss IDs list and the Boss amounts list are not the same size!"); - + en.put("stageEditorShearNotSameSize", "The sheep colors list and the shear amounts list are not the same size!"); + en.put("stageEditorBossesNotSameSize", "The Boss IDs list and the Boss amounts list are not the same size!"); + en.put("stageEditorListContainsDuplicates", " List contains duplicates!"); - + en.put("stageEditorBreakBlocksCleared", "Break blocks objective cleared."); en.put("stageEditorDamageBlocksCleared", "Damage blocks objective cleared."); en.put("stageEditorPlaceBlocksCleared", "Place blocks objective cleared."); @@ -252,17 +250,17 @@ public class Lang { en.put("stageEditorBossesCleared", "Kill Bosses objective cleared."); en.put("stageEditorStartMessageCleared", "Start message cleared."); en.put("stageEditorCompleteMessageCleared", "Complete message cleared."); - + en.put("stageEditorConfirmStageDelete", "Are you sure you want to delete this stage?"); en.put("stageEditorConfirmStageNote", "Any Stages after will be shifted back one spot"); en.put("stageEditorDeleteSucces", "Stage deleted successfully."); - + en.put("stageEditorEnchantments", "Enchantments"); en.put("stageEditorNPCNote", "Note: You may specify the name of the NPC with "); en.put("stageEditorOptional", "Optional"); en.put("stageEditorColors", "Sheep Colors"); en.put("stageEditorBosses", "Bosses"); - + //Events en.put("eventEditorTitle", "Event Editor");