+Saves blocking quests.

+Stage delayMessages get parsed before sending to player.
+more?
*Changed delay times.
This commit is contained in:
Zino 2013-08-03 12:33:06 +02:00
parent ec5bbcb44a
commit 3319aba5fc
6 changed files with 269 additions and 24 deletions

View File

@ -349,6 +349,7 @@ public class Quest {
return false;
if(other.questPointsReq != questPointsReq)
return false;
if(other.redoDelay != redoDelay)
return false;

View File

@ -699,7 +699,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
@Override
public String getPromptText(ConversationContext context) {
return ChatColor.YELLOW + "Enter amount of time (in milliseconds), or 0 to clear the redo delay, or -1 to cancel";
return ChatColor.YELLOW + "Enter amount of time (in seconds), or 0 to clear the redo delay, or -1 to cancel";
}
@ -851,6 +851,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
LinkedList<Boolean> removeItemReqs = null;
LinkedList<String> permReqs = null;
LinkedList<String> questReqs = null;
LinkedList<String> questBlocks = null;
String failMessage = null;
Integer moneyRew = null;
@ -898,6 +899,10 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
if (cc.getSessionData("questReqs") != null) {
questReqs = (LinkedList<String>) cc.getSessionData("questReqs");
}
if (cc.getSessionData("questBlocks") != null) {
questBlocks = (LinkedList<String>) cc.getSessionData("questBlocks");
}
if (cc.getSessionData("failMessage") != null) {
failMessage = (String) cc.getSessionData("failMessage");
@ -949,7 +954,7 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
cs.set("event", initialEvent);
if (moneyReq != null || questPointsReq != null || itemReqs != null && itemReqs.isEmpty() == false || permReqs != null && permReqs.isEmpty() == false || questReqs != null && questReqs.isEmpty() == false) {
if (moneyReq != null || questPointsReq != null || itemReqs != null && itemReqs.isEmpty() == false || permReqs != null && permReqs.isEmpty() == false || (questReqs != null && questReqs.isEmpty() == false) || (questBlocks != null && questBlocks.isEmpty() == false)) {
ConfigurationSection reqs = cs.createSection("requirements");
List<String> items = new LinkedList<String>();
@ -960,12 +965,16 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
}
}
reqs.set("items", items);
if (items.isEmpty() == false) {
reqs.set("items", items);
}
reqs.set("remove-items", removeItemReqs);
reqs.set("money", moneyReq);
reqs.set("quest-points", questPointsReq);
reqs.set("permissions", permReqs);
reqs.set("quests", questReqs);
reqs.set("quests-blocks", questBlocks);
reqs.set("fail-requirement-message", failMessage);
} else {

View File

@ -2555,10 +2555,10 @@ public class Quester {
public void startStageTimer() {
if (delayTimeLeft > -1) {
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new StageTimer(plugin, this), delayTimeLeft * 50);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new StageTimer(plugin, this), (long) (delayTimeLeft * 0.02));
} else {
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new StageTimer(plugin, this), currentStage.delay / 50);
plugin.getServer().getPlayer(name).sendMessage(currentStage.delayMessage);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new StageTimer(plugin, this), (long) (currentStage.delay * 0.02));
plugin.getServer().getPlayer(name).sendMessage(Quests.parseString((currentStage.delayMessage), currentQuest));
}
delayStartTime = System.currentTimeMillis();

View File

