mirror of
https://github.com/PikaMug/Quests.git
synced 2024-12-24 18:18:20 +01:00
Merge pull request #6 from GregZ123/master
Reformatted code and added javadoc comments to particles enums.
This commit is contained in:
commit
740a0b1786
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
||||
|
||||
<groupId>me.blackvein.quests</groupId>
|
||||
<artifactId>quests</artifactId>
|
||||
<version>2.8.6</version>
|
||||
<version>2.8.6-03</version>
|
||||
<name>quests</name>
|
||||
<url>https://github.com/FlyingPikachu/Quests/</url>
|
||||
<packaging>jar</packaging>
|
||||
|
@ -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<Map<String, UUID>> {
|
||||
|
||||
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<String> 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<String> names;
|
||||
private final boolean rateLimiting;
|
||||
|
||||
public UUIDFetcher(List<String> names, boolean rateLimiting) {
|
||||
this.names = ImmutableList.copyOf(names);
|
||||
this.rateLimiting = rateLimiting;
|
||||
}
|
||||
public UUIDFetcher(List<String> names, boolean rateLimiting) {
|
||||
this.names = ImmutableList.copyOf(names);
|
||||
this.rateLimiting = rateLimiting;
|
||||
}
|
||||
|
||||
public UUIDFetcher(List<String> names) {
|
||||
this(names, true);
|
||||
}
|
||||
public UUIDFetcher(List<String> names) {
|
||||
this(names, true);
|
||||
}
|
||||
|
||||
public Map<String, UUID> call() throws Exception {
|
||||
Map<String, UUID> uuidMap = new HashMap<String, UUID>();
|
||||
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<String, UUID> call() throws Exception {
|
||||
Map<String, UUID> uuidMap = new HashMap<String, UUID>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -7,48 +7,56 @@ import org.bukkit.entity.Player;
|
||||
import net.minecraft.server.v1_10_R1.EnumParticle;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayOutWorldParticles;
|
||||
|
||||
/**
|
||||
* This is the Eff_1_10_R1 Enum, it contains all valid effects that players can
|
||||
* use with the 1.10 server version.
|
||||
*
|
||||
* @author FlyingPikachu
|
||||
* @author GregZ_
|
||||
* @since 2.6.2
|
||||
* @version 3
|
||||
*/
|
||||
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 +65,53 @@ public enum Eff_1_10_R1 {
|
||||
ENDROD(EnumParticle.END_ROD),
|
||||
DAMAGE_INDICATOR(EnumParticle.DAMAGE_INDICATOR),
|
||||
FALLING_DUST(EnumParticle.FALLING_DUST);
|
||||
|
||||
|
||||
private final EnumParticle particleEnum;
|
||||
/**
|
||||
* The NMS EnumParticle to be sent to the player.
|
||||
*/
|
||||
private final EnumParticle particleEnum;
|
||||
|
||||
Eff_1_10_R1(EnumParticle particleEnum) {
|
||||
this.particleEnum = particleEnum;
|
||||
}
|
||||
/**
|
||||
* Create a new instance of the Eff_1_10_R1 enum with the given particle type
|
||||
* to be sent.
|
||||
*
|
||||
* @param particleEnum
|
||||
* The particle type to be sent to the player in the
|
||||
* PacketPlayOutWorldParticles packet.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given particle to the player via NMS. It should be noted that
|
||||
* all particles have the range limit set to 256 due to the second variable
|
||||
* in the packet constructor being false.
|
||||
*
|
||||
* @param player
|
||||
* The player to send the particle to.
|
||||
* @param location
|
||||
* The location to play the particle at.
|
||||
* @param offsetX
|
||||
* The offset of the particle in the X direction.
|
||||
* @param offsetY
|
||||
* The offset of the particle in the Y direction.
|
||||
* @param offsetZ
|
||||
* The offset of the particle in the Z direction.
|
||||
* @param speed
|
||||
* The speed that the particle effect will be played at.
|
||||
* @param count
|
||||
* The number of particles to send to the player.
|
||||
* @param data
|
||||
* An integer array needed for some particles, this is used for
|
||||
* packets such as block crack or particle colour on redstone /
|
||||
* firework particles.
|
||||
* @throws Exception
|
||||
* A ReportedException may be thrown if the network manager
|
||||
* fails to handle the 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);
|
||||
}
|
||||
}
|
@ -7,48 +7,56 @@ import org.bukkit.entity.Player;
|
||||
import net.minecraft.server.v1_11_R1.EnumParticle;
|
||||
import net.minecraft.server.v1_11_R1.PacketPlayOutWorldParticles;
|
||||
|
||||
/**
|
||||
* This is the Eff_1_11_R1 Enum, it contains all valid effects that players can
|
||||
* use with the 1.11 server version.
|
||||
*
|
||||
* @author FlyingPikachu
|
||||
* @author GregZ_
|
||||
* @since 2.7.4
|
||||
* @version 3
|
||||
*/
|
||||
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 +67,53 @@ public enum Eff_1_11_R1 {
|
||||
FALLING_DUST(EnumParticle.FALLING_DUST),
|
||||
SPIT(EnumParticle.SPIT),
|
||||
TOTEM(EnumParticle.TOTEM);
|
||||
|
||||
|
||||
private final EnumParticle particleEnum;
|
||||
/**
|
||||
* The NMS EnumParticle to be sent to the player.
|
||||
*/
|
||||
private final EnumParticle particleEnum;
|
||||
|
||||
Eff_1_11_R1(EnumParticle particleEnum) {
|
||||
this.particleEnum = particleEnum;
|
||||
}
|
||||
/**
|
||||
* Create a new instance of the Eff_1_11_R1 enum with the given particle type
|
||||
* to be sent.
|
||||
*
|
||||
* @param particleEnum
|
||||
* The particle type to be sent to the player in the
|
||||
* PacketPlayOutWorldParticles packet.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given particle to the player via NMS. It should be noted that
|
||||
* all particles have the range limit set to 256 due to the second variable
|
||||
* in the packet constructor being false.
|
||||
*
|
||||
* @param player
|
||||
* The player to send the particle to.
|
||||
* @param location
|
||||
* The location to play the particle at.
|
||||
* @param offsetX
|
||||
* The offset of the particle in the X direction.
|
||||
* @param offsetY
|
||||
* The offset of the particle in the Y direction.
|
||||
* @param offsetZ
|
||||
* The offset of the particle in the Z direction.
|
||||
* @param speed
|
||||
* The speed that the particle effect will be played at.
|
||||
* @param count
|
||||
* The number of particles to send to the player.
|
||||
* @param data
|
||||
* An integer array needed for some particles, this is used for
|
||||
* packets such as block crack or particle colour on redstone /
|
||||
* firework particles.
|
||||
* @throws Exception
|
||||
* A ReportedException may be thrown if the network manager
|
||||
* fails to handle the 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);
|
||||
}
|
||||
}
|
@ -7,48 +7,56 @@ import org.bukkit.entity.Player;
|
||||
import net.minecraft.server.v1_12_R1.EnumParticle;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayOutWorldParticles;
|
||||
|
||||
/**
|
||||
* This is the Eff_1_12_R1 Enum, it contains all valid effects that players can
|
||||
* use with the 1.12 server version.
|
||||
*
|
||||
* @author FlyingPikachu
|
||||
* @author GregZ_
|
||||
* @since 2.8.0
|
||||
* @version 3
|
||||
*/
|
||||
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 +67,53 @@ public enum Eff_1_12_R1 {
|
||||
FALLING_DUST(EnumParticle.FALLING_DUST),
|
||||
SPIT(EnumParticle.SPIT),
|
||||
TOTEM(EnumParticle.TOTEM);
|
||||
|
||||
|
||||
private final EnumParticle particleEnum;
|
||||
/**
|
||||
* The NMS EnumParticle to be sent to the player.
|
||||
*/
|
||||
private final EnumParticle particleEnum;
|
||||
|
||||
Eff_1_12_R1(EnumParticle particleEnum) {
|
||||
this.particleEnum = particleEnum;
|
||||
}
|
||||
/**
|
||||
* Create a new instance of the Eff_1_12_R1 enum with the given particle type
|
||||
* to be sent.
|
||||
*
|
||||
* @param particleEnum
|
||||
* The particle type to be sent to the player in the
|
||||
* PacketPlayOutWorldParticles packet.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given particle to the player via NMS. It should be noted that
|
||||
* all particles have the range limit set to 256 due to the second variable
|
||||
* in the packet constructor being false.
|
||||
*
|
||||
* @param player
|
||||
* The player to send the particle to.
|
||||
* @param location
|
||||
* The location to play the particle at.
|
||||
* @param offsetX
|
||||
* The offset of the particle in the X direction.
|
||||
* @param offsetY
|
||||
* The offset of the particle in the Y direction.
|
||||
* @param offsetZ
|
||||
* The offset of the particle in the Z direction.
|
||||
* @param speed
|
||||
* The speed that the particle effect will be played at.
|
||||
* @param count
|
||||
* The number of particles to send to the player.
|
||||
* @param data
|
||||
* An integer array needed for some particles, this is used for
|
||||
* packets such as block crack or particle colour on redstone /
|
||||
* firework particles.
|
||||
* @throws Exception
|
||||
* A ReportedException may be thrown if the network manager
|
||||
* fails to handle the 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);
|
||||
}
|
||||
}
|
@ -6,61 +6,93 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import net.minecraft.server.v1_7_R3.PacketPlayOutWorldParticles;
|
||||
|
||||
/**
|
||||
* This is the Eff_1_7_R3 Enum, it contains all valid effects that players can
|
||||
* use with the 1.7.9 server version.
|
||||
*
|
||||
* @author Blackvein
|
||||
* @author GregZ_
|
||||
* @since 1.9.0
|
||||
* @version 3
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* The name of the particle to be sent.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
/**
|
||||
* Create a new instance of the Eff_1_7_R3 enum with the given particle name
|
||||
* to be sent.
|
||||
*
|
||||
* @param particleName
|
||||
* The name of the particle to be sent to the player in the
|
||||
* PacketPlayOutWorldParticles packet.
|
||||
*/
|
||||
Eff_1_7_R3(String particleName) {
|
||||
this.particleName = particleName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given particle to the player via NMS.
|
||||
*
|
||||
* @param player
|
||||
* The player to send the particle to.
|
||||
* @param location
|
||||
* The location to play the particle at.
|
||||
* @param offsetX
|
||||
* The offset of the particle in the X direction.
|
||||
* @param offsetY
|
||||
* The offset of the particle in the Y direction.
|
||||
* @param offsetZ
|
||||
* The offset of the particle in the Z direction.
|
||||
* @param speed
|
||||
* The speed that the particle effect will be played at.
|
||||
* @param count
|
||||
* The number of particles to send to the player.
|
||||
* @throws Exception
|
||||
* A ReportedException may be thrown if the network manager
|
||||
* fails to handle the packet.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -6,61 +6,93 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutWorldParticles;
|
||||
|
||||
/**
|
||||
* This is the Eff_1_7_R4 Enum, it contains all valid effects that players can
|
||||
* use with the 1.7.10 server version.
|
||||
*
|
||||
* @author Blackvein
|
||||
* @author GregZ_
|
||||
* @since 1.9.0
|
||||
* @version 3
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* The name of the particle to be sent.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
/**
|
||||
* Create a new instance of the Eff_1_7_R4 enum with the given particle name
|
||||
* to be sent.
|
||||
*
|
||||
* @param particleName
|
||||
* The name of the particle to be sent to the player in the
|
||||
* PacketPlayOutWorldParticles packet.
|
||||
*/
|
||||
Eff_1_7_R4(String particleName) {
|
||||
this.particleName = particleName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given particle to the player via NMS.
|
||||
*
|
||||
* @param player
|
||||
* The player to send the particle to.
|
||||
* @param location
|
||||
* The location to play the particle at.
|
||||
* @param offsetX
|
||||
* The offset of the particle in the X direction.
|
||||
* @param offsetY
|
||||
* The offset of the particle in the Y direction.
|
||||
* @param offsetZ
|
||||
* The offset of the particle in the Z direction.
|
||||
* @param speed
|
||||
* The speed that the particle effect will be played at.
|
||||
* @param count
|
||||
* The number of particles to send to the player.
|
||||
* @throws Exception
|
||||
* A ReportedException may be thrown if the network manager
|
||||
* fails to handle the packet.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -7,70 +7,106 @@ import org.bukkit.entity.Player;
|
||||
import net.minecraft.server.v1_8_R1.EnumParticle;
|
||||
import net.minecraft.server.v1_8_R1.PacketPlayOutWorldParticles;
|
||||
|
||||
/**
|
||||
* This is the Eff_1_8_R1 Enum, it contains all valid effects that players can
|
||||
* use with the 1.8 server version.
|
||||
*
|
||||
* @author FlyingPikachu
|
||||
* @author GregZ_
|
||||
* @since 2.0.0
|
||||
* @version 3
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* The NMS EnumParticle to be sent to the player.
|
||||
*/
|
||||
private final EnumParticle particleEnum;
|
||||
|
||||
Eff_1_8_R1(EnumParticle particleEnum) {
|
||||
this.particleEnum = particleEnum;
|
||||
}
|
||||
/**
|
||||
* Create a new instance of the Eff_1_8_R1 enum with the given particle type
|
||||
* to be sent.
|
||||
*
|
||||
* @param particleEnum
|
||||
* The particle type to be sent to the player in the
|
||||
* PacketPlayOutWorldParticles packet.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given particle to the player via NMS. It should be noted that
|
||||
* all particles have the range limit set to 256 due to the second variable
|
||||
* in the packet constructor being false.
|
||||
*
|
||||
* @param player
|
||||
* The player to send the particle to.
|
||||
* @param location
|
||||
* The location to play the particle at.
|
||||
* @param offsetX
|
||||
* The offset of the particle in the X direction.
|
||||
* @param offsetY
|
||||
* The offset of the particle in the Y direction.
|
||||
* @param offsetZ
|
||||
* The offset of the particle in the Z direction.
|
||||
* @param speed
|
||||
* The speed that the particle effect will be played at.
|
||||
* @param count
|
||||
* The number of particles to send to the player.
|
||||
* @param data
|
||||
* An integer array needed for some particles, this is used for
|
||||
* packets such as block crack or particle colour on redstone /
|
||||
* firework particles.
|
||||
* @throws Exception
|
||||
* A ReportedException may be thrown if the network manager
|
||||
* fails to handle the 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);
|
||||
}
|
||||
}
|
||||
|
@ -7,70 +7,106 @@ import org.bukkit.entity.Player;
|
||||
import net.minecraft.server.v1_8_R2.EnumParticle;
|
||||
import net.minecraft.server.v1_8_R2.PacketPlayOutWorldParticles;
|
||||
|
||||
/**
|
||||
* This is the Eff_1_8_R2 Enum, it contains all valid effects that players can
|
||||
* use with the 1.8.3 server version.
|
||||
*
|
||||
* @author FlyingPikachu
|
||||
* @author GregZ_
|
||||
* @since 2.3.1
|
||||
* @version 3
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* The NMS EnumParticle to be sent to the player.
|
||||
*/
|
||||
private final EnumParticle particleEnum;
|
||||
|
||||
Eff_1_8_R2(EnumParticle particleEnum) {
|
||||
this.particleEnum = particleEnum;
|
||||
}
|
||||
/**
|
||||
* Create a new instance of the Eff_1_8_R1 enum with the given particle type
|
||||
* to be sent.
|
||||
*
|
||||
* @param particleEnum
|
||||
* The particle type to be sent to the player in the
|
||||
* PacketPlayOutWorldParticles packet.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given particle to the player via NMS. It should be noted that
|
||||
* all particles have the range limit set to 256 due to the second variable
|
||||
* in the packet constructor being false.
|
||||
*
|
||||
* @param player
|
||||
* The player to send the particle to.
|
||||
* @param location
|
||||
* The location to play the particle at.
|
||||
* @param offsetX
|
||||
* The offset of the particle in the X direction.
|
||||
* @param offsetY
|
||||
* The offset of the particle in the Y direction.
|
||||
* @param offsetZ
|
||||
* The offset of the particle in the Z direction.
|
||||
* @param speed
|
||||
* The speed that the particle effect will be played at.
|
||||
* @param count
|
||||
* The number of particles to send to the player.
|
||||
* @param data
|
||||
* An integer array needed for some particles, this is used for
|
||||
* packets such as block crack or particle colour on redstone /
|
||||
* firework particles.
|
||||
* @throws Exception
|
||||
* A ReportedException may be thrown if the network manager
|
||||
* fails to handle the 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);
|
||||
}
|
||||
}
|
||||
|
@ -7,70 +7,106 @@ import org.bukkit.entity.Player;
|
||||
import net.minecraft.server.v1_8_R3.EnumParticle;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldParticles;
|
||||
|
||||
/**
|
||||
* This is the Eff_1_8_R3 Enum, it contains all valid effects that players can
|
||||
* use with the 1.8.4 - 1.8.8 server versions.
|
||||
*
|
||||
* @author FlyingPikachu
|
||||
* @author GregZ_
|
||||
* @since 2.5.0
|
||||
* @version 4
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* The NMS EnumParticle to be sent to the player.
|
||||
*/
|
||||
private final EnumParticle particleEnum;
|
||||
|
||||
Eff_1_8_R3(EnumParticle particleEnum) {
|
||||
this.particleEnum = particleEnum;
|
||||
}
|
||||
/**
|
||||
* Create a new instance of the Eff_1_8_R3 enum with the given particle type
|
||||
* to be sent.
|
||||
*
|
||||
* @param particleEnum
|
||||
* The particle type to be sent to the player in the
|
||||
* PacketPlayOutWorldParticles packet.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given particle to the player via NMS. It should be noted that
|
||||
* all particles have the range limit set to 256 due to the second variable
|
||||
* in the packet constructor being false.
|
||||
*
|
||||
* @param player
|
||||
* The player to send the particle to.
|
||||
* @param location
|
||||
* The location to play the particle at.
|
||||
* @param offsetX
|
||||
* The offset of the particle in the X direction.
|
||||
* @param offsetY
|
||||
* The offset of the particle in the Y direction.
|
||||
* @param offsetZ
|
||||
* The offset of the particle in the Z direction.
|
||||
* @param speed
|
||||
* The speed that the particle effect will be played at.
|
||||
* @param count
|
||||
* The number of particles to send to the player.
|
||||
* @param data
|
||||
* An integer array needed for some particles, this is used for
|
||||
* packets such as block crack or particle colour on redstone /
|
||||
* firework particles.
|
||||
* @throws Exception
|
||||
* A ReportedException may be thrown if the network manager
|
||||
* fails to handle the 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);
|
||||
}
|
||||
}
|
@ -7,47 +7,57 @@ import org.bukkit.entity.Player;
|
||||
import net.minecraft.server.v1_9_R1.EnumParticle;
|
||||
import net.minecraft.server.v1_9_R1.PacketPlayOutWorldParticles;
|
||||
|
||||
/**
|
||||
* This is the Eff_1_9_R1 Enum, it contains all valid effects that players can
|
||||
* use with the 1.9 server version.
|
||||
*
|
||||
* @author FlyingPikachu
|
||||
* @author woutwoot
|
||||
* @author GregZ_
|
||||
* @since 2.6.0
|
||||
* @version 5
|
||||
*/
|
||||
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 +66,52 @@ public enum Eff_1_9_R1 {
|
||||
ENDROD(EnumParticle.END_ROD),
|
||||
DAMAGE_INDICATOR(EnumParticle.DAMAGE_INDICATOR),;
|
||||
|
||||
private final EnumParticle particleEnum;
|
||||
/**
|
||||
* The NMS EnumParticle to be sent to the player.
|
||||
*/
|
||||
private final EnumParticle particleEnum;
|
||||
|
||||
Eff_1_9_R1(EnumParticle particleEnum) {
|
||||
this.particleEnum = particleEnum;
|
||||
}
|
||||
/**
|
||||
* Create a new instance of the Eff_1_9_R1 enum with the given particle type
|
||||
* to be sent.
|
||||
*
|
||||
* @param particleEnum
|
||||
* The particle type to be sent to the player in the
|
||||
* PacketPlayOutWorldParticles packet.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given particle to the player via NMS. It should be noted that
|
||||
* all particles have the range limit set to 256 due to the second variable
|
||||
* in the packet constructor being false.
|
||||
*
|
||||
* @param player
|
||||
* The player to send the particle to.
|
||||
* @param location
|
||||
* The location to play the particle at.
|
||||
* @param offsetX
|
||||
* The offset of the particle in the X direction.
|
||||
* @param offsetY
|
||||
* The offset of the particle in the Y direction.
|
||||
* @param offsetZ
|
||||
* The offset of the particle in the Z direction.
|
||||
* @param speed
|
||||
* The speed that the particle effect will be played at.
|
||||
* @param count
|
||||
* The number of particles to send to the player.
|
||||
* @param data
|
||||
* An integer array needed for some particles, this is used for
|
||||
* packets such as block crack or particle colour on redstone /
|
||||
* firework particles.
|
||||
* @throws Exception
|
||||
* A ReportedException may be thrown if the network manager
|
||||
* fails to handle the 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);
|
||||
}
|
||||
}
|
@ -7,47 +7,56 @@ import org.bukkit.entity.Player;
|
||||
import net.minecraft.server.v1_9_R2.EnumParticle;
|
||||
import net.minecraft.server.v1_9_R2.PacketPlayOutWorldParticles;
|
||||
|
||||
/**
|
||||
* This is the Eff_1_9_R2 Enum, it contains all valid effects that players can
|
||||
* use with the 1.9.4 server version.
|
||||
*
|
||||
* @author FlyingPikachu
|
||||
* @author GregZ_
|
||||
* @since 2.6.1
|
||||
* @version 4
|
||||
*/
|
||||
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 +65,52 @@ public enum Eff_1_9_R2 {
|
||||
ENDROD(EnumParticle.END_ROD),
|
||||
DAMAGE_INDICATOR(EnumParticle.DAMAGE_INDICATOR),;
|
||||
|
||||
private final EnumParticle particleEnum;
|
||||
/**
|
||||
* The NMS EnumParticle to be sent to the player.
|
||||
*/
|
||||
private final EnumParticle particleEnum;
|
||||
|
||||
Eff_1_9_R2(EnumParticle particleEnum) {
|
||||
this.particleEnum = particleEnum;
|
||||
}
|
||||
/**
|
||||
* Create a new instance of the Eff_1_9_R2 enum with the given particle type
|
||||
* to be sent.
|
||||
*
|
||||
* @param particleEnum
|
||||
* The particle type to be sent to the player in the
|
||||
* PacketPlayOutWorldParticles packet.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given particle to the player via NMS. It should be noted that
|
||||
* all particles have the range limit set to 256 due to the second variable
|
||||
* in the packet constructor being false.
|
||||
*
|
||||
* @param player
|
||||
* The player to send the particle to.
|
||||
* @param location
|
||||
* The location to play the particle at.
|
||||
* @param offsetX
|
||||
* The offset of the particle in the X direction.
|
||||
* @param offsetY
|
||||
* The offset of the particle in the Y direction.
|
||||
* @param offsetZ
|
||||
* The offset of the particle in the Z direction.
|
||||
* @param speed
|
||||
* The speed that the particle effect will be played at.
|
||||
* @param count
|
||||
* The number of particles to send to the player.
|
||||
* @param data
|
||||
* An integer array needed for some particles, this is used for
|
||||
* packets such as block crack or particle colour on redstone /
|
||||
* firework particles.
|
||||
* @throws Exception
|
||||
* A ReportedException may be thrown if the network manager
|
||||
* fails to handle the 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);
|
||||
}
|
||||
}
|
@ -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<String, Object> datamap = new HashMap<String, Object>();
|
||||
public final Map<String, String> descriptions = new HashMap<String, String>();
|
||||
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<String, Object> datamap = new HashMap<String, Object>();
|
||||
public final Map<String, String> descriptions = new HashMap<String, String>();
|
||||
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<String, Object> getDatamap(Player player, CustomObjective obj, Quest quest) {
|
||||
public static Map<String, Object> 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;
|
||||
}
|
||||
}
|
@ -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<String, Object> datamap = new HashMap<String, Object>();
|
||||
public final Map<String, String> descriptions = new HashMap<String, String>();
|
||||
private String name = null;
|
||||
private String author = null;
|
||||
public final Map<String, Object> datamap = new HashMap<String, Object>();
|
||||
public final Map<String, String> descriptions = new HashMap<String, String>();
|
||||
|
||||
public abstract boolean testRequirement(Player p, Map<String, Object> m);
|
||||
public abstract boolean testRequirement(Player p, Map<String, Object> 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);
|
||||
}
|
||||
}
|
||||
|
@ -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<String, Object> datamap = new HashMap<String, Object>();
|
||||
public final Map<String, String> descriptions = new HashMap<String, String>();
|
||||
private String name = null;
|
||||
private String author = null;
|
||||
private String rewardName = null;
|
||||
public final Map<String, Object> datamap = new HashMap<String, Object>();
|
||||
public final Map<String, String> descriptions = new HashMap<String, String>();
|
||||
|
||||
public abstract void giveReward(Player p, Map<String, Object> m);
|
||||
public abstract void giveReward(Player p, Map<String, Object> 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;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -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("<item>", 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<Quest> npcQuests = new LinkedList<Quest>();
|
||||
|
||||
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("<br>")) {
|
||||
player.sendMessage(msg);
|
||||
}
|
||||
|
||||
plugin.conversationFactory.buildConversation(player).begin();
|
||||
|
||||
} else if (quester.currentQuests.containsKey(q) == false) {
|
||||
|
||||
String msg = Lang.get("questMaxAllowed");
|
||||
msg = msg.replaceAll("<number>", 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("<quest>", ChatColor.AQUA + q.name + ChatColor.YELLOW);
|
||||
early = early.replaceAll("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(q)) + ChatColor.YELLOW);
|
||||
player.sendMessage(ChatColor.YELLOW + early);
|
||||
} else if (q.redoDelay < 0) {
|
||||
String completed = Lang.get("questAlreadyCompleted");
|
||||
completed = completed.replaceAll("<quest>", ChatColor.AQUA + q.name + ChatColor.YELLOW);
|
||||
player.sendMessage(ChatColor.YELLOW + completed);
|
||||
} else {
|
||||
quester.questToTake = q.name;
|
||||
String s = extracted(quester);
|
||||
|
||||
for (String msg : s.split("<br>")) {
|
||||
player.sendMessage(msg);
|
||||
}
|
||||
|
||||
plugin.conversationFactory.buildConversation(player).begin();
|
||||
}
|
||||
|
||||
} else if (quester.currentQuests.containsKey(q) == false) {
|
||||
|
||||
String msg = Lang.get("questMaxAllowed");
|
||||
msg = msg.replaceAll("<number>", String.valueOf(Quests.maxQuests));
|
||||
player.sendMessage(ChatColor.YELLOW + msg);
|
||||
|
||||
}
|
||||
|
||||
} else if (npcQuests.isEmpty()) {
|
||||
|
||||
evt.getClicker().sendMessage(ChatColor.YELLOW + Lang.get("noMoreQuest"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onNPCLeftClick(NPCLeftClickEvent evt) {
|
||||
|
||||
if (plugin.questFactory.selectingNPCs.contains(evt.getClicker())) {
|
||||
evt.getClicker().sendMessage(ChatColor.GREEN + evt.getNPC().getName() + ": " + ChatColor.DARK_GREEN + Lang.get("id") + " " + evt.getNPC().getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onNPCDeath(NPCDeathEvent evt) {
|
||||
|
||||
if (evt.getNPC().getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
|
||||
|
||||
EntityDamageByEntityEvent damageEvent = (EntityDamageByEntityEvent) evt.getNPC().getEntity().getLastDamageCause();
|
||||
Entity damager = damageEvent.getDamager();
|
||||
|
||||
if (damager != null) {
|
||||
|
||||
if (damager instanceof Projectile) {
|
||||
|
||||
if (evt.getNPC().getEntity().getLastDamageCause().getEntity() instanceof Player) {
|
||||
|
||||
Player player = (Player) evt.getNPC().getEntity().getLastDamageCause().getEntity();
|
||||
boolean okay = true;
|
||||
|
||||
if (plugin.citizens != null) {
|
||||
if (CitizensAPI.getNPCRegistry().isNPC(player)) {
|
||||
okay = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (okay) {
|
||||
|
||||
Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
|
||||
for (Quest quest : quester.currentQuests.keySet()) {
|
||||
|
||||
if (quester.hasObjective(quest, "killNPC")) {
|
||||
quester.killNPC(quest, evt.getNPC());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} else if (damager instanceof Player) {
|
||||
|
||||
boolean okay = true;
|
||||
|
||||
if (plugin.citizens != null) {
|
||||
if (plugin.citizens.getNPCRegistry().isNPC(damager)) {
|
||||
okay = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (okay) {
|
||||
|
||||
Player player = (Player) damager;
|
||||
Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
for (Quest quest : quester.currentQuests.keySet()) {
|
||||
|
||||
if (quester.hasObjective(quest, "killNPC")) {
|
||||
quester.killNPC(quest, evt.getNPC());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String extracted(final Quester quester) {
|
||||
return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n",
|
||||
ChatColor.GOLD,
|
||||
ChatColor.DARK_PURPLE,
|
||||
quester.questToTake,
|
||||
ChatColor.GOLD,
|
||||
ChatColor.RESET, plugin.getQuest(quester.questToTake).description);
|
||||
}
|
||||
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("<item>", 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<Quest> npcQuests = new LinkedList<Quest>();
|
||||
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("<br>")) {
|
||||
player.sendMessage(msg);
|
||||
}
|
||||
plugin.conversationFactory.buildConversation(player).begin();
|
||||
} else if (quester.currentQuests.containsKey(q) == false) {
|
||||
String msg = Lang.get("questMaxAllowed");
|
||||
msg = msg.replaceAll("<number>", 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("<quest>", ChatColor.AQUA + q.name + ChatColor.YELLOW);
|
||||
early = early.replaceAll("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(q)) + ChatColor.YELLOW);
|
||||
player.sendMessage(ChatColor.YELLOW + early);
|
||||
} else if (q.redoDelay < 0) {
|
||||
String completed = Lang.get("questAlreadyCompleted");
|
||||
completed = completed.replaceAll("<quest>", ChatColor.AQUA + q.name + ChatColor.YELLOW);
|
||||
player.sendMessage(ChatColor.YELLOW + completed);
|
||||
} else {
|
||||
quester.questToTake = q.name;
|
||||
String s = extracted(quester);
|
||||
for (String msg : s.split("<br>")) {
|
||||
player.sendMessage(msg);
|
||||
}
|
||||
plugin.conversationFactory.buildConversation(player).begin();
|
||||
}
|
||||
} else if (quester.currentQuests.containsKey(q) == false) {
|
||||
String msg = Lang.get("questMaxAllowed");
|
||||
msg = msg.replaceAll("<number>", String.valueOf(Quests.maxQuests));
|
||||
player.sendMessage(ChatColor.YELLOW + msg);
|
||||
}
|
||||
} else if (npcQuests.isEmpty()) {
|
||||
evt.getClicker().sendMessage(ChatColor.YELLOW + Lang.get("noMoreQuest"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onNPCLeftClick(NPCLeftClickEvent evt) {
|
||||
if (plugin.questFactory.selectingNPCs.contains(evt.getClicker())) {
|
||||
evt.getClicker().sendMessage(ChatColor.GREEN + evt.getNPC().getName() + ": " + ChatColor.DARK_GREEN + Lang.get("id") + " " + evt.getNPC().getId());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onNPCDeath(NPCDeathEvent evt) {
|
||||
if (evt.getNPC().getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
|
||||
EntityDamageByEntityEvent damageEvent = (EntityDamageByEntityEvent) evt.getNPC().getEntity().getLastDamageCause();
|
||||
Entity damager = damageEvent.getDamager();
|
||||
if (damager != null) {
|
||||
if (damager instanceof Projectile) {
|
||||
if (evt.getNPC().getEntity().getLastDamageCause().getEntity() instanceof Player) {
|
||||
Player player = (Player) evt.getNPC().getEntity().getLastDamageCause().getEntity();
|
||||
boolean okay = true;
|
||||
if (plugin.citizens != null) {
|
||||
if (CitizensAPI.getNPCRegistry().isNPC(player)) {
|
||||
okay = false;
|
||||
}
|
||||
}
|
||||
if (okay) {
|
||||
Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
for (Quest quest : quester.currentQuests.keySet()) {
|
||||
if (quester.hasObjective(quest, "killNPC")) {
|
||||
quester.killNPC(quest, evt.getNPC());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (damager instanceof Player) {
|
||||
boolean okay = true;
|
||||
if (plugin.citizens != null) {
|
||||
if (plugin.citizens.getNPCRegistry().isNPC(damager)) {
|
||||
okay = false;
|
||||
}
|
||||
}
|
||||
if (okay) {
|
||||
Player player = (Player) damager;
|
||||
Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
for (Quest quest : quester.currentQuests.keySet()) {
|
||||
if (quester.hasObjective(quest, "killNPC")) {
|
||||
quester.killNPC(quest, evt.getNPC());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String extracted(final Quester quester) {
|
||||
return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE, quester.questToTake, ChatColor.GOLD, ChatColor.RESET, plugin.getQuest(quester.questToTake).description);
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,20 +1,21 @@
|
||||
package me.blackvein.quests;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.aufdemrand.denizen.BukkitScriptEntryData;
|
||||
import net.aufdemrand.denizen.objects.dPlayer;
|
||||
import net.aufdemrand.denizencore.scripts.ScriptRegistry;
|
||||
import net.aufdemrand.denizencore.scripts.containers.core.TaskScriptContainer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class QuestTaskTrigger {
|
||||
|
||||
public boolean parseQuestTaskTrigger(String theScriptName, Player player) {
|
||||
if (!ScriptRegistry.containsScript(theScriptName)) {
|
||||
return false;
|
||||
}
|
||||
TaskScriptContainer task_script = ScriptRegistry.getScriptContainerAs(theScriptName, TaskScriptContainer.class);
|
||||
BukkitScriptEntryData entryData = new BukkitScriptEntryData(dPlayer.mirrorBukkitPlayer(player), null);
|
||||
task_script.runTaskScript(entryData, null);
|
||||
return true;
|
||||
}
|
||||
public boolean parseQuestTaskTrigger(String theScriptName, Player player) {
|
||||
if (!ScriptRegistry.containsScript(theScriptName)) {
|
||||
return false;
|
||||
}
|
||||
TaskScriptContainer task_script = ScriptRegistry.getScriptContainerAs(theScriptName, TaskScriptContainer.class);
|
||||
BukkitScriptEntryData entryData = new BukkitScriptEntryData(dPlayer.mirrorBukkitPlayer(player), null);
|
||||
task_script.runTaskScript(entryData, null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -16,371 +16,296 @@ import org.bukkit.inventory.ItemStack;
|
||||
public class Stage {
|
||||
|
||||
LinkedList<ItemStack> blocksToDamage = new LinkedList<ItemStack>();
|
||||
LinkedList<ItemStack> blocksToBreak = new LinkedList<ItemStack>();
|
||||
LinkedList<ItemStack> blocksToPlace = new LinkedList<ItemStack>();
|
||||
LinkedList<ItemStack> blocksToUse = new LinkedList<ItemStack>();
|
||||
LinkedList<ItemStack> blocksToCut = new LinkedList<ItemStack>();
|
||||
Integer fishToCatch;
|
||||
Integer playersToKill;
|
||||
Map<Map<Enchantment, Material>, Integer> itemsToEnchant = new HashMap<Map<Enchantment, Material>, Integer>();
|
||||
|
||||
LinkedList<EntityType> mobsToKill = new LinkedList<EntityType>();
|
||||
LinkedList<Integer> mobNumToKill = new LinkedList<Integer>();
|
||||
LinkedList<Location> locationsToKillWithin = new LinkedList<Location>();
|
||||
LinkedList<Integer> radiiToKillWithin = new LinkedList<Integer>();
|
||||
LinkedList<String> areaNames = new LinkedList<String>();
|
||||
|
||||
LinkedList<ItemStack> itemsToDeliver = new LinkedList<ItemStack>();
|
||||
LinkedList<Integer> itemDeliveryTargets = new LinkedList<Integer>() {
|
||||
LinkedList<ItemStack> blocksToBreak = new LinkedList<ItemStack>();
|
||||
LinkedList<ItemStack> blocksToPlace = new LinkedList<ItemStack>();
|
||||
LinkedList<ItemStack> blocksToUse = new LinkedList<ItemStack>();
|
||||
LinkedList<ItemStack> blocksToCut = new LinkedList<ItemStack>();
|
||||
Integer fishToCatch;
|
||||
Integer playersToKill;
|
||||
Map<Map<Enchantment, Material>, Integer> itemsToEnchant = new HashMap<Map<Enchantment, Material>, Integer>();
|
||||
LinkedList<EntityType> mobsToKill = new LinkedList<EntityType>();
|
||||
LinkedList<Integer> mobNumToKill = new LinkedList<Integer>();
|
||||
LinkedList<Location> locationsToKillWithin = new LinkedList<Location>();
|
||||
LinkedList<Integer> radiiToKillWithin = new LinkedList<Integer>();
|
||||
LinkedList<String> areaNames = new LinkedList<String>();
|
||||
LinkedList<ItemStack> itemsToDeliver = new LinkedList<ItemStack>();
|
||||
LinkedList<Integer> itemDeliveryTargets = new LinkedList<Integer>() {
|
||||
|
||||
private static final long serialVersionUID = -2774443496142382127L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if (o instanceof LinkedList) {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof LinkedList) {
|
||||
@SuppressWarnings("unchecked")
|
||||
LinkedList<Integer> otherList = (LinkedList<Integer>) o;
|
||||
|
||||
for (Integer i : this) {
|
||||
|
||||
Integer other = otherList.get(this.indexOf(i));
|
||||
if (!other.equals(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
public LinkedList<String> deliverMessages = new LinkedList<String>();
|
||||
|
||||
public LinkedList<Integer> citizensToInteract = new LinkedList<Integer>() {
|
||||
for (Integer i : this) {
|
||||
Integer other = otherList.get(this.indexOf(i));
|
||||
if (!other.equals(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
public LinkedList<String> deliverMessages = new LinkedList<String>();
|
||||
public LinkedList<Integer> citizensToInteract = new LinkedList<Integer>() {
|
||||
|
||||
private static final long serialVersionUID = -4086855121042524435L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if (o instanceof LinkedList) {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof LinkedList) {
|
||||
@SuppressWarnings("unchecked")
|
||||
LinkedList<Integer> otherList = (LinkedList<Integer>) o;
|
||||
|
||||
for (Integer i : this) {
|
||||
|
||||
Integer other = otherList.get(this.indexOf(i));
|
||||
if (!other.equals(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
public LinkedList<Integer> citizensToKill = new LinkedList<Integer>() {
|
||||
for (Integer i : this) {
|
||||
Integer other = otherList.get(this.indexOf(i));
|
||||
if (!other.equals(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
public LinkedList<Integer> citizensToKill = new LinkedList<Integer>() {
|
||||
|
||||
private static final long serialVersionUID = 7705964814014176415L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if (o instanceof LinkedList) {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof LinkedList) {
|
||||
@SuppressWarnings("unchecked")
|
||||
LinkedList<Integer> otherList = (LinkedList<Integer>) o;
|
||||
for (Integer i : this) {
|
||||
Integer other = otherList.get(this.indexOf(i));
|
||||
if (!other.equals(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
public LinkedList<Integer> citizenNumToKill = new LinkedList<Integer>();
|
||||
public LinkedList<Location> locationsToReach = new LinkedList<Location>();
|
||||
public LinkedList<Integer> radiiToReachWithin = new LinkedList<Integer>();
|
||||
public LinkedList<World> worldsToReachWithin = new LinkedList<World>();
|
||||
public LinkedList<String> locationNames = new LinkedList<String>();
|
||||
public Map<EntityType, Integer> mobsToTame = new EnumMap<EntityType, Integer>(EntityType.class);
|
||||
public Map<DyeColor, Integer> sheepToShear = new EnumMap<DyeColor, Integer>(DyeColor.class);
|
||||
public Map<EnumMap<Material, Integer>, Boolean> itemsToCraft = new HashMap<EnumMap<Material, Integer>, Boolean>();
|
||||
public LinkedList<CustomObjective> customObjectives = new LinkedList<CustomObjective>();
|
||||
public LinkedList<Integer> customObjectiveCounts = new LinkedList<Integer>();
|
||||
public LinkedList<String> customObjectiveDisplays = new LinkedList<String>();
|
||||
public LinkedList<Map<String, Object>> customObjectiveData = new LinkedList<Map<String, Object>>();
|
||||
public LinkedList<String> passwordDisplays = new LinkedList<String>();
|
||||
public LinkedList<LinkedList<String>> passwordPhrases = new LinkedList<LinkedList<String>>();
|
||||
public String script;
|
||||
public Event startEvent = null;
|
||||
public Event deathEvent = null;
|
||||
public Map<String, Event> chatEvents = new HashMap<String, Event>();
|
||||
public Event disconnectEvent = null;
|
||||
public Event finishEvent = null;
|
||||
public long delay = -1;
|
||||
public String delayMessage = null;
|
||||
public String completeMessage = null;
|
||||
public String startMessage = null;
|
||||
public String objectiveOverride = null;
|
||||
|
||||
for (Integer i : this) {
|
||||
|
||||
Integer other = otherList.get(this.indexOf(i));
|
||||
if (!other.equals(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
public LinkedList<Integer> citizenNumToKill = new LinkedList<Integer>();
|
||||
|
||||
public LinkedList<Location> locationsToReach = new LinkedList<Location>();
|
||||
public LinkedList<Integer> radiiToReachWithin = new LinkedList<Integer>();
|
||||
public LinkedList<World> worldsToReachWithin = new LinkedList<World>();
|
||||
public LinkedList<String> locationNames = new LinkedList<String>();
|
||||
public Map<EntityType, Integer> mobsToTame = new EnumMap<EntityType, Integer>(EntityType.class);
|
||||
public Map<DyeColor, Integer> sheepToShear = new EnumMap<DyeColor, Integer>(DyeColor.class);
|
||||
public Map<EnumMap<Material, Integer>, Boolean> itemsToCraft = new HashMap<EnumMap<Material, Integer>, Boolean>();
|
||||
public LinkedList<CustomObjective> customObjectives = new LinkedList<CustomObjective>();
|
||||
public LinkedList<Integer> customObjectiveCounts = new LinkedList<Integer>();
|
||||
public LinkedList<String> customObjectiveDisplays = new LinkedList<String>();
|
||||
public LinkedList<Map<String, Object>> customObjectiveData = new LinkedList<Map<String, Object>>();
|
||||
public LinkedList<String> passwordDisplays = new LinkedList<String>();
|
||||
public LinkedList<LinkedList<String>> passwordPhrases = new LinkedList<LinkedList<String>>();
|
||||
public String script;
|
||||
public Event startEvent = null;
|
||||
public Event deathEvent = null;
|
||||
public Map<String, Event> chatEvents = new HashMap<String, Event>();
|
||||
public Event disconnectEvent = null;
|
||||
public Event finishEvent = null;
|
||||
public long delay = -1;
|
||||
public String delayMessage = null;
|
||||
public String completeMessage = null;
|
||||
public String startMessage = null;
|
||||
public String objectiveOverride = null;
|
||||
|
||||
public int hashCode() {
|
||||
assert false : "hashCode not designed";
|
||||
return 42; // any arbitrary constant will do
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
if (o instanceof Stage) {
|
||||
|
||||
Stage other = (Stage) o;
|
||||
|
||||
if (other.blocksToDamage.equals(blocksToDamage) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.blocksToBreak.equals(blocksToBreak) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.blocksToPlace.equals(blocksToPlace) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.blocksToUse.equals(blocksToUse) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.blocksToCut.equals(blocksToCut) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.fishToCatch != null && fishToCatch != null) {
|
||||
if (other.fishToCatch.equals(fishToCatch) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (other.fishToCatch != null && fishToCatch == null) {
|
||||
return false;
|
||||
} else if (other.fishToCatch == null && fishToCatch != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.playersToKill != null && playersToKill != null) {
|
||||
if (other.playersToKill.equals(playersToKill) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (other.playersToKill != null && playersToKill == null) {
|
||||
return false;
|
||||
} else if (other.playersToKill == null && playersToKill != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.itemsToEnchant.equals(itemsToEnchant) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.mobsToKill.equals(mobsToKill) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.mobNumToKill.equals(mobNumToKill) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.locationsToKillWithin.equals(locationsToKillWithin) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.radiiToKillWithin.equals(radiiToKillWithin) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.areaNames.equals(areaNames) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.itemsToDeliver.equals(itemsToDeliver) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.itemDeliveryTargets.equals(itemDeliveryTargets) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.deliverMessages.equals(deliverMessages) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.citizensToInteract.equals(citizensToInteract) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.citizensToKill.equals(citizensToKill) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.citizenNumToKill.equals(citizenNumToKill) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.locationsToReach.equals(locationsToReach) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.radiiToReachWithin.equals(radiiToReachWithin) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.worldsToReachWithin.equals(worldsToReachWithin) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.locationNames.equals(locationNames) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.mobsToTame.equals(mobsToTame) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.sheepToShear.equals(sheepToShear) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.itemsToCraft.equals(itemsToCraft) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.customObjectives.equals(customObjectives) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.customObjectiveDisplays.equals(customObjectiveDisplays) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.customObjectiveData.equals(customObjectiveData) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.passwordDisplays.equals(passwordDisplays) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.passwordPhrases.equals(passwordPhrases) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.script != null && script != null) {
|
||||
if (other.script.equals(script) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (other.script != null && script == null) {
|
||||
return false;
|
||||
} else if (other.script == null && script != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.startEvent != null && startEvent != null) {
|
||||
if (other.startEvent.equals(startEvent) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (other.startEvent != null && startEvent == null) {
|
||||
return false;
|
||||
} else if (other.startEvent == null && startEvent != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.deathEvent != null && deathEvent != null) {
|
||||
if (other.deathEvent.equals(deathEvent) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (other.deathEvent != null && deathEvent == null) {
|
||||
return false;
|
||||
} else if (other.deathEvent == null && deathEvent != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.finishEvent != null && finishEvent != null) {
|
||||
if (other.finishEvent.equals(finishEvent) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (other.finishEvent != null && finishEvent == null) {
|
||||
return false;
|
||||
} else if (other.finishEvent == null && finishEvent != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.chatEvents.equals(chatEvents) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.delay != delay) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.delayMessage != null && delayMessage != null) {
|
||||
if (other.delayMessage.equals(delayMessage) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (other.delayMessage != null && delayMessage == null) {
|
||||
return false;
|
||||
} else if (other.delayMessage == null && delayMessage != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.startMessage != null && startMessage != null) {
|
||||
if (other.startMessage.equals(startMessage) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (other.startMessage != null && startMessage == null) {
|
||||
return false;
|
||||
} else if (other.startMessage == null && startMessage != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.completeMessage != null && completeMessage != null) {
|
||||
if (other.completeMessage.equals(completeMessage) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (other.completeMessage != null && completeMessage == null) {
|
||||
return false;
|
||||
} else if (other.completeMessage == null && completeMessage != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.objectiveOverride != null && objectiveOverride != null) {
|
||||
if (other.objectiveOverride.equals(objectiveOverride) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (other.objectiveOverride != null && objectiveOverride == null) {
|
||||
return false;
|
||||
} else if (other.objectiveOverride == null && objectiveOverride != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
public int hashCode() {
|
||||
assert false : "hashCode not designed";
|
||||
return 42; // any arbitrary constant will do
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof Stage) {
|
||||
Stage other = (Stage) o;
|
||||
if (other.blocksToDamage.equals(blocksToDamage) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.blocksToBreak.equals(blocksToBreak) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.blocksToPlace.equals(blocksToPlace) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.blocksToUse.equals(blocksToUse) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.blocksToCut.equals(blocksToCut) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.fishToCatch != null && fishToCatch != null) {
|
||||
if (other.fishToCatch.equals(fishToCatch) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (other.fishToCatch != null && fishToCatch == null) {
|
||||
return false;
|
||||
} else if (other.fishToCatch == null && fishToCatch != null) {
|
||||
return false;
|
||||
}
|
||||
if (other.playersToKill != null && playersToKill != null) {
|
||||
if (other.playersToKill.equals(playersToKill) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (other.playersToKill != null && playersToKill == null) {
|
||||
return false;
|
||||
} else if (other.playersToKill == null && playersToKill != null) {
|
||||
return false;
|
||||
}
|
||||
if (other.itemsToEnchant.equals(itemsToEnchant) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.mobsToKill.equals(mobsToKill) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.mobNumToKill.equals(mobNumToKill) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.locationsToKillWithin.equals(locationsToKillWithin) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.radiiToKillWithin.equals(radiiToKillWithin) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.areaNames.equals(areaNames) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.itemsToDeliver.equals(itemsToDeliver) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.itemDeliveryTargets.equals(itemDeliveryTargets) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.deliverMessages.equals(deliverMessages) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.citizensToInteract.equals(citizensToInteract) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.citizensToKill.equals(citizensToKill) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.citizenNumToKill.equals(citizenNumToKill) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.locationsToReach.equals(locationsToReach) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.radiiToReachWithin.equals(radiiToReachWithin) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.worldsToReachWithin.equals(worldsToReachWithin) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.locationNames.equals(locationNames) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.mobsToTame.equals(mobsToTame) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.sheepToShear.equals(sheepToShear) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.itemsToCraft.equals(itemsToCraft) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.customObjectives.equals(customObjectives) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.customObjectiveDisplays.equals(customObjectiveDisplays) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.customObjectiveData.equals(customObjectiveData) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.passwordDisplays.equals(passwordDisplays) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.passwordPhrases.equals(passwordPhrases) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.script != null && script != null) {
|
||||
if (other.script.equals(script) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (other.script != null && script == null) {
|
||||
return false;
|
||||
} else if (other.script == null && script != null) {
|
||||
return false;
|
||||
}
|
||||
if (other.startEvent != null && startEvent != null) {
|
||||
if (other.startEvent.equals(startEvent) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (other.startEvent != null && startEvent == null) {
|
||||
return false;
|
||||
} else if (other.startEvent == null && startEvent != null) {
|
||||
return false;
|
||||
}
|
||||
if (other.deathEvent != null && deathEvent != null) {
|
||||
if (other.deathEvent.equals(deathEvent) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (other.deathEvent != null && deathEvent == null) {
|
||||
return false;
|
||||
} else if (other.deathEvent == null && deathEvent != null) {
|
||||
return false;
|
||||
}
|
||||
if (other.finishEvent != null && finishEvent != null) {
|
||||
if (other.finishEvent.equals(finishEvent) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (other.finishEvent != null && finishEvent == null) {
|
||||
return false;
|
||||
} else if (other.finishEvent == null && finishEvent != null) {
|
||||
return false;
|
||||
}
|
||||
if (other.chatEvents.equals(chatEvents) == false) {
|
||||
return false;
|
||||
}
|
||||
if (other.delay != delay) {
|
||||
return false;
|
||||
}
|
||||
if (other.delayMessage != null && delayMessage != null) {
|
||||
if (other.delayMessage.equals(delayMessage) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (other.delayMessage != null && delayMessage == null) {
|
||||
return false;
|
||||
} else if (other.delayMessage == null && delayMessage != null) {
|
||||
return false;
|
||||
}
|
||||
if (other.startMessage != null && startMessage != null) {
|
||||
if (other.startMessage.equals(startMessage) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (other.startMessage != null && startMessage == null) {
|
||||
return false;
|
||||
} else if (other.startMessage == null && startMessage != null) {
|
||||
return false;
|
||||
}
|
||||
if (other.completeMessage != null && completeMessage != null) {
|
||||
if (other.completeMessage.equals(completeMessage) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (other.completeMessage != null && completeMessage == null) {
|
||||
return false;
|
||||
} else if (other.completeMessage == null && completeMessage != null) {
|
||||
return false;
|
||||
}
|
||||
if (other.objectiveOverride != null && objectiveOverride != null) {
|
||||
if (other.objectiveOverride.equals(objectiveOverride) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (other.objectiveOverride != null && objectiveOverride == null) {
|
||||
return false;
|
||||
} else if (other.objectiveOverride == null && objectiveOverride != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,82 +1,62 @@
|
||||
package me.blackvein.quests;
|
||||
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.blackvein.quests.util.Lang;
|
||||
|
||||
public class StageTimer implements Runnable {
|
||||
|
||||
Quester quester;
|
||||
Quests plugin;
|
||||
Quest quest;
|
||||
Quester quester;
|
||||
Quests plugin;
|
||||
Quest quest;
|
||||
|
||||
public StageTimer(Quests quests, Quester q, Quest qu) {
|
||||
|
||||
quester = q;
|
||||
quest = qu;
|
||||
plugin = quests;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if (quester.getQuestData(quest).delayOver) {
|
||||
|
||||
Player player = quester.getPlayer();
|
||||
|
||||
if (quest.orderedStages.indexOf(quester.getCurrentStage(quest)) == (quest.orderedStages.size() - 1)) {
|
||||
|
||||
if (quester.getCurrentStage(quest).script != null) {
|
||||
plugin.trigger.parseQuestTaskTrigger(quester.getCurrentStage(quest).script, player);
|
||||
}
|
||||
if (quester.getCurrentStage(quest).finishEvent != null) {
|
||||
quester.getCurrentStage(quest).finishEvent.fire(quester, quest);
|
||||
}
|
||||
|
||||
quest.completeQuest(quester);
|
||||
|
||||
} else {
|
||||
|
||||
Stage currentStage = quester.getCurrentStage(quest);
|
||||
int stageNum = quester.currentQuests.get(quest) + 1;
|
||||
quester.hardQuit(quest);
|
||||
|
||||
if (currentStage.script != null) {
|
||||
plugin.trigger.parseQuestTaskTrigger(currentStage.script, player);
|
||||
}
|
||||
|
||||
if (currentStage.finishEvent != null) {
|
||||
currentStage.finishEvent.fire(quester, quest);
|
||||
}
|
||||
|
||||
quester.hardStagePut(quest, stageNum);
|
||||
quester.addEmpties(quest);
|
||||
quester.getQuestData(quest).delayStartTime = 0;
|
||||
quester.getQuestData(quest).delayTimeLeft = -1;
|
||||
|
||||
String msg = Lang.get("questObjectivesTitle");
|
||||
msg = msg.replaceAll("<quest>", quest.name);
|
||||
player.sendMessage(ChatColor.GOLD + msg);
|
||||
player.sendMessage(ChatColor.GOLD + Lang.get("questObjectivesTitle"));
|
||||
for (String s : quester.getObjectivesReal(quest)) {
|
||||
|
||||
player.sendMessage(s);
|
||||
|
||||
}
|
||||
|
||||
String stageStartMessage = quester.getCurrentStage(quest).startMessage;
|
||||
if (stageStartMessage != null) {
|
||||
quester.getPlayer().sendMessage(Quests.parseString(stageStartMessage, quest));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
quester.getQuestData(quest).delayOver = true;
|
||||
quester.updateJournal();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public StageTimer(Quests quests, Quester q, Quest qu) {
|
||||
quester = q;
|
||||
quest = qu;
|
||||
plugin = quests;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (quester.getQuestData(quest).delayOver) {
|
||||
Player player = quester.getPlayer();
|
||||
if (quest.orderedStages.indexOf(quester.getCurrentStage(quest)) == (quest.orderedStages.size() - 1)) {
|
||||
if (quester.getCurrentStage(quest).script != null) {
|
||||
plugin.trigger.parseQuestTaskTrigger(quester.getCurrentStage(quest).script, player);
|
||||
}
|
||||
if (quester.getCurrentStage(quest).finishEvent != null) {
|
||||
quester.getCurrentStage(quest).finishEvent.fire(quester, quest);
|
||||
}
|
||||
quest.completeQuest(quester);
|
||||
} else {
|
||||
Stage currentStage = quester.getCurrentStage(quest);
|
||||
int stageNum = quester.currentQuests.get(quest) + 1;
|
||||
quester.hardQuit(quest);
|
||||
if (currentStage.script != null) {
|
||||
plugin.trigger.parseQuestTaskTrigger(currentStage.script, player);
|
||||
}
|
||||
if (currentStage.finishEvent != null) {
|
||||
currentStage.finishEvent.fire(quester, quest);
|
||||
}
|
||||
quester.hardStagePut(quest, stageNum);
|
||||
quester.addEmpties(quest);
|
||||
quester.getQuestData(quest).delayStartTime = 0;
|
||||
quester.getQuestData(quest).delayTimeLeft = -1;
|
||||
String msg = Lang.get("questObjectivesTitle");
|
||||
msg = msg.replaceAll("<quest>", quest.name);
|
||||
player.sendMessage(ChatColor.GOLD + msg);
|
||||
player.sendMessage(ChatColor.GOLD + Lang.get("questObjectivesTitle"));
|
||||
for (String s : quester.getObjectivesReal(quest)) {
|
||||
player.sendMessage(s);
|
||||
}
|
||||
String stageStartMessage = quester.getCurrentStage(quest).startMessage;
|
||||
if (stageStartMessage != null) {
|
||||
quester.getPlayer().sendMessage(Quests.parseString(stageStartMessage, quest));
|
||||
}
|
||||
}
|
||||
quester.getQuestData(quest).delayOver = true;
|
||||
quester.updateJournal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,28 +2,66 @@ package me.blackvein.quests.exceptions;
|
||||
|
||||
import me.blackvein.quests.Quest;
|
||||
|
||||
/**
|
||||
* This is the InvalidStageException class, this exception is used to indicate
|
||||
* that the new stage of a quest does not exist. This is currently used in the
|
||||
* Quest class when advancing to the next stage or manually setting the stage.
|
||||
*
|
||||
* @author Zino
|
||||
* @author Blackvein
|
||||
* @since 1.7.1-SNAPSHOT
|
||||
* @version 3
|
||||
* @see Quest#nextStage(me.blackvein.quests.Quester)
|
||||
* @see Quest#setStage(me.blackvein.quests.Quester, int)
|
||||
*/
|
||||
public class InvalidStageException extends Exception {
|
||||
|
||||
private final Quest quest;
|
||||
private final int stage;
|
||||
/**
|
||||
* The version id to use when serialising and deserialising this class.
|
||||
*/
|
||||
private static final long serialVersionUID = 1778748295752972651L;
|
||||
|
||||
public InvalidStageException(Quest quest, int stage) {
|
||||
this.quest = quest;
|
||||
this.stage = stage;
|
||||
}
|
||||
|
||||
public Quest getQuest() {
|
||||
return quest;
|
||||
}
|
||||
/**
|
||||
* The Quest instance that an invalid stage was set within.
|
||||
*/
|
||||
private final Quest quest;
|
||||
|
||||
public int getStage() {
|
||||
return stage;
|
||||
}
|
||||
/**
|
||||
* The invalid stage number that was attempted to be set.
|
||||
*/
|
||||
private final int stage;
|
||||
|
||||
private static final long serialVersionUID = 1778748295752972651L;
|
||||
/**
|
||||
* Create a new instance of the InvalidStageException class with the given
|
||||
* holding Quest and invalid stage number.
|
||||
*
|
||||
* @param quest
|
||||
* The quest that an invalid stage id was set within.
|
||||
* @param stage
|
||||
* The invalid stage id that was set.
|
||||
*/
|
||||
public InvalidStageException(Quest quest, int stage) {
|
||||
this.quest = quest;
|
||||
this.stage = stage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printStackTrace() {
|
||||
super.printStackTrace();
|
||||
}
|
||||
/**
|
||||
* Get the quest instance associated with this exception.
|
||||
*
|
||||
* @return The quest that an invalid stage id was set within.
|
||||
*/
|
||||
public Quest getQuest() {
|
||||
return quest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the invalid stage id that was attempted to be set within the quest
|
||||
* class.
|
||||
*
|
||||
* @return The invalid stage id that was set.
|
||||
*/
|
||||
public int getStage() {
|
||||
return stage;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -25,564 +25,442 @@ import me.blackvein.quests.util.Lang;
|
||||
|
||||
public class ItemStackPrompt extends FixedSetPrompt {
|
||||
|
||||
//Stores itemstack in "tempStack" context data.
|
||||
//Stores name in "tempName"
|
||||
//Stores amount in "tempAmount"
|
||||
//Stores data in "tempData"
|
||||
//Stores enchantments in "tempEnchantments"
|
||||
//Stores display name in "tempDisplay"
|
||||
//Stores lore in "tempLore"
|
||||
final Prompt oldPrompt;
|
||||
// Stores itemstack in "tempStack" context data.
|
||||
// Stores name in "tempName"
|
||||
// Stores amount in "tempAmount"
|
||||
// Stores data in "tempData"
|
||||
// Stores enchantments in "tempEnchantments"
|
||||
// Stores display name in "tempDisplay"
|
||||
// Stores lore in "tempLore"
|
||||
final Prompt oldPrompt;
|
||||
|
||||
public ItemStackPrompt(Prompt old) {
|
||||
public ItemStackPrompt(Prompt old) {
|
||||
super("0", "1", "2", "3", "4", "5", "6", "7", "8");
|
||||
oldPrompt = old;
|
||||
}
|
||||
|
||||
super("0", "1", "2", "3", "4", "5", "6", "7", "8");
|
||||
oldPrompt = old;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
String menu = ChatColor.YELLOW + Lang.get("createItemTitle") + "\n";
|
||||
if (cc.getSessionData("tempName") != null) {
|
||||
String stackData = getItemData(cc);
|
||||
if (stackData != null) {
|
||||
menu += stackData;
|
||||
}
|
||||
} else {
|
||||
menu += "\n";
|
||||
}
|
||||
menu += ChatColor.GOLD + "" + ChatColor.BOLD + "0. " + ChatColor.RESET + "" + ChatColor.YELLOW + Lang.get("itemCreateLoadHand") + "\n";
|
||||
menu += ChatColor.YELLOW + "" + ChatColor.BOLD + "1. " + ChatColor.RESET + "" + ChatColor.GOLD + Lang.get("itemCreateSetName") + "\n";
|
||||
menu += ChatColor.YELLOW + "" + ChatColor.BOLD + "2. " + ChatColor.RESET + "" + ChatColor.GOLD + Lang.get("itemCreateSetAmount") + "\n";
|
||||
menu += ChatColor.YELLOW + "" + ChatColor.BOLD + "3. " + ChatColor.RESET + "" + ChatColor.GOLD + Lang.get("itemCreateSetDurab") + "\n";
|
||||
menu += ChatColor.YELLOW + "" + ChatColor.BOLD + "4. " + ChatColor.RESET + "" + ChatColor.GOLD + Lang.get("itemCreateSetEnchs") + "\n";
|
||||
menu += ChatColor.YELLOW + "" + ChatColor.BOLD + "5. " + ChatColor.RESET + "" + ChatColor.ITALIC + ChatColor.GOLD + Lang.get("itemCreateSetDisplay") + "\n";
|
||||
menu += ChatColor.YELLOW + "" + ChatColor.BOLD + "6. " + ChatColor.RESET + "" + ChatColor.ITALIC + ChatColor.GOLD + Lang.get("itemCreateSetLore") + "\n";
|
||||
menu += ChatColor.YELLOW + "" + ChatColor.BOLD + "7. " + ChatColor.RESET + "" + ChatColor.RED + Lang.get("cancel") + "\n";
|
||||
menu += ChatColor.YELLOW + "" + ChatColor.BOLD + "8. " + ChatColor.RESET + "" + ChatColor.GREEN + Lang.get("done") + "\n";
|
||||
return menu;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected Prompt acceptValidatedInput(ConversationContext cc, String input) {
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
String menu = ChatColor.YELLOW + Lang.get("createItemTitle") + "\n";
|
||||
if (cc.getSessionData("tempName") != null) {
|
||||
String stackData = getItemData(cc);
|
||||
if (stackData != null) {
|
||||
menu += stackData;
|
||||
}
|
||||
} else {
|
||||
menu += "\n";
|
||||
}
|
||||
menu += ChatColor.GOLD + "" + ChatColor.BOLD + "0. " + ChatColor.RESET + "" + ChatColor.YELLOW + Lang.get("itemCreateLoadHand") + "\n";
|
||||
menu += ChatColor.YELLOW + "" + ChatColor.BOLD + "1. " + ChatColor.RESET + "" + ChatColor.GOLD + Lang.get("itemCreateSetName") + "\n";
|
||||
menu += ChatColor.YELLOW + "" + ChatColor.BOLD + "2. " + ChatColor.RESET + "" + ChatColor.GOLD + Lang.get("itemCreateSetAmount") + "\n";
|
||||
menu += ChatColor.YELLOW + "" + ChatColor.BOLD + "3. " + ChatColor.RESET + "" + ChatColor.GOLD + Lang.get("itemCreateSetDurab") + "\n";
|
||||
menu += ChatColor.YELLOW + "" + ChatColor.BOLD + "4. " + ChatColor.RESET + "" + ChatColor.GOLD + Lang.get("itemCreateSetEnchs") + "\n";
|
||||
menu += ChatColor.YELLOW + "" + ChatColor.BOLD + "5. " + ChatColor.RESET + "" + ChatColor.ITALIC + ChatColor.GOLD + Lang.get("itemCreateSetDisplay") + "\n";
|
||||
menu += ChatColor.YELLOW + "" + ChatColor.BOLD + "6. " + ChatColor.RESET + "" + ChatColor.ITALIC + ChatColor.GOLD + Lang.get("itemCreateSetLore") + "\n";
|
||||
menu += ChatColor.YELLOW + "" + ChatColor.BOLD + "7. " + ChatColor.RESET + "" + ChatColor.RED + Lang.get("cancel") + "\n";
|
||||
menu += ChatColor.YELLOW + "" + ChatColor.BOLD + "8. " + ChatColor.RESET + "" + ChatColor.GREEN + Lang.get("done") + "\n";
|
||||
return menu;
|
||||
}
|
||||
|
||||
if (input.equalsIgnoreCase("0")) {
|
||||
|
||||
Player player = (Player) cc.getForWhom();
|
||||
@SuppressWarnings("deprecation")
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected Prompt acceptValidatedInput(ConversationContext cc, String input) {
|
||||
if (input.equalsIgnoreCase("0")) {
|
||||
Player player = (Player) cc.getForWhom();
|
||||
@SuppressWarnings("deprecation")
|
||||
ItemStack is = player.getItemInHand();
|
||||
if (is == null || is.getType().equals(Material.AIR)) {
|
||||
|
||||
player.sendMessage(ChatColor.RED + Lang.get("itemCreateNoItem"));
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
|
||||
} else {
|
||||
|
||||
cc.setSessionData("tempName", is.getType().name());
|
||||
cc.setSessionData("tempAmount", is.getAmount());
|
||||
cc.setSessionData("tempData", null);
|
||||
cc.setSessionData("tempEnchantments", null);
|
||||
cc.setSessionData("tempDisplay", null);
|
||||
cc.setSessionData("tempLore", null);
|
||||
if (is.getDurability() != 0) {
|
||||
cc.setSessionData("tempData", is.getDurability());
|
||||
}
|
||||
if (is.getEnchantments() != null && is.getEnchantments().isEmpty() == false) {
|
||||
cc.setSessionData("tempEnchantments", new HashMap<Enchantment, Integer>(is.getEnchantments()));
|
||||
}
|
||||
if (is.hasItemMeta()) {
|
||||
|
||||
ItemMeta meta = is.getItemMeta();
|
||||
if (meta.hasDisplayName()) {
|
||||
String display = meta.getDisplayName().replace(ChatColor.COLOR_CHAR, '&');
|
||||
cc.setSessionData("tempDisplay", display);
|
||||
}
|
||||
if (meta.hasLore()) {
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
lore.addAll(meta.getLore());
|
||||
cc.setSessionData("tempLore", lore);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
player.sendMessage(ChatColor.GREEN + Lang.get("itemCreateLoaded"));
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
|
||||
}
|
||||
|
||||
} else if (input.equalsIgnoreCase("1")) {
|
||||
return new NamePrompt();
|
||||
} else if (input.equalsIgnoreCase("2")) {
|
||||
|
||||
if (cc.getSessionData("tempName") != null) {
|
||||
return new AmountPrompt();
|
||||
} else {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateNoName"));
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
|
||||
} else if (input.equalsIgnoreCase("3")) {
|
||||
|
||||
if (cc.getSessionData("tempName") != null && cc.getSessionData("tempAmount") != null) {
|
||||
return new DataPrompt();
|
||||
} else {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateNoIDAmount"));
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
|
||||
} else if (input.equalsIgnoreCase("4")) {
|
||||
|
||||
if (cc.getSessionData("tempName") != null && cc.getSessionData("tempAmount") != null) {
|
||||
return new EnchantmentPrompt();
|
||||
} else {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateNoIDAmount"));
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
|
||||
} else if (input.equalsIgnoreCase("5")) {
|
||||
|
||||
if (cc.getSessionData("tempName") != null && cc.getSessionData("tempAmount") != null) {
|
||||
return new DisplayPrompt();
|
||||
} else {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateNoNameAmount"));
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
|
||||
} else if (input.equalsIgnoreCase("6")) {
|
||||
|
||||
if (cc.getSessionData("tempName") != null && cc.getSessionData("tempAmount") != null) {
|
||||
return new LorePrompt();
|
||||
} else {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateNoNameAmount"));
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
|
||||
} else if (input.equalsIgnoreCase("7")) {
|
||||
|
||||
cc.setSessionData("tempStack", null);
|
||||
cc.setSessionData("tempName", null);
|
||||
cc.setSessionData("tempAmount", null);
|
||||
cc.setSessionData("tempData", null);
|
||||
cc.setSessionData("tempEnchantments", null);
|
||||
cc.setSessionData("tempDisplay", null);
|
||||
cc.setSessionData("tempLore", null);
|
||||
|
||||
} else if (input.equalsIgnoreCase("8")) {
|
||||
|
||||
if (cc.getSessionData("tempName") != null && cc.getSessionData("tempAmount") != null) {
|
||||
|
||||
String name = (String) cc.getSessionData("tempName");
|
||||
int amount = (Integer) cc.getSessionData("tempAmount");
|
||||
short data = -1;
|
||||
Map<Enchantment, Integer> enchs = null;
|
||||
String display = null;
|
||||
List<String> lore = null;
|
||||
|
||||
if (cc.getSessionData("tempData") != null) {
|
||||
data = (Short) cc.getSessionData("tempData");
|
||||
}
|
||||
if (cc.getSessionData("tempEnchantments") != null) {
|
||||
enchs = (Map<Enchantment, Integer>) cc.getSessionData("tempEnchantments");
|
||||
}
|
||||
if (cc.getSessionData("tempDisplay") != null) {
|
||||
display = ChatColor.translateAlternateColorCodes('&', (String) cc.getSessionData("tempDisplay"));
|
||||
}
|
||||
if (cc.getSessionData("tempLore") != null) {
|
||||
lore = new ArrayList<String>();
|
||||
LinkedList<String> loadedLore = (LinkedList<String>) cc.getSessionData("tempLore");
|
||||
for (String line : loadedLore)
|
||||
{
|
||||
lore.add(ChatColor.translateAlternateColorCodes('&', line));
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack stack = new ItemStack(Material.matchMaterial(name), amount);
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
|
||||
if (data != -1) {
|
||||
stack.setDurability((short) data);
|
||||
}
|
||||
if (enchs != null) {
|
||||
for (Entry<Enchantment, Integer> e : enchs.entrySet()) {
|
||||
meta.addEnchant(e.getKey(), e.getValue(), true);
|
||||
}
|
||||
}
|
||||
if (display != null) {
|
||||
meta.setDisplayName(display);
|
||||
}
|
||||
if (lore != null) {
|
||||
meta.setLore(lore);
|
||||
}
|
||||
|
||||
stack.setItemMeta(meta);
|
||||
|
||||
cc.setSessionData("tempStack", stack);
|
||||
cc.setSessionData("newItem", Boolean.TRUE);
|
||||
} else {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateNoNameAmount"));
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
return oldPrompt;
|
||||
} catch (Exception e) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError"));
|
||||
return Prompt.END_OF_CONVERSATION;
|
||||
}
|
||||
}
|
||||
|
||||
private class NamePrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
return ChatColor.YELLOW + Lang.get("itemCreateEnterName");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
|
||||
String dataString = null;
|
||||
if (input.contains(":")) {
|
||||
String[] splitInput = input.split(":");
|
||||
input = splitInput[0];
|
||||
if (splitInput.length > 1) {
|
||||
dataString = splitInput[1];
|
||||
}
|
||||
}
|
||||
|
||||
Material mat = Material.matchMaterial(input.toUpperCase().replace(" ", "_"));
|
||||
if (mat == null) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidName"));
|
||||
return new NamePrompt();
|
||||
} else {
|
||||
cc.setSessionData("tempName", mat.name());
|
||||
cc.setSessionData("tempAmount", 1);
|
||||
|
||||
if (dataString != null) {
|
||||
try {
|
||||
short data = Short.parseShort(dataString);
|
||||
cc.setSessionData("tempData", data);
|
||||
} catch (NumberFormatException e) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidData"));
|
||||
return new NamePrompt();
|
||||
}
|
||||
}
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class AmountPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
return ChatColor.YELLOW + Lang.get("itemCreateEnterAmount");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
|
||||
try {
|
||||
|
||||
int amt = Integer.parseInt(input);
|
||||
if (amt < 1 || amt > 64) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidAmount"));
|
||||
return new AmountPrompt();
|
||||
} else {
|
||||
cc.setSessionData("tempAmount", Integer.parseInt(input));
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
|
||||
return new AmountPrompt();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class DataPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
return ChatColor.YELLOW + Lang.get("itemCreateEnterDurab");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
|
||||
|
||||
try {
|
||||
|
||||
int amt = Integer.parseInt(input);
|
||||
if (amt < 1) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidDurab"));
|
||||
return new DataPrompt();
|
||||
} else {
|
||||
cc.setSessionData("tempData", Short.parseShort(input));
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
|
||||
return new DataPrompt();
|
||||
}
|
||||
|
||||
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
|
||||
cc.setSessionData("tempData", null);
|
||||
|
||||
}
|
||||
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class EnchantmentPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
|
||||
String text = ChatColor.LIGHT_PURPLE + Lang.get("enchantmentsTitle") + "\n";
|
||||
for (Enchantment e : Enchantment.values()) {
|
||||
|
||||
text += ChatColor.GREEN + Quester.prettyEnchantmentString(e) + ", ";
|
||||
|
||||
}
|
||||
text = text.substring(0, text.length() - 1);
|
||||
|
||||
return text + "\n" + ChatColor.YELLOW + Lang.get("itemCreateEnterEnch");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdClear")) == false && input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
|
||||
Enchantment e = Quests.getEnchantmentPretty(input);
|
||||
if (e != null) {
|
||||
|
||||
cc.setSessionData("tempEnchant", e);
|
||||
return new LevelPrompt(Quester.prettyEnchantmentString(e));
|
||||
|
||||
} else {
|
||||
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidEnch"));
|
||||
return new EnchantmentPrompt();
|
||||
|
||||
}
|
||||
|
||||
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
cc.setSessionData("tempEnchantments", null);
|
||||
}
|
||||
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
|
||||
protected class LevelPrompt extends StringPrompt {
|
||||
|
||||
final String enchantment;
|
||||
|
||||
protected LevelPrompt(String ench) {
|
||||
enchantment = ench;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
String text = Lang.get("itemCreateEnterLevel");
|
||||
text = text.replaceAll("<enchantment>", enchantment);
|
||||
return ChatColor.AQUA + text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
|
||||
try {
|
||||
|
||||
int num = Integer.parseInt(input);
|
||||
if (num < 1) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidLevel"));
|
||||
return new LevelPrompt(enchantment);
|
||||
} else {
|
||||
|
||||
if (cc.getSessionData("tempEnchantments") != null) {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
if (is == null || is.getType().equals(Material.AIR)) {
|
||||
player.sendMessage(ChatColor.RED + Lang.get("itemCreateNoItem"));
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
} else {
|
||||
cc.setSessionData("tempName", is.getType().name());
|
||||
cc.setSessionData("tempAmount", is.getAmount());
|
||||
cc.setSessionData("tempData", null);
|
||||
cc.setSessionData("tempEnchantments", null);
|
||||
cc.setSessionData("tempDisplay", null);
|
||||
cc.setSessionData("tempLore", null);
|
||||
if (is.getDurability() != 0) {
|
||||
cc.setSessionData("tempData", is.getDurability());
|
||||
}
|
||||
if (is.getEnchantments() != null && is.getEnchantments().isEmpty() == false) {
|
||||
cc.setSessionData("tempEnchantments", new HashMap<Enchantment, Integer>(is.getEnchantments()));
|
||||
}
|
||||
if (is.hasItemMeta()) {
|
||||
ItemMeta meta = is.getItemMeta();
|
||||
if (meta.hasDisplayName()) {
|
||||
String display = meta.getDisplayName().replace(ChatColor.COLOR_CHAR, '&');
|
||||
cc.setSessionData("tempDisplay", display);
|
||||
}
|
||||
if (meta.hasLore()) {
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
lore.addAll(meta.getLore());
|
||||
cc.setSessionData("tempLore", lore);
|
||||
}
|
||||
}
|
||||
player.sendMessage(ChatColor.GREEN + Lang.get("itemCreateLoaded"));
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
} else if (input.equalsIgnoreCase("1")) {
|
||||
return new NamePrompt();
|
||||
} else if (input.equalsIgnoreCase("2")) {
|
||||
if (cc.getSessionData("tempName") != null) {
|
||||
return new AmountPrompt();
|
||||
} else {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateNoName"));
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
} else if (input.equalsIgnoreCase("3")) {
|
||||
if (cc.getSessionData("tempName") != null && cc.getSessionData("tempAmount") != null) {
|
||||
return new DataPrompt();
|
||||
} else {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateNoIDAmount"));
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
} else if (input.equalsIgnoreCase("4")) {
|
||||
if (cc.getSessionData("tempName") != null && cc.getSessionData("tempAmount") != null) {
|
||||
return new EnchantmentPrompt();
|
||||
} else {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateNoIDAmount"));
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
} else if (input.equalsIgnoreCase("5")) {
|
||||
if (cc.getSessionData("tempName") != null && cc.getSessionData("tempAmount") != null) {
|
||||
return new DisplayPrompt();
|
||||
} else {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateNoNameAmount"));
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
} else if (input.equalsIgnoreCase("6")) {
|
||||
if (cc.getSessionData("tempName") != null && cc.getSessionData("tempAmount") != null) {
|
||||
return new LorePrompt();
|
||||
} else {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateNoNameAmount"));
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
} else if (input.equalsIgnoreCase("7")) {
|
||||
cc.setSessionData("tempStack", null);
|
||||
cc.setSessionData("tempName", null);
|
||||
cc.setSessionData("tempAmount", null);
|
||||
cc.setSessionData("tempData", null);
|
||||
cc.setSessionData("tempEnchantments", null);
|
||||
cc.setSessionData("tempDisplay", null);
|
||||
cc.setSessionData("tempLore", null);
|
||||
} else if (input.equalsIgnoreCase("8")) {
|
||||
if (cc.getSessionData("tempName") != null && cc.getSessionData("tempAmount") != null) {
|
||||
String name = (String) cc.getSessionData("tempName");
|
||||
int amount = (Integer) cc.getSessionData("tempAmount");
|
||||
short data = -1;
|
||||
Map<Enchantment, Integer> enchs = null;
|
||||
String display = null;
|
||||
List<String> lore = null;
|
||||
if (cc.getSessionData("tempData") != null) {
|
||||
data = (Short) cc.getSessionData("tempData");
|
||||
}
|
||||
if (cc.getSessionData("tempEnchantments") != null) {
|
||||
enchs = (Map<Enchantment, Integer>) cc.getSessionData("tempEnchantments");
|
||||
}
|
||||
if (cc.getSessionData("tempDisplay") != null) {
|
||||
display = ChatColor.translateAlternateColorCodes('&', (String) cc.getSessionData("tempDisplay"));
|
||||
}
|
||||
if (cc.getSessionData("tempLore") != null) {
|
||||
lore = new ArrayList<String>();
|
||||
LinkedList<String> loadedLore = (LinkedList<String>) cc.getSessionData("tempLore");
|
||||
for (String line : loadedLore) {
|
||||
lore.add(ChatColor.translateAlternateColorCodes('&', line));
|
||||
}
|
||||
}
|
||||
ItemStack stack = new ItemStack(Material.matchMaterial(name), amount);
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
if (data != -1) {
|
||||
stack.setDurability((short) data);
|
||||
}
|
||||
if (enchs != null) {
|
||||
for (Entry<Enchantment, Integer> e : enchs.entrySet()) {
|
||||
meta.addEnchant(e.getKey(), e.getValue(), true);
|
||||
}
|
||||
}
|
||||
if (display != null) {
|
||||
meta.setDisplayName(display);
|
||||
}
|
||||
if (lore != null) {
|
||||
meta.setLore(lore);
|
||||
}
|
||||
stack.setItemMeta(meta);
|
||||
cc.setSessionData("tempStack", stack);
|
||||
cc.setSessionData("newItem", Boolean.TRUE);
|
||||
} else {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateNoNameAmount"));
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
}
|
||||
try {
|
||||
return oldPrompt;
|
||||
} catch (Exception e) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateCriticalError"));
|
||||
return Prompt.END_OF_CONVERSATION;
|
||||
}
|
||||
}
|
||||
|
||||
private class NamePrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
return ChatColor.YELLOW + Lang.get("itemCreateEnterName");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
String dataString = null;
|
||||
if (input.contains(":")) {
|
||||
String[] splitInput = input.split(":");
|
||||
input = splitInput[0];
|
||||
if (splitInput.length > 1) {
|
||||
dataString = splitInput[1];
|
||||
}
|
||||
}
|
||||
Material mat = Material.matchMaterial(input.toUpperCase().replace(" ", "_"));
|
||||
if (mat == null) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidName"));
|
||||
return new NamePrompt();
|
||||
} else {
|
||||
cc.setSessionData("tempName", mat.name());
|
||||
cc.setSessionData("tempAmount", 1);
|
||||
if (dataString != null) {
|
||||
try {
|
||||
short data = Short.parseShort(dataString);
|
||||
cc.setSessionData("tempData", data);
|
||||
} catch (NumberFormatException e) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidData"));
|
||||
return new NamePrompt();
|
||||
}
|
||||
}
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
} else {
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class AmountPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
return ChatColor.YELLOW + Lang.get("itemCreateEnterAmount");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
try {
|
||||
int amt = Integer.parseInt(input);
|
||||
if (amt < 1 || amt > 64) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidAmount"));
|
||||
return new AmountPrompt();
|
||||
} else {
|
||||
cc.setSessionData("tempAmount", Integer.parseInt(input));
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
|
||||
return new AmountPrompt();
|
||||
}
|
||||
} else {
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class DataPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
return ChatColor.YELLOW + Lang.get("itemCreateEnterDurab");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
|
||||
try {
|
||||
int amt = Integer.parseInt(input);
|
||||
if (amt < 1) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidDurab"));
|
||||
return new DataPrompt();
|
||||
} else {
|
||||
cc.setSessionData("tempData", Short.parseShort(input));
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidInput"));
|
||||
return new DataPrompt();
|
||||
}
|
||||
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
cc.setSessionData("tempData", null);
|
||||
}
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
}
|
||||
|
||||
private class EnchantmentPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
String text = ChatColor.LIGHT_PURPLE + Lang.get("enchantmentsTitle") + "\n";
|
||||
for (Enchantment e : Enchantment.values()) {
|
||||
text += ChatColor.GREEN + Quester.prettyEnchantmentString(e) + ", ";
|
||||
}
|
||||
text = text.substring(0, text.length() - 1);
|
||||
return text + "\n" + ChatColor.YELLOW + Lang.get("itemCreateEnterEnch");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdClear")) == false && input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
|
||||
Enchantment e = Quests.getEnchantmentPretty(input);
|
||||
if (e != null) {
|
||||
cc.setSessionData("tempEnchant", e);
|
||||
return new LevelPrompt(Quester.prettyEnchantmentString(e));
|
||||
} else {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidEnch"));
|
||||
return new EnchantmentPrompt();
|
||||
}
|
||||
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
cc.setSessionData("tempEnchantments", null);
|
||||
}
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
|
||||
protected class LevelPrompt extends StringPrompt {
|
||||
|
||||
final String enchantment;
|
||||
|
||||
protected LevelPrompt(String ench) {
|
||||
enchantment = ench;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
String text = Lang.get("itemCreateEnterLevel");
|
||||
text = text.replaceAll("<enchantment>", enchantment);
|
||||
return ChatColor.AQUA + text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
try {
|
||||
int num = Integer.parseInt(input);
|
||||
if (num < 1) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidLevel"));
|
||||
return new LevelPrompt(enchantment);
|
||||
} else {
|
||||
if (cc.getSessionData("tempEnchantments") != null) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<Enchantment, Integer> enchs = (Map<Enchantment, Integer>) cc.getSessionData("tempEnchantments");
|
||||
enchs.put((Enchantment) cc.getSessionData("tempEnchant"), num);
|
||||
cc.setSessionData("tempEnchantments", enchs);
|
||||
enchs.put((Enchantment) cc.getSessionData("tempEnchant"), num);
|
||||
cc.setSessionData("tempEnchantments", enchs);
|
||||
} else {
|
||||
Map<Enchantment, Integer> enchs = new HashMap<Enchantment, Integer>();
|
||||
enchs.put((Enchantment) cc.getSessionData("tempEnchant"), num);
|
||||
cc.setSessionData("tempEnchantments", enchs);
|
||||
}
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateNotNumber"));
|
||||
return new LevelPrompt(enchantment);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
private class DisplayPrompt extends StringPrompt {
|
||||
|
||||
Map<Enchantment, Integer> enchs = new HashMap<Enchantment, Integer>();
|
||||
enchs.put((Enchantment) cc.getSessionData("tempEnchant"), num);
|
||||
cc.setSessionData("tempEnchantments", enchs);
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
return ChatColor.YELLOW + Lang.get("itemCreateEnterName");
|
||||
}
|
||||
|
||||
}
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
|
||||
input = Quests.parseString(input);
|
||||
cc.setSessionData("tempDisplay", input);
|
||||
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
cc.setSessionData("tempDisplay", null);
|
||||
}
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateNotNumber"));
|
||||
return new LevelPrompt(enchantment);
|
||||
}
|
||||
private class LorePrompt extends StringPrompt {
|
||||
|
||||
}
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
return ChatColor.YELLOW + Lang.get("itemCreateEnterLore");
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
|
||||
input = Quests.parseString(input);
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
lore.addAll(Arrays.asList(input.split(";")));
|
||||
cc.setSessionData("tempLore", lore);
|
||||
} else if (input.equalsIgnoreCase("clear")) {
|
||||
cc.setSessionData("tempLore", null);
|
||||
}
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class DisplayPrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
return ChatColor.YELLOW + Lang.get("itemCreateEnterName");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
|
||||
|
||||
input = Quests.parseString(input);
|
||||
|
||||
cc.setSessionData("tempDisplay", input);
|
||||
|
||||
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
|
||||
|
||||
cc.setSessionData("tempDisplay", null);
|
||||
|
||||
}
|
||||
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class LorePrompt extends StringPrompt {
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
return ChatColor.YELLOW + Lang.get("itemCreateEnterLore");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
|
||||
|
||||
input = Quests.parseString(input);
|
||||
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
lore.addAll(Arrays.asList(input.split(";")));
|
||||
cc.setSessionData("tempLore", lore);
|
||||
|
||||
} else if (input.equalsIgnoreCase("clear")) {
|
||||
|
||||
cc.setSessionData("tempLore", null);
|
||||
|
||||
}
|
||||
|
||||
return new ItemStackPrompt(oldPrompt);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String getItemData(ConversationContext cc) {
|
||||
|
||||
if (cc.getSessionData("tempName") != null) {
|
||||
|
||||
String item;
|
||||
|
||||
if (cc.getSessionData("tempDisplay") == null) {
|
||||
|
||||
String name = (String) cc.getSessionData("tempName");
|
||||
item = ChatColor.AQUA + Quester.prettyItemString(name);
|
||||
|
||||
if (cc.getSessionData("tempData") != null) {
|
||||
item += ":" + ChatColor.BLUE + (Short) cc.getSessionData("tempData");
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
item = ChatColor.LIGHT_PURPLE + "" + ChatColor.ITALIC + (String) cc.getSessionData("tempDisplay") + ChatColor.RESET + "" + ChatColor.GRAY + " (";
|
||||
String name = (String) cc.getSessionData("tempName");
|
||||
item += ChatColor.AQUA + Quester.prettyItemString(name);
|
||||
if (cc.getSessionData("tempData") != null) {
|
||||
item += ":" + ChatColor.BLUE + (Short) cc.getSessionData("tempData");
|
||||
}
|
||||
item += ChatColor.GRAY + ")";
|
||||
|
||||
}
|
||||
|
||||
if (cc.getSessionData("tempAmount") != null) {
|
||||
item += ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + (Integer) cc.getSessionData("tempAmount");
|
||||
} else {
|
||||
item += ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + "1";
|
||||
}
|
||||
|
||||
item += "\n";
|
||||
|
||||
if (cc.getSessionData("tempEnchantments") != null) {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private String getItemData(ConversationContext cc) {
|
||||
if (cc.getSessionData("tempName") != null) {
|
||||
String item;
|
||||
if (cc.getSessionData("tempDisplay") == null) {
|
||||
String name = (String) cc.getSessionData("tempName");
|
||||
item = ChatColor.AQUA + Quester.prettyItemString(name);
|
||||
if (cc.getSessionData("tempData") != null) {
|
||||
item += ":" + ChatColor.BLUE + (Short) cc.getSessionData("tempData");
|
||||
}
|
||||
} else {
|
||||
item = ChatColor.LIGHT_PURPLE + "" + ChatColor.ITALIC + (String) cc.getSessionData("tempDisplay") + ChatColor.RESET + "" + ChatColor.GRAY + " (";
|
||||
String name = (String) cc.getSessionData("tempName");
|
||||
item += ChatColor.AQUA + Quester.prettyItemString(name);
|
||||
if (cc.getSessionData("tempData") != null) {
|
||||
item += ":" + ChatColor.BLUE + (Short) cc.getSessionData("tempData");
|
||||
}
|
||||
item += ChatColor.GRAY + ")";
|
||||
}
|
||||
if (cc.getSessionData("tempAmount") != null) {
|
||||
item += ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + (Integer) cc.getSessionData("tempAmount");
|
||||
} else {
|
||||
item += ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + "1";
|
||||
}
|
||||
item += "\n";
|
||||
if (cc.getSessionData("tempEnchantments") != null) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<Enchantment, Integer> enchantments = (Map<Enchantment, Integer>) cc.getSessionData("tempEnchantments");
|
||||
for (Entry<Enchantment, Integer> e : enchantments.entrySet()) {
|
||||
|
||||
item += ChatColor.GRAY + " - " + ChatColor.RED + Quester.prettyEnchantmentString(e.getKey()) + " " + Quests.getNumeral(e.getValue()) + "\n";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (cc.getSessionData("tempLore") != null) {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
for (Entry<Enchantment, Integer> e : enchantments.entrySet()) {
|
||||
item += ChatColor.GRAY + " - " + ChatColor.RED + Quester.prettyEnchantmentString(e.getKey()) + " " + Quests.getNumeral(e.getValue()) + "\n";
|
||||
}
|
||||
}
|
||||
if (cc.getSessionData("tempLore") != null) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> lore = (List<String>) cc.getSessionData("tempLore");
|
||||
|
||||
item += ChatColor.DARK_GREEN + "(Lore)\n\"";
|
||||
for (String s : lore) {
|
||||
|
||||
if (lore.indexOf(s) != (lore.size() - 1)) {
|
||||
item += ChatColor.DARK_GREEN + "" + ChatColor.ITALIC + s + "\n";
|
||||
} else {
|
||||
item += ChatColor.DARK_GREEN + "" + ChatColor.ITALIC + s + "\"\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
item += "\n";
|
||||
return item;
|
||||
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
item += ChatColor.DARK_GREEN + "(Lore)\n\"";
|
||||
for (String s : lore) {
|
||||
if (lore.indexOf(s) != (lore.size() - 1)) {
|
||||
item += ChatColor.DARK_GREEN + "" + ChatColor.ITALIC + s + "\n";
|
||||
} else {
|
||||
item += ChatColor.DARK_GREEN + "" + ChatColor.ITALIC + s + "\"\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
item += "\n";
|
||||
return item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -18,173 +18,124 @@ import me.blackvein.quests.util.Lang;
|
||||
|
||||
public class QuestAcceptPrompt extends StringPrompt {
|
||||
|
||||
final Quests plugin;
|
||||
Quester quester;
|
||||
LinkedList<Quest> quests;
|
||||
final Quests plugin;
|
||||
Quester quester;
|
||||
LinkedList<Quest> quests;
|
||||
|
||||
public QuestAcceptPrompt(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
public QuestAcceptPrompt(Quests plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
quests = (LinkedList<Quest>) cc.getSessionData("quests");
|
||||
quester = plugin.getQuester(((Player) cc.getForWhom()).getUniqueId());
|
||||
String npc = (String) cc.getSessionData("npc");
|
||||
String text = Lang.get("questNPCListTitle");
|
||||
text = text.replaceAll("<npc>", npc);
|
||||
String menu = text + "\n";
|
||||
for (int i = 1; i <= quests.size(); i++) {
|
||||
Quest quest = quests.get(i - 1);
|
||||
if (quester.completedQuests.contains(quest.getName())) {
|
||||
menu += ChatColor.DARK_GREEN + "" + ChatColor.BOLD + "" + i + ". " + ChatColor.RESET + "" + ChatColor.GREEN + "" + ChatColor.ITALIC + quest.getName() + ChatColor.RESET + "" + ChatColor.GREEN + " (" + Lang.get("completed") + ")\n";
|
||||
} else {
|
||||
menu += ChatColor.GOLD + "" + ChatColor.BOLD + "" + i + ". " + ChatColor.RESET + "" + ChatColor.YELLOW + "" + ChatColor.ITALIC + quest.getName() + "\n";
|
||||
}
|
||||
}
|
||||
menu += ChatColor.GOLD + "" + ChatColor.BOLD + "" + (quests.size() + 1) + ". " + ChatColor.RESET + "" + ChatColor.GRAY + Lang.get("cancel") + "\n";
|
||||
menu += ChatColor.WHITE + Lang.get("enterAnOption");
|
||||
return menu;
|
||||
}
|
||||
|
||||
quests = (LinkedList<Quest>) cc.getSessionData("quests");
|
||||
quester = plugin.getQuester(((Player) cc.getForWhom()).getUniqueId());
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
int numInput = -1;
|
||||
try {
|
||||
numInput = Integer.parseInt(input);
|
||||
} catch (NumberFormatException e) {
|
||||
// Continue
|
||||
}
|
||||
if (input.equalsIgnoreCase(Lang.get("cancel")) || numInput == (quests.size() + 1)) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("cancelled"));
|
||||
return Prompt.END_OF_CONVERSATION;
|
||||
} else {
|
||||
Quest q = null;
|
||||
for (Quest quest : quests) {
|
||||
if (quest.getName().equalsIgnoreCase(input)) {
|
||||
q = quest;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (q == null) {
|
||||
for (Quest quest : quests) {
|
||||
if (numInput == (quests.indexOf(quest) + 1)) {
|
||||
q = quest;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (q == null) {
|
||||
for (Quest quest : quests) {
|
||||
if (StringUtils.containsIgnoreCase(quest.getName(), input)) {
|
||||
q = quest;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (q == null) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidSelection"));
|
||||
return new QuestAcceptPrompt(plugin);
|
||||
} else {
|
||||
Player player = quester.getPlayer();
|
||||
if (!quester.completedQuests.contains(q.name)) {
|
||||
if (quester.currentQuests.size() < Quests.maxQuests || Quests.maxQuests < 1) {
|
||||
if (q.testRequirements(quester)) {
|
||||
quester.questToTake = q.name;
|
||||
String s = extracted(quester);
|
||||
for (String msg : s.split("<br>")) {
|
||||
player.sendMessage(msg);
|
||||
}
|
||||
plugin.conversationFactory.buildConversation((Conversable) player).begin();
|
||||
} else {
|
||||
player.sendMessage(q.failRequirements);
|
||||
}
|
||||
} else if (quester.currentQuests.containsKey(q) == false) {
|
||||
String msg = Lang.get("questMaxAllowed");
|
||||
msg = msg.replaceAll("<number>", String.valueOf(Quests.maxQuests));
|
||||
player.sendMessage(ChatColor.YELLOW + msg);
|
||||
}
|
||||
} else if (quester.completedQuests.contains(q.name)) {
|
||||
if (quester.currentQuests.size() < Quests.maxQuests || Quests.maxQuests < 1) {
|
||||
if (quester.getDifference(q) > 0) {
|
||||
String early = Lang.get("questTooEarly");
|
||||
early = early.replaceAll("<quest>", ChatColor.AQUA + q.name + ChatColor.YELLOW);
|
||||
early = early.replaceAll("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(q)) + ChatColor.YELLOW);
|
||||
player.sendMessage(ChatColor.YELLOW + early);
|
||||
} else if (q.redoDelay < 0) {
|
||||
String completed = Lang.get("questAlreadyCompleted");
|
||||
completed = completed.replaceAll("<quest>", ChatColor.AQUA + q.name + ChatColor.YELLOW);
|
||||
player.sendMessage(ChatColor.YELLOW + completed);
|
||||
} else {
|
||||
quester.questToTake = q.name;
|
||||
String s = extracted(quester);
|
||||
for (String msg : s.split("<br>")) {
|
||||
player.sendMessage(msg);
|
||||
}
|
||||
plugin.conversationFactory.buildConversation((Conversable) player).begin();
|
||||
}
|
||||
} else if (quester.currentQuests.containsKey(q) == false) {
|
||||
String msg = Lang.get("questMaxAllowed");
|
||||
msg = msg.replaceAll("<number>", String.valueOf(Quests.maxQuests));
|
||||
player.sendMessage(ChatColor.YELLOW + msg);
|
||||
}
|
||||
}
|
||||
return Prompt.END_OF_CONVERSATION;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String npc = (String) cc.getSessionData("npc");
|
||||
String text = Lang.get("questNPCListTitle");
|
||||
text = text.replaceAll("<npc>", npc);
|
||||
String menu = text + "\n";
|
||||
for (int i = 1; i <= quests.size(); i++) {
|
||||
|
||||
Quest quest = quests.get(i - 1);
|
||||
if (quester.completedQuests.contains(quest.getName())) {
|
||||
menu += ChatColor.DARK_GREEN + "" + ChatColor.BOLD + "" + i + ". " + ChatColor.RESET + "" + ChatColor.GREEN + "" + ChatColor.ITALIC + quest.getName() + ChatColor.RESET + "" + ChatColor.GREEN + " (" + Lang.get("completed") + ")\n";
|
||||
} else {
|
||||
menu += ChatColor.GOLD + "" + ChatColor.BOLD + "" + i + ". " + ChatColor.RESET + "" + ChatColor.YELLOW + "" + ChatColor.ITALIC + quest.getName() + "\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
menu += ChatColor.GOLD + "" + ChatColor.BOLD + "" + (quests.size() + 1) + ". " + ChatColor.RESET + "" + ChatColor.GRAY + Lang.get("cancel") + "\n";
|
||||
menu += ChatColor.WHITE + Lang.get("enterAnOption");
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String input) {
|
||||
|
||||
int numInput = -1;
|
||||
try {
|
||||
numInput = Integer.parseInt(input);
|
||||
} catch (NumberFormatException e) {
|
||||
//Continue
|
||||
}
|
||||
|
||||
if (input.equalsIgnoreCase(Lang.get("cancel")) || numInput == (quests.size() + 1)) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("cancelled"));
|
||||
return Prompt.END_OF_CONVERSATION;
|
||||
} else {
|
||||
|
||||
Quest q = null;
|
||||
|
||||
for (Quest quest : quests) {
|
||||
|
||||
if (quest.getName().equalsIgnoreCase(input)) {
|
||||
q = quest;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (q == null) {
|
||||
for (Quest quest : quests) {
|
||||
|
||||
if (numInput == (quests.indexOf(quest) + 1)) {
|
||||
q = quest;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (q == null) {
|
||||
for (Quest quest : quests) {
|
||||
|
||||
if (StringUtils.containsIgnoreCase(quest.getName(), input)) {
|
||||
q = quest;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (q == null) {
|
||||
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("invalidSelection"));
|
||||
return new QuestAcceptPrompt(plugin);
|
||||
} else {
|
||||
|
||||
Player player = quester.getPlayer();
|
||||
|
||||
if (!quester.completedQuests.contains(q.name)) {
|
||||
|
||||
if (quester.currentQuests.size() < Quests.maxQuests || Quests.maxQuests < 1) {
|
||||
|
||||
if (q.testRequirements(quester)) {
|
||||
|
||||
quester.questToTake = q.name;
|
||||
|
||||
String s = extracted(quester);
|
||||
|
||||
for (String msg : s.split("<br>")) {
|
||||
player.sendMessage(msg);
|
||||
}
|
||||
|
||||
plugin.conversationFactory.buildConversation((Conversable) player).begin();
|
||||
|
||||
} else {
|
||||
player.sendMessage(q.failRequirements);
|
||||
}
|
||||
|
||||
} else if (quester.currentQuests.containsKey(q) == false) {
|
||||
|
||||
String msg = Lang.get("questMaxAllowed");
|
||||
msg = msg.replaceAll("<number>", String.valueOf(Quests.maxQuests));
|
||||
player.sendMessage(ChatColor.YELLOW + msg);
|
||||
|
||||
}
|
||||
|
||||
} else if (quester.completedQuests.contains(q.name)) {
|
||||
|
||||
if (quester.currentQuests.size() < Quests.maxQuests || Quests.maxQuests < 1) {
|
||||
|
||||
if (quester.getDifference(q) > 0) {
|
||||
String early = Lang.get("questTooEarly");
|
||||
early = early.replaceAll("<quest>", ChatColor.AQUA + q.name + ChatColor.YELLOW);
|
||||
early = early.replaceAll("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(q)) + ChatColor.YELLOW);
|
||||
player.sendMessage(ChatColor.YELLOW + early);
|
||||
} else if (q.redoDelay < 0) {
|
||||
String completed = Lang.get("questAlreadyCompleted");
|
||||
completed = completed.replaceAll("<quest>", ChatColor.AQUA + q.name + ChatColor.YELLOW);
|
||||
player.sendMessage(ChatColor.YELLOW + completed);
|
||||
} else {
|
||||
quester.questToTake = q.name;
|
||||
String s = extracted(quester);
|
||||
|
||||
for (String msg : s.split("<br>")) {
|
||||
player.sendMessage(msg);
|
||||
}
|
||||
|
||||
plugin.conversationFactory.buildConversation((Conversable) player).begin();
|
||||
}
|
||||
|
||||
} else if (quester.currentQuests.containsKey(q) == false) {
|
||||
|
||||
String msg = Lang.get("questMaxAllowed");
|
||||
msg = msg.replaceAll("<number>", String.valueOf(Quests.maxQuests));
|
||||
player.sendMessage(ChatColor.YELLOW + msg);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Prompt.END_OF_CONVERSATION;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String extracted(final Quester quester) {
|
||||
return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n",
|
||||
ChatColor.GOLD,
|
||||
ChatColor.DARK_PURPLE,
|
||||
quester.questToTake,
|
||||
ChatColor.GOLD,
|
||||
ChatColor.RESET, plugin.getQuest(quester.questToTake).description);
|
||||
}
|
||||
private String extracted(final Quester quester) {
|
||||
return MessageFormat.format("{0}- {1}{2}{3} -\n\n{4}{5}\n", ChatColor.GOLD, ChatColor.DARK_PURPLE, quester.questToTake, ChatColor.GOLD, ChatColor.RESET, plugin.getQuest(quester.questToTake).description);
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -11,279 +11,200 @@ import me.blackvein.quests.util.Lang;
|
||||
|
||||
public class StagesPrompt extends StringPrompt {
|
||||
|
||||
private final QuestFactory questFactory;
|
||||
|
||||
public StagesPrompt(QuestFactory qf) {
|
||||
|
||||
questFactory = qf;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
|
||||
String text = ChatColor.LIGHT_PURPLE + "- " + ChatColor.DARK_PURPLE + Lang.get("stageEditorStages") + ChatColor.LIGHT_PURPLE + " -\n";
|
||||
|
||||
int stages = getStages(cc);
|
||||
|
||||
for (int i = 1; i <= stages; i++) {
|
||||
|
||||
text += ChatColor.BOLD + "" + ChatColor.GREEN + i + ". " + ChatColor.RESET + ChatColor.GOLD + Lang.get("stageEditorEditStage") + " " + i + "\n";
|
||||
|
||||
}
|
||||
|
||||
stages++;
|
||||
text += "\n" + ChatColor.BOLD + "" + ChatColor.GREEN + stages + ". " + ChatColor.RESET + ChatColor.YELLOW + Lang.get("stageEditorNewStage");
|
||||
stages++;
|
||||
text += "\n" + ChatColor.BOLD + "" + ChatColor.BLUE + stages + ". " + ChatColor.RESET + ChatColor.YELLOW + Lang.get("done");
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String string) {
|
||||
|
||||
int i;
|
||||
|
||||
try {
|
||||
|
||||
i = Integer.parseInt(string);
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
return new StagesPrompt(questFactory);
|
||||
}
|
||||
|
||||
int stages = getStages(cc);
|
||||
|
||||
if (i < 0) {
|
||||
return new StagesPrompt(questFactory);
|
||||
} else if (i < (stages + 1) && i > 0) {
|
||||
return new CreateStagePrompt((i), questFactory, questFactory.quests.citizens);
|
||||
} else if (i == (stages + 1)) {
|
||||
return new CreateStagePrompt((stages + 1), questFactory, questFactory.quests.citizens);
|
||||
} else if (i == (stages + 2)) {
|
||||
return questFactory.returnToMenu();
|
||||
} else {
|
||||
return new StagesPrompt(questFactory);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int getStages(ConversationContext cc) {
|
||||
|
||||
int num = 1;
|
||||
|
||||
while (true) {
|
||||
|
||||
if (cc.getSessionData("stage" + num) != null) {
|
||||
num++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return (num - 1);
|
||||
|
||||
}
|
||||
|
||||
public static void deleteStage(ConversationContext cc, int stageNum) {
|
||||
|
||||
int stages = getStages(cc);
|
||||
int current = stageNum;
|
||||
String pref = "stage" + current;
|
||||
String newPref;
|
||||
boolean last = false;
|
||||
|
||||
if (stageNum == stages) {
|
||||
last = true;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
|
||||
if (!last) {
|
||||
|
||||
current++;
|
||||
|
||||
if (current > stages) {
|
||||
break;
|
||||
}
|
||||
|
||||
pref = "stage" + current;
|
||||
newPref = "stage" + (current - 1);
|
||||
|
||||
cc.setSessionData(newPref + CK.S_BREAK_NAMES, cc.getSessionData(pref + CK.S_BREAK_NAMES));
|
||||
cc.setSessionData(newPref + CK.S_BREAK_AMOUNTS, cc.getSessionData(pref + CK.S_BREAK_AMOUNTS));
|
||||
cc.setSessionData(newPref + CK.S_BREAK_DURABILITY, cc.getSessionData(pref + CK.S_BREAK_DURABILITY));
|
||||
|
||||
cc.setSessionData(newPref + CK.S_DAMAGE_NAMES, cc.getSessionData(pref + CK.S_DAMAGE_NAMES));
|
||||
cc.setSessionData(newPref + CK.S_DAMAGE_AMOUNTS, cc.getSessionData(pref + CK.S_DAMAGE_AMOUNTS));
|
||||
cc.setSessionData(newPref + CK.S_DAMAGE_DURABILITY, cc.getSessionData(pref + CK.S_DAMAGE_DURABILITY));
|
||||
|
||||
cc.setSessionData(newPref + CK.S_PLACE_NAMES, cc.getSessionData(pref + CK.S_PLACE_NAMES));
|
||||
cc.setSessionData(newPref + CK.S_PLACE_NAMES, cc.getSessionData(pref + CK.S_PLACE_AMOUNTS));
|
||||
cc.setSessionData(newPref + CK.S_PLACE_DURABILITY, cc.getSessionData(pref + CK.S_PLACE_DURABILITY));
|
||||
|
||||
cc.setSessionData(newPref + CK.S_USE_NAMES, cc.getSessionData(pref + CK.S_USE_NAMES));
|
||||
cc.setSessionData(newPref + CK.S_USE_AMOUNTS, cc.getSessionData(pref + CK.S_USE_AMOUNTS));
|
||||
cc.setSessionData(newPref + CK.S_USE_DURABILITY, cc.getSessionData(pref + CK.S_USE_DURABILITY));
|
||||
|
||||
cc.setSessionData(newPref + CK.S_CUT_NAMES, cc.getSessionData(pref + CK.S_CUT_NAMES));
|
||||
cc.setSessionData(newPref + CK.S_CUT_AMOUNTS, cc.getSessionData(pref + CK.S_CUT_AMOUNTS));
|
||||
cc.setSessionData(newPref + CK.S_CUT_DURABILITY, cc.getSessionData(pref + CK.S_CUT_DURABILITY));
|
||||
|
||||
cc.setSessionData(newPref + CK.S_FISH, cc.getSessionData(pref + CK.S_FISH));
|
||||
|
||||
cc.setSessionData(newPref + CK.S_PLAYER_KILL, cc.getSessionData(pref + CK.S_PLAYER_KILL));
|
||||
|
||||
cc.setSessionData(newPref + CK.S_ENCHANT_TYPES, cc.getSessionData(pref + CK.S_ENCHANT_TYPES));
|
||||
cc.setSessionData(newPref + CK.S_ENCHANT_NAMES, cc.getSessionData(pref + CK.S_ENCHANT_NAMES));
|
||||
cc.setSessionData(newPref + CK.S_ENCHANT_AMOUNTS, cc.getSessionData(pref + CK.S_ENCHANT_AMOUNTS));
|
||||
|
||||
cc.setSessionData(newPref + CK.S_DELIVERY_ITEMS, cc.getSessionData(pref + CK.S_DELIVERY_ITEMS));
|
||||
cc.setSessionData(newPref + CK.S_DELIVERY_NPCS, cc.getSessionData(pref + CK.S_DELIVERY_NPCS));
|
||||
cc.setSessionData(newPref + CK.S_DELIVERY_MESSAGES, cc.getSessionData(pref + CK.S_DELIVERY_MESSAGES));
|
||||
|
||||
cc.setSessionData(newPref + CK.S_NPCS_TO_TALK_TO, cc.getSessionData(pref + CK.S_NPCS_TO_TALK_TO));
|
||||
|
||||
cc.setSessionData(newPref + CK.S_NPCS_TO_KILL, cc.getSessionData(pref + CK.S_NPCS_TO_KILL));
|
||||
cc.setSessionData(newPref + CK.S_NPCS_TO_KILL_AMOUNTS, cc.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS));
|
||||
|
||||
cc.setSessionData(newPref + CK.S_MOB_TYPES, cc.getSessionData(pref + CK.S_MOB_TYPES));
|
||||
cc.setSessionData(newPref + CK.S_MOB_AMOUNTS, cc.getSessionData(pref + CK.S_MOB_AMOUNTS));
|
||||
cc.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS, cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS));
|
||||
cc.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS_RADIUS, cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS));
|
||||
cc.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS_NAMES, cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES));
|
||||
|
||||
cc.setSessionData(newPref + CK.S_REACH_LOCATIONS, cc.getSessionData(pref + CK.S_REACH_LOCATIONS));
|
||||
cc.setSessionData(newPref + CK.S_REACH_LOCATIONS_RADIUS, cc.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS));
|
||||
cc.setSessionData(newPref + CK.S_REACH_LOCATIONS_NAMES, cc.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES));
|
||||
|
||||
cc.setSessionData(newPref + CK.S_TAME_TYPES, cc.getSessionData(pref + CK.S_TAME_TYPES));
|
||||
cc.setSessionData(newPref + CK.S_TAME_AMOUNTS, cc.getSessionData(pref + CK.S_TAME_AMOUNTS));
|
||||
|
||||
cc.setSessionData(newPref + CK.S_SHEAR_COLORS, cc.getSessionData(pref + CK.S_SHEAR_COLORS));
|
||||
cc.setSessionData(newPref + CK.S_SHEAR_AMOUNTS, cc.getSessionData(pref + CK.S_SHEAR_AMOUNTS));
|
||||
|
||||
cc.setSessionData(newPref + CK.S_START_EVENT, cc.getSessionData(pref + CK.S_START_EVENT));
|
||||
cc.setSessionData(newPref + CK.S_DISCONNECT_EVENT, cc.getSessionData(pref + CK.S_DISCONNECT_EVENT));
|
||||
cc.setSessionData(newPref + CK.S_DEATH_EVENT, cc.getSessionData(pref + CK.S_DEATH_EVENT));
|
||||
cc.setSessionData(newPref + CK.S_CHAT_EVENTS, cc.getSessionData(pref + CK.S_CHAT_EVENTS));
|
||||
cc.setSessionData(newPref + CK.S_CHAT_EVENT_TRIGGERS, cc.getSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS));
|
||||
cc.setSessionData(newPref + CK.S_FINISH_EVENT, cc.getSessionData(pref + CK.S_FINISH_EVENT));
|
||||
|
||||
cc.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES, cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES));
|
||||
cc.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_DATA, cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT));
|
||||
cc.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_COUNT, cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT));
|
||||
cc.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS));
|
||||
cc.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP, cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP));
|
||||
|
||||
cc.setSessionData(newPref + CK.S_PASSWORD_DISPLAYS, cc.getSessionData(pref + CK.S_PASSWORD_DISPLAYS));
|
||||
cc.setSessionData(newPref + CK.S_PASSWORD_PHRASES, cc.getSessionData(pref + CK.S_PASSWORD_PHRASES));
|
||||
|
||||
cc.setSessionData(newPref + CK.S_OVERRIDE_DISPLAY, cc.getSessionData(pref + CK.S_OVERRIDE_DISPLAY));
|
||||
|
||||
cc.setSessionData(newPref + CK.S_DELAY, cc.getSessionData(pref + CK.S_DELAY));
|
||||
cc.setSessionData(newPref + CK.S_DELAY_MESSAGE, cc.getSessionData(pref + CK.S_DELAY_MESSAGE));
|
||||
|
||||
cc.setSessionData(newPref + CK.S_DENIZEN, cc.getSessionData(pref + CK.S_DENIZEN));
|
||||
|
||||
cc.setSessionData(newPref + CK.S_COMPLETE_MESSAGE, cc.getSessionData(pref + CK.S_COMPLETE_MESSAGE));
|
||||
cc.setSessionData(newPref + CK.S_START_MESSAGE, cc.getSessionData(pref + CK.S_START_MESSAGE));
|
||||
|
||||
}
|
||||
|
||||
cc.setSessionData(pref + CK.S_BREAK_NAMES, null);
|
||||
cc.setSessionData(pref + CK.S_BREAK_AMOUNTS, null);
|
||||
cc.setSessionData(pref + CK.S_BREAK_DURABILITY, null);
|
||||
|
||||
cc.setSessionData(pref + CK.S_DAMAGE_NAMES, null);
|
||||
cc.setSessionData(pref + CK.S_DAMAGE_AMOUNTS, null);
|
||||
cc.setSessionData(pref + CK.S_DAMAGE_DURABILITY, null);
|
||||
|
||||
cc.setSessionData(pref + CK.S_PLACE_NAMES, null);
|
||||
cc.setSessionData(pref + CK.S_PLACE_AMOUNTS, null);
|
||||
cc.setSessionData(pref + CK.S_PLACE_DURABILITY, null);
|
||||
|
||||
cc.setSessionData(pref + CK.S_USE_NAMES, null);
|
||||
cc.setSessionData(pref + CK.S_USE_AMOUNTS, null);
|
||||
cc.setSessionData(pref + CK.S_USE_DURABILITY, null);
|
||||
|
||||
cc.setSessionData(pref + CK.S_CUT_NAMES, null);
|
||||
cc.setSessionData(pref + CK.S_CUT_AMOUNTS, null);
|
||||
cc.setSessionData(pref + CK.S_CUT_DURABILITY, null);
|
||||
|
||||
cc.setSessionData(pref + CK.S_FISH, null);
|
||||
|
||||
cc.setSessionData(pref + CK.S_PLAYER_KILL, null);
|
||||
|
||||
cc.setSessionData(pref + CK.S_ENCHANT_TYPES, null);
|
||||
cc.setSessionData(pref + CK.S_ENCHANT_NAMES, null);
|
||||
cc.setSessionData(pref + CK.S_ENCHANT_AMOUNTS, null);
|
||||
|
||||
cc.setSessionData(pref + CK.S_DELIVERY_ITEMS, null);
|
||||
cc.setSessionData(pref + CK.S_DELIVERY_NPCS, null);
|
||||
cc.setSessionData(pref + CK.S_DELIVERY_MESSAGES, null);
|
||||
|
||||
cc.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, null);
|
||||
|
||||
cc.setSessionData(pref + CK.S_NPCS_TO_KILL, null);
|
||||
cc.setSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS, null);
|
||||
|
||||
cc.setSessionData(pref + CK.S_MOB_TYPES, null);
|
||||
cc.setSessionData(pref + CK.S_MOB_AMOUNTS, null);
|
||||
cc.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS, null);
|
||||
cc.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS, null);
|
||||
cc.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES, null);
|
||||
|
||||
cc.setSessionData(pref + CK.S_REACH_LOCATIONS, null);
|
||||
cc.setSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS, null);
|
||||
cc.setSessionData(pref + CK.S_REACH_LOCATIONS_NAMES, null);
|
||||
|
||||
cc.setSessionData(pref + CK.S_TAME_TYPES, null);
|
||||
cc.setSessionData(pref + CK.S_TAME_AMOUNTS, null);
|
||||
|
||||
cc.setSessionData(pref + CK.S_SHEAR_COLORS, null);
|
||||
cc.setSessionData(pref + CK.S_SHEAR_AMOUNTS, null);
|
||||
|
||||
cc.setSessionData(pref + CK.S_FINISH_EVENT, null);
|
||||
cc.setSessionData(pref + CK.S_START_EVENT, null);
|
||||
cc.setSessionData(pref + CK.S_DEATH_EVENT, null);
|
||||
cc.setSessionData(pref + CK.S_CHAT_EVENTS, null);
|
||||
cc.setSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS, null);
|
||||
cc.setSessionData(pref + CK.S_DISCONNECT_EVENT, null);
|
||||
|
||||
cc.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES, null);
|
||||
cc.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA, null);
|
||||
cc.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT, null);
|
||||
cc.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, null);
|
||||
cc.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP, null);
|
||||
|
||||
cc.setSessionData(pref + CK.S_PASSWORD_DISPLAYS, null);
|
||||
cc.setSessionData(pref + CK.S_PASSWORD_PHRASES, null);
|
||||
|
||||
cc.setSessionData(pref + CK.S_OVERRIDE_DISPLAY, null);
|
||||
|
||||
cc.setSessionData(pref + CK.S_DELAY, null);
|
||||
cc.setSessionData(pref + CK.S_DELAY_MESSAGE, null);
|
||||
|
||||
cc.setSessionData(pref + CK.S_DENIZEN, null);
|
||||
|
||||
cc.setSessionData(pref + CK.S_COMPLETE_MESSAGE, null);
|
||||
cc.setSessionData(pref + CK.S_START_MESSAGE, null);
|
||||
|
||||
if (last) {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!last) {
|
||||
cc.setSessionData("stage" + (current - 1), null);
|
||||
} else {
|
||||
cc.setSessionData("stage" + (current), null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final QuestFactory questFactory;
|
||||
|
||||
public StagesPrompt(QuestFactory qf) {
|
||||
questFactory = qf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPromptText(ConversationContext cc) {
|
||||
String text = ChatColor.LIGHT_PURPLE + "- " + ChatColor.DARK_PURPLE + Lang.get("stageEditorStages") + ChatColor.LIGHT_PURPLE + " -\n";
|
||||
int stages = getStages(cc);
|
||||
for (int i = 1; i <= stages; i++) {
|
||||
text += ChatColor.BOLD + "" + ChatColor.GREEN + i + ". " + ChatColor.RESET + ChatColor.GOLD + Lang.get("stageEditorEditStage") + " " + i + "\n";
|
||||
}
|
||||
stages++;
|
||||
text += "\n" + ChatColor.BOLD + "" + ChatColor.GREEN + stages + ". " + ChatColor.RESET + ChatColor.YELLOW + Lang.get("stageEditorNewStage");
|
||||
stages++;
|
||||
text += "\n" + ChatColor.BOLD + "" + ChatColor.BLUE + stages + ". " + ChatColor.RESET + ChatColor.YELLOW + Lang.get("done");
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Prompt acceptInput(ConversationContext cc, String string) {
|
||||
int i;
|
||||
try {
|
||||
i = Integer.parseInt(string);
|
||||
} catch (NumberFormatException e) {
|
||||
return new StagesPrompt(questFactory);
|
||||
}
|
||||
int stages = getStages(cc);
|
||||
if (i < 0) {
|
||||
return new StagesPrompt(questFactory);
|
||||
} else if (i < (stages + 1) && i > 0) {
|
||||
return new CreateStagePrompt((i), questFactory, questFactory.quests.citizens);
|
||||
} else if (i == (stages + 1)) {
|
||||
return new CreateStagePrompt((stages + 1), questFactory, questFactory.quests.citizens);
|
||||
} else if (i == (stages + 2)) {
|
||||
return questFactory.returnToMenu();
|
||||
} else {
|
||||
return new StagesPrompt(questFactory);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getStages(ConversationContext cc) {
|
||||
int num = 1;
|
||||
while (true) {
|
||||
if (cc.getSessionData("stage" + num) != null) {
|
||||
num++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (num - 1);
|
||||
}
|
||||
|
||||
public static void deleteStage(ConversationContext cc, int stageNum) {
|
||||
int stages = getStages(cc);
|
||||
int current = stageNum;
|
||||
String pref = "stage" + current;
|
||||
String newPref;
|
||||
boolean last = false;
|
||||
if (stageNum == stages) {
|
||||
last = true;
|
||||
}
|
||||
while (true) {
|
||||
if (!last) {
|
||||
current++;
|
||||
if (current > stages) {
|
||||
break;
|
||||
}
|
||||
pref = "stage" + current;
|
||||
newPref = "stage" + (current - 1);
|
||||
cc.setSessionData(newPref + CK.S_BREAK_NAMES, cc.getSessionData(pref + CK.S_BREAK_NAMES));
|
||||
cc.setSessionData(newPref + CK.S_BREAK_AMOUNTS, cc.getSessionData(pref + CK.S_BREAK_AMOUNTS));
|
||||
cc.setSessionData(newPref + CK.S_BREAK_DURABILITY, cc.getSessionData(pref + CK.S_BREAK_DURABILITY));
|
||||
cc.setSessionData(newPref + CK.S_DAMAGE_NAMES, cc.getSessionData(pref + CK.S_DAMAGE_NAMES));
|
||||
cc.setSessionData(newPref + CK.S_DAMAGE_AMOUNTS, cc.getSessionData(pref + CK.S_DAMAGE_AMOUNTS));
|
||||
cc.setSessionData(newPref + CK.S_DAMAGE_DURABILITY, cc.getSessionData(pref + CK.S_DAMAGE_DURABILITY));
|
||||
cc.setSessionData(newPref + CK.S_PLACE_NAMES, cc.getSessionData(pref + CK.S_PLACE_NAMES));
|
||||
cc.setSessionData(newPref + CK.S_PLACE_NAMES, cc.getSessionData(pref + CK.S_PLACE_AMOUNTS));
|
||||
cc.setSessionData(newPref + CK.S_PLACE_DURABILITY, cc.getSessionData(pref + CK.S_PLACE_DURABILITY));
|
||||
cc.setSessionData(newPref + CK.S_USE_NAMES, cc.getSessionData(pref + CK.S_USE_NAMES));
|
||||
cc.setSessionData(newPref + CK.S_USE_AMOUNTS, cc.getSessionData(pref + CK.S_USE_AMOUNTS));
|
||||
cc.setSessionData(newPref + CK.S_USE_DURABILITY, cc.getSessionData(pref + CK.S_USE_DURABILITY));
|
||||
cc.setSessionData(newPref + CK.S_CUT_NAMES, cc.getSessionData(pref + CK.S_CUT_NAMES));
|
||||
cc.setSessionData(newPref + CK.S_CUT_AMOUNTS, cc.getSessionData(pref + CK.S_CUT_AMOUNTS));
|
||||
cc.setSessionData(newPref + CK.S_CUT_DURABILITY, cc.getSessionData(pref + CK.S_CUT_DURABILITY));
|
||||
cc.setSessionData(newPref + CK.S_FISH, cc.getSessionData(pref + CK.S_FISH));
|
||||
cc.setSessionData(newPref + CK.S_PLAYER_KILL, cc.getSessionData(pref + CK.S_PLAYER_KILL));
|
||||
cc.setSessionData(newPref + CK.S_ENCHANT_TYPES, cc.getSessionData(pref + CK.S_ENCHANT_TYPES));
|
||||
cc.setSessionData(newPref + CK.S_ENCHANT_NAMES, cc.getSessionData(pref + CK.S_ENCHANT_NAMES));
|
||||
cc.setSessionData(newPref + CK.S_ENCHANT_AMOUNTS, cc.getSessionData(pref + CK.S_ENCHANT_AMOUNTS));
|
||||
cc.setSessionData(newPref + CK.S_DELIVERY_ITEMS, cc.getSessionData(pref + CK.S_DELIVERY_ITEMS));
|
||||
cc.setSessionData(newPref + CK.S_DELIVERY_NPCS, cc.getSessionData(pref + CK.S_DELIVERY_NPCS));
|
||||
cc.setSessionData(newPref + CK.S_DELIVERY_MESSAGES, cc.getSessionData(pref + CK.S_DELIVERY_MESSAGES));
|
||||
cc.setSessionData(newPref + CK.S_NPCS_TO_TALK_TO, cc.getSessionData(pref + CK.S_NPCS_TO_TALK_TO));
|
||||
cc.setSessionData(newPref + CK.S_NPCS_TO_KILL, cc.getSessionData(pref + CK.S_NPCS_TO_KILL));
|
||||
cc.setSessionData(newPref + CK.S_NPCS_TO_KILL_AMOUNTS, cc.getSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS));
|
||||
cc.setSessionData(newPref + CK.S_MOB_TYPES, cc.getSessionData(pref + CK.S_MOB_TYPES));
|
||||
cc.setSessionData(newPref + CK.S_MOB_AMOUNTS, cc.getSessionData(pref + CK.S_MOB_AMOUNTS));
|
||||
cc.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS, cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS));
|
||||
cc.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS_RADIUS, cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS));
|
||||
cc.setSessionData(newPref + CK.S_MOB_KILL_LOCATIONS_NAMES, cc.getSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES));
|
||||
cc.setSessionData(newPref + CK.S_REACH_LOCATIONS, cc.getSessionData(pref + CK.S_REACH_LOCATIONS));
|
||||
cc.setSessionData(newPref + CK.S_REACH_LOCATIONS_RADIUS, cc.getSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS));
|
||||
cc.setSessionData(newPref + CK.S_REACH_LOCATIONS_NAMES, cc.getSessionData(pref + CK.S_REACH_LOCATIONS_NAMES));
|
||||
cc.setSessionData(newPref + CK.S_TAME_TYPES, cc.getSessionData(pref + CK.S_TAME_TYPES));
|
||||
cc.setSessionData(newPref + CK.S_TAME_AMOUNTS, cc.getSessionData(pref + CK.S_TAME_AMOUNTS));
|
||||
cc.setSessionData(newPref + CK.S_SHEAR_COLORS, cc.getSessionData(pref + CK.S_SHEAR_COLORS));
|
||||
cc.setSessionData(newPref + CK.S_SHEAR_AMOUNTS, cc.getSessionData(pref + CK.S_SHEAR_AMOUNTS));
|
||||
cc.setSessionData(newPref + CK.S_START_EVENT, cc.getSessionData(pref + CK.S_START_EVENT));
|
||||
cc.setSessionData(newPref + CK.S_DISCONNECT_EVENT, cc.getSessionData(pref + CK.S_DISCONNECT_EVENT));
|
||||
cc.setSessionData(newPref + CK.S_DEATH_EVENT, cc.getSessionData(pref + CK.S_DEATH_EVENT));
|
||||
cc.setSessionData(newPref + CK.S_CHAT_EVENTS, cc.getSessionData(pref + CK.S_CHAT_EVENTS));
|
||||
cc.setSessionData(newPref + CK.S_CHAT_EVENT_TRIGGERS, cc.getSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS));
|
||||
cc.setSessionData(newPref + CK.S_FINISH_EVENT, cc.getSessionData(pref + CK.S_FINISH_EVENT));
|
||||
cc.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES, cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES));
|
||||
cc.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_DATA, cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT));
|
||||
cc.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_COUNT, cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT));
|
||||
cc.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS));
|
||||
cc.setSessionData(newPref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP, cc.getSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP));
|
||||
cc.setSessionData(newPref + CK.S_PASSWORD_DISPLAYS, cc.getSessionData(pref + CK.S_PASSWORD_DISPLAYS));
|
||||
cc.setSessionData(newPref + CK.S_PASSWORD_PHRASES, cc.getSessionData(pref + CK.S_PASSWORD_PHRASES));
|
||||
cc.setSessionData(newPref + CK.S_OVERRIDE_DISPLAY, cc.getSessionData(pref + CK.S_OVERRIDE_DISPLAY));
|
||||
cc.setSessionData(newPref + CK.S_DELAY, cc.getSessionData(pref + CK.S_DELAY));
|
||||
cc.setSessionData(newPref + CK.S_DELAY_MESSAGE, cc.getSessionData(pref + CK.S_DELAY_MESSAGE));
|
||||
cc.setSessionData(newPref + CK.S_DENIZEN, cc.getSessionData(pref + CK.S_DENIZEN));
|
||||
cc.setSessionData(newPref + CK.S_COMPLETE_MESSAGE, cc.getSessionData(pref + CK.S_COMPLETE_MESSAGE));
|
||||
cc.setSessionData(newPref + CK.S_START_MESSAGE, cc.getSessionData(pref + CK.S_START_MESSAGE));
|
||||
}
|
||||
cc.setSessionData(pref + CK.S_BREAK_NAMES, null);
|
||||
cc.setSessionData(pref + CK.S_BREAK_AMOUNTS, null);
|
||||
cc.setSessionData(pref + CK.S_BREAK_DURABILITY, null);
|
||||
cc.setSessionData(pref + CK.S_DAMAGE_NAMES, null);
|
||||
cc.setSessionData(pref + CK.S_DAMAGE_AMOUNTS, null);
|
||||
cc.setSessionData(pref + CK.S_DAMAGE_DURABILITY, null);
|
||||
cc.setSessionData(pref + CK.S_PLACE_NAMES, null);
|
||||
cc.setSessionData(pref + CK.S_PLACE_AMOUNTS, null);
|
||||
cc.setSessionData(pref + CK.S_PLACE_DURABILITY, null);
|
||||
cc.setSessionData(pref + CK.S_USE_NAMES, null);
|
||||
cc.setSessionData(pref + CK.S_USE_AMOUNTS, null);
|
||||
cc.setSessionData(pref + CK.S_USE_DURABILITY, null);
|
||||
cc.setSessionData(pref + CK.S_CUT_NAMES, null);
|
||||
cc.setSessionData(pref + CK.S_CUT_AMOUNTS, null);
|
||||
cc.setSessionData(pref + CK.S_CUT_DURABILITY, null);
|
||||
cc.setSessionData(pref + CK.S_FISH, null);
|
||||
cc.setSessionData(pref + CK.S_PLAYER_KILL, null);
|
||||
cc.setSessionData(pref + CK.S_ENCHANT_TYPES, null);
|
||||
cc.setSessionData(pref + CK.S_ENCHANT_NAMES, null);
|
||||
cc.setSessionData(pref + CK.S_ENCHANT_AMOUNTS, null);
|
||||
cc.setSessionData(pref + CK.S_DELIVERY_ITEMS, null);
|
||||
cc.setSessionData(pref + CK.S_DELIVERY_NPCS, null);
|
||||
cc.setSessionData(pref + CK.S_DELIVERY_MESSAGES, null);
|
||||
cc.setSessionData(pref + CK.S_NPCS_TO_TALK_TO, null);
|
||||
cc.setSessionData(pref + CK.S_NPCS_TO_KILL, null);
|
||||
cc.setSessionData(pref + CK.S_NPCS_TO_KILL_AMOUNTS, null);
|
||||
cc.setSessionData(pref + CK.S_MOB_TYPES, null);
|
||||
cc.setSessionData(pref + CK.S_MOB_AMOUNTS, null);
|
||||
cc.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS, null);
|
||||
cc.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_RADIUS, null);
|
||||
cc.setSessionData(pref + CK.S_MOB_KILL_LOCATIONS_NAMES, null);
|
||||
cc.setSessionData(pref + CK.S_REACH_LOCATIONS, null);
|
||||
cc.setSessionData(pref + CK.S_REACH_LOCATIONS_RADIUS, null);
|
||||
cc.setSessionData(pref + CK.S_REACH_LOCATIONS_NAMES, null);
|
||||
cc.setSessionData(pref + CK.S_TAME_TYPES, null);
|
||||
cc.setSessionData(pref + CK.S_TAME_AMOUNTS, null);
|
||||
cc.setSessionData(pref + CK.S_SHEAR_COLORS, null);
|
||||
cc.setSessionData(pref + CK.S_SHEAR_AMOUNTS, null);
|
||||
cc.setSessionData(pref + CK.S_FINISH_EVENT, null);
|
||||
cc.setSessionData(pref + CK.S_START_EVENT, null);
|
||||
cc.setSessionData(pref + CK.S_DEATH_EVENT, null);
|
||||
cc.setSessionData(pref + CK.S_CHAT_EVENTS, null);
|
||||
cc.setSessionData(pref + CK.S_CHAT_EVENT_TRIGGERS, null);
|
||||
cc.setSessionData(pref + CK.S_DISCONNECT_EVENT, null);
|
||||
cc.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES, null);
|
||||
cc.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA, null);
|
||||
cc.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_COUNT, null);
|
||||
cc.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS, null);
|
||||
cc.setSessionData(pref + CK.S_CUSTOM_OBJECTIVES_DATA_TEMP, null);
|
||||
cc.setSessionData(pref + CK.S_PASSWORD_DISPLAYS, null);
|
||||
cc.setSessionData(pref + CK.S_PASSWORD_PHRASES, null);
|
||||
cc.setSessionData(pref + CK.S_OVERRIDE_DISPLAY, null);
|
||||
cc.setSessionData(pref + CK.S_DELAY, null);
|
||||
cc.setSessionData(pref + CK.S_DELAY_MESSAGE, null);
|
||||
cc.setSessionData(pref + CK.S_DENIZEN, null);
|
||||
cc.setSessionData(pref + CK.S_COMPLETE_MESSAGE, null);
|
||||
cc.setSessionData(pref + CK.S_START_MESSAGE, null);
|
||||
if (last) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!last) {
|
||||
cc.setSessionData("stage" + (current - 1), null);
|
||||
} else {
|
||||
cc.setSessionData("stage" + (current), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,142 +2,136 @@ package me.blackvein.quests.util;
|
||||
|
||||
public class CK {
|
||||
|
||||
public static final String ED_QUEST_EDIT = "edit";
|
||||
public static final String ED_QUEST_DELETE = "delQuest";
|
||||
public static final String ED_EVENT_DELETE = "delEvent";
|
||||
|
||||
//Quests
|
||||
public static final String Q_NAME = "questName";
|
||||
public static final String Q_ASK_MESSAGE = "askMessage";
|
||||
public static final String Q_FINISH_MESSAGE = "finishMessage";
|
||||
public static final String Q_REDO_DELAY = "redoDelay";
|
||||
public static final String Q_START_NPC = "npcStart";
|
||||
public static final String Q_START_BLOCK = "blockStart";
|
||||
public static final String Q_FAIL_MESSAGE = "failMessage";
|
||||
public static final String Q_INITIAL_EVENT = "initialEvent";
|
||||
public static final String Q_REGION = "region";
|
||||
public static final String Q_GUIDISPLAY = "guiDisplay";
|
||||
|
||||
//Requirements
|
||||
public static final String REQ_MONEY = "moneyReq";
|
||||
public static final String REQ_QUEST_POINTS = "questPointsReq";
|
||||
public static final String REQ_ITEMS = "itemReqs";
|
||||
public static final String REQ_ITEMS_REMOVE = "removeItemReqs";
|
||||
public static final String REQ_PERMISSION = "permissionReqs";
|
||||
public static final String REQ_MCMMO_SKILLS = "mcMMOSkillReqs";
|
||||
public static final String REQ_MCMMO_SKILL_AMOUNTS = "mcMMOSkillAmountReqs";
|
||||
public static final String REQ_HEROES_PRIMARY_CLASS = "heroesPrimaryClassReq";
|
||||
public static final String REQ_HEROES_SECONDARY_CLASS = "heroesSecondaryClassReq";
|
||||
public static final String REQ_QUEST = "questReqs";
|
||||
public static final String REQ_QUEST_BLOCK = "questBlocks";
|
||||
public static final String REQ_CUSTOM = "customReqs";
|
||||
public static final String REQ_CUSTOM_DATA = "customReqData";
|
||||
public static final String REQ_CUSTOM_DATA_DESCRIPTIONS = "customReqDataDesc";
|
||||
public static final String REQ_CUSTOM_DATA_TEMP = "customReqDataTemp";
|
||||
|
||||
//Rewards
|
||||
public static final String REW_MONEY = "moneyRew";
|
||||
public static final String REW_QUEST_POINTS = "questPointsRew";
|
||||
public static final String REW_ITEMS = "itemRews";
|
||||
public static final String REW_EXP = "expRew";
|
||||
public static final String REW_COMMAND = "commandRews";
|
||||
public static final String REW_PERMISSION = "permissionRews";
|
||||
public static final String REW_MCMMO_SKILLS = "mcMMOSkillRews";
|
||||
public static final String REW_MCMMO_AMOUNTS = "mcMMOSkillAmounts";
|
||||
public static final String REW_HEROES_CLASSES = "heroesClassRews";
|
||||
public static final String REW_HEROES_AMOUNTS = "heroesAmountRews";
|
||||
public static final String REW_PHAT_LOOTS = "phatLootRews";
|
||||
public static final String REW_CUSTOM = "customRews";
|
||||
public static final String REW_CUSTOM_DATA = "customRewData";
|
||||
public static final String REW_CUSTOM_DATA_DESCRIPTIONS = "customRewDataDesc";
|
||||
public static final String REW_CUSTOM_DATA_TEMP = "customRewDataTemp";
|
||||
//Stages
|
||||
public static final String S_BREAK_NAMES = "breakNames";
|
||||
public static final String S_BREAK_AMOUNTS = "breakAmounts";
|
||||
public static final String S_BREAK_DURABILITY = "breakDurability";
|
||||
public static final String S_DAMAGE_NAMES = "damageNames";
|
||||
public static final String S_DAMAGE_AMOUNTS = "damageAmounts";
|
||||
public static final String S_DAMAGE_DURABILITY = "damageDurability";
|
||||
public static final String S_PLACE_NAMES = "placeNames";
|
||||
public static final String S_PLACE_AMOUNTS = "placeAmounts";
|
||||
public static final String S_PLACE_DURABILITY = "placeDurability";
|
||||
public static final String S_USE_NAMES = "useNames";
|
||||
public static final String S_USE_AMOUNTS = "useAmounts";
|
||||
public static final String S_USE_DURABILITY = "useDurability";
|
||||
public static final String S_CUT_NAMES = "cutNames";
|
||||
public static final String S_CUT_AMOUNTS = "cutAmounts";
|
||||
public static final String S_CUT_DURABILITY = "cutDurability";
|
||||
public static final String S_FISH = "fish";
|
||||
public static final String S_PLAYER_KILL = "playerKill";
|
||||
public static final String S_ENCHANT_TYPES = "enchantTypes";
|
||||
public static final String S_ENCHANT_NAMES = "enchantNames";
|
||||
public static final String S_ENCHANT_AMOUNTS = "enchantAmounts";
|
||||
public static final String S_DELIVERY_ITEMS = "deliveryItems";
|
||||
public static final String S_DELIVERY_NPCS = "deliveryNPCs";
|
||||
public static final String S_DELIVERY_MESSAGES = "deliveryMessages";
|
||||
public static final String S_NPCS_TO_TALK_TO = "npcIdsToTalkTo";
|
||||
public static final String S_NPCS_TO_KILL = "npcIdsToKill";
|
||||
public static final String S_NPCS_TO_KILL_AMOUNTS = "npcAmountsToKill";
|
||||
public static final String S_MOB_TYPES = "mobTypes";
|
||||
public static final String S_MOB_AMOUNTS = "mobAmounts";
|
||||
public static final String S_MOB_KILL_LOCATIONS = "killLocations";
|
||||
public static final String S_MOB_KILL_LOCATIONS_RADIUS = "killLocationRadii";
|
||||
public static final String S_MOB_KILL_LOCATIONS_NAMES = "killLocationNames";
|
||||
public static final String S_REACH_LOCATIONS = "reachLocations";
|
||||
public static final String S_REACH_LOCATIONS_RADIUS = "reachLocationRadii";
|
||||
public static final String S_REACH_LOCATIONS_NAMES = "reachLocationNames";
|
||||
public static final String S_TAME_TYPES = "tameTypes";
|
||||
public static final String S_TAME_AMOUNTS = "tameAmounts";
|
||||
public static final String S_SHEAR_COLORS = "shearColors";
|
||||
public static final String S_SHEAR_AMOUNTS = "shearAmounts";
|
||||
public static final String S_START_EVENT = "startEvent";
|
||||
public static final String S_FINISH_EVENT = "finishEvent";
|
||||
public static final String S_CHAT_EVENTS = "chatEvents";
|
||||
public static final String S_CHAT_EVENT_TRIGGERS = "chatEventTriggers";
|
||||
public static final String S_CHAT_TEMP_EVENT = "chatTempEvent";
|
||||
public static final String S_DEATH_EVENT = "deathEvent";
|
||||
public static final String S_DISCONNECT_EVENT = "disconnectEvent";
|
||||
public static final String S_DELAY = "delay";
|
||||
public static final String S_DELAY_MESSAGE = "delayMessage";
|
||||
public static final String S_DENIZEN = "denizen";
|
||||
public static final String S_COMPLETE_MESSAGE = "completeMessage";
|
||||
public static final String S_START_MESSAGE = "startMessage";
|
||||
public static final String S_OVERRIDE_DISPLAY = "overrideDisplay";
|
||||
public static final String S_PASSWORD_DISPLAYS = "passwordDisplays";
|
||||
public static final String S_PASSWORD_PHRASES = "passwordPhrases";
|
||||
public static final String S_CUSTOM_OBJECTIVES = "customObjectives";
|
||||
public static final String S_CUSTOM_OBJECTIVES_COUNT = "customObjectiveCounts";
|
||||
public static final String S_CUSTOM_OBJECTIVES_DATA = "customObjectiveData";
|
||||
public static final String S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS = "customObjectiveDataDescriptions";
|
||||
public static final String S_CUSTOM_OBJECTIVES_DATA_TEMP = "customObjectiveDataTemp";
|
||||
|
||||
//Events
|
||||
public static final String E_OLD_EVENT = "oldEvent";
|
||||
public static final String E_NAME = "evtName";
|
||||
public static final String E_MESSAGE = "evtMessage";
|
||||
public static final String E_CLEAR_INVENTORY = "evtClearInv";
|
||||
public static final String E_FAIL_QUEST = "evtFailQuest";
|
||||
public static final String E_ITEMS = "evtItems";
|
||||
public static final String E_ITEMS_AMOUNTS = "evtItemAmounts";
|
||||
public static final String E_EXPLOSIONS = "evtExplosions";
|
||||
public static final String E_EFFECTS = "evtEffects";
|
||||
public static final String E_EFFECTS_LOCATIONS = "evtEffectLocations";
|
||||
public static final String E_WORLD_STORM = "evtStormWorld";
|
||||
public static final String E_WORLD_STORM_DURATION = "evtStormDuration";
|
||||
public static final String E_WORLD_THUNDER = "evtThunderWorld";
|
||||
public static final String E_WORLD_THUNDER_DURATION = "evtThunderDuration";
|
||||
public static final String E_MOB_TYPES = "evtMobTypes";
|
||||
public static final String E_LIGHTNING = "evtLightningStrikes";
|
||||
public static final String E_POTION_TYPES = "evtPotionTypes";
|
||||
public static final String E_POTION_DURATIONS = "evtPotionDurations";
|
||||
public static final String E_POTION_STRENGHT = "evtPotionMagnitudes";
|
||||
public static final String E_HUNGER = "evtHunger";
|
||||
public static final String E_SATURATION = "evtSaturation";
|
||||
public static final String E_HEALTH = "evtHealth";
|
||||
public static final String E_TELEPORT = "evtTeleportLocation";
|
||||
public static final String E_COMMANDS = "evtCommands";
|
||||
|
||||
//Party
|
||||
public static final String P_INVITER = "inviter";
|
||||
|
||||
public static final String ED_QUEST_EDIT = "edit";
|
||||
public static final String ED_QUEST_DELETE = "delQuest";
|
||||
public static final String ED_EVENT_DELETE = "delEvent";
|
||||
// Quests
|
||||
public static final String Q_NAME = "questName";
|
||||
public static final String Q_ASK_MESSAGE = "askMessage";
|
||||
public static final String Q_FINISH_MESSAGE = "finishMessage";
|
||||
public static final String Q_REDO_DELAY = "redoDelay";
|
||||
public static final String Q_START_NPC = "npcStart";
|
||||
public static final String Q_START_BLOCK = "blockStart";
|
||||
public static final String Q_FAIL_MESSAGE = "failMessage";
|
||||
public static final String Q_INITIAL_EVENT = "initialEvent";
|
||||
public static final String Q_REGION = "region";
|
||||
public static final String Q_GUIDISPLAY = "guiDisplay";
|
||||
// Requirements
|
||||
public static final String REQ_MONEY = "moneyReq";
|
||||
public static final String REQ_QUEST_POINTS = "questPointsReq";
|
||||
public static final String REQ_ITEMS = "itemReqs";
|
||||
public static final String REQ_ITEMS_REMOVE = "removeItemReqs";
|
||||
public static final String REQ_PERMISSION = "permissionReqs";
|
||||
public static final String REQ_MCMMO_SKILLS = "mcMMOSkillReqs";
|
||||
public static final String REQ_MCMMO_SKILL_AMOUNTS = "mcMMOSkillAmountReqs";
|
||||
public static final String REQ_HEROES_PRIMARY_CLASS = "heroesPrimaryClassReq";
|
||||
public static final String REQ_HEROES_SECONDARY_CLASS = "heroesSecondaryClassReq";
|
||||
public static final String REQ_QUEST = "questReqs";
|
||||
public static final String REQ_QUEST_BLOCK = "questBlocks";
|
||||
public static final String REQ_CUSTOM = "customReqs";
|
||||
public static final String REQ_CUSTOM_DATA = "customReqData";
|
||||
public static final String REQ_CUSTOM_DATA_DESCRIPTIONS = "customReqDataDesc";
|
||||
public static final String REQ_CUSTOM_DATA_TEMP = "customReqDataTemp";
|
||||
// Rewards
|
||||
public static final String REW_MONEY = "moneyRew";
|
||||
public static final String REW_QUEST_POINTS = "questPointsRew";
|
||||
public static final String REW_ITEMS = "itemRews";
|
||||
public static final String REW_EXP = "expRew";
|
||||
public static final String REW_COMMAND = "commandRews";
|
||||
public static final String REW_PERMISSION = "permissionRews";
|
||||
public static final String REW_MCMMO_SKILLS = "mcMMOSkillRews";
|
||||
public static final String REW_MCMMO_AMOUNTS = "mcMMOSkillAmounts";
|
||||
public static final String REW_HEROES_CLASSES = "heroesClassRews";
|
||||
public static final String REW_HEROES_AMOUNTS = "heroesAmountRews";
|
||||
public static final String REW_PHAT_LOOTS = "phatLootRews";
|
||||
public static final String REW_CUSTOM = "customRews";
|
||||
public static final String REW_CUSTOM_DATA = "customRewData";
|
||||
public static final String REW_CUSTOM_DATA_DESCRIPTIONS = "customRewDataDesc";
|
||||
public static final String REW_CUSTOM_DATA_TEMP = "customRewDataTemp";
|
||||
// Stages
|
||||
public static final String S_BREAK_NAMES = "breakNames";
|
||||
public static final String S_BREAK_AMOUNTS = "breakAmounts";
|
||||
public static final String S_BREAK_DURABILITY = "breakDurability";
|
||||
public static final String S_DAMAGE_NAMES = "damageNames";
|
||||
public static final String S_DAMAGE_AMOUNTS = "damageAmounts";
|
||||
public static final String S_DAMAGE_DURABILITY = "damageDurability";
|
||||
public static final String S_PLACE_NAMES = "placeNames";
|
||||
public static final String S_PLACE_AMOUNTS = "placeAmounts";
|
||||
public static final String S_PLACE_DURABILITY = "placeDurability";
|
||||
public static final String S_USE_NAMES = "useNames";
|
||||
public static final String S_USE_AMOUNTS = "useAmounts";
|
||||
public static final String S_USE_DURABILITY = "useDurability";
|
||||
public static final String S_CUT_NAMES = "cutNames";
|
||||
public static final String S_CUT_AMOUNTS = "cutAmounts";
|
||||
public static final String S_CUT_DURABILITY = "cutDurability";
|
||||
public static final String S_FISH = "fish";
|
||||
public static final String S_PLAYER_KILL = "playerKill";
|
||||
public static final String S_ENCHANT_TYPES = "enchantTypes";
|
||||
public static final String S_ENCHANT_NAMES = "enchantNames";
|
||||
public static final String S_ENCHANT_AMOUNTS = "enchantAmounts";
|
||||
public static final String S_DELIVERY_ITEMS = "deliveryItems";
|
||||
public static final String S_DELIVERY_NPCS = "deliveryNPCs";
|
||||
public static final String S_DELIVERY_MESSAGES = "deliveryMessages";
|
||||
public static final String S_NPCS_TO_TALK_TO = "npcIdsToTalkTo";
|
||||
public static final String S_NPCS_TO_KILL = "npcIdsToKill";
|
||||
public static final String S_NPCS_TO_KILL_AMOUNTS = "npcAmountsToKill";
|
||||
public static final String S_MOB_TYPES = "mobTypes";
|
||||
public static final String S_MOB_AMOUNTS = "mobAmounts";
|
||||
public static final String S_MOB_KILL_LOCATIONS = "killLocations";
|
||||
public static final String S_MOB_KILL_LOCATIONS_RADIUS = "killLocationRadii";
|
||||
public static final String S_MOB_KILL_LOCATIONS_NAMES = "killLocationNames";
|
||||
public static final String S_REACH_LOCATIONS = "reachLocations";
|
||||
public static final String S_REACH_LOCATIONS_RADIUS = "reachLocationRadii";
|
||||
public static final String S_REACH_LOCATIONS_NAMES = "reachLocationNames";
|
||||
public static final String S_TAME_TYPES = "tameTypes";
|
||||
public static final String S_TAME_AMOUNTS = "tameAmounts";
|
||||
public static final String S_SHEAR_COLORS = "shearColors";
|
||||
public static final String S_SHEAR_AMOUNTS = "shearAmounts";
|
||||
public static final String S_START_EVENT = "startEvent";
|
||||
public static final String S_FINISH_EVENT = "finishEvent";
|
||||
public static final String S_CHAT_EVENTS = "chatEvents";
|
||||
public static final String S_CHAT_EVENT_TRIGGERS = "chatEventTriggers";
|
||||
public static final String S_CHAT_TEMP_EVENT = "chatTempEvent";
|
||||
public static final String S_DEATH_EVENT = "deathEvent";
|
||||
public static final String S_DISCONNECT_EVENT = "disconnectEvent";
|
||||
public static final String S_DELAY = "delay";
|
||||
public static final String S_DELAY_MESSAGE = "delayMessage";
|
||||
public static final String S_DENIZEN = "denizen";
|
||||
public static final String S_COMPLETE_MESSAGE = "completeMessage";
|
||||
public static final String S_START_MESSAGE = "startMessage";
|
||||
public static final String S_OVERRIDE_DISPLAY = "overrideDisplay";
|
||||
public static final String S_PASSWORD_DISPLAYS = "passwordDisplays";
|
||||
public static final String S_PASSWORD_PHRASES = "passwordPhrases";
|
||||
public static final String S_CUSTOM_OBJECTIVES = "customObjectives";
|
||||
public static final String S_CUSTOM_OBJECTIVES_COUNT = "customObjectiveCounts";
|
||||
public static final String S_CUSTOM_OBJECTIVES_DATA = "customObjectiveData";
|
||||
public static final String S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS = "customObjectiveDataDescriptions";
|
||||
public static final String S_CUSTOM_OBJECTIVES_DATA_TEMP = "customObjectiveDataTemp";
|
||||
// Events
|
||||
public static final String E_OLD_EVENT = "oldEvent";
|
||||
public static final String E_NAME = "evtName";
|
||||
public static final String E_MESSAGE = "evtMessage";
|
||||
public static final String E_CLEAR_INVENTORY = "evtClearInv";
|
||||
public static final String E_FAIL_QUEST = "evtFailQuest";
|
||||
public static final String E_ITEMS = "evtItems";
|
||||
public static final String E_ITEMS_AMOUNTS = "evtItemAmounts";
|
||||
public static final String E_EXPLOSIONS = "evtExplosions";
|
||||
public static final String E_EFFECTS = "evtEffects";
|
||||
public static final String E_EFFECTS_LOCATIONS = "evtEffectLocations";
|
||||
public static final String E_WORLD_STORM = "evtStormWorld";
|
||||
public static final String E_WORLD_STORM_DURATION = "evtStormDuration";
|
||||
public static final String E_WORLD_THUNDER = "evtThunderWorld";
|
||||
public static final String E_WORLD_THUNDER_DURATION = "evtThunderDuration";
|
||||
public static final String E_MOB_TYPES = "evtMobTypes";
|
||||
public static final String E_LIGHTNING = "evtLightningStrikes";
|
||||
public static final String E_POTION_TYPES = "evtPotionTypes";
|
||||
public static final String E_POTION_DURATIONS = "evtPotionDurations";
|
||||
public static final String E_POTION_STRENGHT = "evtPotionMagnitudes";
|
||||
public static final String E_HUNGER = "evtHunger";
|
||||
public static final String E_SATURATION = "evtSaturation";
|
||||
public static final String E_HEALTH = "evtHealth";
|
||||
public static final String E_TELEPORT = "evtTeleportLocation";
|
||||
public static final String E_COMMANDS = "evtCommands";
|
||||
// Party
|
||||
public static final String P_INVITER = "inviter";
|
||||
}
|
@ -3,10 +3,6 @@ package me.blackvein.quests.util;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import me.blackvein.quests.Quester;
|
||||
import me.blackvein.quests.Quests;
|
||||
import net.milkbowl.vault.item.Items;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -14,247 +10,204 @@ import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import me.blackvein.quests.Quester;
|
||||
import me.blackvein.quests.Quests;
|
||||
import net.milkbowl.vault.item.Items;
|
||||
|
||||
public class ItemUtil {
|
||||
|
||||
|
||||
static Quests plugin;
|
||||
|
||||
/**
|
||||
* Will compare stacks by name, amount, data, display name/lore and enchantments
|
||||
*
|
||||
*
|
||||
* @param one ItemStack to compare
|
||||
* @param two ItemStack to compare to
|
||||
* @return 0 if stacks are equal, or the first inequality from the following
|
||||
* values:<br>
|
||||
* @return -1 -> stack names are unequal<br>
|
||||
* @return -2 -> stack amounts are unequal<br>
|
||||
* @return -3 -> stack data is unequal<br>
|
||||
* @return -4 -> stack display name/lore is unequal<br>
|
||||
* @return -5 -> stack enchantments are unequal<br>
|
||||
*/
|
||||
public static int compareItems(ItemStack one, ItemStack two, boolean ignoreAmount) {
|
||||
|
||||
if (one == null && two != null || one != null && two == null) {
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* Will compare stacks by name, amount, data, display name/lore and enchantments
|
||||
*
|
||||
*
|
||||
* @param one
|
||||
* ItemStack to compare
|
||||
* @param two
|
||||
* ItemStack to compare to
|
||||
* @return 0 if stacks are equal, or the first inequality from the following values:<br>
|
||||
* @return -1 -> stack names are unequal<br>
|
||||
* @return -2 -> stack amounts are unequal<br>
|
||||
* @return -3 -> stack data is unequal<br>
|
||||
* @return -4 -> stack display name/lore is unequal<br>
|
||||
* @return -5 -> stack enchantments are unequal<br>
|
||||
*/
|
||||
public static int compareItems(ItemStack one, ItemStack two, boolean ignoreAmount) {
|
||||
if (one == null && two != null || one != null && two == null) {
|
||||
return 0;
|
||||
}
|
||||
if (one == null && two == null) {
|
||||
return 0;
|
||||
}
|
||||
if (one.getType().name() != two.getType().name()) {
|
||||
return -1;
|
||||
} else if ((one.getAmount() != two.getAmount()) && ignoreAmount == false) {
|
||||
return -2;
|
||||
} else if (one.getData().equals(two.getData()) == false) {
|
||||
return -3;
|
||||
}
|
||||
if (one.hasItemMeta() || two.hasItemMeta()) {
|
||||
if (one.hasItemMeta() && two.hasItemMeta() == false) {
|
||||
return -4;
|
||||
} else if (one.hasItemMeta() == false && two.hasItemMeta()) {
|
||||
return -4;
|
||||
} else if (one.getItemMeta().hasDisplayName() && two.getItemMeta().hasDisplayName() == false) {
|
||||
return -4;
|
||||
} else if (one.getItemMeta().hasDisplayName() == false && two.getItemMeta().hasDisplayName()) {
|
||||
return -4;
|
||||
} else if (one.getItemMeta().hasLore() && two.getItemMeta().hasLore() == false) {
|
||||
return -4;
|
||||
} else if (one.getItemMeta().hasLore() == false && two.getItemMeta().hasLore()) {
|
||||
return -4;
|
||||
} else if (one.getItemMeta().hasDisplayName() && two.getItemMeta().hasDisplayName() && ChatColor.stripColor(one.getItemMeta().getDisplayName()).equals(ChatColor.stripColor(two.getItemMeta().getDisplayName())) == false) {
|
||||
return -4;
|
||||
} else if (one.getItemMeta().hasLore() && two.getItemMeta().hasLore() && one.getItemMeta().getLore().equals(two.getItemMeta().getLore()) == false) {
|
||||
return -4;
|
||||
}
|
||||
}
|
||||
if (one.getEnchantments().equals(two.getEnchantments()) == false) {
|
||||
return -5;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (one == null && two == null) {
|
||||
return 0;
|
||||
}
|
||||
// Formats -> name-name:amount-amount:data-data:enchantment-enchantment level:displayname-displayname:lore-lore:
|
||||
// Returns null if invalid format
|
||||
public static ItemStack readItemStack(String data) {
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
ItemStack stack = null;
|
||||
String[] args = data.split(":");
|
||||
ItemMeta meta = null;
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
for (String arg : args) {
|
||||
if (arg.startsWith("name-")) {
|
||||
// Attempt to match item name. Returns null if invalid format
|
||||
try {
|
||||
stack = new ItemStack(Material.matchMaterial(arg.substring(5)));
|
||||
} catch (NullPointerException npe) {
|
||||
return null;
|
||||
}
|
||||
meta = stack.getItemMeta();
|
||||
} else if (arg.startsWith("amount-")) {
|
||||
stack.setAmount(Integer.parseInt(arg.substring(7)));
|
||||
} else if (arg.startsWith("data-")) {
|
||||
stack.setDurability(Short.parseShort(arg.substring(5)));
|
||||
} else if (arg.startsWith("enchantment-")) {
|
||||
String[] enchs = arg.substring(12).split(" ");
|
||||
Enchantment e = Quests.getEnchantment(enchs[0]);
|
||||
meta.addEnchant(e, Integer.parseInt(enchs[1]), true);
|
||||
} else if (arg.startsWith("displayname-")) {
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', arg.substring(12)));
|
||||
} else if (arg.startsWith("lore-")) {
|
||||
lore.add(ChatColor.translateAlternateColorCodes('&', arg.substring(5)));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (lore.isEmpty() == false) {
|
||||
meta.setLore(lore);
|
||||
}
|
||||
stack.setItemMeta(meta);
|
||||
return stack;
|
||||
}
|
||||
|
||||
if (one.getType().name() != two.getType().name()) {
|
||||
return -1;
|
||||
} else if ((one.getAmount() != two.getAmount()) && ignoreAmount == false) {
|
||||
return -2;
|
||||
} else if (one.getData().equals(two.getData()) == false) {
|
||||
return -3;
|
||||
}
|
||||
public static String serialize(ItemStack is) {
|
||||
String serial;
|
||||
if (is == null) {
|
||||
return null;
|
||||
}
|
||||
serial = "name-" + is.getType().name();
|
||||
serial += ":amount-" + is.getAmount();
|
||||
if (is.getDurability() != 0) {
|
||||
serial += ":data-" + is.getDurability();
|
||||
}
|
||||
if (is.getEnchantments().isEmpty() == false) {
|
||||
for (Entry<Enchantment, Integer> e : is.getEnchantments().entrySet()) {
|
||||
serial += ":enchantment-" + Quester.enchantmentString(e.getKey()) + " " + e.getValue();
|
||||
}
|
||||
}
|
||||
if (is.hasItemMeta()) {
|
||||
ItemMeta meta = is.getItemMeta();
|
||||
if (meta.hasDisplayName()) {
|
||||
serial += ":displayname-" + meta.getDisplayName();
|
||||
}
|
||||
if (meta.hasLore()) {
|
||||
for (String s : meta.getLore()) {
|
||||
serial += ":lore-" + s;
|
||||
}
|
||||
}
|
||||
}
|
||||
return serial;
|
||||
}
|
||||
|
||||
if (one.hasItemMeta() || two.hasItemMeta()) {
|
||||
public static String getDisplayString(ItemStack is) {
|
||||
String text;
|
||||
if (is == null) {
|
||||
return null;
|
||||
}
|
||||
if (is.hasItemMeta() && is.getItemMeta().hasDisplayName()) {
|
||||
text = "" + ChatColor.DARK_AQUA + ChatColor.ITALIC + is.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.AQUA + " x " + is.getAmount();
|
||||
} else {
|
||||
text = ChatColor.AQUA + Quester.prettyItemString(is.getType().name());
|
||||
if (is.getDurability() != 0) {
|
||||
text += ChatColor.AQUA + ":" + is.getDurability();
|
||||
}
|
||||
text += ChatColor.AQUA + " x " + is.getAmount();
|
||||
if (is.getEnchantments().isEmpty() == false) {
|
||||
text += " " + ChatColor.DARK_PURPLE + Lang.get("enchantedItem");
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
if (one.hasItemMeta() && two.hasItemMeta() == false) {
|
||||
return -4;
|
||||
} else if (one.hasItemMeta() == false && two.hasItemMeta()) {
|
||||
return -4;
|
||||
} else if (one.getItemMeta().hasDisplayName() && two.getItemMeta().hasDisplayName() == false) {
|
||||
return -4;
|
||||
} else if (one.getItemMeta().hasDisplayName() == false && two.getItemMeta().hasDisplayName()) {
|
||||
return -4;
|
||||
} else if (one.getItemMeta().hasLore() && two.getItemMeta().hasLore() == false) {
|
||||
return -4;
|
||||
} else if (one.getItemMeta().hasLore() == false && two.getItemMeta().hasLore()) {
|
||||
return -4;
|
||||
} else if (one.getItemMeta().hasDisplayName() && two.getItemMeta().hasDisplayName() && ChatColor.stripColor(one.getItemMeta().getDisplayName()).equals(ChatColor.stripColor(two.getItemMeta().getDisplayName())) == false) {
|
||||
return -4;
|
||||
} else if (one.getItemMeta().hasLore() && two.getItemMeta().hasLore() && one.getItemMeta().getLore().equals(two.getItemMeta().getLore()) == false) {
|
||||
return -4;
|
||||
}
|
||||
public static String getString(ItemStack is) {
|
||||
String text;
|
||||
if (is.hasItemMeta() && is.getItemMeta().hasDisplayName()) {
|
||||
text = "" + ChatColor.DARK_AQUA + ChatColor.ITALIC + is.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.AQUA + " x " + is.getAmount();
|
||||
} else {
|
||||
text = ChatColor.AQUA + Quester.prettyItemString(is.getType().name());
|
||||
if (is.getDurability() != 0) {
|
||||
text += ChatColor.AQUA + ":" + is.getDurability();
|
||||
}
|
||||
text += ChatColor.AQUA + " x " + is.getAmount();
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
}
|
||||
public static String getName(ItemStack is) {
|
||||
String text = "";
|
||||
if (is.hasItemMeta() && is.getItemMeta().hasDisplayName()) {
|
||||
text = "" + ChatColor.DARK_AQUA + ChatColor.ITALIC + is.getItemMeta().getDisplayName();
|
||||
} else {
|
||||
try {
|
||||
text = ChatColor.AQUA + Items.itemByStack(is).getName();
|
||||
} catch (NullPointerException ne) {
|
||||
Bukkit.getLogger().severe("This error is caused by an incompatible version of Vault. Please update!");
|
||||
ne.printStackTrace();
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
if (one.getEnchantments().equals(two.getEnchantments()) == false) {
|
||||
return -5;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//Formats -> name-name:amount-amount:data-data:enchantment-enchantment level:displayname-displayname:lore-lore:
|
||||
//Returns null if invalid format
|
||||
public static ItemStack readItemStack(String data) {
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack stack = null;
|
||||
String[] args = data.split(":");
|
||||
ItemMeta meta = null;
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
for (String arg : args) {
|
||||
if (arg.startsWith("name-")) {
|
||||
//Attempt to match item name. Returns null if invalid format
|
||||
try {
|
||||
stack = new ItemStack(Material.matchMaterial(arg.substring(5)));
|
||||
} catch (NullPointerException npe) {
|
||||
return null;
|
||||
}
|
||||
meta = stack.getItemMeta();
|
||||
} else if (arg.startsWith("amount-")) {
|
||||
stack.setAmount(Integer.parseInt(arg.substring(7)));
|
||||
} else if (arg.startsWith("data-")) {
|
||||
stack.setDurability(Short.parseShort(arg.substring(5)));
|
||||
} else if (arg.startsWith("enchantment-")) {
|
||||
String[] enchs = arg.substring(12).split(" ");
|
||||
Enchantment e = Quests.getEnchantment(enchs[0]);
|
||||
meta.addEnchant(e, Integer.parseInt(enchs[1]), true);
|
||||
} else if (arg.startsWith("displayname-")) {
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', arg.substring(12)));
|
||||
} else if (arg.startsWith("lore-")) {
|
||||
lore.add(ChatColor.translateAlternateColorCodes('&', arg.substring(5)));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (lore.isEmpty() == false) {
|
||||
meta.setLore(lore);
|
||||
}
|
||||
|
||||
stack.setItemMeta(meta);
|
||||
|
||||
return stack;
|
||||
|
||||
}
|
||||
|
||||
public static String serialize(ItemStack is) {
|
||||
|
||||
String serial;
|
||||
|
||||
if (is == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
serial = "name-" + is.getType().name();
|
||||
serial += ":amount-" + is.getAmount();
|
||||
if (is.getDurability() != 0) {
|
||||
serial += ":data-" + is.getDurability();
|
||||
}
|
||||
if (is.getEnchantments().isEmpty() == false) {
|
||||
|
||||
for (Entry<Enchantment, Integer> e : is.getEnchantments().entrySet()) {
|
||||
serial += ":enchantment-" + Quester.enchantmentString(e.getKey()) + " " + e.getValue();
|
||||
}
|
||||
|
||||
}
|
||||
if (is.hasItemMeta()) {
|
||||
|
||||
ItemMeta meta = is.getItemMeta();
|
||||
if (meta.hasDisplayName()) {
|
||||
serial += ":displayname-" + meta.getDisplayName();
|
||||
}
|
||||
if (meta.hasLore()) {
|
||||
for (String s : meta.getLore()) {
|
||||
serial += ":lore-" + s;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return serial;
|
||||
|
||||
}
|
||||
|
||||
public static String getDisplayString(ItemStack is) {
|
||||
|
||||
String text;
|
||||
if (is == null) {
|
||||
return null;
|
||||
}
|
||||
if (is.hasItemMeta() && is.getItemMeta().hasDisplayName()) {
|
||||
text = "" + ChatColor.DARK_AQUA + ChatColor.ITALIC + is.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.AQUA + " x " + is.getAmount();
|
||||
} else {
|
||||
text = ChatColor.AQUA + Quester.prettyItemString(is.getType().name());
|
||||
if (is.getDurability() != 0) {
|
||||
text += ChatColor.AQUA + ":" + is.getDurability();
|
||||
}
|
||||
|
||||
text += ChatColor.AQUA + " x " + is.getAmount();
|
||||
|
||||
if (is.getEnchantments().isEmpty() == false) {
|
||||
text += " " + ChatColor.DARK_PURPLE + Lang.get("enchantedItem");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return text;
|
||||
|
||||
}
|
||||
|
||||
public static String getString(ItemStack is) {
|
||||
|
||||
String text;
|
||||
|
||||
if (is.hasItemMeta() && is.getItemMeta().hasDisplayName()) {
|
||||
text = "" + ChatColor.DARK_AQUA + ChatColor.ITALIC + is.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.AQUA + " x " + is.getAmount();
|
||||
} else {
|
||||
text = ChatColor.AQUA + Quester.prettyItemString(is.getType().name());
|
||||
if (is.getDurability() != 0) {
|
||||
text += ChatColor.AQUA + ":" + is.getDurability();
|
||||
}
|
||||
|
||||
text += ChatColor.AQUA + " x " + is.getAmount();
|
||||
|
||||
}
|
||||
|
||||
return text;
|
||||
|
||||
}
|
||||
|
||||
public static String getName(ItemStack is) {
|
||||
|
||||
String text = "";
|
||||
|
||||
if (is.hasItemMeta() && is.getItemMeta().hasDisplayName()) {
|
||||
text = "" + ChatColor.DARK_AQUA + ChatColor.ITALIC + is.getItemMeta().getDisplayName();
|
||||
} else {
|
||||
try {
|
||||
text = ChatColor.AQUA + Items.itemByStack(is).getName();
|
||||
} catch (NullPointerException ne) {
|
||||
Bukkit.getLogger().severe("This error is caused by an incompatible version of Vault. Please update!");
|
||||
ne.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
|
||||
}
|
||||
|
||||
public static boolean isItem(ItemStack is) {
|
||||
|
||||
if(is == null)
|
||||
return false;
|
||||
|
||||
if(is.getType().equals(Material.AIR))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public static boolean isJournal(ItemStack is) {
|
||||
|
||||
if(is == null)
|
||||
return false;
|
||||
|
||||
if(is.hasItemMeta() == false)
|
||||
return false;
|
||||
|
||||
if(is.getItemMeta().hasDisplayName() == false)
|
||||
return false;
|
||||
|
||||
return is.getItemMeta().getDisplayName().equals(ChatColor.LIGHT_PURPLE + Lang.get("journalTitle"));
|
||||
|
||||
}
|
||||
public static boolean isItem(ItemStack is) {
|
||||
if (is == null)
|
||||
return false;
|
||||
if (is.getType().equals(Material.AIR))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isJournal(ItemStack is) {
|
||||
if (is == null)
|
||||
return false;
|
||||
if (is.hasItemMeta() == false)
|
||||
return false;
|
||||
if (is.getItemMeta().hasDisplayName() == false)
|
||||
return false;
|
||||
return is.getItemMeta().getDisplayName().equals(ChatColor.LIGHT_PURPLE + Lang.get("journalTitle"));
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -7,142 +7,106 @@ import org.bukkit.entity.EntityType;
|
||||
|
||||
public class MiscUtil {
|
||||
|
||||
public static String getCapitalized(String s) {
|
||||
public static String getCapitalized(String s) {
|
||||
if (s.isEmpty()) {
|
||||
return s;
|
||||
}
|
||||
s = s.toLowerCase();
|
||||
String s2 = s.substring(0, 1);
|
||||
s2 = s2.toUpperCase();
|
||||
s = s.substring(1, s.length());
|
||||
return s2 + s;
|
||||
}
|
||||
|
||||
if (s.isEmpty()) {
|
||||
return s;
|
||||
}
|
||||
// Time: 7d 24h 5m 10s 20ms
|
||||
public static long getTimeFromString(String string) {
|
||||
// if it returns -1 then the string is incorrect.
|
||||
long timeMilliSeconds = -1;
|
||||
// replace 2 or more spaces with one space.
|
||||
string = string.replaceAll("[ ]{2,}", " ");
|
||||
String[] dates = string.split(" ");
|
||||
for (String date : dates) {
|
||||
String num = date.split("[a-zA-Z]+")[0];
|
||||
String type = date.split("[0-9]+")[1];
|
||||
int t = 0;
|
||||
try {
|
||||
t = Math.abs(Integer.parseInt(num));
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
if (type.equals("d")) {
|
||||
timeMilliSeconds += t * 86400000L;
|
||||
} else if (type.equals("h")) {
|
||||
timeMilliSeconds += t * 3600000;
|
||||
} else if (type.equals("m")) {
|
||||
timeMilliSeconds += t * 60000;
|
||||
} else if (type.equals("s")) {
|
||||
timeMilliSeconds += t * 1000;
|
||||
} else if (type.equals("ms")) {
|
||||
timeMilliSeconds += t;
|
||||
}
|
||||
}
|
||||
// To balance the -1 at the beginning.
|
||||
if (timeMilliSeconds > -1) {
|
||||
timeMilliSeconds++;
|
||||
}
|
||||
return timeMilliSeconds;
|
||||
}
|
||||
|
||||
s = s.toLowerCase();
|
||||
String s2 = s.substring(0, 1);
|
||||
s2 = s2.toUpperCase();
|
||||
public static String getProperMobName(EntityType type) {
|
||||
String name = type.name().toLowerCase();
|
||||
name = Character.toUpperCase(name.charAt(0)) + name.substring(1);
|
||||
while (fixUnderscore(name) != null) {
|
||||
name = fixUnderscore(name);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
s = s.substring(1, s.length());
|
||||
public static EntityType getProperMobType(String properName) {
|
||||
properName = properName.replaceAll("_", "").toUpperCase();
|
||||
for (EntityType et : EntityType.values()) {
|
||||
if (et.isAlive() && et.name().replaceAll("_", "").equalsIgnoreCase(properName)) {
|
||||
return et;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return s2 + s;
|
||||
private static String fixUnderscore(String s) {
|
||||
int index = s.indexOf('_');
|
||||
if (index == -1) {
|
||||
return null;
|
||||
}
|
||||
s = s.substring(0, (index + 1)) + Character.toUpperCase(s.charAt(index + 1)) + s.substring(index + 2);
|
||||
s = s.replaceFirst("_", "");
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Time: 7d 24h 5m 10s 20ms
|
||||
public static long getTimeFromString(String string) {
|
||||
//if it returns -1 then the string is incorrect.
|
||||
long timeMilliSeconds = -1;
|
||||
//replace 2 or more spaces with one space.
|
||||
string = string.replaceAll("[ ]{2,}", " ");
|
||||
|
||||
String[] dates = string.split(" ");
|
||||
|
||||
for (String date : dates) {
|
||||
String num = date.split("[a-zA-Z]+")[0];
|
||||
String type = date.split("[0-9]+")[1];
|
||||
|
||||
int t = 0;
|
||||
try {
|
||||
t = Math.abs(Integer.parseInt(num));
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
|
||||
if (type.equals("d")) {
|
||||
timeMilliSeconds += t * 86400000L;
|
||||
} else if (type.equals("h")) {
|
||||
timeMilliSeconds += t * 3600000;
|
||||
} else if (type.equals("m")) {
|
||||
timeMilliSeconds += t * 60000;
|
||||
} else if (type.equals("s")) {
|
||||
timeMilliSeconds += t * 1000;
|
||||
} else if (type.equals("ms")) {
|
||||
timeMilliSeconds += t;
|
||||
}
|
||||
}
|
||||
|
||||
//To balance the -1 at the beginning.
|
||||
if (timeMilliSeconds > -1) {
|
||||
timeMilliSeconds++;
|
||||
}
|
||||
|
||||
return timeMilliSeconds;
|
||||
}
|
||||
|
||||
public static String getProperMobName(EntityType type) {
|
||||
|
||||
String name = type.name().toLowerCase();
|
||||
|
||||
name = Character.toUpperCase(name.charAt(0)) + name.substring(1);
|
||||
while (fixUnderscore(name) != null) {
|
||||
name = fixUnderscore(name);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public static EntityType getProperMobType(String properName) {
|
||||
|
||||
properName = properName.replaceAll("_", "").toUpperCase();
|
||||
for (EntityType et : EntityType.values()) {
|
||||
|
||||
if (et.isAlive() && et.name().replaceAll("_", "").equalsIgnoreCase(properName)) {
|
||||
return et;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
private static String fixUnderscore(String s) {
|
||||
|
||||
int index = s.indexOf('_');
|
||||
if (index == -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
s = s.substring(0, (index + 1)) + Character.toUpperCase(s.charAt(index + 1)) + s.substring(index + 2);
|
||||
s = s.replaceFirst("_", "");
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
public static String concatArgArray(String[] args, int startingIndex, int endingIndex, char delimiter) {
|
||||
|
||||
String s = "";
|
||||
|
||||
for (int i = startingIndex; i <= endingIndex; i++) {
|
||||
|
||||
s += args[i] + delimiter;
|
||||
|
||||
}
|
||||
|
||||
s = s.substring(0, s.length());
|
||||
|
||||
return s.trim().equals("") ? null : s.trim();
|
||||
}
|
||||
|
||||
public static LinkedList<String> makeLines(String s, String wordDelimiter, int lineLength, ChatColor lineColor) {
|
||||
|
||||
LinkedList<String> toReturn = new LinkedList<String>();
|
||||
String[] split = s.split(wordDelimiter);
|
||||
String line = "";
|
||||
int currentLength = 0;
|
||||
|
||||
for (String piece : split) {
|
||||
|
||||
if ((currentLength + piece.length()) > (lineLength + 1)) {
|
||||
toReturn.add(lineColor + line.replaceAll("^" + wordDelimiter, ""));
|
||||
line = piece + wordDelimiter;
|
||||
currentLength = piece.length() + 1;
|
||||
} else {
|
||||
line += piece + wordDelimiter;
|
||||
currentLength += piece.length() + 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(line.equals("") == false)
|
||||
toReturn.add(lineColor + line);
|
||||
|
||||
return toReturn;
|
||||
|
||||
}
|
||||
public static String concatArgArray(String[] args, int startingIndex, int endingIndex, char delimiter) {
|
||||
String s = "";
|
||||
for (int i = startingIndex; i <= endingIndex; i++) {
|
||||
s += args[i] + delimiter;
|
||||
}
|
||||
s = s.substring(0, s.length());
|
||||
return s.trim().equals("") ? null : s.trim();
|
||||
}
|
||||
|
||||
public static LinkedList<String> makeLines(String s, String wordDelimiter, int lineLength, ChatColor lineColor) {
|
||||
LinkedList<String> toReturn = new LinkedList<String>();
|
||||
String[] split = s.split(wordDelimiter);
|
||||
String line = "";
|
||||
int currentLength = 0;
|
||||
for (String piece : split) {
|
||||
if ((currentLength + piece.length()) > (lineLength + 1)) {
|
||||
toReturn.add(lineColor + line.replaceAll("^" + wordDelimiter, ""));
|
||||
line = piece + wordDelimiter;
|
||||
currentLength = piece.length() + 1;
|
||||
} else {
|
||||
line += piece + wordDelimiter;
|
||||
currentLength += piece.length() + 1;
|
||||
}
|
||||
}
|
||||
if (line.equals("") == false)
|
||||
toReturn.add(lineColor + line);
|
||||
return toReturn;
|
||||
}
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
package me.blackvein.quests.util;
|
||||
import me.blackvein.quests.Quests;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@ -9,267 +8,242 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
|
||||
public class QuestMob {
|
||||
|
||||
private String name = null;
|
||||
private EntityType entityType = null;
|
||||
private Location spawnLocation = null;
|
||||
private Integer spawnAmounts = null;
|
||||
public ItemStack[] inventory = new ItemStack[5];
|
||||
public Float[] dropChances = new Float[5];
|
||||
private String name = null;
|
||||
private EntityType entityType = null;
|
||||
private Location spawnLocation = null;
|
||||
private Integer spawnAmounts = null;
|
||||
public ItemStack[] inventory = new ItemStack[5];
|
||||
public Float[] dropChances = new Float[5];
|
||||
|
||||
public QuestMob(EntityType entityType, Location spawnLocation, int spawnAmounts) {
|
||||
this.entityType = entityType;
|
||||
this.spawnLocation = spawnLocation;
|
||||
this.spawnAmounts = spawnAmounts;
|
||||
}
|
||||
public QuestMob(EntityType entityType, Location spawnLocation, int spawnAmounts) {
|
||||
this.entityType = entityType;
|
||||
this.spawnLocation = spawnLocation;
|
||||
this.spawnAmounts = spawnAmounts;
|
||||
}
|
||||
|
||||
public QuestMob() {
|
||||
public QuestMob() {
|
||||
}
|
||||
|
||||
}
|
||||
public void setSpawnLocation(Location spawnLocation) {
|
||||
this.spawnLocation = spawnLocation;
|
||||
}
|
||||
|
||||
public void setSpawnLocation(Location spawnLocation) {
|
||||
this.spawnLocation = spawnLocation;
|
||||
}
|
||||
public Location getSpawnLocation() {
|
||||
return spawnLocation;
|
||||
}
|
||||
|
||||
public Location getSpawnLocation() {
|
||||
return spawnLocation;
|
||||
}
|
||||
public void setType(EntityType entityType) {
|
||||
this.entityType = entityType;
|
||||
}
|
||||
|
||||
public void setType(EntityType entityType) {
|
||||
this.entityType = entityType;
|
||||
}
|
||||
public EntityType getType() {
|
||||
return entityType;
|
||||
}
|
||||
|
||||
public EntityType getType() {
|
||||
return entityType;
|
||||
}
|
||||
public void setSpawnAmounts(int spawnAmounts) {
|
||||
this.spawnAmounts = spawnAmounts;
|
||||
}
|
||||
|
||||
public void setSpawnAmounts(int spawnAmounts) {
|
||||
this.spawnAmounts = spawnAmounts;
|
||||
}
|
||||
public Integer getSpawnAmounts() {
|
||||
return spawnAmounts;
|
||||
}
|
||||
|
||||
public Integer getSpawnAmounts() {
|
||||
return spawnAmounts;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setHelmet(ItemStack helmet, float dropChance) {
|
||||
inventory[4] = helmet;
|
||||
dropChances[4] = dropChance;
|
||||
}
|
||||
|
||||
public void setHelmet(ItemStack helmet, float dropChance) {
|
||||
inventory[4] = helmet;
|
||||
dropChances[4] = dropChance;
|
||||
}
|
||||
public void setChest(ItemStack chest, float dropChance) {
|
||||
inventory[3] = chest;
|
||||
dropChances[3] = dropChance;
|
||||
}
|
||||
|
||||
public void setChest(ItemStack chest, float dropChance) {
|
||||
inventory[3] = chest;
|
||||
dropChances[3] = dropChance;
|
||||
}
|
||||
public void setLeggings(ItemStack leggings, float dropChance) {
|
||||
inventory[2] = leggings;
|
||||
dropChances[2] = dropChance;
|
||||
}
|
||||
|
||||
public void setLeggings(ItemStack leggings, float dropChance) {
|
||||
inventory[2] = leggings;
|
||||
dropChances[2] = dropChance;
|
||||
}
|
||||
public void setBoots(ItemStack boots, float dropChance) {
|
||||
inventory[1] = boots;
|
||||
dropChances[1] = dropChance;
|
||||
}
|
||||
|
||||
public void setBoots(ItemStack boots, float dropChance) {
|
||||
inventory[1] = boots;
|
||||
dropChances[1] = dropChance;
|
||||
}
|
||||
|
||||
public void setHeldItem(ItemStack heldItem, float dropChance) {
|
||||
inventory[0] = heldItem;
|
||||
dropChances[0] = dropChance;
|
||||
}
|
||||
public void setHeldItem(ItemStack heldItem, float dropChance) {
|
||||
inventory[0] = heldItem;
|
||||
dropChances[0] = dropChance;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void spawn() {
|
||||
World world = spawnLocation.getWorld();
|
||||
for (int i = 0; i < spawnAmounts; i++) {
|
||||
LivingEntity entity = (LivingEntity) world.spawnEntity(spawnLocation, entityType);
|
||||
if (name != null) {
|
||||
entity.setCustomName(name);
|
||||
entity.setCustomNameVisible(true);
|
||||
}
|
||||
EntityEquipment eq = entity.getEquipment();
|
||||
try {
|
||||
eq.setItemInHand(inventory[0]);
|
||||
eq.setBoots(inventory[1]);
|
||||
eq.setLeggings(inventory[2]);
|
||||
eq.setChestplate(inventory[3]);
|
||||
eq.setHelmet(inventory[4]);
|
||||
} catch (Exception e) {
|
||||
Bukkit.getLogger().severe("Entity NMS is invalid for this version of CraftBukkit. Please notify the developer");
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (dropChances[0] != null) {
|
||||
eq.setItemInHandDropChance(dropChances[0]);
|
||||
}
|
||||
if (dropChances[1] != null) {
|
||||
eq.setBootsDropChance(dropChances[1]);
|
||||
}
|
||||
if (dropChances[2] != null) {
|
||||
eq.setLeggingsDropChance(dropChances[2]);
|
||||
}
|
||||
if (dropChances[3] != null) {
|
||||
eq.setChestplateDropChance(dropChances[3]);
|
||||
}
|
||||
if (dropChances[4] != null) {
|
||||
eq.setHelmetDropChance(dropChances[4]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
World world = spawnLocation.getWorld();
|
||||
public String serialize() {
|
||||
String string = "";
|
||||
string += "type-" + entityType.name();
|
||||
if (name != null) {
|
||||
string += "::name-" + name;
|
||||
}
|
||||
if (spawnLocation != null) {
|
||||
string += "::spawn-" + Quests.getLocationInfo(spawnLocation);
|
||||
}
|
||||
if (spawnAmounts != null) {
|
||||
string += "::amounts-" + spawnAmounts;
|
||||
}
|
||||
if (inventory[0] != null) {
|
||||
string += "::hand-" + ItemUtil.serialize(inventory[0]);
|
||||
string += "::hand_drop-" + dropChances[0];
|
||||
}
|
||||
if (inventory[1] != null) {
|
||||
string += "::boots-" + ItemUtil.serialize(inventory[1]);
|
||||
string += "::boots_drop-" + dropChances[1];
|
||||
}
|
||||
if (inventory[2] != null) {
|
||||
string += "::leggings-" + ItemUtil.serialize(inventory[2]);
|
||||
string += "::leggings_drop-" + dropChances[2];
|
||||
}
|
||||
if (inventory[3] != null) {
|
||||
string += "::chest-" + ItemUtil.serialize(inventory[3]);
|
||||
string += "::chest_drop-" + dropChances[3];
|
||||
}
|
||||
if (inventory[4] != null) {
|
||||
string += "::helmet-" + ItemUtil.serialize(inventory[4]);
|
||||
string += "::helmet_drop-" + dropChances[4];
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
for (int i = 0; i < spawnAmounts; i++) {
|
||||
public static QuestMob fromString(String str) {
|
||||
String name = null;
|
||||
EntityType entityType = null;
|
||||
Location loc = null;
|
||||
Integer amounts = null;
|
||||
ItemStack[] inventory = new ItemStack[5];
|
||||
Float[] dropChances = new Float[5];
|
||||
String[] args = str.split("::");
|
||||
for (String string : args) {
|
||||
if (string.startsWith("type-")) {
|
||||
entityType = Quests.getMobType(string.substring(5));
|
||||
} else if (string.startsWith("name-")) {
|
||||
name = string.substring(5);
|
||||
} else if (string.startsWith("spawn-")) {
|
||||
loc = Quests.getLocation(string.substring(6));
|
||||
} else if (string.startsWith("amounts-")) {
|
||||
amounts = Integer.parseInt(string.substring(8));
|
||||
} else if (string.startsWith("hand-")) {
|
||||
inventory[0] = ItemUtil.readItemStack(string.substring(5));
|
||||
} else if (string.startsWith("hand_drop-")) {
|
||||
dropChances[0] = Float.parseFloat(string.substring(10));
|
||||
} else if (string.startsWith("boots-")) {
|
||||
inventory[1] = ItemUtil.readItemStack(string.substring(6));
|
||||
} else if (string.startsWith("boots_drop-")) {
|
||||
dropChances[1] = Float.parseFloat(string.substring(11));
|
||||
} else if (string.startsWith("leggings-")) {
|
||||
inventory[2] = ItemUtil.readItemStack(string.substring(9));
|
||||
} else if (string.startsWith("leggings_drop-")) {
|
||||
dropChances[2] = Float.parseFloat(string.substring(14));
|
||||
} else if (string.startsWith("chest-")) {
|
||||
inventory[3] = ItemUtil.readItemStack(string.substring(6));
|
||||
} else if (string.startsWith("chest_drop-")) {
|
||||
dropChances[3] = Float.parseFloat(string.substring(11));
|
||||
} else if (string.startsWith("helmet-")) {
|
||||
inventory[4] = ItemUtil.readItemStack(string.substring(7));
|
||||
} else if (string.startsWith("helmet_drop-")) {
|
||||
dropChances[4] = Float.parseFloat(string.substring(12));
|
||||
}
|
||||
}
|
||||
QuestMob qm = new QuestMob(entityType, loc, amounts);
|
||||
qm.setName(name);
|
||||
qm.inventory = inventory;
|
||||
qm.dropChances = dropChances;
|
||||
return qm;
|
||||
}
|
||||
|
||||
LivingEntity entity = (LivingEntity) world.spawnEntity(spawnLocation, entityType);
|
||||
public int hashCode() {
|
||||
assert false : "hashCode not designed";
|
||||
return 42; // any arbitrary constant will do
|
||||
}
|
||||
|
||||
if (name != null) {
|
||||
entity.setCustomName(name);
|
||||
entity.setCustomNameVisible(true);
|
||||
}
|
||||
|
||||
EntityEquipment eq = entity.getEquipment();
|
||||
|
||||
try{
|
||||
eq.setItemInHand(inventory[0]);
|
||||
eq.setBoots(inventory[1]);
|
||||
eq.setLeggings(inventory[2]);
|
||||
eq.setChestplate(inventory[3]);
|
||||
eq.setHelmet(inventory[4]);
|
||||
} catch (Exception e) {
|
||||
Bukkit.getLogger().severe("Entity NMS is invalid for this version of CraftBukkit. Please notify the developer");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (dropChances[0] != null) {
|
||||
eq.setItemInHandDropChance(dropChances[0]);
|
||||
}
|
||||
if (dropChances[1] != null) {
|
||||
eq.setBootsDropChance(dropChances[1]);
|
||||
}
|
||||
if (dropChances[2] != null) {
|
||||
eq.setLeggingsDropChance(dropChances[2]);
|
||||
}
|
||||
if (dropChances[3] != null) {
|
||||
eq.setChestplateDropChance(dropChances[3]);
|
||||
}
|
||||
if (dropChances[4] != null) {
|
||||
eq.setHelmetDropChance(dropChances[4]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public String serialize() {
|
||||
String string = "";
|
||||
string += "type-" + entityType.name();
|
||||
if (name != null) {
|
||||
string += "::name-" + name;
|
||||
}
|
||||
if (spawnLocation != null) {
|
||||
string += "::spawn-" + Quests.getLocationInfo(spawnLocation);
|
||||
}
|
||||
if (spawnAmounts != null) {
|
||||
string += "::amounts-" + spawnAmounts;
|
||||
}
|
||||
|
||||
if (inventory[0] != null) {
|
||||
string += "::hand-" + ItemUtil.serialize(inventory[0]);
|
||||
string += "::hand_drop-" + dropChances[0];
|
||||
}
|
||||
|
||||
if (inventory[1] != null) {
|
||||
string += "::boots-" + ItemUtil.serialize(inventory[1]);
|
||||
string += "::boots_drop-" + dropChances[1];
|
||||
}
|
||||
|
||||
if (inventory[2] != null) {
|
||||
string += "::leggings-" + ItemUtil.serialize(inventory[2]);
|
||||
string += "::leggings_drop-" + dropChances[2];
|
||||
}
|
||||
|
||||
if (inventory[3] != null) {
|
||||
string += "::chest-" + ItemUtil.serialize(inventory[3]);
|
||||
string += "::chest_drop-" + dropChances[3];
|
||||
}
|
||||
|
||||
if (inventory[4] != null) {
|
||||
string += "::helmet-" + ItemUtil.serialize(inventory[4]);
|
||||
string += "::helmet_drop-" + dropChances[4];
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
public static QuestMob fromString(String str) {
|
||||
|
||||
String name = null;
|
||||
EntityType entityType = null;
|
||||
Location loc = null;
|
||||
Integer amounts = null;
|
||||
ItemStack[] inventory = new ItemStack[5];
|
||||
Float[] dropChances = new Float[5];
|
||||
|
||||
String[] args = str.split("::");
|
||||
for (String string : args) {
|
||||
if (string.startsWith("type-")) {
|
||||
entityType = Quests.getMobType(string.substring(5));
|
||||
} else if (string.startsWith("name-")) {
|
||||
name = string.substring(5);
|
||||
} else if (string.startsWith("spawn-")) {
|
||||
loc = Quests.getLocation(string.substring(6));
|
||||
} else if (string.startsWith("amounts-")) {
|
||||
amounts = Integer.parseInt(string.substring(8));
|
||||
} else if (string.startsWith("hand-")) {
|
||||
inventory[0] = ItemUtil.readItemStack(string.substring(5));
|
||||
} else if (string.startsWith("hand_drop-")) {
|
||||
dropChances[0] = Float.parseFloat(string.substring(10));
|
||||
} else if (string.startsWith("boots-")) {
|
||||
inventory[1] = ItemUtil.readItemStack(string.substring(6));
|
||||
} else if (string.startsWith("boots_drop-")) {
|
||||
dropChances[1] = Float.parseFloat(string.substring(11));
|
||||
} else if (string.startsWith("leggings-")) {
|
||||
inventory[2] = ItemUtil.readItemStack(string.substring(9));
|
||||
} else if (string.startsWith("leggings_drop-")) {
|
||||
dropChances[2] = Float.parseFloat(string.substring(14));
|
||||
} else if (string.startsWith("chest-")) {
|
||||
inventory[3] = ItemUtil.readItemStack(string.substring(6));
|
||||
} else if (string.startsWith("chest_drop-")) {
|
||||
dropChances[3] = Float.parseFloat(string.substring(11));
|
||||
} else if (string.startsWith("helmet-")) {
|
||||
inventory[4] = ItemUtil.readItemStack(string.substring(7));
|
||||
} else if (string.startsWith("helmet_drop-")) {
|
||||
dropChances[4] = Float.parseFloat(string.substring(12));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QuestMob qm = new QuestMob(entityType, loc, amounts);
|
||||
qm.setName(name);
|
||||
qm.inventory = inventory;
|
||||
qm.dropChances = dropChances;
|
||||
return qm;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
assert false : "hashCode not designed";
|
||||
return 42; // any arbitrary constant will do
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ((o instanceof QuestMob) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QuestMob other = (QuestMob) o;
|
||||
|
||||
if (name != null && other.name != null) {
|
||||
if (name.equalsIgnoreCase(other.name) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (name == null && other.name == null) {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!entityType.equals(other.entityType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dropChances != other.dropChances) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (inventory.length == other.inventory.length) {
|
||||
for (int i = 0; i < inventory.length; i++) {
|
||||
if (ItemUtil.compareItems(inventory[i], other.inventory[i], false) != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!spawnAmounts.equals(other.spawnAmounts)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!spawnLocation.equals(other.spawnLocation)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ((o instanceof QuestMob) == false) {
|
||||
return false;
|
||||
}
|
||||
QuestMob other = (QuestMob) o;
|
||||
if (name != null && other.name != null) {
|
||||
if (name.equalsIgnoreCase(other.name) == false) {
|
||||
return false;
|
||||
}
|
||||
} else if (name == null && other.name == null) {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (!entityType.equals(other.entityType)) {
|
||||
return false;
|
||||
}
|
||||
if (dropChances != other.dropChances) {
|
||||
return false;
|
||||
}
|
||||
if (inventory.length == other.inventory.length) {
|
||||
for (int i = 0; i < inventory.length; i++) {
|
||||
if (ItemUtil.compareItems(inventory[i], other.inventory[i], false) != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (!spawnAmounts.equals(other.spawnAmounts)) {
|
||||
return false;
|
||||
}
|
||||
if (!spawnLocation.equals(other.spawnLocation)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Store the particle effect enums, these are used to support multiple versions
|
||||
* of NMS.
|
||||
*/
|
||||
package me.blackvein.particles;
|
@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Contains all the custom classes extending exception that are used within the
|
||||
* Quests plugin.
|
||||
*/
|
||||
package me.blackvein.quests.exceptions;
|
Loading…
Reference in New Issue
Block a user