mirror of
https://github.com/PikaMug/Quests.git
synced 2024-12-22 09:08:05 +01:00
+Start of MiniEvent system
This commit is contained in:
parent
06c7defba5
commit
b980da3720
@ -2,6 +2,7 @@ package me.blackvein.quests;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import me.blackvein.quests.events.MiniEvent.MiniEventType;
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
@ -404,6 +405,7 @@ public class PlayerListener implements Listener {
|
||||
if (okay) {
|
||||
|
||||
Quester quester = plugin.getQuester(player.getName());
|
||||
|
||||
if (quester.hasObjective("killMob")) {
|
||||
quester.killMob(evt.getEntity().getLocation(), evt.getEntity().getType());
|
||||
}
|
||||
@ -470,6 +472,7 @@ public class PlayerListener implements Listener {
|
||||
if (okay) {
|
||||
|
||||
Quester quester = plugin.getQuester(player.getName());
|
||||
|
||||
if (quester.hasObjective("killPlayer")) {
|
||||
quester.killPlayer(evt.getEntity().getName());
|
||||
}
|
||||
@ -606,6 +609,14 @@ public class PlayerListener implements Listener {
|
||||
|
||||
Quester quester = plugin.getQuester(evt.getPlayer().getName());
|
||||
|
||||
if (quester.currentStage != null) {
|
||||
boolean isCancelled = quester.currentStage.executeReachEvent(evt.getTo(), quester);
|
||||
|
||||
if(isCancelled) {
|
||||
evt.setCancelled(isCancelled);
|
||||
}
|
||||
}
|
||||
|
||||
if (quester.hasObjective("reachLocation")) {
|
||||
|
||||
quester.reachLocation(evt.getTo());
|
||||
@ -617,4 +628,20 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void onEntityDamage(EntityDamageByEntityEvent evt) {
|
||||
if (evt.getEntity() instanceof Player) {
|
||||
double health = ((Damageable) evt.getEntity()).getHealth();
|
||||
if (evt.getDamage() >= health) {
|
||||
Quester quester = plugin.getQuester(((Player) evt.getEntity()).getName());
|
||||
evt.setCancelled(quester.currentStage.executeEvent(quester, MiniEventType.ONDEATH));
|
||||
|
||||
}
|
||||
} else if (evt.getDamager() instanceof Player) {
|
||||
if (evt.getDamage() >= ((Damageable) evt.getEntity()).getHealth()) {
|
||||
Quester quester = plugin.getQuester(((Player) evt.getDamager()).getName());
|
||||
evt.setCancelled(quester.currentStage.executeKillEvent(quester, evt.getEntityType()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class Quest {
|
||||
if(q.currentStage.delay < 0){
|
||||
|
||||
Player player = q.getPlayer();
|
||||
if(stages.indexOf(q.currentStage) == (q.currentQuest.stages.size() - 1)){
|
||||
if(q.currentStageIndex == (q.currentQuest.stages.size() - 1)){
|
||||
|
||||
if(q.currentStage.script != null)
|
||||
plugin.trigger.parseQuestTaskTrigger(q.currentStage.script, player);
|
||||
@ -77,26 +77,8 @@ public class Quest {
|
||||
|
||||
}else {
|
||||
|
||||
q.reset();
|
||||
if(q.currentStage.script != null)
|
||||
plugin.trigger.parseQuestTaskTrigger(q.currentStage.script, player);
|
||||
if(q.currentStage.event != null)
|
||||
q.currentStage.event.happen(q);
|
||||
q.currentStage = stages.get(q.currentStageIndex + 1);
|
||||
q.currentStageIndex++;
|
||||
q.addEmpties();
|
||||
|
||||
player.sendMessage(ChatColor.GOLD + "---(Objectives)---");
|
||||
for(String s : q.getObjectives()){
|
||||
|
||||
player.sendMessage(s);
|
||||
|
||||
}
|
||||
|
||||
String stageStartMessage = q.currentStage.startMessage;
|
||||
if (stageStartMessage != null) {
|
||||
q.getPlayer().sendMessage(Quests.parseString(stageStartMessage, q.currentQuest));
|
||||
}
|
||||
setStage(q, q.currentStageIndex);
|
||||
|
||||
}
|
||||
|
||||
@ -110,6 +92,37 @@ public class Quest {
|
||||
|
||||
}
|
||||
|
||||
public void setStage(Quester q, int stage) {
|
||||
|
||||
if (stages.size() - 1 < stage) {
|
||||
return;
|
||||
}
|
||||
|
||||
q.reset();
|
||||
|
||||
if(q.currentStage.script != null)
|
||||
plugin.trigger.parseQuestTaskTrigger(q.currentStage.script, q.getPlayer());
|
||||
|
||||
if(q.currentStage.event != null)
|
||||
q.currentStage.event.happen(q);
|
||||
|
||||
q.currentStage = stages.get(stage);
|
||||
q.addEmpties();
|
||||
|
||||
q.getPlayer().sendMessage(ChatColor.GOLD + "---(Objectives)---");
|
||||
for(String s : q.getObjectives()){
|
||||
|
||||
q.getPlayer().sendMessage(s);
|
||||
|
||||
}
|
||||
|
||||
String stageStartMessage = q.currentStage.startMessage;
|
||||
if (stageStartMessage != null) {
|
||||
q.getPlayer().sendMessage(Quests.parseString(stageStartMessage, q.currentQuest));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return name;
|
||||
}
|
||||
|
@ -6,6 +6,9 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import me.blackvein.quests.events.MiniEvent;
|
||||
import me.blackvein.quests.events.MiniEvent.MiniEventType;
|
||||
import me.blackvein.quests.prompts.RequirementsPrompt;
|
||||
import me.blackvein.quests.prompts.RewardsPrompt;
|
||||
import me.blackvein.quests.prompts.StagesPrompt;
|
||||
@ -1135,6 +1138,8 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
startMessage = null;
|
||||
completeMessage = null;
|
||||
|
||||
Map<MiniEventType, List<MiniEvent>> miniEvents = null;
|
||||
|
||||
|
||||
if (cc.getSessionData(pref + CK.S_BREAK_IDS) != null) {
|
||||
breakIds = (LinkedList<Integer>) cc.getSessionData(pref + CK.S_BREAK_IDS);
|
||||
@ -1242,6 +1247,10 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
completeMessage = (String) cc.getSessionData(pref + CK.S_COMPLETE_MESSAGE);
|
||||
}
|
||||
|
||||
if (cc.getSessionData(pref + CK.S_MINI_EVENTS) != null) {
|
||||
miniEvents = (Map<MiniEventType, List<MiniEvent>>) cc.getSessionData(pref + CK.S_MINI_EVENTS);
|
||||
}
|
||||
|
||||
if (breakIds != null && breakIds.isEmpty() == false) {
|
||||
stage.set("break-block-ids", breakIds);
|
||||
stage.set("break-block-amounts", breakAmounts);
|
||||
@ -1306,6 +1315,16 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
stage.set("start-message", startMessage);
|
||||
stage.set("complete-message", completeMessage);
|
||||
|
||||
//TODO change here
|
||||
if (miniEvents != null && miniEvents.isEmpty() == false) {
|
||||
for (Entry<MiniEventType, List<MiniEvent>> ent : miniEvents.entrySet()) {
|
||||
int count = 1;
|
||||
for (MiniEvent miniEvent : ent.getValue()) {
|
||||
stage.createSection("mini-events." + ent.getKey().getName() + "." + count, miniEvent.getValues());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1684,6 +1703,10 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
|
||||
cc.setSessionData(pref + CK.S_START_MESSAGE, stage.startMessage);
|
||||
}
|
||||
|
||||
if (stage.miniEvents != null && stage.miniEvents.isEmpty() == false) {
|
||||
cc.setSessionData(pref + CK.S_START_MESSAGE, stage.miniEvents);
|
||||
}
|
||||
|
||||
}
|
||||
//
|
||||
|
||||
|
@ -745,20 +745,20 @@ public class Quester {
|
||||
|
||||
public void enchantItem(Enchantment e, Material m) {
|
||||
|
||||
for (Entry entry : itemsEnchanted.entrySet()) {
|
||||
for (Entry<Map<Enchantment, Material>, Integer> entry : itemsEnchanted.entrySet()) {
|
||||
|
||||
if (((Map) entry.getKey()).containsKey(e) && ((Map) entry.getKey()).containsValue(m)) {
|
||||
if (entry.getKey().containsKey(e) && entry.getKey().containsValue(m)) {
|
||||
|
||||
for (Entry entry2 : currentStage.itemsToEnchant.entrySet()) {
|
||||
for (Entry<Map<Enchantment, Material>, Integer> entry2 : currentStage.itemsToEnchant.entrySet()) {
|
||||
|
||||
if (((Map) entry2.getKey()).containsKey(e) && ((Map) entry2.getKey()).containsValue(m)) {
|
||||
if (entry2.getKey().containsKey(e) && entry2.getKey().containsValue(m)) {
|
||||
|
||||
if ((Integer) entry.getValue() < (Integer) entry2.getValue()) {
|
||||
if (entry.getValue() < entry2.getValue()) {
|
||||
|
||||
Integer num = (Integer) entry.getValue() + 1;
|
||||
itemsEnchanted.put(((Map) entry.getKey()), (num));
|
||||
Integer num = entry.getValue() + 1;
|
||||
itemsEnchanted.put(entry.getKey(), num);
|
||||
|
||||
if ((num).equals((Integer) entry2.getValue())) {
|
||||
if (num.equals(entry2.getValue())) {
|
||||
finishObjective("enchantItem", m, null, e, null, null, null, null, null, null);
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.Statement;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
@ -22,6 +21,12 @@ import java.util.logging.Logger;
|
||||
|
||||
import me.ThaH3lper.com.EpicBoss;
|
||||
import me.ThaH3lper.com.LoadBosses.LoadBoss;
|
||||
import me.blackvein.quests.events.MiniEvent;
|
||||
import me.blackvein.quests.events.MiniEvent.MiniEventType;
|
||||
import me.blackvein.quests.events.MiniEventChat;
|
||||
import me.blackvein.quests.events.MiniEventKill;
|
||||
import me.blackvein.quests.events.MiniEventNPCInteract;
|
||||
import me.blackvein.quests.events.MiniEventReach;
|
||||
import me.blackvein.quests.prompts.QuestAcceptPrompt;
|
||||
import me.blackvein.quests.util.ItemUtil;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
@ -108,6 +113,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
public int killDelay = 0;
|
||||
public int totalQuestPoints = 0;
|
||||
public Lang lang;
|
||||
private static Quests instance = null;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
@ -116,6 +122,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
effListener = new NpcEffectThread(this);
|
||||
npcListener = new NpcListener(this);
|
||||
bossListener = new EpicBossListener(this);
|
||||
instance = this;
|
||||
|
||||
this.conversationFactory = new ConversationFactory(this)
|
||||
.withModality(false)
|
||||
@ -271,6 +278,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
|
||||
}
|
||||
|
||||
public static Quests getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private class QuestPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
@ -1000,7 +1011,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
} else if (args[0].equalsIgnoreCase("info")) {
|
||||
|
||||
cs.sendMessage(GOLD + "Quests " + this.getDescription().getVersion());
|
||||
cs.sendMessage(GOLD + "Made by " + DARKRED + "Blackvein");
|
||||
cs.sendMessage(GOLD + "Made by " + DARKRED + "Blackvein" + GOLD + " and " + RED + "BlockCat");
|
||||
return true;
|
||||
|
||||
} else {
|
||||
@ -3003,6 +3014,68 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
|
||||
}
|
||||
|
||||
for (MiniEventType t : MiniEventType.values()) {
|
||||
int meCount = 1;
|
||||
if (config.contains("quests." + s + ".stages.ordered." + s2 + ".mini-events." + t.getName())) {
|
||||
ConfigurationSection configSection = config.createSection("quests." + s + ".stages.ordered." + s2 + ".mini-events." + t.getName());
|
||||
|
||||
LinkedList<MiniEvent> ml = new LinkedList<MiniEvent>();
|
||||
|
||||
for (String string : configSection.getKeys(false)) {
|
||||
|
||||
MiniEvent me = null;
|
||||
ConfigurationSection miniSection = configSection.getConfigurationSection(string);
|
||||
|
||||
switch(t) {
|
||||
case ONDEATH:
|
||||
me = new MiniEvent(miniSection.getValues(false));
|
||||
break;
|
||||
case ONKILL:
|
||||
if (miniSection.contains("data")) {
|
||||
me = new MiniEventKill(quest, miniSection.getValues(false), miniSection.getString("data"));
|
||||
} else {
|
||||
me = new MiniEventKill(quest, miniSection.getValues(false), "");
|
||||
}
|
||||
break;
|
||||
case ONREACH:
|
||||
if (miniSection.contains("data")) {
|
||||
me = new MiniEventReach(quest, miniSection.getValues(false), miniSection.getString("data"));
|
||||
} else {
|
||||
me = new MiniEventReach(quest, miniSection.getValues(false), "");
|
||||
}
|
||||
break;
|
||||
case ONCHAT:
|
||||
if (miniSection.contains("data")) {
|
||||
me = new MiniEventChat(quest, miniSection.getValues(false), miniSection.getString("data"));
|
||||
} else {
|
||||
me = new MiniEventChat(quest, miniSection.getValues(false), "");
|
||||
}
|
||||
break;
|
||||
case ONSTAGEEND:
|
||||
me = new MiniEvent(miniSection.getValues(false));
|
||||
break;
|
||||
case ONQUESTQUIT:
|
||||
me = new MiniEvent(miniSection.getValues(false));
|
||||
break;
|
||||
case ONNPCINTERACT:
|
||||
if (miniSection.contains("data")) {
|
||||
me = new MiniEventNPCInteract(quest, miniSection.getValues(false), miniSection.getString("data"));
|
||||
} else {
|
||||
me = new MiniEventNPCInteract(quest, miniSection.getValues(false), "");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (me != null) {
|
||||
ml.add(me);
|
||||
}
|
||||
meCount++;
|
||||
}
|
||||
|
||||
stage.miniEvents.put(t, ml);
|
||||
}
|
||||
}
|
||||
|
||||
stage.citizensToInteract = npcsToTalkTo;
|
||||
|
||||
if (stageFailed) {
|
||||
@ -3268,6 +3341,42 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
|
||||
|
||||
}
|
||||
|
||||
public static String parseString(String s) {
|
||||
|
||||
String parsed = s;
|
||||
|
||||
parsed = parsed.replaceAll("<black>", BLACK.toString());
|
||||
parsed = parsed.replaceAll("<darkblue>", DARKBLUE.toString());
|
||||
parsed = parsed.replaceAll("<darkgreen>", DARKGREEN.toString());
|
||||
parsed = parsed.replaceAll("<darkaqua>", DARKAQUA.toString());
|
||||
parsed = parsed.replaceAll("<darkred>", DARKRED.toString());
|
||||
parsed = parsed.replaceAll("<purple>", PURPLE.toString());
|
||||
parsed = parsed.replaceAll("<gold>", GOLD.toString());
|
||||
parsed = parsed.replaceAll("<grey>", GRAY.toString());
|
||||
parsed = parsed.replaceAll("<gray>", GRAY.toString());
|
||||
parsed = parsed.replaceAll("<darkgrey>", DARKGRAY.toString());
|
||||
parsed = parsed.replaceAll("<darkgray>", DARKGRAY.toString());
|
||||
parsed = parsed.replaceAll("<blue>", BLUE.toString());
|
||||
parsed = parsed.replaceAll("<green>", GREEN.toString());
|
||||
parsed = parsed.replaceAll("<aqua>", AQUA.toString());
|
||||
parsed = parsed.replaceAll("<red>", RED.toString());
|
||||
parsed = parsed.replaceAll("<pink>", PINK.toString());
|
||||
parsed = parsed.replaceAll("<yellow>", YELLOW.toString());
|
||||
parsed = parsed.replaceAll("<white>", WHITE.toString());
|
||||
|
||||
parsed = parsed.replaceAll("<random>", MAGIC.toString());
|
||||
parsed = parsed.replaceAll("<italic>", ITALIC.toString());
|
||||
parsed = parsed.replaceAll("<bold>", BOLD.toString());
|
||||
parsed = parsed.replaceAll("<underline>", UNDERLINE.toString());
|
||||
parsed = parsed.replaceAll("<strike>", STRIKETHROUGH.toString());
|
||||
parsed = parsed.replaceAll("<reset>", RESET.toString());
|
||||
parsed = ChatColor.translateAlternateColorCodes('&', parsed);
|
||||
|
||||
return parsed;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private boolean setupEconomy() {
|
||||
try {
|
||||
|
||||
|
@ -1,11 +1,17 @@
|
||||
package me.blackvein.quests;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import me.blackvein.quests.events.MiniEvent;
|
||||
import me.blackvein.quests.events.MiniEvent.MiniEventType;
|
||||
import me.blackvein.quests.events.MiniEventKill;
|
||||
import me.blackvein.quests.events.MiniEventReach;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -24,6 +30,9 @@ public class Stage {
|
||||
Integer fishToCatch;
|
||||
Integer playersToKill;
|
||||
Map<Map<Enchantment, Material>, Integer> itemsToEnchant = new HashMap<Map<Enchantment, Material>, Integer>();
|
||||
|
||||
Map<MiniEventType, List<MiniEvent>> miniEvents = new HashMap();
|
||||
|
||||
LinkedList<EntityType> mobsToKill = new LinkedList<EntityType>();
|
||||
LinkedList<Integer> mobNumToKill = new LinkedList<Integer>();
|
||||
LinkedList<Location> locationsToKillWithin = new LinkedList<Location>();
|
||||
@ -90,16 +99,13 @@ public class Stage {
|
||||
|
||||
LinkedList<NPC> otherList = (LinkedList<NPC>) o;
|
||||
|
||||
for (NPC n : this) {
|
||||
if (this.size() != otherList.size()) return false;
|
||||
|
||||
NPC other = otherList.get(this.indexOf(n));
|
||||
if (other.getId() != n.getId()) {
|
||||
return false;
|
||||
for (int i = 0; i < this.size(); i++) {
|
||||
if (this.get(i) != otherList.get(i)) return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
@ -124,6 +130,50 @@ public class Stage {
|
||||
public String completeMessage = null;
|
||||
public String startMessage = null;
|
||||
|
||||
public boolean executeEvent(Quester quester, MiniEventType type) {
|
||||
|
||||
if (miniEvents.containsKey(type)) {
|
||||
boolean isCancelled = false;
|
||||
for (MiniEvent me : miniEvents.get(type)) {
|
||||
boolean c = me.execute(quester);
|
||||
if (c == true) {
|
||||
isCancelled = true;
|
||||
}
|
||||
}
|
||||
return isCancelled;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean executeReachEvent(Location location, Quester quester) {
|
||||
|
||||
if (miniEvents.containsKey(MiniEventType.ONREACH)) {
|
||||
boolean isCancelled = false;
|
||||
for (MiniEvent me : miniEvents.get(MiniEventType.ONREACH)) {
|
||||
boolean c = ((MiniEventReach) me).execute(quester, location);
|
||||
if (c == true) {
|
||||
isCancelled = true;
|
||||
}
|
||||
}
|
||||
return isCancelled;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean executeKillEvent(Quester quester, EntityType entityType) {
|
||||
if (miniEvents.containsKey(MiniEventType.ONKILL)) {
|
||||
boolean isCancelled = false;
|
||||
for (MiniEvent me : miniEvents.get(MiniEventType.ONREACH)) {
|
||||
boolean c = ((MiniEventKill) me).execute(quester, entityType);
|
||||
if (c == true) {
|
||||
isCancelled = true;
|
||||
}
|
||||
}
|
||||
return isCancelled;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
@ -313,4 +363,6 @@ public class Stage {
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
157
src/main/java/me/blackvein/quests/events/MiniEvent.java
Normal file
157
src/main/java/me/blackvein/quests/events/MiniEvent.java
Normal file
@ -0,0 +1,157 @@
|
||||
package me.blackvein.quests.events;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import me.blackvein.quests.ItemUtil;
|
||||
import me.blackvein.quests.Quest;
|
||||
import me.blackvein.quests.Quester;
|
||||
import me.blackvein.quests.Quests;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
public class MiniEvent {
|
||||
|
||||
protected boolean cancelled = false;
|
||||
protected Map<String, Object> values = new LinkedHashMap<String, Object>();
|
||||
|
||||
public MiniEvent(Map<String, Object> map) {
|
||||
if (map != null) {
|
||||
this.values = map;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean execute(Quester quester) {
|
||||
|
||||
if (quester == null) {
|
||||
return true;
|
||||
}
|
||||
for (Entry<String, Object> ent : values.entrySet()) {
|
||||
String key = ent.getKey();
|
||||
String value = (String)ent.getValue();
|
||||
|
||||
switch(key) {
|
||||
case "cancel":
|
||||
setCancelled(value);
|
||||
break;
|
||||
case "command":
|
||||
executeCommand(value);
|
||||
break;
|
||||
case "send-message":
|
||||
sendMessage(value, quester);
|
||||
break;
|
||||
case "chat-message":
|
||||
chatMessage(value, quester);
|
||||
break;
|
||||
case "broadcast-message":
|
||||
broadcastMessage(value);
|
||||
break;
|
||||
case "set-stage":
|
||||
setStage(value, quester);
|
||||
break;
|
||||
case "teleport":
|
||||
teleport(value, quester);
|
||||
break;
|
||||
case "take-item":
|
||||
takeItem(value, quester);
|
||||
break;
|
||||
case "add-item":
|
||||
addItem(value, quester);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return isCancelled();
|
||||
}
|
||||
|
||||
public void setCancelled(String data) {
|
||||
Boolean c = false;
|
||||
try {
|
||||
c = Boolean.parseBoolean(data);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
cancelled = c;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void executeCommand(String command) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
}
|
||||
|
||||
public void sendMessage(String message, Quester quester) {
|
||||
quester.getPlayer().sendMessage(message);
|
||||
}
|
||||
|
||||
public void chatMessage(String message, Quester quester) {
|
||||
quester.getPlayer().chat(message);
|
||||
}
|
||||
|
||||
public void broadcastMessage(String message) {
|
||||
Bukkit.getServer().broadcastMessage(message);
|
||||
}
|
||||
|
||||
public void setStage(String data, Quester quester) {
|
||||
int i = -1;
|
||||
|
||||
try {
|
||||
i = Integer.parseInt(data);
|
||||
} catch (Exception e) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (i > 0)
|
||||
quester.currentQuest.setStage(quester, i - 1);
|
||||
}
|
||||
|
||||
public void teleport(String data, Quester quester) {
|
||||
Location loc = Quests.getLocation(data);
|
||||
if (loc != null) {
|
||||
quester.getPlayer().teleport(loc);
|
||||
}
|
||||
}
|
||||
|
||||
public void takeItem(String data, Quester quester) {
|
||||
ItemStack is = ItemUtil.parseItem(data);
|
||||
PlayerInventory inv = quester.getPlayer().getInventory();
|
||||
|
||||
Quests.removeItem(inv, is);
|
||||
}
|
||||
|
||||
public void addItem(String data, Quester quester) {
|
||||
ItemStack is = ItemUtil.parseItem(data);
|
||||
Quests.addItem(quester.getPlayer(), is);
|
||||
}
|
||||
|
||||
public enum MiniEventType {
|
||||
ONDEATH ("onDeath"),
|
||||
ONKILL ("onKill"),
|
||||
ONREACH("onReach"),
|
||||
ONCHAT("onChat"),
|
||||
ONSTAGEEND("onStageEnd"),
|
||||
ONQUESTQUIT("onQuestQuit"),
|
||||
ONNPCINTERACT("OnNPCInteract");
|
||||
|
||||
private String name;
|
||||
|
||||
MiniEventType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public Map<?, ?> getValues() {
|
||||
return values;
|
||||
}
|
||||
}
|
17
src/main/java/me/blackvein/quests/events/MiniEventChat.java
Normal file
17
src/main/java/me/blackvein/quests/events/MiniEventChat.java
Normal file
@ -0,0 +1,17 @@
|
||||
package me.blackvein.quests.events;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import me.blackvein.quests.Quest;
|
||||
|
||||
public class MiniEventChat extends MiniEvent {
|
||||
|
||||
private String chatString;
|
||||
|
||||
public MiniEventChat(Quest quest, Map<String, Object> keys, String data) {
|
||||
super(keys);
|
||||
this.chatString = data;
|
||||
}
|
||||
|
||||
}
|
31
src/main/java/me/blackvein/quests/events/MiniEventKill.java
Normal file
31
src/main/java/me/blackvein/quests/events/MiniEventKill.java
Normal file
@ -0,0 +1,31 @@
|
||||
package me.blackvein.quests.events;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import me.blackvein.quests.Quest;
|
||||
import me.blackvein.quests.Quester;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public class MiniEventKill extends MiniEvent {
|
||||
|
||||
private List<String> mobTypes;
|
||||
|
||||
public MiniEventKill(Quest quest, Map<String, Object> keys, String mobs) {
|
||||
super(keys);
|
||||
this.mobTypes = Arrays.asList(mobs.split(","));
|
||||
}
|
||||
|
||||
public boolean execute(Quester quester, EntityType type) {
|
||||
if (mobTypes.contains(Quester.prettyMobString(type)) || mobTypes.isEmpty()) {
|
||||
return super.execute(quester);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package me.blackvein.quests.events;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import me.blackvein.quests.Quest;
|
||||
|
||||
public class MiniEventNPCInteract extends MiniEvent {
|
||||
|
||||
private int npcId = -1;
|
||||
|
||||
public MiniEventNPCInteract(Quest quest, Map<String, Object> map, String data) {
|
||||
super(map);
|
||||
|
||||
try {
|
||||
npcId = Integer.parseInt(data);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
41
src/main/java/me/blackvein/quests/events/MiniEventReach.java
Normal file
41
src/main/java/me/blackvein/quests/events/MiniEventReach.java
Normal file
@ -0,0 +1,41 @@
|
||||
package me.blackvein.quests.events;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import me.blackvein.quests.Quest;
|
||||
import me.blackvein.quests.Quester;
|
||||
import me.blackvein.quests.Quests;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class MiniEventReach extends MiniEvent{
|
||||
|
||||
private Location location;
|
||||
private int radius;
|
||||
|
||||
public MiniEventReach(Quest quest, Map<String, Object> keys, String data) {
|
||||
super(keys);
|
||||
try {
|
||||
|
||||
this.location = Quests.getLocation(data.split(":")[0]);
|
||||
this.radius = Integer.parseInt(data.split(":")[1]);
|
||||
} catch(Exception e) {
|
||||
location = null;
|
||||
radius = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean execute(Quester quester, Location loc) {
|
||||
if (location == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (loc.toVector().distance(location.toVector()) > radius) {
|
||||
return false;
|
||||
} else {
|
||||
return super.execute(quester);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,19 +1,25 @@
|
||||
package me.blackvein.quests.prompts;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import me.ThaH3lper.com.LoadBosses.LoadBoss;
|
||||
import me.blackvein.quests.ColorUtil;
|
||||
import me.blackvein.quests.Event;
|
||||
import me.blackvein.quests.QuestFactory;
|
||||
import me.blackvein.quests.Quester;
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.events.MiniEvent;
|
||||
import me.blackvein.quests.events.MiniEvent.MiniEventType;
|
||||
import me.blackvein.quests.util.CK;
|
||||
import me.blackvein.quests.util.ItemUtil;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import net.aufdemrand.denizen.scripts.ScriptRegistry;
|
||||
import net.citizensnpcs.api.CitizensPlugin;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -35,7 +41,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", "23", "24");
|
||||
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", "25");
|
||||
this.stageNum = stageNum;
|
||||
this.pref = "stage" + stageNum;
|
||||
this.citizens = cit;
|
||||
@ -321,7 +327,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
}
|
||||
|
||||
if (context.getSessionData(pref + CK.S_DELAY) == null) {
|
||||
text += GRAY + "" + BOLD + "19 " + RESET + GRAY + "- " + Lang.get("stageEditorDelayMessage") + GRAY + " " + Lang.get("noDelaySet") + "\n";
|
||||
text += GRAY + "" + BOLD + "19 " + RESET + GRAY + "- " + Lang.get("stageEditorDelayMessage") + GRAY + " (" + Lang.get("noDelaySet") + ")\n";
|
||||
} else if (context.getSessionData(pref + CK.S_DELAY_MESSAGE) == null) {
|
||||
text += PINK + "" + BOLD + "19 " + RESET + PURPLE + "- "+ Lang.get("stageEditorDelayMessage") + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
} else {
|
||||
@ -334,7 +340,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
} else {
|
||||
|
||||
if (context.getSessionData(pref + CK.S_DENIZEN) == null) {
|
||||
text += GRAY + "" + BOLD + "20 " + RESET + PURPLE + "- " + Lang.get("stageEditorDenizenScript") + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
text += PINK + "" + BOLD + "20 " + RESET + PURPLE + "- " + Lang.get("stageEditorDenizenScript") + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
} else {
|
||||
text += PINK + "" + BOLD + "20 " + RESET + PURPLE + "- " + Lang.get("stageEditorDenizenScript") + GRAY + " (" + AQUA + context.getSessionData(pref + CK.S_DENIZEN) + GRAY + "\n";
|
||||
}
|
||||
@ -353,8 +359,10 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
text += PINK + "" + BOLD + "22 " + RESET + PURPLE + "- " + Lang.get("stageEditorCompleteMessage") + GRAY + "(" + AQUA + "\"" + context.getSessionData(pref + CK.S_COMPLETE_MESSAGE) + "\"" + GRAY + ")\n";
|
||||
}
|
||||
|
||||
text += RED + "" + BOLD + "23 " + RESET + PURPLE + "- " + Lang.get("stageEditorDelete") + "\n";
|
||||
text += GREEN + "" + BOLD + "24 " + RESET + PURPLE + "- " + Lang.get("done") + "\n";
|
||||
text += PINK + "" + BOLD + "23 " + RESET + PURPLE + "- " + Lang.get("stageEditorMiniEventMessage") + "\n";
|
||||
|
||||
text += RED + "" + BOLD + "24 " + RESET + PURPLE + "- " + Lang.get("stageEditorDelete") + "\n";
|
||||
text += GREEN + "" + BOLD + "25 " + RESET + PURPLE + "- " + Lang.get("done") + "\n";
|
||||
|
||||
return text;
|
||||
|
||||
@ -438,8 +446,10 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
} else if (input.equalsIgnoreCase("22")) {
|
||||
return new CompleteMessagePrompt();
|
||||
} else if (input.equalsIgnoreCase("23")) {
|
||||
return new DeletePrompt();
|
||||
return new MiniEventPrompt();
|
||||
} else if (input.equalsIgnoreCase("24")) {
|
||||
return new DeletePrompt();
|
||||
} else if (input.equalsIgnoreCase("25")) {
|
||||
return new StagesPrompt(questFactory);
|
||||
} else {
|
||||
return new CreateStagePrompt(stageNum, questFactory, citizens);
|
||||
@ -3369,7 +3379,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
//TODO: Here
|
||||
|
||||
String text = DARKGREEN + "- " + Lang.get("stageEditorEvents") + " -\n";
|
||||
if (questFactory.quests.events.isEmpty()) {
|
||||
text += RED + "- None";
|
||||
@ -3536,7 +3546,7 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
player.sendMessage(YELLOW + "Denizen script cleared.");
|
||||
return new CreateStagePrompt(stageNum, questFactory, citizens);
|
||||
} else {
|
||||
return new DenizenPrompt();
|
||||
return new CreateStagePrompt(stageNum, questFactory, citizens);
|
||||
}
|
||||
|
||||
}
|
||||
@ -3819,4 +3829,255 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class MiniEventPrompt extends StringPrompt {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
String text = YELLOW + "- " + GOLD + Lang.get("stageEditorMiniEventMessage") + YELLOW + "-\n";
|
||||
if (context.getSessionData(CK.S_MINI_EVENTS) == null) {
|
||||
text += PINK + "" + BOLD + "1 " + RESET + PURPLE + "- " + "onDeath" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
text += PINK + "" + BOLD + "2 " + RESET + PURPLE + "- " + "onKill" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
text += PINK + "" + BOLD + "3 " + RESET + PURPLE + "- " + "onReach" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
text += PINK + "" + BOLD + "4 " + RESET + PURPLE + "- " + "onStageEnd" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
text += PINK + "" + BOLD + "5 " + RESET + PURPLE + "- " + "onQuestQuit" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
text += PINK + "" + BOLD + "6 " + RESET + PURPLE + "- " + "onNpcTalk" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
text += GREEN + "" + BOLD + "7 " + RESET + GREEN + "- " + Lang.get("done");
|
||||
} else {
|
||||
Map<MiniEventType, List<MiniEvent>> map = (Map<MiniEventType, List<MiniEvent>>) context.getSessionData(CK.S_MINI_EVENTS);
|
||||
|
||||
if (map.containsKey(MiniEventType.ONDEATH)) {
|
||||
text += PINK + "" + BOLD + "1 " + RESET + PURPLE + "- " + "onDeath" + AQUA + " (" + map.get(MiniEventType.ONDEATH).size() + ")\n";
|
||||
} else {
|
||||
text += PINK + "" + BOLD + "1 " + RESET + PURPLE + "- " + "onDeath" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey(MiniEventType.ONKILL)) {
|
||||
text += PINK + "" + BOLD + "2 " + RESET + PURPLE + "- " + "onKill" + AQUA + " (" + map.get(MiniEventType.ONKILL) + ")\n";
|
||||
} else {
|
||||
text += PINK + "" + BOLD + "2 " + RESET + PURPLE + "- " + "onKill" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey(MiniEventType.ONREACH)) {
|
||||
text += PINK + "" + BOLD + "3 " + RESET + PURPLE + "- " + "onReach" + AQUA + " (" + map.get(MiniEventType.ONREACH).size() + ")\n";
|
||||
} else {
|
||||
text += PINK + "" + BOLD + "3 " + RESET + PURPLE + "- " + "onReach" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey(MiniEventType.ONSTAGEEND)) {
|
||||
text += PINK + "" + BOLD + "4 " + RESET + PURPLE + "- " + "onStageEnd" + AQUA + " (" + map.get(MiniEventType.ONSTAGEEND).size() + ")\n";
|
||||
} else {
|
||||
text += PINK + "" + BOLD + "4 " + RESET + PURPLE + "- " + "onStageEnd" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey(MiniEventType.ONQUESTQUIT)) {
|
||||
text += PINK + "" + BOLD + "5 " + RESET + PURPLE + "- " + "onQuestQuit" + AQUA + " (" + map.get(MiniEventType.ONQUESTQUIT).size() + ")\n";
|
||||
} else {
|
||||
text += PINK + "" + BOLD + "5 " + RESET + PURPLE + "- " + "onQuestQuit" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
if (map.containsKey(MiniEventType.ONNPCINTERACT)) {
|
||||
text += PINK + "" + BOLD + "6 " + RESET + PURPLE + "- " + "onNpcTalk" + AQUA + " (" + map.get(MiniEventType.ONNPCINTERACT).size() + ")\n";
|
||||
} else {
|
||||
text += PINK + "" + BOLD + "6 " + RESET + PURPLE + "- " + "onNpcTalk" + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
text += GREEN + "" + BOLD + "7 " + RESET + GREEN + "- " + Lang.get("done");
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext context, String input) {
|
||||
MiniEventType type = null;
|
||||
switch (input) {
|
||||
case "1":
|
||||
type = MiniEventType.ONDEATH;
|
||||
break;
|
||||
case "2":
|
||||
type = MiniEventType.ONKILL;
|
||||
break;
|
||||
case "3":
|
||||
type = MiniEventType.ONREACH;
|
||||
break;
|
||||
case "4":
|
||||
type = MiniEventType.ONSTAGEEND;
|
||||
break;
|
||||
case "5":
|
||||
type = MiniEventType.ONQUESTQUIT;
|
||||
break;
|
||||
case "6":
|
||||
type = MiniEventType.ONNPCINTERACT;
|
||||
break;
|
||||
case "7":
|
||||
return new CreateStagePrompt(stageNum, questFactory, citizens);
|
||||
}
|
||||
|
||||
if (type == null) return new MiniEventPrompt();
|
||||
|
||||
return new MiniEventEditorPrompt(type);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private class MiniEventEditorPrompt extends StringPrompt {
|
||||
|
||||
private MiniEventType type;
|
||||
|
||||
public MiniEventEditorPrompt (MiniEventType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
String text = YELLOW + "- " + GOLD + type.getName() + YELLOW + "-\n";
|
||||
if (context.getSessionData(CK.S_MINI_EVENTS) == null) {
|
||||
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("stageEditorAddMiniEvent") + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - " + Lang.get("clear") + "\n";
|
||||
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("done");
|
||||
} else {
|
||||
HashMap<MiniEventType, List<MiniEvent>> types = (HashMap<MiniEventType, List<MiniEvent>>) context.getSessionData(CK.S_MINI_EVENTS);
|
||||
for (int i = 0; i < types.size(); i++) {
|
||||
text += GOLD + " " + (i + 1) + " - Edit: " + AQUA + "Mini-Event: " + (i + 1);
|
||||
}
|
||||
|
||||
text += BLUE + "" + BOLD + (types.size() + 1) + RESET + YELLOW + " - " + Lang.get("stageEditorAddMiniEvent") + "\n";
|
||||
text += BLUE + "" + BOLD + (types.size() + 2) + RESET + YELLOW + " - " + Lang.get("clear") + "\n";
|
||||
text += GREEN + "" + BOLD + (types.size() + 3) + RESET + YELLOW + " - " + Lang.get("done");
|
||||
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext context, String input) {
|
||||
HashMap<MiniEventType, List<MiniEvent>> map = (HashMap<MiniEventType, List<MiniEvent>>) context.getSessionData(CK.S_MINI_EVENTS);
|
||||
boolean none = true;
|
||||
if (map != null) {
|
||||
if (map.containsKey(type)) none = false;
|
||||
}
|
||||
if (none) {
|
||||
if (input.equalsIgnoreCase("1")) {
|
||||
return new MiniEventAddPrompt(0, null);
|
||||
} else if (input.equalsIgnoreCase("2")) {
|
||||
//TODO cleared
|
||||
context.getForWhom().sendRawMessage(YELLOW + Lang.get("eventEditorMobSpawnsCleared"));
|
||||
return new MiniEventEditorPrompt(type);
|
||||
} else if (input.equalsIgnoreCase("3")) {
|
||||
return new CreateStagePrompt(stageNum, questFactory, citizens);
|
||||
}
|
||||
} else {
|
||||
LinkedList<MiniEvent> types = new LinkedList<MiniEvent>(map.get(type));
|
||||
int inp = -1;
|
||||
try {
|
||||
inp = Integer.parseInt(input);
|
||||
} catch (Exception e) {
|
||||
context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorNotANumber"));
|
||||
return new MiniEventEditorPrompt(type);
|
||||
}
|
||||
|
||||
if (inp == types.size() + 1) {
|
||||
return new MiniEventAddPrompt(inp - 1, null);
|
||||
} else if (inp == types.size() + 2) {
|
||||
//TODO cleared
|
||||
context.getForWhom().sendRawMessage(YELLOW + Lang.get("eventEditorMobSpawnsCleared"));
|
||||
map.put(type, null);
|
||||
context.setSessionData(CK.S_MINI_EVENTS, map);
|
||||
return new MiniEventEditorPrompt(type);
|
||||
} else if (inp == types.size() + 3) {
|
||||
return new CreateStagePrompt(stageNum, questFactory, citizens);
|
||||
} else if (inp > types.size()){
|
||||
return new MiniEventEditorPrompt(type);
|
||||
} else {
|
||||
return new MiniEventAddPrompt(inp - 1, types.get(inp - 1));
|
||||
}
|
||||
}
|
||||
|
||||
return new MiniEventEditorPrompt(type);
|
||||
}
|
||||
}
|
||||
|
||||
private class MiniEventAddPrompt extends StringPrompt {
|
||||
|
||||
private int index;
|
||||
private MiniEvent miniEvent;
|
||||
|
||||
public MiniEventAddPrompt (int index, MiniEvent miniEvent) {
|
||||
this.index = index;
|
||||
if (miniEvent == null) {
|
||||
this.miniEvent = new MiniEvent(null);
|
||||
} else {
|
||||
this.miniEvent = miniEvent;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public String getPromptText(ConversationContext context) {
|
||||
String text = "\n";
|
||||
HashMap<String, String> map = (HashMap<String, String>) miniEvent.getValues();
|
||||
|
||||
if (map.containsKey("cancel")) {
|
||||
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventCancel") + GRAY + " (" + map.get("cancel") + ")\n";
|
||||
} else {
|
||||
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventCancel") + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey("command")) {
|
||||
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventCommand") + GRAY + " (" + map.get("command") + ")\n";
|
||||
} else {
|
||||
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventCommand") + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey("send-message")) {
|
||||
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventSendMessage") + GRAY + " (" + map.get("send-message") + ")\n";
|
||||
} else {
|
||||
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventSendMessage") + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey("chat-message")) {
|
||||
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventChatMessage") + GRAY + " (" + map.get("chat-message") + ")\n";
|
||||
} else {
|
||||
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventChatMessage") + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey("broadcast-message")) {
|
||||
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventBroadcastMessage") + GRAY + " (" + map.get("broadcast-message") + ")\n";
|
||||
} else {
|
||||
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventBroadcaseMessage") + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey("set-stage")) {
|
||||
text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventSetStage") + GRAY + " (" + map.get("set-stage") + ")\n";
|
||||
} else {
|
||||
text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventSetStage") + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey("teleport")) {
|
||||
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventTeleport") + GRAY + " (" + map.get("teleport") + ")\n";
|
||||
} else {
|
||||
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventTeleport") + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey("take-item")) {
|
||||
text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventTakeItem") + GRAY + " (" + map.get("take-item") + ")\n";
|
||||
} else {
|
||||
text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventTakeItem") + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
if (map.containsKey("add-item")) {
|
||||
text += BLUE + "" + BOLD + "8" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventAddItem") + GRAY + " (" + map.get("add-item") + ")\n";
|
||||
} else {
|
||||
text += BLUE + "" + BOLD + "8" + RESET + YELLOW + " - " + Lang.get("stageEditorMiniEventAddItem") + GRAY + " (" + Lang.get("noneSet") + ")\n";
|
||||
}
|
||||
|
||||
text += GREEN + "" + BOLD + "9" + RESET + YELLOW + " - " + Lang.get("done");
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext context, String input) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ public class CK {
|
||||
public static final String S_DENIZEN = "denizen";
|
||||
public static final String S_COMPLETE_MESSAGE = "completeMessage";
|
||||
public static final String S_START_MESSAGE = "startMessage";
|
||||
public static final String S_MINI_EVENTS = "miniEvents";
|
||||
|
||||
//Events
|
||||
public static final String E_OLD_EVENT = "oldEvent";
|
||||
|
@ -119,6 +119,7 @@ public class Lang {
|
||||
en.put("stageEditorDenizenScript", "Denizen Script");
|
||||
en.put("stageEditorStartMessage", "Start Message");
|
||||
en.put("stageEditorCompleteMessage", "Complete Message");
|
||||
en.put("stageEditorMiniEventMessage", "Mini-Events");
|
||||
en.put("stageEditorDelete", "Delete Stage");
|
||||
|
||||
en.put("stageEditorDamageBlocks", "Damage Blocks");
|
||||
@ -146,6 +147,7 @@ public class Lang {
|
||||
en.put("stageEditorSetShearColors", "Set sheep colors");
|
||||
en.put("stageEditorSetShearAmounts", "Set shear amounts");
|
||||
en.put("stageEditorSetBosses", "Set Bosses");
|
||||
en.put("stageEditorAddMiniEvent", "Add mini-event");
|
||||
|
||||
en.put("stageEditorEnterBlockIds", "Enter block IDs, separating each one by a space, or enter \'cancel\' to return.");
|
||||
en.put("stageEditorBreakBlocksPrompt", "Enter block amounts (numbers), separating each one by a space, or enter \'cancel\' to return.");
|
||||
|
Loading…
Reference in New Issue
Block a user