From 82eca3991a7de3ab7aa615391334ab10d656746a Mon Sep 17 00:00:00 2001 From: GregZ_ Date: Fri, 23 Jun 2017 15:43:07 +0100 Subject: [PATCH 1/3] Quests - V2.8.6-01 - Code reformat - By GregZ_ * Incremented dev version in pom.xml. * Reformatted code to make it easier to read. * Organized import order because the current lack order hurts my head. --- pom.xml | 2 +- .../java/com/evilmidget38/UUIDFetcher.java | 157 +- .../me/blackvein/particles/Eff_1_10_R1.java | 103 +- .../me/blackvein/particles/Eff_1_11_R1.java | 103 +- .../me/blackvein/particles/Eff_1_12_R1.java | 103 +- .../me/blackvein/particles/Eff_1_7_R3.java | 95 +- .../me/blackvein/particles/Eff_1_7_R4.java | 95 +- .../me/blackvein/particles/Eff_1_8_R1.java | 103 +- .../me/blackvein/particles/Eff_1_8_R2.java | 103 +- .../me/blackvein/particles/Eff_1_8_R3.java | 103 +- .../me/blackvein/particles/Eff_1_9_R1.java | 103 +- .../me/blackvein/particles/Eff_1_9_R2.java | 103 +- .../me/blackvein/quests/CustomObjective.java | 364 +- .../blackvein/quests/CustomRequirement.java | 48 +- .../me/blackvein/quests/CustomReward.java | 62 +- src/main/java/me/blackvein/quests/Event.java | 1165 +- .../me/blackvein/quests/EventFactory.java | 4809 ++++----- .../me/blackvein/quests/NpcEffectThread.java | 2238 ++-- .../java/me/blackvein/quests/NpcListener.java | 500 +- .../me/blackvein/quests/PlayerListener.java | 1567 ++- src/main/java/me/blackvein/quests/Quest.java | 1445 ++- .../java/me/blackvein/quests/QuestData.java | 1939 ++-- .../me/blackvein/quests/QuestFactory.java | 4082 +++---- .../me/blackvein/quests/QuestTaskTrigger.java | 21 +- .../java/me/blackvein/quests/Quester.java | 6152 +++++------ src/main/java/me/blackvein/quests/Quests.java | 9461 +++++++---------- src/main/java/me/blackvein/quests/Stage.java | 625 +- .../java/me/blackvein/quests/StageTimer.java | 124 +- .../exceptions/InvalidStageException.java | 34 +- .../quests/prompts/CreateStagePrompt.java | 8093 ++++++-------- .../quests/prompts/ItemStackPrompt.java | 968 +- .../quests/prompts/QuestAcceptPrompt.java | 279 +- .../quests/prompts/RequirementsPrompt.java | 1879 ++-- .../quests/prompts/RewardsPrompt.java | 1830 ++-- .../quests/prompts/StagesPrompt.java | 471 +- .../java/me/blackvein/quests/util/CK.java | 270 +- .../me/blackvein/quests/util/ItemUtil.java | 427 +- .../java/me/blackvein/quests/util/Lang.java | 2266 ++-- .../me/blackvein/quests/util/MiscUtil.java | 228 +- .../me/blackvein/quests/util/QuestMob.java | 454 +- 40 files changed, 22796 insertions(+), 30178 deletions(-) diff --git a/pom.xml b/pom.xml index 89f9242b9..ef6f49a70 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ me.blackvein.quests quests - 2.8.6 + 2.8.6-01 quests https://github.com/FlyingPikachu/Quests/ jar diff --git a/src/main/java/com/evilmidget38/UUIDFetcher.java b/src/main/java/com/evilmidget38/UUIDFetcher.java index 5c3c1014f..fc9e68cb0 100644 --- a/src/main/java/com/evilmidget38/UUIDFetcher.java +++ b/src/main/java/com/evilmidget38/UUIDFetcher.java @@ -1,97 +1,102 @@ package com.evilmidget38; -import com.google.common.collect.ImmutableList; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; - import java.io.InputStreamReader; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.nio.ByteBuffer; -import java.util.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; import java.util.concurrent.Callable; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; + +import com.google.common.collect.ImmutableList; + public class UUIDFetcher implements Callable> { - private static final double PROFILES_PER_REQUEST = 100; - private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft"; - private final JSONParser jsonParser = new JSONParser(); - private final List names; - private final boolean rateLimiting; + private static final double PROFILES_PER_REQUEST = 100; + private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft"; + private final JSONParser jsonParser = new JSONParser(); + private final List names; + private final boolean rateLimiting; - public UUIDFetcher(List names, boolean rateLimiting) { - this.names = ImmutableList.copyOf(names); - this.rateLimiting = rateLimiting; - } + public UUIDFetcher(List names, boolean rateLimiting) { + this.names = ImmutableList.copyOf(names); + this.rateLimiting = rateLimiting; + } - public UUIDFetcher(List names) { - this(names, true); - } + public UUIDFetcher(List names) { + this(names, true); + } - public Map call() throws Exception { - Map uuidMap = new HashMap(); - int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST); - for (int i = 0; i < requests; i++) { - HttpURLConnection connection = createConnection(); - String body = JSONArray.toJSONString(names.subList(i * 100, Math.min((i + 1) * 100, names.size()))); - writeBody(connection, body); - JSONArray array = (JSONArray) jsonParser.parse(new InputStreamReader(connection.getInputStream())); - for (Object profile : array) { - JSONObject jsonProfile = (JSONObject) profile; - String id = (String) jsonProfile.get("id"); - String name = (String) jsonProfile.get("name"); - UUID uuid = UUIDFetcher.getUUID(id); - uuidMap.put(name, uuid); - } - if (rateLimiting && i != requests - 1) { - Thread.sleep(100L); - } - } - return uuidMap; - } + public Map call() throws Exception { + Map uuidMap = new HashMap(); + int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST); + for (int i = 0; i < requests; i++) { + HttpURLConnection connection = createConnection(); + String body = JSONArray.toJSONString(names.subList(i * 100, Math.min((i + 1) * 100, names.size()))); + writeBody(connection, body); + JSONArray array = (JSONArray) jsonParser.parse(new InputStreamReader(connection.getInputStream())); + for (Object profile : array) { + JSONObject jsonProfile = (JSONObject) profile; + String id = (String) jsonProfile.get("id"); + String name = (String) jsonProfile.get("name"); + UUID uuid = UUIDFetcher.getUUID(id); + uuidMap.put(name, uuid); + } + if (rateLimiting && i != requests - 1) { + Thread.sleep(100L); + } + } + return uuidMap; + } - private static void writeBody(HttpURLConnection connection, String body) throws Exception { - OutputStream stream = connection.getOutputStream(); - stream.write(body.getBytes()); - stream.flush(); - stream.close(); - } + private static void writeBody(HttpURLConnection connection, String body) throws Exception { + OutputStream stream = connection.getOutputStream(); + stream.write(body.getBytes()); + stream.flush(); + stream.close(); + } - private static HttpURLConnection createConnection() throws Exception { - URL url = new URL(PROFILE_URL); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setRequestMethod("POST"); - connection.setRequestProperty("Content-Type", "application/json"); - connection.setUseCaches(false); - connection.setDoInput(true); - connection.setDoOutput(true); - return connection; - } + private static HttpURLConnection createConnection() throws Exception { + URL url = new URL(PROFILE_URL); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod("POST"); + connection.setRequestProperty("Content-Type", "application/json"); + connection.setUseCaches(false); + connection.setDoInput(true); + connection.setDoOutput(true); + return connection; + } - private static UUID getUUID(String id) { - return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" + id.substring(20, 32)); - } + private static UUID getUUID(String id) { + return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" + id.substring(20, 32)); + } - public static byte[] toBytes(UUID uuid) { - ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]); - byteBuffer.putLong(uuid.getMostSignificantBits()); - byteBuffer.putLong(uuid.getLeastSignificantBits()); - return byteBuffer.array(); - } + public static byte[] toBytes(UUID uuid) { + ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]); + byteBuffer.putLong(uuid.getMostSignificantBits()); + byteBuffer.putLong(uuid.getLeastSignificantBits()); + return byteBuffer.array(); + } - public static UUID fromBytes(byte[] array) { - if (array.length != 16) { - throw new IllegalArgumentException("Illegal byte array length: " + array.length); - } - ByteBuffer byteBuffer = ByteBuffer.wrap(array); - long mostSignificant = byteBuffer.getLong(); - long leastSignificant = byteBuffer.getLong(); - return new UUID(mostSignificant, leastSignificant); - } + public static UUID fromBytes(byte[] array) { + if (array.length != 16) { + throw new IllegalArgumentException("Illegal byte array length: " + array.length); + } + ByteBuffer byteBuffer = ByteBuffer.wrap(array); + long mostSignificant = byteBuffer.getLong(); + long leastSignificant = byteBuffer.getLong(); + return new UUID(mostSignificant, leastSignificant); + } - public static UUID getUUIDOf(String name) throws Exception { - return new UUIDFetcher(Collections.singletonList(name)).call().get(name); - } + public static UUID getUUIDOf(String name) throws Exception { + return new UUIDFetcher(Collections.singletonList(name)).call().get(name); + } } diff --git a/src/main/java/me/blackvein/particles/Eff_1_10_R1.java b/src/main/java/me/blackvein/particles/Eff_1_10_R1.java index acb2f7386..b915f346b 100644 --- a/src/main/java/me/blackvein/particles/Eff_1_10_R1.java +++ b/src/main/java/me/blackvein/particles/Eff_1_10_R1.java @@ -9,46 +9,45 @@ import net.minecraft.server.v1_10_R1.PacketPlayOutWorldParticles; public enum Eff_1_10_R1 { - EXPLOSION(EnumParticle.EXPLOSION_NORMAL), EXPLOSION_LARGE(EnumParticle.EXPLOSION_LARGE), - EXPLOSION_HUGE(EnumParticle.EXPLOSION_HUGE), - FIREWORKS_SPARK(EnumParticle.FIREWORKS_SPARK), - BUBBLE(EnumParticle.WATER_BUBBLE), - WAKE(EnumParticle.WATER_WAKE), - SPLASH(EnumParticle.WATER_SPLASH), - SUSPENDED(EnumParticle.SUSPENDED), - DEPTH_SUSPEND(EnumParticle.SUSPENDED_DEPTH), - CRIT(EnumParticle.CRIT), - MAGIC_CRIT(EnumParticle.CRIT_MAGIC), - SMOKE(EnumParticle.SMOKE_NORMAL), - LARGE_SMOKE(EnumParticle.SMOKE_LARGE), - SPELL(EnumParticle.SPELL), - INSTANT_SPELL(EnumParticle.SPELL_INSTANT), - MOB_SPELL(EnumParticle.SPELL_MOB), - MOB_SPELL_AMBIENT(EnumParticle.SPELL_MOB_AMBIENT), - WITCH_MAGIC(EnumParticle.SPELL_WITCH), - DRIP_WATER(EnumParticle.DRIP_WATER), - DRIP_LAVA(EnumParticle.DRIP_LAVA), - ANGRY_VILLAGER(EnumParticle.VILLAGER_ANGRY), - HAPPY_VILLAGER(EnumParticle.VILLAGER_HAPPY), - TOWN_AURA(EnumParticle.TOWN_AURA), - NOTE(EnumParticle.NOTE), - PORTAL(EnumParticle.PORTAL), - ENCHANTMENT_TABLE(EnumParticle.ENCHANTMENT_TABLE), - FLAME(EnumParticle.FLAME), - LAVA(EnumParticle.LAVA), - FOOTSTEP(EnumParticle.FOOTSTEP), - CLOUD(EnumParticle.CLOUD), - RED_DUST(EnumParticle.REDSTONE), - SNOWBALL_POOF(EnumParticle.SNOWBALL), - SNOW_SHOVEL(EnumParticle.SNOW_SHOVEL), - SLIME(EnumParticle.SLIME), - HEART(EnumParticle.HEART), - BARRIER(EnumParticle.BARRIER), - ICONCRACK_(EnumParticle.ITEM_CRACK), - BLOCKCRACK_(EnumParticle.BLOCK_CRACK), - BLOCKDUST_(EnumParticle.BLOCK_DUST), + EXPLOSION_HUGE(EnumParticle.EXPLOSION_HUGE), + FIREWORKS_SPARK(EnumParticle.FIREWORKS_SPARK), + BUBBLE(EnumParticle.WATER_BUBBLE), + WAKE(EnumParticle.WATER_WAKE), + SPLASH(EnumParticle.WATER_SPLASH), + SUSPENDED(EnumParticle.SUSPENDED), + DEPTH_SUSPEND(EnumParticle.SUSPENDED_DEPTH), + CRIT(EnumParticle.CRIT), + MAGIC_CRIT(EnumParticle.CRIT_MAGIC), + SMOKE(EnumParticle.SMOKE_NORMAL), + LARGE_SMOKE(EnumParticle.SMOKE_LARGE), + SPELL(EnumParticle.SPELL), + INSTANT_SPELL(EnumParticle.SPELL_INSTANT), + MOB_SPELL(EnumParticle.SPELL_MOB), + MOB_SPELL_AMBIENT(EnumParticle.SPELL_MOB_AMBIENT), + WITCH_MAGIC(EnumParticle.SPELL_WITCH), + DRIP_WATER(EnumParticle.DRIP_WATER), + DRIP_LAVA(EnumParticle.DRIP_LAVA), + ANGRY_VILLAGER(EnumParticle.VILLAGER_ANGRY), + HAPPY_VILLAGER(EnumParticle.VILLAGER_HAPPY), + TOWN_AURA(EnumParticle.TOWN_AURA), + NOTE(EnumParticle.NOTE), + PORTAL(EnumParticle.PORTAL), + ENCHANTMENT_TABLE(EnumParticle.ENCHANTMENT_TABLE), + FLAME(EnumParticle.FLAME), + LAVA(EnumParticle.LAVA), + FOOTSTEP(EnumParticle.FOOTSTEP), + CLOUD(EnumParticle.CLOUD), + RED_DUST(EnumParticle.REDSTONE), + SNOWBALL_POOF(EnumParticle.SNOWBALL), + SNOW_SHOVEL(EnumParticle.SNOW_SHOVEL), + SLIME(EnumParticle.SLIME), + HEART(EnumParticle.HEART), + BARRIER(EnumParticle.BARRIER), + ICONCRACK_(EnumParticle.ITEM_CRACK), + BLOCKCRACK_(EnumParticle.BLOCK_CRACK), + BLOCKDUST_(EnumParticle.BLOCK_DUST), DROPLET(EnumParticle.WATER_DROP), TAKE(EnumParticle.ITEM_TAKE), MOB_APPEARANCE(EnumParticle.MOB_APPEARANCE), @@ -57,27 +56,15 @@ public enum Eff_1_10_R1 { ENDROD(EnumParticle.END_ROD), DAMAGE_INDICATOR(EnumParticle.DAMAGE_INDICATOR), FALLING_DUST(EnumParticle.FALLING_DUST); - - private final EnumParticle particleEnum; + private final EnumParticle particleEnum; - Eff_1_10_R1(EnumParticle particleEnum) { - this.particleEnum = particleEnum; - } + Eff_1_10_R1(EnumParticle particleEnum) { + this.particleEnum = particleEnum; + } - public void sendToPlayer(Player player, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count, int[] data) throws Exception { - PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleEnum, - false, - (float) location.getX(), - (float) location.getY(), - (float) location.getZ(), - offsetX, - offsetY, - offsetZ, - speed, - count, - data); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); - } - + public void sendToPlayer(Player player, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count, int[] data) throws Exception { + PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleEnum, false, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count, data); + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); + } } \ No newline at end of file diff --git a/src/main/java/me/blackvein/particles/Eff_1_11_R1.java b/src/main/java/me/blackvein/particles/Eff_1_11_R1.java index 78c68befa..1f0f34689 100644 --- a/src/main/java/me/blackvein/particles/Eff_1_11_R1.java +++ b/src/main/java/me/blackvein/particles/Eff_1_11_R1.java @@ -9,46 +9,45 @@ import net.minecraft.server.v1_11_R1.PacketPlayOutWorldParticles; public enum Eff_1_11_R1 { - EXPLOSION(EnumParticle.EXPLOSION_NORMAL), EXPLOSION_LARGE(EnumParticle.EXPLOSION_LARGE), - EXPLOSION_HUGE(EnumParticle.EXPLOSION_HUGE), - FIREWORKS_SPARK(EnumParticle.FIREWORKS_SPARK), - BUBBLE(EnumParticle.WATER_BUBBLE), - WAKE(EnumParticle.WATER_WAKE), - SPLASH(EnumParticle.WATER_SPLASH), - SUSPENDED(EnumParticle.SUSPENDED), - DEPTH_SUSPEND(EnumParticle.SUSPENDED_DEPTH), - CRIT(EnumParticle.CRIT), - MAGIC_CRIT(EnumParticle.CRIT_MAGIC), - SMOKE(EnumParticle.SMOKE_NORMAL), - LARGE_SMOKE(EnumParticle.SMOKE_LARGE), - SPELL(EnumParticle.SPELL), - INSTANT_SPELL(EnumParticle.SPELL_INSTANT), - MOB_SPELL(EnumParticle.SPELL_MOB), - MOB_SPELL_AMBIENT(EnumParticle.SPELL_MOB_AMBIENT), - WITCH_MAGIC(EnumParticle.SPELL_WITCH), - DRIP_WATER(EnumParticle.DRIP_WATER), - DRIP_LAVA(EnumParticle.DRIP_LAVA), - ANGRY_VILLAGER(EnumParticle.VILLAGER_ANGRY), - HAPPY_VILLAGER(EnumParticle.VILLAGER_HAPPY), - TOWN_AURA(EnumParticle.TOWN_AURA), - NOTE(EnumParticle.NOTE), - PORTAL(EnumParticle.PORTAL), - ENCHANTMENT_TABLE(EnumParticle.ENCHANTMENT_TABLE), - FLAME(EnumParticle.FLAME), - LAVA(EnumParticle.LAVA), - FOOTSTEP(EnumParticle.FOOTSTEP), - CLOUD(EnumParticle.CLOUD), - RED_DUST(EnumParticle.REDSTONE), - SNOWBALL_POOF(EnumParticle.SNOWBALL), - SNOW_SHOVEL(EnumParticle.SNOW_SHOVEL), - SLIME(EnumParticle.SLIME), - HEART(EnumParticle.HEART), - BARRIER(EnumParticle.BARRIER), - ICONCRACK_(EnumParticle.ITEM_CRACK), - BLOCKCRACK_(EnumParticle.BLOCK_CRACK), - BLOCKDUST_(EnumParticle.BLOCK_DUST), + EXPLOSION_HUGE(EnumParticle.EXPLOSION_HUGE), + FIREWORKS_SPARK(EnumParticle.FIREWORKS_SPARK), + BUBBLE(EnumParticle.WATER_BUBBLE), + WAKE(EnumParticle.WATER_WAKE), + SPLASH(EnumParticle.WATER_SPLASH), + SUSPENDED(EnumParticle.SUSPENDED), + DEPTH_SUSPEND(EnumParticle.SUSPENDED_DEPTH), + CRIT(EnumParticle.CRIT), + MAGIC_CRIT(EnumParticle.CRIT_MAGIC), + SMOKE(EnumParticle.SMOKE_NORMAL), + LARGE_SMOKE(EnumParticle.SMOKE_LARGE), + SPELL(EnumParticle.SPELL), + INSTANT_SPELL(EnumParticle.SPELL_INSTANT), + MOB_SPELL(EnumParticle.SPELL_MOB), + MOB_SPELL_AMBIENT(EnumParticle.SPELL_MOB_AMBIENT), + WITCH_MAGIC(EnumParticle.SPELL_WITCH), + DRIP_WATER(EnumParticle.DRIP_WATER), + DRIP_LAVA(EnumParticle.DRIP_LAVA), + ANGRY_VILLAGER(EnumParticle.VILLAGER_ANGRY), + HAPPY_VILLAGER(EnumParticle.VILLAGER_HAPPY), + TOWN_AURA(EnumParticle.TOWN_AURA), + NOTE(EnumParticle.NOTE), + PORTAL(EnumParticle.PORTAL), + ENCHANTMENT_TABLE(EnumParticle.ENCHANTMENT_TABLE), + FLAME(EnumParticle.FLAME), + LAVA(EnumParticle.LAVA), + FOOTSTEP(EnumParticle.FOOTSTEP), + CLOUD(EnumParticle.CLOUD), + RED_DUST(EnumParticle.REDSTONE), + SNOWBALL_POOF(EnumParticle.SNOWBALL), + SNOW_SHOVEL(EnumParticle.SNOW_SHOVEL), + SLIME(EnumParticle.SLIME), + HEART(EnumParticle.HEART), + BARRIER(EnumParticle.BARRIER), + ICONCRACK_(EnumParticle.ITEM_CRACK), + BLOCKCRACK_(EnumParticle.BLOCK_CRACK), + BLOCKDUST_(EnumParticle.BLOCK_DUST), DROPLET(EnumParticle.WATER_DROP), TAKE(EnumParticle.ITEM_TAKE), MOB_APPEARANCE(EnumParticle.MOB_APPEARANCE), @@ -59,27 +58,15 @@ public enum Eff_1_11_R1 { FALLING_DUST(EnumParticle.FALLING_DUST), SPIT(EnumParticle.SPIT), TOTEM(EnumParticle.TOTEM); - - private final EnumParticle particleEnum; + private final EnumParticle particleEnum; - Eff_1_11_R1(EnumParticle particleEnum) { - this.particleEnum = particleEnum; - } + Eff_1_11_R1(EnumParticle particleEnum) { + this.particleEnum = particleEnum; + } - public void sendToPlayer(Player player, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count, int[] data) throws Exception { - PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleEnum, - false, - (float) location.getX(), - (float) location.getY(), - (float) location.getZ(), - offsetX, - offsetY, - offsetZ, - speed, - count, - data); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); - } - + public void sendToPlayer(Player player, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count, int[] data) throws Exception { + PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleEnum, false, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count, data); + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); + } } \ No newline at end of file diff --git a/src/main/java/me/blackvein/particles/Eff_1_12_R1.java b/src/main/java/me/blackvein/particles/Eff_1_12_R1.java index 6f4b60c74..1db749541 100644 --- a/src/main/java/me/blackvein/particles/Eff_1_12_R1.java +++ b/src/main/java/me/blackvein/particles/Eff_1_12_R1.java @@ -9,46 +9,45 @@ import net.minecraft.server.v1_12_R1.PacketPlayOutWorldParticles; public enum Eff_1_12_R1 { - EXPLOSION(EnumParticle.EXPLOSION_NORMAL), EXPLOSION_LARGE(EnumParticle.EXPLOSION_LARGE), - EXPLOSION_HUGE(EnumParticle.EXPLOSION_HUGE), - FIREWORKS_SPARK(EnumParticle.FIREWORKS_SPARK), - BUBBLE(EnumParticle.WATER_BUBBLE), - WAKE(EnumParticle.WATER_WAKE), - SPLASH(EnumParticle.WATER_SPLASH), - SUSPENDED(EnumParticle.SUSPENDED), - DEPTH_SUSPEND(EnumParticle.SUSPENDED_DEPTH), - CRIT(EnumParticle.CRIT), - MAGIC_CRIT(EnumParticle.CRIT_MAGIC), - SMOKE(EnumParticle.SMOKE_NORMAL), - LARGE_SMOKE(EnumParticle.SMOKE_LARGE), - SPELL(EnumParticle.SPELL), - INSTANT_SPELL(EnumParticle.SPELL_INSTANT), - MOB_SPELL(EnumParticle.SPELL_MOB), - MOB_SPELL_AMBIENT(EnumParticle.SPELL_MOB_AMBIENT), - WITCH_MAGIC(EnumParticle.SPELL_WITCH), - DRIP_WATER(EnumParticle.DRIP_WATER), - DRIP_LAVA(EnumParticle.DRIP_LAVA), - ANGRY_VILLAGER(EnumParticle.VILLAGER_ANGRY), - HAPPY_VILLAGER(EnumParticle.VILLAGER_HAPPY), - TOWN_AURA(EnumParticle.TOWN_AURA), - NOTE(EnumParticle.NOTE), - PORTAL(EnumParticle.PORTAL), - ENCHANTMENT_TABLE(EnumParticle.ENCHANTMENT_TABLE), - FLAME(EnumParticle.FLAME), - LAVA(EnumParticle.LAVA), - FOOTSTEP(EnumParticle.FOOTSTEP), - CLOUD(EnumParticle.CLOUD), - RED_DUST(EnumParticle.REDSTONE), - SNOWBALL_POOF(EnumParticle.SNOWBALL), - SNOW_SHOVEL(EnumParticle.SNOW_SHOVEL), - SLIME(EnumParticle.SLIME), - HEART(EnumParticle.HEART), - BARRIER(EnumParticle.BARRIER), - ICONCRACK_(EnumParticle.ITEM_CRACK), - BLOCKCRACK_(EnumParticle.BLOCK_CRACK), - BLOCKDUST_(EnumParticle.BLOCK_DUST), + EXPLOSION_HUGE(EnumParticle.EXPLOSION_HUGE), + FIREWORKS_SPARK(EnumParticle.FIREWORKS_SPARK), + BUBBLE(EnumParticle.WATER_BUBBLE), + WAKE(EnumParticle.WATER_WAKE), + SPLASH(EnumParticle.WATER_SPLASH), + SUSPENDED(EnumParticle.SUSPENDED), + DEPTH_SUSPEND(EnumParticle.SUSPENDED_DEPTH), + CRIT(EnumParticle.CRIT), + MAGIC_CRIT(EnumParticle.CRIT_MAGIC), + SMOKE(EnumParticle.SMOKE_NORMAL), + LARGE_SMOKE(EnumParticle.SMOKE_LARGE), + SPELL(EnumParticle.SPELL), + INSTANT_SPELL(EnumParticle.SPELL_INSTANT), + MOB_SPELL(EnumParticle.SPELL_MOB), + MOB_SPELL_AMBIENT(EnumParticle.SPELL_MOB_AMBIENT), + WITCH_MAGIC(EnumParticle.SPELL_WITCH), + DRIP_WATER(EnumParticle.DRIP_WATER), + DRIP_LAVA(EnumParticle.DRIP_LAVA), + ANGRY_VILLAGER(EnumParticle.VILLAGER_ANGRY), + HAPPY_VILLAGER(EnumParticle.VILLAGER_HAPPY), + TOWN_AURA(EnumParticle.TOWN_AURA), + NOTE(EnumParticle.NOTE), + PORTAL(EnumParticle.PORTAL), + ENCHANTMENT_TABLE(EnumParticle.ENCHANTMENT_TABLE), + FLAME(EnumParticle.FLAME), + LAVA(EnumParticle.LAVA), + FOOTSTEP(EnumParticle.FOOTSTEP), + CLOUD(EnumParticle.CLOUD), + RED_DUST(EnumParticle.REDSTONE), + SNOWBALL_POOF(EnumParticle.SNOWBALL), + SNOW_SHOVEL(EnumParticle.SNOW_SHOVEL), + SLIME(EnumParticle.SLIME), + HEART(EnumParticle.HEART), + BARRIER(EnumParticle.BARRIER), + ICONCRACK_(EnumParticle.ITEM_CRACK), + BLOCKCRACK_(EnumParticle.BLOCK_CRACK), + BLOCKDUST_(EnumParticle.BLOCK_DUST), DROPLET(EnumParticle.WATER_DROP), TAKE(EnumParticle.ITEM_TAKE), MOB_APPEARANCE(EnumParticle.MOB_APPEARANCE), @@ -59,27 +58,15 @@ public enum Eff_1_12_R1 { FALLING_DUST(EnumParticle.FALLING_DUST), SPIT(EnumParticle.SPIT), TOTEM(EnumParticle.TOTEM); - - private final EnumParticle particleEnum; + private final EnumParticle particleEnum; - Eff_1_12_R1(EnumParticle particleEnum) { - this.particleEnum = particleEnum; - } + Eff_1_12_R1(EnumParticle particleEnum) { + this.particleEnum = particleEnum; + } - public void sendToPlayer(Player player, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count, int[] data) throws Exception { - PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleEnum, - false, - (float) location.getX(), - (float) location.getY(), - (float) location.getZ(), - offsetX, - offsetY, - offsetZ, - speed, - count, - data); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); - } - + public void sendToPlayer(Player player, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count, int[] data) throws Exception { + PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleEnum, false, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count, data); + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); + } } \ No newline at end of file diff --git a/src/main/java/me/blackvein/particles/Eff_1_7_R3.java b/src/main/java/me/blackvein/particles/Eff_1_7_R3.java index 4ff0a2e2d..689525977 100644 --- a/src/main/java/me/blackvein/particles/Eff_1_7_R3.java +++ b/src/main/java/me/blackvein/particles/Eff_1_7_R3.java @@ -8,59 +8,50 @@ import net.minecraft.server.v1_7_R3.PacketPlayOutWorldParticles; public enum Eff_1_7_R3 { - HUGE_EXPLOSION("hugeexplosion"), - LARGE_EXPLODE("largeexplode"), - FIREWORKS_SPARK("fireworksSpark"), - BUBBLE("bubble"), - SUSPEND("susgpend"), - DEPTH_SUSPEND("depthSuspend"), - TOWN_AURA("townaura"), - CRIT("crit"), - MAGIC_CRIT("magicCrit"), - MOB_SPELL("mobSpell"), - MOB_SPELL_AMBIENT("mobSpellAmbient"), - SPELL("spell"), - INSTANT_SPELL("instantSpell"), - WITCH_MAGIC("witchMagic"), - NOTE("note"), - PORTAL("portal"), - ENCHANTMENT_TABLE("enchantmenttable"), - EXPLODE("explode"), - FLAME("flame"), - LAVA("lava"), - FOOTSTEP("footstep"), - SPLASH("splash"), - LARGE_SMOKE("largesmoke"), - CLOUD("cloud"), - RED_DUST("reddust"), - SNOWBALL_POOF("snowballpoof"), - DRIP_WATER("dripWater"), - DRIP_LAVA("dripLava"), - SNOW_SHOVEL("snowshovel"), - SLIME("slime"), - HEART("heart"), - ANGRY_VILLAGER("angryVillager"), - HAPPY_VILLAGER("happyVillager"), - ICONCRACK("iconcrack_"), - TILECRACK("tilecrack_"); + HUGE_EXPLOSION("hugeexplosion"), + LARGE_EXPLODE("largeexplode"), + FIREWORKS_SPARK("fireworksSpark"), + BUBBLE("bubble"), + SUSPEND("susgpend"), + DEPTH_SUSPEND("depthSuspend"), + TOWN_AURA("townaura"), + CRIT("crit"), + MAGIC_CRIT("magicCrit"), + MOB_SPELL("mobSpell"), + MOB_SPELL_AMBIENT("mobSpellAmbient"), + SPELL("spell"), + INSTANT_SPELL("instantSpell"), + WITCH_MAGIC("witchMagic"), + NOTE("note"), + PORTAL("portal"), + ENCHANTMENT_TABLE("enchantmenttable"), + EXPLODE("explode"), + FLAME("flame"), + LAVA("lava"), + FOOTSTEP("footstep"), + SPLASH("splash"), + LARGE_SMOKE("largesmoke"), + CLOUD("cloud"), + RED_DUST("reddust"), + SNOWBALL_POOF("snowballpoof"), + DRIP_WATER("dripWater"), + DRIP_LAVA("dripLava"), + SNOW_SHOVEL("snowshovel"), + SLIME("slime"), + HEART("heart"), + ANGRY_VILLAGER("angryVillager"), + HAPPY_VILLAGER("happyVillager"), + ICONCRACK("iconcrack_"), + TILECRACK("tilecrack_"); - private final String particleName; + private final String particleName; - Eff_1_7_R3(String particleName) { - this.particleName = particleName; - } - - public void sendToPlayer(Player player, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count) throws Exception { - PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleName, - (float) location.getX(), - (float) location.getY(), - (float) location.getZ(), - offsetX, - offsetY, - offsetZ, - speed, - count); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); - } + Eff_1_7_R3(String particleName) { + this.particleName = particleName; + } + public void sendToPlayer(Player player, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count) throws Exception { + PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleName, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count); + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); + } } diff --git a/src/main/java/me/blackvein/particles/Eff_1_7_R4.java b/src/main/java/me/blackvein/particles/Eff_1_7_R4.java index c8d368daa..224a71d04 100644 --- a/src/main/java/me/blackvein/particles/Eff_1_7_R4.java +++ b/src/main/java/me/blackvein/particles/Eff_1_7_R4.java @@ -8,59 +8,50 @@ import net.minecraft.server.v1_7_R4.PacketPlayOutWorldParticles; public enum Eff_1_7_R4 { - HUGE_EXPLOSION("hugeexplosion"), - LARGE_EXPLODE("largeexplode"), - FIREWORKS_SPARK("fireworksSpark"), - BUBBLE("bubble"), - SUSPEND("susgpend"), - DEPTH_SUSPEND("depthSuspend"), - TOWN_AURA("townaura"), - CRIT("crit"), - MAGIC_CRIT("magicCrit"), - MOB_SPELL("mobSpell"), - MOB_SPELL_AMBIENT("mobSpellAmbient"), - SPELL("spell"), - INSTANT_SPELL("instantSpell"), - WITCH_MAGIC("witchMagic"), - NOTE("note"), - PORTAL("portal"), - ENCHANTMENT_TABLE("enchantmenttable"), - EXPLODE("explode"), - FLAME("flame"), - LAVA("lava"), - FOOTSTEP("footstep"), - SPLASH("splash"), - LARGE_SMOKE("largesmoke"), - CLOUD("cloud"), - RED_DUST("reddust"), - SNOWBALL_POOF("snowballpoof"), - DRIP_WATER("dripWater"), - DRIP_LAVA("dripLava"), - SNOW_SHOVEL("snowshovel"), - SLIME("slime"), - HEART("heart"), - ANGRY_VILLAGER("angryVillager"), - HAPPY_VILLAGER("happyVillager"), - ICONCRACK("iconcrack_"), - TILECRACK("tilecrack_"); + HUGE_EXPLOSION("hugeexplosion"), + LARGE_EXPLODE("largeexplode"), + FIREWORKS_SPARK("fireworksSpark"), + BUBBLE("bubble"), + SUSPEND("susgpend"), + DEPTH_SUSPEND("depthSuspend"), + TOWN_AURA("townaura"), + CRIT("crit"), + MAGIC_CRIT("magicCrit"), + MOB_SPELL("mobSpell"), + MOB_SPELL_AMBIENT("mobSpellAmbient"), + SPELL("spell"), + INSTANT_SPELL("instantSpell"), + WITCH_MAGIC("witchMagic"), + NOTE("note"), + PORTAL("portal"), + ENCHANTMENT_TABLE("enchantmenttable"), + EXPLODE("explode"), + FLAME("flame"), + LAVA("lava"), + FOOTSTEP("footstep"), + SPLASH("splash"), + LARGE_SMOKE("largesmoke"), + CLOUD("cloud"), + RED_DUST("reddust"), + SNOWBALL_POOF("snowballpoof"), + DRIP_WATER("dripWater"), + DRIP_LAVA("dripLava"), + SNOW_SHOVEL("snowshovel"), + SLIME("slime"), + HEART("heart"), + ANGRY_VILLAGER("angryVillager"), + HAPPY_VILLAGER("happyVillager"), + ICONCRACK("iconcrack_"), + TILECRACK("tilecrack_"); - private final String particleName; + private final String particleName; - Eff_1_7_R4(String particleName) { - this.particleName = particleName; - } - - public void sendToPlayer(Player player, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count) throws Exception { - PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleName, - (float) location.getX(), - (float) location.getY(), - (float) location.getZ(), - offsetX, - offsetY, - offsetZ, - speed, - count); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); - } + Eff_1_7_R4(String particleName) { + this.particleName = particleName; + } + public void sendToPlayer(Player player, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count) throws Exception { + PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleName, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count); + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); + } } diff --git a/src/main/java/me/blackvein/particles/Eff_1_8_R1.java b/src/main/java/me/blackvein/particles/Eff_1_8_R1.java index 36720353c..c28b7dd08 100644 --- a/src/main/java/me/blackvein/particles/Eff_1_8_R1.java +++ b/src/main/java/me/blackvein/particles/Eff_1_8_R1.java @@ -8,69 +8,58 @@ import net.minecraft.server.v1_8_R1.EnumParticle; import net.minecraft.server.v1_8_R1.PacketPlayOutWorldParticles; public enum Eff_1_8_R1 { - + EXPLOSION(EnumParticle.EXPLOSION_NORMAL), EXPLOSION_LARGE(EnumParticle.EXPLOSION_LARGE), - EXPLOSION_HUGE(EnumParticle.EXPLOSION_HUGE), - FIREWORKS_SPARK(EnumParticle.FIREWORKS_SPARK), - BUBBLE(EnumParticle.WATER_BUBBLE), - WAKE(EnumParticle.WATER_WAKE), - SPLASH(EnumParticle.WATER_SPLASH), - SUSPENDED(EnumParticle.SUSPENDED), - DEPTH_SUSPEND(EnumParticle.SUSPENDED_DEPTH), - CRIT(EnumParticle.CRIT), - MAGIC_CRIT(EnumParticle.CRIT_MAGIC), - SMOKE(EnumParticle.SMOKE_NORMAL), - LARGE_SMOKE(EnumParticle.SMOKE_LARGE), - SPELL(EnumParticle.SPELL), - INSTANT_SPELL(EnumParticle.SPELL_INSTANT), - MOB_SPELL(EnumParticle.SPELL_MOB), - MOB_SPELL_AMBIENT(EnumParticle.SPELL_MOB_AMBIENT), - WITCH_MAGIC(EnumParticle.SPELL_WITCH), - DRIP_WATER(EnumParticle.DRIP_WATER), - DRIP_LAVA(EnumParticle.DRIP_LAVA), - ANGRY_VILLAGER(EnumParticle.VILLAGER_ANGRY), - HAPPY_VILLAGER(EnumParticle.VILLAGER_HAPPY), - TOWN_AURA(EnumParticle.TOWN_AURA), - NOTE(EnumParticle.NOTE), - PORTAL(EnumParticle.PORTAL), - ENCHANTMENT_TABLE(EnumParticle.ENCHANTMENT_TABLE), - FLAME(EnumParticle.FLAME), - LAVA(EnumParticle.LAVA), - FOOTSTEP(EnumParticle.FOOTSTEP), - CLOUD(EnumParticle.CLOUD), - RED_DUST(EnumParticle.REDSTONE), - SNOWBALL_POOF(EnumParticle.SNOWBALL), - SNOW_SHOVEL(EnumParticle.SNOW_SHOVEL), - SLIME(EnumParticle.SLIME), - HEART(EnumParticle.HEART), - BARRIER(EnumParticle.BARRIER), - ICONCRACK_(EnumParticle.ITEM_CRACK), - BLOCKCRACK_(EnumParticle.BLOCK_CRACK), - BLOCKDUST_(EnumParticle.BLOCK_DUST), + EXPLOSION_HUGE(EnumParticle.EXPLOSION_HUGE), + FIREWORKS_SPARK(EnumParticle.FIREWORKS_SPARK), + BUBBLE(EnumParticle.WATER_BUBBLE), + WAKE(EnumParticle.WATER_WAKE), + SPLASH(EnumParticle.WATER_SPLASH), + SUSPENDED(EnumParticle.SUSPENDED), + DEPTH_SUSPEND(EnumParticle.SUSPENDED_DEPTH), + CRIT(EnumParticle.CRIT), + MAGIC_CRIT(EnumParticle.CRIT_MAGIC), + SMOKE(EnumParticle.SMOKE_NORMAL), + LARGE_SMOKE(EnumParticle.SMOKE_LARGE), + SPELL(EnumParticle.SPELL), + INSTANT_SPELL(EnumParticle.SPELL_INSTANT), + MOB_SPELL(EnumParticle.SPELL_MOB), + MOB_SPELL_AMBIENT(EnumParticle.SPELL_MOB_AMBIENT), + WITCH_MAGIC(EnumParticle.SPELL_WITCH), + DRIP_WATER(EnumParticle.DRIP_WATER), + DRIP_LAVA(EnumParticle.DRIP_LAVA), + ANGRY_VILLAGER(EnumParticle.VILLAGER_ANGRY), + HAPPY_VILLAGER(EnumParticle.VILLAGER_HAPPY), + TOWN_AURA(EnumParticle.TOWN_AURA), + NOTE(EnumParticle.NOTE), + PORTAL(EnumParticle.PORTAL), + ENCHANTMENT_TABLE(EnumParticle.ENCHANTMENT_TABLE), + FLAME(EnumParticle.FLAME), + LAVA(EnumParticle.LAVA), + FOOTSTEP(EnumParticle.FOOTSTEP), + CLOUD(EnumParticle.CLOUD), + RED_DUST(EnumParticle.REDSTONE), + SNOWBALL_POOF(EnumParticle.SNOWBALL), + SNOW_SHOVEL(EnumParticle.SNOW_SHOVEL), + SLIME(EnumParticle.SLIME), + HEART(EnumParticle.HEART), + BARRIER(EnumParticle.BARRIER), + ICONCRACK_(EnumParticle.ITEM_CRACK), + BLOCKCRACK_(EnumParticle.BLOCK_CRACK), + BLOCKDUST_(EnumParticle.BLOCK_DUST), DROPLET(EnumParticle.WATER_DROP), TAKE(EnumParticle.ITEM_TAKE), MOB_APPEARANCE(EnumParticle.MOB_APPEARANCE); - private final EnumParticle particleEnum; + private final EnumParticle particleEnum; - Eff_1_8_R1(EnumParticle particleEnum) { - this.particleEnum = particleEnum; - } + Eff_1_8_R1(EnumParticle particleEnum) { + this.particleEnum = particleEnum; + } - public void sendToPlayer(Player player, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count, int[] data) throws Exception { - PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleEnum, - false, - (float) location.getX(), - (float) location.getY(), - (float) location.getZ(), - offsetX, - offsetY, - offsetZ, - speed, - count, - data); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); - } - + public void sendToPlayer(Player player, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count, int[] data) throws Exception { + PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleEnum, false, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count, data); + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); + } } diff --git a/src/main/java/me/blackvein/particles/Eff_1_8_R2.java b/src/main/java/me/blackvein/particles/Eff_1_8_R2.java index 8bf1c5e2d..381dff463 100644 --- a/src/main/java/me/blackvein/particles/Eff_1_8_R2.java +++ b/src/main/java/me/blackvein/particles/Eff_1_8_R2.java @@ -8,69 +8,58 @@ import net.minecraft.server.v1_8_R2.EnumParticle; import net.minecraft.server.v1_8_R2.PacketPlayOutWorldParticles; public enum Eff_1_8_R2 { - + EXPLOSION(EnumParticle.EXPLOSION_NORMAL), EXPLOSION_LARGE(EnumParticle.EXPLOSION_LARGE), - EXPLOSION_HUGE(EnumParticle.EXPLOSION_HUGE), - FIREWORKS_SPARK(EnumParticle.FIREWORKS_SPARK), - BUBBLE(EnumParticle.WATER_BUBBLE), - WAKE(EnumParticle.WATER_WAKE), - SPLASH(EnumParticle.WATER_SPLASH), - SUSPENDED(EnumParticle.SUSPENDED), - DEPTH_SUSPEND(EnumParticle.SUSPENDED_DEPTH), - CRIT(EnumParticle.CRIT), - MAGIC_CRIT(EnumParticle.CRIT_MAGIC), - SMOKE(EnumParticle.SMOKE_NORMAL), - LARGE_SMOKE(EnumParticle.SMOKE_LARGE), - SPELL(EnumParticle.SPELL), - INSTANT_SPELL(EnumParticle.SPELL_INSTANT), - MOB_SPELL(EnumParticle.SPELL_MOB), - MOB_SPELL_AMBIENT(EnumParticle.SPELL_MOB_AMBIENT), - WITCH_MAGIC(EnumParticle.SPELL_WITCH), - DRIP_WATER(EnumParticle.DRIP_WATER), - DRIP_LAVA(EnumParticle.DRIP_LAVA), - ANGRY_VILLAGER(EnumParticle.VILLAGER_ANGRY), - HAPPY_VILLAGER(EnumParticle.VILLAGER_HAPPY), - TOWN_AURA(EnumParticle.TOWN_AURA), - NOTE(EnumParticle.NOTE), - PORTAL(EnumParticle.PORTAL), - ENCHANTMENT_TABLE(EnumParticle.ENCHANTMENT_TABLE), - FLAME(EnumParticle.FLAME), - LAVA(EnumParticle.LAVA), - FOOTSTEP(EnumParticle.FOOTSTEP), - CLOUD(EnumParticle.CLOUD), - RED_DUST(EnumParticle.REDSTONE), - SNOWBALL_POOF(EnumParticle.SNOWBALL), - SNOW_SHOVEL(EnumParticle.SNOW_SHOVEL), - SLIME(EnumParticle.SLIME), - HEART(EnumParticle.HEART), - BARRIER(EnumParticle.BARRIER), - ICONCRACK_(EnumParticle.ITEM_CRACK), - BLOCKCRACK_(EnumParticle.BLOCK_CRACK), - BLOCKDUST_(EnumParticle.BLOCK_DUST), + EXPLOSION_HUGE(EnumParticle.EXPLOSION_HUGE), + FIREWORKS_SPARK(EnumParticle.FIREWORKS_SPARK), + BUBBLE(EnumParticle.WATER_BUBBLE), + WAKE(EnumParticle.WATER_WAKE), + SPLASH(EnumParticle.WATER_SPLASH), + SUSPENDED(EnumParticle.SUSPENDED), + DEPTH_SUSPEND(EnumParticle.SUSPENDED_DEPTH), + CRIT(EnumParticle.CRIT), + MAGIC_CRIT(EnumParticle.CRIT_MAGIC), + SMOKE(EnumParticle.SMOKE_NORMAL), + LARGE_SMOKE(EnumParticle.SMOKE_LARGE), + SPELL(EnumParticle.SPELL), + INSTANT_SPELL(EnumParticle.SPELL_INSTANT), + MOB_SPELL(EnumParticle.SPELL_MOB), + MOB_SPELL_AMBIENT(EnumParticle.SPELL_MOB_AMBIENT), + WITCH_MAGIC(EnumParticle.SPELL_WITCH), + DRIP_WATER(EnumParticle.DRIP_WATER), + DRIP_LAVA(EnumParticle.DRIP_LAVA), + ANGRY_VILLAGER(EnumParticle.VILLAGER_ANGRY), + HAPPY_VILLAGER(EnumParticle.VILLAGER_HAPPY), + TOWN_AURA(EnumParticle.TOWN_AURA), + NOTE(EnumParticle.NOTE), + PORTAL(EnumParticle.PORTAL), + ENCHANTMENT_TABLE(EnumParticle.ENCHANTMENT_TABLE), + FLAME(EnumParticle.FLAME), + LAVA(EnumParticle.LAVA), + FOOTSTEP(EnumParticle.FOOTSTEP), + CLOUD(EnumParticle.CLOUD), + RED_DUST(EnumParticle.REDSTONE), + SNOWBALL_POOF(EnumParticle.SNOWBALL), + SNOW_SHOVEL(EnumParticle.SNOW_SHOVEL), + SLIME(EnumParticle.SLIME), + HEART(EnumParticle.HEART), + BARRIER(EnumParticle.BARRIER), + ICONCRACK_(EnumParticle.ITEM_CRACK), + BLOCKCRACK_(EnumParticle.BLOCK_CRACK), + BLOCKDUST_(EnumParticle.BLOCK_DUST), DROPLET(EnumParticle.WATER_DROP), TAKE(EnumParticle.ITEM_TAKE), MOB_APPEARANCE(EnumParticle.MOB_APPEARANCE); - private final EnumParticle particleEnum; + private final EnumParticle particleEnum; - Eff_1_8_R2(EnumParticle particleEnum) { - this.particleEnum = particleEnum; - } + Eff_1_8_R2(EnumParticle particleEnum) { + this.particleEnum = particleEnum; + } - public void sendToPlayer(Player player, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count, int[] data) throws Exception { - PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleEnum, - false, - (float) location.getX(), - (float) location.getY(), - (float) location.getZ(), - offsetX, - offsetY, - offsetZ, - speed, - count, - data); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); - } - + public void sendToPlayer(Player player, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count, int[] data) throws Exception { + PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleEnum, false, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count, data); + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); + } } diff --git a/src/main/java/me/blackvein/particles/Eff_1_8_R3.java b/src/main/java/me/blackvein/particles/Eff_1_8_R3.java index 28c75bfde..af3300882 100644 --- a/src/main/java/me/blackvein/particles/Eff_1_8_R3.java +++ b/src/main/java/me/blackvein/particles/Eff_1_8_R3.java @@ -8,69 +8,58 @@ import net.minecraft.server.v1_8_R3.EnumParticle; import net.minecraft.server.v1_8_R3.PacketPlayOutWorldParticles; public enum Eff_1_8_R3 { - + EXPLOSION(EnumParticle.EXPLOSION_NORMAL), EXPLOSION_LARGE(EnumParticle.EXPLOSION_LARGE), - EXPLOSION_HUGE(EnumParticle.EXPLOSION_HUGE), - FIREWORKS_SPARK(EnumParticle.FIREWORKS_SPARK), - BUBBLE(EnumParticle.WATER_BUBBLE), - WAKE(EnumParticle.WATER_WAKE), - SPLASH(EnumParticle.WATER_SPLASH), - SUSPENDED(EnumParticle.SUSPENDED), - DEPTH_SUSPEND(EnumParticle.SUSPENDED_DEPTH), - CRIT(EnumParticle.CRIT), - MAGIC_CRIT(EnumParticle.CRIT_MAGIC), - SMOKE(EnumParticle.SMOKE_NORMAL), - LARGE_SMOKE(EnumParticle.SMOKE_LARGE), - SPELL(EnumParticle.SPELL), - INSTANT_SPELL(EnumParticle.SPELL_INSTANT), - MOB_SPELL(EnumParticle.SPELL_MOB), - MOB_SPELL_AMBIENT(EnumParticle.SPELL_MOB_AMBIENT), - WITCH_MAGIC(EnumParticle.SPELL_WITCH), - DRIP_WATER(EnumParticle.DRIP_WATER), - DRIP_LAVA(EnumParticle.DRIP_LAVA), - ANGRY_VILLAGER(EnumParticle.VILLAGER_ANGRY), - HAPPY_VILLAGER(EnumParticle.VILLAGER_HAPPY), - TOWN_AURA(EnumParticle.TOWN_AURA), - NOTE(EnumParticle.NOTE), - PORTAL(EnumParticle.PORTAL), - ENCHANTMENT_TABLE(EnumParticle.ENCHANTMENT_TABLE), - FLAME(EnumParticle.FLAME), - LAVA(EnumParticle.LAVA), - FOOTSTEP(EnumParticle.FOOTSTEP), - CLOUD(EnumParticle.CLOUD), - RED_DUST(EnumParticle.REDSTONE), - SNOWBALL_POOF(EnumParticle.SNOWBALL), - SNOW_SHOVEL(EnumParticle.SNOW_SHOVEL), - SLIME(EnumParticle.SLIME), - HEART(EnumParticle.HEART), - BARRIER(EnumParticle.BARRIER), - ICONCRACK_(EnumParticle.ITEM_CRACK), - BLOCKCRACK_(EnumParticle.BLOCK_CRACK), - BLOCKDUST_(EnumParticle.BLOCK_DUST), + EXPLOSION_HUGE(EnumParticle.EXPLOSION_HUGE), + FIREWORKS_SPARK(EnumParticle.FIREWORKS_SPARK), + BUBBLE(EnumParticle.WATER_BUBBLE), + WAKE(EnumParticle.WATER_WAKE), + SPLASH(EnumParticle.WATER_SPLASH), + SUSPENDED(EnumParticle.SUSPENDED), + DEPTH_SUSPEND(EnumParticle.SUSPENDED_DEPTH), + CRIT(EnumParticle.CRIT), + MAGIC_CRIT(EnumParticle.CRIT_MAGIC), + SMOKE(EnumParticle.SMOKE_NORMAL), + LARGE_SMOKE(EnumParticle.SMOKE_LARGE), + SPELL(EnumParticle.SPELL), + INSTANT_SPELL(EnumParticle.SPELL_INSTANT), + MOB_SPELL(EnumParticle.SPELL_MOB), + MOB_SPELL_AMBIENT(EnumParticle.SPELL_MOB_AMBIENT), + WITCH_MAGIC(EnumParticle.SPELL_WITCH), + DRIP_WATER(EnumParticle.DRIP_WATER), + DRIP_LAVA(EnumParticle.DRIP_LAVA), + ANGRY_VILLAGER(EnumParticle.VILLAGER_ANGRY), + HAPPY_VILLAGER(EnumParticle.VILLAGER_HAPPY), + TOWN_AURA(EnumParticle.TOWN_AURA), + NOTE(EnumParticle.NOTE), + PORTAL(EnumParticle.PORTAL), + ENCHANTMENT_TABLE(EnumParticle.ENCHANTMENT_TABLE), + FLAME(EnumParticle.FLAME), + LAVA(EnumParticle.LAVA), + FOOTSTEP(EnumParticle.FOOTSTEP), + CLOUD(EnumParticle.CLOUD), + RED_DUST(EnumParticle.REDSTONE), + SNOWBALL_POOF(EnumParticle.SNOWBALL), + SNOW_SHOVEL(EnumParticle.SNOW_SHOVEL), + SLIME(EnumParticle.SLIME), + HEART(EnumParticle.HEART), + BARRIER(EnumParticle.BARRIER), + ICONCRACK_(EnumParticle.ITEM_CRACK), + BLOCKCRACK_(EnumParticle.BLOCK_CRACK), + BLOCKDUST_(EnumParticle.BLOCK_DUST), DROPLET(EnumParticle.WATER_DROP), TAKE(EnumParticle.ITEM_TAKE), MOB_APPEARANCE(EnumParticle.MOB_APPEARANCE); - private final EnumParticle particleEnum; + private final EnumParticle particleEnum; - Eff_1_8_R3(EnumParticle particleEnum) { - this.particleEnum = particleEnum; - } + Eff_1_8_R3(EnumParticle particleEnum) { + this.particleEnum = particleEnum; + } - public void sendToPlayer(Player player, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count, int[] data) throws Exception { - PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleEnum, - false, - (float) location.getX(), - (float) location.getY(), - (float) location.getZ(), - offsetX, - offsetY, - offsetZ, - speed, - count, - data); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); - } - + public void sendToPlayer(Player player, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count, int[] data) throws Exception { + PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleEnum, false, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count, data); + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); + } } \ No newline at end of file diff --git a/src/main/java/me/blackvein/particles/Eff_1_9_R1.java b/src/main/java/me/blackvein/particles/Eff_1_9_R1.java index 10cccde94..295e44ca1 100644 --- a/src/main/java/me/blackvein/particles/Eff_1_9_R1.java +++ b/src/main/java/me/blackvein/particles/Eff_1_9_R1.java @@ -8,46 +8,46 @@ import net.minecraft.server.v1_9_R1.EnumParticle; import net.minecraft.server.v1_9_R1.PacketPlayOutWorldParticles; public enum Eff_1_9_R1 { - + EXPLOSION(EnumParticle.EXPLOSION_NORMAL), EXPLOSION_LARGE(EnumParticle.EXPLOSION_LARGE), - EXPLOSION_HUGE(EnumParticle.EXPLOSION_HUGE), - FIREWORKS_SPARK(EnumParticle.FIREWORKS_SPARK), - BUBBLE(EnumParticle.WATER_BUBBLE), - WAKE(EnumParticle.WATER_WAKE), - SPLASH(EnumParticle.WATER_SPLASH), - SUSPENDED(EnumParticle.SUSPENDED), - DEPTH_SUSPEND(EnumParticle.SUSPENDED_DEPTH), - CRIT(EnumParticle.CRIT), - MAGIC_CRIT(EnumParticle.CRIT_MAGIC), - SMOKE(EnumParticle.SMOKE_NORMAL), - LARGE_SMOKE(EnumParticle.SMOKE_LARGE), - SPELL(EnumParticle.SPELL), - INSTANT_SPELL(EnumParticle.SPELL_INSTANT), - MOB_SPELL(EnumParticle.SPELL_MOB), - MOB_SPELL_AMBIENT(EnumParticle.SPELL_MOB_AMBIENT), - WITCH_MAGIC(EnumParticle.SPELL_WITCH), - DRIP_WATER(EnumParticle.DRIP_WATER), - DRIP_LAVA(EnumParticle.DRIP_LAVA), - ANGRY_VILLAGER(EnumParticle.VILLAGER_ANGRY), - HAPPY_VILLAGER(EnumParticle.VILLAGER_HAPPY), - TOWN_AURA(EnumParticle.TOWN_AURA), - NOTE(EnumParticle.NOTE), - PORTAL(EnumParticle.PORTAL), - ENCHANTMENT_TABLE(EnumParticle.ENCHANTMENT_TABLE), - FLAME(EnumParticle.FLAME), - LAVA(EnumParticle.LAVA), - FOOTSTEP(EnumParticle.FOOTSTEP), - CLOUD(EnumParticle.CLOUD), - RED_DUST(EnumParticle.REDSTONE), - SNOWBALL_POOF(EnumParticle.SNOWBALL), - SNOW_SHOVEL(EnumParticle.SNOW_SHOVEL), - SLIME(EnumParticle.SLIME), - HEART(EnumParticle.HEART), - BARRIER(EnumParticle.BARRIER), - ICONCRACK_(EnumParticle.ITEM_CRACK), - BLOCKCRACK_(EnumParticle.BLOCK_CRACK), - BLOCKDUST_(EnumParticle.BLOCK_DUST), + EXPLOSION_HUGE(EnumParticle.EXPLOSION_HUGE), + FIREWORKS_SPARK(EnumParticle.FIREWORKS_SPARK), + BUBBLE(EnumParticle.WATER_BUBBLE), + WAKE(EnumParticle.WATER_WAKE), + SPLASH(EnumParticle.WATER_SPLASH), + SUSPENDED(EnumParticle.SUSPENDED), + DEPTH_SUSPEND(EnumParticle.SUSPENDED_DEPTH), + CRIT(EnumParticle.CRIT), + MAGIC_CRIT(EnumParticle.CRIT_MAGIC), + SMOKE(EnumParticle.SMOKE_NORMAL), + LARGE_SMOKE(EnumParticle.SMOKE_LARGE), + SPELL(EnumParticle.SPELL), + INSTANT_SPELL(EnumParticle.SPELL_INSTANT), + MOB_SPELL(EnumParticle.SPELL_MOB), + MOB_SPELL_AMBIENT(EnumParticle.SPELL_MOB_AMBIENT), + WITCH_MAGIC(EnumParticle.SPELL_WITCH), + DRIP_WATER(EnumParticle.DRIP_WATER), + DRIP_LAVA(EnumParticle.DRIP_LAVA), + ANGRY_VILLAGER(EnumParticle.VILLAGER_ANGRY), + HAPPY_VILLAGER(EnumParticle.VILLAGER_HAPPY), + TOWN_AURA(EnumParticle.TOWN_AURA), + NOTE(EnumParticle.NOTE), + PORTAL(EnumParticle.PORTAL), + ENCHANTMENT_TABLE(EnumParticle.ENCHANTMENT_TABLE), + FLAME(EnumParticle.FLAME), + LAVA(EnumParticle.LAVA), + FOOTSTEP(EnumParticle.FOOTSTEP), + CLOUD(EnumParticle.CLOUD), + RED_DUST(EnumParticle.REDSTONE), + SNOWBALL_POOF(EnumParticle.SNOWBALL), + SNOW_SHOVEL(EnumParticle.SNOW_SHOVEL), + SLIME(EnumParticle.SLIME), + HEART(EnumParticle.HEART), + BARRIER(EnumParticle.BARRIER), + ICONCRACK_(EnumParticle.ITEM_CRACK), + BLOCKCRACK_(EnumParticle.BLOCK_CRACK), + BLOCKDUST_(EnumParticle.BLOCK_DUST), DROPLET(EnumParticle.WATER_DROP), TAKE(EnumParticle.ITEM_TAKE), MOB_APPEARANCE(EnumParticle.MOB_APPEARANCE), @@ -56,25 +56,14 @@ public enum Eff_1_9_R1 { ENDROD(EnumParticle.END_ROD), DAMAGE_INDICATOR(EnumParticle.DAMAGE_INDICATOR),; - private final EnumParticle particleEnum; + private final EnumParticle particleEnum; - Eff_1_9_R1(EnumParticle particleEnum) { - this.particleEnum = particleEnum; - } + Eff_1_9_R1(EnumParticle particleEnum) { + this.particleEnum = particleEnum; + } - public void sendToPlayer(Player player, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count, int[] data) throws Exception { - PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleEnum, - false, - (float) location.getX(), - (float) location.getY(), - (float) location.getZ(), - offsetX, - offsetY, - offsetZ, - speed, - count, - data); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); - } - + public void sendToPlayer(Player player, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count, int[] data) throws Exception { + PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleEnum, false, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count, data); + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); + } } \ No newline at end of file diff --git a/src/main/java/me/blackvein/particles/Eff_1_9_R2.java b/src/main/java/me/blackvein/particles/Eff_1_9_R2.java index db55891cd..5b10f8b1e 100644 --- a/src/main/java/me/blackvein/particles/Eff_1_9_R2.java +++ b/src/main/java/me/blackvein/particles/Eff_1_9_R2.java @@ -8,46 +8,46 @@ import net.minecraft.server.v1_9_R2.EnumParticle; import net.minecraft.server.v1_9_R2.PacketPlayOutWorldParticles; public enum Eff_1_9_R2 { - + EXPLOSION(EnumParticle.EXPLOSION_NORMAL), EXPLOSION_LARGE(EnumParticle.EXPLOSION_LARGE), - EXPLOSION_HUGE(EnumParticle.EXPLOSION_HUGE), - FIREWORKS_SPARK(EnumParticle.FIREWORKS_SPARK), - BUBBLE(EnumParticle.WATER_BUBBLE), - WAKE(EnumParticle.WATER_WAKE), - SPLASH(EnumParticle.WATER_SPLASH), - SUSPENDED(EnumParticle.SUSPENDED), - DEPTH_SUSPEND(EnumParticle.SUSPENDED_DEPTH), - CRIT(EnumParticle.CRIT), - MAGIC_CRIT(EnumParticle.CRIT_MAGIC), - SMOKE(EnumParticle.SMOKE_NORMAL), - LARGE_SMOKE(EnumParticle.SMOKE_LARGE), - SPELL(EnumParticle.SPELL), - INSTANT_SPELL(EnumParticle.SPELL_INSTANT), - MOB_SPELL(EnumParticle.SPELL_MOB), - MOB_SPELL_AMBIENT(EnumParticle.SPELL_MOB_AMBIENT), - WITCH_MAGIC(EnumParticle.SPELL_WITCH), - DRIP_WATER(EnumParticle.DRIP_WATER), - DRIP_LAVA(EnumParticle.DRIP_LAVA), - ANGRY_VILLAGER(EnumParticle.VILLAGER_ANGRY), - HAPPY_VILLAGER(EnumParticle.VILLAGER_HAPPY), - TOWN_AURA(EnumParticle.TOWN_AURA), - NOTE(EnumParticle.NOTE), - PORTAL(EnumParticle.PORTAL), - ENCHANTMENT_TABLE(EnumParticle.ENCHANTMENT_TABLE), - FLAME(EnumParticle.FLAME), - LAVA(EnumParticle.LAVA), - FOOTSTEP(EnumParticle.FOOTSTEP), - CLOUD(EnumParticle.CLOUD), - RED_DUST(EnumParticle.REDSTONE), - SNOWBALL_POOF(EnumParticle.SNOWBALL), - SNOW_SHOVEL(EnumParticle.SNOW_SHOVEL), - SLIME(EnumParticle.SLIME), - HEART(EnumParticle.HEART), - BARRIER(EnumParticle.BARRIER), - ICONCRACK_(EnumParticle.ITEM_CRACK), - BLOCKCRACK_(EnumParticle.BLOCK_CRACK), - BLOCKDUST_(EnumParticle.BLOCK_DUST), + EXPLOSION_HUGE(EnumParticle.EXPLOSION_HUGE), + FIREWORKS_SPARK(EnumParticle.FIREWORKS_SPARK), + BUBBLE(EnumParticle.WATER_BUBBLE), + WAKE(EnumParticle.WATER_WAKE), + SPLASH(EnumParticle.WATER_SPLASH), + SUSPENDED(EnumParticle.SUSPENDED), + DEPTH_SUSPEND(EnumParticle.SUSPENDED_DEPTH), + CRIT(EnumParticle.CRIT), + MAGIC_CRIT(EnumParticle.CRIT_MAGIC), + SMOKE(EnumParticle.SMOKE_NORMAL), + LARGE_SMOKE(EnumParticle.SMOKE_LARGE), + SPELL(EnumParticle.SPELL), + INSTANT_SPELL(EnumParticle.SPELL_INSTANT), + MOB_SPELL(EnumParticle.SPELL_MOB), + MOB_SPELL_AMBIENT(EnumParticle.SPELL_MOB_AMBIENT), + WITCH_MAGIC(EnumParticle.SPELL_WITCH), + DRIP_WATER(EnumParticle.DRIP_WATER), + DRIP_LAVA(EnumParticle.DRIP_LAVA), + ANGRY_VILLAGER(EnumParticle.VILLAGER_ANGRY), + HAPPY_VILLAGER(EnumParticle.VILLAGER_HAPPY), + TOWN_AURA(EnumParticle.TOWN_AURA), + NOTE(EnumParticle.NOTE), + PORTAL(EnumParticle.PORTAL), + ENCHANTMENT_TABLE(EnumParticle.ENCHANTMENT_TABLE), + FLAME(EnumParticle.FLAME), + LAVA(EnumParticle.LAVA), + FOOTSTEP(EnumParticle.FOOTSTEP), + CLOUD(EnumParticle.CLOUD), + RED_DUST(EnumParticle.REDSTONE), + SNOWBALL_POOF(EnumParticle.SNOWBALL), + SNOW_SHOVEL(EnumParticle.SNOW_SHOVEL), + SLIME(EnumParticle.SLIME), + HEART(EnumParticle.HEART), + BARRIER(EnumParticle.BARRIER), + ICONCRACK_(EnumParticle.ITEM_CRACK), + BLOCKCRACK_(EnumParticle.BLOCK_CRACK), + BLOCKDUST_(EnumParticle.BLOCK_DUST), DROPLET(EnumParticle.WATER_DROP), TAKE(EnumParticle.ITEM_TAKE), MOB_APPEARANCE(EnumParticle.MOB_APPEARANCE), @@ -56,25 +56,14 @@ public enum Eff_1_9_R2 { ENDROD(EnumParticle.END_ROD), DAMAGE_INDICATOR(EnumParticle.DAMAGE_INDICATOR),; - private final EnumParticle particleEnum; + private final EnumParticle particleEnum; - Eff_1_9_R2(EnumParticle particleEnum) { - this.particleEnum = particleEnum; - } + Eff_1_9_R2(EnumParticle particleEnum) { + this.particleEnum = particleEnum; + } - public void sendToPlayer(Player player, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count, int[] data) throws Exception { - PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleEnum, - false, - (float) location.getX(), - (float) location.getY(), - (float) location.getZ(), - offsetX, - offsetY, - offsetZ, - speed, - count, - data); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); - } - + public void sendToPlayer(Player player, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count, int[] data) throws Exception { + PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleEnum, false, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count, data); + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); + } } \ No newline at end of file diff --git a/src/main/java/me/blackvein/quests/CustomObjective.java b/src/main/java/me/blackvein/quests/CustomObjective.java index 7eab3fa98..5b3198ef9 100644 --- a/src/main/java/me/blackvein/quests/CustomObjective.java +++ b/src/main/java/me/blackvein/quests/CustomObjective.java @@ -8,227 +8,183 @@ import org.bukkit.event.Listener; public abstract class CustomObjective implements Listener { - private String name = null; - private String author = null; - public final Map datamap = new HashMap(); - public final Map descriptions = new HashMap(); - private String countPrompt = "null"; - private String display = "null"; - private boolean enableCount = true; - private boolean showCount = true; - private int count = 1; + private String name = null; + private String author = null; + public final Map datamap = new HashMap(); + public final Map descriptions = new HashMap(); + private String countPrompt = "null"; + private String display = "null"; + private boolean enableCount = true; + private boolean showCount = true; + private int count = 1; - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } - public String getAuthor() { - return author; - } + public String getAuthor() { + return author; + } - public void setAuthor(String author) { - this.author = author; - } + public void setAuthor(String author) { + this.author = author; + } - public void addData(String name) { - datamap.put(name, null); - } + public void addData(String name) { + datamap.put(name, null); + } - public void addDescription(String data, String description) { - descriptions.put(data, description); - } + public void addDescription(String data, String description) { + descriptions.put(data, description); + } - public int getCount() { - return count; - } + public int getCount() { + return count; + } - public void setCount(int count) { - this.count = count; - } + public void setCount(int count) { + this.count = count; + } - public String getCountPrompt() { - return countPrompt; - } + public String getCountPrompt() { + return countPrompt; + } - public void setCountPrompt(String countPrompt) { - this.countPrompt = countPrompt; - } + public void setCountPrompt(String countPrompt) { + this.countPrompt = countPrompt; + } - public boolean isCountShown() { - return showCount; - } + public boolean isCountShown() { + return showCount; + } - public void setShowCount(boolean showCount) { - this.showCount = showCount; - } + public void setShowCount(boolean showCount) { + this.showCount = showCount; + } - public String getDisplay() { - return display; - } + public String getDisplay() { + return display; + } - public void setDisplay(String display) { - this.display = display; - } + public void setDisplay(String display) { + this.display = display; + } - public boolean isEnableCount() { - return enableCount; - } + public boolean isEnableCount() { + return enableCount; + } - public void setEnableCount(boolean enableCount) { - this.enableCount = enableCount; - } + public void setEnableCount(boolean enableCount) { + this.enableCount = enableCount; + } - public static Map getDatamap(Player player, CustomObjective obj, Quest quest) { + public static Map getDatamap(Player player, CustomObjective obj, Quest quest) { + Quester quester = Quests.getInstance().getQuester(player.getUniqueId()); + if (quester != null) { + Stage currentStage = quester.getCurrentStage(quest); + if (currentStage == null) + return null; + int index = -1; + int tempIndex = 0; + for (me.blackvein.quests.CustomObjective co : currentStage.customObjectives) { + if (co.getName().equals(obj.getName())) { + index = tempIndex; + break; + } + tempIndex++; + } + if (index > -1) { + return currentStage.customObjectiveData.get(index); + } + } + return null; + } - Quester quester = Quests.getInstance().getQuester(player.getUniqueId()); - if (quester != null) { - - Stage currentStage = quester.getCurrentStage(quest); - if (currentStage == null) return null; - - int index = -1; - int tempIndex = 0; - - - for (me.blackvein.quests.CustomObjective co : currentStage.customObjectives) { - - if (co.getName().equals(obj.getName())) { - index = tempIndex; - break; - } - - tempIndex++; - - } - - if (index > -1) { - - return currentStage.customObjectiveData.get(index); - - } - - } - - return null; - - } - - public static void incrementObjective(Player player, CustomObjective obj, int count, Quest quest) { - - Quester quester = Quests.getInstance().getQuester(player.getUniqueId()); - if (quester != null) { - - //Check if the player has Quest with objective - boolean hasQuest = false; - - for (CustomObjective co : quester.getCurrentStage(quest).customObjectives) { - - if (co.getName().equals(obj.getName())) { - hasQuest = true; - break; - } - - } - - if (hasQuest && quester.hasCustomObjective(quest, obj.getName())) { - - if (quester.getQuestData(quest).customObjectiveCounts.containsKey(obj.getName())) { - int old = quester.getQuestData(quest).customObjectiveCounts.get(obj.getName()); - Quests.getInstance().getQuester(player.getUniqueId()).getQuestData(quest).customObjectiveCounts.put(obj.getName(), old + count); - } else { - Quests.getInstance().getQuester(player.getUniqueId()).getQuestData(quest).customObjectiveCounts.put(obj.getName(), count); - } - - int index = -1; - for (int i = 0; i < quester.getCurrentStage(quest).customObjectives.size(); i++) { - if (quester.getCurrentStage(quest).customObjectives.get(i).getName().equals(obj.getName())) { - index = i; - break; - } - } - - if (index > -1) { - - if (quester.getQuestData(quest).customObjectiveCounts.get(obj.getName()) >= quester.getCurrentStage(quest).customObjectiveCounts.get(index)) { - - quester.finishObjective(quest, "customObj", null, null, null, null, null, null, null, null, null, obj); - } - - } - - } - - } - - } - - @Override - public boolean equals(Object o) { - - if (o instanceof CustomObjective) { - - CustomObjective other = (CustomObjective) o; - - if (other.name.equals(name) == false) { - return false; - } - - if (other.author.equals(name) == false) { - return false; - } - - for (String s : other.datamap.keySet()) { - if (datamap.containsKey(s) == false) { - return false; - } - } - - for (Object val : other.datamap.values()) { - if (datamap.containsValue(val) == false) { - return false; - } - } - - for (String s : other.descriptions.keySet()) { - if (descriptions.containsKey(s) == false) { - return false; - } - } - - for (String s : other.descriptions.values()) { - if (descriptions.containsValue(s) == false) { - return false; - } - } - - if (other.countPrompt.equals(countPrompt) == false) { - return false; - } - - if (other.display.equals(display) == false) { - return false; - } - - if (other.enableCount != enableCount) { - return false; - } - - if (other.showCount != showCount) { - return false; - } - - if (other.count != count) { - return false; - } - - return true; - } - - return false; - } + public static void incrementObjective(Player player, CustomObjective obj, int count, Quest quest) { + Quester quester = Quests.getInstance().getQuester(player.getUniqueId()); + if (quester != null) { + // Check if the player has Quest with objective + boolean hasQuest = false; + for (CustomObjective co : quester.getCurrentStage(quest).customObjectives) { + if (co.getName().equals(obj.getName())) { + hasQuest = true; + break; + } + } + if (hasQuest && quester.hasCustomObjective(quest, obj.getName())) { + if (quester.getQuestData(quest).customObjectiveCounts.containsKey(obj.getName())) { + int old = quester.getQuestData(quest).customObjectiveCounts.get(obj.getName()); + Quests.getInstance().getQuester(player.getUniqueId()).getQuestData(quest).customObjectiveCounts.put(obj.getName(), old + count); + } else { + Quests.getInstance().getQuester(player.getUniqueId()).getQuestData(quest).customObjectiveCounts.put(obj.getName(), count); + } + int index = -1; + for (int i = 0; i < quester.getCurrentStage(quest).customObjectives.size(); i++) { + if (quester.getCurrentStage(quest).customObjectives.get(i).getName().equals(obj.getName())) { + index = i; + break; + } + } + if (index > -1) { + if (quester.getQuestData(quest).customObjectiveCounts.get(obj.getName()) >= quester.getCurrentStage(quest).customObjectiveCounts.get(index)) { + quester.finishObjective(quest, "customObj", null, null, null, null, null, null, null, null, null, obj); + } + } + } + } + } + @Override + public boolean equals(Object o) { + if (o instanceof CustomObjective) { + CustomObjective other = (CustomObjective) o; + if (other.name.equals(name) == false) { + return false; + } + if (other.author.equals(name) == false) { + return false; + } + for (String s : other.datamap.keySet()) { + if (datamap.containsKey(s) == false) { + return false; + } + } + for (Object val : other.datamap.values()) { + if (datamap.containsValue(val) == false) { + return false; + } + } + for (String s : other.descriptions.keySet()) { + if (descriptions.containsKey(s) == false) { + return false; + } + } + for (String s : other.descriptions.values()) { + if (descriptions.containsValue(s) == false) { + return false; + } + } + if (other.countPrompt.equals(countPrompt) == false) { + return false; + } + if (other.display.equals(display) == false) { + return false; + } + if (other.enableCount != enableCount) { + return false; + } + if (other.showCount != showCount) { + return false; + } + if (other.count != count) { + return false; + } + return true; + } + return false; + } } \ No newline at end of file diff --git a/src/main/java/me/blackvein/quests/CustomRequirement.java b/src/main/java/me/blackvein/quests/CustomRequirement.java index 657bdc4d9..675eb273e 100644 --- a/src/main/java/me/blackvein/quests/CustomRequirement.java +++ b/src/main/java/me/blackvein/quests/CustomRequirement.java @@ -2,39 +2,39 @@ package me.blackvein.quests; import java.util.HashMap; import java.util.Map; + import org.bukkit.entity.Player; public abstract class CustomRequirement { - private String name = null; - private String author = null; - public final Map datamap = new HashMap(); - public final Map descriptions = new HashMap(); + private String name = null; + private String author = null; + public final Map datamap = new HashMap(); + public final Map descriptions = new HashMap(); - public abstract boolean testRequirement(Player p, Map m); + public abstract boolean testRequirement(Player p, Map m); - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } - public String getAuthor() { - return author; - } + public String getAuthor() { + return author; + } - public void setAuthor(String author) { - this.author = author; - } + public void setAuthor(String author) { + this.author = author; + } - public void addData(String name) { - datamap.put(name, null); - } - - public void addDescription(String data, String description) { - descriptions.put(data, description); - } + public void addData(String name) { + datamap.put(name, null); + } + public void addDescription(String data, String description) { + descriptions.put(data, description); + } } diff --git a/src/main/java/me/blackvein/quests/CustomReward.java b/src/main/java/me/blackvein/quests/CustomReward.java index 40cd306a5..e0655e142 100644 --- a/src/main/java/me/blackvein/quests/CustomReward.java +++ b/src/main/java/me/blackvein/quests/CustomReward.java @@ -2,48 +2,48 @@ package me.blackvein.quests; import java.util.HashMap; import java.util.Map; + import org.bukkit.entity.Player; public abstract class CustomReward { - private String name = null; - private String author = null; - private String rewardName = null; - public final Map datamap = new HashMap(); - public final Map descriptions = new HashMap(); + private String name = null; + private String author = null; + private String rewardName = null; + public final Map datamap = new HashMap(); + public final Map descriptions = new HashMap(); - public abstract void giveReward(Player p, Map m); + public abstract void giveReward(Player p, Map m); - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } - public String getAuthor() { - return author; - } + public String getAuthor() { + return author; + } - public void setAuthor(String author) { - this.author = author; - } + public void setAuthor(String author) { + this.author = author; + } - public void addData(String name) { - datamap.put(name, null); - } + public void addData(String name) { + datamap.put(name, null); + } - public void addDescription(String data, String description) { - descriptions.put(data, description); - } + public void addDescription(String data, String description) { + descriptions.put(data, description); + } - public void setRewardName(String name) { - rewardName = name; - } - - public String getRewardName() { - return rewardName; - } + public void setRewardName(String name) { + rewardName = name; + } + public String getRewardName() { + return rewardName; + } } diff --git a/src/main/java/me/blackvein/quests/Event.java b/src/main/java/me/blackvein/quests/Event.java index 61fd06ce8..584d7f085 100644 --- a/src/main/java/me/blackvein/quests/Event.java +++ b/src/main/java/me/blackvein/quests/Event.java @@ -7,9 +7,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import me.blackvein.quests.util.ItemUtil; -import me.blackvein.quests.util.QuestMob; - import org.bukkit.ChatColor; import org.bukkit.Effect; import org.bukkit.Location; @@ -23,685 +20,499 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; +import me.blackvein.quests.util.ItemUtil; +import me.blackvein.quests.util.QuestMob; + public class Event { - + Quests plugin; - String name = ""; - String message = null; - boolean clearInv = false; - boolean failQuest = false; - LinkedList explosions = new LinkedList(); - Map effects = new HashMap(); - LinkedList items = new LinkedList(); - World stormWorld = null; - int stormDuration = 0; - World thunderWorld = null; - int thunderDuration = 0; - public LinkedList mobSpawns = new LinkedList() { + String name = ""; + String message = null; + boolean clearInv = false; + boolean failQuest = false; + LinkedList explosions = new LinkedList(); + Map effects = new HashMap(); + LinkedList items = new LinkedList(); + World stormWorld = null; + int stormDuration = 0; + World thunderWorld = null; + int thunderDuration = 0; + public LinkedList mobSpawns = new LinkedList() { private static final long serialVersionUID = -761974607799449780L; @Override - public boolean equals(Object o) { - if (o instanceof LinkedList) { - - @SuppressWarnings("unchecked") + public boolean equals(Object o) { + if (o instanceof LinkedList) { + @SuppressWarnings("unchecked") LinkedList other = (LinkedList) 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 lightningStrikes = new LinkedList(); - LinkedList commands = new LinkedList(); - LinkedList potionEffects = new LinkedList(); - int hunger = -1; - int saturation = -1; - float health = -1; - Location teleport; - - public int hashCode() { - assert false : "hashCode not designed"; - return 42; // any arbitrary constant will do - } - - @Override - public boolean equals(Object o) { - - if (o instanceof Event) { - - Event other = (Event) o; - - if (other.name.equals(name) == false) { - return false; - } - - if (other.message != null && message != null) { - if (other.message.equals(message) == false) { - return false; - } - } else if (other.message != null && message == null) { - return false; - } else if (other.message == null && message != null) { - return false; - } - - if (other.clearInv != clearInv) { - return false; - } - - if (other.failQuest != failQuest) { - return false; - } - - if (other.explosions.equals(explosions) == false) { - return false; - } - - if (other.effects.entrySet().equals(effects.entrySet()) == false) { - return false; - } - - if (other.items.equals(items) == false) { - return false; - } - - if (other.stormWorld != null && stormWorld != null) { - if (other.stormWorld.equals(stormWorld) == false) { - return false; - } - } else if (other.stormWorld != null && stormWorld == null) { - return false; - } else if (other.stormWorld == null && stormWorld != null) { - return false; - } - - if (other.stormDuration != stormDuration) { - return false; - } - - if (other.thunderWorld != null && thunderWorld != null) { - if (other.thunderWorld.equals(thunderWorld) == false) { - return false; - } - } else if (other.thunderWorld != null && thunderWorld == null) { - return false; - } else if (other.thunderWorld == null && thunderWorld != null) { - return false; - } - - if (other.thunderDuration != thunderDuration) { - return false; - } - - for (QuestMob qm : mobSpawns) { - - if (qm.equals(other.mobSpawns.get(mobSpawns.indexOf(qm))) == false) { - return false; - } - - } - - if (other.lightningStrikes.equals(lightningStrikes) == false) { - return false; - } - - if (other.commands.equals(commands) == false) { - return false; - } - - if (other.potionEffects.equals(potionEffects) == false) { - return false; - } - - if (other.hunger != hunger) { - return false; - } - - if (other.saturation != saturation) { - return false; - } - - if (other.health != health) { - return false; - } - - if (other.teleport != null && teleport != null) { - if (other.teleport.equals(teleport) == false) { - return false; - } - } else if (other.teleport != null && teleport == null) { - return false; - } else if (other.teleport == null && teleport != null) { - return false; - } - - } - - return true; - } - - public String getName() { - - return name; - - } - - public void fire(Quester quester, Quest quest) { - - Player player = quester.getPlayer(); - - if (message != null) { - player.sendMessage(Quests.parseString(message, quest)); - } - - if (clearInv == true) { - player.getInventory().clear(); - } - - if (explosions.isEmpty() == false) { - - for (Location l : explosions) { - - l.getWorld().createExplosion(l, 4F, false); - - } - - } - - if (effects.isEmpty() == false) { - - for (Location l : effects.keySet()) { - - l.getWorld().playEffect(l, effects.get(l), 1); - - } - - } - - if (items.isEmpty() == false) { - - for (ItemStack is : items) { - Quests.addItem(player, is); - } - - } - - if (stormWorld != null) { - stormWorld.setStorm(true); - stormWorld.setWeatherDuration(stormDuration); - } - - if (thunderWorld != null) { - thunderWorld.setThundering(true); - thunderWorld.setThunderDuration(thunderDuration); - } - - if (mobSpawns.isEmpty() == false) { - - for (QuestMob questMob : mobSpawns) { - questMob.spawn(); - } - } - - if (lightningStrikes.isEmpty() == false) { - - for (Location l : lightningStrikes) { - - l.getWorld().strikeLightning(l); - - } - - } - - if (commands.isEmpty() == false) { - - for (String s : commands) { - quester.plugin.getServer().dispatchCommand(quester.plugin.getServer().getConsoleSender(), s.replaceAll("", quester.getPlayer().getName())); - } - - } - - if (potionEffects.isEmpty() == false) { - - for (PotionEffect p : potionEffects) { - - player.addPotionEffect(p); - - } - - } - - if (hunger != -1) { - - player.setFoodLevel(hunger); - - } - - if (saturation != -1) { - - player.setSaturation(saturation); - - } - - if (health != -1) { - - player.setHealth(health); - - } - - if (teleport != null) { - - player.teleport(teleport); - - } - - if (failQuest == true) { - - quest.failQuest(quester); - - } - - } - - public static Event loadEvent(String name, Quests plugin) { - - if (name == null || plugin == null) { - return null; - } - - Event event = new Event(); - - FileConfiguration data = new YamlConfiguration(); - try { - data.load(new File(plugin.getDataFolder(), "events.yml")); - } catch (IOException e) { - e.printStackTrace(); - } catch (InvalidConfigurationException e) { - e.printStackTrace(); - } - - String eventKey = "events." + name + "."; - - event.name = name; - if (data.contains(eventKey + "message")) { - event.message = data.getString(eventKey + "message"); - } - - if (data.contains(eventKey + "clear-inventory")) { - - if (data.isBoolean(eventKey + "clear-inventory")) { - event.clearInv = data.getBoolean(eventKey + "clear-inventory"); - } else { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "clear-inventory: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a true/false value!"); - return null; - } - - } - - if (data.contains(eventKey + "fail-quest")) { - - if (data.isBoolean(eventKey + "fail-quest")) { - event.failQuest = data.getBoolean(eventKey + "fail-quest"); - } else { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "fail-quest: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a true/false value!"); - return null; - } - - } - - if (data.contains(eventKey + "explosions")) { - - if (Quests.checkList(data.getList(eventKey + "explosions"), String.class)) { - - for (String s : data.getStringList(eventKey + "explosions")) { - - Location loc = Quests.getLocation(s); - - if (loc == null) { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + loc + ChatColor.GOLD + " inside " + ChatColor.GREEN + "explosions: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not in proper location format!"); - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\""); - return null; - } - - event.explosions.add(loc); - - } - - } else { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "explosions: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of locations!"); - return null; - } - - } - - if (data.contains(eventKey + "effects")) { - - if (Quests.checkList(data.getList(eventKey + "effects"), String.class)) { - - if (data.contains(eventKey + "effect-locations")) { - - if (Quests.checkList(data.getList(eventKey + "effect-locations"), String.class)) { - - List effectList = data.getStringList(eventKey + "effects"); - List effectLocs = data.getStringList(eventKey + "effect-locations"); - - for (String s : effectList) { - - Effect effect = Quests.getEffect(s); - Location l = Quests.getLocation(effectLocs.get(effectList.indexOf(s))); - - if (effect == null) { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + s + ChatColor.GOLD + " inside " + ChatColor.GREEN + "effects: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid effect name!"); - return null; - } - - if (l == null) { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + effectLocs.get(effectList.indexOf(s)) + ChatColor.GOLD + " inside " + ChatColor.GREEN + "effect-locations: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not in proper location format!"); - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\""); - return null; - } - - event.effects.put(l, effect); - - } - - } else { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "effect-locations: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of locations!"); - return null; - } - - } else { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "effect-locations:"); - return null; - } - - } else { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "effects: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of effects!"); - return null; - } - } - - if (data.contains(eventKey + "items")) { - - if (Quests.checkList(data.getList(eventKey + "items"), String.class)) { - - List eventItems = new LinkedList(); - - for (String s : data.getStringList(eventKey + "items")) { - try { - eventItems.add(ItemUtil.readItemStack(s)); - } catch (Exception e) { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] \"" + ChatColor.RED + s + ChatColor.GOLD + "\" inside " + ChatColor.GREEN + " items: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not formatted properly!"); - return null; - } - } - - event.items.addAll(eventItems); - - } else { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "items: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of items!"); - return null; - } - - } - - if (data.contains(eventKey + "storm-world")) { - - World w = plugin.getServer().getWorld(data.getString(eventKey + "storm-world")); - - if (w == null) { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "storm-world: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid World name!"); - return null; - } - - if (data.contains(eventKey + "storm-duration")) { - - if (data.getInt(eventKey + "storm-duration", -999) != -999) { - event.stormDuration = data.getInt(eventKey + "storm-duration") * 1000; - } else { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "storm-duration: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a number!"); - return null; - } - - event.stormWorld = w; - - } else { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "storm-duration:"); - return null; - } - - } - - if (data.contains(eventKey + "thunder-world")) { - - World w = plugin.getServer().getWorld(data.getString(eventKey + "thunder-world")); - - if (w == null) { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "thunder-world: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid World name!"); - return null; - } - - if (data.contains(eventKey + "thunder-duration")) { - - if (data.getInt(eventKey + "thunder-duration", -999) != -999) { - event.thunderDuration = data.getInt(eventKey + "thunder-duration"); - } else { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "thunder-duration: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a number!"); - return null; - } - - event.thunderWorld = w; - - } else { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "thunder-duration:"); - return null; - } - - } - - if (data.contains(eventKey + "mob-spawns")) { - ConfigurationSection section = data.getConfigurationSection(eventKey + "mob-spawns"); - - //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 (spawnLocation == null) { - plugin.getLogger().severe(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!"); - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\""); - return null; - } - - if (type == null) { - plugin.getLogger().severe(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; - } - - 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")) { - - if (Quests.checkList(data.getList(eventKey + "lightning-strikes"), String.class)) { - - for (String s : data.getStringList(eventKey + "lightning-strikes")) { - - Location loc = Quests.getLocation(s); - if (loc == null) { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + s + ChatColor.GOLD + " inside " + ChatColor.GREEN + " lightning-strikes: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not in proper location format!"); - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\""); - return null; - } - event.lightningStrikes.add(loc); - - } - - } else { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "lightning-strikes: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of locations!"); - return null; - } - - } - - if (data.contains(eventKey + "commands")) { - - if (Quests.checkList(data.getList(eventKey + "commands"), String.class)) { - for (String s : data.getStringList(eventKey + "commands")) { - if (s.startsWith("/")) { - s = s.replaceFirst("/", ""); - } - event.commands.add(s); - } - } else { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "commands: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of commands!"); - return null; - } - } - - if (data.contains(eventKey + "potion-effect-types")) { - - if (Quests.checkList(data.getList(eventKey + "potion-effect-types"), String.class)) { - - if (data.contains(eventKey + "potion-effect-durations")) { - - if (Quests.checkList(data.getList(eventKey + "potion-effect-durations"), Integer.class)) { - - if (data.contains(eventKey + "potion-effect-amplifiers")) { - - if (Quests.checkList(data.getList(eventKey + "potion-effect-amplifiers"), Integer.class)) { - - List types = data.getStringList(eventKey + "potion-effect-types"); - List durations = data.getIntegerList(eventKey + "potion-effect-durations"); - List amplifiers = data.getIntegerList(eventKey + "potion-effect-amplifiers"); - - for (String s : types) { - - PotionEffect effect = Quests.getPotionEffect(s, durations.get(types.indexOf(s)), amplifiers.get(types.indexOf(s))); - if (effect == null) { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + s + ChatColor.GOLD + " inside " + ChatColor.GREEN + " lightning-strikes: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid potion effect name!"); - return null; - } - event.potionEffects.add(effect); - - } - - } else { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "potion-effect-amplifiers: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of numbers!"); - return null; - } - - } else { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "potion-effect-amplifiers:"); - return null; - } - - } else { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "potion-effect-durations: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of numbers!"); - return null; - } - - } else { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "potion-effect-durations:"); - return null; - } - - } else { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "potion-effect-types: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of potion effects!"); - return null; - } - - } - - if (data.contains(eventKey + "hunger")) { - - if (data.getInt(eventKey + "hunger", -999) != -999) { - event.hunger = data.getInt(eventKey + "hunger"); - } else { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "hunger: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a number!"); - return null; - } - - } - - if (data.contains(eventKey + "saturation")) { - - if (data.getInt(eventKey + "saturation", -999) != -999) { - event.saturation = data.getInt(eventKey + "saturation"); - } else { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "saturation: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a number!"); - return null; - } - - } - - if (data.contains(eventKey + "health")) { - - if (data.getInt(eventKey + "health", -999) != -999) { - event.health = data.getInt(eventKey + "health"); - } else { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "health: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a number!"); - return null; - } - - } - - if (data.contains(eventKey + "teleport-location")) { - - if (data.isString(eventKey + "teleport-location")) { - - Location l = Quests.getLocation(data.getString(eventKey + "teleport-location")); - if (l == null) { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + data.getString(eventKey + "teleport-location") + ChatColor.GOLD + "for " + ChatColor.GREEN + " teleport-location: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not in proper location format!"); - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\""); - return null; - } - event.teleport = l; - - } else { - plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "teleport-location: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a location!"); - return null; - } - - } - - return event; - - } + 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 lightningStrikes = new LinkedList(); + LinkedList commands = new LinkedList(); + LinkedList potionEffects = new LinkedList(); + int hunger = -1; + int saturation = -1; + float health = -1; + Location teleport; + + public int hashCode() { + assert false : "hashCode not designed"; + return 42; // any arbitrary constant will do + } + + @Override + public boolean equals(Object o) { + if (o instanceof Event) { + Event other = (Event) o; + if (other.name.equals(name) == false) { + return false; + } + if (other.message != null && message != null) { + if (other.message.equals(message) == false) { + return false; + } + } else if (other.message != null && message == null) { + return false; + } else if (other.message == null && message != null) { + return false; + } + if (other.clearInv != clearInv) { + return false; + } + if (other.failQuest != failQuest) { + return false; + } + if (other.explosions.equals(explosions) == false) { + return false; + } + if (other.effects.entrySet().equals(effects.entrySet()) == false) { + return false; + } + if (other.items.equals(items) == false) { + return false; + } + if (other.stormWorld != null && stormWorld != null) { + if (other.stormWorld.equals(stormWorld) == false) { + return false; + } + } else if (other.stormWorld != null && stormWorld == null) { + return false; + } else if (other.stormWorld == null && stormWorld != null) { + return false; + } + if (other.stormDuration != stormDuration) { + return false; + } + if (other.thunderWorld != null && thunderWorld != null) { + if (other.thunderWorld.equals(thunderWorld) == false) { + return false; + } + } else if (other.thunderWorld != null && thunderWorld == null) { + return false; + } else if (other.thunderWorld == null && thunderWorld != null) { + return false; + } + if (other.thunderDuration != thunderDuration) { + return false; + } + for (QuestMob qm : mobSpawns) { + if (qm.equals(other.mobSpawns.get(mobSpawns.indexOf(qm))) == false) { + return false; + } + } + if (other.lightningStrikes.equals(lightningStrikes) == false) { + return false; + } + if (other.commands.equals(commands) == false) { + return false; + } + if (other.potionEffects.equals(potionEffects) == false) { + return false; + } + if (other.hunger != hunger) { + return false; + } + if (other.saturation != saturation) { + return false; + } + if (other.health != health) { + return false; + } + if (other.teleport != null && teleport != null) { + if (other.teleport.equals(teleport) == false) { + return false; + } + } else if (other.teleport != null && teleport == null) { + return false; + } else if (other.teleport == null && teleport != null) { + return false; + } + } + return true; + } + + public String getName() { + return name; + } + + public void fire(Quester quester, Quest quest) { + Player player = quester.getPlayer(); + if (message != null) { + player.sendMessage(Quests.parseString(message, quest)); + } + if (clearInv == true) { + player.getInventory().clear(); + } + if (explosions.isEmpty() == false) { + for (Location l : explosions) { + l.getWorld().createExplosion(l, 4F, false); + } + } + if (effects.isEmpty() == false) { + for (Location l : effects.keySet()) { + l.getWorld().playEffect(l, effects.get(l), 1); + } + } + if (items.isEmpty() == false) { + for (ItemStack is : items) { + Quests.addItem(player, is); + } + } + if (stormWorld != null) { + stormWorld.setStorm(true); + stormWorld.setWeatherDuration(stormDuration); + } + if (thunderWorld != null) { + thunderWorld.setThundering(true); + thunderWorld.setThunderDuration(thunderDuration); + } + if (mobSpawns.isEmpty() == false) { + for (QuestMob questMob : mobSpawns) { + questMob.spawn(); + } + } + if (lightningStrikes.isEmpty() == false) { + for (Location l : lightningStrikes) { + l.getWorld().strikeLightning(l); + } + } + if (commands.isEmpty() == false) { + for (String s : commands) { + quester.plugin.getServer().dispatchCommand(quester.plugin.getServer().getConsoleSender(), s.replaceAll("", quester.getPlayer().getName())); + } + } + if (potionEffects.isEmpty() == false) { + for (PotionEffect p : potionEffects) { + player.addPotionEffect(p); + } + } + if (hunger != -1) { + player.setFoodLevel(hunger); + } + if (saturation != -1) { + player.setSaturation(saturation); + } + if (health != -1) { + player.setHealth(health); + } + if (teleport != null) { + player.teleport(teleport); + } + if (failQuest == true) { + quest.failQuest(quester); + } + } + + public static Event loadEvent(String name, Quests plugin) { + if (name == null || plugin == null) { + return null; + } + Event event = new Event(); + FileConfiguration data = new YamlConfiguration(); + try { + data.load(new File(plugin.getDataFolder(), "events.yml")); + } catch (IOException e) { + e.printStackTrace(); + } catch (InvalidConfigurationException e) { + e.printStackTrace(); + } + String eventKey = "events." + name + "."; + event.name = name; + if (data.contains(eventKey + "message")) { + event.message = data.getString(eventKey + "message"); + } + if (data.contains(eventKey + "clear-inventory")) { + if (data.isBoolean(eventKey + "clear-inventory")) { + event.clearInv = data.getBoolean(eventKey + "clear-inventory"); + } else { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "clear-inventory: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a true/false value!"); + return null; + } + } + if (data.contains(eventKey + "fail-quest")) { + if (data.isBoolean(eventKey + "fail-quest")) { + event.failQuest = data.getBoolean(eventKey + "fail-quest"); + } else { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "fail-quest: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a true/false value!"); + return null; + } + } + if (data.contains(eventKey + "explosions")) { + if (Quests.checkList(data.getList(eventKey + "explosions"), String.class)) { + for (String s : data.getStringList(eventKey + "explosions")) { + Location loc = Quests.getLocation(s); + if (loc == null) { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + loc + ChatColor.GOLD + " inside " + ChatColor.GREEN + "explosions: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not in proper location format!"); + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\""); + return null; + } + event.explosions.add(loc); + } + } else { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "explosions: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of locations!"); + return null; + } + } + if (data.contains(eventKey + "effects")) { + if (Quests.checkList(data.getList(eventKey + "effects"), String.class)) { + if (data.contains(eventKey + "effect-locations")) { + if (Quests.checkList(data.getList(eventKey + "effect-locations"), String.class)) { + List effectList = data.getStringList(eventKey + "effects"); + List effectLocs = data.getStringList(eventKey + "effect-locations"); + for (String s : effectList) { + Effect effect = Quests.getEffect(s); + Location l = Quests.getLocation(effectLocs.get(effectList.indexOf(s))); + if (effect == null) { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + s + ChatColor.GOLD + " inside " + ChatColor.GREEN + "effects: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid effect name!"); + return null; + } + if (l == null) { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + effectLocs.get(effectList.indexOf(s)) + ChatColor.GOLD + " inside " + ChatColor.GREEN + "effect-locations: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not in proper location format!"); + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\""); + return null; + } + event.effects.put(l, effect); + } + } else { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "effect-locations: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of locations!"); + return null; + } + } else { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "effect-locations:"); + return null; + } + } else { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "effects: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of effects!"); + return null; + } + } + if (data.contains(eventKey + "items")) { + if (Quests.checkList(data.getList(eventKey + "items"), String.class)) { + List eventItems = new LinkedList(); + for (String s : data.getStringList(eventKey + "items")) { + try { + eventItems.add(ItemUtil.readItemStack(s)); + } catch (Exception e) { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] \"" + ChatColor.RED + s + ChatColor.GOLD + "\" inside " + ChatColor.GREEN + " items: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not formatted properly!"); + return null; + } + } + event.items.addAll(eventItems); + } else { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "items: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of items!"); + return null; + } + } + if (data.contains(eventKey + "storm-world")) { + World w = plugin.getServer().getWorld(data.getString(eventKey + "storm-world")); + if (w == null) { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "storm-world: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid World name!"); + return null; + } + if (data.contains(eventKey + "storm-duration")) { + if (data.getInt(eventKey + "storm-duration", -999) != -999) { + event.stormDuration = data.getInt(eventKey + "storm-duration") * 1000; + } else { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "storm-duration: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a number!"); + return null; + } + event.stormWorld = w; + } else { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "storm-duration:"); + return null; + } + } + if (data.contains(eventKey + "thunder-world")) { + World w = plugin.getServer().getWorld(data.getString(eventKey + "thunder-world")); + if (w == null) { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "thunder-world: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid World name!"); + return null; + } + if (data.contains(eventKey + "thunder-duration")) { + if (data.getInt(eventKey + "thunder-duration", -999) != -999) { + event.thunderDuration = data.getInt(eventKey + "thunder-duration"); + } else { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "thunder-duration: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a number!"); + return null; + } + event.thunderWorld = w; + } else { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "thunder-duration:"); + return null; + } + } + if (data.contains(eventKey + "mob-spawns")) { + ConfigurationSection section = data.getConfigurationSection(eventKey + "mob-spawns"); + // 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 (spawnLocation == null) { + plugin.getLogger().severe(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!"); + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\""); + return null; + } + if (type == null) { + plugin.getLogger().severe(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; + } + 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")) { + if (Quests.checkList(data.getList(eventKey + "lightning-strikes"), String.class)) { + for (String s : data.getStringList(eventKey + "lightning-strikes")) { + Location loc = Quests.getLocation(s); + if (loc == null) { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + s + ChatColor.GOLD + " inside " + ChatColor.GREEN + " lightning-strikes: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not in proper location format!"); + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\""); + return null; + } + event.lightningStrikes.add(loc); + } + } else { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "lightning-strikes: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of locations!"); + return null; + } + } + if (data.contains(eventKey + "commands")) { + if (Quests.checkList(data.getList(eventKey + "commands"), String.class)) { + for (String s : data.getStringList(eventKey + "commands")) { + if (s.startsWith("/")) { + s = s.replaceFirst("/", ""); + } + event.commands.add(s); + } + } else { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "commands: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of commands!"); + return null; + } + } + if (data.contains(eventKey + "potion-effect-types")) { + if (Quests.checkList(data.getList(eventKey + "potion-effect-types"), String.class)) { + if (data.contains(eventKey + "potion-effect-durations")) { + if (Quests.checkList(data.getList(eventKey + "potion-effect-durations"), Integer.class)) { + if (data.contains(eventKey + "potion-effect-amplifiers")) { + if (Quests.checkList(data.getList(eventKey + "potion-effect-amplifiers"), Integer.class)) { + List types = data.getStringList(eventKey + "potion-effect-types"); + List durations = data.getIntegerList(eventKey + "potion-effect-durations"); + List amplifiers = data.getIntegerList(eventKey + "potion-effect-amplifiers"); + for (String s : types) { + PotionEffect effect = Quests.getPotionEffect(s, durations.get(types.indexOf(s)), amplifiers.get(types.indexOf(s))); + if (effect == null) { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + s + ChatColor.GOLD + " inside " + ChatColor.GREEN + " lightning-strikes: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid potion effect name!"); + return null; + } + event.potionEffects.add(effect); + } + } else { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "potion-effect-amplifiers: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of numbers!"); + return null; + } + } else { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "potion-effect-amplifiers:"); + return null; + } + } else { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "potion-effect-durations: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of numbers!"); + return null; + } + } else { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "potion-effect-durations:"); + return null; + } + } else { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "potion-effect-types: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of potion effects!"); + return null; + } + } + if (data.contains(eventKey + "hunger")) { + if (data.getInt(eventKey + "hunger", -999) != -999) { + event.hunger = data.getInt(eventKey + "hunger"); + } else { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "hunger: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a number!"); + return null; + } + } + if (data.contains(eventKey + "saturation")) { + if (data.getInt(eventKey + "saturation", -999) != -999) { + event.saturation = data.getInt(eventKey + "saturation"); + } else { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "saturation: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a number!"); + return null; + } + } + if (data.contains(eventKey + "health")) { + if (data.getInt(eventKey + "health", -999) != -999) { + event.health = data.getInt(eventKey + "health"); + } else { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "health: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a number!"); + return null; + } + } + if (data.contains(eventKey + "teleport-location")) { + if (data.isString(eventKey + "teleport-location")) { + Location l = Quests.getLocation(data.getString(eventKey + "teleport-location")); + if (l == null) { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + data.getString(eventKey + "teleport-location") + ChatColor.GOLD + "for " + ChatColor.GREEN + " teleport-location: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not in proper location format!"); + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\""); + return null; + } + event.teleport = l; + } else { + plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "teleport-location: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a location!"); + return null; + } + } + return event; + } } diff --git a/src/main/java/me/blackvein/quests/EventFactory.java b/src/main/java/me/blackvein/quests/EventFactory.java index 317df668d..23e1d4d7e 100644 --- a/src/main/java/me/blackvein/quests/EventFactory.java +++ b/src/main/java/me/blackvein/quests/EventFactory.java @@ -44,2823 +44,2100 @@ import net.citizensnpcs.api.CitizensAPI; public class EventFactory implements ConversationAbandonedListener { - Quests quests; - Map editSessions = new HashMap(); - Map selectedExplosionLocations = new HashMap(); - Map selectedEffectLocations = new HashMap(); - Map selectedMobLocations = new HashMap(); - Map selectedLightningLocations = new HashMap(); - Map selectedTeleportLocations = new HashMap(); - List names = new LinkedList(); - ConversationFactory convoCreator; - File eventsFile; + Quests quests; + Map editSessions = new HashMap(); + Map selectedExplosionLocations = new HashMap(); + Map selectedEffectLocations = new HashMap(); + Map selectedMobLocations = new HashMap(); + Map selectedLightningLocations = new HashMap(); + Map selectedTeleportLocations = new HashMap(); + List names = new LinkedList(); + ConversationFactory convoCreator; + File eventsFile; + + public EventFactory(Quests plugin) { + quests = plugin; + // Ensure to initialize convoCreator last, to ensure that 'this' is fully initialized before it is passed + this.convoCreator = new ConversationFactory(plugin).withModality(false).withLocalEcho(false).withPrefix(new QuestCreatorPrefix()).withFirstPrompt(new MenuPrompt()).withTimeout(3600).thatExcludesNonPlayersWithMessage("Console may not perform this operation!").addConversationAbandonedListener(this); + } + + @Override + public void conversationAbandoned(ConversationAbandonedEvent abandonedEvent) { + Player player = (Player) abandonedEvent.getContext().getForWhom(); + selectedExplosionLocations.remove(player.getUniqueId()); + selectedEffectLocations.remove(player.getUniqueId()); + selectedMobLocations.remove(player.getUniqueId()); + selectedLightningLocations.remove(player.getUniqueId()); + selectedTeleportLocations.remove(player.getUniqueId()); + } + + private class QuestCreatorPrefix implements ConversationPrefix { - public EventFactory(Quests plugin) { - - quests = plugin; - - //Ensure to initialize convoCreator last, to ensure that 'this' is fully initialized before it is passed - this.convoCreator = new ConversationFactory(plugin) - .withModality(false) - .withLocalEcho(false) - .withPrefix(new QuestCreatorPrefix()) - .withFirstPrompt(new MenuPrompt()) - .withTimeout(3600) - .thatExcludesNonPlayersWithMessage("Console may not perform this operation!") - .addConversationAbandonedListener(this); - - } - - @Override - public void conversationAbandoned(ConversationAbandonedEvent abandonedEvent) { - - Player player = (Player) abandonedEvent.getContext().getForWhom(); - selectedExplosionLocations.remove(player.getUniqueId()); - selectedEffectLocations.remove(player.getUniqueId()); - selectedMobLocations.remove(player.getUniqueId()); - selectedLightningLocations.remove(player.getUniqueId()); - selectedTeleportLocations.remove(player.getUniqueId()); - - } - - private class QuestCreatorPrefix implements ConversationPrefix { - - @Override - public String getPrefix(ConversationContext context) { - - return ""; - - } - } - - private class MenuPrompt extends FixedSetPrompt { - - public MenuPrompt() { - - super("1", "2", "3", "4"); - - } - - @Override - public String getPromptText(ConversationContext context) { - - String text - = ChatColor.GOLD + Lang.get("eventEditorTitle") + "\n" - + ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorCreate") + "\n" - + ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorEdit") + "\n" - + ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorDelete") + "\n" - + ChatColor.GREEN + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("exit"); - - return text; - - } - - @Override - protected Prompt acceptValidatedInput(ConversationContext context, String input) { - - final Player player = (Player) context.getForWhom(); - - if (input.equalsIgnoreCase("1")) { - - if (player.hasPermission("quests.editor.events.create")) { - context.setSessionData(CK.E_OLD_EVENT, ""); - return new EventNamePrompt(); - } else { - player.sendMessage(ChatColor.RED + Lang.get("eventEditorCreatePermisssions")); - return new MenuPrompt(); - } - - } else if (input.equalsIgnoreCase("2")) { - - if (player.hasPermission("quests.editor.events.edit")) { - - if (quests.events.isEmpty()) { - ((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW + Lang.get("eventEditorNoneToEdit")); - return new MenuPrompt(); - } else { - return new SelectEditPrompt(); - } - - } else { - - player.sendMessage(ChatColor.RED + Lang.get("eventEditorEditPermisssions")); - return new MenuPrompt(); - - } - } else if (input.equalsIgnoreCase("3")) { - - if (player.hasPermission("quests.editor.events.delete")) { - - if (quests.events.isEmpty()) { - ((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW + Lang.get("eventEditorNoneToDelete")); - return new MenuPrompt(); - } else { - return new SelectDeletePrompt(); - } - - } else { - - player.sendMessage(ChatColor.RED + Lang.get("eventEditorDeletePermisssions")); - return new MenuPrompt(); - - } - - } else if (input.equalsIgnoreCase("4")) { - ((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW + Lang.get("exited")); - return Prompt.END_OF_CONVERSATION; - } - - return null; - - } - } - - public Prompt returnToMenu() { - - return new CreateMenuPrompt(); - - } - - public static void clearData(ConversationContext context) { - - context.setSessionData(CK.E_OLD_EVENT, null); - context.setSessionData(CK.E_NAME, null); - context.setSessionData(CK.E_MESSAGE, null); - context.setSessionData(CK.E_CLEAR_INVENTORY, null); - context.setSessionData(CK.E_FAIL_QUEST, null); - context.setSessionData(CK.E_ITEMS, null); - context.setSessionData(CK.E_ITEMS_AMOUNTS, null); - context.setSessionData(CK.E_EXPLOSIONS, null); - context.setSessionData(CK.E_EFFECTS, null); - context.setSessionData(CK.E_EFFECTS_LOCATIONS, null); - context.setSessionData(CK.E_WORLD_STORM, null); - context.setSessionData(CK.E_WORLD_STORM_DURATION, null); - 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_LIGHTNING, null); - context.setSessionData(CK.E_POTION_TYPES, null); - context.setSessionData(CK.E_POTION_DURATIONS, null); - context.setSessionData(CK.E_POTION_STRENGHT, null); - context.setSessionData(CK.E_HUNGER, null); - context.setSessionData(CK.E_SATURATION, null); - context.setSessionData(CK.E_HEALTH, null); - context.setSessionData(CK.E_TELEPORT, null); - context.setSessionData(CK.E_COMMANDS, null); - - } - - public static void loadData(Event event, ConversationContext context) { - - if (event.message != null) { - context.setSessionData(CK.E_MESSAGE, event.message); - } - - if (event.clearInv == true) { - context.setSessionData(CK.E_CLEAR_INVENTORY, Lang.get("yesWord")); - } else { - context.setSessionData(CK.E_CLEAR_INVENTORY, Lang.get("noWord")); - } - - if (event.failQuest == true) { - context.setSessionData(CK.E_FAIL_QUEST, Lang.get("yesWord")); - } else { - context.setSessionData(CK.E_FAIL_QUEST, Lang.get("noWord")); - } - - if (event.items != null && event.items.isEmpty() == false) { - - LinkedList items = new LinkedList(); - items.addAll(event.items); - - context.setSessionData(CK.E_ITEMS, items); - - } - - if (event.explosions != null && event.explosions.isEmpty() == false) { - - LinkedList locs = new LinkedList(); - - for (Location loc : event.explosions) { - locs.add(Quests.getLocationInfo(loc)); - } - - context.setSessionData(CK.E_EXPLOSIONS, locs); - - } - - if (event.effects != null && event.effects.isEmpty() == false) { - - LinkedList locs = new LinkedList(); - LinkedList effs = new LinkedList(); - - for (Entry e : event.effects.entrySet()) { - - locs.add(Quests.getLocationInfo((Location) e.getKey())); - effs.add(((Effect) e.getValue()).toString()); - - } - - context.setSessionData(CK.E_EFFECTS, effs); - context.setSessionData(CK.E_EFFECTS_LOCATIONS, locs); - - } - - if (event.stormWorld != null) { - - context.setSessionData(CK.E_WORLD_STORM, event.stormWorld.getName()); - context.setSessionData(CK.E_WORLD_STORM_DURATION, (long) event.stormDuration); - - } - - if (event.thunderWorld != null) { - - context.setSessionData(CK.E_WORLD_THUNDER, event.thunderWorld.getName()); - context.setSessionData(CK.E_WORLD_THUNDER_DURATION, (long) event.thunderDuration); - - } - - if (event.mobSpawns != null && event.mobSpawns.isEmpty() == false) { - - LinkedList questMobs = new LinkedList(); - - for (QuestMob questMob : event.mobSpawns) { - questMobs.add(questMob.serialize()); - } - - context.setSessionData(CK.E_MOB_TYPES, questMobs); - } - - if (event.lightningStrikes != null && event.lightningStrikes.isEmpty() == false) { - - LinkedList locs = new LinkedList(); - for (Location loc : event.lightningStrikes) { - locs.add(Quests.getLocationInfo(loc)); - } - context.setSessionData(CK.E_LIGHTNING, locs); - - } - - if (event.potionEffects != null && event.potionEffects.isEmpty() == false) { - - LinkedList types = new LinkedList(); - LinkedList durations = new LinkedList(); - LinkedList mags = new LinkedList(); - - for (PotionEffect pe : event.potionEffects) { - - types.add(pe.getType().getName()); - durations.add((long) pe.getDuration()); - mags.add(pe.getAmplifier()); - - } - - context.setSessionData(CK.E_POTION_TYPES, types); - context.setSessionData(CK.E_POTION_DURATIONS, durations); - context.setSessionData(CK.E_POTION_STRENGHT, mags); - - } - - if (event.hunger > -1) { - - context.setSessionData(CK.E_HUNGER, (Integer) event.hunger); - - } - - if (event.saturation > -1) { - - context.setSessionData(CK.E_SATURATION, (Integer) event.saturation); - - } - - if (event.health > -1) { - - context.setSessionData(CK.E_HEALTH, (Float) event.health); - - } - - if (event.teleport != null) { - - context.setSessionData(CK.E_TELEPORT, Quests.getLocationInfo(event.teleport)); - - } - - if (event.commands != null) { - - context.setSessionData(CK.E_COMMANDS, event.commands); - - } - - } - - private class SelectEditPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - - String text = ChatColor.GOLD + "- " + Lang.get("eventEditorEdit") + " -\n"; - - for (Event evt : quests.events) { - text += ChatColor.AQUA + evt.name + ChatColor.YELLOW + ", "; - } - - text = text.substring(0, text.length() - 2) + "\n"; - text += ChatColor.YELLOW + Lang.get("eventEditorEnterEventName"); - - return text; - - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - - for (Event evt : quests.events) { - - if (evt.name.equalsIgnoreCase(input)) { - context.setSessionData(CK.E_OLD_EVENT, evt.name); - context.setSessionData(CK.E_NAME, evt.name); - loadData(evt, context); - return new CreateMenuPrompt(); - } - - } - - ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorNotFound")); - return new SelectEditPrompt(); - - } else { - return new MenuPrompt(); - } - - } - - } - - private class SelectDeletePrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - - String text = ChatColor.GOLD + "- " + Lang.get("eventEditorDelete") + " -\n"; - - for (Event evt : quests.events) { - text += ChatColor.AQUA + evt.name + ChatColor.YELLOW + ","; - } - - text = text.substring(0, text.length() - 1) + "\n"; - text += ChatColor.YELLOW + Lang.get("eventEditorEnterEventName"); - - return text; - - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - - LinkedList used = new LinkedList(); - - for (Event evt : quests.events) { - - if (evt.name.equalsIgnoreCase(input)) { - - for (Quest quest : quests.getQuests()) { - - for (Stage stage : quest.orderedStages) { - - if (stage.finishEvent != null && stage.finishEvent.name.equalsIgnoreCase(evt.name)) { - used.add(quest.name); - break; - } - - } - - } - - if (used.isEmpty()) { - context.setSessionData(CK.ED_EVENT_DELETE, evt.name); - return new DeletePrompt(); - } else { - ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorEventInUse") + " \"" + ChatColor.DARK_PURPLE + evt.name + ChatColor.RED + "\":"); - for (String s : used) { - ((Player) context.getForWhom()).sendMessage(ChatColor.RED + "- " + ChatColor.DARK_RED + s); - } - ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorMustModifyQuests")); - return new SelectDeletePrompt(); - } - } - - } - - ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorNotFound")); - return new SelectDeletePrompt(); - - } else { - return new MenuPrompt(); - } - - } - - } - - private class DeletePrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - - String text - = ChatColor.RED + Lang.get("eventEditorDeletePrompt") + " \"" + ChatColor.GOLD + (String) context.getSessionData(CK.ED_EVENT_DELETE) + ChatColor.RED + "\"?\n"; - text += ChatColor.YELLOW + Lang.get("yesWord") + "/" + Lang.get("noWord"); - - return text; - - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - - if (input.equalsIgnoreCase(Lang.get("yesWord"))) { - deleteEvent(context); - return new MenuPrompt(); - } else if (input.equalsIgnoreCase(Lang.get("noWord"))) { - return new MenuPrompt(); - } else { - return new DeletePrompt(); - } - - } - - } - - private class CreateMenuPrompt extends FixedSetPrompt { - - public CreateMenuPrompt() { - - super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"); - - } - - @SuppressWarnings("unchecked") @Override - public String getPromptText(ConversationContext context) { - - String text - = ChatColor.GOLD + "- " + Lang.get("event") + ": " + ChatColor.AQUA + context.getSessionData(CK.E_NAME) + ChatColor.GOLD + " -\n"; - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetName") + "\n"; - - if (context.getSessionData(CK.E_MESSAGE) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMessage") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMessage") + "(" + ChatColor.AQUA + "\"" + context.getSessionData(CK.E_MESSAGE) + "\"" + ChatColor.YELLOW + ")\n"; - } - - if (context.getSessionData(CK.E_CLEAR_INVENTORY) == null) { - context.setSessionData(CK.E_CLEAR_INVENTORY, "No"); - } - - if (context.getSessionData(CK.E_FAIL_QUEST) == null) { - context.setSessionData(CK.E_FAIL_QUEST, "No"); - } - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorClearInv") + ": " + ChatColor.AQUA + context.getSessionData(CK.E_CLEAR_INVENTORY) + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorFailQuest") + ": " + ChatColor.AQUA + context.getSessionData(CK.E_FAIL_QUEST) + "\n"; - - if (context.getSessionData(CK.E_ITEMS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetItems") + "\n"; - LinkedList items = (LinkedList) context.getSessionData(CK.E_ITEMS); - - for (ItemStack is : items) { - - text += ChatColor.GRAY + " - " + ItemUtil.getString(is) + "\n"; - - } - - } - - if (context.getSessionData(CK.E_EXPLOSIONS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetExplosions") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetExplosions") + "\n"; - LinkedList locations = (LinkedList) context.getSessionData(CK.E_EXPLOSIONS); - - for (String loc : locations) { - - text += ChatColor.GRAY + " - " + ChatColor.AQUA + loc + "\n"; - - } - - } - - if (context.getSessionData(CK.E_EFFECTS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetEffects") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetEffects") + "\n"; - LinkedList effects = (LinkedList) context.getSessionData(CK.E_EFFECTS); - LinkedList locations = (LinkedList) context.getSessionData(CK.E_EFFECTS_LOCATIONS); - - for (String effect : effects) { - - text += ChatColor.GRAY + " - " + ChatColor.AQUA + effect + ChatColor.GRAY + " at " + ChatColor.DARK_AQUA + locations.get(effects.indexOf(effect)) + "\n"; - - } - - } - - if (context.getSessionData(CK.E_WORLD_STORM) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetStorm") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetStorm") + " (" + ChatColor.AQUA + (String) context.getSessionData(CK.E_WORLD_STORM) + ChatColor.YELLOW + " -> " + ChatColor.DARK_AQUA + Quests.getTime((Long) context.getSessionData(CK.E_WORLD_STORM_DURATION)) + ChatColor.YELLOW + ")\n"; - } - - if (context.getSessionData(CK.E_WORLD_THUNDER) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "9" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetThunder") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "9" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetThunder") + " (" + ChatColor.AQUA + (String) context.getSessionData(CK.E_WORLD_THUNDER) + ChatColor.YELLOW + " -> " + ChatColor.DARK_AQUA + Quests.getTime((Long) context.getSessionData(CK.E_WORLD_THUNDER_DURATION)) + ChatColor.YELLOW + ")\n"; - } - - if (context.getSessionData(CK.E_MOB_TYPES) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "10" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobSpawns") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - LinkedList types = (LinkedList) context.getSessionData(CK.E_MOB_TYPES); - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "10" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobSpawns") + "\n"; - - for (String s : types) { - QuestMob qm = QuestMob.fromString(s); - text += ChatColor.GRAY + " - " + ChatColor.AQUA + qm.getType().name() + ((qm.getName() != null) ? ": " + qm.getName() : "") + ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + qm.getSpawnAmounts() + ChatColor.GRAY + " -> " + ChatColor.GREEN + Quests.getLocationInfo(qm.getSpawnLocation()) + "\n"; - } - } - - if (context.getSessionData(CK.E_LIGHTNING) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "11" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetLightning") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "11" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetLightning") + "\n"; - LinkedList locations = (LinkedList) context.getSessionData(CK.E_LIGHTNING); - - for (String loc : locations) { - - text += ChatColor.GRAY + " - " + ChatColor.AQUA + loc + "\n"; - - } - - } - - if (context.getSessionData(CK.E_POTION_TYPES) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "12" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetPotionEffects") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "12" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetPotionEffects") + "\n"; - LinkedList types = (LinkedList) context.getSessionData(CK.E_POTION_TYPES); - LinkedList durations = (LinkedList) context.getSessionData(CK.E_POTION_DURATIONS); - LinkedList mags = (LinkedList) context.getSessionData(CK.E_POTION_STRENGHT); - int index = -1; - - for (String type : types) { - - index++; - text += ChatColor.GRAY + " - " + ChatColor.AQUA + type + ChatColor.DARK_PURPLE + " " + Quests.getNumeral(mags.get(index)) + ChatColor.GRAY + " -> " + ChatColor.DARK_AQUA + Quests.getTime(durations.get(index) * 50L) + "\n"; - - } - - } - - if (context.getSessionData(CK.E_HUNGER) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "13" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetHunger") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "13" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetHunger") + ChatColor.AQUA + " (" + (Integer) context.getSessionData(CK.E_HUNGER) + ")\n"; - - } - - if (context.getSessionData(CK.E_SATURATION) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "14" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetSaturation") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "14" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetSaturation") + ChatColor.AQUA + " (" + (Integer) context.getSessionData(CK.E_SATURATION) + ")\n"; - - } - - if (context.getSessionData(CK.E_HEALTH) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "15" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetHealth") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "15" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetHealth") + ChatColor.AQUA + " (" + (Integer) context.getSessionData(CK.E_HEALTH) + ")\n"; - - } - - if (context.getSessionData(CK.E_TELEPORT) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "16" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetTeleport") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "16" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetTeleport") + ChatColor.AQUA + " (" + (String) context.getSessionData(CK.E_TELEPORT) + ")\n"; - - } - - if (context.getSessionData(CK.E_COMMANDS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "17" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetCommands") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; - } else { - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "17" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetCommands") + "\n"; - for (String s : (LinkedList) context.getSessionData(CK.E_COMMANDS)) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; - } - - } - - text += ChatColor.GREEN + "" + ChatColor.BOLD + "18" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done") + "\n"; - text += ChatColor.RED + "" + ChatColor.BOLD + "19" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("quit"); - - return text; - - } - - @Override - public Prompt acceptValidatedInput(ConversationContext context, String input) { - - if (input.equalsIgnoreCase("1")) { - - return new SetNamePrompt(); - - } else if (input.equalsIgnoreCase("2")) { - - return new MessagePrompt(); - - } else if (input.equalsIgnoreCase("3")) { - - String s = (String) context.getSessionData(CK.E_CLEAR_INVENTORY); - if (s.equalsIgnoreCase(Lang.get("yesWord"))) { - context.setSessionData(CK.E_CLEAR_INVENTORY, Lang.get("noWord")); - } else { - context.setSessionData(CK.E_CLEAR_INVENTORY, Lang.get("yesWord")); - } - - return new CreateMenuPrompt(); - - } else if (input.equalsIgnoreCase("4")) { - - String s = (String) context.getSessionData(CK.E_FAIL_QUEST); - if (s.equalsIgnoreCase(Lang.get("yesWord"))) { - context.setSessionData(CK.E_FAIL_QUEST, Lang.get("noWord")); - } else { - context.setSessionData(CK.E_FAIL_QUEST, Lang.get("yesWord")); - } - - return new CreateMenuPrompt(); - - } else if (input.equalsIgnoreCase("5")) { - - return new ItemListPrompt(); - - } else if (input.equalsIgnoreCase("6")) { - - selectedExplosionLocations.put(((Player) context.getForWhom()).getUniqueId(), null); - return new ExplosionPrompt(); - - } else if (input.equalsIgnoreCase("7")) { - - return new EffectListPrompt(); - - } else if (input.equalsIgnoreCase("8")) { - - return new StormPrompt(); - - } else if (input.equalsIgnoreCase("9")) { - - return new ThunderPrompt(); - - } else if (input.equalsIgnoreCase("10")) { - - return new MobPrompt(); - - } else if (input.equalsIgnoreCase("11")) { - - selectedLightningLocations.put(((Player) context.getForWhom()).getUniqueId(), null); - return new LightningPrompt(); - - } else if (input.equalsIgnoreCase("12")) { - - return new PotionEffectPrompt(); - - } else if (input.equalsIgnoreCase("13")) { - - return new HungerPrompt(); - - } else if (input.equalsIgnoreCase("14")) { - - return new SaturationPrompt(); - - } else if (input.equalsIgnoreCase("15")) { - - return new HealthPrompt(); - - } else if (input.equalsIgnoreCase("16")) { - - selectedTeleportLocations.put(((Player) context.getForWhom()).getUniqueId(), null); - return new TeleportPrompt(); - - } else if (input.equalsIgnoreCase("17")) { - - return new CommandsPrompt(); - - } else if (input.equalsIgnoreCase("18")) { - - if (context.getSessionData(CK.E_OLD_EVENT) != null) { - return new FinishPrompt((String) context.getSessionData(CK.E_OLD_EVENT)); - } else { - return new FinishPrompt(null); - } - - } else if (input.equalsIgnoreCase("19")) { - - return new QuitPrompt(); - - } - - return null; - - } - } - - private class QuitPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - - String text - = ChatColor.GREEN + Lang.get("eventEditorQuitWithoutSaving") + "\n"; - text += ChatColor.YELLOW + Lang.get("yesWord") + "/" + Lang.get("noWord"); - - return text; - - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - - if (input.equalsIgnoreCase(Lang.get("yesWord"))) { - clearData(context); - return new MenuPrompt(); - } else if (input.equalsIgnoreCase(Lang.get("noWord"))) { - return new CreateMenuPrompt(); - } else { - ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("invalidOption")); - return new QuitPrompt(); - } - - } - - } - - private class FinishPrompt extends StringPrompt { - - String modName = null; - LinkedList modified = new LinkedList(); - - public FinishPrompt(String modifiedName) { - - if (modifiedName != null) { - - modName = modifiedName; - for (Quest q : quests.getQuests()) { - - for (Stage s : q.orderedStages) { - - if (s.finishEvent != null && s.finishEvent.name != null) { - - if (s.finishEvent.name.equalsIgnoreCase(modifiedName)) { - modified.add(q.getName()); - break; - } - - } - - } - - } - - } - - } - - @Override - public String getPromptText(ConversationContext context) { - - String text - = ChatColor.RED + Lang.get("eventEditorFinishAndSave") + " \"" + ChatColor.GOLD + (String) context.getSessionData(CK.E_NAME) + ChatColor.RED + "\"?\n"; - if (modified.isEmpty() == false) { - text += ChatColor.RED + Lang.get("eventEditorModifiedNote") + "\n"; - for (String s : modified) { - text += ChatColor.GRAY + " - " + ChatColor.DARK_RED + s + "\n"; - } - text += ChatColor.RED + Lang.get("eventEditorForcedToQuit") + "\n"; - } - text += ChatColor.YELLOW + Lang.get("yesWord") + "/" + Lang.get("noWord"); - - return text; - - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - - if (input.equalsIgnoreCase(Lang.get("yesWord"))) { - saveEvent(context); - return new MenuPrompt(); - } else if (input.equalsIgnoreCase(Lang.get("noWord"))) { - return new CreateMenuPrompt(); - } else { - ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("invalidOption")); - return new FinishPrompt(modName); - } - - } - - } - - //Convenience methods to reduce typecasting - private static String getCString(ConversationContext context, String path) { - return (String) context.getSessionData(path); - } - - @SuppressWarnings("unchecked") - private static LinkedList getCStringList(ConversationContext context, String path) { - return (LinkedList) context.getSessionData(path); - } - - private static Integer getCInt(ConversationContext context, String path) { - return (Integer) context.getSessionData(path); - } - - @SuppressWarnings("unchecked") - private static LinkedList getCIntList(ConversationContext context, String path) { - return (LinkedList) context.getSessionData(path); - } - - @SuppressWarnings("unused") + public String getPrefix(ConversationContext context) { + return ""; + } + } + + private class MenuPrompt extends FixedSetPrompt { + + public MenuPrompt() { + super("1", "2", "3", "4"); + } + + @Override + public String getPromptText(ConversationContext context) { + String text = ChatColor.GOLD + Lang.get("eventEditorTitle") + "\n" + ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorCreate") + "\n" + ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorEdit") + "\n" + ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorDelete") + "\n" + ChatColor.GREEN + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("exit"); + return text; + } + + @Override + protected Prompt acceptValidatedInput(ConversationContext context, String input) { + final Player player = (Player) context.getForWhom(); + if (input.equalsIgnoreCase("1")) { + if (player.hasPermission("quests.editor.events.create")) { + context.setSessionData(CK.E_OLD_EVENT, ""); + return new EventNamePrompt(); + } else { + player.sendMessage(ChatColor.RED + Lang.get("eventEditorCreatePermisssions")); + return new MenuPrompt(); + } + } else if (input.equalsIgnoreCase("2")) { + if (player.hasPermission("quests.editor.events.edit")) { + if (quests.events.isEmpty()) { + ((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW + Lang.get("eventEditorNoneToEdit")); + return new MenuPrompt(); + } else { + return new SelectEditPrompt(); + } + } else { + player.sendMessage(ChatColor.RED + Lang.get("eventEditorEditPermisssions")); + return new MenuPrompt(); + } + } else if (input.equalsIgnoreCase("3")) { + if (player.hasPermission("quests.editor.events.delete")) { + if (quests.events.isEmpty()) { + ((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW + Lang.get("eventEditorNoneToDelete")); + return new MenuPrompt(); + } else { + return new SelectDeletePrompt(); + } + } else { + player.sendMessage(ChatColor.RED + Lang.get("eventEditorDeletePermisssions")); + return new MenuPrompt(); + } + } else if (input.equalsIgnoreCase("4")) { + ((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW + Lang.get("exited")); + return Prompt.END_OF_CONVERSATION; + } + return null; + } + } + + public Prompt returnToMenu() { + return new CreateMenuPrompt(); + } + + public static void clearData(ConversationContext context) { + context.setSessionData(CK.E_OLD_EVENT, null); + context.setSessionData(CK.E_NAME, null); + context.setSessionData(CK.E_MESSAGE, null); + context.setSessionData(CK.E_CLEAR_INVENTORY, null); + context.setSessionData(CK.E_FAIL_QUEST, null); + context.setSessionData(CK.E_ITEMS, null); + context.setSessionData(CK.E_ITEMS_AMOUNTS, null); + context.setSessionData(CK.E_EXPLOSIONS, null); + context.setSessionData(CK.E_EFFECTS, null); + context.setSessionData(CK.E_EFFECTS_LOCATIONS, null); + context.setSessionData(CK.E_WORLD_STORM, null); + context.setSessionData(CK.E_WORLD_STORM_DURATION, null); + 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_LIGHTNING, null); + context.setSessionData(CK.E_POTION_TYPES, null); + context.setSessionData(CK.E_POTION_DURATIONS, null); + context.setSessionData(CK.E_POTION_STRENGHT, null); + context.setSessionData(CK.E_HUNGER, null); + context.setSessionData(CK.E_SATURATION, null); + context.setSessionData(CK.E_HEALTH, null); + context.setSessionData(CK.E_TELEPORT, null); + context.setSessionData(CK.E_COMMANDS, null); + } + + public static void loadData(Event event, ConversationContext context) { + if (event.message != null) { + context.setSessionData(CK.E_MESSAGE, event.message); + } + if (event.clearInv == true) { + context.setSessionData(CK.E_CLEAR_INVENTORY, Lang.get("yesWord")); + } else { + context.setSessionData(CK.E_CLEAR_INVENTORY, Lang.get("noWord")); + } + if (event.failQuest == true) { + context.setSessionData(CK.E_FAIL_QUEST, Lang.get("yesWord")); + } else { + context.setSessionData(CK.E_FAIL_QUEST, Lang.get("noWord")); + } + if (event.items != null && event.items.isEmpty() == false) { + LinkedList items = new LinkedList(); + items.addAll(event.items); + context.setSessionData(CK.E_ITEMS, items); + } + if (event.explosions != null && event.explosions.isEmpty() == false) { + LinkedList locs = new LinkedList(); + for (Location loc : event.explosions) { + locs.add(Quests.getLocationInfo(loc)); + } + context.setSessionData(CK.E_EXPLOSIONS, locs); + } + if (event.effects != null && event.effects.isEmpty() == false) { + LinkedList locs = new LinkedList(); + LinkedList effs = new LinkedList(); + for (Entry e : event.effects.entrySet()) { + locs.add(Quests.getLocationInfo((Location) e.getKey())); + effs.add(((Effect) e.getValue()).toString()); + } + context.setSessionData(CK.E_EFFECTS, effs); + context.setSessionData(CK.E_EFFECTS_LOCATIONS, locs); + } + if (event.stormWorld != null) { + context.setSessionData(CK.E_WORLD_STORM, event.stormWorld.getName()); + context.setSessionData(CK.E_WORLD_STORM_DURATION, (long) event.stormDuration); + } + if (event.thunderWorld != null) { + context.setSessionData(CK.E_WORLD_THUNDER, event.thunderWorld.getName()); + context.setSessionData(CK.E_WORLD_THUNDER_DURATION, (long) event.thunderDuration); + } + if (event.mobSpawns != null && event.mobSpawns.isEmpty() == false) { + LinkedList questMobs = new LinkedList(); + for (QuestMob questMob : event.mobSpawns) { + questMobs.add(questMob.serialize()); + } + context.setSessionData(CK.E_MOB_TYPES, questMobs); + } + if (event.lightningStrikes != null && event.lightningStrikes.isEmpty() == false) { + LinkedList locs = new LinkedList(); + for (Location loc : event.lightningStrikes) { + locs.add(Quests.getLocationInfo(loc)); + } + context.setSessionData(CK.E_LIGHTNING, locs); + } + if (event.potionEffects != null && event.potionEffects.isEmpty() == false) { + LinkedList types = new LinkedList(); + LinkedList durations = new LinkedList(); + LinkedList mags = new LinkedList(); + for (PotionEffect pe : event.potionEffects) { + types.add(pe.getType().getName()); + durations.add((long) pe.getDuration()); + mags.add(pe.getAmplifier()); + } + context.setSessionData(CK.E_POTION_TYPES, types); + context.setSessionData(CK.E_POTION_DURATIONS, durations); + context.setSessionData(CK.E_POTION_STRENGHT, mags); + } + if (event.hunger > -1) { + context.setSessionData(CK.E_HUNGER, (Integer) event.hunger); + } + if (event.saturation > -1) { + context.setSessionData(CK.E_SATURATION, (Integer) event.saturation); + } + if (event.health > -1) { + context.setSessionData(CK.E_HEALTH, (Float) event.health); + } + if (event.teleport != null) { + context.setSessionData(CK.E_TELEPORT, Quests.getLocationInfo(event.teleport)); + } + if (event.commands != null) { + context.setSessionData(CK.E_COMMANDS, event.commands); + } + } + + private class SelectEditPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + String text = ChatColor.GOLD + "- " + Lang.get("eventEditorEdit") + " -\n"; + for (Event evt : quests.events) { + text += ChatColor.AQUA + evt.name + ChatColor.YELLOW + ", "; + } + text = text.substring(0, text.length() - 2) + "\n"; + text += ChatColor.YELLOW + Lang.get("eventEditorEnterEventName"); + return text; + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + for (Event evt : quests.events) { + if (evt.name.equalsIgnoreCase(input)) { + context.setSessionData(CK.E_OLD_EVENT, evt.name); + context.setSessionData(CK.E_NAME, evt.name); + loadData(evt, context); + return new CreateMenuPrompt(); + } + } + ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorNotFound")); + return new SelectEditPrompt(); + } else { + return new MenuPrompt(); + } + } + } + + private class SelectDeletePrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + String text = ChatColor.GOLD + "- " + Lang.get("eventEditorDelete") + " -\n"; + for (Event evt : quests.events) { + text += ChatColor.AQUA + evt.name + ChatColor.YELLOW + ","; + } + text = text.substring(0, text.length() - 1) + "\n"; + text += ChatColor.YELLOW + Lang.get("eventEditorEnterEventName"); + return text; + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + LinkedList used = new LinkedList(); + for (Event evt : quests.events) { + if (evt.name.equalsIgnoreCase(input)) { + for (Quest quest : quests.getQuests()) { + for (Stage stage : quest.orderedStages) { + if (stage.finishEvent != null && stage.finishEvent.name.equalsIgnoreCase(evt.name)) { + used.add(quest.name); + break; + } + } + } + if (used.isEmpty()) { + context.setSessionData(CK.ED_EVENT_DELETE, evt.name); + return new DeletePrompt(); + } else { + ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorEventInUse") + " \"" + ChatColor.DARK_PURPLE + evt.name + ChatColor.RED + "\":"); + for (String s : used) { + ((Player) context.getForWhom()).sendMessage(ChatColor.RED + "- " + ChatColor.DARK_RED + s); + } + ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorMustModifyQuests")); + return new SelectDeletePrompt(); + } + } + } + ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorNotFound")); + return new SelectDeletePrompt(); + } else { + return new MenuPrompt(); + } + } + } + + private class DeletePrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + String text = ChatColor.RED + Lang.get("eventEditorDeletePrompt") + " \"" + ChatColor.GOLD + (String) context.getSessionData(CK.ED_EVENT_DELETE) + ChatColor.RED + "\"?\n"; + text += ChatColor.YELLOW + Lang.get("yesWord") + "/" + Lang.get("noWord"); + return text; + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase(Lang.get("yesWord"))) { + deleteEvent(context); + return new MenuPrompt(); + } else if (input.equalsIgnoreCase(Lang.get("noWord"))) { + return new MenuPrompt(); + } else { + return new DeletePrompt(); + } + } + } + + private class CreateMenuPrompt extends FixedSetPrompt { + + public CreateMenuPrompt() { + super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"); + } + + @SuppressWarnings("unchecked") + @Override + public String getPromptText(ConversationContext context) { + String text = ChatColor.GOLD + "- " + Lang.get("event") + ": " + ChatColor.AQUA + context.getSessionData(CK.E_NAME) + ChatColor.GOLD + " -\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetName") + "\n"; + if (context.getSessionData(CK.E_MESSAGE) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMessage") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMessage") + "(" + ChatColor.AQUA + "\"" + context.getSessionData(CK.E_MESSAGE) + "\"" + ChatColor.YELLOW + ")\n"; + } + if (context.getSessionData(CK.E_CLEAR_INVENTORY) == null) { + context.setSessionData(CK.E_CLEAR_INVENTORY, "No"); + } + if (context.getSessionData(CK.E_FAIL_QUEST) == null) { + context.setSessionData(CK.E_FAIL_QUEST, "No"); + } + text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorClearInv") + ": " + ChatColor.AQUA + context.getSessionData(CK.E_CLEAR_INVENTORY) + "\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorFailQuest") + ": " + ChatColor.AQUA + context.getSessionData(CK.E_FAIL_QUEST) + "\n"; + if (context.getSessionData(CK.E_ITEMS) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetItems") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetItems") + "\n"; + LinkedList items = (LinkedList) context.getSessionData(CK.E_ITEMS); + for (ItemStack is : items) { + text += ChatColor.GRAY + " - " + ItemUtil.getString(is) + "\n"; + } + } + if (context.getSessionData(CK.E_EXPLOSIONS) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetExplosions") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetExplosions") + "\n"; + LinkedList locations = (LinkedList) context.getSessionData(CK.E_EXPLOSIONS); + for (String loc : locations) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + loc + "\n"; + } + } + if (context.getSessionData(CK.E_EFFECTS) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetEffects") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetEffects") + "\n"; + LinkedList effects = (LinkedList) context.getSessionData(CK.E_EFFECTS); + LinkedList locations = (LinkedList) context.getSessionData(CK.E_EFFECTS_LOCATIONS); + for (String effect : effects) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + effect + ChatColor.GRAY + " at " + ChatColor.DARK_AQUA + locations.get(effects.indexOf(effect)) + "\n"; + } + } + if (context.getSessionData(CK.E_WORLD_STORM) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetStorm") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetStorm") + " (" + ChatColor.AQUA + (String) context.getSessionData(CK.E_WORLD_STORM) + ChatColor.YELLOW + " -> " + ChatColor.DARK_AQUA + Quests.getTime((Long) context.getSessionData(CK.E_WORLD_STORM_DURATION)) + ChatColor.YELLOW + ")\n"; + } + if (context.getSessionData(CK.E_WORLD_THUNDER) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "9" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetThunder") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "9" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetThunder") + " (" + ChatColor.AQUA + (String) context.getSessionData(CK.E_WORLD_THUNDER) + ChatColor.YELLOW + " -> " + ChatColor.DARK_AQUA + Quests.getTime((Long) context.getSessionData(CK.E_WORLD_THUNDER_DURATION)) + ChatColor.YELLOW + ")\n"; + } + if (context.getSessionData(CK.E_MOB_TYPES) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "10" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobSpawns") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + } else { + LinkedList types = (LinkedList) context.getSessionData(CK.E_MOB_TYPES); + text += ChatColor.BLUE + "" + ChatColor.BOLD + "10" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobSpawns") + "\n"; + for (String s : types) { + QuestMob qm = QuestMob.fromString(s); + text += ChatColor.GRAY + " - " + ChatColor.AQUA + qm.getType().name() + ((qm.getName() != null) ? ": " + qm.getName() : "") + ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + qm.getSpawnAmounts() + ChatColor.GRAY + " -> " + ChatColor.GREEN + Quests.getLocationInfo(qm.getSpawnLocation()) + "\n"; + } + } + if (context.getSessionData(CK.E_LIGHTNING) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "11" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetLightning") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "11" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetLightning") + "\n"; + LinkedList locations = (LinkedList) context.getSessionData(CK.E_LIGHTNING); + for (String loc : locations) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + loc + "\n"; + } + } + if (context.getSessionData(CK.E_POTION_TYPES) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "12" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetPotionEffects") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "12" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetPotionEffects") + "\n"; + LinkedList types = (LinkedList) context.getSessionData(CK.E_POTION_TYPES); + LinkedList durations = (LinkedList) context.getSessionData(CK.E_POTION_DURATIONS); + LinkedList mags = (LinkedList) context.getSessionData(CK.E_POTION_STRENGHT); + int index = -1; + for (String type : types) { + index++; + text += ChatColor.GRAY + " - " + ChatColor.AQUA + type + ChatColor.DARK_PURPLE + " " + Quests.getNumeral(mags.get(index)) + ChatColor.GRAY + " -> " + ChatColor.DARK_AQUA + Quests.getTime(durations.get(index) * 50L) + "\n"; + } + } + if (context.getSessionData(CK.E_HUNGER) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "13" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetHunger") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "13" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetHunger") + ChatColor.AQUA + " (" + (Integer) context.getSessionData(CK.E_HUNGER) + ")\n"; + } + if (context.getSessionData(CK.E_SATURATION) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "14" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetSaturation") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "14" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetSaturation") + ChatColor.AQUA + " (" + (Integer) context.getSessionData(CK.E_SATURATION) + ")\n"; + } + if (context.getSessionData(CK.E_HEALTH) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "15" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetHealth") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "15" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetHealth") + ChatColor.AQUA + " (" + (Integer) context.getSessionData(CK.E_HEALTH) + ")\n"; + } + if (context.getSessionData(CK.E_TELEPORT) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "16" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetTeleport") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "16" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetTeleport") + ChatColor.AQUA + " (" + (String) context.getSessionData(CK.E_TELEPORT) + ")\n"; + } + if (context.getSessionData(CK.E_COMMANDS) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "17" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetCommands") + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "17" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetCommands") + "\n"; + for (String s : (LinkedList) context.getSessionData(CK.E_COMMANDS)) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; + } + } + text += ChatColor.GREEN + "" + ChatColor.BOLD + "18" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done") + "\n"; + text += ChatColor.RED + "" + ChatColor.BOLD + "19" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("quit"); + return text; + } + + @Override + public Prompt acceptValidatedInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase("1")) { + return new SetNamePrompt(); + } else if (input.equalsIgnoreCase("2")) { + return new MessagePrompt(); + } else if (input.equalsIgnoreCase("3")) { + String s = (String) context.getSessionData(CK.E_CLEAR_INVENTORY); + if (s.equalsIgnoreCase(Lang.get("yesWord"))) { + context.setSessionData(CK.E_CLEAR_INVENTORY, Lang.get("noWord")); + } else { + context.setSessionData(CK.E_CLEAR_INVENTORY, Lang.get("yesWord")); + } + return new CreateMenuPrompt(); + } else if (input.equalsIgnoreCase("4")) { + String s = (String) context.getSessionData(CK.E_FAIL_QUEST); + if (s.equalsIgnoreCase(Lang.get("yesWord"))) { + context.setSessionData(CK.E_FAIL_QUEST, Lang.get("noWord")); + } else { + context.setSessionData(CK.E_FAIL_QUEST, Lang.get("yesWord")); + } + return new CreateMenuPrompt(); + } else if (input.equalsIgnoreCase("5")) { + return new ItemListPrompt(); + } else if (input.equalsIgnoreCase("6")) { + selectedExplosionLocations.put(((Player) context.getForWhom()).getUniqueId(), null); + return new ExplosionPrompt(); + } else if (input.equalsIgnoreCase("7")) { + return new EffectListPrompt(); + } else if (input.equalsIgnoreCase("8")) { + return new StormPrompt(); + } else if (input.equalsIgnoreCase("9")) { + return new ThunderPrompt(); + } else if (input.equalsIgnoreCase("10")) { + return new MobPrompt(); + } else if (input.equalsIgnoreCase("11")) { + selectedLightningLocations.put(((Player) context.getForWhom()).getUniqueId(), null); + return new LightningPrompt(); + } else if (input.equalsIgnoreCase("12")) { + return new PotionEffectPrompt(); + } else if (input.equalsIgnoreCase("13")) { + return new HungerPrompt(); + } else if (input.equalsIgnoreCase("14")) { + return new SaturationPrompt(); + } else if (input.equalsIgnoreCase("15")) { + return new HealthPrompt(); + } else if (input.equalsIgnoreCase("16")) { + selectedTeleportLocations.put(((Player) context.getForWhom()).getUniqueId(), null); + return new TeleportPrompt(); + } else if (input.equalsIgnoreCase("17")) { + return new CommandsPrompt(); + } else if (input.equalsIgnoreCase("18")) { + if (context.getSessionData(CK.E_OLD_EVENT) != null) { + return new FinishPrompt((String) context.getSessionData(CK.E_OLD_EVENT)); + } else { + return new FinishPrompt(null); + } + } else if (input.equalsIgnoreCase("19")) { + return new QuitPrompt(); + } + return null; + } + } + + private class QuitPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + String text = ChatColor.GREEN + Lang.get("eventEditorQuitWithoutSaving") + "\n"; + text += ChatColor.YELLOW + Lang.get("yesWord") + "/" + Lang.get("noWord"); + return text; + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase(Lang.get("yesWord"))) { + clearData(context); + return new MenuPrompt(); + } else if (input.equalsIgnoreCase(Lang.get("noWord"))) { + return new CreateMenuPrompt(); + } else { + ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("invalidOption")); + return new QuitPrompt(); + } + } + } + + private class FinishPrompt extends StringPrompt { + + String modName = null; + LinkedList modified = new LinkedList(); + + public FinishPrompt(String modifiedName) { + if (modifiedName != null) { + modName = modifiedName; + for (Quest q : quests.getQuests()) { + for (Stage s : q.orderedStages) { + if (s.finishEvent != null && s.finishEvent.name != null) { + if (s.finishEvent.name.equalsIgnoreCase(modifiedName)) { + modified.add(q.getName()); + break; + } + } + } + } + } + } + + @Override + public String getPromptText(ConversationContext context) { + String text = ChatColor.RED + Lang.get("eventEditorFinishAndSave") + " \"" + ChatColor.GOLD + (String) context.getSessionData(CK.E_NAME) + ChatColor.RED + "\"?\n"; + if (modified.isEmpty() == false) { + text += ChatColor.RED + Lang.get("eventEditorModifiedNote") + "\n"; + for (String s : modified) { + text += ChatColor.GRAY + " - " + ChatColor.DARK_RED + s + "\n"; + } + text += ChatColor.RED + Lang.get("eventEditorForcedToQuit") + "\n"; + } + text += ChatColor.YELLOW + Lang.get("yesWord") + "/" + Lang.get("noWord"); + return text; + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase(Lang.get("yesWord"))) { + saveEvent(context); + return new MenuPrompt(); + } else if (input.equalsIgnoreCase(Lang.get("noWord"))) { + return new CreateMenuPrompt(); + } else { + ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("invalidOption")); + return new FinishPrompt(modName); + } + } + } + + // Convenience methods to reduce typecasting + private static String getCString(ConversationContext context, String path) { + return (String) context.getSessionData(path); + } + + @SuppressWarnings("unchecked") + private static LinkedList getCStringList(ConversationContext context, String path) { + return (LinkedList) context.getSessionData(path); + } + + private static Integer getCInt(ConversationContext context, String path) { + return (Integer) context.getSessionData(path); + } + + @SuppressWarnings("unchecked") + private static LinkedList getCIntList(ConversationContext context, String path) { + return (LinkedList) context.getSessionData(path); + } + + @SuppressWarnings("unused") private static Boolean getCBoolean(ConversationContext context, String path) { - return (Boolean) context.getSessionData(path); - } + return (Boolean) context.getSessionData(path); + } - @SuppressWarnings({ "unchecked", "unused" }) - private static LinkedList getCBooleanList(ConversationContext context, String path) { - return (LinkedList) context.getSessionData(path); - } + @SuppressWarnings({ "unchecked", "unused" }) + private static LinkedList getCBooleanList(ConversationContext context, String path) { + return (LinkedList) context.getSessionData(path); + } - private static Long getCLong(ConversationContext context, String path) { - return (Long) context.getSessionData(path); - } + private static Long getCLong(ConversationContext context, String path) { + return (Long) context.getSessionData(path); + } - @SuppressWarnings("unchecked") - private static LinkedList getCLongList(ConversationContext context, String path) { - return (LinkedList) context.getSessionData(path); - } - // + @SuppressWarnings("unchecked") + private static LinkedList getCLongList(ConversationContext context, String path) { + return (LinkedList) context.getSessionData(path); + } + // - private void deleteEvent(ConversationContext context) { + private void deleteEvent(ConversationContext context) { + YamlConfiguration data = new YamlConfiguration(); + try { + eventsFile = new File(quests.getDataFolder(), "events.yml"); + data.load(eventsFile); + } catch (IOException e) { + e.printStackTrace(); + ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorReadingFile")); + return; + } catch (InvalidConfigurationException e) { + e.printStackTrace(); + ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorReadingFile")); + return; + } + String event = (String) context.getSessionData(CK.ED_EVENT_DELETE); + ConfigurationSection sec = data.getConfigurationSection("events"); + sec.set(event, null); + try { + data.save(eventsFile); + } catch (IOException e) { + ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorSaving")); + return; + } + quests.reloadQuests(); + ((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW + Lang.get("eventEditorDeleted")); + for (Quester q : quests.questers.values()) { + for (Quest quest : q.currentQuests.keySet()) { + q.checkQuest(quest); + } + } + clearData(context); + } - YamlConfiguration data = new YamlConfiguration(); - - try { - eventsFile = new File(quests.getDataFolder(), "events.yml"); - data.load(eventsFile); - } catch (IOException e) { - e.printStackTrace(); - ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorReadingFile")); - return; - } catch (InvalidConfigurationException e) { - e.printStackTrace(); - ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorReadingFile")); - return; - } - - String event = (String) context.getSessionData(CK.ED_EVENT_DELETE); - ConfigurationSection sec = data.getConfigurationSection("events"); - sec.set(event, null); - - try { - data.save(eventsFile); - } catch (IOException e) { - ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorSaving")); - return; - } - - quests.reloadQuests(); - - ((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW + Lang.get("eventEditorDeleted")); - - for (Quester q : quests.questers.values()) { - - for (Quest quest : q.currentQuests.keySet()) { - q.checkQuest(quest); - } - - } - - clearData(context); - - } - - private void saveEvent(ConversationContext context) { - - YamlConfiguration data = new YamlConfiguration(); - - try { - eventsFile = new File(quests.getDataFolder(), "events.yml"); - data.load(eventsFile); - } catch (IOException e) { - e.printStackTrace(); - ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorReadingFile")); - return; - } catch (InvalidConfigurationException e) { - e.printStackTrace(); - ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorReadingFile")); - return; - } - - if (((String) context.getSessionData(CK.E_OLD_EVENT)).isEmpty() == false) { - data.set("events." + (String) context.getSessionData(CK.E_OLD_EVENT), null); - quests.events.remove(quests.getEvent((String) context.getSessionData(CK.E_OLD_EVENT))); - } - - ConfigurationSection section = data.createSection("events." + (String) context.getSessionData(CK.E_NAME)); - names.remove((String) context.getSessionData(CK.E_NAME)); - - if (context.getSessionData(CK.E_MESSAGE) != null) { - section.set("message", getCString(context, CK.E_MESSAGE)); - } - - if (context.getSessionData(CK.E_CLEAR_INVENTORY) != null) { - String s = getCString(context, CK.E_CLEAR_INVENTORY); - if (s.equalsIgnoreCase(Lang.get("yesWord"))) { - section.set("clear-inventory", true); - } - } - - if (context.getSessionData(CK.E_FAIL_QUEST) != null) { - String s = getCString(context, CK.E_FAIL_QUEST); - if (s.equalsIgnoreCase(Lang.get("yesWord"))) { - section.set("fail-quest", true); - } - } - - if (context.getSessionData(CK.E_ITEMS) != null) { - - @SuppressWarnings("unchecked") + private void saveEvent(ConversationContext context) { + YamlConfiguration data = new YamlConfiguration(); + try { + eventsFile = new File(quests.getDataFolder(), "events.yml"); + data.load(eventsFile); + } catch (IOException e) { + e.printStackTrace(); + ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorReadingFile")); + return; + } catch (InvalidConfigurationException e) { + e.printStackTrace(); + ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorReadingFile")); + return; + } + if (((String) context.getSessionData(CK.E_OLD_EVENT)).isEmpty() == false) { + data.set("events." + (String) context.getSessionData(CK.E_OLD_EVENT), null); + quests.events.remove(quests.getEvent((String) context.getSessionData(CK.E_OLD_EVENT))); + } + ConfigurationSection section = data.createSection("events." + (String) context.getSessionData(CK.E_NAME)); + names.remove((String) context.getSessionData(CK.E_NAME)); + if (context.getSessionData(CK.E_MESSAGE) != null) { + section.set("message", getCString(context, CK.E_MESSAGE)); + } + if (context.getSessionData(CK.E_CLEAR_INVENTORY) != null) { + String s = getCString(context, CK.E_CLEAR_INVENTORY); + if (s.equalsIgnoreCase(Lang.get("yesWord"))) { + section.set("clear-inventory", true); + } + } + if (context.getSessionData(CK.E_FAIL_QUEST) != null) { + String s = getCString(context, CK.E_FAIL_QUEST); + if (s.equalsIgnoreCase(Lang.get("yesWord"))) { + section.set("fail-quest", true); + } + } + if (context.getSessionData(CK.E_ITEMS) != null) { + @SuppressWarnings("unchecked") LinkedList items = (LinkedList) context.getSessionData(CK.E_ITEMS); - LinkedList lines = new LinkedList(); - - for (ItemStack is : items) { - lines.add(ItemUtil.serialize(is)); - } - - section.set("items", lines); - - } - - if (context.getSessionData(CK.E_EXPLOSIONS) != null) { - - LinkedList locations = getCStringList(context, CK.E_EXPLOSIONS); - section.set("explosions", locations); - - } - - if (context.getSessionData(CK.E_EFFECTS) != null) { - - LinkedList effects = getCStringList(context, CK.E_EFFECTS); - LinkedList locations = getCStringList(context, CK.E_EFFECTS_LOCATIONS); - - section.set("effects", effects); - section.set("effect-locations", locations); - - } - - if (context.getSessionData(CK.E_WORLD_STORM) != null) { - - String world = getCString(context, CK.E_WORLD_STORM); - Long duration = getCLong(context, CK.E_WORLD_STORM_DURATION); - - section.set("storm-world", world); - section.set("storm-duration", duration / 50L); - - } - - if (context.getSessionData(CK.E_WORLD_THUNDER) != null) { - - String world = getCString(context, CK.E_WORLD_THUNDER); - Long duration = getCLong(context, CK.E_WORLD_THUNDER_DURATION); - - section.set("thunder-world", world); - section.set("thunder-duration", duration / 50L); - - } - - try { - if (context.getSessionData(CK.E_MOB_TYPES) != null) { - int count = 0; - - 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); - - if (questMob == null) { - continue; - } - - ss.set("name", questMob.getName()); - ss.set("spawn-location", Quests.getLocationInfo(questMob.getSpawnLocation())); - ss.set("mob-type", questMob.getType().name()); - 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) { - - LinkedList locations = getCStringList(context, CK.E_LIGHTNING); - section.set("lightning-strikes", locations); - - } - - if (context.getSessionData(CK.E_COMMANDS) != null) { - - LinkedList commands = getCStringList(context, CK.E_COMMANDS); - if (commands.isEmpty() == false) { - section.set("commands", commands); - } - - } - - if (context.getSessionData(CK.E_POTION_TYPES) != null) { - - LinkedList types = getCStringList(context, CK.E_POTION_TYPES); - LinkedList durations = getCLongList(context, CK.E_POTION_DURATIONS); - LinkedList mags = getCIntList(context, CK.E_POTION_STRENGHT); - - section.set("potion-effect-types", types); - section.set("potion-effect-durations", durations); - section.set("potion-effect-amplifiers", mags); - - } - - if (context.getSessionData(CK.E_HUNGER) != null) { - - Integer i = getCInt(context, CK.E_HUNGER); - section.set("hunger", i); - - } - - if (context.getSessionData(CK.E_SATURATION) != null) { - - Integer i = getCInt(context, CK.E_SATURATION); - section.set("saturation", i); - - } - - if (context.getSessionData(CK.E_HEALTH) != null) { - - Integer i = getCInt(context, CK.E_HEALTH); - section.set("health", i); - - } - - if (context.getSessionData(CK.E_TELEPORT) != null) { - - section.set("teleport-location", getCString(context, CK.E_TELEPORT)); - - } - - try { - data.save(eventsFile); - } catch (IOException e) { - ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorSaving")); - return; - } - - quests.reloadQuests(); - - ((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW + Lang.get("eventEditorSaved")); - - for (Quester q : quests.questers.values()) { - - for (Quest quest : q.currentQuests.keySet()) { - q.checkQuest(quest); - } - - } - - clearData(context); - - } - - private class EventNamePrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - - String text - = ChatColor.AQUA + Lang.get("eventEditorCreate") + ChatColor.GOLD + " - " + Lang.get("eventEditorEnterEventName"); - - return text; - - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - - for (Event e : quests.events) { - - if (e.name.equalsIgnoreCase(input)) { - - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorExists")); - return new EventNamePrompt(); - - } - - } - - if (names.contains(input)) { - - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorSomeone")); - return new EventNamePrompt(); - - } - - if (StringUtils.isAlphanumeric(input) == false) { - - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorAlpha")); - return new EventNamePrompt(); - - } - - context.setSessionData(CK.E_NAME, input); - names.add(input); - return new CreateMenuPrompt(); - - } else { - - return new MenuPrompt(); - - } - - } - } - - @SuppressWarnings("unused") + LinkedList lines = new LinkedList(); + for (ItemStack is : items) { + lines.add(ItemUtil.serialize(is)); + } + section.set("items", lines); + } + if (context.getSessionData(CK.E_EXPLOSIONS) != null) { + LinkedList locations = getCStringList(context, CK.E_EXPLOSIONS); + section.set("explosions", locations); + } + if (context.getSessionData(CK.E_EFFECTS) != null) { + LinkedList effects = getCStringList(context, CK.E_EFFECTS); + LinkedList locations = getCStringList(context, CK.E_EFFECTS_LOCATIONS); + section.set("effects", effects); + section.set("effect-locations", locations); + } + if (context.getSessionData(CK.E_WORLD_STORM) != null) { + String world = getCString(context, CK.E_WORLD_STORM); + Long duration = getCLong(context, CK.E_WORLD_STORM_DURATION); + section.set("storm-world", world); + section.set("storm-duration", duration / 50L); + } + if (context.getSessionData(CK.E_WORLD_THUNDER) != null) { + String world = getCString(context, CK.E_WORLD_THUNDER); + Long duration = getCLong(context, CK.E_WORLD_THUNDER_DURATION); + section.set("thunder-world", world); + section.set("thunder-duration", duration / 50L); + } + try { + if (context.getSessionData(CK.E_MOB_TYPES) != null) { + int count = 0; + 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); + if (questMob == null) { + continue; + } + ss.set("name", questMob.getName()); + ss.set("spawn-location", Quests.getLocationInfo(questMob.getSpawnLocation())); + ss.set("mob-type", questMob.getType().name()); + 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) { + LinkedList locations = getCStringList(context, CK.E_LIGHTNING); + section.set("lightning-strikes", locations); + } + if (context.getSessionData(CK.E_COMMANDS) != null) { + LinkedList commands = getCStringList(context, CK.E_COMMANDS); + if (commands.isEmpty() == false) { + section.set("commands", commands); + } + } + if (context.getSessionData(CK.E_POTION_TYPES) != null) { + LinkedList types = getCStringList(context, CK.E_POTION_TYPES); + LinkedList durations = getCLongList(context, CK.E_POTION_DURATIONS); + LinkedList mags = getCIntList(context, CK.E_POTION_STRENGHT); + section.set("potion-effect-types", types); + section.set("potion-effect-durations", durations); + section.set("potion-effect-amplifiers", mags); + } + if (context.getSessionData(CK.E_HUNGER) != null) { + Integer i = getCInt(context, CK.E_HUNGER); + section.set("hunger", i); + } + if (context.getSessionData(CK.E_SATURATION) != null) { + Integer i = getCInt(context, CK.E_SATURATION); + section.set("saturation", i); + } + if (context.getSessionData(CK.E_HEALTH) != null) { + Integer i = getCInt(context, CK.E_HEALTH); + section.set("health", i); + } + if (context.getSessionData(CK.E_TELEPORT) != null) { + section.set("teleport-location", getCString(context, CK.E_TELEPORT)); + } + try { + data.save(eventsFile); + } catch (IOException e) { + ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorErrorSaving")); + return; + } + quests.reloadQuests(); + ((Player) context.getForWhom()).sendMessage(ChatColor.YELLOW + Lang.get("eventEditorSaved")); + for (Quester q : quests.questers.values()) { + for (Quest quest : q.currentQuests.keySet()) { + q.checkQuest(quest); + } + } + clearData(context); + } + + private class EventNamePrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + String text = ChatColor.AQUA + Lang.get("eventEditorCreate") + ChatColor.GOLD + " - " + Lang.get("eventEditorEnterEventName"); + return text; + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + for (Event e : quests.events) { + if (e.name.equalsIgnoreCase(input)) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorExists")); + return new EventNamePrompt(); + } + } + if (names.contains(input)) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorSomeone")); + return new EventNamePrompt(); + } + if (StringUtils.isAlphanumeric(input) == false) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorAlpha")); + return new EventNamePrompt(); + } + context.setSessionData(CK.E_NAME, input); + names.add(input); + return new CreateMenuPrompt(); + } else { + return new MenuPrompt(); + } + } + } + + @SuppressWarnings("unused") private class SetNpcStartPrompt extends NumericPrompt { - @Override - public String getPromptText(ConversationContext context) { - - return ChatColor.YELLOW + Lang.get("eventEditorEnterNPCId"); - - } - - @Override - protected Prompt acceptValidatedInput(ConversationContext context, Number input) { - - if (input.intValue() != -1) { - - if (CitizensAPI.getNPCRegistry().getById(input.intValue()) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorNoNPCExists")); - return new SetNpcStartPrompt(); - } - - context.setSessionData("npcStart", input.intValue()); - - } - - return new CreateMenuPrompt(); - - } - } - - private class ExplosionPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - - return ChatColor.YELLOW + Lang.get("eventEditorExplosionPrompt"); - - } - - @SuppressWarnings("unchecked") @Override - public Prompt acceptInput(ConversationContext context, String input) { + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("eventEditorEnterNPCId"); + } - Player player = (Player) context.getForWhom(); + @Override + protected Prompt acceptValidatedInput(ConversationContext context, Number input) { + if (input.intValue() != -1) { + if (CitizensAPI.getNPCRegistry().getById(input.intValue()) == null) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorNoNPCExists")); + return new SetNpcStartPrompt(); + } + context.setSessionData("npcStart", input.intValue()); + } + return new CreateMenuPrompt(); + } + } - if (input.equalsIgnoreCase(Lang.get("cmdAdd"))) { + private class ExplosionPrompt extends StringPrompt { - Block block = selectedExplosionLocations.get(player.getUniqueId()); - if (block != null) { + @Override + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("eventEditorExplosionPrompt"); + } - Location loc = block.getLocation(); + @SuppressWarnings("unchecked") + @Override + public Prompt acceptInput(ConversationContext context, String input) { + Player player = (Player) context.getForWhom(); + if (input.equalsIgnoreCase(Lang.get("cmdAdd"))) { + Block block = selectedExplosionLocations.get(player.getUniqueId()); + if (block != null) { + Location loc = block.getLocation(); + LinkedList locs; + if (context.getSessionData(CK.E_EXPLOSIONS) != null) { + locs = (LinkedList) context.getSessionData(CK.E_EXPLOSIONS); + } else { + locs = new LinkedList(); + } + locs.add(Quests.getLocationInfo(loc)); + context.setSessionData(CK.E_EXPLOSIONS, locs); + selectedExplosionLocations.remove(player.getUniqueId()); + } else { + player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst")); + return new ExplosionPrompt(); + } + return new CreateMenuPrompt(); + } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { + context.setSessionData(CK.E_EXPLOSIONS, null); + selectedExplosionLocations.remove(player.getUniqueId()); + return new CreateMenuPrompt(); + } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { + selectedExplosionLocations.remove(player.getUniqueId()); + return new CreateMenuPrompt(); + } else { + return new ExplosionPrompt(); + } + } + } - LinkedList locs; - if (context.getSessionData(CK.E_EXPLOSIONS) != null) { - locs = (LinkedList) context.getSessionData(CK.E_EXPLOSIONS); - } else { - locs = new LinkedList(); - } + private class SetNamePrompt extends StringPrompt { - locs.add(Quests.getLocationInfo(loc)); - context.setSessionData(CK.E_EXPLOSIONS, locs); - selectedExplosionLocations.remove(player.getUniqueId()); + @Override + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("eventEditorEnterEventName"); + } - } else { - player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst")); - return new ExplosionPrompt(); - } + @Override + public Prompt acceptInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + for (Event e : quests.events) { + if (e.name.equalsIgnoreCase(input)) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorExists")); + return new SetNamePrompt(); + } + } + if (names.contains(input)) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorSomeone")); + return new SetNamePrompt(); + } + if (StringUtils.isAlphanumeric(input) == false) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorAlpha")); + return new SetNamePrompt(); + } + names.remove((String) context.getSessionData(CK.E_NAME)); + context.setSessionData(CK.E_NAME, input); + names.add(input); + } + return new CreateMenuPrompt(); + } + } - return new CreateMenuPrompt(); + private class MessagePrompt extends StringPrompt { - } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { + @Override + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("eventEditorSetMessagePrompt"); + } - context.setSessionData(CK.E_EXPLOSIONS, null); - selectedExplosionLocations.remove(player.getUniqueId()); - return new CreateMenuPrompt(); + @Override + public Prompt acceptInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdNone")) == false) { + context.setSessionData(CK.E_MESSAGE, input); + } else if (input.equalsIgnoreCase(Lang.get("cmdNone"))) { + context.setSessionData(CK.E_MESSAGE, null); + } + return new CreateMenuPrompt(); + } + } - } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { + private class ItemListPrompt extends FixedSetPrompt { - selectedExplosionLocations.remove(player.getUniqueId()); - return new CreateMenuPrompt(); + public ItemListPrompt() { + super("1", "2", "3"); + } - } else { - return new ExplosionPrompt(); - } + @Override + public String getPromptText(ConversationContext context) { + // Check/add newly made item + if (context.getSessionData("newItem") != null) { + if (context.getSessionData(CK.E_ITEMS) != null) { + List items = getItems(context); + items.add((ItemStack) context.getSessionData("tempStack")); + context.setSessionData(CK.E_ITEMS, items); + } else { + LinkedList itemRews = new LinkedList(); + itemRews.add((ItemStack) context.getSessionData("tempStack")); + context.setSessionData(CK.E_ITEMS, itemRews); + } + context.setSessionData("newItem", null); + context.setSessionData("tempStack", null); + } + String text = ChatColor.GOLD + Lang.get("eventEditorGiveItemsTitle") + "\n"; + if (context.getSessionData(CK.E_ITEMS) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorAddItem") + "\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); + } else { + for (ItemStack is : getItems(context)) { + text += ChatColor.GRAY + " - " + ItemUtil.getDisplayString(is) + "\n"; + } + text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorAddItem") + "\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); + } + return text; + } - } - } + @Override + protected Prompt acceptValidatedInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase("1")) { + return new ItemStackPrompt(ItemListPrompt.this); + } else if (input.equalsIgnoreCase("2")) { + context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorItemsCleared")); + context.setSessionData(CK.E_ITEMS, null); + return new ItemListPrompt(); + } else if (input.equalsIgnoreCase("3")) { + return new CreateMenuPrompt(); + } + return null; + } - private class SetNamePrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - - return ChatColor.YELLOW + Lang.get("eventEditorEnterEventName"); - - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - - for (Event e : quests.events) { - - if (e.name.equalsIgnoreCase(input)) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorExists")); - return new SetNamePrompt(); - } - - } - - if (names.contains(input)) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorSomeone")); - return new SetNamePrompt(); - } - - if (StringUtils.isAlphanumeric(input) == false) { - - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorAlpha")); - return new SetNamePrompt(); - - } - - names.remove((String) context.getSessionData(CK.E_NAME)); - context.setSessionData(CK.E_NAME, input); - names.add(input); - - } - - return new CreateMenuPrompt(); - - } - } - - private class MessagePrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - - return ChatColor.YELLOW + Lang.get("eventEditorSetMessagePrompt"); - - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdNone")) == false) { - context.setSessionData(CK.E_MESSAGE, input); - } else if (input.equalsIgnoreCase(Lang.get("cmdNone"))) { - context.setSessionData(CK.E_MESSAGE, null); - } - - return new CreateMenuPrompt(); - - } - } - - private class ItemListPrompt extends FixedSetPrompt { - - public ItemListPrompt() { - - super("1", "2", "3"); - - } - - @Override - public String getPromptText(ConversationContext context) { - - // Check/add newly made item - if (context.getSessionData("newItem") != null) { - if (context.getSessionData(CK.E_ITEMS) != null) { - List items = getItems(context); - items.add((ItemStack) context.getSessionData("tempStack")); - context.setSessionData(CK.E_ITEMS, items); - } else { - LinkedList itemRews = new LinkedList(); - itemRews.add((ItemStack) context.getSessionData("tempStack")); - context.setSessionData(CK.E_ITEMS, itemRews); - } - - context.setSessionData("newItem", null); - context.setSessionData("tempStack", null); - - } - - String text = ChatColor.GOLD + Lang.get("eventEditorGiveItemsTitle") + "\n"; - if (context.getSessionData(CK.E_ITEMS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorAddItem") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); - } else { - - for (ItemStack is : getItems(context)) { - - text += ChatColor.GRAY + " - " + ItemUtil.getDisplayString(is) + "\n"; - - } - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorAddItem") + "\n"; - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); - - } - - return text; - - } - - @Override - protected Prompt acceptValidatedInput(ConversationContext context, String input) { - - if (input.equalsIgnoreCase("1")) { - return new ItemStackPrompt(ItemListPrompt.this); - } else if (input.equalsIgnoreCase("2")) { - context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorItemsCleared")); - context.setSessionData(CK.E_ITEMS, null); - return new ItemListPrompt(); - } else if (input.equalsIgnoreCase("3")) { - return new CreateMenuPrompt(); - } - return null; - - } - - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") private List getItems(ConversationContext context) { - return (List) context.getSessionData(CK.E_ITEMS); - } + return (List) context.getSessionData(CK.E_ITEMS); + } + } - } + private class EffectListPrompt extends FixedSetPrompt { - private class EffectListPrompt extends FixedSetPrompt { + public EffectListPrompt() { + super("1", "2", "3", "4"); + } - public EffectListPrompt() { + @Override + public String getPromptText(ConversationContext context) { + String text = ChatColor.GOLD + "- " + Lang.get("eventEditorEffects") + " -\n"; + if (context.getSessionData(CK.E_EFFECTS) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorAddEffect") + " (" + Lang.get("noneSet") + ")\n"; + text += ChatColor.GRAY + "2 - " + Lang.get("eventEditorAddEffectLocation") + " (" + Lang.get("eventEditorNoEffects") + ")\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorAddEffect") + "\n"; + for (String s : getEffects(context)) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; + } + if (context.getSessionData(CK.E_EFFECTS_LOCATIONS) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorAddEffectLocation") + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorAddEffectLocation") + "\n"; + for (String s : getEffectLocations(context)) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; + } + } + text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); + } + return text; + } - super("1", "2", "3", "4"); + @Override + protected Prompt acceptValidatedInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase("1")) { + return new EffectPrompt(); + } else if (input.equalsIgnoreCase("2")) { + if (context.getSessionData(CK.E_EFFECTS) == null) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustAddEffects")); + return new EffectListPrompt(); + } else { + selectedEffectLocations.put(((Player) context.getForWhom()).getUniqueId(), null); + return new EffectLocationPrompt(); + } + } else if (input.equalsIgnoreCase("3")) { + context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorEffectsCleared")); + context.setSessionData(CK.E_EFFECTS, null); + context.setSessionData(CK.E_EFFECTS_LOCATIONS, null); + return new EffectListPrompt(); + } else if (input.equalsIgnoreCase("4")) { + int one; + int two; + if (context.getSessionData(CK.E_EFFECTS) != null) { + one = getEffects(context).size(); + } else { + one = 0; + } + if (context.getSessionData(CK.E_EFFECTS_LOCATIONS) != null) { + two = getEffectLocations(context).size(); + } else { + two = 0; + } + if (one == two) { + return new CreateMenuPrompt(); + } else { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorListSizeMismatch")); + return new EffectListPrompt(); + } + } + return null; + } - } - - @Override - public String getPromptText(ConversationContext context) { - - String text = ChatColor.GOLD + "- " + Lang.get("eventEditorEffects") + " -\n"; - if (context.getSessionData(CK.E_EFFECTS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorAddEffect") + " (" + Lang.get("noneSet") + ")\n"; - text += ChatColor.GRAY + "2 - " + Lang.get("eventEditorAddEffectLocation") + " (" + Lang.get("eventEditorNoEffects") + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); - } else { - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorAddEffect") + "\n"; - for (String s : getEffects(context)) { - - text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; - - } - - if (context.getSessionData(CK.E_EFFECTS_LOCATIONS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorAddEffectLocation") + " (" + Lang.get("noneSet") + ")\n"; - } else { - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorAddEffectLocation") + "\n"; - for (String s : getEffectLocations(context)) { - - text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; - - } - - } - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); - - } - - return text; - - } - - @Override - protected Prompt acceptValidatedInput(ConversationContext context, String input) { - - if (input.equalsIgnoreCase("1")) { - return new EffectPrompt(); - } else if (input.equalsIgnoreCase("2")) { - if (context.getSessionData(CK.E_EFFECTS) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustAddEffects")); - return new EffectListPrompt(); - } else { - selectedEffectLocations.put(((Player) context.getForWhom()).getUniqueId(), null); - return new EffectLocationPrompt(); - } - } else if (input.equalsIgnoreCase("3")) { - context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorEffectsCleared")); - context.setSessionData(CK.E_EFFECTS, null); - context.setSessionData(CK.E_EFFECTS_LOCATIONS, null); - return new EffectListPrompt(); - } else if (input.equalsIgnoreCase("4")) { - - int one; - int two; - - if (context.getSessionData(CK.E_EFFECTS) != null) { - one = getEffects(context).size(); - } else { - one = 0; - } - - if (context.getSessionData(CK.E_EFFECTS_LOCATIONS) != null) { - two = getEffectLocations(context).size(); - } else { - two = 0; - } - - if (one == two) { - return new CreateMenuPrompt(); - } else { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorListSizeMismatch")); - return new EffectListPrompt(); - } - } - return null; - - } - - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") private List getEffects(ConversationContext context) { - return (List) context.getSessionData(CK.E_EFFECTS); - } + return (List) context.getSessionData(CK.E_EFFECTS); + } - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") private List getEffectLocations(ConversationContext context) { - return (List) context.getSessionData(CK.E_EFFECTS_LOCATIONS); - } - } + return (List) context.getSessionData(CK.E_EFFECTS_LOCATIONS); + } + } - private class EffectLocationPrompt extends StringPrompt { + private class EffectLocationPrompt extends StringPrompt { - @Override - public String getPromptText(ConversationContext context) { - - return ChatColor.YELLOW + Lang.get("eventEditorEffectLocationPrompt"); - - } - - @SuppressWarnings("unchecked") @Override - public Prompt acceptInput(ConversationContext context, String input) { + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("eventEditorEffectLocationPrompt"); + } - Player player = (Player) context.getForWhom(); - - if (input.equalsIgnoreCase(Lang.get("cmdAdd"))) { - - Block block = selectedEffectLocations.get(player.getUniqueId()); - if (block != null) { - - Location loc = block.getLocation(); - - LinkedList locs; - if (context.getSessionData(CK.E_EFFECTS_LOCATIONS) != null) { - locs = (LinkedList) context.getSessionData(CK.E_EFFECTS_LOCATIONS); - } else { - locs = new LinkedList(); - } - - locs.add(Quests.getLocationInfo(loc)); - context.setSessionData(CK.E_EFFECTS_LOCATIONS, locs); - selectedEffectLocations.remove(player.getUniqueId()); - - } else { - player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst")); - return new EffectLocationPrompt(); - } - - return new EffectListPrompt(); - - } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { - - selectedEffectLocations.remove(player.getUniqueId()); - return new EffectListPrompt(); - - } else { - return new EffectLocationPrompt(); - } - - } - } - - private class EffectPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - - String effects = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorEffectsTitle") + "\n"; - effects += ChatColor.DARK_PURPLE + "BLAZE_SHOOT " + ChatColor.GRAY + "- " + Lang.get("effBlazeShoot") + "\n"; - effects += ChatColor.DARK_PURPLE + "BOW_FIRE " + ChatColor.GRAY + "- " + Lang.get("effBowFire") + "\n"; - effects += ChatColor.DARK_PURPLE + "CLICK1 " + ChatColor.GRAY + "- " + Lang.get("effClick1") + "\n"; - effects += ChatColor.DARK_PURPLE + "CLICK2 " + ChatColor.GRAY + "- " + Lang.get("effClick2") + "\n"; - effects += ChatColor.DARK_PURPLE + "DOOR_TOGGLE " + ChatColor.GRAY + "- " + Lang.get("effDoorToggle") + "\n"; - effects += ChatColor.DARK_PURPLE + "EXTINGUISH " + ChatColor.GRAY + "- " + Lang.get("effExtinguish") + "\n"; - effects += ChatColor.DARK_PURPLE + "GHAST_SHOOT " + ChatColor.GRAY + "- " + Lang.get("effGhastShoot") + "\n"; - effects += ChatColor.DARK_PURPLE + "GHAST_SHRIEK " + ChatColor.GRAY + "- " + Lang.get("effGhastShriek") + "\n"; - effects += ChatColor.DARK_PURPLE + "ZOMBIE_CHEW_IRON_DOOR " + ChatColor.GRAY + "- " + Lang.get("effZombieWood") + "\n"; - effects += ChatColor.DARK_PURPLE + "ZOMBIE_CHEW_WOODEN_DOOR " + ChatColor.GRAY + "- " + Lang.get("effZombieIron") + "\n"; - - return ChatColor.YELLOW + effects + Lang.get("effEnterName"); - - } - - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") @Override - public Prompt acceptInput(ConversationContext context, String input) { - - Player player = (Player) context.getForWhom(); - - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - - if (Quests.getEffect(input.toUpperCase()) != null) { - - LinkedList effects; - if (context.getSessionData(CK.E_EFFECTS) != null) { - effects = (LinkedList) context.getSessionData(CK.E_EFFECTS); - } else { - effects = new LinkedList(); - } - - effects.add(input.toUpperCase()); - context.setSessionData(CK.E_EFFECTS, effects); - selectedEffectLocations.remove(player.getUniqueId()); - return new EffectListPrompt(); - - } else { - player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("eventEditorInvalidEffect")); - return new EffectPrompt(); - } - - } else { - - selectedEffectLocations.remove(player.getUniqueId()); - return new EffectListPrompt(); - - } - - } - } - - private class StormPrompt extends FixedSetPrompt { - - public StormPrompt() { - - super("1", "2", "3", "4"); - - } - - @Override - public String getPromptText(ConversationContext context) { - - String text = ChatColor.GOLD + Lang.get("eventEditorStormTitle") + "\n"; - if (context.getSessionData(CK.E_WORLD_STORM) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetWorld") + " (" + Lang.get("noneSet") + ")\n"; - text += ChatColor.GRAY + "2 - " + Lang.get("eventEditorSetDuration") + " " + Lang.get("eventEditorNoWorld") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); - } else { - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetWorld") + " (" + ChatColor.AQUA + ((String) context.getSessionData(CK.E_WORLD_STORM)) + ChatColor.YELLOW + ")\n"; - - if (context.getSessionData(CK.E_WORLD_STORM_DURATION) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetDuration") + " (" + Lang.get("noneSet") + ")\n"; - } else { - - Long dur = (Long) context.getSessionData(CK.E_WORLD_STORM_DURATION); - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetDuration") + " (" + ChatColor.AQUA + Quests.getTime(dur) + ChatColor.YELLOW + ")\n"; - - } - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); - - } - - return text; - - } - - @Override - protected Prompt acceptValidatedInput(ConversationContext context, String input) { - - if (input.equalsIgnoreCase("1")) { - return new StormWorldPrompt(); - } else if (input.equalsIgnoreCase("2")) { - if (context.getSessionData(CK.E_WORLD_STORM) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorSetWorldFirst")); - return new StormPrompt(); - } else { - return new StormDurationPrompt(); - } - } else if (input.equalsIgnoreCase("3")) { - context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorStormCleared")); - context.setSessionData(CK.E_WORLD_STORM, null); - context.setSessionData(CK.E_WORLD_STORM_DURATION, null); - return new StormPrompt(); - } else if (input.equalsIgnoreCase("4")) { - - if (context.getSessionData(CK.E_WORLD_STORM) != null && context.getSessionData(CK.E_WORLD_STORM_DURATION) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetStormDuration")); - return new StormPrompt(); - } else { - return new CreateMenuPrompt(); - } - - } - return null; - - } - } - - private class StormWorldPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - - String effects = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorWorldsTitle") + "\n" + ChatColor.DARK_PURPLE; - for (World w : quests.getServer().getWorlds()) { - effects += w.getName() + ", "; - } - - effects = effects.substring(0, effects.length()); - - return ChatColor.YELLOW + effects + Lang.get("eventEditorEnterStormWorld"); - - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - - Player player = (Player) context.getForWhom(); - - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - - if (quests.getServer().getWorld(input) != null) { - - context.setSessionData(CK.E_WORLD_STORM, quests.getServer().getWorld(input).getName()); - - } else { - player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("eventEditorInvalidWorld")); - return new StormWorldPrompt(); - } - - } - return new StormPrompt(); - - } - } - - private class StormDurationPrompt extends NumericPrompt { - - @Override - public String getPromptText(ConversationContext context) { - - return ChatColor.YELLOW + Lang.get("eventEditorEnterStormDuration"); - - } - - @Override - protected Prompt acceptValidatedInput(ConversationContext context, Number input) { - - if (input.longValue() < 1000) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorAtLeastOneSecond")); - return new StormDurationPrompt(); - } - - context.setSessionData(CK.E_WORLD_STORM_DURATION, input.longValue()); - return new StormPrompt(); - - } - } - - private class ThunderPrompt extends FixedSetPrompt { - - public ThunderPrompt() { - - super("1", "2", "3", "4"); - - } - - @Override - public String getPromptText(ConversationContext context) { - - String text = ChatColor.GOLD + Lang.get("eventEditorThunderTitle") + "\n"; - - if (context.getSessionData(CK.E_WORLD_THUNDER) == null) { - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetWorld") + " (" + Lang.get("noneSet") + ")\n"; - text += ChatColor.GRAY + "2 - " + Lang.get("eventEditorSetDuration") + " " + Lang.get("eventEditorNoWorld") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); - - } else { - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetWorld") + " (" + ChatColor.AQUA + ((String) context.getSessionData(CK.E_WORLD_THUNDER)) + ChatColor.YELLOW + ")\n"; - - if (context.getSessionData(CK.E_WORLD_THUNDER_DURATION) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetDuration") + " (" + Lang.get("noneSet") + ")\n"; - } else { - - Long dur = (Long) context.getSessionData(CK.E_WORLD_THUNDER_DURATION); - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetDuration") + " (" + ChatColor.AQUA + Quests.getTime(dur) + ChatColor.YELLOW + ")\n"; - - } - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); - - } - - return text; - - } - - @Override - protected Prompt acceptValidatedInput(ConversationContext context, String input) { - - if (input.equalsIgnoreCase("1")) { - return new ThunderWorldPrompt(); - } else if (input.equalsIgnoreCase("2")) { - if (context.getSessionData(CK.E_WORLD_THUNDER) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorSetWorldFirst")); - return new ThunderPrompt(); - } else { - return new ThunderDurationPrompt(); - } - } else if (input.equalsIgnoreCase("3")) { - context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorThunderCleared")); - context.setSessionData(CK.E_WORLD_THUNDER, null); - context.setSessionData(CK.E_WORLD_THUNDER_DURATION, null); - return new ThunderPrompt(); - } else if (input.equalsIgnoreCase("4")) { - - if (context.getSessionData(CK.E_WORLD_THUNDER) != null && context.getSessionData(CK.E_WORLD_THUNDER_DURATION) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetThunderDuration")); - return new ThunderPrompt(); - } else { - return new CreateMenuPrompt(); - } - - } - return null; - - } - } - - private class ThunderWorldPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - - String effects = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorWorldsTitle") + "\n" + ChatColor.DARK_PURPLE; - for (World w : quests.getServer().getWorlds()) { - effects += w.getName() + ", "; - } - - effects = effects.substring(0, effects.length()); - - return ChatColor.YELLOW + effects + Lang.get("eventEditorEnterThunderWorld"); - - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - - Player player = (Player) context.getForWhom(); - - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - - if (quests.getServer().getWorld(input) != null) { - - context.setSessionData(CK.E_WORLD_THUNDER, quests.getServer().getWorld(input).getName()); - - } else { - player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("eventEditorInvalidWorld")); - return new ThunderWorldPrompt(); - } - - } - return new ThunderPrompt(); - - } - } - - private class ThunderDurationPrompt extends NumericPrompt { - - @Override - public String getPromptText(ConversationContext context) { - - return ChatColor.YELLOW + Lang.get("eventEditorEnterDuration"); - - } - - @Override - protected Prompt acceptValidatedInput(ConversationContext context, Number input) { - - if (input.longValue() < 1000) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorAtLeastOneSecond")); - return new ThunderDurationPrompt(); - } else { - context.setSessionData(CK.E_WORLD_THUNDER_DURATION, input.longValue()); - } - - return new ThunderPrompt(); - - } - } - - private class MobPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - - String text = ChatColor.GOLD + Lang.get("eventEditorMobSpawnsTitle") + "\n"; - if (context.getSessionData(CK.E_MOB_TYPES) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorAddMobTypes") + " (" + Lang.get("noneSet") + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); - } else { - @SuppressWarnings("unchecked") + public Prompt acceptInput(ConversationContext context, String input) { + Player player = (Player) context.getForWhom(); + if (input.equalsIgnoreCase(Lang.get("cmdAdd"))) { + Block block = selectedEffectLocations.get(player.getUniqueId()); + if (block != null) { + Location loc = block.getLocation(); + LinkedList locs; + if (context.getSessionData(CK.E_EFFECTS_LOCATIONS) != null) { + locs = (LinkedList) context.getSessionData(CK.E_EFFECTS_LOCATIONS); + } else { + locs = new LinkedList(); + } + locs.add(Quests.getLocationInfo(loc)); + context.setSessionData(CK.E_EFFECTS_LOCATIONS, locs); + selectedEffectLocations.remove(player.getUniqueId()); + } else { + player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst")); + return new EffectLocationPrompt(); + } + return new EffectListPrompt(); + } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { + selectedEffectLocations.remove(player.getUniqueId()); + return new EffectListPrompt(); + } else { + return new EffectLocationPrompt(); + } + } + } + + private class EffectPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + String effects = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorEffectsTitle") + "\n"; + effects += ChatColor.DARK_PURPLE + "BLAZE_SHOOT " + ChatColor.GRAY + "- " + Lang.get("effBlazeShoot") + "\n"; + effects += ChatColor.DARK_PURPLE + "BOW_FIRE " + ChatColor.GRAY + "- " + Lang.get("effBowFire") + "\n"; + effects += ChatColor.DARK_PURPLE + "CLICK1 " + ChatColor.GRAY + "- " + Lang.get("effClick1") + "\n"; + effects += ChatColor.DARK_PURPLE + "CLICK2 " + ChatColor.GRAY + "- " + Lang.get("effClick2") + "\n"; + effects += ChatColor.DARK_PURPLE + "DOOR_TOGGLE " + ChatColor.GRAY + "- " + Lang.get("effDoorToggle") + "\n"; + effects += ChatColor.DARK_PURPLE + "EXTINGUISH " + ChatColor.GRAY + "- " + Lang.get("effExtinguish") + "\n"; + effects += ChatColor.DARK_PURPLE + "GHAST_SHOOT " + ChatColor.GRAY + "- " + Lang.get("effGhastShoot") + "\n"; + effects += ChatColor.DARK_PURPLE + "GHAST_SHRIEK " + ChatColor.GRAY + "- " + Lang.get("effGhastShriek") + "\n"; + effects += ChatColor.DARK_PURPLE + "ZOMBIE_CHEW_IRON_DOOR " + ChatColor.GRAY + "- " + Lang.get("effZombieWood") + "\n"; + effects += ChatColor.DARK_PURPLE + "ZOMBIE_CHEW_WOODEN_DOOR " + ChatColor.GRAY + "- " + Lang.get("effZombieIron") + "\n"; + return ChatColor.YELLOW + effects + Lang.get("effEnterName"); + } + + @SuppressWarnings("unchecked") + @Override + public Prompt acceptInput(ConversationContext context, String input) { + Player player = (Player) context.getForWhom(); + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + if (Quests.getEffect(input.toUpperCase()) != null) { + LinkedList effects; + if (context.getSessionData(CK.E_EFFECTS) != null) { + effects = (LinkedList) context.getSessionData(CK.E_EFFECTS); + } else { + effects = new LinkedList(); + } + effects.add(input.toUpperCase()); + context.setSessionData(CK.E_EFFECTS, effects); + selectedEffectLocations.remove(player.getUniqueId()); + return new EffectListPrompt(); + } else { + player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("eventEditorInvalidEffect")); + return new EffectPrompt(); + } + } else { + selectedEffectLocations.remove(player.getUniqueId()); + return new EffectListPrompt(); + } + } + } + + private class StormPrompt extends FixedSetPrompt { + + public StormPrompt() { + super("1", "2", "3", "4"); + } + + @Override + public String getPromptText(ConversationContext context) { + String text = ChatColor.GOLD + Lang.get("eventEditorStormTitle") + "\n"; + if (context.getSessionData(CK.E_WORLD_STORM) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetWorld") + " (" + Lang.get("noneSet") + ")\n"; + text += ChatColor.GRAY + "2 - " + Lang.get("eventEditorSetDuration") + " " + Lang.get("eventEditorNoWorld") + "\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetWorld") + " (" + ChatColor.AQUA + ((String) context.getSessionData(CK.E_WORLD_STORM)) + ChatColor.YELLOW + ")\n"; + if (context.getSessionData(CK.E_WORLD_STORM_DURATION) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetDuration") + " (" + Lang.get("noneSet") + ")\n"; + } else { + Long dur = (Long) context.getSessionData(CK.E_WORLD_STORM_DURATION); + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetDuration") + " (" + ChatColor.AQUA + Quests.getTime(dur) + ChatColor.YELLOW + ")\n"; + } + text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); + } + return text; + } + + @Override + protected Prompt acceptValidatedInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase("1")) { + return new StormWorldPrompt(); + } else if (input.equalsIgnoreCase("2")) { + if (context.getSessionData(CK.E_WORLD_STORM) == null) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorSetWorldFirst")); + return new StormPrompt(); + } else { + return new StormDurationPrompt(); + } + } else if (input.equalsIgnoreCase("3")) { + context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorStormCleared")); + context.setSessionData(CK.E_WORLD_STORM, null); + context.setSessionData(CK.E_WORLD_STORM_DURATION, null); + return new StormPrompt(); + } else if (input.equalsIgnoreCase("4")) { + if (context.getSessionData(CK.E_WORLD_STORM) != null && context.getSessionData(CK.E_WORLD_STORM_DURATION) == null) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetStormDuration")); + return new StormPrompt(); + } else { + return new CreateMenuPrompt(); + } + } + return null; + } + } + + private class StormWorldPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + String effects = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorWorldsTitle") + "\n" + ChatColor.DARK_PURPLE; + for (World w : quests.getServer().getWorlds()) { + effects += w.getName() + ", "; + } + effects = effects.substring(0, effects.length()); + return ChatColor.YELLOW + effects + Lang.get("eventEditorEnterStormWorld"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + Player player = (Player) context.getForWhom(); + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + if (quests.getServer().getWorld(input) != null) { + context.setSessionData(CK.E_WORLD_STORM, quests.getServer().getWorld(input).getName()); + } else { + player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("eventEditorInvalidWorld")); + return new StormWorldPrompt(); + } + } + return new StormPrompt(); + } + } + + private class StormDurationPrompt extends NumericPrompt { + + @Override + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("eventEditorEnterStormDuration"); + } + + @Override + protected Prompt acceptValidatedInput(ConversationContext context, Number input) { + if (input.longValue() < 1000) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorAtLeastOneSecond")); + return new StormDurationPrompt(); + } + context.setSessionData(CK.E_WORLD_STORM_DURATION, input.longValue()); + return new StormPrompt(); + } + } + + private class ThunderPrompt extends FixedSetPrompt { + + public ThunderPrompt() { + super("1", "2", "3", "4"); + } + + @Override + public String getPromptText(ConversationContext context) { + String text = ChatColor.GOLD + Lang.get("eventEditorThunderTitle") + "\n"; + if (context.getSessionData(CK.E_WORLD_THUNDER) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetWorld") + " (" + Lang.get("noneSet") + ")\n"; + text += ChatColor.GRAY + "2 - " + Lang.get("eventEditorSetDuration") + " " + Lang.get("eventEditorNoWorld") + "\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetWorld") + " (" + ChatColor.AQUA + ((String) context.getSessionData(CK.E_WORLD_THUNDER)) + ChatColor.YELLOW + ")\n"; + if (context.getSessionData(CK.E_WORLD_THUNDER_DURATION) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetDuration") + " (" + Lang.get("noneSet") + ")\n"; + } else { + Long dur = (Long) context.getSessionData(CK.E_WORLD_THUNDER_DURATION); + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetDuration") + " (" + ChatColor.AQUA + Quests.getTime(dur) + ChatColor.YELLOW + ")\n"; + } + text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); + } + return text; + } + + @Override + protected Prompt acceptValidatedInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase("1")) { + return new ThunderWorldPrompt(); + } else if (input.equalsIgnoreCase("2")) { + if (context.getSessionData(CK.E_WORLD_THUNDER) == null) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorSetWorldFirst")); + return new ThunderPrompt(); + } else { + return new ThunderDurationPrompt(); + } + } else if (input.equalsIgnoreCase("3")) { + context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorThunderCleared")); + context.setSessionData(CK.E_WORLD_THUNDER, null); + context.setSessionData(CK.E_WORLD_THUNDER_DURATION, null); + return new ThunderPrompt(); + } else if (input.equalsIgnoreCase("4")) { + if (context.getSessionData(CK.E_WORLD_THUNDER) != null && context.getSessionData(CK.E_WORLD_THUNDER_DURATION) == null) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetThunderDuration")); + return new ThunderPrompt(); + } else { + return new CreateMenuPrompt(); + } + } + return null; + } + } + + private class ThunderWorldPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + String effects = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorWorldsTitle") + "\n" + ChatColor.DARK_PURPLE; + for (World w : quests.getServer().getWorlds()) { + effects += w.getName() + ", "; + } + effects = effects.substring(0, effects.length()); + return ChatColor.YELLOW + effects + Lang.get("eventEditorEnterThunderWorld"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + Player player = (Player) context.getForWhom(); + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + if (quests.getServer().getWorld(input) != null) { + context.setSessionData(CK.E_WORLD_THUNDER, quests.getServer().getWorld(input).getName()); + } else { + player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("eventEditorInvalidWorld")); + return new ThunderWorldPrompt(); + } + } + return new ThunderPrompt(); + } + } + + private class ThunderDurationPrompt extends NumericPrompt { + + @Override + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("eventEditorEnterDuration"); + } + + @Override + protected Prompt acceptValidatedInput(ConversationContext context, Number input) { + if (input.longValue() < 1000) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorAtLeastOneSecond")); + return new ThunderDurationPrompt(); + } else { + context.setSessionData(CK.E_WORLD_THUNDER_DURATION, input.longValue()); + } + return new ThunderPrompt(); + } + } + + private class MobPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + String text = ChatColor.GOLD + Lang.get("eventEditorMobSpawnsTitle") + "\n"; + if (context.getSessionData(CK.E_MOB_TYPES) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorAddMobTypes") + " (" + Lang.get("noneSet") + ")\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); + } else { + @SuppressWarnings("unchecked") LinkedList types = (LinkedList) context.getSessionData(CK.E_MOB_TYPES); + for (int i = 0; i < types.size(); i++) { + QuestMob qm = QuestMob.fromString(types.get(i)); + text += ChatColor.GOLD + " " + (i + 1) + " - " + Lang.get("edit") + ": " + ChatColor.AQUA + qm.getType().name() + ((qm.getName() != null) ? ": " + qm.getName() : "") + ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + qm.getSpawnAmounts() + ChatColor.GRAY + " -> " + ChatColor.GREEN + Quests.getLocationInfo(qm.getSpawnLocation()) + "\n"; + } + text += ChatColor.BLUE + "" + ChatColor.BOLD + (types.size() + 1) + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorAddMobTypes") + "\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + (types.size() + 2) + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; + text += ChatColor.GREEN + "" + ChatColor.BOLD + (types.size() + 3) + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); + } + return text; + } - for (int i = 0; i < types.size(); i++) { - QuestMob qm = QuestMob.fromString(types.get(i)); - text += ChatColor.GOLD + " " + (i + 1) + " - " + Lang.get("edit") + ": " + ChatColor.AQUA + qm.getType().name() + ((qm.getName() != null) ? ": " + qm.getName() : "") + ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + qm.getSpawnAmounts() + ChatColor.GRAY + " -> " + ChatColor.GREEN + Quests.getLocationInfo(qm.getSpawnLocation()) + "\n"; - } - - text += ChatColor.BLUE + "" + ChatColor.BOLD + (types.size() + 1) + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorAddMobTypes") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + (types.size() + 2) + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; - text += ChatColor.GREEN + "" + ChatColor.BOLD + (types.size() + 3) + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); - - } - - return text; - - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - - 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(ChatColor.YELLOW + Lang.get("eventEditorMobSpawnsCleared")); - context.setSessionData(CK.E_MOB_TYPES, null); - return new MobPrompt(); - } else if (input.equalsIgnoreCase("3")) { - return new CreateMenuPrompt(); - } - } else { - @SuppressWarnings("unchecked") + @Override + public Prompt acceptInput(ConversationContext context, String input) { + 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(ChatColor.YELLOW + Lang.get("eventEditorMobSpawnsCleared")); + context.setSessionData(CK.E_MOB_TYPES, null); + return new MobPrompt(); + } else if (input.equalsIgnoreCase("3")) { + return new CreateMenuPrompt(); + } + } else { + @SuppressWarnings("unchecked") LinkedList types = (LinkedList) context.getSessionData(CK.E_MOB_TYPES); - int inp; - try { - inp = Integer.parseInt(input); - } catch (NumberFormatException e) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorNotANumber")); - return new MobPrompt(); - } + int inp; + try { + inp = Integer.parseInt(input); + } catch (NumberFormatException e) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorNotANumber")); + return new MobPrompt(); + } + if (inp == types.size() + 1) { + return new QuestMobPrompt(inp - 1, null); + } else if (inp == types.size() + 2) { + context.getForWhom().sendRawMessage(ChatColor.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))); + } + } + return new MobPrompt(); + } + } + + private class QuestMobPrompt extends StringPrompt { + + private QuestMob questMob; + private Integer itemIndex = -1; + private final Integer mobIndex; + + public QuestMobPrompt(int mobIndex, QuestMob questMob) { + this.questMob = questMob; + this.mobIndex = mobIndex; + } - if (inp == types.size() + 1) { - return new QuestMobPrompt(inp - 1, null); - } else if (inp == types.size() + 2) { - context.getForWhom().sendRawMessage(ChatColor.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))); - } - } - - return new MobPrompt(); - } - } - - private class QuestMobPrompt extends StringPrompt { - - private QuestMob questMob; - private Integer itemIndex = -1; - private final Integer mobIndex; - - public QuestMobPrompt(int mobIndex, QuestMob questMob) { - this.questMob = questMob; - this.mobIndex = mobIndex; - } - - @Override - public String getPromptText(ConversationContext context) { - - String text = ChatColor.GOLD + Lang.get("eventEditorAddMobTypesTitle") + "\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; - } - - context.setSessionData("newItem", null); - context.setSessionData("tempStack", null); - - } - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobName") + ChatColor.GRAY + " (" + ((questMob.getName() == null) ? Lang.get("noneSet") : ChatColor.AQUA + questMob.getName()) + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobType") + ChatColor.GRAY + " (" + ((questMob.getType() == null) ? Lang.get("eventEditorNoTypesSet") : ChatColor.AQUA + questMob.getType().name()) + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorAddSpawnLocation") + ChatColor.GRAY + " (" + ((questMob.getSpawnLocation() == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA + Quests.getLocationInfo(questMob.getSpawnLocation())) + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobSpawnAmount") + ChatColor.GRAY + " (" + ((questMob.getSpawnAmounts() == null) ? ChatColor.GRAY + Lang.get("eventEditorNoAmountsSet") : ChatColor.AQUA + "" + questMob.getSpawnAmounts()) + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobItemInHand") + ChatColor.GRAY + " (" + ((questMob.inventory[0] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA + ItemUtil.getDisplayString(questMob.inventory[0])) + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobItemInHandDrop") + ChatColor.GRAY + " (" + ((questMob.dropChances[0] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA + "" + questMob.dropChances[0]) + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobBoots") + ChatColor.GRAY + " (" + ((questMob.inventory[1] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA + ItemUtil.getDisplayString(questMob.inventory[1])) + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobBootsDrop") + ChatColor.GRAY + " (" + ((questMob.dropChances[1] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA + "" + questMob.dropChances[1]) + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "9" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobLeggings") + ChatColor.GRAY + " (" + ((questMob.inventory[2] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA + ItemUtil.getDisplayString(questMob.inventory[2])) + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "10" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobLeggingsDrop") + ChatColor.GRAY + " (" + ((questMob.dropChances[2] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA + "" + questMob.dropChances[2]) + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "11" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobChestPlate") + ChatColor.GRAY + " (" + ((questMob.inventory[3] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA + ItemUtil.getDisplayString(questMob.inventory[3])) + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "12" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobChestPlateDrop") + ChatColor.GRAY + " (" + ((questMob.dropChances[3] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA + "" + questMob.dropChances[3]) + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "13" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobHelmet") + ChatColor.GRAY + " (" + ((questMob.inventory[4] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA + ItemUtil.getDisplayString(questMob.inventory[4])) + ChatColor.GRAY + ")\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "14" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobHelmetDrop") + ChatColor.GRAY + " (" + ((questMob.dropChances[4] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA + "" + questMob.dropChances[4]) + ChatColor.GRAY + ")\n"; - - text += ChatColor.GREEN + "" + ChatColor.BOLD + "15" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done") + "\n"; - text += ChatColor.RED + "" + ChatColor.BOLD + "16" + ChatColor.RESET + ChatColor.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()).getUniqueId(), 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(ChatColor.RED + Lang.get("eventEditorMustSetMobTypesFirst")); - return new QuestMobPrompt(mobIndex, questMob); - } else if (questMob.getSpawnLocation() == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetMobLocationFirst")); - return new QuestMobPrompt(mobIndex, questMob); - } else if (questMob.getSpawnAmounts() == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetMobAmountsFirst")); - return new QuestMobPrompt(mobIndex, questMob); - } - if (context.getSessionData(CK.E_MOB_TYPES) == null) { - LinkedList list = new LinkedList(); - list.add(questMob.serialize()); - context.setSessionData(CK.E_MOB_TYPES, list); - } else { - if (((LinkedList) context.getSessionData(CK.E_MOB_TYPES)).isEmpty()) { - LinkedList list = new LinkedList(); - list.add(questMob.serialize()); - context.setSessionData(CK.E_MOB_TYPES, list); - } else { - LinkedList list = (LinkedList) 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 MobNamePrompt extends StringPrompt { - - private final QuestMob questMob; - private final Integer mobIndex; - - public MobNamePrompt(int mobIndex, QuestMob questMob) { - this.questMob = questMob; - this.mobIndex = mobIndex; - } - - @Override - public String getPromptText(ConversationContext context) { - String text = ChatColor.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 final QuestMob questMob; - private final Integer mobIndex; - - public MobTypePrompt(int mobIndex, QuestMob questMob) { - this.questMob = questMob; - this.mobIndex = mobIndex; - } - - @Override - public String getPromptText(ConversationContext arg0) { - - String mobs = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorMobsTitle") + "\n"; - final EntityType[] mobArr = EntityType.values(); - for (int i = 0; i < mobArr.length; i++) { - - final EntityType type = mobArr[i]; - if (type.isAlive() == false) { - continue; - } - - if (i < (mobArr.length - 1)) { - mobs += MiscUtil.getProperMobName(mobArr[i]) + ", "; - } else { - mobs += MiscUtil.getProperMobName(mobArr[i]) + "\n"; - } - } - - return mobs + ChatColor.YELLOW + Lang.get("eventEditorSetMobTypesPrompt"); - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - - Player player = (Player) context.getForWhom(); - - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - - if (MiscUtil.getProperMobType(input) != null) { - - questMob.setType(MiscUtil.getProperMobType(input)); - - } else { - player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("eventEditorInvalidMob")); - return new MobTypePrompt(mobIndex, questMob); - } - } - - return new QuestMobPrompt(mobIndex, questMob); - } - } - - private class MobAmountPrompt extends StringPrompt { - - private final QuestMob questMob; - private final Integer mobIndex; - - public MobAmountPrompt(int mobIndex, QuestMob questMob) { - this.questMob = questMob; - this.mobIndex = mobIndex; - } - - @Override - public String getPromptText(ConversationContext context) { - - return ChatColor.YELLOW + Lang.get("eventEditorSetMobAmountsPrompt"); - - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - - Player player = (Player) context.getForWhom(); - - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - - try { - - int i = Integer.parseInt(input); - - if (i < 1) { - player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("eventEditorNotGreaterThanZero")); - return new MobAmountPrompt(mobIndex, questMob); - } - - questMob.setSpawnAmounts(i); - return new QuestMobPrompt(mobIndex, questMob); - } catch (NumberFormatException e) { - player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("eventEditorNotANumber")); - return new MobAmountPrompt(mobIndex, questMob); - } - - } - - return new QuestMobPrompt(mobIndex, questMob); - - } - } - - private class MobLocationPrompt extends StringPrompt { - - private final QuestMob questMob; - private final Integer mobIndex; - - public MobLocationPrompt(int mobIndex, QuestMob questMob) { - this.questMob = questMob; - this.mobIndex = mobIndex; - } - - @Override - public String getPromptText(ConversationContext context) { - - return ChatColor.YELLOW + Lang.get("eventEditorSetMobLocationPrompt"); - - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - - Player player = (Player) context.getForWhom(); - - if (input.equalsIgnoreCase(Lang.get("cmdAdd"))) { - - Block block = selectedMobLocations.get(player.getUniqueId()); - if (block != null) { - - Location loc = block.getLocation(); - - questMob.setSpawnLocation(loc); - selectedMobLocations.remove(player.getUniqueId()); - - } else { - player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst")); - return new MobLocationPrompt(mobIndex, questMob); - } - - return new QuestMobPrompt(mobIndex, questMob); - - } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { - - selectedMobLocations.remove(player.getUniqueId()); - return new QuestMobPrompt(mobIndex, questMob); - - } else { - return new MobLocationPrompt(mobIndex, questMob); - } - - } - } - - private class MobDropPrompt extends StringPrompt { - - private final QuestMob questMob; - private final Integer mobIndex; - private final 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 = ChatColor.YELLOW + Lang.get("eventEditorSetDropChance"); - return text; - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - - float chance; - - if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { - return new QuestMobPrompt(mobIndex, questMob); - } - - try { - chance = Float.parseFloat(input); - } catch (NumberFormatException e) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorInvalidDropChance")); - return new MobDropPrompt(invIndex, mobIndex, questMob); - } - if (chance > 1 || chance < 0) { - context.getForWhom().sendRawMessage(ChatColor.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 - public String getPromptText(ConversationContext context) { - - return ChatColor.YELLOW + Lang.get("eventEditorLightningPrompt"); - - } - - @SuppressWarnings("unchecked") @Override - public Prompt acceptInput(ConversationContext context, String input) { + public String getPromptText(ConversationContext context) { + String text = ChatColor.GOLD + Lang.get("eventEditorAddMobTypesTitle") + "\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; + } + context.setSessionData("newItem", null); + context.setSessionData("tempStack", null); + } + text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobName") + ChatColor.GRAY + " (" + ((questMob.getName() == null) ? Lang.get("noneSet") : ChatColor.AQUA + questMob.getName()) + ")\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobType") + ChatColor.GRAY + " (" + ((questMob.getType() == null) ? Lang.get("eventEditorNoTypesSet") : ChatColor.AQUA + questMob.getType().name()) + ChatColor.GRAY + ")\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorAddSpawnLocation") + ChatColor.GRAY + " (" + ((questMob.getSpawnLocation() == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA + Quests.getLocationInfo(questMob.getSpawnLocation())) + ChatColor.GRAY + ")\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobSpawnAmount") + ChatColor.GRAY + " (" + ((questMob.getSpawnAmounts() == null) ? ChatColor.GRAY + Lang.get("eventEditorNoAmountsSet") : ChatColor.AQUA + "" + questMob.getSpawnAmounts()) + ChatColor.GRAY + ")\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobItemInHand") + ChatColor.GRAY + " (" + ((questMob.inventory[0] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA + ItemUtil.getDisplayString(questMob.inventory[0])) + ChatColor.GRAY + ")\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobItemInHandDrop") + ChatColor.GRAY + " (" + ((questMob.dropChances[0] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA + "" + questMob.dropChances[0]) + ChatColor.GRAY + ")\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobBoots") + ChatColor.GRAY + " (" + ((questMob.inventory[1] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA + ItemUtil.getDisplayString(questMob.inventory[1])) + ChatColor.GRAY + ")\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobBootsDrop") + ChatColor.GRAY + " (" + ((questMob.dropChances[1] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA + "" + questMob.dropChances[1]) + ChatColor.GRAY + ")\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "9" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobLeggings") + ChatColor.GRAY + " (" + ((questMob.inventory[2] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA + ItemUtil.getDisplayString(questMob.inventory[2])) + ChatColor.GRAY + ")\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "10" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobLeggingsDrop") + ChatColor.GRAY + " (" + ((questMob.dropChances[2] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA + "" + questMob.dropChances[2]) + ChatColor.GRAY + ")\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "11" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobChestPlate") + ChatColor.GRAY + " (" + ((questMob.inventory[3] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA + ItemUtil.getDisplayString(questMob.inventory[3])) + ChatColor.GRAY + ")\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "12" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobChestPlateDrop") + ChatColor.GRAY + " (" + ((questMob.dropChances[3] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA + "" + questMob.dropChances[3]) + ChatColor.GRAY + ")\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "13" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobHelmet") + ChatColor.GRAY + " (" + ((questMob.inventory[4] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA + ItemUtil.getDisplayString(questMob.inventory[4])) + ChatColor.GRAY + ")\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "14" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetMobHelmetDrop") + ChatColor.GRAY + " (" + ((questMob.dropChances[4] == null) ? ChatColor.GRAY + Lang.get("noneSet") : ChatColor.AQUA + "" + questMob.dropChances[4]) + ChatColor.GRAY + ")\n"; + text += ChatColor.GREEN + "" + ChatColor.BOLD + "15" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done") + "\n"; + text += ChatColor.RED + "" + ChatColor.BOLD + "16" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("cancel"); + return text; + } - Player player = (Player) context.getForWhom(); - - if (input.equalsIgnoreCase(Lang.get("cmdAdd"))) { - - Block block = selectedLightningLocations.get(player.getUniqueId()); - if (block != null) { - - Location loc = block.getLocation(); - - LinkedList locs; - if (context.getSessionData(CK.E_LIGHTNING) != null) { - locs = (LinkedList) context.getSessionData(CK.E_LIGHTNING); - } else { - locs = new LinkedList(); - } - - locs.add(Quests.getLocationInfo(loc)); - context.setSessionData(CK.E_LIGHTNING, locs); - selectedLightningLocations.remove(player.getUniqueId()); - - } else { - player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst")); - return new LightningPrompt(); - } - - return new CreateMenuPrompt(); - - } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - - context.setSessionData(CK.E_LIGHTNING, null); - selectedLightningLocations.remove(player.getUniqueId()); - return new CreateMenuPrompt(); - - } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { - - selectedLightningLocations.remove(player.getUniqueId()); - return new CreateMenuPrompt(); - - } else { - return new LightningPrompt(); - } - - } - } - - private class PotionEffectPrompt extends FixedSetPrompt { - - public PotionEffectPrompt() { - - super("1", "2", "3", "4", "5"); - - } - - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") @Override - public String getPromptText(ConversationContext context) { + 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()).getUniqueId(), 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(ChatColor.RED + Lang.get("eventEditorMustSetMobTypesFirst")); + return new QuestMobPrompt(mobIndex, questMob); + } else if (questMob.getSpawnLocation() == null) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetMobLocationFirst")); + return new QuestMobPrompt(mobIndex, questMob); + } else if (questMob.getSpawnAmounts() == null) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetMobAmountsFirst")); + return new QuestMobPrompt(mobIndex, questMob); + } + if (context.getSessionData(CK.E_MOB_TYPES) == null) { + LinkedList list = new LinkedList(); + list.add(questMob.serialize()); + context.setSessionData(CK.E_MOB_TYPES, list); + } else { + if (((LinkedList) context.getSessionData(CK.E_MOB_TYPES)).isEmpty()) { + LinkedList list = new LinkedList(); + list.add(questMob.serialize()); + context.setSessionData(CK.E_MOB_TYPES, list); + } else { + LinkedList list = (LinkedList) 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); + } + } + } - String text = ChatColor.GOLD + Lang.get("eventEditorPotionEffectsTitle") + "\n"; - if (context.getSessionData(CK.E_POTION_TYPES) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetPotionEffectTypes") + " (" + Lang.get("noneSet") + ")\n"; - text += ChatColor.GRAY + "2 - " + Lang.get("eventEditorSetPotionDurations") + " " + Lang.get("eventEditorNoTypesSet") + "\n"; - text += ChatColor.GRAY + "3 - " + Lang.get("eventEditorSetPotionMagnitudes") + " " + Lang.get("eventEditorNoTypesSet") + "\n"; - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; - text += ChatColor.GREEN + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); - } else { + private class MobNamePrompt extends StringPrompt { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetPotionEffectTypes") + "\n"; - for (String s : (LinkedList) context.getSessionData(CK.E_POTION_TYPES)) { - text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; - } + private final QuestMob questMob; + private final Integer mobIndex; - if (context.getSessionData(CK.E_POTION_DURATIONS) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetPotionDurations") + " (" + Lang.get("noneSet") + ")\n"; - text += ChatColor.GRAY + "3 - " + Lang.get("eventEditorSetPotionMagnitudes") + " " + Lang.get("eventEditorNoDurationsSet") + "\n"; - } else { + public MobNamePrompt(int mobIndex, QuestMob questMob) { + this.questMob = questMob; + this.mobIndex = mobIndex; + } - text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorNoDurationsSet") + "\n"; - for (Long l : (LinkedList) context.getSessionData(CK.E_POTION_DURATIONS)) { - text += ChatColor.GRAY + " - " + ChatColor.DARK_AQUA + Quests.getTime(l * 50L) + "\n"; - } - - if (context.getSessionData(CK.E_POTION_STRENGHT) == null) { - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetPotionMagnitudes") + " (" + Lang.get("noneSet") + ")\n"; - } else { - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetPotionMagnitudes") + "\n"; - for (int i : (LinkedList) context.getSessionData(CK.E_POTION_STRENGHT)) { - text += ChatColor.GRAY + " - " + ChatColor.DARK_PURPLE + i + "\n"; - } - - } - - } - - text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; - text += ChatColor.GREEN + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); - - } - - return text; - - } - - @SuppressWarnings("unchecked") @Override - protected Prompt acceptValidatedInput(ConversationContext context, String input) { - - if (input.equalsIgnoreCase("1")) { - return new PotionTypesPrompt(); - } else if (input.equalsIgnoreCase("2")) { - if (context.getSessionData(CK.E_POTION_TYPES) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetPotionTypesFirst")); - return new PotionEffectPrompt(); - } else { - return new PotionDurationsPrompt(); - } - } else if (input.equalsIgnoreCase("3")) { - if (context.getSessionData(CK.E_POTION_TYPES) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetPotionTypesAndDurationsFirst")); - return new PotionEffectPrompt(); - } else if (context.getSessionData(CK.E_POTION_DURATIONS) == null) { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetPotionDurationsFirst")); - return new PotionEffectPrompt(); - } else { - return new PotionMagnitudesPrompt(); - } - - } else if (input.equalsIgnoreCase("4")) { - context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorPotionsCleared")); - context.setSessionData(CK.E_POTION_TYPES, null); - context.setSessionData(CK.E_POTION_DURATIONS, null); - context.setSessionData(CK.E_POTION_STRENGHT, null); - return new PotionEffectPrompt(); - } else if (input.equalsIgnoreCase("5")) { - - int one; - int two; - int three; - - if (context.getSessionData(CK.E_POTION_TYPES) != null) { - one = ((List) context.getSessionData(CK.E_POTION_TYPES)).size(); - } else { - one = 0; - } - - if (context.getSessionData(CK.E_POTION_DURATIONS) != null) { - two = ((List) context.getSessionData(CK.E_POTION_DURATIONS)).size(); - } else { - two = 0; - } - - if (context.getSessionData(CK.E_POTION_STRENGHT) != null) { - three = ((List) context.getSessionData(CK.E_POTION_STRENGHT)).size(); - } else { - three = 0; - } - - if (one == two && two == three) { - return new CreateMenuPrompt(); - } else { - context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorListSizeMismatch")); - return new PotionEffectPrompt(); - } - - } - return null; - - } - } - - private class PotionTypesPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - - String effs = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorPotionTypesTitle") + "\n"; - for (PotionEffectType pet : PotionEffectType.values()) { - effs += (pet != null && pet.getName() != null) ? (ChatColor.DARK_PURPLE + pet.getName() + "\n") : ""; - } - - return effs + ChatColor.YELLOW + Lang.get("eventEditorSetPotionEffectsPrompt"); - - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - - Player player = (Player) context.getForWhom(); - - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - - LinkedList effTypes = new LinkedList(); - for (String s : input.split(" ")) { - - if (PotionEffectType.getByName(s.toUpperCase()) != null) { - - effTypes.add(PotionEffectType.getByName(s.toUpperCase()).getName()); - - context.setSessionData(CK.E_POTION_TYPES, effTypes); - - } else { - player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("eventEditorInvalidPotionType")); - return new PotionTypesPrompt(); - } - - } - - } - - return new PotionEffectPrompt(); - - } - } - - private class PotionDurationsPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - - return ChatColor.YELLOW + Lang.get("eventEditorSetPotionDurationsPrompt"); - - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - - Player player = (Player) context.getForWhom(); - - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - - LinkedList effDurations = new LinkedList(); - for (String s : input.split(" ")) { - - try { - - int i = Integer.parseInt(s); - long l = i * 1000; - - if (l < 1000) { - player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("eventEditorNotGreaterThanOneSecond")); - return new PotionDurationsPrompt(); - } - - effDurations.add(l / 50L); - - } catch (NumberFormatException e) { - player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("eventEditorNotANumber")); - return new PotionDurationsPrompt(); - } - - } - - context.setSessionData(CK.E_POTION_DURATIONS, effDurations); - - } - - return new PotionEffectPrompt(); - - } - } - - private class PotionMagnitudesPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - - return ChatColor.YELLOW + Lang.get("eventEditorSetPotionMagnitudesPrompt"); - - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - - Player player = (Player) context.getForWhom(); - - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { - - LinkedList magAmounts = new LinkedList(); - for (String s : input.split(" ")) { - - try { - - int i = Integer.parseInt(s); - - if (i < 1) { - player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("eventEditorNotGreaterThanZero")); - return new PotionMagnitudesPrompt(); - } - - magAmounts.add(i); - - } catch (NumberFormatException e) { - player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("eventEditorNotANumber")); - return new PotionMagnitudesPrompt(); - } - - } - - context.setSessionData(CK.E_POTION_STRENGHT, magAmounts); - - } - - return new PotionEffectPrompt(); - - } - } - - private class HungerPrompt extends NumericPrompt { - - @Override - public String getPromptText(ConversationContext context) { - - return ChatColor.YELLOW + Lang.get("eventEditorSetHungerPrompt"); - - } - - @Override - protected Prompt acceptValidatedInput(ConversationContext context, Number input) { - - if (input.intValue() != -1) { - - if (input.intValue() < 0) { - ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorHungerLevelAtLeastZero")); - return new HungerPrompt(); - } else { - context.setSessionData(CK.E_HUNGER, (Integer) input.intValue()); - } - - } else { - context.setSessionData(CK.E_HUNGER, null); - } - - return new CreateMenuPrompt(); - - } - } - - private class SaturationPrompt extends NumericPrompt { - - @Override - public String getPromptText(ConversationContext context) { - - return ChatColor.YELLOW + Lang.get("eventEditorSetSaturationPrompt"); - - } - - @Override - protected Prompt acceptValidatedInput(ConversationContext context, Number input) { - - if (input.intValue() != -1) { - - if (input.intValue() < 0) { - ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorSaturationLevelAtLeastZero")); - return new SaturationPrompt(); - } else { - context.setSessionData(CK.E_SATURATION, (Integer) input.intValue()); - } - - } else { - context.setSessionData(CK.E_SATURATION, null); - } - - return new CreateMenuPrompt(); - - } - } - - private class HealthPrompt extends NumericPrompt { - - @Override - public String getPromptText(ConversationContext context) { - - return ChatColor.YELLOW + Lang.get("eventEditorSetHealthPrompt"); - - } - - @Override - protected Prompt acceptValidatedInput(ConversationContext context, Number input) { - - if (input.intValue() != -1) { - - if (input.intValue() < 0) { - ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorHealthLevelAtLeastZero")); - return new HealthPrompt(); - } else { - context.setSessionData(CK.E_HEALTH, (Integer) input.intValue()); - } - - } else { - context.setSessionData(CK.E_HEALTH, null); - } - - return new CreateMenuPrompt(); - - } - } - - private class TeleportPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - - return ChatColor.YELLOW + Lang.get("eventEditorSetTeleportPrompt"); - - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - - Player player = (Player) context.getForWhom(); - - if (input.equalsIgnoreCase(Lang.get("cmdDone"))) { - - Block block = selectedTeleportLocations.get(player.getUniqueId()); - if (block != null) { - - Location loc = block.getLocation(); - - context.setSessionData(CK.E_TELEPORT, Quests.getLocationInfo(loc)); - selectedTeleportLocations.remove(player.getUniqueId()); - - } else { - player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst")); - return new TeleportPrompt(); - } - - return new CreateMenuPrompt(); - - } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - - context.setSessionData(CK.E_TELEPORT, null); - selectedTeleportLocations.remove(player.getUniqueId()); - return new CreateMenuPrompt(); - - } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { - - selectedTeleportLocations.remove(player.getUniqueId()); - return new CreateMenuPrompt(); - - } else { - return new TeleportPrompt(); - } - - } - } - - private class CommandsPrompt extends StringPrompt { - - @Override - public String getPromptText(ConversationContext context) { - - String text = ChatColor.GOLD + "" + ChatColor.ITALIC + Lang.get("eventEditorCommandsNote"); - return ChatColor.YELLOW + Lang.get("eventEditorSetCommandsPrompt") + "\n" + text; - - } - - @Override - public Prompt acceptInput(ConversationContext context, String input) { - - if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { - - String[] commands = input.split(","); - LinkedList cmdList = new LinkedList(); - cmdList.addAll(Arrays.asList(commands)); - context.setSessionData(CK.E_COMMANDS, cmdList); - - } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { - context.setSessionData(CK.E_COMMANDS, null); - } - - return new CreateMenuPrompt(); - - } - } + public String getPromptText(ConversationContext context) { + String text = ChatColor.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 final QuestMob questMob; + private final Integer mobIndex; + + public MobTypePrompt(int mobIndex, QuestMob questMob) { + this.questMob = questMob; + this.mobIndex = mobIndex; + } + + @Override + public String getPromptText(ConversationContext arg0) { + String mobs = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorMobsTitle") + "\n"; + final EntityType[] mobArr = EntityType.values(); + for (int i = 0; i < mobArr.length; i++) { + final EntityType type = mobArr[i]; + if (type.isAlive() == false) { + continue; + } + if (i < (mobArr.length - 1)) { + mobs += MiscUtil.getProperMobName(mobArr[i]) + ", "; + } else { + mobs += MiscUtil.getProperMobName(mobArr[i]) + "\n"; + } + } + return mobs + ChatColor.YELLOW + Lang.get("eventEditorSetMobTypesPrompt"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + Player player = (Player) context.getForWhom(); + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + if (MiscUtil.getProperMobType(input) != null) { + questMob.setType(MiscUtil.getProperMobType(input)); + } else { + player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("eventEditorInvalidMob")); + return new MobTypePrompt(mobIndex, questMob); + } + } + return new QuestMobPrompt(mobIndex, questMob); + } + } + + private class MobAmountPrompt extends StringPrompt { + + private final QuestMob questMob; + private final Integer mobIndex; + + public MobAmountPrompt(int mobIndex, QuestMob questMob) { + this.questMob = questMob; + this.mobIndex = mobIndex; + } + + @Override + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("eventEditorSetMobAmountsPrompt"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + Player player = (Player) context.getForWhom(); + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + try { + int i = Integer.parseInt(input); + if (i < 1) { + player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("eventEditorNotGreaterThanZero")); + return new MobAmountPrompt(mobIndex, questMob); + } + questMob.setSpawnAmounts(i); + return new QuestMobPrompt(mobIndex, questMob); + } catch (NumberFormatException e) { + player.sendMessage(ChatColor.LIGHT_PURPLE + input + " " + ChatColor.RED + Lang.get("eventEditorNotANumber")); + return new MobAmountPrompt(mobIndex, questMob); + } + } + return new QuestMobPrompt(mobIndex, questMob); + } + } + + private class MobLocationPrompt extends StringPrompt { + + private final QuestMob questMob; + private final Integer mobIndex; + + public MobLocationPrompt(int mobIndex, QuestMob questMob) { + this.questMob = questMob; + this.mobIndex = mobIndex; + } + + @Override + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("eventEditorSetMobLocationPrompt"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + Player player = (Player) context.getForWhom(); + if (input.equalsIgnoreCase(Lang.get("cmdAdd"))) { + Block block = selectedMobLocations.get(player.getUniqueId()); + if (block != null) { + Location loc = block.getLocation(); + questMob.setSpawnLocation(loc); + selectedMobLocations.remove(player.getUniqueId()); + } else { + player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst")); + return new MobLocationPrompt(mobIndex, questMob); + } + return new QuestMobPrompt(mobIndex, questMob); + } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { + selectedMobLocations.remove(player.getUniqueId()); + return new QuestMobPrompt(mobIndex, questMob); + } else { + return new MobLocationPrompt(mobIndex, questMob); + } + } + } + + private class MobDropPrompt extends StringPrompt { + + private final QuestMob questMob; + private final Integer mobIndex; + private final 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 = ChatColor.YELLOW + Lang.get("eventEditorSetDropChance"); + return text; + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + float chance; + if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { + return new QuestMobPrompt(mobIndex, questMob); + } + try { + chance = Float.parseFloat(input); + } catch (NumberFormatException e) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorInvalidDropChance")); + return new MobDropPrompt(invIndex, mobIndex, questMob); + } + if (chance > 1 || chance < 0) { + context.getForWhom().sendRawMessage(ChatColor.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 + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("eventEditorLightningPrompt"); + } + + @SuppressWarnings("unchecked") + @Override + public Prompt acceptInput(ConversationContext context, String input) { + Player player = (Player) context.getForWhom(); + if (input.equalsIgnoreCase(Lang.get("cmdAdd"))) { + Block block = selectedLightningLocations.get(player.getUniqueId()); + if (block != null) { + Location loc = block.getLocation(); + LinkedList locs; + if (context.getSessionData(CK.E_LIGHTNING) != null) { + locs = (LinkedList) context.getSessionData(CK.E_LIGHTNING); + } else { + locs = new LinkedList(); + } + locs.add(Quests.getLocationInfo(loc)); + context.setSessionData(CK.E_LIGHTNING, locs); + selectedLightningLocations.remove(player.getUniqueId()); + } else { + player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst")); + return new LightningPrompt(); + } + return new CreateMenuPrompt(); + } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { + context.setSessionData(CK.E_LIGHTNING, null); + selectedLightningLocations.remove(player.getUniqueId()); + return new CreateMenuPrompt(); + } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { + selectedLightningLocations.remove(player.getUniqueId()); + return new CreateMenuPrompt(); + } else { + return new LightningPrompt(); + } + } + } + + private class PotionEffectPrompt extends FixedSetPrompt { + + public PotionEffectPrompt() { + super("1", "2", "3", "4", "5"); + } + + @SuppressWarnings("unchecked") + @Override + public String getPromptText(ConversationContext context) { + String text = ChatColor.GOLD + Lang.get("eventEditorPotionEffectsTitle") + "\n"; + if (context.getSessionData(CK.E_POTION_TYPES) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetPotionEffectTypes") + " (" + Lang.get("noneSet") + ")\n"; + text += ChatColor.GRAY + "2 - " + Lang.get("eventEditorSetPotionDurations") + " " + Lang.get("eventEditorNoTypesSet") + "\n"; + text += ChatColor.GRAY + "3 - " + Lang.get("eventEditorSetPotionMagnitudes") + " " + Lang.get("eventEditorNoTypesSet") + "\n"; + text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; + text += ChatColor.GREEN + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetPotionEffectTypes") + "\n"; + for (String s : (LinkedList) context.getSessionData(CK.E_POTION_TYPES)) { + text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n"; + } + if (context.getSessionData(CK.E_POTION_DURATIONS) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetPotionDurations") + " (" + Lang.get("noneSet") + ")\n"; + text += ChatColor.GRAY + "3 - " + Lang.get("eventEditorSetPotionMagnitudes") + " " + Lang.get("eventEditorNoDurationsSet") + "\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorNoDurationsSet") + "\n"; + for (Long l : (LinkedList) context.getSessionData(CK.E_POTION_DURATIONS)) { + text += ChatColor.GRAY + " - " + ChatColor.DARK_AQUA + Quests.getTime(l * 50L) + "\n"; + } + if (context.getSessionData(CK.E_POTION_STRENGHT) == null) { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetPotionMagnitudes") + " (" + Lang.get("noneSet") + ")\n"; + } else { + text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("eventEditorSetPotionMagnitudes") + "\n"; + for (int i : (LinkedList) context.getSessionData(CK.E_POTION_STRENGHT)) { + text += ChatColor.GRAY + " - " + ChatColor.DARK_PURPLE + i + "\n"; + } + } + } + text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n"; + text += ChatColor.GREEN + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done"); + } + return text; + } + + @SuppressWarnings("unchecked") + @Override + protected Prompt acceptValidatedInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase("1")) { + return new PotionTypesPrompt(); + } else if (input.equalsIgnoreCase("2")) { + if (context.getSessionData(CK.E_POTION_TYPES) == null) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetPotionTypesFirst")); + return new PotionEffectPrompt(); + } else { + return new PotionDurationsPrompt(); + } + } else if (input.equalsIgnoreCase("3")) { + if (context.getSessionData(CK.E_POTION_TYPES) == null) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetPotionTypesAndDurationsFirst")); + return new PotionEffectPrompt(); + } else if (context.getSessionData(CK.E_POTION_DURATIONS) == null) { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorMustSetPotionDurationsFirst")); + return new PotionEffectPrompt(); + } else { + return new PotionMagnitudesPrompt(); + } + } else if (input.equalsIgnoreCase("4")) { + context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("eventEditorPotionsCleared")); + context.setSessionData(CK.E_POTION_TYPES, null); + context.setSessionData(CK.E_POTION_DURATIONS, null); + context.setSessionData(CK.E_POTION_STRENGHT, null); + return new PotionEffectPrompt(); + } else if (input.equalsIgnoreCase("5")) { + int one; + int two; + int three; + if (context.getSessionData(CK.E_POTION_TYPES) != null) { + one = ((List) context.getSessionData(CK.E_POTION_TYPES)).size(); + } else { + one = 0; + } + if (context.getSessionData(CK.E_POTION_DURATIONS) != null) { + two = ((List) context.getSessionData(CK.E_POTION_DURATIONS)).size(); + } else { + two = 0; + } + if (context.getSessionData(CK.E_POTION_STRENGHT) != null) { + three = ((List) context.getSessionData(CK.E_POTION_STRENGHT)).size(); + } else { + three = 0; + } + if (one == two && two == three) { + return new CreateMenuPrompt(); + } else { + context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("eventEditorListSizeMismatch")); + return new PotionEffectPrompt(); + } + } + return null; + } + } + + private class PotionTypesPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + String effs = ChatColor.LIGHT_PURPLE + Lang.get("eventEditorPotionTypesTitle") + "\n"; + for (PotionEffectType pet : PotionEffectType.values()) { + effs += (pet != null && pet.getName() != null) ? (ChatColor.DARK_PURPLE + pet.getName() + "\n") : ""; + } + return effs + ChatColor.YELLOW + Lang.get("eventEditorSetPotionEffectsPrompt"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + Player player = (Player) context.getForWhom(); + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + LinkedList effTypes = new LinkedList(); + for (String s : input.split(" ")) { + if (PotionEffectType.getByName(s.toUpperCase()) != null) { + effTypes.add(PotionEffectType.getByName(s.toUpperCase()).getName()); + context.setSessionData(CK.E_POTION_TYPES, effTypes); + } else { + player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("eventEditorInvalidPotionType")); + return new PotionTypesPrompt(); + } + } + } + return new PotionEffectPrompt(); + } + } + + private class PotionDurationsPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("eventEditorSetPotionDurationsPrompt"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + Player player = (Player) context.getForWhom(); + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + LinkedList effDurations = new LinkedList(); + for (String s : input.split(" ")) { + try { + int i = Integer.parseInt(s); + long l = i * 1000; + if (l < 1000) { + player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("eventEditorNotGreaterThanOneSecond")); + return new PotionDurationsPrompt(); + } + effDurations.add(l / 50L); + } catch (NumberFormatException e) { + player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("eventEditorNotANumber")); + return new PotionDurationsPrompt(); + } + } + context.setSessionData(CK.E_POTION_DURATIONS, effDurations); + } + return new PotionEffectPrompt(); + } + } + + private class PotionMagnitudesPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("eventEditorSetPotionMagnitudesPrompt"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + Player player = (Player) context.getForWhom(); + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) { + LinkedList magAmounts = new LinkedList(); + for (String s : input.split(" ")) { + try { + int i = Integer.parseInt(s); + if (i < 1) { + player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("eventEditorNotGreaterThanZero")); + return new PotionMagnitudesPrompt(); + } + magAmounts.add(i); + } catch (NumberFormatException e) { + player.sendMessage(ChatColor.LIGHT_PURPLE + s + " " + ChatColor.RED + Lang.get("eventEditorNotANumber")); + return new PotionMagnitudesPrompt(); + } + } + context.setSessionData(CK.E_POTION_STRENGHT, magAmounts); + } + return new PotionEffectPrompt(); + } + } + + private class HungerPrompt extends NumericPrompt { + + @Override + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("eventEditorSetHungerPrompt"); + } + + @Override + protected Prompt acceptValidatedInput(ConversationContext context, Number input) { + if (input.intValue() != -1) { + if (input.intValue() < 0) { + ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorHungerLevelAtLeastZero")); + return new HungerPrompt(); + } else { + context.setSessionData(CK.E_HUNGER, (Integer) input.intValue()); + } + } else { + context.setSessionData(CK.E_HUNGER, null); + } + return new CreateMenuPrompt(); + } + } + + private class SaturationPrompt extends NumericPrompt { + + @Override + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("eventEditorSetSaturationPrompt"); + } + + @Override + protected Prompt acceptValidatedInput(ConversationContext context, Number input) { + if (input.intValue() != -1) { + if (input.intValue() < 0) { + ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorSaturationLevelAtLeastZero")); + return new SaturationPrompt(); + } else { + context.setSessionData(CK.E_SATURATION, (Integer) input.intValue()); + } + } else { + context.setSessionData(CK.E_SATURATION, null); + } + return new CreateMenuPrompt(); + } + } + + private class HealthPrompt extends NumericPrompt { + + @Override + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("eventEditorSetHealthPrompt"); + } + + @Override + protected Prompt acceptValidatedInput(ConversationContext context, Number input) { + if (input.intValue() != -1) { + if (input.intValue() < 0) { + ((Player) context.getForWhom()).sendMessage(ChatColor.RED + Lang.get("eventEditorHealthLevelAtLeastZero")); + return new HealthPrompt(); + } else { + context.setSessionData(CK.E_HEALTH, (Integer) input.intValue()); + } + } else { + context.setSessionData(CK.E_HEALTH, null); + } + return new CreateMenuPrompt(); + } + } + + private class TeleportPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + return ChatColor.YELLOW + Lang.get("eventEditorSetTeleportPrompt"); + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + Player player = (Player) context.getForWhom(); + if (input.equalsIgnoreCase(Lang.get("cmdDone"))) { + Block block = selectedTeleportLocations.get(player.getUniqueId()); + if (block != null) { + Location loc = block.getLocation(); + context.setSessionData(CK.E_TELEPORT, Quests.getLocationInfo(loc)); + selectedTeleportLocations.remove(player.getUniqueId()); + } else { + player.sendMessage(ChatColor.RED + Lang.get("eventEditorSelectBlockFirst")); + return new TeleportPrompt(); + } + return new CreateMenuPrompt(); + } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { + context.setSessionData(CK.E_TELEPORT, null); + selectedTeleportLocations.remove(player.getUniqueId()); + return new CreateMenuPrompt(); + } else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) { + selectedTeleportLocations.remove(player.getUniqueId()); + return new CreateMenuPrompt(); + } else { + return new TeleportPrompt(); + } + } + } + + private class CommandsPrompt extends StringPrompt { + + @Override + public String getPromptText(ConversationContext context) { + String text = ChatColor.GOLD + "" + ChatColor.ITALIC + Lang.get("eventEditorCommandsNote"); + return ChatColor.YELLOW + Lang.get("eventEditorSetCommandsPrompt") + "\n" + text; + } + + @Override + public Prompt acceptInput(ConversationContext context, String input) { + if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) { + String[] commands = input.split(","); + LinkedList cmdList = new LinkedList(); + cmdList.addAll(Arrays.asList(commands)); + context.setSessionData(CK.E_COMMANDS, cmdList); + } else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) { + context.setSessionData(CK.E_COMMANDS, null); + } + return new CreateMenuPrompt(); + } + } } diff --git a/src/main/java/me/blackvein/quests/NpcEffectThread.java b/src/main/java/me/blackvein/quests/NpcEffectThread.java index 38ed137b0..99a7ebee0 100644 --- a/src/main/java/me/blackvein/quests/NpcEffectThread.java +++ b/src/main/java/me/blackvein/quests/NpcEffectThread.java @@ -2,6 +2,14 @@ package me.blackvein.quests; import java.util.List; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + +import me.blackvein.particles.Eff_1_10_R1; +import me.blackvein.particles.Eff_1_11_R1; +import me.blackvein.particles.Eff_1_12_R1; import me.blackvein.particles.Eff_1_7_R3; import me.blackvein.particles.Eff_1_7_R4; import me.blackvein.particles.Eff_1_8_R1; @@ -9,1278 +17,974 @@ import me.blackvein.particles.Eff_1_8_R2; import me.blackvein.particles.Eff_1_8_R3; import me.blackvein.particles.Eff_1_9_R1; import me.blackvein.particles.Eff_1_9_R2; -import me.blackvein.particles.Eff_1_10_R1; -import me.blackvein.particles.Eff_1_11_R1; -import me.blackvein.particles.Eff_1_12_R1; import net.citizensnpcs.api.npc.NPC; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; - public class NpcEffectThread implements Runnable { - final Quests plugin; + final Quests plugin; - public NpcEffectThread(Quests quests) { - - plugin = quests; - - } + public NpcEffectThread(Quests quests) { + plugin = quests; + } @Override - public void run() { - - for (Player player : plugin.getServer().getOnlinePlayers()) { - - Quester quester = plugin.getQuester(player.getUniqueId()); - List nearby = player.getNearbyEntities(32.0, 32.0, 32.0); - if (nearby.isEmpty() == false) { - - for (Entity e : nearby) { - if (plugin.citizens != null) { - if (plugin.citizens.getNPCRegistry().isNPC(e)) { - - NPC npc = plugin.citizens.getNPCRegistry().getNPC(e); - if (plugin.hasQuest(npc, quester)) { - showEffect(player, npc); - - } - - } - } - - } - - } - - } - - } - - private static void showEffect(Player player, NPC npc) { - - if (Bukkit.getBukkitVersion().contains("1.7.9")) { - showEffect_R3(player, npc); - } else if (Bukkit.getBukkitVersion().contains("1.7.10")) { - showEffect_R4(player, npc); - } else if (Bukkit.getBukkitVersion().contains("1.8.4") - || Bukkit.getBukkitVersion().contains("1.8.5") - || Bukkit.getBukkitVersion().contains("1.8.6") - || Bukkit.getBukkitVersion().contains("1.8.7") - || Bukkit.getBukkitVersion().contains("1.8.8")) { - showEffect_1_8_R3(player, npc); - } else if (Bukkit.getBukkitVersion().contains("1.8.3")) { - showEffect_1_8_R2(player, npc); - } else if (Bukkit.getBukkitVersion().contains("1.8")) { - showEffect_1_8_R1(player, npc); - } else if (Bukkit.getBukkitVersion().contains("1.9.4")) { - showEffect_1_9_R2(player, npc); - } else if (Bukkit.getBukkitVersion().contains("1.9")) { - showEffect_1_9_R1(player, npc); - } else if (Bukkit.getBukkitVersion().contains("1.10")) { - showEffect_1_10_R1(player, npc); - } else if (Bukkit.getBukkitVersion().contains("1.11")) { - showEffect_1_11_R1(player, npc); - } else if (Bukkit.getBukkitVersion().contains("1.12")) { - showEffect_1_12_R1(player, npc); - } - } - - private static void showEffect_1_12_R1(Player player, NPC npc) { - - //Get and set eye location, because npc.getBukkitEntity() is deprecated. - Location eyeLoc = npc.getEntity().getLocation(); - eyeLoc.setY(eyeLoc.getY() + 1.5); - - if (Quests.effect.equalsIgnoreCase("enchant")) { - - try { - Eff_1_12_R1.ENCHANTMENT_TABLE.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 10, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("crit")) { - - try { - Eff_1_12_R1.CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("spell")) { - - try { - Eff_1_12_R1.INSTANT_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("magiccrit")) { - - try { - Eff_1_12_R1.MAGIC_CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("mobspell")) { - - try { - Eff_1_12_R1.MOB_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("note")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_12_R1.NOTE.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("portal")) { - - try { - Eff_1_12_R1.PORTAL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 5, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("dust")) { - - try { - Location newLoc = new Location(player.getWorld(), eyeLoc.getX(), eyeLoc.getY() + (float) 0.5, eyeLoc.getZ()); - Eff_1_12_R1.RED_DUST.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("witch")) { - - try { - Eff_1_12_R1.WITCH_MAGIC.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("snowball")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_12_R1.SNOWBALL_POOF.sendToPlayer(player, newLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("splash")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_12_R1.SPLASH.sendToPlayer(player, newLoc, 0, 0, 0, 1, 4, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("smoke")) { - - try { - Eff_1_12_R1.TOWN_AURA.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 20, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else { - - try { - Eff_1_12_R1.valueOf(Quests.effect).sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - Quests.getInstance().getLogger().info(Quests.effect + " is not a valid effect name!"); - e.printStackTrace(); - } - } - - } - - private static void showEffect_1_11_R1(Player player, NPC npc) { - - //Get and set eye location, because npc.getBukkitEntity() is deprecated. - Location eyeLoc = npc.getEntity().getLocation(); - eyeLoc.setY(eyeLoc.getY() + 1.5); - - if (Quests.effect.equalsIgnoreCase("enchant")) { - - try { - Eff_1_11_R1.ENCHANTMENT_TABLE.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 10, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("crit")) { - - try { - Eff_1_11_R1.CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("spell")) { - - try { - Eff_1_11_R1.INSTANT_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("magiccrit")) { - - try { - Eff_1_11_R1.MAGIC_CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("mobspell")) { - - try { - Eff_1_11_R1.MOB_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("note")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_11_R1.NOTE.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("portal")) { - - try { - Eff_1_11_R1.PORTAL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 5, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("dust")) { - - try { - Location newLoc = new Location(player.getWorld(), eyeLoc.getX(), eyeLoc.getY() + (float) 0.5, eyeLoc.getZ()); - Eff_1_11_R1.RED_DUST.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("witch")) { - - try { - Eff_1_11_R1.WITCH_MAGIC.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("snowball")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_11_R1.SNOWBALL_POOF.sendToPlayer(player, newLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("splash")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_11_R1.SPLASH.sendToPlayer(player, newLoc, 0, 0, 0, 1, 4, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("smoke")) { - - try { - Eff_1_11_R1.TOWN_AURA.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 20, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else { - - try { - Eff_1_11_R1.valueOf(Quests.effect).sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - Quests.getInstance().getLogger().info(Quests.effect + " is not a valid effect name!"); - e.printStackTrace(); - } - } - - } - - private static void showEffect_1_10_R1(Player player, NPC npc) { - - //Get and set eye location, because npc.getBukkitEntity() is deprecated. - Location eyeLoc = npc.getEntity().getLocation(); - eyeLoc.setY(eyeLoc.getY() + 1.5); - - if (Quests.effect.equalsIgnoreCase("enchant")) { - - try { - Eff_1_10_R1.ENCHANTMENT_TABLE.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 10, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("crit")) { - - try { - Eff_1_10_R1.CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("spell")) { - - try { - Eff_1_10_R1.INSTANT_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("magiccrit")) { - - try { - Eff_1_10_R1.MAGIC_CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("mobspell")) { - - try { - Eff_1_10_R1.MOB_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("note")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_10_R1.NOTE.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("portal")) { - - try { - Eff_1_10_R1.PORTAL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 5, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("dust")) { - - try { - Location newLoc = new Location(player.getWorld(), eyeLoc.getX(), eyeLoc.getY() + (float) 0.5, eyeLoc.getZ()); - Eff_1_10_R1.RED_DUST.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("witch")) { - - try { - Eff_1_10_R1.WITCH_MAGIC.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("snowball")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_10_R1.SNOWBALL_POOF.sendToPlayer(player, newLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("splash")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_10_R1.SPLASH.sendToPlayer(player, newLoc, 0, 0, 0, 1, 4, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("smoke")) { - - try { - Eff_1_10_R1.TOWN_AURA.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 20, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else { - - try { - Eff_1_10_R1.valueOf(Quests.effect).sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - Quests.getInstance().getLogger().info(Quests.effect + " is not a valid effect name!"); - e.printStackTrace(); - } - } - - } - -private static void showEffect_1_9_R2(Player player, NPC npc) { - - //Get and set eye location, because npc.getBukkitEntity() is deprecated. - Location eyeLoc = npc.getEntity().getLocation(); - eyeLoc.setY(eyeLoc.getY() + 1.5); - - if (Quests.effect.equalsIgnoreCase("enchant")) { - - try { - Eff_1_9_R2.ENCHANTMENT_TABLE.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 10, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("crit")) { - - try { - Eff_1_9_R2.CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("spell")) { - - try { - Eff_1_9_R2.INSTANT_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("magiccrit")) { - - try { - Eff_1_9_R2.MAGIC_CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("mobspell")) { - - try { - Eff_1_9_R2.MOB_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("note")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_9_R2.NOTE.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("portal")) { - - try { - Eff_1_9_R2.PORTAL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 5, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("dust")) { - - try { - Location newLoc = new Location(player.getWorld(), eyeLoc.getX(), eyeLoc.getY() + (float) 0.5, eyeLoc.getZ()); - Eff_1_9_R2.RED_DUST.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("witch")) { - - try { - Eff_1_9_R2.WITCH_MAGIC.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("snowball")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_9_R2.SNOWBALL_POOF.sendToPlayer(player, newLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("splash")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_9_R2.SPLASH.sendToPlayer(player, newLoc, 0, 0, 0, 1, 4, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("smoke")) { - - try { - Eff_1_9_R2.TOWN_AURA.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 20, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else { - - try { - Eff_1_9_R2.valueOf(Quests.effect).sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - Quests.getInstance().getLogger().info(Quests.effect + " is not a valid effect name!"); - e.printStackTrace(); - } - } - - } - - private static void showEffect_1_9_R1(Player player, NPC npc) { - - //Get and set eye location, because npc.getBukkitEntity() is deprecated. - Location eyeLoc = npc.getEntity().getLocation(); - eyeLoc.setY(eyeLoc.getY() + 1.5); - - if (Quests.effect.equalsIgnoreCase("enchant")) { - - try { - Eff_1_9_R1.ENCHANTMENT_TABLE.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 10, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("crit")) { - - try { - Eff_1_9_R1.CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("spell")) { - - try { - Eff_1_9_R1.INSTANT_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("magiccrit")) { - - try { - Eff_1_9_R1.MAGIC_CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("mobspell")) { - - try { - Eff_1_9_R1.MOB_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("note")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_9_R1.NOTE.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("portal")) { - - try { - Eff_1_9_R1.PORTAL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 5, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("dust")) { - - try { - Location newLoc = new Location(player.getWorld(), eyeLoc.getX(), eyeLoc.getY() + (float) 0.5, eyeLoc.getZ()); - Eff_1_9_R1.RED_DUST.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("witch")) { - - try { - Eff_1_9_R1.WITCH_MAGIC.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("snowball")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_9_R1.SNOWBALL_POOF.sendToPlayer(player, newLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("splash")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_9_R1.SPLASH.sendToPlayer(player, newLoc, 0, 0, 0, 1, 4, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("smoke")) { - - try { - Eff_1_9_R1.TOWN_AURA.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 20, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else { - - try { - Eff_1_9_R1.valueOf(Quests.effect).sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - Quests.getInstance().getLogger().info(Quests.effect + " is not a valid effect name!"); - e.printStackTrace(); - } - } - - } - - private static void showEffect_1_8_R3(Player player, NPC npc) { - - //Get and set eye location, because npc.getBukkitEntity() is deprecated. - Location eyeLoc = npc.getEntity().getLocation(); - eyeLoc.setY(eyeLoc.getY() + 1.5); - - if (Quests.effect.equalsIgnoreCase("enchant")) { - - try { - Eff_1_8_R3.ENCHANTMENT_TABLE.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 10, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("crit")) { - - try { - Eff_1_8_R3.CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("spell")) { - - try { - Eff_1_8_R3.INSTANT_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("magiccrit")) { - - try { - Eff_1_8_R3.MAGIC_CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("mobspell")) { - - try { - Eff_1_8_R3.MOB_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("note")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_8_R3.NOTE.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("portal")) { - - try { - Eff_1_8_R3.PORTAL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 5, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("dust")) { - - try { - Location newLoc = new Location(player.getWorld(), eyeLoc.getX(), eyeLoc.getY() + (float) 0.5, eyeLoc.getZ()); - Eff_1_8_R3.RED_DUST.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("witch")) { - - try { - Eff_1_8_R3.WITCH_MAGIC.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("snowball")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_8_R3.SNOWBALL_POOF.sendToPlayer(player, newLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("splash")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_8_R3.SPLASH.sendToPlayer(player, newLoc, 0, 0, 0, 1, 4, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("smoke")) { - - try { - Eff_1_8_R3.TOWN_AURA.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 20, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else { - - try { - Eff_1_8_R3.valueOf(Quests.effect).sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - Quests.getInstance().getLogger().info(Quests.effect + " is not a valid effect name!"); - e.printStackTrace(); - } - } - - } - - private static void showEffect_1_8_R2(Player player, NPC npc) { - - //Get and set eye location, because npc.getBukkitEntity() is deprecated. - Location eyeLoc = npc.getEntity().getLocation(); - eyeLoc.setY(eyeLoc.getY() + 1.5); - - if (Quests.effect.equalsIgnoreCase("enchant")) { - - try { - Eff_1_8_R2.ENCHANTMENT_TABLE.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 10, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("crit")) { - - try { - Eff_1_8_R2.CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("spell")) { - - try { - Eff_1_8_R2.INSTANT_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("magiccrit")) { - - try { - Eff_1_8_R2.MAGIC_CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("mobspell")) { - - try { - Eff_1_8_R2.MOB_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("note")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_8_R2.NOTE.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("portal")) { - - try { - Eff_1_8_R2.PORTAL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 5, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("dust")) { - - try { - Location newLoc = new Location(player.getWorld(), eyeLoc.getX(), eyeLoc.getY() + (float) 0.5, eyeLoc.getZ()); - Eff_1_8_R2.RED_DUST.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("witch")) { - - try { - Eff_1_8_R2.WITCH_MAGIC.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("snowball")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_8_R2.SNOWBALL_POOF.sendToPlayer(player, newLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("splash")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_8_R2.SPLASH.sendToPlayer(player, newLoc, 0, 0, 0, 1, 4, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("smoke")) { - - try { - Eff_1_8_R2.TOWN_AURA.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 20, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else { - - try { - Eff_1_8_R2.valueOf(Quests.effect).sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - Quests.getInstance().getLogger().info(Quests.effect + " is not a valid effect name!"); - e.printStackTrace(); - } - } - - } - - private static void showEffect_1_8_R1(Player player, NPC npc) { - - //Get and set eye location, because npc.getBukkitEntity() is deprecated. - Location eyeLoc = npc.getEntity().getLocation(); - eyeLoc.setY(eyeLoc.getY() + 1.5); - - if (Quests.effect.equalsIgnoreCase("enchant")) { - - try { - Eff_1_8_R1.ENCHANTMENT_TABLE.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 10, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("crit")) { - - try { - Eff_1_8_R1.CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("spell")) { - - try { - Eff_1_8_R1.INSTANT_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("magiccrit")) { - - try { - Eff_1_8_R1.MAGIC_CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("mobspell")) { - - try { - Eff_1_8_R1.MOB_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("note")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_8_R1.NOTE.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("portal")) { - - try { - Eff_1_8_R1.PORTAL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 5, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("dust")) { - - try { - Location newLoc = new Location(player.getWorld(), eyeLoc.getX(), eyeLoc.getY() + (float) 0.5, eyeLoc.getZ()); - Eff_1_8_R1.RED_DUST.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("witch")) { - - try { - Eff_1_8_R1.WITCH_MAGIC.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("snowball")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_8_R1.SNOWBALL_POOF.sendToPlayer(player, newLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("splash")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_8_R1.SPLASH.sendToPlayer(player, newLoc, 0, 0, 0, 1, 4, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("smoke")) { - - try { - Eff_1_8_R1.TOWN_AURA.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 20, null); - } catch (Exception e) { - e.printStackTrace(); - } - - } else { - - try { - Eff_1_8_R1.valueOf(Quests.effect).sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); - } catch (Exception e) { - Quests.getInstance().getLogger().info(Quests.effect + " is not a valid effect name!"); - e.printStackTrace(); - } - } - - } - - private static void showEffect_R4(Player player, NPC npc) { - - //Get and set eye location, because npc.getBukkitEntity() is deprecated. - Location eyeLoc = npc.getEntity().getLocation(); - eyeLoc.setY(eyeLoc.getY() + 1.5); - - if (Quests.effect.equalsIgnoreCase("enchant")) { - - try { - Eff_1_7_R4.ENCHANTMENT_TABLE.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 10); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("crit")) { - - try { - Eff_1_7_R4.CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("spell")) { - - try { - Eff_1_7_R4.INSTANT_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("magiccrit")) { - - try { - Eff_1_7_R4.MAGIC_CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("mobspell")) { - - try { - Eff_1_7_R4.MOB_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("note")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_7_R4.NOTE.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("portal")) { - - try { - Eff_1_7_R4.PORTAL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 5); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("dust")) { - - try { - Location newLoc = new Location(player.getWorld(), eyeLoc.getX(), eyeLoc.getY() + (float) 0.5, eyeLoc.getZ()); - Eff_1_7_R4.RED_DUST.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("witch")) { - - try { - Eff_1_7_R4.WITCH_MAGIC.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("snowball")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_7_R4.SNOWBALL_POOF.sendToPlayer(player, newLoc, 0, 0, 0, 1, 3); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("splash")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_7_R4.SPLASH.sendToPlayer(player, newLoc, 0, 0, 0, 1, 4); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("smoke")) { - - try { - Eff_1_7_R4.TOWN_AURA.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 20); - } catch (Exception e) { - e.printStackTrace(); - } - - } - - } - - private static void showEffect_R3(Player player, NPC npc) { - - //Get and set eye location, because npc.getBukkitEntity() is deprecated. - Location eyeLoc = npc.getEntity().getLocation(); - eyeLoc.setY(eyeLoc.getY() + 1.5); - - if (Quests.effect.equalsIgnoreCase("enchant")) { - - try { - Eff_1_7_R3.ENCHANTMENT_TABLE.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 10); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("crit")) { - - try { - Eff_1_7_R3.CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("spell")) { - - try { - Eff_1_7_R3.INSTANT_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("magiccrit")) { - - try { - Eff_1_7_R3.MAGIC_CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("mobspell")) { - - try { - Eff_1_7_R3.MOB_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("note")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_7_R3.NOTE.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("portal")) { - - try { - Eff_1_7_R3.PORTAL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 5); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("dust")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_7_R3.RED_DUST.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("witch")) { - - try { - Eff_1_7_R3.WITCH_MAGIC.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("snowball")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_7_R3.SNOWBALL_POOF.sendToPlayer(player, newLoc, 0, 0, 0, 1, 3); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("splash")) { - - try { - Location old = eyeLoc; - Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); - Eff_1_7_R3.SPLASH.sendToPlayer(player, newLoc, 0, 0, 0, 1, 4); - } catch (Exception e) { - e.printStackTrace(); - } - - } else if (Quests.effect.equalsIgnoreCase("smoke")) { - - try { - Eff_1_7_R3.TOWN_AURA.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 20); - } catch (Exception e) { - e.printStackTrace(); - } - - } - - } - + public void run() { + for (Player player : plugin.getServer().getOnlinePlayers()) { + Quester quester = plugin.getQuester(player.getUniqueId()); + List nearby = player.getNearbyEntities(32.0, 32.0, 32.0); + if (nearby.isEmpty() == false) { + for (Entity e : nearby) { + if (plugin.citizens != null) { + if (plugin.citizens.getNPCRegistry().isNPC(e)) { + NPC npc = plugin.citizens.getNPCRegistry().getNPC(e); + if (plugin.hasQuest(npc, quester)) { + showEffect(player, npc); + } + } + } + } + } + } + } + + private static void showEffect(Player player, NPC npc) { + if (Bukkit.getBukkitVersion().contains("1.7.9")) { + showEffect_R3(player, npc); + } else if (Bukkit.getBukkitVersion().contains("1.7.10")) { + showEffect_R4(player, npc); + } else if (Bukkit.getBukkitVersion().contains("1.8.4") || Bukkit.getBukkitVersion().contains("1.8.5") || Bukkit.getBukkitVersion().contains("1.8.6") || Bukkit.getBukkitVersion().contains("1.8.7") || Bukkit.getBukkitVersion().contains("1.8.8")) { + showEffect_1_8_R3(player, npc); + } else if (Bukkit.getBukkitVersion().contains("1.8.3")) { + showEffect_1_8_R2(player, npc); + } else if (Bukkit.getBukkitVersion().contains("1.8")) { + showEffect_1_8_R1(player, npc); + } else if (Bukkit.getBukkitVersion().contains("1.9.4")) { + showEffect_1_9_R2(player, npc); + } else if (Bukkit.getBukkitVersion().contains("1.9")) { + showEffect_1_9_R1(player, npc); + } else if (Bukkit.getBukkitVersion().contains("1.10")) { + showEffect_1_10_R1(player, npc); + } else if (Bukkit.getBukkitVersion().contains("1.11")) { + showEffect_1_11_R1(player, npc); + } else if (Bukkit.getBukkitVersion().contains("1.12")) { + showEffect_1_12_R1(player, npc); + } + } + + private static void showEffect_1_12_R1(Player player, NPC npc) { + // Get and set eye location, because npc.getBukkitEntity() is deprecated. + Location eyeLoc = npc.getEntity().getLocation(); + eyeLoc.setY(eyeLoc.getY() + 1.5); + if (Quests.effect.equalsIgnoreCase("enchant")) { + try { + Eff_1_12_R1.ENCHANTMENT_TABLE.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 10, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("crit")) { + try { + Eff_1_12_R1.CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("spell")) { + try { + Eff_1_12_R1.INSTANT_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("magiccrit")) { + try { + Eff_1_12_R1.MAGIC_CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("mobspell")) { + try { + Eff_1_12_R1.MOB_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("note")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_12_R1.NOTE.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("portal")) { + try { + Eff_1_12_R1.PORTAL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 5, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("dust")) { + try { + Location newLoc = new Location(player.getWorld(), eyeLoc.getX(), eyeLoc.getY() + (float) 0.5, eyeLoc.getZ()); + Eff_1_12_R1.RED_DUST.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("witch")) { + try { + Eff_1_12_R1.WITCH_MAGIC.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("snowball")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_12_R1.SNOWBALL_POOF.sendToPlayer(player, newLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("splash")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_12_R1.SPLASH.sendToPlayer(player, newLoc, 0, 0, 0, 1, 4, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("smoke")) { + try { + Eff_1_12_R1.TOWN_AURA.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 20, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + try { + Eff_1_12_R1.valueOf(Quests.effect).sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + Quests.getInstance().getLogger().info(Quests.effect + " is not a valid effect name!"); + e.printStackTrace(); + } + } + } + + private static void showEffect_1_11_R1(Player player, NPC npc) { + // Get and set eye location, because npc.getBukkitEntity() is deprecated. + Location eyeLoc = npc.getEntity().getLocation(); + eyeLoc.setY(eyeLoc.getY() + 1.5); + if (Quests.effect.equalsIgnoreCase("enchant")) { + try { + Eff_1_11_R1.ENCHANTMENT_TABLE.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 10, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("crit")) { + try { + Eff_1_11_R1.CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("spell")) { + try { + Eff_1_11_R1.INSTANT_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("magiccrit")) { + try { + Eff_1_11_R1.MAGIC_CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("mobspell")) { + try { + Eff_1_11_R1.MOB_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("note")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_11_R1.NOTE.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("portal")) { + try { + Eff_1_11_R1.PORTAL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 5, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("dust")) { + try { + Location newLoc = new Location(player.getWorld(), eyeLoc.getX(), eyeLoc.getY() + (float) 0.5, eyeLoc.getZ()); + Eff_1_11_R1.RED_DUST.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("witch")) { + try { + Eff_1_11_R1.WITCH_MAGIC.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("snowball")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_11_R1.SNOWBALL_POOF.sendToPlayer(player, newLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("splash")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_11_R1.SPLASH.sendToPlayer(player, newLoc, 0, 0, 0, 1, 4, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("smoke")) { + try { + Eff_1_11_R1.TOWN_AURA.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 20, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + try { + Eff_1_11_R1.valueOf(Quests.effect).sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + Quests.getInstance().getLogger().info(Quests.effect + " is not a valid effect name!"); + e.printStackTrace(); + } + } + } + + private static void showEffect_1_10_R1(Player player, NPC npc) { + // Get and set eye location, because npc.getBukkitEntity() is deprecated. + Location eyeLoc = npc.getEntity().getLocation(); + eyeLoc.setY(eyeLoc.getY() + 1.5); + if (Quests.effect.equalsIgnoreCase("enchant")) { + try { + Eff_1_10_R1.ENCHANTMENT_TABLE.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 10, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("crit")) { + try { + Eff_1_10_R1.CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("spell")) { + try { + Eff_1_10_R1.INSTANT_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("magiccrit")) { + try { + Eff_1_10_R1.MAGIC_CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("mobspell")) { + try { + Eff_1_10_R1.MOB_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("note")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_10_R1.NOTE.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("portal")) { + try { + Eff_1_10_R1.PORTAL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 5, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("dust")) { + try { + Location newLoc = new Location(player.getWorld(), eyeLoc.getX(), eyeLoc.getY() + (float) 0.5, eyeLoc.getZ()); + Eff_1_10_R1.RED_DUST.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("witch")) { + try { + Eff_1_10_R1.WITCH_MAGIC.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("snowball")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_10_R1.SNOWBALL_POOF.sendToPlayer(player, newLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("splash")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_10_R1.SPLASH.sendToPlayer(player, newLoc, 0, 0, 0, 1, 4, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("smoke")) { + try { + Eff_1_10_R1.TOWN_AURA.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 20, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + try { + Eff_1_10_R1.valueOf(Quests.effect).sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + Quests.getInstance().getLogger().info(Quests.effect + " is not a valid effect name!"); + e.printStackTrace(); + } + } + } + + private static void showEffect_1_9_R2(Player player, NPC npc) { + // Get and set eye location, because npc.getBukkitEntity() is deprecated. + Location eyeLoc = npc.getEntity().getLocation(); + eyeLoc.setY(eyeLoc.getY() + 1.5); + if (Quests.effect.equalsIgnoreCase("enchant")) { + try { + Eff_1_9_R2.ENCHANTMENT_TABLE.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 10, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("crit")) { + try { + Eff_1_9_R2.CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("spell")) { + try { + Eff_1_9_R2.INSTANT_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("magiccrit")) { + try { + Eff_1_9_R2.MAGIC_CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("mobspell")) { + try { + Eff_1_9_R2.MOB_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("note")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_9_R2.NOTE.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("portal")) { + try { + Eff_1_9_R2.PORTAL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 5, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("dust")) { + try { + Location newLoc = new Location(player.getWorld(), eyeLoc.getX(), eyeLoc.getY() + (float) 0.5, eyeLoc.getZ()); + Eff_1_9_R2.RED_DUST.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("witch")) { + try { + Eff_1_9_R2.WITCH_MAGIC.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("snowball")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_9_R2.SNOWBALL_POOF.sendToPlayer(player, newLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("splash")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_9_R2.SPLASH.sendToPlayer(player, newLoc, 0, 0, 0, 1, 4, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("smoke")) { + try { + Eff_1_9_R2.TOWN_AURA.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 20, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + try { + Eff_1_9_R2.valueOf(Quests.effect).sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + Quests.getInstance().getLogger().info(Quests.effect + " is not a valid effect name!"); + e.printStackTrace(); + } + } + } + + private static void showEffect_1_9_R1(Player player, NPC npc) { + // Get and set eye location, because npc.getBukkitEntity() is deprecated. + Location eyeLoc = npc.getEntity().getLocation(); + eyeLoc.setY(eyeLoc.getY() + 1.5); + if (Quests.effect.equalsIgnoreCase("enchant")) { + try { + Eff_1_9_R1.ENCHANTMENT_TABLE.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 10, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("crit")) { + try { + Eff_1_9_R1.CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("spell")) { + try { + Eff_1_9_R1.INSTANT_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("magiccrit")) { + try { + Eff_1_9_R1.MAGIC_CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("mobspell")) { + try { + Eff_1_9_R1.MOB_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("note")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_9_R1.NOTE.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("portal")) { + try { + Eff_1_9_R1.PORTAL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 5, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("dust")) { + try { + Location newLoc = new Location(player.getWorld(), eyeLoc.getX(), eyeLoc.getY() + (float) 0.5, eyeLoc.getZ()); + Eff_1_9_R1.RED_DUST.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("witch")) { + try { + Eff_1_9_R1.WITCH_MAGIC.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("snowball")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_9_R1.SNOWBALL_POOF.sendToPlayer(player, newLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("splash")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_9_R1.SPLASH.sendToPlayer(player, newLoc, 0, 0, 0, 1, 4, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("smoke")) { + try { + Eff_1_9_R1.TOWN_AURA.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 20, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + try { + Eff_1_9_R1.valueOf(Quests.effect).sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + Quests.getInstance().getLogger().info(Quests.effect + " is not a valid effect name!"); + e.printStackTrace(); + } + } + } + + private static void showEffect_1_8_R3(Player player, NPC npc) { + // Get and set eye location, because npc.getBukkitEntity() is deprecated. + Location eyeLoc = npc.getEntity().getLocation(); + eyeLoc.setY(eyeLoc.getY() + 1.5); + if (Quests.effect.equalsIgnoreCase("enchant")) { + try { + Eff_1_8_R3.ENCHANTMENT_TABLE.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 10, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("crit")) { + try { + Eff_1_8_R3.CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("spell")) { + try { + Eff_1_8_R3.INSTANT_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("magiccrit")) { + try { + Eff_1_8_R3.MAGIC_CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("mobspell")) { + try { + Eff_1_8_R3.MOB_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("note")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_8_R3.NOTE.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("portal")) { + try { + Eff_1_8_R3.PORTAL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 5, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("dust")) { + try { + Location newLoc = new Location(player.getWorld(), eyeLoc.getX(), eyeLoc.getY() + (float) 0.5, eyeLoc.getZ()); + Eff_1_8_R3.RED_DUST.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("witch")) { + try { + Eff_1_8_R3.WITCH_MAGIC.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("snowball")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_8_R3.SNOWBALL_POOF.sendToPlayer(player, newLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("splash")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_8_R3.SPLASH.sendToPlayer(player, newLoc, 0, 0, 0, 1, 4, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("smoke")) { + try { + Eff_1_8_R3.TOWN_AURA.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 20, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + try { + Eff_1_8_R3.valueOf(Quests.effect).sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + Quests.getInstance().getLogger().info(Quests.effect + " is not a valid effect name!"); + e.printStackTrace(); + } + } + } + + private static void showEffect_1_8_R2(Player player, NPC npc) { + // Get and set eye location, because npc.getBukkitEntity() is deprecated. + Location eyeLoc = npc.getEntity().getLocation(); + eyeLoc.setY(eyeLoc.getY() + 1.5); + if (Quests.effect.equalsIgnoreCase("enchant")) { + try { + Eff_1_8_R2.ENCHANTMENT_TABLE.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 10, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("crit")) { + try { + Eff_1_8_R2.CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("spell")) { + try { + Eff_1_8_R2.INSTANT_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("magiccrit")) { + try { + Eff_1_8_R2.MAGIC_CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("mobspell")) { + try { + Eff_1_8_R2.MOB_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("note")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_8_R2.NOTE.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("portal")) { + try { + Eff_1_8_R2.PORTAL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 5, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("dust")) { + try { + Location newLoc = new Location(player.getWorld(), eyeLoc.getX(), eyeLoc.getY() + (float) 0.5, eyeLoc.getZ()); + Eff_1_8_R2.RED_DUST.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("witch")) { + try { + Eff_1_8_R2.WITCH_MAGIC.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("snowball")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_8_R2.SNOWBALL_POOF.sendToPlayer(player, newLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("splash")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_8_R2.SPLASH.sendToPlayer(player, newLoc, 0, 0, 0, 1, 4, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("smoke")) { + try { + Eff_1_8_R2.TOWN_AURA.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 20, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + try { + Eff_1_8_R2.valueOf(Quests.effect).sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + Quests.getInstance().getLogger().info(Quests.effect + " is not a valid effect name!"); + e.printStackTrace(); + } + } + } + + private static void showEffect_1_8_R1(Player player, NPC npc) { + // Get and set eye location, because npc.getBukkitEntity() is deprecated. + Location eyeLoc = npc.getEntity().getLocation(); + eyeLoc.setY(eyeLoc.getY() + 1.5); + if (Quests.effect.equalsIgnoreCase("enchant")) { + try { + Eff_1_8_R1.ENCHANTMENT_TABLE.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 10, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("crit")) { + try { + Eff_1_8_R1.CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("spell")) { + try { + Eff_1_8_R1.INSTANT_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("magiccrit")) { + try { + Eff_1_8_R1.MAGIC_CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("mobspell")) { + try { + Eff_1_8_R1.MOB_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("note")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_8_R1.NOTE.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("portal")) { + try { + Eff_1_8_R1.PORTAL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 5, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("dust")) { + try { + Location newLoc = new Location(player.getWorld(), eyeLoc.getX(), eyeLoc.getY() + (float) 0.5, eyeLoc.getZ()); + Eff_1_8_R1.RED_DUST.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("witch")) { + try { + Eff_1_8_R1.WITCH_MAGIC.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("snowball")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_8_R1.SNOWBALL_POOF.sendToPlayer(player, newLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("splash")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_8_R1.SPLASH.sendToPlayer(player, newLoc, 0, 0, 0, 1, 4, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("smoke")) { + try { + Eff_1_8_R1.TOWN_AURA.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 20, null); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + try { + Eff_1_8_R1.valueOf(Quests.effect).sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3, null); + } catch (Exception e) { + Quests.getInstance().getLogger().info(Quests.effect + " is not a valid effect name!"); + e.printStackTrace(); + } + } + } + + private static void showEffect_R4(Player player, NPC npc) { + // Get and set eye location, because npc.getBukkitEntity() is deprecated. + Location eyeLoc = npc.getEntity().getLocation(); + eyeLoc.setY(eyeLoc.getY() + 1.5); + if (Quests.effect.equalsIgnoreCase("enchant")) { + try { + Eff_1_7_R4.ENCHANTMENT_TABLE.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 10); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("crit")) { + try { + Eff_1_7_R4.CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("spell")) { + try { + Eff_1_7_R4.INSTANT_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("magiccrit")) { + try { + Eff_1_7_R4.MAGIC_CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("mobspell")) { + try { + Eff_1_7_R4.MOB_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("note")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_7_R4.NOTE.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("portal")) { + try { + Eff_1_7_R4.PORTAL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 5); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("dust")) { + try { + Location newLoc = new Location(player.getWorld(), eyeLoc.getX(), eyeLoc.getY() + (float) 0.5, eyeLoc.getZ()); + Eff_1_7_R4.RED_DUST.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("witch")) { + try { + Eff_1_7_R4.WITCH_MAGIC.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("snowball")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_7_R4.SNOWBALL_POOF.sendToPlayer(player, newLoc, 0, 0, 0, 1, 3); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("splash")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_7_R4.SPLASH.sendToPlayer(player, newLoc, 0, 0, 0, 1, 4); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("smoke")) { + try { + Eff_1_7_R4.TOWN_AURA.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 20); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + private static void showEffect_R3(Player player, NPC npc) { + // Get and set eye location, because npc.getBukkitEntity() is deprecated. + Location eyeLoc = npc.getEntity().getLocation(); + eyeLoc.setY(eyeLoc.getY() + 1.5); + if (Quests.effect.equalsIgnoreCase("enchant")) { + try { + Eff_1_7_R3.ENCHANTMENT_TABLE.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 10); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("crit")) { + try { + Eff_1_7_R3.CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("spell")) { + try { + Eff_1_7_R3.INSTANT_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("magiccrit")) { + try { + Eff_1_7_R3.MAGIC_CRIT.sendToPlayer(player, eyeLoc, 0, 0, 0, (float) 0.35, 3); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("mobspell")) { + try { + Eff_1_7_R3.MOB_SPELL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("note")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_7_R3.NOTE.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("portal")) { + try { + Eff_1_7_R3.PORTAL.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 5); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("dust")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_7_R3.RED_DUST.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("witch")) { + try { + Eff_1_7_R3.WITCH_MAGIC.sendToPlayer(player, eyeLoc, 0, 0, 0, 1, 3); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("snowball")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_7_R3.SNOWBALL_POOF.sendToPlayer(player, newLoc, 0, 0, 0, 1, 3); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("splash")) { + try { + Location old = eyeLoc; + Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float) 0.5, old.getZ()); + Eff_1_7_R3.SPLASH.sendToPlayer(player, newLoc, 0, 0, 0, 1, 4); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (Quests.effect.equalsIgnoreCase("smoke")) { + try { + Eff_1_7_R3.TOWN_AURA.sendToPlayer(player, eyeLoc, 0, 1, 0, 1, 20); + } catch (Exception e) { + e.printStackTrace(); + } + } + } } diff --git a/src/main/java/me/blackvein/quests/NpcListener.java b/src/main/java/me/blackvein/quests/NpcListener.java index 569212d9e..fb6352482 100644 --- a/src/main/java/me/blackvein/quests/NpcListener.java +++ b/src/main/java/me/blackvein/quests/NpcListener.java @@ -3,14 +3,6 @@ package me.blackvein.quests; import java.text.MessageFormat; import java.util.LinkedList; -import me.blackvein.quests.util.ItemUtil; -import me.blackvein.quests.util.Lang; -import net.citizensnpcs.api.CitizensAPI; -import net.citizensnpcs.api.event.NPCDeathEvent; -import net.citizensnpcs.api.event.NPCLeftClickEvent; -import net.citizensnpcs.api.event.NPCRightClickEvent; -import net.citizensnpcs.api.npc.NPC; - import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.conversations.Conversation; @@ -23,302 +15,208 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; +import me.blackvein.quests.util.ItemUtil; +import me.blackvein.quests.util.Lang; +import net.citizensnpcs.api.CitizensAPI; +import net.citizensnpcs.api.event.NPCDeathEvent; +import net.citizensnpcs.api.event.NPCLeftClickEvent; +import net.citizensnpcs.api.event.NPCRightClickEvent; +import net.citizensnpcs.api.npc.NPC; + public class NpcListener implements Listener { - final Quests plugin; + final Quests plugin; - public NpcListener(Quests newPlugin) { + public NpcListener(Quests newPlugin) { + plugin = newPlugin; + } - plugin = newPlugin; - - } - - @SuppressWarnings("deprecation") + @SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.LOWEST) - public void onNPCRightClick(NPCRightClickEvent evt) { - - if (plugin.questFactory.selectingNPCs.contains(evt.getClicker())) { - evt.getClicker().sendMessage(ChatColor.GREEN + evt.getNPC().getName() + ": " + ChatColor.DARK_GREEN + "ID " + evt.getNPC().getId()); - return; - } - - if (evt.getClicker().isConversing() == false) { - - final Player player = evt.getClicker(); - final Quester quester = plugin.getQuester(player.getUniqueId()); - boolean delivery = false; - - for (Quest quest : quester.currentQuests.keySet()) { - - if (quester.hasObjective(quest, "deliverItem") && player.getItemInHand() != null) { - - ItemStack hand = player.getItemInHand(); - - ItemStack found = null; - - for (ItemStack is : quester.getCurrentStage(quest).itemsToDeliver) { - - if (ItemUtil.compareItems(is, hand, true) == 0) { - found = is; - break; - } - - } - - NPC clicked = evt.getNPC(); - - if (found != null) { - - for (Integer n : quester.getCurrentStage(quest).itemDeliveryTargets) { - - if (n.equals(clicked.getId())) { - quester.deliverItem(quest, hand); - delivery = true; - break; - } - } - - break; - - } else if (!hand.getType().equals(Material.AIR)){ - - for (Integer n : quester.getCurrentStage(quest).itemDeliveryTargets) { - - if (n.equals(clicked.getId())) { - String text = ""; - - if (hand.hasItemMeta()) { - text += ChatColor.LIGHT_PURPLE + "" + ChatColor.ITALIC + (hand.getItemMeta().hasDisplayName() ? hand.getItemMeta().getDisplayName() + ChatColor.GRAY + " (" : ""); - } - - text += ChatColor.AQUA + Quester.prettyItemString(hand.getType().name()) + (hand.getDurability() != 0 ? (":" + ChatColor.BLUE + hand.getDurability()) : "") + ChatColor.GRAY; - - if (hand.hasItemMeta()) { - text += (hand.getItemMeta().hasDisplayName() ? ")" : ""); - } - - text += " x " + ChatColor.DARK_AQUA + hand.getAmount() + ChatColor.GRAY; - - evt.getClicker().sendMessage(Lang.get("questInvalidDeliveryItem").replaceAll("", text)); - break; - } - } - - //break; - - } - - } - - } - - if (plugin.questNPCs.contains(evt.getNPC()) && delivery == false) { - - if (plugin.checkQuester(player.getUniqueId()) == false) { - - boolean hasObjective = false; - - for (Quest quest : quester.currentQuests.keySet()) { - - if (quester.hasObjective(quest, "talkToNPC")) { - - if (quester.getQuestData(quest) != null && quester.getQuestData(quest).citizensInteracted.containsKey(evt.getNPC().getId()) && quester.getQuestData(quest).citizensInteracted.get(evt.getNPC().getId()) == false) { - hasObjective = true; - } - - quester.interactWithNPC(quest, evt.getNPC()); - - } - - } - - if (!hasObjective) { - - LinkedList npcQuests = new LinkedList(); - - for (Quest q : plugin.getQuests()) { - if(quester.currentQuests.containsKey(q)) - continue; - if (q.npcStart != null && q.npcStart.getId() == evt.getNPC().getId()) { - if (Quests.ignoreLockedQuests && (quester.completedQuests.contains(q.name) == false || q.redoDelay > -1)) { - if (q.testRequirements(quester)) { - npcQuests.add(q); - } - } else if (quester.completedQuests.contains(q.name) == false || q.redoDelay > -1) { - npcQuests.add(q); - } - } - - } - - if (npcQuests.isEmpty() == false && npcQuests.size() >= 1) { - - if (plugin.questNPCGUIs.contains(evt.getNPC().getId())) { - quester.showGUIDisplay(evt.getNPC(), npcQuests); - return; - } - - Conversation c = plugin.NPCConversationFactory.buildConversation(player); - c.getContext().setSessionData("quests", npcQuests); - c.getContext().setSessionData("npc", evt.getNPC().getName()); - c.begin(); - - } else if (npcQuests.size() == 1) { - - Quest q = npcQuests.get(0); - - if (!quester.completedQuests.contains(q.name)) { - - if (quester.currentQuests.size() < Quests.maxQuests || Quests.maxQuests < 1) { - - quester.questToTake = q.name; - - String s = extracted(quester); - - for (String msg : s.split("
")) { - player.sendMessage(msg); - } - - plugin.conversationFactory.buildConversation(player).begin(); - - } else if (quester.currentQuests.containsKey(q) == false) { - - String msg = Lang.get("questMaxAllowed"); - msg = msg.replaceAll("", String.valueOf(Quests.maxQuests)); - player.sendMessage(ChatColor.YELLOW + msg); - - } - - } else if (quester.currentQuests.size() < Quests.maxQuests || Quests.maxQuests < 1) { - - if (quester.getDifference(q) > 0) { - String early = Lang.get("questTooEarly"); - early = early.replaceAll("", ChatColor.AQUA + q.name + ChatColor.YELLOW); - early = early.replaceAll("