+ Changed way of spawning mobs with an event.

This commit is contained in:
Zino 2013-08-20 20:39:31 +02:00
parent 35971be829
commit 526e6f28dc
9 changed files with 1127 additions and 722 deletions

217
pom.xml
View File

@ -1,129 +1,110 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.blackvein.quests</groupId>
<artifactId>quests</artifactId>
<version>1.6.7-SNAPSHOT</version>
<name>quests</name>
<url>http://dev.bukkit.org/server-mods/quests/</url>
<packaging>jar</packaging>
<description></description>
<groupId>me.blackvein.quests</groupId>
<artifactId>quests</artifactId>
<version>1.6.7-SNAPSHOT</version>
<name>quests</name>
<url>http://dev.bukkit.org/server-mods/quests/</url>
<packaging>jar</packaging>
<description></description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<libs.dir>${project.basedir}/lib</libs.dir>
</properties>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public</url>
</repository>
<repository>
<repositories>
<repository>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public</url>
</repository>
<repository>
<id>citizens-repo</id>
<url>http://repo.citizensnpcs.com</url>
</repository>
<repository>
<id>denizens-repo</id>
<url>http://repo.citizensnpcs.com</url>
</repository>
<repository>
<id>vault-repo</id>
<url>http://ci.herocraftonline.com/plugin/repository/everything</url>
</repository>
<repository>
<id>mcMMO-repo</id>
<url>http://repo.mcmmo.org</url>
</repository>
<repository>
<id>denizens-repo</id>
<url>http://repo.citizensnpcs.com</url>
</repository>
<repository>
<id>vault-repo</id>
<url>http://ci.herocraftonline.com/plugin/repository/everything</url>
</repository>
<repository>
<id>mcMMO-repo</id>
<url>http://repo.mcmmo.org</url>
</repository>
</repositories>
</repositories>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens</artifactId>
<version>2.0.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.aufdemrand</groupId>
<artifactId>denizen</artifactId>
<version>0.9.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>Vault</artifactId>
<version>1.2.22-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>me.ThaH3lper</groupId>
<artifactId>EpicBoss</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${libs.dir}/EpicBossRecoded.jar</systemPath>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens</artifactId>
<version>2.0.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.aufdemrand</groupId>
<artifactId>denizen</artifactId>
<version>0.9.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>Vault</artifactId>
<version>1.2.22-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>me.ThaH3lper</groupId>
<artifactId>EpicBoss</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/EpicBossRecoded.jar</systemPath>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<targetPath>.</targetPath>
<directory>${basedir}/src/main/resources/</directory>
<filtering>true</filtering>
<includes>
<include>config.yml</include>
<include>plugin.yml</include>
<include>events.yml</include>
<include>quests.yml</include>
<include>items.txt</include>
</includes>
</resource>
<resource>
<targetPath>.</targetPath>
<directory>${basedir}/</directory>
<filtering>false</filtering>
<includes>
<include>README.md</include>
</includes>
</resource>
</resources>
<build>
<resources>
<resource>
<targetPath>.</targetPath>
<directory>${basedir}/src/main/resources/</directory>
<filtering>true</filtering>
<includes>
<include>config.yml</include>
<include>plugin.yml</include>
<include>events.yml</include>
<include>quests.yml</include>
<include>items.txt</include>
</includes>
</resource>
<resource>
<targetPath>.</targetPath>
<directory>${basedir}/</directory>
<filtering>false</filtering>
<includes>
<include>README.md</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<addMavenDescriptor>true</addMavenDescriptor>
<manifest>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
<outputDirectory>${project.build.directory}</outputDirectory>
<finalName>${project.build.finalName}</finalName>
</configuration>
</plugin>
</plugins>
</build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,9 +1,19 @@
package me.blackvein.quests;
import java.io.File;
import java.util.*;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import me.blackvein.quests.util.ItemUtil;
import org.bukkit.*;
import me.blackvein.quests.util.QuestMob;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.EntityType;
@ -23,9 +33,23 @@ public class Event {
int stormDuration = 0;
World thunderWorld = null;
int thunderDuration = 0;
LinkedList<Location> mobSpawnLocs = new LinkedList<Location>();
LinkedList<EntityType> mobSpawnTypes = new LinkedList<EntityType>();
LinkedList<Integer> mobSpawnAmounts = new LinkedList<Integer>();
public LinkedList<QuestMob> mobSpawns = new LinkedList<QuestMob>() {
@Override
public boolean equals(Object o) {
if (o instanceof LinkedList) {
LinkedList<QuestMob> other = (LinkedList<QuestMob>) o;
if (size() != other.size()) return false;
for (int i = 0; i < size(); i++) {
if (get(i).equals(other.get(i)) == false) return false;
}
}
return false;
}
};
LinkedList<Location> lightningStrikes = new LinkedList<Location>();
LinkedList<String> commands = new LinkedList<String>();
LinkedList<PotionEffect> potionEffects = new LinkedList<PotionEffect>();
@ -99,17 +123,8 @@ public class Event {
return false;
}
if (other.mobSpawnLocs.equals(mobSpawnLocs) == false) {
return false;
}
if (other.mobSpawnTypes.equals(mobSpawnTypes) == false) {
return false;
}
if (other.mobSpawnAmounts.equals(mobSpawnAmounts) == false) {
return false;
}
if (other.mobSpawns.equals(mobSpawns) == false)
return false;
if (other.lightningStrikes.equals(lightningStrikes) == false) {
return false;
@ -206,18 +221,11 @@ public class Event {
thunderWorld.setThunderDuration(thunderDuration);
}
if (mobSpawnLocs.isEmpty() == false) {
for (Location l : mobSpawnLocs) {
for (int i = 1; i <= mobSpawnAmounts.get(mobSpawnLocs.indexOf(l)); i++) {
l.getWorld().spawnEntity(l, mobSpawnTypes.get(mobSpawnLocs.indexOf(l)));
}
}
if (mobSpawns.isEmpty() == false) {
for (QuestMob questMob : mobSpawns) {
questMob.spawn();
}
}
if (lightningStrikes.isEmpty() == false) {
@ -458,70 +466,53 @@ public class Event {
}
if (data.contains(eventKey + "mob-spawn-locations")) {
if (data.contains(eventKey + "mob-spawns")) {
ConfigurationSection section = data.getConfigurationSection(eventKey + "mob-spawns");
if (Quests.checkList(data.getList(eventKey + "mob-spawn-locations"), String.class)) {
//is a mob, the keys are just a number or something.
for (String s : section.getKeys(false)) {
String mobName = section.getString(s + ".name");
Location spawnLocation = Quests.getLocation(section.getString(s + ".spawn-location"));
EntityType type = Quests.getMobType(section.getString(s + ".mob-type"));
Integer mobAmount = section.getInt(s + ".spawn-amounts");
if (data.contains(eventKey + "mob-spawn-types")) {
if (Quests.checkList(data.getList(eventKey + "mob-spawn-types"), String.class)) {
if (spawnLocation == null) {
Quests.printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + s + ChatColor.GOLD + " inside " + ChatColor.GREEN + " mob-spawn-locations: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not in proper location format!");
Quests.printSevere(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\"");
return null;
}
if (data.contains(eventKey + "mob-spawn-amounts")) {
if (Quests.checkList(data.getList(eventKey + "mob-spawn-amounts"), Integer.class)) {
List<String> mobLocs = data.getStringList(eventKey + "mob-spawn-locations");
List<String> mobTypes = data.getStringList(eventKey + "mob-spawn-types");
List<Integer> mobAmounts = data.getIntegerList(eventKey + "mob-spawn-amounts");
for (String s : mobLocs) {
Location location = Quests.getLocation(s);
if (location == null) {
Quests.printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + s + ChatColor.GOLD + " inside " + ChatColor.GREEN + " mob-spawn-locations: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not in proper location format!");
Quests.printSevere(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\"");
return null;
}
EntityType type = Quests.getMobType(mobTypes.get(mobLocs.indexOf(s)));
if (type == null) {
Quests.printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + mobTypes.get(mobLocs.indexOf(s)) + ChatColor.GOLD + " inside " + ChatColor.GREEN + " mob-spawn-types: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid mob name!");
return null;
}
int amount = mobAmounts.get(mobLocs.indexOf(s));
event.mobSpawnLocs.add(location);
event.mobSpawnTypes.add(type);
event.mobSpawnAmounts.add(amount);
}
} else {
Quests.printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "mob-spawn-amounts: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of numbers!");
return null;
}
} else {
Quests.printSevere(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "mob-spawn-amounts:");
return null;
}
} else {
Quests.printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "mob-spawn-types: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of mob names!");
return null;
}
} else {
Quests.printSevere(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "mob-spawn-types:");
if (type == null) {
Quests.printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + section.getString(s + ".mob-type") + ChatColor.GOLD + " inside " + ChatColor.GREEN + " mob-spawn-types: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid mob name!");
return null;
}
} else {
Quests.printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "mob-spawn-locations: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of locations!");
return null;
}
ItemStack[] inventory = new ItemStack[5];
Float[] dropChances = new Float[5];
inventory[0] = ItemUtil.readItemStack(section.getString(s + ".held-item"));
dropChances[0] = (float) section.getDouble(s + ".held-item-drop-chance");
inventory[1] = ItemUtil.readItemStack(section.getString(s + ".boots"));
dropChances[1] = (float) section.getDouble(s + ".boots-drop-chance");
inventory[2] = ItemUtil.readItemStack(section.getString(s + ".leggings"));
dropChances[2] = (float) section.getDouble(s + ".leggings-drop-chance");
inventory[3] = ItemUtil.readItemStack(section.getString(s + ".chest-plate"));
dropChances[3] = (float) section.getDouble(s + ".chest-plate-drop-chance");
inventory[4] = ItemUtil.readItemStack(section.getString(s + ".helmet"));
dropChances[4] = (float) section.getDouble(s + ".helmet-drop-chance");
QuestMob questMob = new QuestMob(type, spawnLocation, mobAmount);
questMob.inventory = inventory;
questMob.dropChances = dropChances;
questMob.setName(mobName);
event.mobSpawns.add(questMob);
}
}
if (data.contains(eventKey + "lightning-strikes")) {

View File

@ -7,10 +7,12 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import me.blackvein.quests.prompts.ItemStackPrompt;
import me.blackvein.quests.util.CK;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import me.blackvein.quests.util.QuestMob;
import net.citizensnpcs.api.CitizensAPI;
import org.apache.commons.lang.StringUtils;
@ -21,7 +23,15 @@ import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.conversations.*;
import org.bukkit.conversations.ConversationAbandonedEvent;
import org.bukkit.conversations.ConversationAbandonedListener;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.ConversationFactory;
import org.bukkit.conversations.ConversationPrefix;
import org.bukkit.conversations.FixedSetPrompt;
import org.bukkit.conversations.NumericPrompt;
import org.bukkit.conversations.Prompt;
import org.bukkit.conversations.StringPrompt;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
@ -184,8 +194,6 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
context.setSessionData(CK.E_WORLD_THUNDER, null);
context.setSessionData(CK.E_WORLD_THUNDER_DURATION, null);
context.setSessionData(CK.E_MOB_TYPES, null);
context.setSessionData(CK.E_MOB_AMOUNTS, null);
context.setSessionData(CK.E_MOB_LOCATIONS, null);
context.setSessionData(CK.E_LIGHTNING, null);
context.setSessionData(CK.E_POTION_TYPES, null);
context.setSessionData(CK.E_POTION_DURATIONS, null);
@ -233,7 +241,7 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
LinkedList<String> effs = new LinkedList<String>();
LinkedList<String> locs = new LinkedList<String>();
for(Entry e : event.effects.entrySet()){
for(Entry<?, ?> e : event.effects.entrySet()){
effs.add(((Effect) e.getKey()).toString());
locs.add(Quests.getLocationInfo((Location) e.getValue()));
@ -259,24 +267,15 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
}
if(event.mobSpawnTypes != null && event.mobSpawnTypes.isEmpty() == false){
if (event.mobSpawns != null && event.mobSpawns.isEmpty() == false) {
LinkedList<String> types = new LinkedList<String>();
LinkedList<String> locs = new LinkedList<String>();
LinkedList<Integer> amounts = new LinkedList<Integer>();
LinkedList<String> questMobs = new LinkedList<String>();
for(int i = 0; i < event.mobSpawnTypes.size(); i++){
types.add(Quester.prettyMobString(event.mobSpawnTypes.get(i)));
locs.add(Quests.getLocationInfo(event.mobSpawnLocs.get(i)));
amounts.add(event.mobSpawnAmounts.get(i));
}
context.setSessionData(CK.E_MOB_TYPES, types);
context.setSessionData(CK.E_MOB_AMOUNTS, amounts);
context.setSessionData(CK.E_MOB_LOCATIONS, locs);
for (QuestMob questMob : event.mobSpawns) {
questMobs.add(questMob.serialize());
}
context.setSessionData(CK.E_MOB_TYPES, questMobs);
}
if(event.lightningStrikes != null && event.lightningStrikes.isEmpty() == false){
@ -571,15 +570,12 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
text += BLUE + "" + BOLD + "9" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobSpawns") + GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
LinkedList<String> types = (LinkedList<String>) context.getSessionData(CK.E_MOB_TYPES);
LinkedList<Integer> amounts = (LinkedList<Integer>) context.getSessionData(CK.E_MOB_AMOUNTS);
LinkedList<String> locations = (LinkedList<String>) context.getSessionData(CK.E_MOB_LOCATIONS);
text += BLUE + "" + BOLD + "9" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobSpawns") + "\n";
for (String s : types) {
int amt = amounts.get(types.indexOf(s));
String loc = locations.get(types.indexOf(s));
text += GRAY + " - " + AQUA + s + GRAY + " x " + DARKAQUA + amt + GRAY + " -> " + GREEN + loc + "\n";
QuestMob qm = QuestMob.fromString(s);
text += GRAY + " - " + AQUA + qm.getType().getName() + ((qm.getName() != null) ? ": " + qm.getName() : "") + GRAY + " x " + DARKAQUA + qm.getSpawnAmounts() + GRAY + " -> " + GREEN + Quests.getLocationInfo(qm.getSpawnLocation()) + "\n";
}
}
@ -862,7 +858,8 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
return (String)context.getSessionData(path);
}
private static LinkedList<String> getCStringList(ConversationContext context, String path){
@SuppressWarnings("unchecked")
private static LinkedList<String> getCStringList(ConversationContext context, String path){
return (LinkedList<String>)context.getSessionData(path);
}
@ -870,7 +867,8 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
return (Integer)context.getSessionData(path);
}
private static LinkedList<Integer> getCIntList(ConversationContext context, String path){
@SuppressWarnings("unchecked")
private static LinkedList<Integer> getCIntList(ConversationContext context, String path){
return (LinkedList<Integer>)context.getSessionData(path);
}
@ -878,7 +876,8 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
return (Boolean)context.getSessionData(path);
}
private static LinkedList<Boolean> getCBooleanList(ConversationContext context, String path){
@SuppressWarnings("unchecked")
private static LinkedList<Boolean> getCBooleanList(ConversationContext context, String path){
return (LinkedList<Boolean>)context.getSessionData(path);
}
@ -886,7 +885,8 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
return (Long)context.getSessionData(path);
}
private static LinkedList<Long> getCLongList(ConversationContext context, String path){
@SuppressWarnings("unchecked")
private static LinkedList<Long> getCLongList(ConversationContext context, String path){
return (LinkedList<Long>)context.getSessionData(path);
}
//
@ -1007,16 +1007,39 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
}
try {
if (context.getSessionData(CK.E_MOB_TYPES) != null) {
int count = 0;
LinkedList<String> types = getCStringList(context, CK.E_MOB_TYPES);
LinkedList<Integer> amounts = getCIntList(context, CK.E_MOB_AMOUNTS);
LinkedList<String> locations = getCStringList(context, CK.E_MOB_LOCATIONS);
for (String s : getCStringList(context, CK.E_MOB_TYPES)) {
ConfigurationSection ss = section.getConfigurationSection("mob-spawns." + count);
if (ss == null) {
ss = section.createSection("mob-spawns." + count);
}
QuestMob questMob = QuestMob.fromString(s);
section.set("mob-spawn-types", types);
section.set("mob-spawn-amounts", amounts);
section.set("mob-spawn-locations", locations);
if (questMob == null) continue;
ss.set("name", questMob.getName());
ss.set("spawn-location", Quests.getLocationInfo(questMob.getSpawnLocation()));
ss.set("mob-type", questMob.getType().getName());
ss.set("spawn-amounts", questMob.getSpawnAmounts());
ss.set("held-item", ItemUtil.serialize(questMob.inventory[0]));
ss.set("held-item-drop-chance", questMob.dropChances[0]);
ss.set("boots", ItemUtil.serialize(questMob.inventory[1]));
ss.set("boots-drop-chance", questMob.dropChances[1]);
ss.set("leggings", ItemUtil.serialize(questMob.inventory[2]));
ss.set("leggings-drop-chance", questMob.dropChances[2]);
ss.set("chest-plate", ItemUtil.serialize(questMob.inventory[3]));
ss.set("chest-plate-drop-chance", questMob.dropChances[3]);
ss.set("helmet", ItemUtil.serialize(questMob.inventory[4]));
ss.set("helmet-drop-chance", questMob.dropChances[4]);
count++;
}
}
} catch (Exception e) {
e.printStackTrace();
}
if (context.getSessionData(CK.E_LIGHTNING) != null) {
@ -1029,7 +1052,8 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
if (context.getSessionData(CK.E_COMMANDS) != null) {
LinkedList<String> commands = getCStringList(context, CK.E_COMMANDS);
section.set("commands", commands);
if (commands.isEmpty() == false)
section.set("commands", commands);
}
@ -1855,57 +1879,27 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
}
}
private class MobPrompt extends FixedSetPrompt {
public MobPrompt() {
super("1", "2", "3", "4", "5");
}
private class MobPrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext context) {
String text = GOLD + "- " + Lang.get("eventEditorMobSpawns") + " -\n";
if (context.getSessionData(CK.E_MOB_TYPES) == null) {
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobTypes") + " (" + Lang.get("noneSet") + ")\n";
text += GRAY + "2 - " + Lang.get("eventEditorSetMobAmounts") + " " + Lang.get("eventEditorNoTypesSet") + "\n";
text += GRAY + "3 - " + Lang.get("eventEditorAddSpawnLocation") + " " + Lang.get("eventEditorNoTypesSet") + "\n";
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("clear") + "\n";
text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("done");
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("eventEditorAddMobTypes") + " (" + Lang.get("noneSet") + ")\n";
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - " + Lang.get("clear") + "\n";
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("done");
} else {
LinkedList<String> types = (LinkedList<String>) context.getSessionData(CK.E_MOB_TYPES);
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobTypes") + "\n";
for (String s : (LinkedList<String>) context.getSessionData(CK.E_MOB_TYPES)) {
text += GRAY + " - " + AQUA + s + "\n";
for (int i = 0; i < types.size(); i++) {
QuestMob qm = QuestMob.fromString(types.get(i));
text += GOLD + " " + (i + 1) + " - Edit: " + AQUA + qm.getType().getName() + ((qm.getName() != null) ? ": " + qm.getName() : "") + GRAY + " x " + DARKAQUA + qm.getSpawnAmounts() + GRAY + " -> " + GREEN + Quests.getLocationInfo(qm.getSpawnLocation()) + "\n";
}
if (context.getSessionData(CK.E_MOB_AMOUNTS) == null) {
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobAmounts") + " (" + Lang.get("noneSet") + ")\n";
text += GRAY + "3 - " + Lang.get("eventEditorAddSpawnLocation") + Lang.get("eventEditorNoAmountsSet") + "\n";
} else {
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobAmounts") + "\n";
for (int i : (LinkedList<Integer>) context.getSessionData(CK.E_MOB_AMOUNTS)) {
text += GRAY + " - " + DARKAQUA + i + "\n";
}
if (context.getSessionData(CK.E_MOB_LOCATIONS) == null) {
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("eventEditorAddSpawnLocation") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("eventEditorAddSpawnLocation") + "\n";
for (String s : (LinkedList<String>) context.getSessionData(CK.E_MOB_LOCATIONS)) {
text += GRAY + " - " + GREEN + s + "\n";
}
}
}
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("clear") + "\n";
text += GREEN + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("done");
text += BLUE + "" + BOLD + (types.size() + 1) + RESET + YELLOW + " - " + Lang.get("eventEditorAddMobTypes") + "\n";
text += BLUE + "" + BOLD + (types.size() + 2) + RESET + YELLOW + " - " + Lang.get("clear") + "\n";
text += GREEN + "" + BOLD + (types.size() + 3) + RESET + YELLOW + " - " + Lang.get("done");
}
@ -1913,78 +1907,223 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
}
@Override
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1")) {
return new MobTypesPrompt();
} else if (input.equalsIgnoreCase("2")) {
if (context.getSessionData(CK.E_MOB_TYPES) == null) {
context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorMustSetMobTypesFirst"));
if (context.getSessionData(CK.E_MOB_TYPES) == null) {
if (input.equalsIgnoreCase("1")) {
return new QuestMobPrompt(0, null);
} else if (input.equalsIgnoreCase("2")) {
context.getForWhom().sendRawMessage(YELLOW + Lang.get("eventEditorMobSpawnsCleared"));
context.setSessionData(CK.E_MOB_TYPES, null);
return new MobPrompt();
} else {
return new MobAmountsPrompt();
}
} else if (input.equalsIgnoreCase("3")) {
if (context.getSessionData(CK.E_MOB_TYPES) == null) {
context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorMustSetMobTypesAndAmountsFirst"));
return new MobPrompt();
} else if (context.getSessionData(CK.E_MOB_AMOUNTS) == null) {
context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorMustSetMobAmountsFirst"));
return new MobPrompt();
} else {
selectedMobLocations.put((Player) context.getForWhom(), null);
return new MobLocationPrompt();
}
} else if (input.equalsIgnoreCase("4")) {
context.getForWhom().sendRawMessage(YELLOW + Lang.get("eventEditorMobSpawnsCleared"));
context.setSessionData(CK.E_MOB_TYPES, null);
context.setSessionData(CK.E_MOB_AMOUNTS, null);
context.setSessionData(CK.E_MOB_LOCATIONS, null);
return new MobPrompt();
} else if (input.equalsIgnoreCase("5")) {
} else if (input.equalsIgnoreCase("3")) {
return new CreateMenuPrompt();
}
} else {
LinkedList<String> types = (LinkedList<String>) context.getSessionData(CK.E_MOB_TYPES);
int inp = -1;
try {
inp = Integer.parseInt(input);
} catch (Exception e) {
context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorNotANumber"));
return new MobPrompt();
}
int one;
int two;
int three;
if (inp == types.size() + 1) {
return new QuestMobPrompt(inp - 1, null);
} else if (inp == types.size() + 2) {
context.getForWhom().sendRawMessage(YELLOW + Lang.get("eventEditorMobSpawnsCleared"));
context.setSessionData(CK.E_MOB_TYPES, null);
return new MobPrompt();
} else if (inp == types.size() + 3) {
return new CreateMenuPrompt();
} else if (inp > types.size()){
return new MobPrompt();
} else {
return new QuestMobPrompt(inp - 1, QuestMob.fromString(types.get(inp - 1)));
}
}
if (context.getSessionData(CK.E_MOB_TYPES) != null) {
one = ((List<String>) context.getSessionData(CK.E_MOB_TYPES)).size();
} else {
one = 0;
return new MobPrompt();
}
}
private class QuestMobPrompt extends StringPrompt {
private QuestMob questMob;
private Integer itemIndex = -1;
private Integer mobIndex;
public QuestMobPrompt(int mobIndex, QuestMob questMob) {
this.questMob = questMob;
this.mobIndex = mobIndex;
}
@Override
public String getPromptText(ConversationContext context) {
String text = GOLD + "- " + Lang.get("eventEditorAddMobTypes") + " - \n";
if (questMob == null) {
questMob = new QuestMob();
}
// Check/add newly made item
if(context.getSessionData("newItem") != null){
if(itemIndex >= 0){
questMob.inventory[itemIndex] = ((ItemStack) context.getSessionData("tempStack"));
itemIndex = -1;
}
if (context.getSessionData(CK.E_MOB_AMOUNTS) != null) {
two = ((List<Integer>) context.getSessionData(CK.E_MOB_AMOUNTS)).size();
} else {
two = 0;
}
if (context.getSessionData(CK.E_MOB_LOCATIONS) != null) {
three = ((List<String>) context.getSessionData(CK.E_MOB_LOCATIONS)).size();
} else {
three = 0;
}
if (one == two && two == three) {
return new CreateMenuPrompt();
} else {
context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorListSizeMismatch"));
return new MobPrompt();
}
context.setSessionData("newItem", null);
context.setSessionData("tempStack", null);
}
return null;
text += BLUE + "" + BOLD + "1" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobName") + GRAY + " (" + ((questMob.getName() == null) ? Lang.get("noneSet") : AQUA + questMob.getName()) + ")\n";
text += BLUE + "" + BOLD + "2" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobType") + GRAY + " (" + ((questMob.getType() == null) ? Lang.get("eventEditorNoTypesSet") : AQUA + questMob.getType().getName()) + GRAY + ")\n";
text += BLUE + "" + BOLD + "3" + RESET + YELLOW + " - " + Lang.get("eventEditorAddSpawnLocation") + GRAY + " (" + ((questMob.getSpawnLocation() == null) ? GRAY + Lang.get("noneSet") : AQUA + Quests.getLocationInfo(questMob.getSpawnLocation()) ) + GRAY + ")\n";
text += BLUE + "" + BOLD + "4" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobSpawnAmount") + GRAY +" (" + ((questMob.getSpawnAmounts() == null) ? GRAY + Lang.get("eventEditorNoAmountsSet") : AQUA + "" + questMob.getSpawnAmounts()) + GRAY + ")\n";
text += BLUE + "" + BOLD + "5" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobItemInHand") + GRAY +" (" + ((questMob.inventory[0] == null) ? GRAY + Lang.get("noneSet") : AQUA + ItemUtil.getDisplayString(questMob.inventory[0])) + GRAY + ")\n";
text += BLUE + "" + BOLD + "6" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobItemInHandDrop") + GRAY + " (" + ((questMob.dropChances[0] == null) ? GRAY + Lang.get("noneSet") : AQUA + "" + questMob.dropChances[0]) + GRAY + ")\n";
text += BLUE + "" + BOLD + "7" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobBoots") + GRAY + " (" + ((questMob.inventory[1] == null) ? GRAY + Lang.get("noneSet") : AQUA + ItemUtil.getDisplayString(questMob.inventory[1])) + GRAY + ")\n";
text += BLUE + "" + BOLD + "8" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobBootsDrop") + GRAY + " (" + ((questMob.dropChances[1] == null) ? GRAY + Lang.get("noneSet") : AQUA + "" + questMob.dropChances[1]) + GRAY + ")\n";
text += BLUE + "" + BOLD + "9" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobLeggings") + GRAY + " (" + ((questMob.inventory[2] == null) ? GRAY + Lang.get("noneSet") : AQUA + ItemUtil.getDisplayString(questMob.inventory[2])) + GRAY + ")\n";
text += BLUE + "" + BOLD + "10" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobLeggingsDrop") + GRAY + " (" + ((questMob.dropChances[2] == null) ? GRAY + Lang.get("noneSet") : AQUA + "" + questMob.dropChances[2]) + GRAY + ")\n";
text += BLUE + "" + BOLD + "11" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobChestPlate") + GRAY + " (" + ((questMob.inventory[3] == null) ? GRAY + Lang.get("noneSet") : AQUA + ItemUtil.getDisplayString(questMob.inventory[3])) + GRAY + ")\n";
text += BLUE + "" + BOLD + "12" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobChestPlateDrop") + GRAY + " (" + ((questMob.dropChances[3] == null) ? GRAY + Lang.get("noneSet") : AQUA + "" + questMob.dropChances[3]) + GRAY + ")\n";
text += BLUE + "" + BOLD + "13" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobHelmet") + GRAY + " (" + ((questMob.inventory[4] == null) ? GRAY + Lang.get("noneSet") : AQUA + ItemUtil.getDisplayString(questMob.inventory[4])) + GRAY + ")\n";
text += BLUE + "" + BOLD + "14" + RESET + YELLOW + " - " + Lang.get("eventEditorSetMobHelmetDrop") + GRAY + " (" + ((questMob.dropChances[4] == null) ? GRAY + Lang.get("noneSet") : AQUA + "" + questMob.dropChances[4]) + GRAY + ")\n";
text += GREEN + "" + BOLD + "15" + RESET + YELLOW + " - " + Lang.get("done") + "\n";
text += RED + "" + BOLD + "16" + RESET + YELLOW + " - " + Lang.get("cancel");
return text;
}
@SuppressWarnings("unchecked")
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1")) {
return new MobNamePrompt(mobIndex, questMob);
} else if (input.equalsIgnoreCase("2")) {
return new MobTypePrompt(mobIndex, questMob);
} else if (input.equalsIgnoreCase("3")) {
selectedMobLocations.put((Player) context.getForWhom(), null);
return new MobLocationPrompt(mobIndex, questMob);
} else if (input.equalsIgnoreCase("4")) {
return new MobAmountPrompt(mobIndex, questMob);
} else if (input.equalsIgnoreCase("5")) {
itemIndex = 0;
return new ItemStackPrompt(QuestMobPrompt.this);
} else if (input.equalsIgnoreCase("6")) {
return new MobDropPrompt(0, mobIndex, questMob);
} else if (input.equalsIgnoreCase("7")) {
itemIndex = 1;
return new ItemStackPrompt(QuestMobPrompt.this);
} else if (input.equalsIgnoreCase("8")) {
return new MobDropPrompt(1, mobIndex, questMob);
} else if (input.equalsIgnoreCase("9")) {
itemIndex = 2;
return new ItemStackPrompt(QuestMobPrompt.this);
} else if (input.equalsIgnoreCase("10")) {
return new MobDropPrompt(2, mobIndex, questMob);
} else if (input.equalsIgnoreCase("11")) {
itemIndex = 3;
return new ItemStackPrompt(QuestMobPrompt.this);
} else if (input.equalsIgnoreCase("12")) {
return new MobDropPrompt(3, mobIndex, questMob);
} else if (input.equalsIgnoreCase("13")) {
itemIndex = 4;
return new ItemStackPrompt(QuestMobPrompt.this);
} else if (input.equalsIgnoreCase("14")) {
return new MobDropPrompt(4, mobIndex, questMob);
} else if (input.equalsIgnoreCase("15")) {
if (questMob.getType() == null) {
context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorMustSetMobTypesFirst"));
return new QuestMobPrompt(mobIndex, questMob);
} else if (questMob.getSpawnLocation() == null) {
context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorMustSetMobLocationFirst"));
return new QuestMobPrompt(mobIndex, questMob);
} else if (questMob.getSpawnAmounts() == null) {
context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorMustSetMobAmountsFirst"));
return new QuestMobPrompt(mobIndex, questMob);
}
if (context.getSessionData(CK.E_MOB_TYPES) == null) {
LinkedList<String> list = new LinkedList<String>();
list.add(questMob.serialize());
context.setSessionData(CK.E_MOB_TYPES, list);
} else {
if (((LinkedList<String>) context.getSessionData(CK.E_MOB_TYPES)).isEmpty()) {
LinkedList<String> list = new LinkedList<String>();
list.add(questMob.serialize());
context.setSessionData(CK.E_MOB_TYPES, list);
} else {
LinkedList<String> list = (LinkedList<String>) context.getSessionData(CK.E_MOB_TYPES);
list.set(mobIndex, questMob.serialize());
context.setSessionData(CK.E_MOB_TYPES, list);
}
}
return new MobPrompt();
} else if (input.equalsIgnoreCase("16")) {
return new MobPrompt();
} else {
return new QuestMobPrompt(mobIndex, questMob);
}
}
}
private class MobTypesPrompt extends StringPrompt {
private class MobNamePrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext context) {
private QuestMob questMob;
private Integer mobIndex;
String mobs = PINK + "- " + Lang.get("mobs") + " - \n";
public MobNamePrompt (int mobIndex, QuestMob questMob) {
this.questMob = questMob;
this.mobIndex = mobIndex;
}
@Override
public String getPromptText(ConversationContext context) {
String text = YELLOW + Lang.get("eventEditorSetMobNamePrompt");
return text;
}
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
return new QuestMobPrompt(mobIndex, questMob);
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
questMob.setName(null);
return new QuestMobPrompt(mobIndex, questMob);
} else {
input = ChatColor.translateAlternateColorCodes('&', input);
questMob.setName(input);
return new QuestMobPrompt(mobIndex, questMob);
}
}
}
private class MobTypePrompt extends StringPrompt {
private QuestMob questMob;
private Integer mobIndex;
public MobTypePrompt (int mobIndex, QuestMob questMob) {
this.questMob = questMob;
this.mobIndex = mobIndex;
}
@Override
public String getPromptText(ConversationContext arg0) {
String mobs = PINK + "- " + Lang.get("mobs") + " - \n";
mobs += PURPLE + "Bat, ";
mobs += PURPLE + "Blaze, ";
mobs += PURPLE + "CaveSpider, ";
@ -2015,39 +2154,37 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
mobs += PURPLE + "Zombie\n";
return mobs + YELLOW + Lang.get("eventEditorSetMobTypesPrompt");
}
}
@Override
public Prompt acceptInput(ConversationContext context, String input) {
Player player = (Player) context.getForWhom();
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
Player player = (Player) context.getForWhom();
if (Quests.getMobType(input) != null) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
questMob.setType(Quests.getMobType(input));
LinkedList<String> mobTypes = new LinkedList<String>();
for (String s : input.split(" ")) {
} else {
player.sendMessage(PINK + input + " " + RED + Lang.get("eventEditorInvalidMob"));
return new MobTypePrompt(mobIndex, questMob);
}
}
if (Quests.getMobType(s) != null) {
mobTypes.add(Quester.prettyMobString(Quests.getMobType(s)));
context.setSessionData(CK.E_MOB_TYPES, mobTypes);
} else {
player.sendMessage(PINK + s + " " + RED + Lang.get("eventEditorInvalidMob"));
return new MobTypesPrompt();
}
}
}
return new MobPrompt();
}
return new QuestMobPrompt(mobIndex, questMob);
}
}
private class MobAmountsPrompt extends StringPrompt {
private class MobAmountPrompt extends StringPrompt {
private QuestMob questMob;
private Integer mobIndex;
public MobAmountPrompt (int mobIndex, QuestMob questMob) {
this.questMob = questMob;
this.mobIndex = mobIndex;
}
@Override
public String getPromptText(ConversationContext context) {
@ -2063,43 +2200,43 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
LinkedList<Integer> mobAmounts = new LinkedList<Integer>();
for (String s : input.split(" ")) {
try {
int i = Integer.parseInt(s);
int i = Integer.parseInt(input);
if (i < 1) {
player.sendMessage(PINK + input + " " + RED + Lang.get("eventEditorNotGreaterThanZero"));
return new MobAmountsPrompt();
return new MobAmountPrompt(mobIndex, questMob);
}
mobAmounts.add(i);
questMob.setSpawnAmounts(i);
return new QuestMobPrompt(mobIndex, questMob);
} catch (Exception e) {
player.sendMessage(PINK + input + " " + RED + Lang.get("eventEditorNotANumber"));
return new MobAmountsPrompt();
return new MobAmountPrompt(mobIndex, questMob);
}
}
context.setSessionData(CK.E_MOB_AMOUNTS, mobAmounts);
}
return new MobPrompt();
return new QuestMobPrompt(mobIndex, questMob);
}
}
private class MobLocationPrompt extends StringPrompt {
private QuestMob questMob;
private Integer mobIndex;
public MobLocationPrompt (int mobIndex, QuestMob questMob) {
this.questMob = questMob;
this.mobIndex = mobIndex;
}
@Override
public String getPromptText(ConversationContext context) {
return YELLOW + Lang.get("eventEditorMobLocationPrompt");
return YELLOW + Lang.get("eventEditorSetMobLocationPrompt");
}
@ -2115,36 +2252,71 @@ public class EventFactory implements ConversationAbandonedListener, ColorUtil{
Location loc = block.getLocation();
LinkedList<String> locs;
if (context.getSessionData(CK.E_MOB_LOCATIONS) != null) {
locs = (LinkedList<String>) context.getSessionData(CK.E_MOB_LOCATIONS);
} else {
locs = new LinkedList<String>();
}
locs.add(Quests.getLocationInfo(loc));
context.setSessionData(CK.E_MOB_LOCATIONS, locs);
questMob.setSpawnLocation(loc);
selectedMobLocations.remove(player);
} else {
player.sendMessage(RED + Lang.get("eventEditorSelectBlockFirst"));
return new MobLocationPrompt();
return new MobLocationPrompt(mobIndex, questMob);
}
return new MobPrompt();
return new QuestMobPrompt(mobIndex, questMob);
} else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
selectedMobLocations.remove(player);
return new MobPrompt();
return new QuestMobPrompt(mobIndex, questMob);
} else {
return new MobLocationPrompt();
return new MobLocationPrompt(mobIndex, questMob);
}
}
}
private class MobDropPrompt extends StringPrompt {
private QuestMob questMob;
private Integer mobIndex;
private Integer invIndex;
public MobDropPrompt (int invIndex, int mobIndex ,QuestMob questMob) {
this.questMob = questMob;
this.mobIndex = mobIndex;
this.invIndex = invIndex;
}
@Override
public String getPromptText(ConversationContext context) {
String text = YELLOW + Lang.get("eventEditorSetDropChance");
return text;
}
@Override
public Prompt acceptInput(ConversationContext context, String input) {
float chance = 0.0F;
if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
return new QuestMobPrompt(mobIndex, questMob);
}
try {
chance = Float.parseFloat(input);
} catch (Exception e) {
context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorInvalidDropChance"));
return new MobDropPrompt(invIndex, mobIndex, questMob);
}
if (chance > 1 || chance < 0) {
context.getForWhom().sendRawMessage(RED + Lang.get("eventEditorInvalidDropChance"));
return new MobDropPrompt(invIndex, mobIndex, questMob);
}
questMob.dropChances[invIndex] = chance;
return new QuestMobPrompt(mobIndex, questMob);
}
}
private class LightningPrompt extends StringPrompt {
@Override

View File

@ -1,19 +1,19 @@
package me.blackvein.quests;
import com.gmail.nossr50.api.ExperienceAPI;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.util.player.UserManager;
import java.util.LinkedList;
import java.util.List;
import me.blackvein.quests.util.ItemUtil;
import net.citizensnpcs.api.npc.NPC;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import com.gmail.nossr50.util.player.UserManager;
public class Quest {
public String name;

View File

@ -570,7 +570,7 @@ public class RewardsPrompt extends FixedSetPrompt implements ColorUtil{
String skillList =
GOLD + "-Skill List-\n" +
AQUA + "Acrobatics\n" +
AQUA + "All\n" +
GRAY + "All\n" +
AQUA + "Archery\n" +
AQUA + "Axes\n" +
AQUA + "Excavation\n" +

View File

@ -93,8 +93,6 @@ public class CK {
public static final String E_WORLD_THUNDER = "evtThunderWorld";
public static final String E_WORLD_THUNDER_DURATION = "evtThunderDuration";
public static final String E_MOB_TYPES = "evtMobTypes";
public static final String E_MOB_AMOUNTS = "evtMobAmounts";
public static final String E_MOB_LOCATIONS = "evtMobLocations";
public static final String E_LIGHTNING = "evtLightningStrikes";
public static final String E_POTION_TYPES = "evtPotionTypes";
public static final String E_POTION_DURATIONS = "evtPotionDurations";

View File

@ -70,6 +70,7 @@ public class ItemUtil implements ColorUtil{
//
public static ItemStack readItemStack(String data){
if (data == null) return null;
ItemStack stack = null;
String[] args = data.split(":");
ItemMeta meta = null;
@ -108,6 +109,8 @@ public class ItemUtil implements ColorUtil{
String serial;
if (is == null) return null;
serial = "id-" + is.getTypeId();
serial += ":amount-" + is.getAmount();
if(is.getDurability() != 0)

View File

@ -12,336 +12,354 @@ import org.bukkit.configuration.file.YamlConfiguration;
public class Lang {
public static String lang = "en";
public static String lang = "en";
private static Map<String, String> en = new LinkedHashMap<String, String>();
private static Map<String, String> en = new LinkedHashMap<String, String>();
private Quests plugin;
public Lang (Quests plugin) {
this.plugin = plugin;
}
public Lang (Quests plugin) {
this.plugin = plugin;
}
public static String get(String key){
return en.get(key);
}
public static String get(String key){
return en.get(key);
}
public void initPhrases(){
public void initPhrases(){
//English
//TODO: If finished, completely check everything.
//Quests
//Quest create menu
en.put("questEditorHeader", "Create Quest");
en.put("questEditorCreate", "Create new Quest");
en.put("questEditorEdit", "Edit a Quest");
en.put("questEditorDelete", "Delete Quest");
en.put("questEditorName", "Set name");
//English
//TODO: If finished, completely check everything.
//Quests
//Quest create menu
en.put("questEditorHeader", "Create Quest");
en.put("questEditorCreate", "Create new Quest");
en.put("questEditorEdit", "Edit a Quest");
en.put("questEditorDelete", "Delete Quest");
en.put("questEditorName", "Set name");
en.put("questEditorAskMessage", "Set ask message");
en.put("questEditorFinishMessage", "Set finish message");
en.put("questEditorRedoDelay", "Set redo delay");
en.put("questEditorNPCStart", "Set NPC start");
en.put("questEditorBlockStart", "Set Block start");
en.put("questEditorInitialEvent", "Set initial Event");
en.put("questEditorReqs", "Edit Requirements");
en.put("questEditorStages", "Edit Stages");
en.put("questEditorRews", "Edit Rewards");
en.put("questEditorAskMessage", "Set ask message");
en.put("questEditorFinishMessage", "Set finish message");
en.put("questEditorRedoDelay", "Set redo delay");
en.put("questEditorNPCStart", "Set NPC start");
en.put("questEditorBlockStart", "Set Block start");
en.put("questEditorInitialEvent", "Set initial Event");
en.put("questEditorReqs", "Edit Requirements");
en.put("questEditorStages", "Edit Stages");
en.put("questEditorRews", "Edit Rewards");
en.put("questEditorEnterQuestName", "Enter Quest name (or \"cancel\" to return)");
en.put("questEditorEnterAskMessage", "Enter ask message (or \"cancel\" to return)");
en.put("questEditorEnterFinishMessage", "Enter finish message (or \"cancel\" to return)");
en.put("questEditorEnterRedoDelay", "Enter amount of time (in milliseconds), 0 to clear the redo delay or -1 to cancel ");
en.put("questEditorEnterNPCStart", "Enter NPC ID, -1 to clear the NPC start or -2 to cancel");
en.put("questEditorEnterBlockStart", "Right-click on a block to use as a start point, then enter \"done\" to save,\n"
+ "or enter \"clear\" to clear the block start, or \"cancel\" to return");
en.put("questEditorEnterInitialEvent", "Enter an Event name, or enter \"clear\" to clear the initial Event, or \"cancel\" to return");
en.put("questEditorEnterQuestName", "Enter Quest name (or \"cancel\" to return)");
en.put("questEditorEnterAskMessage", "Enter ask message (or \"cancel\" to return)");
en.put("questEditorEnterFinishMessage", "Enter finish message (or \"cancel\" to return)");
en.put("questEditorEnterRedoDelay", "Enter amount of time (in milliseconds), 0 to clear the redo delay or -1 to cancel ");
en.put("questEditorEnterNPCStart", "Enter NPC ID, -1 to clear the NPC start or -2 to cancel");
en.put("questEditorEnterBlockStart", "Right-click on a block to use as a start point, then enter \"done\" to save,\n"
+ "or enter \"clear\" to clear the block start, or \"cancel\" to return");
en.put("questEditorEnterInitialEvent", "Enter an Event name, or enter \"clear\" to clear the initial Event, or \"cancel\" to return");
//Quest create menu errors
en.put("questEditorNameExists", "A Quest with that name already exists!");
en.put("questEditorBeingEdited", "Someone is creating/editing a Quest with that name!");
en.put("questEditorInvalidQuestName", "Name may not contain commas!");
en.put("questEditorInvalidEventName", "is not a valid event name!");
en.put("questEditorInvalidNPC", "No NPC exists with that id!");
en.put("questEditorNoStartBlockSelected", "You must select a block first.");
en.put("questEditorPositiveAmount", "Amount must be a positive number.");
en.put("questEditorQuestAsRequirement1", "The following Quests have");
en.put("questEditorQuestAsRequirement2", "as a requirement:");
en.put("questEditorQuestAsRequirement3", "You must modify these Quests so that they do not use it before deleting it.");
en.put("questEditorQuestNotFound", "Quest not found!");
//Quest create menu errors
en.put("questEditorNameExists", "A Quest with that name already exists!");
en.put("questEditorBeingEdited", "Someone is creating/editing a Quest with that name!");
en.put("questEditorInvalidQuestName", "Name may not contain commas!");
en.put("questEditorInvalidEventName", "is not a valid event name!");
en.put("questEditorInvalidNPC", "No NPC exists with that id!");
en.put("questEditorNoStartBlockSelected", "You must select a block first.");
en.put("questEditorPositiveAmount", "Amount must be a positive number.");
en.put("questEditorQuestAsRequirement1", "The following Quests have");
en.put("questEditorQuestAsRequirement2", "as a requirement:");
en.put("questEditorQuestAsRequirement3", "You must modify these Quests so that they do not use it before deleting it.");
en.put("questEditorQuestNotFound", "Quest not found!");
en.put("questEditorEventCleared", "Initial Event cleared.");
en.put("questEditorSave", "Finish and save");
en.put("questEditorEventCleared", "Initial Event cleared.");
en.put("questEditorSave", "Finish and save");
en.put("questEditorNeedAskMessage", "You must set an ask message!");
en.put("questEditorNeedFinishMessage", "You must set a finish message!");
en.put("questEditorNeedStages", "Your Quest has no Stages!");
en.put("questEditorSaved", "Quest saved! (You will need to perform a Quest reload for it to appear)");
en.put("questEditorExited", "Are you sure you want to exit without saving?");
en.put("questEditorDeleted", "Are you sure you want to delete the Quest");
en.put("questEditorNeedAskMessage", "You must set an ask message!");
en.put("questEditorNeedFinishMessage", "You must set a finish message!");
en.put("questEditorNeedStages", "Your Quest has no Stages!");
en.put("questEditorSaved", "Quest saved! (You will need to perform a Quest reload for it to appear)");
en.put("questEditorExited", "Are you sure you want to exit without saving?");
en.put("questEditorDeleted", "Are you sure you want to delete the Quest");
en.put("questEditorNoPermsCreate", "You do not have permission to create Quests.");
en.put("questEditorNoPermsEdit", "You do not have permission to edit Quests.");
en.put("questEditorNoPermsDelete", "You do not have permission to delete Quests.");
//
en.put("questEditorNoPermsCreate", "You do not have permission to create Quests.");
en.put("questEditorNoPermsEdit", "You do not have permission to edit Quests.");
en.put("questEditorNoPermsDelete", "You do not have permission to delete Quests.");
//
//Stages
//Menu
en.put("stageEditorEditStage", "Edit Stage");
en.put("stageEditorNewStage", "Add new Stage");
//create prompt
en.put("stageEditorStages", "Stages");
en.put("stageEditorStage", "Stage");
en.put("stageEditorEditStage", "Edit Stage");
en.put("stageEditorNewStage", "Add new Stage");
en.put("stageEditorBreakBlocks", "Break Blocks");
en.put("stageEditorDamageBlocks", "Damage Blocks");
en.put("stageEditorPlaceBlocks", "Place Blocks");
en.put("stageEditorUseBlocks", "Use Blocks");
en.put("stageEditorCutBlocks", "Cut Blocks");
en.put("stageEditorCatchFish", "Catch Fish");
en.put("stageEditorFish", "fish");
en.put("stageEditorKillPlayers", "Kill Players");
en.put("stageEditorPlayers", "players");
en.put("stageEditorEnchantItems", "Enchant Items");
en.put("stageEditorDeliverItems", "Deliver Items");
en.put("stageEditorTalkToNPCs", "Talk to NPCs");
en.put("stageEditorKillNPCs", "Kill NPCs");
en.put("stageEditorKillBosses", "Kill Bosses");
en.put("stageEditorKillMobs", "Kill Mobs");
en.put("stageEditorReachLocs", "");
en.put("stageEditorReachRadii1", "Reach within");
en.put("stageEditorReachRadii2", "blocks of");
en.put("stageEditorTameMobs", "Tame Mobs");
en.put("stageEditorShearSheep", "Shear Sheep");
en.put("stageEditorDelayMessage", "Delay Message");
en.put("stageEditorDenizenScript", "Denizen Script");
en.put("stageEditorStartMessage", "Start Message");
en.put("stageEditorCompleteMessage", "Complete Message");
en.put("stageEditorDelete", "Delete Stage");
//Stages
//Menu
en.put("stageEditorEditStage", "Edit Stage");
en.put("stageEditorNewStage", "Add new Stage");
//create prompt
en.put("stageEditorStages", "Stages");
en.put("stageEditorStage", "Stage");
en.put("stageEditorEditStage", "Edit Stage");
en.put("stageEditorNewStage", "Add new Stage");
en.put("stageEditorBreakBlocks", "Break Blocks");
en.put("stageEditorDamageBlocks", "Damage Blocks");
en.put("stageEditorPlaceBlocks", "Place Blocks");
en.put("stageEditorUseBlocks", "Use Blocks");
en.put("stageEditorCutBlocks", "Cut Blocks");
en.put("stageEditorCatchFish", "Catch Fish");
en.put("stageEditorFish", "fish");
en.put("stageEditorKillPlayers", "Kill Players");
en.put("stageEditorPlayers", "players");
en.put("stageEditorEnchantItems", "Enchant Items");
en.put("stageEditorDeliverItems", "Deliver Items");
en.put("stageEditorTalkToNPCs", "Talk to NPCs");
en.put("stageEditorKillNPCs", "Kill NPCs");
en.put("stageEditorKillBosses", "Kill Bosses");
en.put("stageEditorKillMobs", "Kill Mobs");
en.put("stageEditorReachLocs", "");
en.put("stageEditorReachRadii1", "Reach within");
en.put("stageEditorReachRadii2", "blocks of");
en.put("stageEditorTameMobs", "Tame Mobs");
en.put("stageEditorShearSheep", "Shear Sheep");
en.put("stageEditorDelayMessage", "Delay Message");
en.put("stageEditorDenizenScript", "Denizen Script");
en.put("stageEditorStartMessage", "Start Message");
en.put("stageEditorCompleteMessage", "Complete Message");
en.put("stageEditorDelete", "Delete Stage");
en.put("stageEditorSetBlockIds", "Set block IDs");
en.put("stageEditorSetBlockAmounts", "Set block amounts");
en.put("stageEditorNoBlockIds", "You must set Block IDs first!");
en.put("stageEditorBreakBlocksCleared", "Break blocks objective cleared.");
en.put("stageEditorInvalidIdAmountList", "The block IDs list block amounts list are not the same size!");
en.put("stageEditorEnterBlockIds", "Enter block IDs, separating each one by a space, or enter \'cancel\' to return.");
en.put("stageEditorContainsDuplicates", "List contains duplicates!");
en.put("stageEditorInvalidBlockId", "is not a valid block ID!");
en.put("stageEditorInvalidEntryInt", "Invalid entry, input was not a list of numbers!");
en.put("stageEditorSetBlockIds", "Set block IDs");
en.put("stageEditorSetBlockAmounts", "Set block amounts");
en.put("stageEditorNoBlockIds", "You must set Block IDs first!");
en.put("stageEditorBreakBlocksCleared", "Break blocks objective cleared.");
en.put("stageEditorInvalidIdAmountList", "The block IDs list block amounts list are not the same size!");
en.put("stageEditorEnterBlockIds", "Enter block IDs, separating each one by a space, or enter \'cancel\' to return.");
en.put("stageEditorContainsDuplicates", "List contains duplicates!");
en.put("stageEditorInvalidBlockId", "is not a valid block ID!");
en.put("stageEditorInvalidEntryInt", "Invalid entry, input was not a list of numbers!");
//prompts
//prompts
//Events
en.put("eventEditorTitle", "Event Editor");
en.put("eventEditorCreate", "Create new Event");
en.put("eventEditorEdit", "Edit an Event");
en.put("eventEditorDelete", "Delete an Event");
//Events
en.put("eventEditorTitle", "Event Editor");
en.put("eventEditorCreate", "Create new Event");
en.put("eventEditorEdit", "Edit an Event");
en.put("eventEditorDelete", "Delete an Event");
en.put("eventEditorNoneToEdit", "No Events currently exist to be edited!");
en.put("eventEditorNoneToDelete", "No Events currently exist to be deleted!");
en.put("eventEditorNotFound", "Event not found!");
en.put("eventEditorExists", "Event already exists!");
en.put("eventEditorSomeone", "Someone is already creating or editing an Event with that name!");
en.put("eventEditorAlpha", "Name must be alphanumeric!");
en.put("eventEditorNoneToEdit", "No Events currently exist to be edited!");
en.put("eventEditorNoneToDelete", "No Events currently exist to be deleted!");
en.put("eventEditorNotFound", "Event not found!");
en.put("eventEditorExists", "Event already exists!");
en.put("eventEditorSomeone", "Someone is already creating or editing an Event with that name!");
en.put("eventEditorAlpha", "Name must be alphanumeric!");
en.put("eventEditorErrorReadingFile", "Error reading Events file.");
en.put("eventEditorErrorSaving", "An error occurred while saving.");
en.put("eventEditorDeleted", "Event deleted, Quests and Events reloaded.");
en.put("eventEditorSaved", "Event saved, Quests and Events reloaded.");
en.put("eventEditorErrorReadingFile", "Error reading Events file.");
en.put("eventEditorErrorSaving", "An error occurred while saving.");
en.put("eventEditorDeleted", "Event deleted, Quests and Events reloaded.");
en.put("eventEditorSaved", "Event saved, Quests and Events reloaded.");
en.put("eventEditorEnterEventName", "Enter an Event name, or \"cancel\" to return.");
en.put("eventEditorDeletePrompt", "Are you sure you want to delete the Event");
en.put("eventEditorQuitWithoutSaving", "Are you sure you want to quit without saving?");
en.put("eventEditorFinishAndSave", "Are you sure you want to finish and save the Event");
en.put("eventEditorModifiedNote", "Note: You have modified an Event that the following Quests use:");
en.put("eventEditorForcedToQuit", "If you save the Event, anyone who is actively doing any of these Quests will be forced to quit them.");
en.put("eventEditorEnterEventName", "Enter an Event name, or \"cancel\" to return.");
en.put("eventEditorDeletePrompt", "Are you sure you want to delete the Event");
en.put("eventEditorQuitWithoutSaving", "Are you sure you want to quit without saving?");
en.put("eventEditorFinishAndSave", "Are you sure you want to finish and save the Event");
en.put("eventEditorModifiedNote", "Note: You have modified an Event that the following Quests use:");
en.put("eventEditorForcedToQuit", "If you save the Event, anyone who is actively doing any of these Quests will be forced to quit them.");
en.put("eventEditorEventInUse", "The following Quests use the Event");
en.put("eventEditorMustModifyQuests", "eventEditorNotFound");
en.put("eventEditorListSizeMismatch", "The lists are not the same size!");
en.put("eventEditorListDuplicates", "List contains duplicates!");
en.put("eventEditorNotANumberList", "Input was not a list of numbers!");
en.put("eventEditorInvalidEntry", "Invalid entry");
en.put("eventEditorEventInUse", "The following Quests use the Event");
en.put("eventEditorMustModifyQuests", "eventEditorNotFound");
en.put("eventEditorListSizeMismatch", "The lists are not the same size!");
en.put("eventEditorListDuplicates", "List contains duplicates!");
en.put("eventEditorNotANumberList", "Input was not a list of numbers!");
en.put("eventEditorInvalidEntry", "Invalid entry");
en.put("eventEditorSetName", "Set name");
en.put("eventEditorSetMessage", "Set message");
en.put("eventEditorSetName", "Set name");
en.put("eventEditorSetMessage", "Set message");
en.put("eventEditorClearInv", "Clear player inventory");
en.put("eventEditorSetExplosions", "Set explosion locations");
en.put("eventEditorSetLightning", "Set lightning strike locations");
en.put("eventEditorSetEffects", "Set effects");
en.put("eventEditorSetStorm", "Set storm");
en.put("eventEditorSetThunder", "Set thunder");
en.put("eventEditorSetMobSpawns", "Set mob spawns");
en.put("eventEditorSetPotionEffects", "Set potion effects");
en.put("eventEditorSetHunger", "Set player hunger level");
en.put("eventEditorSetSaturation", "Set player saturation level");
en.put("eventEditorSetHealth", "Set player health level");
en.put("eventEditorSetTeleport", "Set player teleport location");
en.put("eventEditorSetCommands", "Set commands to execute");
en.put("eventEditorClearInv", "Clear player inventory");
en.put("eventEditorSetExplosions", "Set explosion locations");
en.put("eventEditorSetLightning", "Set lightning strike locations");
en.put("eventEditorSetEffects", "Set effects");
en.put("eventEditorSetStorm", "Set storm");
en.put("eventEditorSetThunder", "Set thunder");
en.put("eventEditorSetMobSpawns", "Set mob spawns");
en.put("eventEditorSetPotionEffects", "Set potion effects");
en.put("eventEditorSetHunger", "Set player hunger level");
en.put("eventEditorSetSaturation", "Set player saturation level");
en.put("eventEditorSetHealth", "Set player health level");
en.put("eventEditorSetTeleport", "Set player teleport location");
en.put("eventEditorSetCommands", "Set commands to execute");
en.put("eventEditorItems", "Event Items");
en.put("eventEditorSetItems", "Give items");
en.put("eventEditorItemsCleared", "Event items cleared.");
en.put("eventEditorSetItemIDs", "Set item IDs");
en.put("eventEditorSetItemAmounts", "Set item amounts");
en.put("eventEditorNoIDs", "No IDs set");
en.put("eventEditorMustSetIDs", "You must set item IDs first!");
en.put("eventEditorInvalidID", "___ is not a valid item ID!");
en.put("eventEditorNotGreaterThanZero", "___ is not greater than 0!");
en.put("eventEditorNotANumber", "___ is not a number!");
en.put("eventEditorItems", "Event Items");
en.put("eventEditorSetItems", "Give items");
en.put("eventEditorItemsCleared", "Event items cleared.");
en.put("eventEditorSetItemIDs", "Set item IDs");
en.put("eventEditorSetItemAmounts", "Set item amounts");
en.put("eventEditorNoIDs", "No IDs set");
en.put("eventEditorMustSetIDs", "You must set item IDs first!");
en.put("eventEditorInvalidID", "___ is not a valid item ID!");
en.put("eventEditorNotGreaterThanZero", "___ is not greater than 0!");
en.put("eventEditorNotANumber", "___ is not a number!");
en.put("eventEditorStorm", "Event Storm");
en.put("eventEditorSetWorld", "Set world");
en.put("eventEditorSetDuration", "Set duration");
en.put("eventEditorNoWorld", "(No world set)");
en.put("eventEditorSetWorldFirst", "You must set a world first!");
en.put("eventEditorInvalidWorld", "___ is not a valid world name!");
en.put("eventEditorMustSetStormDuration", "You must set a storm duration!");
en.put("eventEditorStormCleared", "Storm data cleared.");
en.put("eventEditorEnterStormWorld", "Enter a world name for the storm to occur in, or enter \"cancel\" to return");
en.put("eventEditorEnterDuration", "Enter duration (in milliseconds)");
en.put("eventEditorAtLeastOneSecond", "Amount must be at least 1 second! (1000 milliseconds)");
en.put("eventEditorNotGreaterThanOneSecond", "___ is not greater than 1 second! (1000 milliseconds)");
en.put("eventEditorStorm", "Event Storm");
en.put("eventEditorSetWorld", "Set world");
en.put("eventEditorSetDuration", "Set duration");
en.put("eventEditorNoWorld", "(No world set)");
en.put("eventEditorSetWorldFirst", "You must set a world first!");
en.put("eventEditorInvalidWorld", "___ is not a valid world name!");
en.put("eventEditorMustSetStormDuration", "You must set a storm duration!");
en.put("eventEditorStormCleared", "Storm data cleared.");
en.put("eventEditorEnterStormWorld", "Enter a world name for the storm to occur in, or enter \"cancel\" to return");
en.put("eventEditorEnterDuration", "Enter duration (in milliseconds)");
en.put("eventEditorAtLeastOneSecond", "Amount must be at least 1 second! (1000 milliseconds)");
en.put("eventEditorNotGreaterThanOneSecond", "___ is not greater than 1 second! (1000 milliseconds)");
en.put("eventEditorThunder", "Event Thunder");
en.put("eventEditorInvalidWorld", "___ is not a valid world name!");
en.put("eventEditorMustSetThunderDuration", "You must set a thunder duration!");
en.put("eventEditorThunderCleared", "Thunder data cleared.");
en.put("eventEditorEnterThunderWorld", "Enter a world name for the thunder to occur in, or enter \"cancel\" to return");
en.put("eventEditorThunder", "Event Thunder");
en.put("eventEditorInvalidWorld", "___ is not a valid world name!");
en.put("eventEditorMustSetThunderDuration", "You must set a thunder duration!");
en.put("eventEditorThunderCleared", "Thunder data cleared.");
en.put("eventEditorEnterThunderWorld", "Enter a world name for the thunder to occur in, or enter \"cancel\" to return");
en.put("eventEditorEffects", "Event Effects");
en.put("eventEditorAddEffect", "Add effect");
en.put("eventEditorAddEffectLocation", "Add effect location");
en.put("eventEditorNoEffects", "No effects set");
en.put("eventEditorMustAddEffects", "You must add effects first!");
en.put("eventEditorInvalidEffect", "___ is not a valid effect name!");
en.put("eventEditorEffectsCleared", "Event effects cleared.");
en.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");
en.put("eventEditorEffects", "Event Effects");
en.put("eventEditorAddEffect", "Add effect");
en.put("eventEditorAddEffectLocation", "Add effect location");
en.put("eventEditorNoEffects", "No effects set");
en.put("eventEditorMustAddEffects", "You must add effects first!");
en.put("eventEditorInvalidEffect", "___ is not a valid effect name!");
en.put("eventEditorEffectsCleared", "Event effects cleared.");
en.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");
en.put("eventEditorMobSpawns", "Event Mob Spawns");
en.put("eventEditorSetMobTypes", "Set mob types");
en.put("eventEditorNoTypesSet", "(No types set)");
en.put("eventEditorMustSetMobTypesFirst", "You must set mob types first!");
en.put("eventEditorSetMobAmounts", "Set mob amounts");
en.put("eventEditorNoAmountsSet", "(No amounts set)");
en.put("eventEditorMustSetMobAmountsFirst", "You must set mob amounts first!");
en.put("eventEditorMustSetMobTypesAndAmountsFirst", "You must set mob types and amounts first!");
en.put("eventEditorAddSpawnLocation", "Add spawn location");
en.put("eventEditorMobSpawnsCleared", "Mob spawns cleared.");
en.put("eventEditorInvalidMob", "___ is not a valid mob name!");
en.put("eventEditorMobSpawns", "Event Mob Spawns");
en.put("eventEditorAddMobTypes", "Add mob");
en.put("eventEditorNoTypesSet", "(No type set)");
en.put("eventEditorMustSetMobTypesFirst", "You must set the mob type first!");
en.put("eventEditorSetMobAmounts", "Set mob amount");
en.put("eventEditorNoAmountsSet", "(No amounts set)");
en.put("eventEditorMustSetMobAmountsFirst", "You must set mob amount first!");
en.put("eventEditorAddSpawnLocation", "Set spawn location");
en.put("eventEditorMobSpawnsCleared", "Mob spawns cleared.");
en.put("eventEditorMustSetMobLocationFirst", "You must set a spawn-location first!");
en.put("eventEditorInvalidMob", "___ is not a valid mob name!");
en.put("eventEditorSetMobName", "Set custom name for mob");
en.put("eventEditorSetMobType", "Set mob type");
en.put("eventEditorSetMobItemInHand", "Set item in hand");
en.put("eventEditorSetMobItemInHandDrop", "Set drop chance of item in hand");
en.put("eventEditorSetMobBoots", "Set boots");
en.put("eventEditorSetMobBootsDrop", "Set drop chance of boots");
en.put("eventEditorSetMobLeggings", "Set leggings");
en.put("eventEditorSetMobLeggingsDrop", "Set drop chance of leggings");
en.put("eventEditorSetMobChestPlate", "Set chest plate");
en.put("eventEditorSetMobChestPlateDrop", "Set drop chance of chest plate");
en.put("eventEditorSetMobHelmet", "Set helmet");
en.put("eventEditorSetMobHelmetDrop", "Set drop chance of helmet");
en.put("eventEditorSetMobSpawnLoc", "Right-click on a block to spawn a mob at, then enter \"add\" to the confirm it, or enter \"cancel\" to return");
en.put("eventEditorSetMobSpawnAmount", "Set the amount of mobs to spawn");
en.put("eventEditorSetDropChance", "Set the drop chance");
en.put("eventEditorInvalidDropChance", "Drop chance has to be between 0.0 and 1.0");
en.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");
en.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");
en.put("eventEditorPotionEffects", "Event Potion Effects");
en.put("eventEditorSetPotionEffects", "Set potion effect types");
en.put("eventEditorMustSetPotionTypesFirst", "You must set potion effect types first!");
en.put("eventEditorSetPotionDurations", "Set potion effect durations");
en.put("eventEditorMustSetPotionDurationsFirst", "You must set potion effect durations first!");
en.put("eventEditorMustSetPotionTypesAndDurationsFirst", "You must set potion effect types and durations first!");
en.put("eventEditorNoDurationsSet", "(No durations set)");
en.put("eventEditorSetPotionMagnitudes", "Set potion effect magnitudes");
en.put("eventEditorPotionsCleared", "Potion effects cleared.");
en.put("eventEditorInvalidPotionType", "___ is not a valid potion effect type!");
en.put("eventEditorPotionEffects", "Event Potion Effects");
en.put("eventEditorSetPotionEffects", "Set potion effect types");
en.put("eventEditorMustSetPotionTypesFirst", "You must set potion effect types first!");
en.put("eventEditorSetPotionDurations", "Set potion effect durations");
en.put("eventEditorMustSetPotionDurationsFirst", "You must set potion effect durations first!");
en.put("eventEditorMustSetPotionTypesAndDurationsFirst", "You must set potion effect types and durations first!");
en.put("eventEditorNoDurationsSet", "(No durations set)");
en.put("eventEditorSetPotionMagnitudes", "Set potion effect magnitudes");
en.put("eventEditorPotionsCleared", "Potion effects cleared.");
en.put("eventEditorInvalidPotionType", "___ is not a valid potion effect type!");
en.put("eventEditorEnterNPCId", "Enter NPC ID (or -1 to return)");
en.put("eventEditorNoNPCExists", "No NPC exists with that id!");
en.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");
en.put("eventEditorSelectBlockFirst", "You must select a block first.");
en.put("eventEditorSetMessagePrompt", "Enter message, or enter \'none\' to delete, (or \'cancel\' to return)");
en.put("eventEditorSetItemIDsPrompt", "Enter item IDs separating each one by a space, or enter \"cancel\" to return.");
en.put("eventEditorSetItemAmountsPrompt", "Enter item amounts (numbers) separating each one by a space, or enter \"cancel\" to return.");
en.put("eventEditorSetMobTypesPrompt", "Enter mob names separating each one by a space, or enter \"cancel\" to return");
en.put("eventEditorSetMobAmountsPrompt", "Enter mob amounts separating each one by a space, or enter \"cancel\" to return");
en.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");
en.put("eventEditorSetPotionEffectsPrompt", "Enter potion effect types separating each one by a space, or enter \"cancel\" to return");
en.put("eventEditorSetPotionDurationsPrompt", "Enter effect durations (in milliseconds) separating each one by a space, or enter \"cancel\" to return");
en.put("eventEditorSetPotionMagnitudesPrompt", "Enter potion effect magnitudes separating each one by a space, or enter \"cancel\" to return");
en.put("eventEditorSetHungerPrompt", "Enter hunger level, or -1 to remove it");
en.put("eventEditorHungerLevelAtLeastZero", "Hunger level must be at least 0!");
en.put("eventEditorSetSaturationPrompt", "Enter saturation level, or -1 to remove it");
en.put("eventEditorSaturationLevelAtLeastZero", "Saturation level must be at least 0!");
en.put("eventEditorSetHealthPrompt", "Enter health level, or -1 to remove it");
en.put("eventEditorHealthLevelAtLeastZero", "Health level must be at least 0!");
en.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");
en.put("eventEditorCommandsNote", "Note: You may use <player> to refer to the player's name.");
en.put("eventEditorSetCommandsPrompt", "Enter commands separating each one by a comma, or enter \"clear\" to clear the list, or enter \"cancel\" to return.");
en.put("eventEditorSet", "");
//en.put("eventEditorSet", "");
//en.put("eventEditorSet", "");
en.put("eventEditorEnterNPCId", "Enter NPC ID (or -1 to return)");
en.put("eventEditorNoNPCExists", "No NPC exists with that id!");
en.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");
en.put("eventEditorSelectBlockFirst", "You must select a block first.");
en.put("eventEditorSetMessagePrompt", "Enter message, or enter \'none\' to delete, (or \'cancel\' to return)");
en.put("eventEditorSetItemIDsPrompt", "Enter item IDs separating each one by a space, or enter \"cancel\" to return.");
en.put("eventEditorSetItemAmountsPrompt", "Enter item amounts (numbers) separating each one by a space, or enter \"cancel\" to return.");
en.put("eventEditorSetMobTypesPrompt", "Enter mob name, or enter \"cancel\" to return");
en.put("eventEditorSetMobAmountsPrompt", "Enter mob amount, or enter \"cancel\" to return");
en.put("eventEditorSetMobNamePrompt", "Set the name for this mob, or enter \"cancel\" to return");
en.put("eventEditorSetMobLocationPrompt", "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");
en.put("eventEditorSetPotionEffectsPrompt", "Enter potion effect types separating each one by a space, or enter \"cancel\" to return");
en.put("eventEditorSetPotionDurationsPrompt", "Enter effect durations (in milliseconds) separating each one by a space, or enter \"cancel\" to return");
en.put("eventEditorSetPotionMagnitudesPrompt", "Enter potion effect magnitudes separating each one by a space, or enter \"cancel\" to return");
en.put("eventEditorSetHungerPrompt", "Enter hunger level, or -1 to remove it");
en.put("eventEditorHungerLevelAtLeastZero", "Hunger level must be at least 0!");
en.put("eventEditorSetSaturationPrompt", "Enter saturation level, or -1 to remove it");
en.put("eventEditorSaturationLevelAtLeastZero", "Saturation level must be at least 0!");
en.put("eventEditorSetHealthPrompt", "Enter health level, or -1 to remove it");
en.put("eventEditorHealthLevelAtLeastZero", "Health level must be at least 0!");
en.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");
en.put("eventEditorCommandsNote", "Note: You may use <player> to refer to the player's name.");
en.put("eventEditorSetCommandsPrompt", "Enter commands separating each one by a comma, or enter \"clear\" to clear the list, or enter \"cancel\" to return.");
en.put("eventEditorSet", "");
//en.put("eventEditorSet", "");
//en.put("eventEditorSet", "");
//
//
//Effects
en.put("effBlazeShoot", "Sound of a Blaze firing");
en.put("effBowFire", "Sound of a bow firing");
en.put("effClick1", "A click sound");
en.put("effClick2", "A different click sound");
en.put("effDoorToggle", "Sound of a door opening or closing");
en.put("effExtinguish", "Sound of fire being extinguished");
en.put("effGhastShoot", "Sound of a Ghast firing");
en.put("effGhastShriek", "Sound of a Ghast shrieking");
en.put("effZombieWood", "Sound of a Zombie chewing an iron door");
en.put("effZombieIron", "Sound of a Zombie chewing a wooden door");
en.put("effEnterName", "Enter an effect name to add it to the list, or enter \"cancel\" to return");
//Effects
en.put("effBlazeShoot", "Sound of a Blaze firing");
en.put("effBowFire", "Sound of a bow firing");
en.put("effClick1", "A click sound");
en.put("effClick2", "A different click sound");
en.put("effDoorToggle", "Sound of a door opening or closing");
en.put("effExtinguish", "Sound of fire being extinguished");
en.put("effGhastShoot", "Sound of a Ghast firing");
en.put("effGhastShriek", "Sound of a Ghast shrieking");
en.put("effZombieWood", "Sound of a Zombie chewing an iron door");
en.put("effZombieIron", "Sound of a Zombie chewing a wooden door");
en.put("effEnterName", "Enter an effect name to add it to the list, or enter \"cancel\" to return");
//
//
//Inputs
en.put("cmdCancel", "cancel");
en.put("cmdAdd", "add");
en.put("cmdClear", "clear");
en.put("cmdNone", "none");
en.put("cmdDone", "done");
//
//Inputs
en.put("cmdCancel", "cancel");
en.put("cmdAdd", "add");
en.put("cmdClear", "clear");
en.put("cmdNone", "none");
en.put("cmdDone", "done");
//
//Misc
en.put("event", "Event");
en.put("delay", "Delay");
en.put("save", "Save");
en.put("exit", "Exit");
en.put("exited", "Exited.");
en.put("yes", "Yes");
en.put("no", "No");
en.put("clear", "Clear");
en.put("done", "Done");
en.put("quit", "Quit");
en.put("noneSet", "None set");
en.put("noDelaySet", "No delay set");
en.put("noIdsSet", "No IDs set");
en.put("worlds", "Worlds");
en.put("mobs", "Mobs");
en.put("invalidOption", "Invalid option!");
//
//
//Misc
en.put("event", "Event");
en.put("delay", "Delay");
en.put("save", "Save");
en.put("exit", "Exit");
en.put("exited", "Exited");
en.put("cancel", "Cancel");
en.put("yes", "Yes");
en.put("no", "No");
en.put("clear", "Clear");
en.put("done", "Done");
en.put("quit", "Quit");
en.put("noneSet", "None set");
en.put("noDelaySet", "No delay set");
en.put("noIdsSet", "No IDs set");
en.put("worlds", "Worlds");
en.put("mobs", "Mobs");
en.put("invalidOption", "Invalid option!");
//
//
File file = new File(plugin.getDataFolder(), "/lang/" + lang + ".yml");
YamlConfiguration langFile = YamlConfiguration.loadConfiguration(file);
File file = new File(plugin.getDataFolder(), "/lang/" + lang + ".yml");
YamlConfiguration langFile = YamlConfiguration.loadConfiguration(file);
for (Entry<String, Object> e : langFile.getValues(true).entrySet()) {
en.put(e.getKey(), (String) e.getValue());
}
for (Entry<String, Object> e : langFile.getValues(true).entrySet()) {
en.put(e.getKey(), (String) e.getValue());
}
}
}
public void save() {
File file = new File(plugin.getDataFolder(), "/lang/" + lang + ".yml");
YamlConfiguration langFile = YamlConfiguration.loadConfiguration(file);
public void save() {
File file = new File(plugin.getDataFolder(), "/lang/" + lang + ".yml");
YamlConfiguration langFile = YamlConfiguration.loadConfiguration(file);
for (Entry<String, String> e : en.entrySet()) {
langFile.set(e.getKey(), e.getValue());
}
for (Entry<String, String> e : en.entrySet()) {
langFile.set(e.getKey(), e.getValue());
}
try {
try {
langFile.save(file);
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}

View File

@ -0,0 +1,242 @@
package me.blackvein.quests.util;
import me.blackvein.quests.Quests;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_6_R2.inventory.CraftItemStack;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.ItemStack;
public class QuestMob {
private String name = null;
private EntityType entityType = null;
private Location spawnLocation = null;
private Integer spawnAmounts = null;
public ItemStack[] inventory = new ItemStack[5];
public Float[] dropChances = new Float[5];
public QuestMob (EntityType entityType, Location spawnLocation, int spawnAmounts) {
this.entityType = entityType;
this.spawnLocation = spawnLocation;
this.spawnAmounts = spawnAmounts;
}
public QuestMob() {
}
public void setSpawnLocation(Location spawnLocation) {
this.spawnLocation = spawnLocation;
}
public Location getSpawnLocation() {
return spawnLocation;
}
public void setType(EntityType entityType) {
this.entityType = entityType;
}
public EntityType getType() {
return entityType;
}
public void setSpawnAmounts(int spawnAmounts) {
this.spawnAmounts = spawnAmounts;
}
public Integer getSpawnAmounts() {
return spawnAmounts;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setHelmet(ItemStack helmet, float dropChance) {
inventory[4] = helmet;
dropChances[4] = dropChance;
}
public void setChest(ItemStack chest, float dropChance) {
inventory[3] = chest;
dropChances[3] = dropChance;
}
public void setLeggings(ItemStack leggings, float dropChance) {
inventory[2] = leggings;
dropChances[2] = dropChance;
}
public void setBoots(ItemStack boots, float dropChance) {
inventory[1] = boots;
dropChances[1] = dropChance;
}
public void setHeldItem(ItemStack heldItem, float dropChance) {
inventory[0] = heldItem;
dropChances[0] = dropChance;
}
public void spawn() {
System.out.println("Spawned!");
World world = spawnLocation.getWorld();
for (int i = 0; i < spawnAmounts; i++) {
Entity entity = world.spawnEntity(spawnLocation, entityType);
if (name != null) {
((LivingEntity) entity).setCustomName(name);
((LivingEntity) entity).setCustomNameVisible(true);
}
for (int j = 0; j < 5; j++) {
if (inventory[j] != null)
((CraftEntity) entity).getHandle().setEquipment(j, CraftItemStack.asNMSCopy(inventory[j]));
}
EntityEquipment eq = ((CraftLivingEntity) entity).getEquipment();
if (dropChances[0] != null) eq.setItemInHandDropChance(dropChances[0]);
if (dropChances[1] != null) eq.setBootsDropChance(dropChances[1]);
if (dropChances[2] != null) eq.setLeggingsDropChance(dropChances[2]);
if (dropChances[3] != null) eq.setChestplateDropChance(dropChances[3]);
if (dropChances[4] != null) eq.setHelmetDropChance(dropChances[4]);
}
}
public String serialize() {
String string = "";
string += "type-" + entityType.getName();
if (name != null) string += "::name-" + name;
if (spawnLocation != null) string += "::spawn-" + Quests.getLocationInfo(spawnLocation);
if (spawnAmounts != null) string += "::amounts-" + spawnAmounts;
if (inventory[0] != null) {
string += "::hand-" + ItemUtil.serialize(inventory[0]);
string += "::hand_drop-" + dropChances[0];
}
if (inventory[1] != null) {
string += "::boots-" + ItemUtil.serialize(inventory[1]);
string += "::boots_drop-" + dropChances[1];
}
if (inventory[2] != null) {
string += "::leggings-" + ItemUtil.serialize(inventory[2]);
string += "::leggings_drop-" + dropChances[2];
}
if (inventory[3] != null) {
string += "::chest-" + ItemUtil.serialize(inventory[3]);
string += "::chest_drop-" + dropChances[3];
}
if (inventory[4] != null) {
string += "::helmet-" + ItemUtil.serialize(inventory[4]);
string += "::helmet_drop-" + dropChances[4];
}
return string;
}
public static QuestMob fromString(String str) {
String name = null;
EntityType entityType = null;
Location loc = null;
Integer amounts = null;
ItemStack[] inventory = new ItemStack[5];
Float[] dropChances = new Float[5];
String[] args = str.split("::");
for (String string : args) {
if (string.startsWith("type-")) {
entityType = Quests.getMobType(string.substring(5));
} else if (string.startsWith("name-")) {
name = string.substring(5);
} else if (string.startsWith("spawn-")) {
loc = Quests.getLocation(string.substring(6));
} else if (string.startsWith("amounts-")) {
amounts = Integer.parseInt(string.substring(8));
} else if (string.startsWith("hand-")) {
inventory[0] = ItemUtil.readItemStack(string.substring(5));
} else if (string.startsWith("hand_drop-")) {
dropChances[0] = Float.parseFloat(string.substring(10));
} else if (string.startsWith("boots-")) {
inventory[1] = ItemUtil.readItemStack(string.substring(6));
} else if (string.startsWith("boots_drop-")) {
dropChances[1] = Float.parseFloat(string.substring(11));
} else if (string.startsWith("leggings-")) {
inventory[2] = ItemUtil.readItemStack(string.substring(9));
} else if (string.startsWith("leggings_drop-")) {
dropChances[2] = Float.parseFloat(string.substring(14));
} else if (string.startsWith("chest-")) {
inventory[3] = ItemUtil.readItemStack(string.substring(6));
} else if (string.startsWith("chest_drop-")) {
dropChances[3] = Float.parseFloat(string.substring(11));
} else if (string.startsWith("helmet-")) {
inventory[4] = ItemUtil.readItemStack(string.substring(7));
} else if (string.startsWith("helmet_drop-")) {
dropChances[4] = Float.parseFloat(string.substring(12));
}
}
QuestMob qm = new QuestMob(entityType, loc, amounts);
qm.setName(name);
qm.inventory = inventory;
qm.dropChances = dropChances;
return qm;
}
@Override
public boolean equals(Object o) {
if ((o instanceof QuestMob) == false) {
return false;
}
QuestMob other = (QuestMob) o;
if (name.equalsIgnoreCase(other.name) == false)
return false;
if (entityType != other.entityType)
return false;
if (dropChances != other.dropChances)
return false;
if (inventory.length == other.inventory.length) {
for (int i = 0; i < inventory.length; i++) {
if (ItemUtil.compareItems(inventory[i], other.inventory[i], false) != 0)
return false;
}
} else {
return false;
}
if (spawnAmounts != other.spawnAmounts)
return false;
if (spawnLocation != other.spawnLocation)
return false;
return true;
}
}