mirror of
https://github.com/PikaMug/Quests.git
synced 2025-02-03 14:11:32 +01:00
Remove editor access to shear/cut blocks objective
This commit is contained in:
parent
d6bbe086d8
commit
1749fb4306
@ -39,7 +39,7 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
|
|||||||
this.pref = "stage" + stageNum;
|
this.pref = "stage" + stageNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final int size = 6;
|
private final int size = 5;
|
||||||
|
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return size;
|
return size;
|
||||||
@ -55,9 +55,8 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
|
|||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
case 4:
|
case 4:
|
||||||
case 5:
|
|
||||||
return ChatColor.BLUE;
|
return ChatColor.BLUE;
|
||||||
case 6:
|
case 5:
|
||||||
return ChatColor.GREEN;
|
return ChatColor.GREEN;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
@ -75,8 +74,6 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
|
|||||||
case 4:
|
case 4:
|
||||||
return ChatColor.YELLOW + Lang.get("stageEditorUseBlocks");
|
return ChatColor.YELLOW + Lang.get("stageEditorUseBlocks");
|
||||||
case 5:
|
case 5:
|
||||||
return ChatColor.YELLOW + Lang.get("stageEditorCutBlocks");
|
|
||||||
case 6:
|
|
||||||
return ChatColor.GREEN + Lang.get("done");
|
return ChatColor.GREEN + Lang.get("done");
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
@ -139,19 +136,6 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
case 5:
|
case 5:
|
||||||
if (context.getSessionData(pref + CK.S_CUT_NAMES) == null) {
|
|
||||||
return ChatColor.GRAY + " (" + Lang.get("noneSet") + ")";
|
|
||||||
} else {
|
|
||||||
String text = "\n";
|
|
||||||
LinkedList<String> names = (LinkedList<String>) context.getSessionData(pref + CK.S_CUT_NAMES);
|
|
||||||
LinkedList<Integer> amnts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_CUT_AMOUNTS);
|
|
||||||
for (int i = 0; i < names.size(); i++) {
|
|
||||||
text += ChatColor.GRAY + " - " + ChatColor.BLUE + ItemUtil.getPrettyItemName(names.get(i))
|
|
||||||
+ ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + amnts.get(i) + "\n";
|
|
||||||
}
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
case 6:
|
|
||||||
return "";
|
return "";
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
@ -185,8 +169,6 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
|
|||||||
case 4:
|
case 4:
|
||||||
return new BlocksUseListPrompt(context);
|
return new BlocksUseListPrompt(context);
|
||||||
case 5:
|
case 5:
|
||||||
return new BlocksShearListPrompt(context);
|
|
||||||
case 6:
|
|
||||||
try {
|
try {
|
||||||
return new StageMainPrompt(stageNum, context);
|
return new StageMainPrompt(stageNum, context);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -1449,317 +1431,4 @@ public class BlocksPrompt extends QuestsEditorNumericPrompt {
|
|||||||
return new BlocksUseListPrompt(context);
|
return new BlocksUseListPrompt(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BlocksShearListPrompt extends QuestsEditorNumericPrompt {
|
|
||||||
|
|
||||||
public BlocksShearListPrompt(ConversationContext context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final int size = 5;
|
|
||||||
|
|
||||||
public int getSize() {
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle(ConversationContext context) {
|
|
||||||
return Lang.get("stageEditorCutBlocks");
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChatColor getNumberColor(ConversationContext context, int number) {
|
|
||||||
switch (number) {
|
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
case 3:
|
|
||||||
return ChatColor.BLUE;
|
|
||||||
case 4:
|
|
||||||
return ChatColor.RED;
|
|
||||||
case 5:
|
|
||||||
return ChatColor.GREEN;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSelectionText(ConversationContext context, int number) {
|
|
||||||
switch(number) {
|
|
||||||
case 1:
|
|
||||||
return ChatColor.YELLOW + Lang.get("stageEditorSetBlockNames");
|
|
||||||
case 2:
|
|
||||||
return ChatColor.YELLOW + Lang.get("stageEditorSetBlockAmounts");
|
|
||||||
case 3:
|
|
||||||
return ChatColor.YELLOW + Lang.get("stageEditorSetBlockDurability");
|
|
||||||
case 4:
|
|
||||||
return ChatColor.RED + Lang.get("clear");
|
|
||||||
case 5:
|
|
||||||
return ChatColor.GREEN + Lang.get("done");
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public String getAdditionalText(ConversationContext context, int number) {
|
|
||||||
switch(number) {
|
|
||||||
case 1:
|
|
||||||
if (context.getSessionData(pref + CK.S_CUT_NAMES) != null) {
|
|
||||||
String text = "\n";
|
|
||||||
for (String s : (List<String>) context.getSessionData(pref + CK.S_CUT_NAMES)) {
|
|
||||||
text += ChatColor.GRAY + " - " + ChatColor.AQUA + ItemUtil.getPrettyItemName(s) + "\n";
|
|
||||||
}
|
|
||||||
return text;
|
|
||||||
} else {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
case 2:
|
|
||||||
if (context.getSessionData(pref + CK.S_CUT_AMOUNTS) != null) {
|
|
||||||
String text = "\n";
|
|
||||||
for (Integer i : (List<Integer>) context.getSessionData(pref + CK.S_CUT_AMOUNTS)) {
|
|
||||||
text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\n";
|
|
||||||
}
|
|
||||||
return text;
|
|
||||||
} else {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
case 3:
|
|
||||||
if (context.getSessionData(pref + CK.S_CUT_DURABILITY) != null) {
|
|
||||||
String text = "\n";
|
|
||||||
for (Short s : (List<Short>) context.getSessionData(pref + CK.S_CUT_DURABILITY)) {
|
|
||||||
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
|
|
||||||
}
|
|
||||||
return text;
|
|
||||||
} else {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
case 4:
|
|
||||||
case 5:
|
|
||||||
return "";
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPromptText(ConversationContext context) {
|
|
||||||
QuestsEditorPostOpenNumericPromptEvent event = new QuestsEditorPostOpenNumericPromptEvent(context, this);
|
|
||||||
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
String text = ChatColor.GOLD + "- " + getTitle(context) + " -\n";
|
|
||||||
for (int i = 1; i <= size; i++) {
|
|
||||||
text += getNumberColor(context, i) + "" + ChatColor.BOLD + i + ChatColor.RESET + " - "
|
|
||||||
+ getSelectionText(context, i) + " " + getAdditionalText(context, i) + "\n";
|
|
||||||
}
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
|
|
||||||
switch(input.intValue()) {
|
|
||||||
case 1:
|
|
||||||
return new BlockShearNamesPrompt(context);
|
|
||||||
case 2:
|
|
||||||
return new BlockShearAmountsPrompt(context);
|
|
||||||
case 3:
|
|
||||||
return new BlockShearDurabilityPrompt(context);
|
|
||||||
case 4:
|
|
||||||
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("stageEditorObjectiveCleared"));
|
|
||||||
context.setSessionData(pref + CK.S_CUT_NAMES, null);
|
|
||||||
context.setSessionData(pref + CK.S_CUT_AMOUNTS, null);
|
|
||||||
context.setSessionData(pref + CK.S_CUT_DURABILITY, null);
|
|
||||||
return new BlocksShearListPrompt(context);
|
|
||||||
case 5:
|
|
||||||
int one;
|
|
||||||
int two;
|
|
||||||
if (context.getSessionData(pref + CK.S_CUT_NAMES) != null) {
|
|
||||||
one = ((List<Integer>) context.getSessionData(pref + CK.S_CUT_NAMES)).size();
|
|
||||||
} else {
|
|
||||||
one = 0;
|
|
||||||
}
|
|
||||||
if (context.getSessionData(pref + CK.S_CUT_AMOUNTS) != null) {
|
|
||||||
two = ((List<Integer>) context.getSessionData(pref + CK.S_CUT_AMOUNTS)).size();
|
|
||||||
} else {
|
|
||||||
two = 0;
|
|
||||||
}
|
|
||||||
if (one == two) {
|
|
||||||
int missing;
|
|
||||||
LinkedList<Short> elements;
|
|
||||||
if (context.getSessionData(pref + CK.S_CUT_DURABILITY) != null) {
|
|
||||||
missing = one - ((List<Short>) context.getSessionData(pref + CK.S_CUT_DURABILITY)).size();
|
|
||||||
elements = (LinkedList<Short>) context.getSessionData(pref + CK.S_CUT_DURABILITY);
|
|
||||||
} else {
|
|
||||||
missing = one;
|
|
||||||
elements = new LinkedList<Short>();
|
|
||||||
}
|
|
||||||
for (int i = 0; i < missing; i++) {
|
|
||||||
elements.add((short) 0);
|
|
||||||
}
|
|
||||||
context.setSessionData(pref + CK.S_CUT_DURABILITY, elements);
|
|
||||||
return new BlocksPrompt(stageNum, context);
|
|
||||||
} else {
|
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listsNotSameSize"));
|
|
||||||
return new BlocksShearListPrompt(context);
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return new BlocksPrompt(stageNum, context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class BlockShearNamesPrompt extends QuestsEditorStringPrompt {
|
|
||||||
|
|
||||||
public BlockShearNamesPrompt(ConversationContext context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTitle(ConversationContext context) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getQueryText(ConversationContext context) {
|
|
||||||
return Lang.get("stageEditorEnterBlockNames");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPromptText(ConversationContext context) {
|
|
||||||
QuestsEditorPostOpenStringPromptEvent event = new QuestsEditorPostOpenStringPromptEvent(context, this);
|
|
||||||
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
return ChatColor.YELLOW + getQueryText(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Prompt acceptInput(ConversationContext context, String input) {
|
|
||||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
|
||||||
String[] args = input.split(" ");
|
|
||||||
LinkedList<String> names = new LinkedList<String>();
|
|
||||||
for (String s : args) {
|
|
||||||
try {
|
|
||||||
Material m = Material.matchMaterial(s);
|
|
||||||
if (m != null) {
|
|
||||||
if (m.isBlock()) {
|
|
||||||
names.add(s);
|
|
||||||
} else {
|
|
||||||
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + ChatColor.RED + " "
|
|
||||||
+ Lang.get("stageEditorNotSolid"));
|
|
||||||
return new BlockShearNamesPrompt(context);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + ChatColor.RED + " "
|
|
||||||
+ Lang.get("stageEditorInvalidBlockName"));
|
|
||||||
return new BlockShearNamesPrompt(context);
|
|
||||||
}
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
|
|
||||||
+ Lang.get("stageEditorNotListofNumbers"));
|
|
||||||
return new BlockShearNamesPrompt(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
context.setSessionData(pref + CK.S_CUT_NAMES, names);
|
|
||||||
}
|
|
||||||
return new BlocksShearListPrompt(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class BlockShearAmountsPrompt extends QuestsEditorStringPrompt {
|
|
||||||
|
|
||||||
public BlockShearAmountsPrompt(ConversationContext context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTitle(ConversationContext context) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getQueryText(ConversationContext context) {
|
|
||||||
return Lang.get("stageEditorEnterBlockAmounts");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPromptText(ConversationContext context) {
|
|
||||||
QuestsEditorPostOpenStringPromptEvent event = new QuestsEditorPostOpenStringPromptEvent(context, this);
|
|
||||||
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
return ChatColor.YELLOW + getQueryText(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Prompt acceptInput(ConversationContext context, String input) {
|
|
||||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
|
||||||
String[] args = input.split(" ");
|
|
||||||
LinkedList<Integer> amounts = new LinkedList<Integer>();
|
|
||||||
for (String s : args) {
|
|
||||||
try {
|
|
||||||
if (Integer.parseInt(s) > 0) {
|
|
||||||
amounts.add(Integer.parseInt(s));
|
|
||||||
} else {
|
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED
|
|
||||||
+ Lang.get("invalidMinimum").replace("<number>", "1"));
|
|
||||||
return new BlockShearAmountsPrompt(context);
|
|
||||||
}
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
|
|
||||||
+ Lang.get("stageEditorNotListofNumbers"));
|
|
||||||
return new BlockShearAmountsPrompt(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
context.setSessionData(pref + CK.S_CUT_AMOUNTS, amounts);
|
|
||||||
}
|
|
||||||
return new BlocksShearListPrompt(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class BlockShearDurabilityPrompt extends QuestsEditorStringPrompt {
|
|
||||||
|
|
||||||
public BlockShearDurabilityPrompt(ConversationContext context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTitle(ConversationContext context) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getQueryText(ConversationContext context) {
|
|
||||||
return Lang.get("stageEditorEnterBlockDurability");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPromptText(ConversationContext context) {
|
|
||||||
QuestsEditorPostOpenStringPromptEvent event = new QuestsEditorPostOpenStringPromptEvent(context, this);
|
|
||||||
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
|
||||||
|
|
||||||
return ChatColor.YELLOW + getQueryText(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Prompt acceptInput(ConversationContext context, String input) {
|
|
||||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
|
||||||
String[] args = input.split(" ");
|
|
||||||
LinkedList<Short> durability = new LinkedList<Short>();
|
|
||||||
for (String s : args) {
|
|
||||||
try {
|
|
||||||
if (Short.parseShort(s) >= 0) {
|
|
||||||
durability.add(Short.parseShort(s));
|
|
||||||
} else {
|
|
||||||
context.getForWhom().sendRawMessage(ChatColor.RED
|
|
||||||
+ Lang.get("invalidMinimum").replace("<number>", "0"));
|
|
||||||
return new BlockShearDurabilityPrompt(context);
|
|
||||||
}
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
|
|
||||||
+ Lang.get("stageEditorNotListofNumbers"));
|
|
||||||
return new BlockShearDurabilityPrompt(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
context.setSessionData(pref + CK.S_CUT_DURABILITY, durability);
|
|
||||||
}
|
|
||||||
return new BlocksShearListPrompt(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user