*Fixed denizen script not being recognized

* Changed version info
* Time fix, for if epoch time changes.
*More work on language files
This commit is contained in:
Zino 2013-08-07 14:46:46 +02:00
parent 5f5229a997
commit 986ba7eb8f
4 changed files with 260 additions and 208 deletions

View File

@ -83,10 +83,10 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
String text = String text =
GOLD + "- Quest Editor -\n" GOLD + "- Quest Editor -\n"
+ BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Create a Quest\n" + BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("questEditorCreate") + "\n"
+ BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Edit a Quest\n" + BLUE + "" + BOLD + "2" + RESET + YELLOW + " - " + Lang.get("questEditorEdit") + "\n"
+ BLUE + "" + BOLD + "3" + RESET + YELLOW + " - Delete a Quest\n" + BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("questEditorDelete") + "\n"
+ GOLD + "" + BOLD + "4" + RESET + YELLOW + " - Exit"; + GOLD + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("exit");
return text; return text;
@ -103,7 +103,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (player.hasPermission("quests.editor.create")) { if (player.hasPermission("quests.editor.create")) {
return new QuestNamePrompt(); return new QuestNamePrompt();
} else { } else {
player.sendMessage(RED + "You do not have permission to create Quests."); player.sendMessage(RED + Lang.get("questEditorNoPermsCreate"));
return new MenuPrompt(); return new MenuPrompt();
} }
@ -112,7 +112,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (player.hasPermission("quests.editor.edit")) { if (player.hasPermission("quests.editor.edit")) {
return new SelectEditPrompt(); return new SelectEditPrompt();
} else { } else {
player.sendMessage(RED + "You do not have permission to edit Quests."); player.sendMessage(RED + Lang.get("questEditorNoPermsCreate"));
return new MenuPrompt(); return new MenuPrompt();
} }
@ -121,12 +121,12 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (player.hasPermission("quests.editor.delete")) { if (player.hasPermission("quests.editor.delete")) {
return new SelectDeletePrompt(); return new SelectDeletePrompt();
} else { } else {
player.sendMessage(RED + "You do not have permission to delete Quests."); player.sendMessage(RED + Lang.get("questEditorNoPermsDelete"));
return new MenuPrompt(); return new MenuPrompt();
} }
} else if (input.equalsIgnoreCase("4")) { } else if (input.equalsIgnoreCase("4")) {
context.getForWhom().sendRawMessage(YELLOW + "Exited."); context.getForWhom().sendRawMessage(YELLOW + Lang.get("exited"));
return Prompt.END_OF_CONVERSATION; return Prompt.END_OF_CONVERSATION;
} }
@ -155,29 +155,29 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
String text = String text =
GOLD + "- Quest: " + AQUA + context.getSessionData(CK.Q_NAME) + GOLD + " -\n"; GOLD + "- Quest: " + AQUA + context.getSessionData(CK.Q_NAME) + GOLD + " -\n";
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - Set name\n"; text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - "+ Lang.get("questEditorName") +"\n";
if (context.getSessionData(CK.Q_ASK_MESSAGE) == null) { if (context.getSessionData(CK.Q_ASK_MESSAGE) == null) {
text += BLUE + "" + BOLD + "2" + RESET + RED + " - Set ask message " + DARKRED + "(Required, none set)\n"; text += BLUE + "" + BOLD + "2" + RESET + RED + " - " + Lang.get("questEditorAskMessage") + " " + DARKRED + "(Required, none set)\n";
} else { } else {
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - Set ask message (\"" + context.getSessionData(CK.Q_ASK_MESSAGE) + "\")\n"; text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - " + Lang.get("questEditorAskMessage") + " (\"" + context.getSessionData(CK.Q_ASK_MESSAGE) + "\")\n";
} }
if (context.getSessionData(CK.Q_FINISH_MESSAGE) == null) { if (context.getSessionData(CK.Q_FINISH_MESSAGE) == null) {
text += BLUE + "" + BOLD + "3" + RESET + RED + " - Set finish message " + DARKRED + "(Required, none set)\n"; text += BLUE + "" + BOLD + "3" + RESET + RED + " - " + Lang.get("questEditorFinishMessage") + " " + DARKRED + "(Required, none set)\n";
} else { } else {
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - Set finish message (\"" + context.getSessionData(CK.Q_FINISH_MESSAGE) + "\")\n"; text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("questEditorFinishMessage") + " (\"" + context.getSessionData(CK.Q_FINISH_MESSAGE) + "\")\n";
} }
if (context.getSessionData(CK.Q_REDO_DELAY) == null) { if (context.getSessionData(CK.Q_REDO_DELAY) == null) {
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - Set redo delay (None set)\n"; text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("questEditorRedoDelay") + " (None set)\n";
} else { } else {
//something here is throwing an exception //something here is throwing an exception
try{ try{
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - Set redo delay (" + Quests.getTime((Long) context.getSessionData(CK.Q_REDO_DELAY)) + ")\n"; text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("questEditorRedoDelay") + " (" + Quests.getTime((Long) context.getSessionData(CK.Q_REDO_DELAY)) + ")\n";
}catch(Exception e){ }catch(Exception e){
e.printStackTrace(); e.printStackTrace();
} }
@ -186,27 +186,27 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
} }
if (context.getSessionData(CK.Q_START_NPC) == null && quests.citizens != null) { if (context.getSessionData(CK.Q_START_NPC) == null && quests.citizens != null) {
text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - Set NPC start (None set)\n"; text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("questEditorNPCStart") + " (None set)\n";
} else if (quests.citizens != null) { } else if (quests.citizens != null) {
text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - Set NPC start (" + CitizensAPI.getNPCRegistry().getById((Integer) context.getSessionData(CK.Q_START_NPC)).getName() + ")\n"; text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("questEditorNPCStart") + " (" + CitizensAPI.getNPCRegistry().getById((Integer) context.getSessionData(CK.Q_START_NPC)).getName() + ")\n";
} }
if (context.getSessionData(CK.Q_START_BLOCK) == null) { if (context.getSessionData(CK.Q_START_BLOCK) == null) {
if (quests.citizens != null) { if (quests.citizens != null) {
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - Set Block start (None set)\n"; text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - " + Lang.get("questEditorBlockStart") + " (None set)\n";
} else { } else {
text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - Set Block start (None set)\n"; text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("questEditorBlockStart") + " (None set)\n";
} }
} else { } else {
if (quests.citizens != null) { if (quests.citizens != null) {
Location l = (Location) context.getSessionData(CK.Q_START_BLOCK); Location l = (Location) context.getSessionData(CK.Q_START_BLOCK);
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - Set Block start (" + l.getWorld().getName() + ", " + l.getBlockX() + ", " + l.getBlockY() + ", " + l.getBlockZ() + ")\n"; text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - " + Lang.get("questEditorBlockStart") + " (" + l.getWorld().getName() + ", " + l.getBlockX() + ", " + l.getBlockY() + ", " + l.getBlockZ() + ")\n";
} else { } else {
Location l = (Location) context.getSessionData(CK.Q_START_BLOCK); Location l = (Location) context.getSessionData(CK.Q_START_BLOCK);
text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - Set Block start (" + l.getWorld().getName() + ", " + l.getBlockX() + ", " + l.getBlockY() + ", " + l.getBlockZ() + ")\n"; text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("questEditorBlockStart") + " (" + l.getWorld().getName() + ", " + l.getBlockX() + ", " + l.getBlockY() + ", " + l.getBlockZ() + ")\n";
} }
} }
@ -215,53 +215,53 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (context.getSessionData(CK.Q_INITIAL_EVENT) == null) { if (context.getSessionData(CK.Q_INITIAL_EVENT) == null) {
if (quests.citizens != null) { if (quests.citizens != null) {
text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - Set initial Event (None set)\n"; text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - " + Lang.get("questEditorInitialEvent") + " (None set)\n";
} else { } else {
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - Set initial Event (None set)\n"; text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - " + Lang.get("questEditorInitialEvent") + " (None set)\n";
} }
} else { } else {
if (quests.citizens != null) { if (quests.citizens != null) {
String s = (String) context.getSessionData(CK.Q_INITIAL_EVENT); String s = (String) context.getSessionData(CK.Q_INITIAL_EVENT);
text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - Set initial Event (" + s + ")\n"; text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - " + Lang.get("questEditorInitialEvent") + " (" + s + ")\n";
} else { } else {
String s = (String) context.getSessionData(CK.Q_INITIAL_EVENT); String s = (String) context.getSessionData(CK.Q_INITIAL_EVENT);
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - Set initial Event (" + s + ")\n"; text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - " + Lang.get("questEditorInitialEvent") + " (" + s + ")\n";
} }
} }
if (quests.citizens != null) { if (quests.citizens != null) {
text += BLUE + "" + BOLD + "8" + RESET + DARKAQUA + " - Edit Requirements\n"; text += BLUE + "" + BOLD + "8" + RESET + DARKAQUA + " - " + Lang.get("questEditorReqs") + "\n";
} else { } else {
text += BLUE + "" + BOLD + "7" + RESET + DARKAQUA + " - Edit Requirements\n"; text += BLUE + "" + BOLD + "7" + RESET + DARKAQUA + " - " + Lang.get("questEditorReqs") + "\n";
} }
if (quests.citizens != null) { if (quests.citizens != null) {
text += BLUE + "" + BOLD + "9" + RESET + PINK + " - Edit Stages\n"; text += BLUE + "" + BOLD + "9" + RESET + PINK + " - " + Lang.get("questEditorStages") + "\n";
} else { } else {
text += BLUE + "" + BOLD + "8" + RESET + PINK + " - Edit Stages\n"; text += BLUE + "" + BOLD + "8" + RESET + PINK + " - " + Lang.get("questEditorStages") + "\n";
} }
if (quests.citizens != null) { if (quests.citizens != null) {
text += BLUE + "" + BOLD + "10" + RESET + GREEN + " - Edit Rewards\n"; text += BLUE + "" + BOLD + "10" + RESET + GREEN + " - " + Lang.get("questEditorRews") + "\n";
} else { } else {
text += BLUE + "" + BOLD + "9" + RESET + GREEN + " - Edit Rewards\n"; text += BLUE + "" + BOLD + "9" + RESET + GREEN + " - " + Lang.get("questEditorRews") + "\n";
} }
if (quests.citizens != null) { if (quests.citizens != null) {
text += BLUE + "" + BOLD + "11" + RESET + GOLD + " - Save\n"; text += BLUE + "" + BOLD + "11" + RESET + GOLD + " - " + Lang.get("save") + "\n";
} else { } else {
text += BLUE + "" + BOLD + "10" + RESET + GOLD + " - Save\n"; text += BLUE + "" + BOLD + "10" + RESET + GOLD + " - " + Lang.get("save") + "\n";
} }
if (quests.citizens != null) { if (quests.citizens != null) {
text += BLUE + "" + BOLD + "12" + RESET + RED + " - Exit\n"; text += BLUE + "" + BOLD + "12" + RESET + RED + " - " + Lang.get("exit") + "\n";
} else { } else {
text += BLUE + "" + BOLD + "11" + RESET + RED + " - Exit\n"; text += BLUE + "" + BOLD + "11" + RESET + RED + " - " + Lang.get("exit") + "\n";
} }
@ -387,7 +387,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
@Override @Override
public Prompt acceptInput(ConversationContext context, String input) { public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("cancel") == false) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
for (Quest q : quests.getQuests()) { for (Quest q : quests.getQuests()) {
@ -430,8 +430,8 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
@Override @Override
public String getPromptText(ConversationContext context) { public String getPromptText(ConversationContext context) {
String text = GOLD + "- Create Quest -\n"; String text = GOLD + "- " + Lang.get("questCreateHeader") + " -\n";
text += AQUA + "Create new Quest " + GOLD + "- " + Lang.get("enterQuestName"); text += AQUA + Lang.get("questCreateNew") + " " + GOLD + "- " + Lang.get("enterQuestName");
return text; return text;
@ -440,13 +440,13 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
@Override @Override
public Prompt acceptInput(ConversationContext context, String input) { public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("cancel") == false) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
for (Quest q : quests.quests) { for (Quest q : quests.quests) {
if (q.name.equalsIgnoreCase(input)) { if (q.name.equalsIgnoreCase(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + "Quest already exists!"); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questNameExists"));
return new QuestNamePrompt(); return new QuestNamePrompt();
} }
@ -455,14 +455,14 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (names.contains(input)) { if (names.contains(input)) {
context.getForWhom().sendRawMessage(ChatColor.RED + "Someone is creating a Quest with that name!"); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questBeingEdited"));
return new QuestNamePrompt(); return new QuestNamePrompt();
} }
if (input.contains(",")) { if (input.contains(",")) {
context.getForWhom().sendRawMessage(ChatColor.RED + "Name may not contain commas!"); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questNameContainsCommas"));
return new QuestNamePrompt(); return new QuestNamePrompt();
} }
@ -485,7 +485,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
@Override @Override
public String getPromptText(ConversationContext context) { public String getPromptText(ConversationContext context) {
return ChatColor.YELLOW + "Enter NPC ID, or -1 to clear the NPC start, or -2 to cancel"; return ChatColor.YELLOW + Lang.get("enterNPCStart");
} }
@ -495,7 +495,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (input.intValue() > -1) { if (input.intValue() > -1) {
if (CitizensAPI.getNPCRegistry().getById(input.intValue()) == null) { if (CitizensAPI.getNPCRegistry().getById(input.intValue()) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + "No NPC exists with that id!"); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("npcNonExistant"));
return new SetNpcStartPrompt(); return new SetNpcStartPrompt();
} }
@ -508,7 +508,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
} else if (input.intValue() == -2) { } else if (input.intValue() == -2) {
return new CreateMenuPrompt(); return new CreateMenuPrompt();
} else { } else {
context.getForWhom().sendRawMessage(ChatColor.RED + "No NPC exists with that id!"); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("npcNonExistant"));
return new SetNpcStartPrompt(); return new SetNpcStartPrompt();
} }
@ -520,8 +520,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
@Override @Override
public String getPromptText(ConversationContext context) { public String getPromptText(ConversationContext context) {
return ChatColor.YELLOW + "Right-click on a block to use as a start point, then enter \"done\" to save,\n" return ChatColor.YELLOW + Lang.get("enterBlockStart");
+ "or enter \"clear\" to clear the block start, or \"cancel\" to return";
} }
@ -529,9 +528,9 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
public Prompt acceptInput(ConversationContext context, String input) { public Prompt acceptInput(ConversationContext context, String input) {
Player player = (Player) context.getForWhom(); Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase("done") || input.equalsIgnoreCase("cancel")) { if (input.equalsIgnoreCase(Lang.get("cmdDone")) || input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
if (input.equalsIgnoreCase("done")) { if (input.equalsIgnoreCase(Lang.get("cmdDone"))) {
Block block = selectedBlockStarts.get(player); Block block = selectedBlockStarts.get(player);
if (block != null) { if (block != null) {
@ -539,7 +538,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
context.setSessionData(CK.Q_START_BLOCK, loc); context.setSessionData(CK.Q_START_BLOCK, loc);
selectedBlockStarts.remove(player); selectedBlockStarts.remove(player);
} else { } else {
player.sendMessage(ChatColor.RED + "You must select a block first."); player.sendMessage(ChatColor.RED + Lang.get("blockNotSelected"));
return new BlockStartPrompt(); return new BlockStartPrompt();
} }
@ -550,7 +549,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
return new CreateMenuPrompt(); return new CreateMenuPrompt();
} else if (input.equalsIgnoreCase("clear")) { } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
selectedBlockStarts.remove(player); selectedBlockStarts.remove(player);
context.setSessionData(CK.Q_START_BLOCK, null); context.setSessionData(CK.Q_START_BLOCK, null);
@ -568,14 +567,14 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
@Override @Override
public String getPromptText(ConversationContext context) { public String getPromptText(ConversationContext context) {
return ChatColor.YELLOW + "Enter Quest name (or \'cancel\' to return)"; return ChatColor.YELLOW + Lang.get("enterQuestName");
} }
@Override @Override
public Prompt acceptInput(ConversationContext context, String input) { public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("cancel") == false) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
for (Quest q : quests.quests) { for (Quest q : quests.quests) {
@ -586,7 +585,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
} }
if (s != null && s.equalsIgnoreCase(input) == false) { if (s != null && s.equalsIgnoreCase(input) == false) {
context.getForWhom().sendRawMessage(RED + "A Quest with that name already exists!"); context.getForWhom().sendRawMessage(RED + Lang.get("questNameExists"));
return new SetNamePrompt(); return new SetNamePrompt();
} }
} }
@ -594,13 +593,13 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
} }
if (names.contains(input)) { if (names.contains(input)) {
context.getForWhom().sendRawMessage(RED + "Someone is creating/editing a Quest with that name!"); context.getForWhom().sendRawMessage(RED + Lang.get("questBeingEdited"));
return new SetNamePrompt(); return new SetNamePrompt();
} }
if (input.contains(",")) { if (input.contains(",")) {
context.getForWhom().sendRawMessage(ChatColor.RED + "Name may not contain commas!"); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questNameContainsCommas"));
return new QuestNamePrompt(); return new QuestNamePrompt();
} }
@ -621,14 +620,14 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
@Override @Override
public String getPromptText(ConversationContext context) { public String getPromptText(ConversationContext context) {
return ChatColor.YELLOW + "Enter ask message (or \'cancel\' to return)"; return ChatColor.YELLOW + Lang.get("enterAskMessage");
} }
@Override @Override
public Prompt acceptInput(ConversationContext context, String input) { public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("cancel") == false) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
if (input.startsWith("++")) { if (input.startsWith("++")) {
if (context.getSessionData(CK.Q_ASK_MESSAGE) != null) { if (context.getSessionData(CK.Q_ASK_MESSAGE) != null) {
context.setSessionData(CK.Q_ASK_MESSAGE, context.getSessionData(CK.Q_ASK_MESSAGE) + " " + input.substring(2)); context.setSessionData(CK.Q_ASK_MESSAGE, context.getSessionData(CK.Q_ASK_MESSAGE) + " " + input.substring(2));
@ -648,14 +647,14 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
@Override @Override
public String getPromptText(ConversationContext context) { public String getPromptText(ConversationContext context) {
return ChatColor.YELLOW + "Enter finish message (or \'cancel\' to return)"; return ChatColor.YELLOW + Lang.get("enterFinishMessage");
} }
@Override @Override
public Prompt acceptInput(ConversationContext context, String input) { public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("cancel") == false) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
if (input.startsWith("++")) { if (input.startsWith("++")) {
if (context.getSessionData(CK.Q_FINISH_MESSAGE) != null) { if (context.getSessionData(CK.Q_FINISH_MESSAGE) != null) {
context.setSessionData(CK.Q_FINISH_MESSAGE, context.getSessionData(CK.Q_FINISH_MESSAGE) + " " + input.substring(2)); context.setSessionData(CK.Q_FINISH_MESSAGE, context.getSessionData(CK.Q_FINISH_MESSAGE) + " " + input.substring(2));
@ -675,7 +674,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
@Override @Override
public String getPromptText(ConversationContext context) { public String getPromptText(ConversationContext context) {
String text = DARKGREEN + "- Events -\n"; String text = DARKGREEN + "- " + Lang.get("event") + " -\n";
if (quests.events.isEmpty()) { if (quests.events.isEmpty()) {
text += RED + "- None"; text += RED + "- None";
} else { } else {
@ -684,7 +683,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
} }
} }
return text + YELLOW + "Enter an Event name, or enter \"clear\" to clear the initial Event, or \"cancel\" to return"; return text + YELLOW + Lang.get("questEditorEnterInitialEvent");
} }
@ -693,7 +692,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
Player player = (Player) context.getForWhom(); Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase("cancel") == false && input.equalsIgnoreCase("clear") == false) { if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
Event found = null; Event found = null;
@ -707,16 +706,16 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
} }
if (found == null) { if (found == null) {
player.sendMessage(RED + input + YELLOW + " is not a valid event name!"); player.sendMessage(RED + input + YELLOW + " " + Lang.get("questEditorInvalidName"));
return new InitialEventPrompt(); return new InitialEventPrompt();
} else { } else {
context.setSessionData(CK.Q_INITIAL_EVENT, found.getName()); context.setSessionData(CK.Q_INITIAL_EVENT, found.getName());
return new CreateMenuPrompt(); return new CreateMenuPrompt();
} }
} else if (input.equalsIgnoreCase("clear")) { } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.Q_INITIAL_EVENT, null); context.setSessionData(CK.Q_INITIAL_EVENT, null);
player.sendMessage(YELLOW + "Initial Event cleared."); player.sendMessage(YELLOW + Lang.get("questEditorEventCleared"));
return new CreateMenuPrompt(); return new CreateMenuPrompt();
} else { } else {
return new CreateMenuPrompt(); return new CreateMenuPrompt();
@ -730,7 +729,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
@Override @Override
public String getPromptText(ConversationContext context) { public String getPromptText(ConversationContext context) {
return ChatColor.YELLOW + "Enter amount of time (in milliseconds), or 0 to clear the redo delay, or -1 to cancel"; return ChatColor.YELLOW + Lang.get("questEditorEnterRedoDelay");
} }
@ -738,7 +737,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
protected Prompt acceptValidatedInput(ConversationContext context, Number input) { protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
if (input.longValue() < -1) { if (input.longValue() < -1) {
context.getForWhom().sendRawMessage(ChatColor.RED + "Amount must be a positive number."); context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorPositiveAmount"));
} else if (input.longValue() == 0) { } else if (input.longValue() == 0) {
context.setSessionData(CK.Q_REDO_DELAY, null); context.setSessionData(CK.Q_REDO_DELAY, null);
} else if (input.longValue() != -1) { } else if (input.longValue() != -1) {
@ -758,23 +757,23 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
String text = GREEN String text = GREEN
+ "1 - Yes\n" + "1 - Yes\n"
+ "2 - No"; + "2 - No";
return ChatColor.YELLOW + "Finish and save \"" + AQUA + context.getSessionData(CK.Q_NAME) + YELLOW + "\"?\n" + text; return ChatColor.YELLOW + Lang.get("questEditorSave") + " \"" + AQUA + context.getSessionData(CK.Q_NAME) + YELLOW + "\"?\n" + text;
} }
@Override @Override
public Prompt acceptInput(ConversationContext context, String input) { public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase("Yes")) { if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(Lang.get("yes"))) {
if (context.getSessionData(CK.Q_ASK_MESSAGE) == null) { if (context.getSessionData(CK.Q_ASK_MESSAGE) == null) {
context.getForWhom().sendRawMessage(RED + "You must set an ask message!"); context.getForWhom().sendRawMessage(RED + Lang.get("questEditorNeedAskMessage"));
return new CreateMenuPrompt(); return new CreateMenuPrompt();
} else if (context.getSessionData(CK.Q_FINISH_MESSAGE) == null) { } else if (context.getSessionData(CK.Q_FINISH_MESSAGE) == null) {
context.getForWhom().sendRawMessage(RED + "You must set a finish message!"); context.getForWhom().sendRawMessage(RED + Lang.get("questEditorNeedFinishMessage"));
return new CreateMenuPrompt(); return new CreateMenuPrompt();
} else if (StagesPrompt.getStages(context) == 0) { } else if (StagesPrompt.getStages(context) == 0) {
context.getForWhom().sendRawMessage(RED + "Your Quest has no Stages!"); context.getForWhom().sendRawMessage(RED + Lang.get("questEditorNeedStages"));
return new CreateMenuPrompt(); return new CreateMenuPrompt();
} }
@ -797,7 +796,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
ConfigurationSection newSection = questSection.createSection("custom" + customNum); ConfigurationSection newSection = questSection.createSection("custom" + customNum);
saveQuest(context, newSection); saveQuest(context, newSection);
data.save(new File(quests.getDataFolder(), "quests.yml")); data.save(new File(quests.getDataFolder(), "quests.yml"));
context.getForWhom().sendRawMessage(BOLD + "Quest saved! (You will need to perform a Quest reload for it to appear)"); context.getForWhom().sendRawMessage(BOLD + Lang.get("questEditorSaved"));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -805,7 +804,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
return Prompt.END_OF_CONVERSATION; return Prompt.END_OF_CONVERSATION;
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase("No")) { } else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(Lang.get("no"))) {
return new CreateMenuPrompt(); return new CreateMenuPrompt();
} else { } else {
return new SavePrompt(); return new SavePrompt();
@ -820,21 +819,21 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
public String getPromptText(ConversationContext context) { public String getPromptText(ConversationContext context) {
String text = GREEN String text = GREEN
+ "1 - Yes\n" + "1 - " + Lang.get("yes") + "\n"
+ "2 - No"; + "2 - " + Lang.get("no");
return ChatColor.YELLOW + "Are you sure you want to exit without saving?\n" + text; return ChatColor.YELLOW + Lang.get("questEditorExited") + "\n" + text;
} }
@Override @Override
public Prompt acceptInput(ConversationContext context, String input) { public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase("Yes")) { if (input.equalsIgnoreCase("1") || input.equalsIgnoreCase(Lang.get("yes"))) {
context.getForWhom().sendRawMessage(BOLD + "" + YELLOW + "Exited."); context.getForWhom().sendRawMessage(BOLD + "" + YELLOW + Lang.get("exited"));
return Prompt.END_OF_CONVERSATION; return Prompt.END_OF_CONVERSATION;
} else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase("No")) { } else if (input.equalsIgnoreCase("2") || input.equalsIgnoreCase(Lang.get("no"))) {
return new CreateMenuPrompt(); return new CreateMenuPrompt();
} else { } else {
return new ExitPrompt(); return new ExitPrompt();
@ -1695,14 +1694,14 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
@Override @Override
public String getPromptText(ConversationContext context) { public String getPromptText(ConversationContext context) {
String text = GOLD + "- " + "Delete Quest" + " -\n"; String text = GOLD + "- " + Lang.get("questEditorDelete") + " -\n";
for (Quest quest : quests.quests) { for (Quest quest : quests.quests) {
text += AQUA + quest.name + YELLOW + ","; text += AQUA + quest.name + YELLOW + ",";
} }
text = text.substring(0, text.length() - 1) + "\n"; text = text.substring(0, text.length() - 1) + "\n";
text += YELLOW + "Enter a Quest name, or \"cancel\" to return."; text += YELLOW + Lang.get("questEditorEnterQuestName");
return text; return text;
@ -1731,18 +1730,18 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
context.setSessionData(CK.ED_QUEST_DELETE, quest.name); context.setSessionData(CK.ED_QUEST_DELETE, quest.name);
return new DeletePrompt(); return new DeletePrompt();
} else { } else {
((Player) context.getForWhom()).sendMessage(RED + "The following Quests have \"" + PURPLE + context.getSessionData(CK.ED_QUEST_DELETE) + RED + "\" as a requirement:"); ((Player) context.getForWhom()).sendMessage(RED + Lang.get("questEditorQuestAsRequirement1") + " \"" + PURPLE + context.getSessionData(CK.ED_QUEST_DELETE) + RED + "\" " + Lang.get("questEditorQuestAsRequirement2"));
for (String s : used) { for (String s : used) {
((Player) context.getForWhom()).sendMessage(RED + "- " + DARKRED + s); ((Player) context.getForWhom()).sendMessage(RED + "- " + DARKRED + s);
} }
((Player) context.getForWhom()).sendMessage(RED + "You must modify these Quests so that they do not use it before deleting it."); ((Player) context.getForWhom()).sendMessage(RED + Lang.get("questEditorQuestAsRequirement3"));
return new SelectDeletePrompt(); return new SelectDeletePrompt();
} }
} }
} }
((Player) context.getForWhom()).sendMessage(RED + "Quest not found!"); ((Player) context.getForWhom()).sendMessage(RED + Lang.get("questEditorQuestNotFound"));
return new SelectDeletePrompt(); return new SelectDeletePrompt();
} else { } else {
@ -1758,8 +1757,8 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
public String getPromptText(ConversationContext context) { public String getPromptText(ConversationContext context) {
String text = String text =
RED + "Are you sure you want to delete the Quest " + " \"" + GOLD + (String) context.getSessionData(CK.ED_QUEST_DELETE) + RED + "\"?\n"; RED + Lang.get("questEditorDeleted") + " \"" + GOLD + (String) context.getSessionData(CK.ED_QUEST_DELETE) + RED + "\"?\n";
text += YELLOW + Lang.get("yes") + "/" + Lang.get("no"); text += YELLOW + Lang.get("yes") + "/" + Lang.get(Lang.get("no"));
return text; return text;
@ -1771,7 +1770,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (input.equalsIgnoreCase(Lang.get("yes"))) { if (input.equalsIgnoreCase(Lang.get("yes"))) {
deleteQuest(context); deleteQuest(context);
return Prompt.END_OF_CONVERSATION; return Prompt.END_OF_CONVERSATION;
} else if (input.equalsIgnoreCase(Lang.get("no"))) { } else if (input.equalsIgnoreCase(Lang.get(Lang.get("no")))) {
return new MenuPrompt(); return new MenuPrompt();
} else { } else {
return new DeletePrompt(); return new DeletePrompt();

View File

@ -1997,11 +1997,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
if (config.contains("quests." + s + ".stages.ordered." + s2 + ".script-to-run")) { if (config.contains("quests." + s + ".stages.ordered." + s2 + ".script-to-run")) {
if (ScriptRegistry.containsScript("quests." + s + ".stages.ordered." + s2 + ".script-to-run")) { if (ScriptRegistry.containsScript(config.getString("quests." + s + ".stages.ordered." + s2 + ".script-to-run"))) {
trigger = new QuestTaskTrigger(); trigger = new QuestTaskTrigger();
stage.script = config.getString("quests." + s + ".stages.ordered." + s2 + ".script-to-run"); stage.script = config.getString("quests." + s + ".stages.ordered." + s2 + ".script-to-run");
} else { } else {
printSevere(GOLD + "[Quests] " + RED + "script-to-run: " + GOLD + "in " + PINK + "Stage " + s2 + GOLD + " of Quest " + PURPLE + quest.name + GOLD + " is not a Denizen script!"); printSevere(GOLD + "[Quests] script-to-run: in Stage " + s2 + " of Quest " + quest.name + " is not a Denizen script!");
stageFailed = true; stageFailed = true;
break; break;
} }
@ -2015,7 +2015,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
if (checkList(config.getList("quests." + s + ".stages.ordered." + s2 + ".break-block-ids"), Integer.class)) { if (checkList(config.getList("quests." + s + ".stages.ordered." + s2 + ".break-block-ids"), Integer.class)) {
breakids = config.getIntegerList("quests." + s + ".stages.ordered." + s2 + ".break-block-ids"); breakids = config.getIntegerList("quests." + s + ".stages.ordered." + s2 + ".break-block-ids");
} else { } else {
printSevere(GOLD + "[Quests] " + RED + "break-block-ids: " + GOLD + "in " + PINK + "Stage " + s2 + GOLD + " of Quest " + PURPLE + quest.name + GOLD + " is not a list of numbers!"); printSevere(GOLD + "[Quests] break-block-ids: in Stage " + s2 + " of Quest " + quest.name + " is not a list of numbers!");
stageFailed = true; stageFailed = true;
break; break;
} }
@ -3559,8 +3559,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(milliseconds); calendar.setTimeInMillis(milliseconds);
long days = calendar.get(Calendar.DAY_OF_YEAR) - 1; Calendar epoch = Calendar.getInstance();
long hours = calendar.get(Calendar.HOUR_OF_DAY) - 1; epoch.setTimeInMillis(0);
long days = calendar.get(Calendar.DAY_OF_YEAR) - epoch.get(Calendar.DAY_OF_YEAR);
long hours = calendar.get(Calendar.HOUR_OF_DAY) - epoch.get(Calendar.HOUR_OF_DAY);
long minutes = calendar.get(Calendar.MINUTE); long minutes = calendar.get(Calendar.MINUTE);
long seconds = calendar.get(Calendar.SECOND); long seconds = calendar.get(Calendar.SECOND);
long milliSeconds2 = calendar.get(Calendar.MILLISECOND); long milliSeconds2 = calendar.get(Calendar.MILLISECOND);

View File

@ -29,11 +29,60 @@ public class Lang {
public void initPhrases(){ public void initPhrases(){
//English //English
//TODO: If finished, completely check everything.
//Quests
//Quest create menu
en.put("questEditorHeader", "Create Quest");
en.put("questEditorCreate", "Create new Quest");
en.put("questEditorEdit", "Edit a Quest");
en.put("questEditorDelete", "Delete Quest");
en.put("questEditorName", "Set name");
//Quests en.put("questEditorAskMessage", "Set ask message");
en.put("enterQuestName", "Enter Quest name (or \"cancel\" to return)"); en.put("questEditorFinishMessage", "Set finish message");
en.put("questEditorRedoDelay", "Set redo delay");
en.put("questEditorNPCStart", "Set NPC start");
en.put("questEditorBlockStart", "Set Block start");
en.put("questEditorInitialEvent", "Set initial Event");
en.put("questEditorReqs", "Edit Requirements");
en.put("questEditorStages", "Edit Stage");
en.put("questEditorRews", "Edit Rewards");
en.put("questEditorEnterQuestName", "Enter Quest name (or \"cancel\" to return)");
en.put("questEditorEnterAskMessage", "Enter ask message (or \"cancel\" to return)");
en.put("questEditorEnterFinishMessage", "Enter finish message (or \"cancel\" to return)");
en.put("questEditorEnterRedoDelay", "Enter amount of time (in milliseconds), 0 to clear the redo delay or -1 to cancel ");
en.put("questEditorEnterNPCStart", "Enter NPC ID, -1 to clear the NPC start or -2 to cancel");
en.put("questEditorEnterBlockStart", "Right-click on a block to use as a start point, then enter \"done\" to save,\n"
+ "or enter \"clear\" to clear the block start, or \"cancel\" to return");
en.put("questEditorEnterInitialEvent", "Enter an Event name, or enter \"clear\" to clear the initial Event, or \"cancel\" to return");
//Quest create menu errors
en.put("questEditorNameExists", "A Quest with that name already exists!");
en.put("questEditorBeingEdited", "Someone is creating/editing a Quest with that name!");
en.put("questEditorInvalidQuestName", "Name may not contain commas!");
en.put("questEditorInvalidEventName", "is not a valid event name!");
en.put("questEditorInvalidNPC", "No NPC exists with that id!");
en.put("questEditorNoStartBlockSelected", "You must select a block first.");
en.put("questEditorPositiveAmount", "Amount must be a positive number.");
en.put("questEditorQuestAsRequirement1", "The following Quests have");
en.put("questEditorQuestAsRequirement2", "as a requirement:");
en.put("questEditorQuestAsRequirement3", "You must modify these Quests so that they do not use it before deleting it.");
en.put("questEditorQuestNotFound", "Quest not found!");
en.put("questEditorEventCleared", "Initial Event cleared.");
en.put("questEditorSave", "Finish and save");
en.put("questEditorNeedAskMessage", "You must set an ask message!");
en.put("questEditorNeedFinishMessage", "You must set a finish message!");
en.put("questEditorNeedStages", "Your Quest has no Stages!");
en.put("questEditorSaved", "Quest saved! (You will need to perform a Quest reload for it to appear)");
en.put("questEditorExited", "Are you sure you want to exit without saving?");
en.put("questEditorDeleted", "Are you sure you want to delete the Quest");
en.put("questEditorNoPermsCreate", "You do not have permission to create Quests.");
en.put("questEditorNoPermsEdit", "You do not have permission to edit Quests.");
en.put("questEditorNoPermsDelete", "You do not have permission to delete Quests.");
// //
@ -206,6 +255,7 @@ public class Lang {
//Misc //Misc
en.put("event", "Event"); en.put("event", "Event");
en.put("save", "save");
en.put("exit", "Exit"); en.put("exit", "Exit");
en.put("exited", "Exited."); en.put("exited", "Exited.");
en.put("yes", "Yes"); en.put("yes", "Yes");

View File

@ -1,6 +1,6 @@
name: Quests name: Quests
main: me.blackvein.quests.Quests main: me.blackvein.quests.Quests
version: 1.6.4 version: 1.6.7
description: Player questing system description: Player questing system
website: http://dev.bukkit.org/server-mods/quests/ website: http://dev.bukkit.org/server-mods/quests/
dev-url: https://github.com/Blackvein/Quests/ dev-url: https://github.com/Blackvein/Quests/