From c81e2c103591ac447964b0a36c19724b30c7044f Mon Sep 17 00:00:00 2001 From: fullwall Date: Mon, 22 Oct 2012 14:54:01 +0800 Subject: [PATCH] Update website --- .../trait/text/PageChangePrompt.java | 2 +- .../net/citizensnpcs/trait/text/Text.java | 2 +- .../trait/text/TextAddPrompt.java | 2 +- .../trait/text/TextEditPrompt.java | 2 +- .../trait/text/TextEditStartPrompt.java | 4 +- .../trait/text/TextRemovePrompt.java | 6 +-- .../trait/text/TextStartPrompt.java | 53 +++++++++++++++++++ src/main/resources/plugin.yml | 2 +- 8 files changed, 63 insertions(+), 10 deletions(-) create mode 100644 src/main/java/net/citizensnpcs/trait/text/TextStartPrompt.java diff --git a/src/main/java/net/citizensnpcs/trait/text/PageChangePrompt.java b/src/main/java/net/citizensnpcs/trait/text/PageChangePrompt.java index f051d3947..2fdf49285 100644 --- a/src/main/java/net/citizensnpcs/trait/text/PageChangePrompt.java +++ b/src/main/java/net/citizensnpcs/trait/text/PageChangePrompt.java @@ -21,7 +21,7 @@ public class PageChangePrompt extends NumericPrompt { Player player = (Player) context.getForWhom(); if (!text.sendPage(player, input.intValue())) { Messaging.sendErrorTr(player, Messages.TEXT_EDITOR_INVALID_PAGE); - return new StartPrompt(text); + return new TextStartPrompt(text); } return (Prompt) context.getSessionData("previous"); } diff --git a/src/main/java/net/citizensnpcs/trait/text/Text.java b/src/main/java/net/citizensnpcs/trait/text/Text.java index a134f36e6..39d656cc3 100644 --- a/src/main/java/net/citizensnpcs/trait/text/Text.java +++ b/src/main/java/net/citizensnpcs/trait/text/Text.java @@ -65,7 +65,7 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve public Editor getEditor(final Player player) { final Conversation conversation = new ConversationFactory(plugin) .addConversationAbandonedListener(this).withLocalEcho(false).withEscapeSequence("/npc text") - .withEscapeSequence("exit").withModality(false).withFirstPrompt(new StartPrompt(this)) + .withEscapeSequence("exit").withModality(false).withFirstPrompt(new TextStartPrompt(this)) .buildConversation(player); return new Editor() { diff --git a/src/main/java/net/citizensnpcs/trait/text/TextAddPrompt.java b/src/main/java/net/citizensnpcs/trait/text/TextAddPrompt.java index 5f97ea24a..0e9984216 100644 --- a/src/main/java/net/citizensnpcs/trait/text/TextAddPrompt.java +++ b/src/main/java/net/citizensnpcs/trait/text/TextAddPrompt.java @@ -20,7 +20,7 @@ public class TextAddPrompt extends StringPrompt { public Prompt acceptInput(ConversationContext context, String input) { text.add(input); Messaging.sendTr((Player) context.getForWhom(), Messages.TEXT_EDITOR_ADDED_ENTRY, input); - return new StartPrompt(text); + return new TextStartPrompt(text); } @Override diff --git a/src/main/java/net/citizensnpcs/trait/text/TextEditPrompt.java b/src/main/java/net/citizensnpcs/trait/text/TextEditPrompt.java index 6648bc31a..97fd95c97 100644 --- a/src/main/java/net/citizensnpcs/trait/text/TextEditPrompt.java +++ b/src/main/java/net/citizensnpcs/trait/text/TextEditPrompt.java @@ -22,7 +22,7 @@ public class TextEditPrompt extends StringPrompt { text.edit(index, input); Messaging .sendTr((CommandSender) context.getForWhom(), Messages.TEXT_EDITOR_EDITED_TEXT, index, input); - return new StartPrompt(text); + return new TextStartPrompt(text); } @Override diff --git a/src/main/java/net/citizensnpcs/trait/text/TextEditStartPrompt.java b/src/main/java/net/citizensnpcs/trait/text/TextEditStartPrompt.java index 0241f93b0..c4300526e 100644 --- a/src/main/java/net/citizensnpcs/trait/text/TextEditStartPrompt.java +++ b/src/main/java/net/citizensnpcs/trait/text/TextEditStartPrompt.java @@ -22,7 +22,7 @@ public class TextEditStartPrompt extends StringPrompt { int index = Integer.parseInt(input); if (!text.hasIndex(index)) { Messaging.sendErrorTr(player, Messages.TEXT_EDITOR_INVALID_INDEX, index); - return new StartPrompt(text); + return new TextStartPrompt(text); } context.setSessionData("index", index); return new TextEditPrompt(text); @@ -33,7 +33,7 @@ public class TextEditStartPrompt extends StringPrompt { } } Messaging.sendErrorTr(player, Messages.TEXT_EDITOR_INVALID_INPUT); - return new StartPrompt(text); + return new TextStartPrompt(text); } @Override diff --git a/src/main/java/net/citizensnpcs/trait/text/TextRemovePrompt.java b/src/main/java/net/citizensnpcs/trait/text/TextRemovePrompt.java index 9147287e2..49857ea70 100644 --- a/src/main/java/net/citizensnpcs/trait/text/TextRemovePrompt.java +++ b/src/main/java/net/citizensnpcs/trait/text/TextRemovePrompt.java @@ -22,11 +22,11 @@ public class TextRemovePrompt extends StringPrompt { int index = Integer.parseInt(input); if (!text.hasIndex(index)) { Messaging.sendErrorTr(player, Messages.TEXT_EDITOR_INVALID_INDEX, index); - return new StartPrompt(text); + return new TextStartPrompt(text); } text.remove(index); Messaging.sendTr(player, Messages.TEXT_EDITOR_REMOVED_ENTRY, index); - return new StartPrompt(text); + return new TextStartPrompt(text); } catch (NumberFormatException ex) { if (input.equalsIgnoreCase("page")) { context.setSessionData("previous", this); @@ -34,7 +34,7 @@ public class TextRemovePrompt extends StringPrompt { } } Messaging.sendErrorTr(player, Messages.TEXT_EDITOR_INVALID_INPUT); - return new StartPrompt(text); + return new TextStartPrompt(text); } @Override diff --git a/src/main/java/net/citizensnpcs/trait/text/TextStartPrompt.java b/src/main/java/net/citizensnpcs/trait/text/TextStartPrompt.java new file mode 100644 index 000000000..bc50c62fb --- /dev/null +++ b/src/main/java/net/citizensnpcs/trait/text/TextStartPrompt.java @@ -0,0 +1,53 @@ +package net.citizensnpcs.trait.text; + +import net.citizensnpcs.util.Messages; +import net.citizensnpcs.util.Messaging; + +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.conversations.ConversationContext; +import org.bukkit.conversations.Prompt; +import org.bukkit.conversations.StringPrompt; + +public class TextStartPrompt extends StringPrompt { + private final Text text; + + public TextStartPrompt(Text text) { + this.text = text; + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + input = ChatColor.stripColor(input.trim().split(" ")[0]); + CommandSender sender = (CommandSender) context.getForWhom(); + if (input.equalsIgnoreCase("add")) + return new TextAddPrompt(text); + else if (input.equalsIgnoreCase("edit")) + return new TextEditStartPrompt(text); + else if (input.equalsIgnoreCase("remove")) + return new TextRemovePrompt(text); + else if (input.equalsIgnoreCase("random")) + Messaging.sendTr(sender, Messages.TEXT_EDITOR_RANDOM_TALKER_SET, text.toggleRandomTalker()); + else if (input.equalsIgnoreCase("realistic looking")) + Messaging.sendTr(sender, Messages.TEXT_EDITOR_REALISTIC_LOOKING_SET, + text.toggleRealisticLooking()); + else if (input.equalsIgnoreCase("close")) + Messaging.sendTr(sender, Messages.TEXT_EDITOR_CLOSE_TALKER_SET, text.toggle()); + else if (input.equalsIgnoreCase("help")) { + context.setSessionData("said-text", false); + Messaging.send(sender, getPromptText(context)); + } else + Messaging.sendErrorTr(sender, Messages.TEXT_EDITOR_INVALID_EDIT_TYPE); + + return new TextStartPrompt(text); + } + + @Override + public String getPromptText(ConversationContext context) { + if (context.getSessionData("said-text") == Boolean.TRUE) + return ""; + String text = Messaging.tr(Messages.TEXT_EDITOR_START_PROMPT); + context.setSessionData("said-text", Boolean.TRUE); + return text; + } +} \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 94d9a87af..be5c10e87 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -3,7 +3,7 @@ authors: [aPunch, fullwall] softdepend: [Vault] version: 2.0.3 main: net.citizensnpcs.Citizens -website: http://www.citizensnpcs.net +website: http://www.citizensnpcs.com commands: traitc: description: Configures traits