mirror of https://github.com/PikaMug/Quests.git
Auto-fill supplemental objective lists
This commit is contained in:
parent
86d9e2c665
commit
9aa26d5b28
|
@ -3022,7 +3022,8 @@ public class Quester implements IQuester {
|
|||
final String[] message = ConfigUtil.parseStringWithPossibleLineBreaks(getCurrentStage(quest)
|
||||
.getDeliverMessages().get(new Random().nextInt(getCurrentStage(quest).getDeliverMessages()
|
||||
.size())), plugin.getDependencies().getCitizens().getNPCRegistry()
|
||||
.getByUniqueId(getCurrentStage(quest).getItemDeliveryTargets().get(items.indexOf(found))));
|
||||
.getByUniqueId(getCurrentStage(quest).getItemDeliveryTargets().get(items.indexOf(found))),
|
||||
toDeliver - newAmount);
|
||||
player.sendMessage(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -1545,7 +1545,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
|
|||
for (int i = 0 ; i < stage.getLocationsToReach().size(); i++) {
|
||||
if (i < data.locationsReached.size()) {
|
||||
final ChatColor color = !data.locationsReached.get(i) ? ChatColor.GREEN : ChatColor.GRAY;
|
||||
String message = color + Lang.get(quester.getPlayer(), "goTo");
|
||||
String message = color + "- " + Lang.get(quester.getPlayer(), "goTo");
|
||||
message = message.replace("<location>", stage.getLocationNames().get(i));
|
||||
quester.sendMessage(message);
|
||||
}
|
||||
|
|
|
@ -542,6 +542,7 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
|
@ -558,6 +559,19 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
|
|||
}
|
||||
}
|
||||
context.setSessionData(pref + CK.S_MOB_TYPES, mobTypes);
|
||||
|
||||
LinkedList<Integer> amounts = new LinkedList<>();
|
||||
if (context.getSessionData(pref + CK.S_MOB_AMOUNTS) != null) {
|
||||
amounts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_MOB_AMOUNTS);
|
||||
}
|
||||
if (amounts != null) {
|
||||
for (int i = 0; i < mobTypes.size(); i++) {
|
||||
if (i >= amounts.size()) {
|
||||
amounts.add(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
context.setSessionData(pref + CK.S_MOB_AMOUNTS, amounts);
|
||||
}
|
||||
return new MobsKillListPrompt(context);
|
||||
}
|
||||
|
@ -778,112 +792,6 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
|
|||
}
|
||||
}
|
||||
|
||||
public class MobsFishPrompt extends QuestsEditorStringPrompt {
|
||||
|
||||
public MobsFishPrompt(final ConversationContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle(final ConversationContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryText(final ConversationContext context) {
|
||||
return Lang.get("stageEditorCatchFishPrompt");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
if (context.getPlugin() != null) {
|
||||
final QuestsEditorPostOpenStringPromptEvent event
|
||||
= new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
if (!input.equalsIgnoreCase(Lang.get("cmdCancel")) && !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
try {
|
||||
final int i = Integer.parseInt(input);
|
||||
if (i < 0) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorPositiveAmount"));
|
||||
return new MobsFishPrompt(context);
|
||||
} else if (i > 0) {
|
||||
context.setSessionData(pref + CK.S_FISH, i);
|
||||
}
|
||||
} catch (final NumberFormatException e) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber")
|
||||
.replace("<input>", input));
|
||||
return new MobsFishPrompt(context);
|
||||
}
|
||||
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
context.setSessionData(pref + CK.S_FISH, null);
|
||||
}
|
||||
return new MobsPrompt(stageNum, context);
|
||||
}
|
||||
}
|
||||
|
||||
public class MobsCowsPrompt extends QuestsEditorStringPrompt {
|
||||
|
||||
public MobsCowsPrompt(final ConversationContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle(final ConversationContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryText(final ConversationContext context) {
|
||||
return Lang.get("stageEditorMilkCowsPrompt");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
if (context.getPlugin() != null) {
|
||||
final QuestsEditorPostOpenStringPromptEvent event
|
||||
= new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
if (!input.equalsIgnoreCase(Lang.get("cmdCancel")) && !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
try {
|
||||
final int i = Integer.parseInt(input);
|
||||
if (i < 0) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorPositiveAmount"));
|
||||
return new MobsCowsPrompt(context);
|
||||
} else if (i > 0) {
|
||||
context.setSessionData(pref + CK.S_COW_MILK, i);
|
||||
}
|
||||
} catch (final NumberFormatException e) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber")
|
||||
.replace("<input>", input));
|
||||
return new MobsCowsPrompt(context);
|
||||
}
|
||||
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
context.setSessionData(pref + CK.S_COW_MILK, null);
|
||||
}
|
||||
return new MobsPrompt(stageNum, context);
|
||||
}
|
||||
}
|
||||
|
||||
public class MobsTameListPrompt extends QuestsEditorNumericPrompt {
|
||||
|
||||
public MobsTameListPrompt(final ConversationContext context) {
|
||||
|
@ -1073,6 +981,7 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
|
@ -1087,6 +996,19 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
|
|||
if (type.isAlive() || (ec != null && Tameable.class.isAssignableFrom(ec))) {
|
||||
mobTypes.add(s);
|
||||
context.setSessionData(pref + CK.S_TAME_TYPES, mobTypes);
|
||||
|
||||
LinkedList<Integer> amounts = new LinkedList<>();
|
||||
if (context.getSessionData(pref + CK.S_TAME_AMOUNTS) != null) {
|
||||
amounts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_TAME_AMOUNTS);
|
||||
}
|
||||
if (amounts != null) {
|
||||
for (int i = 0; i < mobTypes.size(); i++) {
|
||||
if (i >= amounts.size()) {
|
||||
amounts.add(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
context.setSessionData(pref + CK.S_TAME_AMOUNTS, amounts);
|
||||
} else {
|
||||
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
|
||||
+ Lang.get("stageEditorInvalidMob"));
|
||||
|
@ -1159,6 +1081,112 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
|
|||
}
|
||||
}
|
||||
|
||||
public class MobsFishPrompt extends QuestsEditorStringPrompt {
|
||||
|
||||
public MobsFishPrompt(final ConversationContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle(final ConversationContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryText(final ConversationContext context) {
|
||||
return Lang.get("stageEditorCatchFishPrompt");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
if (context.getPlugin() != null) {
|
||||
final QuestsEditorPostOpenStringPromptEvent event
|
||||
= new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
if (!input.equalsIgnoreCase(Lang.get("cmdCancel")) && !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
try {
|
||||
final int i = Integer.parseInt(input);
|
||||
if (i < 0) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorPositiveAmount"));
|
||||
return new MobsFishPrompt(context);
|
||||
} else if (i > 0) {
|
||||
context.setSessionData(pref + CK.S_FISH, i);
|
||||
}
|
||||
} catch (final NumberFormatException e) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber")
|
||||
.replace("<input>", input));
|
||||
return new MobsFishPrompt(context);
|
||||
}
|
||||
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
context.setSessionData(pref + CK.S_FISH, null);
|
||||
}
|
||||
return new MobsPrompt(stageNum, context);
|
||||
}
|
||||
}
|
||||
|
||||
public class MobsCowsPrompt extends QuestsEditorStringPrompt {
|
||||
|
||||
public MobsCowsPrompt(final ConversationContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle(final ConversationContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryText(final ConversationContext context) {
|
||||
return Lang.get("stageEditorMilkCowsPrompt");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getPromptText(final @NotNull ConversationContext context) {
|
||||
if (context.getPlugin() != null) {
|
||||
final QuestsEditorPostOpenStringPromptEvent event
|
||||
= new QuestsEditorPostOpenStringPromptEvent(context, this);
|
||||
context.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
return ChatColor.YELLOW + getQueryText(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
if (!input.equalsIgnoreCase(Lang.get("cmdCancel")) && !input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
try {
|
||||
final int i = Integer.parseInt(input);
|
||||
if (i < 0) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("stageEditorPositiveAmount"));
|
||||
return new MobsCowsPrompt(context);
|
||||
} else if (i > 0) {
|
||||
context.setSessionData(pref + CK.S_COW_MILK, i);
|
||||
}
|
||||
} catch (final NumberFormatException e) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNotANumber")
|
||||
.replace("<input>", input));
|
||||
return new MobsCowsPrompt(context);
|
||||
}
|
||||
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
context.setSessionData(pref + CK.S_COW_MILK, null);
|
||||
}
|
||||
return new MobsPrompt(stageNum, context);
|
||||
}
|
||||
}
|
||||
|
||||
public class MobsShearListPrompt extends QuestsEditorNumericPrompt {
|
||||
|
||||
public MobsShearListPrompt(final ConversationContext context) {
|
||||
|
@ -1340,6 +1368,7 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Prompt acceptInput(final @NotNull ConversationContext context, final String input) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
|
@ -1350,6 +1379,19 @@ public class MobsPrompt extends QuestsEditorNumericPrompt {
|
|||
if (MiscUtil.getProperDyeColor(s) != null) {
|
||||
colors.add(s);
|
||||
context.setSessionData(pref + CK.S_SHEAR_COLORS, colors);
|
||||
|
||||
LinkedList<Integer> amounts = new LinkedList<>();
|
||||
if (context.getSessionData(pref + CK.S_SHEAR_AMOUNTS) != null) {
|
||||
amounts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_SHEAR_AMOUNTS);
|
||||
}
|
||||
if (amounts != null) {
|
||||
for (int i = 0; i < colors.size(); i++) {
|
||||
if (i >= amounts.size()) {
|
||||
amounts.add(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
context.setSessionData(pref + CK.S_SHEAR_AMOUNTS, amounts);
|
||||
} else {
|
||||
context.getForWhom().sendRawMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED
|
||||
+ Lang.get("stageEditorInvalidDye"));
|
||||
|
|
|
@ -479,6 +479,15 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
|
|||
}
|
||||
}
|
||||
context.setSessionData(pref + CK.S_DELIVERY_NPCS, npcs);
|
||||
|
||||
LinkedList<String> messages = new LinkedList<>();
|
||||
if (context.getSessionData(pref + CK.S_DELIVERY_MESSAGES) != null) {
|
||||
messages = (LinkedList<String>) context.getSessionData(pref + CK.S_DELIVERY_MESSAGES);
|
||||
}
|
||||
if (messages != null && messages.size() == 0) {
|
||||
messages.add(Lang.get("thankYouMore"));
|
||||
}
|
||||
context.setSessionData(pref + CK.S_DELIVERY_MESSAGES, messages);
|
||||
}
|
||||
final Set<UUID> selectingNpcs = plugin.getQuestFactory().getSelectingNpcs();
|
||||
selectingNpcs.remove(((Player) context.getForWhom()).getUniqueId());
|
||||
|
@ -816,6 +825,19 @@ public class NpcsPrompt extends QuestsEditorNumericPrompt {
|
|||
}
|
||||
}
|
||||
context.setSessionData(pref + CK.S_NPCS_TO_KILL, npcs);
|
||||
|
||||
LinkedList<Integer> amounts = new LinkedList<>();
|
||||
if (context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS) != null) {
|
||||
amounts = (LinkedList<Integer>) context.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS);
|
||||
}
|
||||
if (npcs != null && amounts != null) {
|
||||
for (int i = 0; i < npcs.size(); i++) {
|
||||
if (i >= amounts.size()) {
|
||||
amounts.add(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
context.setSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS, amounts);
|
||||
}
|
||||
final Set<UUID> selectingNpcs = plugin.getQuestFactory().getSelectingNpcs();
|
||||
selectingNpcs.remove(((Player) context.getForWhom()).getUniqueId());
|
||||
|
|
|
@ -857,23 +857,42 @@ public class StageMainPrompt extends QuestsEditorNumericPrompt {
|
|||
final Block block = plugin.getQuestFactory().getSelectedReachLocations().get(player.getUniqueId());
|
||||
if (block != null) {
|
||||
final Location loc = block.getLocation();
|
||||
final LinkedList<String> locations;
|
||||
if (context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS) != null) {
|
||||
locations = (LinkedList<String>) context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS);
|
||||
} else {
|
||||
locations = new LinkedList<>();
|
||||
}
|
||||
final LinkedList<String> locations
|
||||
= context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS) != null
|
||||
? (LinkedList<String>) context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS)
|
||||
: new LinkedList<>();
|
||||
if (locations != null) {
|
||||
locations.add(ConfigUtil.getLocationInfo(loc));
|
||||
}
|
||||
context.setSessionData(stagePrefix + CK.S_REACH_LOCATIONS, locations);
|
||||
final Map<UUID, Block> temp = plugin.getQuestFactory().getSelectedReachLocations();
|
||||
temp.remove(player.getUniqueId());
|
||||
plugin.getQuestFactory().setSelectedReachLocations(temp);
|
||||
|
||||
LinkedList<Integer> amounts = new LinkedList<>();
|
||||
LinkedList<String> names = new LinkedList<>();
|
||||
if (context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS_RADIUS) != null) {
|
||||
amounts = (LinkedList<Integer>) context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS_RADIUS);
|
||||
}
|
||||
if (context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS_NAMES) != null) {
|
||||
names = (LinkedList<String>) context.getSessionData(stagePrefix + CK.S_REACH_LOCATIONS_NAMES);
|
||||
}
|
||||
if (locations != null && amounts != null && names != null) {
|
||||
for (int i = 0; i < locations.size(); i++) {
|
||||
if (i >= amounts.size()) {
|
||||
amounts.add(5);
|
||||
}
|
||||
if (i >= names.size()) {
|
||||
names.add(Lang.get("location").replace("<id>", "#" + (i + 1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
context.setSessionData(stagePrefix + CK.S_REACH_LOCATIONS_RADIUS, amounts);
|
||||
context.setSessionData(stagePrefix + CK.S_REACH_LOCATIONS_NAMES, names);
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + Lang.get("stageEditorNoBlockSelected"));
|
||||
return new ReachLocationPrompt(context);
|
||||
}
|
||||
final Map<UUID, Block> temp = plugin.getQuestFactory().getSelectedReachLocations();
|
||||
temp.remove(player.getUniqueId());
|
||||
plugin.getQuestFactory().setSelectedReachLocations(temp);
|
||||
return new ReachListPrompt(context);
|
||||
} else if (input != null && input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
|
||||
final Map<UUID, Block> temp = plugin.getQuestFactory().getSelectedReachLocations();
|
||||
|
|
|
@ -128,11 +128,14 @@ public class ConfigUtil {
|
|||
return parsed.split("\n");
|
||||
}
|
||||
|
||||
public static String[] parseStringWithPossibleLineBreaks(final String s, final NPC npc) {
|
||||
public static String[] parseStringWithPossibleLineBreaks(final String s, final NPC npc, int amount) {
|
||||
String parsed = parseString(s);
|
||||
if (parsed.contains("<npc>")) {
|
||||
parsed = parsed.replace("<npc>", npc.getName());
|
||||
}
|
||||
if (parsed.contains("<amount>")) {
|
||||
parsed = parsed.replace("<amount>", String.valueOf(amount));
|
||||
}
|
||||
return parsed.split("\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -666,6 +666,7 @@ talkTo: "Talk to <npc>"
|
|||
tame: "Tame <mob>: <count>"
|
||||
shearSheep: "Shear <color> Sheep: <count>"
|
||||
goTo: "Go to <location>"
|
||||
location: "Location <id>"
|
||||
completed: "Completed"
|
||||
redoCompleted: "(Completed)"
|
||||
consoleError: "This operation may only be performed in-game."
|
||||
|
@ -777,6 +778,7 @@ enterNpcUniqueIds: "Enter NPC UUIDs, <space>, <cancel>"
|
|||
enterOrClearNpcUniqueIds: "Enter NPC UUIDs, <space>, <clear>, <cancel>"
|
||||
listsNotSameSize: "All required lists must have the same number of entries!"
|
||||
listDuplicate: "List contains duplicates!"
|
||||
thankYouMore: "Thank you. Only <amount> more to go!"
|
||||
id: "ID"
|
||||
quest: "Quest"
|
||||
event: "Action"
|
||||
|
|
Loading…
Reference in New Issue