+Added stage start message

+Added stage complete message
This commit is contained in:
Zino 2013-08-03 21:51:14 +02:00
parent 9e79f98f95
commit b46aa5230f
9 changed files with 220 additions and 64 deletions

View File

@ -58,9 +58,14 @@ public class Quest {
//
public void nextStage(Quester q){
String stageCompleteMessage = q.currentStage.completeMessage;
if (stageCompleteMessage != null) {
q.getPlayer().sendMessage(Quests.parseString(stageCompleteMessage, q.currentQuest));
}
if(q.currentStage.delay < 0){
Player player = plugin.getServer().getPlayerExact(q.name);
Player player = q.getPlayer();
if(stages.indexOf(q.currentStage) == (stages.size() - 1)){
@ -88,13 +93,17 @@ public class Quest {
}
String stageStartMessage = q.currentStage.startMessage;
if (stageStartMessage != null) {
q.getPlayer().sendMessage(Quests.parseString(stageStartMessage, q.currentQuest));
}
}
q.delayStartTime = 0;
q.delayTimeLeft = -1;
}else{
q.startStageTimer();
}

View File

@ -1043,6 +1043,8 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
String event;
Long delay;
String delayMessage;
String startMessage;
String completeMessage;
for (int i = 1; i <= StagesPrompt.getStages(cc); i++) {
@ -1103,7 +1105,8 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
event = null;
delay = null;
delayMessage = null;
startMessage = null;
completeMessage = null;
if (cc.getSessionData(pref + CK.S_BREAK_IDS) != null) {
@ -1198,6 +1201,14 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
script = (String) cc.getSessionData(pref + CK.S_DENIZEN);
}
if (cc.getSessionData(pref + CK.S_START_MESSAGE) != null) {
startMessage = (String) cc.getSessionData(pref + CK.S_START_MESSAGE);
}
if (cc.getSessionData(pref + CK.S_COMPLETE_MESSAGE) != null) {
completeMessage = (String) cc.getSessionData(pref + CK.S_COMPLETE_MESSAGE);
}
if (breakIds != null && breakIds.isEmpty() == false) {
stage.set("break-block-ids", breakIds);
stage.set("break-block-amounts", breakAmounts);
@ -1256,9 +1267,11 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
stage.set("sheep-to-shear", shearColors);
stage.set("sheep-amounts", shearAmounts);
stage.set("script-to-run", script);
stage.set(CK.S_EVENT, event);
stage.set(CK.S_DELAY, delay);
stage.set("event", event);
stage.set("delay", delay);
stage.set("delay-message", delayMessage);
stage.set("start-message", startMessage);
stage.set("complete-message", completeMessage);
}
@ -1629,6 +1642,14 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
cc.setSessionData(pref + CK.S_DENIZEN, stage.script);
}
if (stage.completeMessage != null) {
cc.setSessionData(pref + CK.S_COMPLETE_MESSAGE, stage.completeMessage);
}
if (stage.startMessage != null) {
cc.setSessionData(pref + CK.S_START_MESSAGE, stage.startMessage);
}
}
//

View File

@ -71,7 +71,7 @@ public class Quester {
public Player getPlayer() {
return plugin.getServer().getPlayer(name);
return plugin.getServer().getPlayerExact(name);
}
@ -101,6 +101,11 @@ public class Quester {
player.sendMessage(s);
}
String stageStartMessage = currentStage.startMessage;
if (stageStartMessage != null) {
getPlayer().sendMessage(Quests.parseString(stageStartMessage, currentQuest));
}
if(q.initialEvent != null)
q.initialEvent.happen(this);

View File

@ -3254,6 +3254,18 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
}
if (config.contains("quests." + s + ".stages.ordered." + s2 + ".start-message")) {
stage.startMessage = config.getString("quests." + s + ".stages.ordered." + s2 + ".start-message");
}
if (config.contains("quests." + s + ".stages.ordered." + s2 + ".complete-message")) {
stage.completeMessage = config.getString("quests." + s + ".stages.ordered." + s2 + ".complete-message");
}
stage.citizensToInteract = npcsToTalkTo;
if (stageFailed) {

View File

@ -57,7 +57,7 @@ public class Stage {
};
ArrayList<String> deliverMessages = new ArrayList<String>();
LinkedList<NPC> citizensToInteract = new LinkedList<NPC>(){
public LinkedList<NPC> citizensToInteract = new LinkedList<NPC>(){
@Override
public boolean equals(Object o) {
@ -81,7 +81,7 @@ public class Stage {
}
};
LinkedList<NPC> citizensToKill = new LinkedList<NPC>() {
public LinkedList<NPC> citizensToKill = new LinkedList<NPC>() {
@Override
public boolean equals(Object o) {
@ -105,22 +105,24 @@ public class Stage {
}
};
LinkedList<Integer> citizenNumToKill = new LinkedList<Integer>();
public LinkedList<Integer> citizenNumToKill = new LinkedList<Integer>();
LinkedList<String> bossesToKill = new LinkedList<String>();
LinkedList<Integer> bossAmountsToKill = new LinkedList<Integer>();
public LinkedList<String> bossesToKill = new LinkedList<String>();
public LinkedList<Integer> bossAmountsToKill = new LinkedList<Integer>();
LinkedList<Location> locationsToReach = new LinkedList<Location>();
LinkedList<Integer> radiiToReachWithin = new LinkedList<Integer>();
LinkedList<World> worldsToReachWithin = new LinkedList<World>();
LinkedList<String> locationNames = new LinkedList<String>();
Map<EntityType, Integer> mobsToTame = new EnumMap<EntityType, Integer>(EntityType.class);
Map<DyeColor, Integer> sheepToShear = new EnumMap<DyeColor, Integer>(DyeColor.class);
Map<EnumMap<Material, Integer>, Boolean> itemsToCraft = new HashMap<EnumMap<Material, Integer>, Boolean>();
String script;
Event event;
long delay = -1;
String delayMessage = null;
public LinkedList<Location> locationsToReach = new LinkedList<Location>();
public LinkedList<Integer> radiiToReachWithin = new LinkedList<Integer>();
public LinkedList<World> worldsToReachWithin = new LinkedList<World>();
public LinkedList<String> locationNames = new LinkedList<String>();
public Map<EntityType, Integer> mobsToTame = new EnumMap<EntityType, Integer>(EntityType.class);
public Map<DyeColor, Integer> sheepToShear = new EnumMap<DyeColor, Integer>(DyeColor.class);
public Map<EnumMap<Material, Integer>, Boolean> itemsToCraft = new HashMap<EnumMap<Material, Integer>, Boolean>();
public String script;
public Event event;
public long delay = -1;
public String delayMessage = null;
public String completeMessage = null;
public String startMessage = null;
@Override
public boolean equals(Object o) {
@ -286,6 +288,26 @@ public class Stage {
return false;
}
if (other.startMessage != null && startMessage != null) {
if (other.startMessage.equals(startMessage) == false) {
return false;
}
} else if (other.startMessage != null && startMessage == null) {
return false;
} else if (other.startMessage == null && startMessage != null) {
return false;
}
if (other.completeMessage != null && completeMessage != null) {
if (other.completeMessage.equals(completeMessage) == false) {
return false;
}
} else if (other.completeMessage != null && completeMessage == null) {
return false;
} else if (other.completeMessage == null && completeMessage != null) {
return false;
}
}
return true;

View File

@ -52,6 +52,11 @@ public class StageTimer implements Runnable{
}
String stageStartMessage = quester.currentStage.startMessage;
if (stageStartMessage != null) {
quester.getPlayer().sendMessage(Quests.parseString(stageStartMessage, quester.currentQuest));
}
}
}

View File

@ -35,7 +35,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
public CreateStagePrompt(int stageNum, QuestFactory qf, CitizensPlugin cit) {
super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22");
super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24");
this.stageNum = stageNum;
this.pref = "stage" + stageNum;
this.citizens = cit;
@ -341,8 +341,20 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
}
text += RED + "" + BOLD + "21 " + RESET + PURPLE + "- Delete Stage\n";
text += GREEN + "" + BOLD + "22 " + RESET + PURPLE + "- Done\n";
if (context.getSessionData(pref + CK.S_START_MESSAGE) == null) {
text += PINK + "" + BOLD + "21 " + RESET + PURPLE + "- Start Mmessage " + GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += PINK + "" + BOLD + "21 " + RESET + PURPLE + "- Start Message " + GRAY + "(" + AQUA + "\"" + context.getSessionData(pref + CK.S_START_MESSAGE) + "\"" + GRAY + ")\n";
}
if (context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) == null) {
text += PINK + "" + BOLD + "22 " + RESET + PURPLE + "- Complete Message " + GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += PINK + "" + BOLD + "22 " + RESET + PURPLE + "- Complete Message " + GRAY + "(" + AQUA + "\"" + context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) + "\"" + GRAY + ")\n";
}
text += RED + "" + BOLD + "23 " + RESET + PURPLE + "- Delete Stage\n";
text += GREEN + "" + BOLD + "24 " + RESET + PURPLE + "- Done\n";
return text;
@ -422,8 +434,12 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
return new DenizenPrompt();
}
} else if (input.equalsIgnoreCase("21")) {
return new DeletePrompt();
return new StartMessagePrompt();
} else if (input.equalsIgnoreCase("22")) {
return new CompleteMessagePrompt();
} else if (input.equalsIgnoreCase("23")) {
return new DeletePrompt();
} else if (input.equalsIgnoreCase("24")) {
return new StagesPrompt(questFactory);
} else {
return new CreateStagePrompt(stageNum, questFactory, citizens);
@ -3748,4 +3764,62 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
}
}
private class StartMessagePrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext context) {
return YELLOW + "Enter start message, or enter \"clear\" to clear the message, or \"cancel\" to return";
}
@Override
public Prompt acceptInput(ConversationContext context, String input) {
Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase("cancel") == false && input.equalsIgnoreCase("clear") == false) {
context.setSessionData(pref + CK.S_START_MESSAGE, input);
return new CreateStagePrompt(stageNum, questFactory, citizens);
} else if (input.equalsIgnoreCase("clear")) {
context.setSessionData(pref + CK.S_START_MESSAGE, null);
player.sendMessage(YELLOW + "Start message cleared.");
return new CreateStagePrompt(stageNum, questFactory, citizens);
} else {
return new StartMessagePrompt();
}
}
}
private class CompleteMessagePrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext context) {
return YELLOW + "Enter start message, or enter \"clear\" to clear the message, or \"cancel\" to return";
}
@Override
public Prompt acceptInput(ConversationContext context, String input) {
Player player = (Player) context.getForWhom();
if (input.equalsIgnoreCase("cancel") == false && input.equalsIgnoreCase("clear") == false) {
context.setSessionData(pref + CK.S_COMPLETE_MESSAGE, input);
return new CreateStagePrompt(stageNum, questFactory, citizens);
} else if (input.equalsIgnoreCase("clear")) {
context.setSessionData(pref + CK.S_COMPLETE_MESSAGE, null);
player.sendMessage(YELLOW + "Complete message cleared.");
return new CreateStagePrompt(stageNum, questFactory, citizens);
} else {
return new CompleteMessagePrompt();
}
}
}
}

