mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-27 21:26:29 +01:00
Disallow empty quest/action names from external sources
This commit is contained in:
parent
d3aea3ee3b
commit
8531d4031c
@ -250,8 +250,8 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
}
|
||||
|
||||
public String getTitle(ConversationContext context) {
|
||||
return Lang.get("quest") + ": " + context.getSessionData(CK.Q_NAME) + " " + ChatColor.GRAY
|
||||
+ (context.getSessionData(CK.Q_ID) != null ? "(" + Lang.get("id") + ":"
|
||||
return Lang.get("quest") + ": " + context.getSessionData(CK.Q_NAME) + "" + ChatColor.GRAY
|
||||
+ (context.getSessionData(CK.Q_ID) != null ? " (" + Lang.get("id") + ":"
|
||||
+ context.getSessionData(CK.Q_ID) + ")": "");
|
||||
}
|
||||
|
||||
@ -529,6 +529,11 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext context, String input) {
|
||||
if (input == null) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
|
||||
return new QuestSelectCreatePrompt(plugin, context, QuestFactory.this);
|
||||
}
|
||||
input = input.trim();
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
for (Quest q : plugin.getQuests()) {
|
||||
if (q.getName().equalsIgnoreCase(input)) {
|
||||
@ -544,6 +549,10 @@ public class QuestFactory implements ConversationAbandonedListener {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("questEditorInvalidQuestName"));
|
||||
return new QuestSelectCreatePrompt(plugin, context, QuestFactory.this);
|
||||
}
|
||||
if (input.equals("")) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
|
||||
return new QuestSelectCreatePrompt(plugin, context, QuestFactory.this);
|
||||
}
|
||||
context.setSessionData(CK.Q_NAME, input);
|
||||
names.add(input);
|
||||
return new QuestMainPrompt(plugin, context, QuestFactory.this);
|
||||
|
@ -462,6 +462,11 @@ public class ActionFactory implements ConversationAbandonedListener {
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext context, String input) {
|
||||
if (input == null) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
|
||||
return new ActionSelectCreatePrompt(context, ActionFactory.this);
|
||||
}
|
||||
input = input.trim();
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
for (Action e : plugin.getActions()) {
|
||||
if (e.getName().equalsIgnoreCase(input)) {
|
||||
@ -477,6 +482,10 @@ public class ActionFactory implements ConversationAbandonedListener {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorAlpha"));
|
||||
return new ActionSelectCreatePrompt(context, ActionFactory.this);
|
||||
}
|
||||
if (input.equals("")) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
|
||||
return new ActionSelectCreatePrompt(context, ActionFactory.this);
|
||||
}
|
||||
context.setSessionData(CK.E_NAME, input);
|
||||
names.add(input);
|
||||
return new ActionMainPrompt(context, ActionFactory.this);
|
||||
|
Loading…
Reference in New Issue
Block a user