@ -3803,6 +3803,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
}
public static String getTime(long milliseconds) {
String message = "";
@ -3813,7 +3814,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
long hours = calendar.get(Calendar.HOUR_OF_DAY) - 1;
long minutes = calendar.get(Calendar.MINUTE);
long seconds = calendar.get(Calendar.SECOND);
long milliSeconds2 = calendar.get(Calendar.MILLISECOND);
if (days > 0) {
if (days == 1) {
@ -3851,7 +3852,14 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} else {
message += " " + seconds + " Seconds,";
}
} else {
if (milliSeconds2 > 0) {
if (milliSeconds2 == 1) {
message += " 1 Millisecond,";
} else {
message += " " + seconds + " Milliseconds,";
}
}
}
message = message.substring(1, message.length() - 1);

View File

@ -25,7 +25,7 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
public RequirementsPrompt(Quests plugin, QuestFactory qf){
super("1", "2", "3", "4", "5", "6", "7");
super("1", "2", "3", "4", "5", "6", "7", "8");
quests = plugin;
factory = qf;
@ -78,16 +78,29 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
}
}
if(context.getSessionData("questBlocks") == null)
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - Set Quest that mustn't be done " + GRAY + " (" + Lang.get("noneSet") + ")\n";
else{
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - Set Quest requirements\n";
List<String> qs = (List<String>) context.getSessionData("questBlocks");
for(String s : qs){
text += GRAY + " - " + AQUA + s + "\n";
if(context.getSessionData("moneyReq") == null && context.getSessionData("questPointsReq") == null && context.getSessionData("itemReqs") == null && context.getSessionData("permissionReqs") == null && context.getSessionData("questReqs") == null){
text += GRAY + "" + BOLD + "6 - " + RESET + GRAY + "Set fail requirements message (No requirements set)\n";
}else if(context.getSessionData("failMessage") == null){
text += RED + "" + BOLD + "6 - " + RESET + RED + "Set fail requirements message (Required)\n";
}else{
text += BLUE + "" + BOLD + "6 - " + RESET + YELLOW + "Set fail requirements message" + GRAY + "(" + AQUA + "\"" + context.getSessionData("failMessage") + "\"" + GRAY + ")\n";
}
}
text += GREEN + "" + BOLD + "7" + RESET + YELLOW + " - Done";
if(context.getSessionData("moneyReq") == null && context.getSessionData("questPointsReq") == null && context.getSessionData("itemReqs") == null && context.getSessionData("permissionReqs") == null && context.getSessionData("questReqs") == null && context.getSessionData("questBlocks") == null){
text += GRAY + "" + BOLD + "7 - " + RESET + GRAY + "Set fail requirements message (No requirements set)\n";
}else if(context.getSessionData("failMessage") == null){
text += RED + "" + BOLD + "7 - " + RESET + RED + "Set fail requirements message (Required)\n";
}else{
text += BLUE + "" + BOLD + "7 - " + RESET + YELLOW + "Set fail requirements message" + GRAY + "(" + AQUA + "\"" + context.getSessionData("failMessage") + "\"" + GRAY + ")\n";
}
text += GREEN + "" + BOLD + "8" + RESET + YELLOW + " - Done";
return text;
@ -106,11 +119,13 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
}else if(input.equalsIgnoreCase("4")){
return new PermissionsPrompt();
}else if(input.equalsIgnoreCase("5")){
return new QuestListPrompt();
}else if(input.equalsIgnoreCase("6")){
return new FailMessagePrompt();
return new QuestListPrompt(true);
}else if(input.equalsIgnoreCase("6")) {
return new QuestListPrompt(false);
}else if(input.equalsIgnoreCase("7")){
if(context.getSessionData("moneyReq") != null || context.getSessionData("questPointsReq") != null || context.getSessionData("itemReqs") != null || context.getSessionData("permissionReqs") != null || context.getSessionData("questReqs") != null){
return new FailMessagePrompt();
}else if(input.equalsIgnoreCase("8")){
if(context.getSessionData("moneyReq") != null || context.getSessionData("questPointsReq") != null || context.getSessionData("itemReqs") != null || context.getSessionData("permissionReqs") != null || context.getSessionData("questReqs") != null || context.getSessionData("questBlocks") != null){
if(context.getSessionData("failMessage") == null){
context.getForWhom().sendRawMessage(RED + "You must set a fail requirements message!");
@ -184,6 +199,16 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
}
private class QuestListPrompt extends StringPrompt {
private boolean isRequiredQuest;
/*public QuestListPrompt() {
this.isRequiredQuest = true;
}*/
public QuestListPrompt(boolean isRequired) {
this.isRequiredQuest = isRequired;
}
@Override
public String getPromptText(ConversationContext context){
@ -224,14 +249,14 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
if(quests.getQuest(s) == null){
context.getForWhom().sendRawMessage(PINK + s + " " + RED + "is not a Quest name!");
return new QuestListPrompt();
return new QuestListPrompt(isRequiredQuest);
}
if(questNames.contains(s)){
context.getForWhom().sendRawMessage(RED + "List contains duplicates!");
return new QuestListPrompt();
return new QuestListPrompt(isRequiredQuest);
}
@ -250,11 +275,19 @@ public class RequirementsPrompt extends FixedSetPrompt implements ColorUtil{
});
context.setSessionData("questReqs", questNames);
if (isRequiredQuest) {
context.setSessionData("questReqs", questNames);
} else {
context.setSessionData("questBlocks", questNames);
}
}else if(input.equalsIgnoreCase("clear")){
context.setSessionData("questReqs", null);
if (isRequiredQuest) {
context.setSessionData("questReqs", null);
} else {
context.setSessionData("questBlocks", null);
}
}

View File

@ -239,6 +239,200 @@ public class Lang {
//
}
public void initiateFrench() {
//English
//Quests
fr.put("enterQuestName", "Enter Quest name (or \"cancel\" to return)");
//
//Events
fr.put("eventEditorTitle", "Event Editor");
fr.put("eventEditorCreate", "Create new Event");
fr.put("eventEditorEdit", "Edit an Event");
fr.put("eventEditorDelete", "Delete an Event");
fr.put("eventEditorNoneToEdit", "No Events currently exist to be edited!");
fr.put("eventEditorNoneToDelete", "No Events currently exist to be deleted!");
fr.put("eventEditorNotFound", "Event not found!");
fr.put("eventEditorExists", "Event already exists!");
fr.put("eventEditorSomeone", "Someone is already creating or editing an Event with that name!");
fr.put("eventEditorAlpha", "Name must be alphanumeric!");
fr.put("eventEditorErrorReadingFile", "Error reading Events file.");
fr.put("eventEditorErrorSaving", "An error occurred while saving.");
fr.put("eventEditorDeleted", "Event deleted, Quests and Events reloaded.");
fr.put("eventEditorSaved", "Event saved, Quests and Events reloaded.");
fr.put("eventEditorEnterEventName", "Enter an Event name, or \"cancel\" to return.");
fr.put("eventEditorDeletePrompt", "Are you sure you want to delete the Event");
fr.put("eventEditorQuitWithoutSaving", "Are you sure you want to quit without saving?");
fr.put("eventEditorFinishAndSave", "Are you sure you want to finish and save the Event");
fr.put("eventEditorModifiedNote", "Note: You have modified an Event that the following Quests use:");
fr.put("eventEditorForcedToQuit", "If you save the Event, anyone who is actively doing any of these Quests will be forced to quit them.");
fr.put("eventEditorEventInUse", "The following Quests use the Event");
fr.put("eventEditorMustModifyQuests", "eventEditorNotFound");
fr.put("eventEditorListSizeMismatch", "The lists are not the same size!");
fr.put("eventEditorListDuplicates", "List contains duplicates!");
fr.put("eventEditorNotANumberList", "Input was not a list of numbers!");
fr.put("eventEditorInvalidEntry", "Invalid entry");
fr.put("eventEditorSetName", "Set name");
fr.put("eventEditorSetMessage", "Set message");
fr.put("eventEditorClearInv", "Clear player inventory");
fr.put("eventEditorSetExplosions", "Set explosion locations");
fr.put("eventEditorSetLightning", "Set lightning strike locations");
fr.put("eventEditorSetEffects", "Set effects");
fr.put("eventEditorSetStorm", "Set storm");
fr.put("eventEditorSetThunder", "Set thunder");
fr.put("eventEditorSetMobSpawns", "Set mob spawns");
fr.put("eventEditorSetPotionEffects", "Set potion effects");
fr.put("eventEditorSetHunger", "Set player hunger level");
fr.put("eventEditorSetSaturation", "Set player saturation level");
fr.put("eventEditorSetHealth", "Set player health level");
fr.put("eventEditorSetTeleport", "Set player teleport location");
fr.put("eventEditorSetCommands", "Set commands to execute");
fr.put("eventEditorItems", "Event Items");
fr.put("eventEditorSetItems", "Give items");
fr.put("eventEditorItemsCleared", "Event items cleared.");
fr.put("eventEditorSetItemIDs", "Set item IDs");
fr.put("eventEditorSetItemAmounts", "Set item amounts");
fr.put("eventEditorNoIDs", "No IDs set");
fr.put("eventEditorMustSetIDs", "You must set item IDs first!");
fr.put("eventEditorInvalidID", "___ is not a valid item ID!");
fr.put("eventEditorNotGreaterThanZero", "___ is not greater than 0!");
fr.put("eventEditorNotANumber", "___ is not a number!");
fr.put("eventEditorStorm", "Event Storm");
fr.put("eventEditorSetWorld", "Set world");
fr.put("eventEditorSetDuration", "Set duration");
fr.put("eventEditorNoWorld", "(No world set)");
fr.put("eventEditorSetWorldFirst", "You must set a world first!");
fr.put("eventEditorInvalidWorld", "___ is not a valid world name!");
fr.put("eventEditorMustSetStormDuration", "You must set a storm duration!");
fr.put("eventEditorStormCleared", "Storm data cleared.");
fr.put("eventEditorEnterStormWorld", "Enter a world name for the storm to occur in, or enter \"cancel\" to return");
fr.put("eventEditorEnterDuration", "Enter duration (in milliseconds)");
fr.put("eventEditorAtLeastOneSecond", "Amount must be at least 1 second! (1000 milliseconds)");
fr.put("eventEditorNotGreaterThanOneSecond", "___ is not greater than 1 second! (1000 milliseconds)");
fr.put("eventEditorThunder", "Event Thunder");
fr.put("eventEditorInvalidWorld", "___ is not a valid world name!");
fr.put("eventEditorMustSetThunderDuration", "You must set a thunder duration!");
fr.put("eventEditorThunderCleared", "Thunder data cleared.");
fr.put("eventEditorEnterThunderWorld", "Enter a world name for the thunder to occur in, or enter \"cancel\" to return");
fr.put("eventEditorEffects", "Event Effects");
fr.put("eventEditorAddEffect", "Add effect");
fr.put("eventEditorAddEffectLocation", "Add effect location");
fr.put("eventEditorNoEffects", "No effects set");
fr.put("eventEditorMustAddEffects", "You must add effects first!");
fr.put("eventEditorInvalidEffect", "___ is not a valid effect name!");
fr.put("eventEditorEffectsCleared", "Event effects cleared.");
fr.put("eventEditorEffectLocationPrompt", "Right-click on a block to play an effect at, then enter \"add\" to add it to the list, or enter \"cancel\" to return");
fr.put("eventEditorMobSpawns", "Event Mob Spawns");
fr.put("eventEditorSetMobTypes", "Set mob types");
fr.put("eventEditorNoTypesSet", "(No types set)");
fr.put("eventEditorMustSetMobTypesFirst", "You must set mob types first!");
fr.put("eventEditorSetMobAmounts", "Set mob amounts");
fr.put("eventEditorNoAmountsSet", "(No amounts set)");
fr.put("eventEditorMustSetMobAmountsFirst", "You must set mob amounts first!");
fr.put("eventEditorMustSetMobTypesAndAmountsFirst", "You must set mob types and amounts first!");
fr.put("eventEditorAddSpawnLocation", "Add spawn location");
fr.put("eventEditorMobSpawnsCleared", "Mob spawns cleared.");
fr.put("eventEditorInvalidMob", "___ is not a valid mob name!");
fr.put("eventEditorLightningPrompt", "Right-click on a block to spawn a lightning strike at, then enter \"add\" to add it to the list, or enter \"clear\" to clear the locations list, or \"cancel\" to return");
fr.put("eventEditorPotionEffects", "Event Potion Effects");
fr.put("eventEditorSetPotionEffects", "Set potion effect types");
fr.put("eventEditorMustSetPotionTypesFirst", "You must set potion effect types first!");
fr.put("eventEditorSetPotionDurations", "Set potion effect durations");
fr.put("eventEditorMustSetPotionDurationsFirst", "You must set potion effect durations first!");
fr.put("eventEditorMustSetPotionTypesAndDurationsFirst", "You must set potion effect types and durations first!");
fr.put("eventEditorNoDurationsSet", "(No durations set)");
fr.put("eventEditorSetPotionMagnitudes", "Set potion effect magnitudes");
fr.put("eventEditorPotionsCleared", "Potion effects cleared.");
fr.put("eventEditorInvalidPotionType", "___ is not a valid potion effect type!");
fr.put("eventEditorEnterNPCId", "Enter NPC ID (or -1 to return)");
fr.put("eventEditorNoNPCExists", "No NPC exists with that id!");
fr.put("eventEditorExplosionPrompt", "Right-click on a block to spawn an explosion at, then enter \"add\" to add it to the list, or enter \"clear\" to clear the explosions list, or \"cancel\" to return");
fr.put("eventEditorSelectBlockFirst", "You must select a block first.");
fr.put("eventEditorSetMessagePrompt", "Enter message, or enter \'none\' to delete, (or \'cancel\' to return)");
fr.put("eventEditorSetItemIDsPrompt", "Enter item IDs separating each one by a space, or enter \"cancel\" to return.");
fr.put("eventEditorSetItemAmountsPrompt", "Enter item amounts (numbers) separating each one by a space, or enter \"cancel\" to return.");
fr.put("eventEditorSetMobTypesPrompt", "Enter mob names separating each one by a space, or enter \"cancel\" to return");
fr.put("eventEditorSetMobAmountsPrompt", "Enter mob amounts separating each one by a space, or enter \"cancel\" to return");
fr.put("eventEditorMobLocationPrompt", "Right-click on a block to select it, then enter \"add\" to add it to the mob spawn location list, or enter \"cancel\" to return");
fr.put("eventEditorSetPotionEffectsPrompt", "Enter potion effect types separating each one by a space, or enter \"cancel\" to return");
fr.put("eventEditorSetPotionDurationsPrompt", "Enter effect durations (in milliseconds) separating each one by a space, or enter \"cancel\" to return");
fr.put("eventEditorSetPotionMagnitudesPrompt", "Enter potion effect magnitudes separating each one by a space, or enter \"cancel\" to return");
fr.put("eventEditorSetHungerPrompt", "Enter hunger level, or -1 to remove it");
fr.put("eventEditorHungerLevelAtLeastZero", "Hunger level must be at least 0!");
fr.put("eventEditorSetSaturationPrompt", "Enter saturation level, or -1 to remove it");
fr.put("eventEditorSaturationLevelAtLeastZero", "Saturation level must be at least 0!");
fr.put("eventEditorSetHealthPrompt", "Enter health level, or -1 to remove it");
fr.put("eventEditorHealthLevelAtLeastZero", "Health level must be at least 0!");
fr.put("eventEditorSetTeleportPrompt", "Right-click on a block to teleport the player to, then enter \"done\" to finish,\nor enter \"clear\" to clear the teleport location, or \"cancel\" to return");
fr.put("eventEditorCommandsNote", "Note: You may use <player> to refer to the player's name.");
fr.put("eventEditorSetCommandsPrompt", "Enter commands separating each one by a comma, or enter \"clear\" to clear the list, or enter \"cancel\" to return.");
fr.put("eventEditorSet", "");
fr.put("eventEditorSet", "");
fr.put("eventEditorSet", "");
//
//Effects
fr.put("effBlazeShoot", "Sound of a Blaze firing");
fr.put("effBowFire", "Sound of a bow firing");
fr.put("effClick1", "A click sound");
fr.put("effClick2", "A different click sound");
fr.put("effDoorToggle", "Sound of a door opening or closing");
fr.put("effExtinguish", "Sound of fire being extinguished");
fr.put("effGhastShoot", "Sound of a Ghast firing");
fr.put("effGhastShriek", "Sound of a Ghast shrieking");
fr.put("effZombieWood", "Sound of a Zombie chewing an iron door");
fr.put("effZombieIron", "Sound of a Zombie chewing a wooden door");
fr.put("effEnterName", "Enter an effect name to add it to the list, or enter \"cancel\" to return");
//
//Inputs
fr.put("cmdCancel", "cancel");
fr.put("cmdAdd", "add");
fr.put("cmdClear", "clear");
fr.put("cmdNone", "none");
fr.put("cmdDone", "done");
//
//Misc
fr.put("event", "Event");
fr.put("exit", "Exit");
fr.put("exited", "Exited.");
fr.put("yes", "Yes");
fr.put("no", "No");
fr.put("done", "Done");
fr.put("quit", "Quit");
fr.put("clear", "Clear");
fr.put("noneSet", "None set");
fr.put("worlds", "Worlds");
fr.put("mobs", "Mobs");
fr.put("invalidOption", "Invalid option!");
//
//
}
}