View File

@ -107,60 +107,63 @@ public class StagesPrompt extends StringPrompt implements ColorUtil{
pref = "stage" + current;
newPref = "stage" + (current - 1);
cc.setSessionData(newPref + "breakIds", cc.getSessionData(pref + CK.S_BREAK_IDS));
cc.setSessionData(newPref + "breakAmounts", cc.getSessionData(pref + CK.S_BREAK_AMOUNTS));
cc.setSessionData(newPref + CK.S_BREAK_IDS, cc.getSessionData(pref + CK.S_BREAK_IDS));
cc.setSessionData(newPref + CK.S_BREAK_AMOUNTS, cc.getSessionData(pref + CK.S_BREAK_AMOUNTS));
cc.setSessionData(newPref + "damageIds", cc.getSessionData(pref + CK.S_DAMAGE_IDS));
cc.setSessionData(newPref + "damageAmounts", cc.getSessionData(pref + CK.S_DAMAGE_AMOUNTS));
cc.setSessionData(newPref + CK.S_DAMAGE_IDS, cc.getSessionData(pref + CK.S_DAMAGE_IDS));
cc.setSessionData(newPref + CK.S_DAMAGE_AMOUNTS, cc.getSessionData(pref + CK.S_DAMAGE_AMOUNTS));
cc.setSessionData(newPref + "placeIds", cc.getSessionData(pref + CK.S_PLACE_IDS));
cc.setSessionData(newPref + "placeAmounts", cc.getSessionData(pref + CK.S_PLACE_AMOUNTS));
cc.setSessionData(newPref + CK.S_PLACE_IDS, cc.getSessionData(pref + CK.S_PLACE_IDS));
cc.setSessionData(newPref + CK.S_PLACE_IDS, cc.getSessionData(pref + CK.S_PLACE_AMOUNTS));
cc.setSessionData(newPref + "useIds", cc.getSessionData(pref + CK.S_USE_IDS));
cc.setSessionData(newPref + "useAmounts", cc.getSessionData(pref + CK.S_USE_AMOUNTS));
cc.setSessionData(newPref + CK.S_USE_IDS, cc.getSessionData(pref + CK.S_USE_IDS));
cc.setSessionData(newPref + CK.S_USE_AMOUNTS, cc.getSessionData(pref + CK.S_USE_AMOUNTS));
cc.setSessionData(newPref + "cutIds", cc.getSessionData(pref + CK.S_CUT_IDS));
cc.setSessionData(newPref + "cutAmounts", cc.getSessionData(pref + CK.S_CUT_AMOUNTS));
cc.setSessionData(newPref + CK.S_CUT_IDS, cc.getSessionData(pref + CK.S_CUT_IDS));
cc.setSessionData(newPref + CK.S_CUT_AMOUNTS, cc.getSessionData(pref + CK.S_CUT_AMOUNTS));
cc.setSessionData(newPref + "fish", cc.getSessionData(pref + CK.S_FISH));
cc.setSessionData(newPref + CK.S_FISH, cc.getSessionData(pref + CK.S_FISH));
cc.setSessionData(newPref + "playerKill", cc.getSessionData(pref + CK.S_PLAYER_KILL));
cc.setSessionData(newPref + CK.S_PLAYER_KILL, cc.getSessionData(pref + CK.S_PLAYER_KILL));
cc.setSessionData(newPref + "enchantTypes", cc.getSessionData(pref + CK.S_ENCHANT_TYPES));
cc.setSessionData(newPref + "enchantIds", cc.getSessionData(pref + CK.S_ENCHANT_IDS));
cc.setSessionData(newPref + "enchantAmounts", cc.getSessionData(pref + CK.S_ENCHANT_AMOUNTS));
cc.setSessionData(newPref + CK.S_ENCHANT_TYPES, cc.getSessionData(pref + CK.S_ENCHANT_TYPES));
cc.setSessionData(newPref + CK.S_ENCHANT_IDS, cc.getSessionData(pref + CK.S_ENCHANT_IDS));
cc.setSessionData(newPref + CK.S_ENCHANT_AMOUNTS, cc.getSessionData(pref + CK.S_ENCHANT_AMOUNTS));
cc.setSessionData(newPref + "deliveryItems", cc.getSessionData(pref + CK.S_DELIVERY_ITEMS));
cc.setSessionData(newPref + "deliveryNPCs", cc.getSessionData(pref + CK.S_DELIVERY_NPCS));
cc.setSessionData(newPref + "deliveryMessages", cc.getSessionData(pref + CK.S_DELIVERY_MESSAGES));
cc.setSessionData(newPref + CK.S_DELIVERY_ITEMS, cc.getSessionData(pref + CK.S_DELIVERY_ITEMS));
cc.setSessionData(newPref + CK.S_DELIVERY_NPCS, cc.getSessionData(pref + CK.S_DELIVERY_NPCS));
cc.setSessionData(newPref + CK.S_DELIVERY_MESSAGES, cc.getSessionData(pref + CK.S_DELIVERY_MESSAGES));
cc.setSessionData(newPref + "npcIdsToTalkTo", cc.getSessionData(pref + CK.S_NPCS_TO_TALK_TO));
cc.setSessionData(newPref + CK.S_NPCS_TO_TALK_TO, cc.getSessionData(pref + CK.S_NPCS_TO_TALK_TO));
cc.setSessionData(newPref + "npcIdsToKill", cc.getSessionData(pref + CK.S_NPCS_TO_KILL));
cc.setSessionData(newPref + "npcAmountsToKill", cc.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS));
cc.setSessionData(newPref + CK.S_NPCS_TO_KILL, cc.getSessionData(pref + CK.S_NPCS_TO_KILL));
cc.setSessionData(newPref + CK.S_NPCS_TO_KILL_AMOUNTS, cc.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS));
cc.setSessionData(newPref + "mobTypes", cc.getSessionData(pref + CK.S_MOB_TYPES));
cc.setSessionData(newPref + "mobAmounts", cc.getSessionData(pref + CK.S_MOB_AMOUNTS));
cc.setSessionData(newPref + "killLocations", cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS));
cc.setSessionData(newPref + "killLocationRadii", cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS));
cc.setSessionData(newPref + "killLocationNames", cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES));
cc.setSessionData(newPref + CK.S_MOB_TYPES, cc.getSessionData(pref + CK.S_MOB_TYPES));
cc.setSessionData(newPref + CK.S_MOB_AMOUNTS, cc.getSessionData(pref + CK.S_MOB_AMOUNTS));
cc.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS, cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS));
cc.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS_RADIUS, cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS));
cc.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS_NAMES, cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES));
cc.setSessionData(newPref + "reachLocations", cc.getSessionData(pref + CK.S_REACH_LOCATIONS));
cc.setSessionData(newPref + "reachLocationRadii", cc.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS));
cc.setSessionData(newPref + "reachLocationNames", cc.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES));
cc.setSessionData(newPref + CK.S_REACH_LOCATIONS, cc.getSessionData(pref + CK.S_REACH_LOCATIONS));
cc.setSessionData(newPref + CK.S_REACH_LOCATIONS_RADIUS, cc.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS));
cc.setSessionData(newPref + CK.S_REACH_LOCATIONS_NAMES, cc.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES));
cc.setSessionData(newPref + "tameTypes", cc.getSessionData(pref + CK.S_TAME_TYPES));
cc.setSessionData(newPref + "tameAmounts", cc.getSessionData(pref + CK.S_TAME_AMOUNTS));
cc.setSessionData(newPref + CK.S_TAME_TYPES, cc.getSessionData(pref + CK.S_TAME_TYPES));
cc.setSessionData(newPref + CK.S_TAME_AMOUNTS, cc.getSessionData(pref + CK.S_TAME_AMOUNTS));
cc.setSessionData(newPref + "shearColors", cc.getSessionData(pref + CK.S_SHEAR_COLORS));
cc.setSessionData(newPref + "shearAmounts", cc.getSessionData(pref + CK.S_SHEAR_AMOUNTS));
cc.setSessionData(newPref + CK.S_SHEAR_COLORS, cc.getSessionData(pref + CK.S_SHEAR_COLORS));
cc.setSessionData(newPref + CK.S_SHEAR_AMOUNTS, cc.getSessionData(pref + CK.S_SHEAR_AMOUNTS));
cc.setSessionData(newPref + "event", cc.getSessionData(pref + CK.S_EVENT));
cc.setSessionData(newPref + CK.S_EVENT, cc.getSessionData(pref + CK.S_EVENT));
cc.setSessionData(newPref + "delay", cc.getSessionData(pref + CK.S_DELAY));
cc.setSessionData(newPref + "delayMessage", cc.getSessionData(pref + CK.S_DELAY_MESSAGE));
cc.setSessionData(newPref + CK.S_DELAY, cc.getSessionData(pref + CK.S_DELAY));
cc.setSessionData(newPref +CK.S_DELAY_MESSAGE, cc.getSessionData(pref + CK.S_DELAY_MESSAGE));
cc.setSessionData(newPref + "denizen", cc.getSessionData(pref + CK.S_DENIZEN));
cc.setSessionData(newPref + CK.S_DENIZEN, cc.getSessionData(pref + CK.S_DENIZEN));
cc.setSessionData(newPref + CK.S_COMPLETE_MESSAGE, cc.getSessionData(pref + CK.S_COMPLETE_MESSAGE));
cc.setSessionData(newPref + CK.S_START_MESSAGE, cc.getSessionData(pref + CK.S_START_MESSAGE));
}
@ -220,6 +223,9 @@ public class StagesPrompt extends StringPrompt implements ColorUtil{
cc.setSessionData(pref + CK.S_DENIZEN, null);
cc.setSessionData(pref + CK.S_COMPLETE_MESSAGE, null);
cc.setSessionData(pref + CK.S_START_MESSAGE, null);
if(last)
break;

View File

@ -77,6 +77,8 @@ public class CK {
public static String S_DELAY = "delay";
public static String S_DELAY_MESSAGE = "delayMessage";
public static String S_DENIZEN = "denizen";
public static String S_COMPLETE_MESSAGE = "completeMessage";
public static String S_START_MESSAGE = "startMessage";
//Events
public static String E_OLD_EVENT = "oldEvent";