Merge pull request #6 from GregZ123/master

Reformatted code and added javadoc comments to particles enums.
This commit is contained in:
FlyingPikachu 2017-06-29 23:11:49 -04:00 committed by GitHub
commit 740a0b1786
42 changed files with 23303 additions and 30178 deletions

View File

@ -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>

View File

@ -1,18 +1,23 @@
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;

View File

@ -7,9 +7,17 @@ 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),
@ -58,26 +66,52 @@ public enum Eff_1_10_R1 {
DAMAGE_INDICATOR(EnumParticle.DAMAGE_INDICATOR),
FALLING_DUST(EnumParticle.FALLING_DUST);
/**
* The NMS EnumParticle to be sent to the player.
*/
private final EnumParticle 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;
}
/**
* 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);
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);
}
}

View File

@ -7,9 +7,17 @@ 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),
@ -60,26 +68,52 @@ public enum Eff_1_11_R1 {
SPIT(EnumParticle.SPIT),
TOTEM(EnumParticle.TOTEM);
/**
* The NMS EnumParticle to be sent to the player.
*/
private final EnumParticle 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;
}
/**
* 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);
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);
}
}

View File

@ -7,9 +7,17 @@ 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),
@ -60,26 +68,52 @@ public enum Eff_1_12_R1 {
SPIT(EnumParticle.SPIT),
TOTEM(EnumParticle.TOTEM);
/**
* The NMS EnumParticle to be sent to the player.
*/
private final EnumParticle 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;
}
/**
* 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);
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);
}
}

View File

@ -6,6 +6,15 @@ 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"),
@ -44,23 +53,46 @@ public enum Eff_1_7_R3 {
ICONCRACK("iconcrack_"),
TILECRACK("tilecrack_");
/**
* The name of the particle to be sent.
*/
private final String particleName;
/**
* 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);
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);
}
}

View File

@ -6,6 +6,15 @@ 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"),
@ -44,23 +53,46 @@ public enum Eff_1_7_R4 {
ICONCRACK("iconcrack_"),
TILECRACK("tilecrack_");
/**
* The name of the particle to be sent.
*/
private final String particleName;
/**
* 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);
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);
}
}

View File

@ -7,6 +7,15 @@ 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),
@ -52,25 +61,52 @@ public enum Eff_1_8_R1 {
TAKE(EnumParticle.ITEM_TAKE),
MOB_APPEARANCE(EnumParticle.MOB_APPEARANCE);
/**
* The NMS EnumParticle to be sent to the player.
*/
private final EnumParticle 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;
}
/**
* 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);
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);
}
}

View File

@ -7,6 +7,15 @@ 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),
@ -52,25 +61,52 @@ public enum Eff_1_8_R2 {
TAKE(EnumParticle.ITEM_TAKE),
MOB_APPEARANCE(EnumParticle.MOB_APPEARANCE);
/**
* The NMS EnumParticle to be sent to the player.
*/
private final EnumParticle 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;
}
/**
* 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);
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);
}
}

View File

@ -7,6 +7,15 @@ 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),
@ -52,25 +61,52 @@ public enum Eff_1_8_R3 {
TAKE(EnumParticle.ITEM_TAKE),
MOB_APPEARANCE(EnumParticle.MOB_APPEARANCE);
/**
* The NMS EnumParticle to be sent to the player.
*/
private final EnumParticle 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;
}
/**
* 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);
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);
}
}

View File

@ -7,6 +7,16 @@ 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),
@ -56,25 +66,52 @@ public enum Eff_1_9_R1 {
ENDROD(EnumParticle.END_ROD),
DAMAGE_INDICATOR(EnumParticle.DAMAGE_INDICATOR),;
/**
* The NMS EnumParticle to be sent to the player.
*/
private final EnumParticle 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;
}
/**
* 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);
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);
}
}

View File

@ -7,6 +7,15 @@ 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),
@ -56,25 +65,52 @@ public enum Eff_1_9_R2 {
ENDROD(EnumParticle.END_ROD),
DAMAGE_INDICATOR(EnumParticle.DAMAGE_INDICATOR),;
/**
* The NMS EnumParticle to be sent to the player.
*/
private final EnumParticle 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;
}
/**
* 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);
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);
}
}

View File

@ -83,66 +83,45 @@ public abstract class CustomObjective implements Listener {
}
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;
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
// 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())) {
@ -150,85 +129,62 @@ public abstract class CustomObjective implements Listener {
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;
}
}

View File

@ -2,6 +2,7 @@ package me.blackvein.quests;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.entity.Player;
public abstract class CustomRequirement {
@ -36,5 +37,4 @@ public abstract class CustomRequirement {
public void addDescription(String data, String description) {
descriptions.put(data, description);
}
}

View File

@ -2,6 +2,7 @@ package me.blackvein.quests;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.entity.Player;
public abstract class CustomReward {
@ -45,5 +46,4 @@ public abstract class CustomReward {
public String getRewardName() {
return rewardName;
}
}

View File

@ -7,9 +7,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.QuestMob;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.Location;
@ -23,6 +20,9 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.QuestMob;
public class Event {
Quests plugin;
@ -44,14 +44,11 @@ public class Event {
@Override
public boolean equals(Object o) {
if (o instanceof LinkedList) {
@SuppressWarnings("unchecked")
LinkedList<QuestMob> other = (LinkedList<QuestMob>) o;
if (size() != other.size()) {
return false;
}
for (int i = 0; i < size(); i++) {
if (get(i).equals(other.get(i)) == false) {
return false;
@ -76,15 +73,11 @@ public class Event {
@Override
public boolean equals(Object o) {
if (o instanceof Event) {
Event other = (Event) o;
if (other.name.equals(name) == false) {
return false;
}
if (other.message != null && message != null) {
if (other.message.equals(message) == false) {
return false;
@ -94,27 +87,21 @@ public class Event {
} else if (other.message == null && message != null) {
return false;
}
if (other.clearInv != clearInv) {
return false;
}
if (other.failQuest != failQuest) {
return false;
}
if (other.explosions.equals(explosions) == false) {
return false;
}
if (other.effects.entrySet().equals(effects.entrySet()) == false) {
return false;
}
if (other.items.equals(items) == false) {
return false;
}
if (other.stormWorld != null && stormWorld != null) {
if (other.stormWorld.equals(stormWorld) == false) {
return false;
@ -124,11 +111,9 @@ public class Event {
} else if (other.stormWorld == null && stormWorld != null) {
return false;
}
if (other.stormDuration != stormDuration) {
return false;
}
if (other.thunderWorld != null && thunderWorld != null) {
if (other.thunderWorld.equals(thunderWorld) == false) {
return false;
@ -138,43 +123,32 @@ public class Event {
} else if (other.thunderWorld == null && thunderWorld != null) {
return false;
}
if (other.thunderDuration != thunderDuration) {
return false;
}
for (QuestMob qm : mobSpawns) {
if (qm.equals(other.mobSpawns.get(mobSpawns.indexOf(qm))) == false) {
return false;
}
}
if (other.lightningStrikes.equals(lightningStrikes) == false) {
return false;
}
if (other.commands.equals(commands) == false) {
return false;
}
if (other.potionEffects.equals(potionEffects) == false) {
return false;
}
if (other.hunger != hunger) {
return false;
}
if (other.saturation != saturation) {
return false;
}
if (other.health != health) {
return false;
}
if (other.teleport != null && teleport != null) {
if (other.teleport.equals(teleport) == false) {
return false;
@ -184,143 +158,87 @@ public class Event {
} else if (other.teleport == null && teleport != null) {
return false;
}
}
return true;
}
public String getName() {
return name;
}
public void fire(Quester quester, Quest quest) {
Player player = quester.getPlayer();
if (message != null) {
player.sendMessage(Quests.parseString(message, quest));
}
if (clearInv == true) {
player.getInventory().clear();
}
if (explosions.isEmpty() == false) {
for (Location l : explosions) {
l.getWorld().createExplosion(l, 4F, false);
}
}
if (effects.isEmpty() == false) {
for (Location l : effects.keySet()) {
l.getWorld().playEffect(l, effects.get(l), 1);
}
}
if (items.isEmpty() == false) {
for (ItemStack is : items) {
Quests.addItem(player, is);
}
}
if (stormWorld != null) {
stormWorld.setStorm(true);
stormWorld.setWeatherDuration(stormDuration);
}
if (thunderWorld != null) {
thunderWorld.setThundering(true);
thunderWorld.setThunderDuration(thunderDuration);
}
if (mobSpawns.isEmpty() == false) {
for (QuestMob questMob : mobSpawns) {
questMob.spawn();
}
}
if (lightningStrikes.isEmpty() == false) {
for (Location l : lightningStrikes) {
l.getWorld().strikeLightning(l);
}
}
if (commands.isEmpty() == false) {
for (String s : commands) {
quester.plugin.getServer().dispatchCommand(quester.plugin.getServer().getConsoleSender(), s.replaceAll("<player>", quester.getPlayer().getName()));
}
}
if (potionEffects.isEmpty() == false) {
for (PotionEffect p : potionEffects) {
player.addPotionEffect(p);
}
}
if (hunger != -1) {
player.setFoodLevel(hunger);
}
if (saturation != -1) {
player.setSaturation(saturation);
}
if (health != -1) {
player.setHealth(health);
}
if (teleport != null) {
player.teleport(teleport);
}
if (failQuest == true) {
quest.failQuest(quester);
}
}
public static Event loadEvent(String name, Quests plugin) {
if (name == null || plugin == null) {
return null;
}
Event event = new Event();
FileConfiguration data = new YamlConfiguration();
try {
data.load(new File(plugin.getDataFolder(), "events.yml"));
@ -329,114 +247,79 @@ public class Event {
} catch (InvalidConfigurationException e) {
e.printStackTrace();
}
String eventKey = "events." + name + ".";
event.name = name;
if (data.contains(eventKey + "message")) {
event.message = data.getString(eventKey + "message");
}
if (data.contains(eventKey + "clear-inventory")) {
if (data.isBoolean(eventKey + "clear-inventory")) {
event.clearInv = data.getBoolean(eventKey + "clear-inventory");
} else {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "clear-inventory: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a true/false value!");
return null;
}
}
if (data.contains(eventKey + "fail-quest")) {
if (data.isBoolean(eventKey + "fail-quest")) {
event.failQuest = data.getBoolean(eventKey + "fail-quest");
} else {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "fail-quest: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a true/false value!");
return null;
}
}
if (data.contains(eventKey + "explosions")) {
if (Quests.checkList(data.getList(eventKey + "explosions"), String.class)) {
for (String s : data.getStringList(eventKey + "explosions")) {
Location loc = Quests.getLocation(s);
if (loc == null) {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + loc + ChatColor.GOLD + " inside " + ChatColor.GREEN + "explosions: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not in proper location format!");
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\"");
return null;
}
event.explosions.add(loc);
}
} else {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "explosions: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of locations!");
return null;
}
}
if (data.contains(eventKey + "effects")) {
if (Quests.checkList(data.getList(eventKey + "effects"), String.class)) {
if (data.contains(eventKey + "effect-locations")) {
if (Quests.checkList(data.getList(eventKey + "effect-locations"), String.class)) {
List<String> effectList = data.getStringList(eventKey + "effects");
List<String> effectLocs = data.getStringList(eventKey + "effect-locations");
for (String s : effectList) {
Effect effect = Quests.getEffect(s);
Location l = Quests.getLocation(effectLocs.get(effectList.indexOf(s)));
if (effect == null) {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + s + ChatColor.GOLD + " inside " + ChatColor.GREEN + "effects: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid effect name!");
return null;
}
if (l == null) {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + effectLocs.get(effectList.indexOf(s)) + ChatColor.GOLD + " inside " + ChatColor.GREEN + "effect-locations: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not in proper location format!");
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\"");
return null;
}
event.effects.put(l, effect);
}
} else {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "effect-locations: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of locations!");
return null;
}
} else {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "effect-locations:");
return null;
}
} else {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "effects: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of effects!");
return null;
}
}
if (data.contains(eventKey + "items")) {
if (Quests.checkList(data.getList(eventKey + "items"), String.class)) {
List<ItemStack> eventItems = new LinkedList<ItemStack>();
for (String s : data.getStringList(eventKey + "items")) {
try {
eventItems.add(ItemUtil.readItemStack(s));
@ -445,124 +328,89 @@ public class Event {
return null;
}
}
event.items.addAll(eventItems);
} else {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "items: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of items!");
return null;
}
}
if (data.contains(eventKey + "storm-world")) {
World w = plugin.getServer().getWorld(data.getString(eventKey + "storm-world"));
if (w == null) {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "storm-world: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid World name!");
return null;
}
if (data.contains(eventKey + "storm-duration")) {
if (data.getInt(eventKey + "storm-duration", -999) != -999) {
event.stormDuration = data.getInt(eventKey + "storm-duration") * 1000;
} else {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "storm-duration: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a number!");
return null;
}
event.stormWorld = w;
} else {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "storm-duration:");
return null;
}
}
if (data.contains(eventKey + "thunder-world")) {
World w = plugin.getServer().getWorld(data.getString(eventKey + "thunder-world"));
if (w == null) {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "thunder-world: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid World name!");
return null;
}
if (data.contains(eventKey + "thunder-duration")) {
if (data.getInt(eventKey + "thunder-duration", -999) != -999) {
event.thunderDuration = data.getInt(eventKey + "thunder-duration");
} else {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "thunder-duration: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a number!");
return null;
}
event.thunderWorld = w;
} else {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "thunder-duration:");
return null;
}
}
if (data.contains(eventKey + "mob-spawns")) {
ConfigurationSection section = data.getConfigurationSection(eventKey + "mob-spawns");
//is a mob, the keys are just a number or something.
// is a mob, the keys are just a number or something.
for (String s : section.getKeys(false)) {
String mobName = section.getString(s + ".name");
Location spawnLocation = Quests.getLocation(section.getString(s + ".spawn-location"));
EntityType type = Quests.getMobType(section.getString(s + ".mob-type"));
Integer mobAmount = section.getInt(s + ".spawn-amounts");
if (spawnLocation == null) {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + s + ChatColor.GOLD + " inside " + ChatColor.GREEN + " mob-spawn-locations: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not in proper location format!");
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Proper location format is: \"WorldName x y z\"");
return null;
}
if (type == null) {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + section.getString(s + ".mob-type") + ChatColor.GOLD + " inside " + ChatColor.GREEN + " mob-spawn-types: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid mob name!");
return null;
}
ItemStack[] inventory = new ItemStack[5];
Float[] dropChances = new Float[5];
inventory[0] = ItemUtil.readItemStack(section.getString(s + ".held-item"));
dropChances[0] = (float) section.getDouble(s + ".held-item-drop-chance");
inventory[1] = ItemUtil.readItemStack(section.getString(s + ".boots"));
dropChances[1] = (float) section.getDouble(s + ".boots-drop-chance");
inventory[2] = ItemUtil.readItemStack(section.getString(s + ".leggings"));
dropChances[2] = (float) section.getDouble(s + ".leggings-drop-chance");
inventory[3] = ItemUtil.readItemStack(section.getString(s + ".chest-plate"));
dropChances[3] = (float) section.getDouble(s + ".chest-plate-drop-chance");
inventory[4] = ItemUtil.readItemStack(section.getString(s + ".helmet"));
dropChances[4] = (float) section.getDouble(s + ".helmet-drop-chance");
QuestMob questMob = new QuestMob(type, spawnLocation, mobAmount);
questMob.inventory = inventory;
questMob.dropChances = dropChances;
questMob.setName(mobName);
event.mobSpawns.add(questMob);
}
}
if (data.contains(eventKey + "lightning-strikes")) {
if (Quests.checkList(data.getList(eventKey + "lightning-strikes"), String.class)) {
for (String s : data.getStringList(eventKey + "lightning-strikes")) {
Location loc = Quests.getLocation(s);
if (loc == null) {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + s + ChatColor.GOLD + " inside " + ChatColor.GREEN + " lightning-strikes: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not in proper location format!");
@ -570,18 +418,13 @@ public class Event {
return null;
}
event.lightningStrikes.add(loc);
}
} else {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "lightning-strikes: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of locations!");
return null;
}
}
if (data.contains(eventKey + "commands")) {
if (Quests.checkList(data.getList(eventKey + "commands"), String.class)) {
for (String s : data.getStringList(eventKey + "commands")) {
if (s.startsWith("/")) {
@ -594,98 +437,70 @@ public class Event {
return null;
}
}
if (data.contains(eventKey + "potion-effect-types")) {
if (Quests.checkList(data.getList(eventKey + "potion-effect-types"), String.class)) {
if (data.contains(eventKey + "potion-effect-durations")) {
if (Quests.checkList(data.getList(eventKey + "potion-effect-durations"), Integer.class)) {
if (data.contains(eventKey + "potion-effect-amplifiers")) {
if (Quests.checkList(data.getList(eventKey + "potion-effect-amplifiers"), Integer.class)) {
List<String> types = data.getStringList(eventKey + "potion-effect-types");
List<Integer> durations = data.getIntegerList(eventKey + "potion-effect-durations");
List<Integer> amplifiers = data.getIntegerList(eventKey + "potion-effect-amplifiers");
for (String s : types) {
PotionEffect effect = Quests.getPotionEffect(s, durations.get(types.indexOf(s)), amplifiers.get(types.indexOf(s)));
if (effect == null) {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + s + ChatColor.GOLD + " inside " + ChatColor.GREEN + " lightning-strikes: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a valid potion effect name!");
return null;
}
event.potionEffects.add(effect);
}
} else {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "potion-effect-amplifiers: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of numbers!");
return null;
}
} else {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "potion-effect-amplifiers:");
return null;
}
} else {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "potion-effect-durations: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of numbers!");
return null;
}
} else {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is missing " + ChatColor.RED + "potion-effect-durations:");
return null;
}
} else {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "potion-effect-types: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a list of potion effects!");
return null;
}
}
if (data.contains(eventKey + "hunger")) {
if (data.getInt(eventKey + "hunger", -999) != -999) {
event.hunger = data.getInt(eventKey + "hunger");
} else {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "hunger: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a number!");
return null;
}
}
if (data.contains(eventKey + "saturation")) {
if (data.getInt(eventKey + "saturation", -999) != -999) {
event.saturation = data.getInt(eventKey + "saturation");
} else {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "saturation: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a number!");
return null;
}
}
if (data.contains(eventKey + "health")) {
if (data.getInt(eventKey + "health", -999) != -999) {
event.health = data.getInt(eventKey + "health");
} else {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "health: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a number!");
return null;
}
}
if (data.contains(eventKey + "teleport-location")) {
if (data.isString(eventKey + "teleport-location")) {
Location l = Quests.getLocation(data.getString(eventKey + "teleport-location"));
if (l == null) {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + data.getString(eventKey + "teleport-location") + ChatColor.GOLD + "for " + ChatColor.GREEN + " teleport-location: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not in proper location format!");
@ -693,15 +508,11 @@ public class Event {
return null;
}
event.teleport = l;
} else {
plugin.getLogger().severe(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "teleport-location: " + ChatColor.GOLD + "inside Event " + ChatColor.DARK_PURPLE + name + ChatColor.GOLD + " is not a location!");
return null;
}
}
return event;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -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,121 +15,88 @@ 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;
public NpcListener(Quests newPlugin) {
plugin = newPlugin;
}
@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)){
} 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;
// 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))
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)) {
@ -148,49 +107,32 @@ public class NpcListener implements Listener {
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);
@ -203,122 +145,78 @@ public class NpcListener implements Listener {
} 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);
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);
}
}

View File

@ -3,10 +3,6 @@ package me.blackvein.quests;
import java.io.File;
import java.util.Iterator;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import net.citizensnpcs.api.CitizensAPI;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@ -53,90 +49,62 @@ import org.bukkit.projectiles.ProjectileSource;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import net.citizensnpcs.api.CitizensAPI;
public class PlayerListener implements Listener {
final Quests plugin;
public PlayerListener(Quests newPlugin) {
plugin = newPlugin;
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onInventoryClickEvent(InventoryClickEvent evt) {
InventoryAction ac = evt.getAction();
if(ItemUtil.isItem(evt.getCurrentItem()) && ItemUtil.isJournal(evt.getCurrentItem())) {
if(ac.equals(InventoryAction.MOVE_TO_OTHER_INVENTORY)
|| ac.equals(InventoryAction.DROP_ALL_SLOT)
|| ac.equals(InventoryAction.DROP_ONE_SLOT)) {
if (ItemUtil.isItem(evt.getCurrentItem()) && ItemUtil.isJournal(evt.getCurrentItem())) {
if (ac.equals(InventoryAction.MOVE_TO_OTHER_INVENTORY) || ac.equals(InventoryAction.DROP_ALL_SLOT) || ac.equals(InventoryAction.DROP_ONE_SLOT)) {
evt.setCancelled(true);
return;
}
} else if(ItemUtil.isItem(evt.getCurrentItem()) && ItemUtil.isJournal(evt.getCursor())) {
if(ac.equals(InventoryAction.MOVE_TO_OTHER_INVENTORY)
|| ac.equals(InventoryAction.DROP_ALL_CURSOR)
|| ac.equals(InventoryAction.DROP_ONE_CURSOR)) {
} else if (ItemUtil.isItem(evt.getCurrentItem()) && ItemUtil.isJournal(evt.getCursor())) {
if (ac.equals(InventoryAction.MOVE_TO_OTHER_INVENTORY) || ac.equals(InventoryAction.DROP_ALL_CURSOR) || ac.equals(InventoryAction.DROP_ONE_CURSOR)) {
evt.setCancelled(true);
return;
}
}
if(ItemUtil.isItem(evt.getCurrentItem()) && ItemUtil.isJournal(evt.getCurrentItem()) || ItemUtil.isItem(evt.getCursor()) && ItemUtil.isJournal(evt.getCursor())) {
if (ItemUtil.isItem(evt.getCurrentItem()) && ItemUtil.isJournal(evt.getCurrentItem()) || ItemUtil.isItem(evt.getCursor()) && ItemUtil.isJournal(evt.getCursor())) {
int upper = evt.getView().getTopInventory().getSize();
if(evt.getView().getTopInventory().getType().equals(InventoryType.CRAFTING))
if (evt.getView().getTopInventory().getType().equals(InventoryType.CRAFTING))
upper += 4;
int lower = evt.getView().getBottomInventory().getSize();
int relative = evt.getRawSlot() - upper;
if(relative < 0 || relative >= (lower)) {
if (relative < 0 || relative >= (lower)) {
evt.setCancelled(true);
return;
}
}
Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
Player player = (Player) evt.getWhoClicked();
if (evt.getInventory().getTitle().contains(Lang.get("quests"))) {
ItemStack clicked = evt.getCurrentItem();
if (clicked != null) {
for (Quest quest : plugin.quests) {
if (quest.guiDisplay != null) {
if (ItemUtil.compareItems(clicked, quest.guiDisplay, false) == 0) {
if (quester.currentQuests.size() >= Quests.maxQuests && Quests.maxQuests > 0) {
String msg = Lang.get("questMaxAllowed");
msg = msg.replaceAll("<number>", String.valueOf(Quests.maxQuests));
player.sendMessage(ChatColor.YELLOW + msg);
} else if (quester.completedQuests.contains(quest.name) && quest.redoDelay < 0) {
String completed = Lang.get("questAlreadyCompleted");
completed = completed.replaceAll("<quest>", ChatColor.AQUA + quest.name + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + completed);
} else {
boolean takeable = true;
if (quester.completedQuests.contains(quest.name)) {
if (quester.getDifference(quest) > 0) {
String early = Lang.get("questTooEarly");
early = early.replaceAll("<quest>", ChatColor.AQUA + quest.name + ChatColor.YELLOW);
@ -144,11 +112,8 @@ public class PlayerListener implements Listener {
player.sendMessage(ChatColor.YELLOW + early);
takeable = false;
}
}
if (quest.region != null) {
boolean inRegion = false;
Player p = quester.getPlayer();
RegionManager rm = Quests.worldGuard.getRegionManager(p.getWorld());
@ -160,226 +125,149 @@ public class PlayerListener implements Listener {
break;
}
}
if (inRegion == false) {
String invalidLoc = Lang.get("questInvalidLocation");
invalidLoc = invalidLoc.replaceAll("<quest>", ChatColor.AQUA + quest.name + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + invalidLoc);
takeable = false;
}
}
if (takeable == true) {
quester.takeQuest(quest, false);
}
evt.getWhoClicked().closeInventory();
}
}
}
}
evt.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onInventoryDragEvent(InventoryDragEvent evt) {
if(ItemUtil.isItem(evt.getOldCursor()) && ItemUtil.isJournal(evt.getOldCursor()) || ItemUtil.isItem(evt.getCursor()) && ItemUtil.isJournal(evt.getCursor())) {
if (ItemUtil.isItem(evt.getOldCursor()) && ItemUtil.isJournal(evt.getOldCursor()) || ItemUtil.isItem(evt.getCursor()) && ItemUtil.isJournal(evt.getCursor())) {
int upper = evt.getView().getTopInventory().getSize();
if(evt.getView().getTopInventory().getType().equals(InventoryType.CRAFTING))
if (evt.getView().getTopInventory().getType().equals(InventoryType.CRAFTING))
upper += 4;
int lower = evt.getView().getBottomInventory().getSize();
for(int relative : evt.getRawSlots()) {
for (int relative : evt.getRawSlots()) {
relative -= upper;
if(relative < 0 || relative >= (lower)) {
if (relative < 0 || relative >= (lower)) {
evt.setCancelled(true);
break;
}
}
}
}
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent evt) {
if(ItemUtil.isJournal(evt.getItemDrop().getItemStack()))
if (ItemUtil.isJournal(evt.getItemDrop().getItemStack()))
evt.setCancelled(true);
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent evt) {
if (plugin.checkQuester(evt.getPlayer().getUniqueId()) == false) {
if (evt.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
final Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
final Player player = evt.getPlayer();
boolean hasObjective = false;
for (Quest quest : quester.currentQuests.keySet()) {
if (quester.hasObjective(quest, "useBlock")) {
ItemStack i = new ItemStack(evt.getClickedBlock().getType(), 1, evt.getClickedBlock().getState().getData().toItemStack().getDurability());
quester.useBlock(quest, i);
hasObjective = true;
}
}
if (!hasObjective) {
if (plugin.questFactory.selectedBlockStarts.containsKey(evt.getPlayer().getUniqueId())) {
Block block = evt.getClickedBlock();
Location loc = block.getLocation();
plugin.questFactory.selectedBlockStarts.put(evt.getPlayer().getUniqueId(), block);
evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().name()) + ChatColor.GOLD + ")");
} else if (plugin.eventFactory.selectedExplosionLocations.containsKey(evt.getPlayer().getUniqueId())) {
Block block = evt.getClickedBlock();
Location loc = block.getLocation();
plugin.eventFactory.selectedExplosionLocations.put(evt.getPlayer().getUniqueId(), block);
evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().name()) + ChatColor.GOLD + ")");
} else if (plugin.eventFactory.selectedEffectLocations.containsKey(evt.getPlayer().getUniqueId())) {
Block block = evt.getClickedBlock();
Location loc = block.getLocation();
plugin.eventFactory.selectedEffectLocations.put(evt.getPlayer().getUniqueId(), block);
evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().name()) + ChatColor.GOLD + ")");
} else if (plugin.eventFactory.selectedMobLocations.containsKey(evt.getPlayer().getUniqueId())) {
Block block = evt.getClickedBlock();
Location loc = block.getLocation();
plugin.eventFactory.selectedMobLocations.put(evt.getPlayer().getUniqueId(), block);
evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().name()) + ChatColor.GOLD + ")");
} else if (plugin.eventFactory.selectedLightningLocations.containsKey(evt.getPlayer().getUniqueId())) {
Block block = evt.getClickedBlock();
Location loc = block.getLocation();
plugin.eventFactory.selectedLightningLocations.put(evt.getPlayer().getUniqueId(), block);
evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().name()) + ChatColor.GOLD + ")");
} else if (plugin.eventFactory.selectedTeleportLocations.containsKey(evt.getPlayer().getUniqueId())) {
Block block = evt.getClickedBlock();
Location loc = block.getLocation();
plugin.eventFactory.selectedTeleportLocations.put(evt.getPlayer().getUniqueId(), block);
evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().name()) + ChatColor.GOLD + ")");
} else if (plugin.questFactory.selectedKillLocations.containsKey(evt.getPlayer().getUniqueId())) {
Block block = evt.getClickedBlock();
Location loc = block.getLocation();
plugin.questFactory.selectedKillLocations.put(evt.getPlayer().getUniqueId(), block);
evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().name()) + ChatColor.GOLD + ")");
} else if (plugin.questFactory.selectedReachLocations.containsKey(evt.getPlayer().getUniqueId())) {
Block block = evt.getClickedBlock();
Location loc = block.getLocation();
plugin.questFactory.selectedReachLocations.put(evt.getPlayer().getUniqueId(), block);
evt.getPlayer().sendMessage(ChatColor.GOLD + Lang.get("questSelectedLocation") + " " + ChatColor.AQUA + loc.getWorld().getName() + ": " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ChatColor.GOLD + " (" + ChatColor.GREEN + Quester.prettyItemString(block.getType().name()) + ChatColor.GOLD + ")");
} else if (player.isConversing() == false) {
for (final Quest q : plugin.quests) {
if (q.blockStart != null) {
if (q.blockStart.equals(evt.getClickedBlock().getLocation())) {
if (quester.currentQuests.size() >= Quests.maxQuests && Quests.maxQuests > 0) {
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 (q.redoDelay > -1 && (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);
return;
} else if (quester.completedQuests.contains(q.name) && q.redoDelay < 0) {
String completed = Lang.get("questAlreadyCompleted");
completed = completed.replaceAll("<quest>", ChatColor.AQUA + q.name + ChatColor.YELLOW);
player.sendMessage(ChatColor.YELLOW + completed);
return;
}
}
quester.questToTake = q.name;
String s
= ChatColor.GOLD + "- " + ChatColor.DARK_PURPLE + quester.questToTake + ChatColor.GOLD + " -\n"
+ "\n"
+ ChatColor.RESET + plugin.getQuest(quester.questToTake).description + "\n";
String s = ChatColor.GOLD + "- " + ChatColor.DARK_PURPLE + quester.questToTake + ChatColor.GOLD + " -\n" + "\n" + ChatColor.RESET + plugin.getQuest(quester.questToTake).description + "\n";
for (String msg : s.split("<br>")) {
player.sendMessage(msg);
}
plugin.conversationFactory.buildConversation(player).begin();
}
break;
}
}
}
}
}
}
}
}
@SuppressWarnings("deprecation")
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent evt) {
if (evt.getRightClicked().getType() == EntityType.ITEM_FRAME) {
if(ItemUtil.isJournal(evt.getPlayer().getItemInHand())) {
if (ItemUtil.isJournal(evt.getPlayer().getItemInHand())) {
evt.setCancelled(true);
evt.getPlayer().sendMessage(ChatColor.RED + Lang.get("journalDenied"));
}
@ -388,13 +276,9 @@ public class PlayerListener implements Listener {
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent evt) {
if (plugin.checkQuester(evt.getPlayer().getUniqueId()) == false) {
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
if (quester.currentQuests.isEmpty() == false) {
for (Quest quest : quester.currentQuests.keySet()) {
Stage currentStage = quester.getCurrentStage(quest);
if (currentStage == null) {
@ -403,107 +287,66 @@ public class PlayerListener implements Listener {
}
continue;
}
if (currentStage.chatEvents.isEmpty() == false) {
String chat = evt.getMessage();
for (String s : currentStage.chatEvents.keySet()) {
if (s.equalsIgnoreCase(chat)) {
if (quester.getQuestData(quest).eventFired.get(s) == null || quester.getQuestData(quest).eventFired.get(s) == false) {
currentStage.chatEvents.get(s).fire(quester, quest);
quester.getQuestData(quest).eventFired.put(s, true);
}
}
}
}
if (quester.hasObjective(quest, "password")) {
quester.sayPass(quest, evt);
}
}
}
}
}
@EventHandler
public void onBlockDamage(BlockDamageEvent evt) {
if (plugin.checkQuester(evt.getPlayer().getUniqueId()) == false) {
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
for (Quest quest : quester.currentQuests.keySet()) {
if (quester.hasObjective(quest, "damageBlock")) {
ItemStack i = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState().getData().toItemStack().getDurability());
quester.damageBlock(quest, i);
}
}
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockPlace(BlockPlaceEvent evt) {
if (plugin.checkQuester(evt.getPlayer().getUniqueId()) == false) {
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
for (Quest quest : quester.currentQuests.keySet()) {
if (quester.hasObjective(quest, "placeBlock")) {
if (evt.isCancelled() == false) {
ItemStack i = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState().getData().toItemStack().getDurability());
quester.placeBlock(quest, i);
}
}
}
}
}
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent evt) {
if (plugin.checkQuester(evt.getPlayer().getUniqueId()) == false) {
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
for (Quest quest : quester.currentQuests.keySet()) {
if (quester.hasObjective(quest, "breakBlock")) {
if (evt.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH) == false && evt.isCancelled() == false) {
ItemStack i = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState().getData().toItemStack().getDurability());
quester.breakBlock(quest, i);
}
}
if (quester.hasObjective(quest, "placeBlock")) {
for (ItemStack is : quester.getQuestData(quest).blocksPlaced) {
if (is.getAmount() > 0) {
if (evt.isCancelled() == false) {
@ -513,355 +356,224 @@ public class PlayerListener implements Listener {
}
}
}
}
if (evt.getPlayer().getItemInHand().getType().equals(Material.SHEARS) && quester.hasObjective(quest, "cutBlock")) {
ItemStack i = new ItemStack(evt.getBlock().getType(), 1, evt.getBlock().getState().getData().toItemStack().getDurability());
quester.cutBlock(quest, i);
}
}
}
}
@EventHandler
public void onPlayerShearEntity(PlayerShearEntityEvent evt) {
if (plugin.checkQuester(evt.getPlayer().getUniqueId()) == false) {
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
for (Quest quest : quester.currentQuests.keySet()) {
if (evt.getEntity().getType() == EntityType.SHEEP && quester.hasObjective(quest, "shearSheep")) {
Sheep sheep = (Sheep) evt.getEntity();
quester.shearSheep(quest, sheep.getColor());
}
}
}
}
@EventHandler
public void onEntityTame(EntityTameEvent evt) {
if (evt.getOwner() instanceof Player) {
Player p = (Player) evt.getOwner();
if (plugin.checkQuester(p.getUniqueId()) == false) {
Quester quester = plugin.getQuester(p.getUniqueId());
for (Quest quest : quester.currentQuests.keySet()) {
if (quester.hasObjective(quest, "tameMob")) {
quester.tameMob(quest, evt.getEntityType());
}
}
}
}
}
@EventHandler
public void onEnchantItem(EnchantItemEvent evt) {
if (plugin.checkQuester(evt.getEnchanter().getUniqueId()) == false) {
Quester quester = plugin.getQuester(evt.getEnchanter().getUniqueId());
for (Quest quest : quester.currentQuests.keySet()) {
if (quester.hasObjective(quest, "enchantItem")) {
for (Enchantment e : evt.getEnchantsToAdd().keySet()) {
quester.enchantItem(quest, e, evt.getItem().getType());
}
}
}
}
}
@EventHandler
public void onEntityDeath(EntityDeathEvent evt) {
//NPCs count as a Player so we check for them through Citizens
// NPCs count as a Player so we check for them through Citizens
boolean isTargetNPC = false;
if (plugin.citizens != null) {
if (CitizensAPI.getNPCRegistry().isNPC(evt.getEntity())) {
isTargetNPC = true;
}
}
if (evt.getEntity() instanceof Player == false || isTargetNPC) {
if (evt.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent damageEvent = (EntityDamageByEntityEvent) evt.getEntity().getLastDamageCause();
Entity damager = damageEvent.getDamager();
if (damager != null) {
if (damager instanceof Projectile) {
Projectile projectile = (Projectile)damager;
Projectile projectile = (Projectile) damager;
ProjectileSource source = projectile.getShooter();
if (source instanceof Player) {
Player player = (Player) source;
boolean okay = true;
if (plugin.citizens != null) {
if (CitizensAPI.getNPCRegistry().isNPC(player)) {
okay = false;
}
}
if (okay) {
if (isTargetNPC) {
Quester quester = plugin.getQuester(player.getUniqueId());
for (Quest quest : quester.currentQuests.keySet()) {
if (quester.hasObjective(quest, "killNPC")) {
quester.killNPC(quest, CitizensAPI.getNPCRegistry().getNPC(evt.getEntity()));
}
}
} else {
Quester quester = plugin.getQuester(player.getUniqueId());
for (Quest quest : quester.currentQuests.keySet()) {
if (quester.hasObjective(quest, "killMob")) {
quester.killMob(quest, evt.getEntity().getLocation(), evt.getEntity().getType());
}
}
}
}
}
} else if (damager instanceof TNTPrimed) {
TNTPrimed tnt = (TNTPrimed)damager;
TNTPrimed tnt = (TNTPrimed) damager;
Entity source = tnt.getSource();
if(source instanceof Player) {
if (source instanceof Player) {
Player player = (Player) source;
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, "killMob")) {
quester.killMob(quest, evt.getEntity().getLocation(), evt.getEntity().getType());
}
}
}
}
}
} else if (damager instanceof Player) {
boolean okay = true;
if (plugin.citizens != null) {
if (CitizensAPI.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, "killMob")) {
quester.killMob(quest, evt.getEntity().getLocation(), evt.getEntity().getType());
}
}
}
}
}
}
}
}
}
@EventHandler
public void onPlayerDeath(PlayerDeathEvent evt) {
if (evt.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent damageEvent = (EntityDamageByEntityEvent) evt.getEntity().getLastDamageCause();
Entity damager = damageEvent.getDamager();
if (damager != null) {
if (damager instanceof Projectile) {
if(evt.getEntity().getLastDamageCause().getEntity() instanceof Player) {
if (evt.getEntity().getLastDamageCause().getEntity() instanceof Player) {
Player player = (Player) evt.getEntity().getLastDamageCause().getEntity();
if (plugin.checkQuester(player.getUniqueId()) == false) {
boolean okay = true;
if (plugin.citizens != null) {
if (CitizensAPI.getNPCRegistry().isNPC(player) || CitizensAPI.getNPCRegistry().isNPC(evt.getEntity())) {
okay = false;
}
}
if (okay) {
Quester quester = plugin.getQuester(player.getUniqueId());
for (Quest quest : quester.currentQuests.keySet()) {
if (quester.hasObjective(quest, "killPlayer")) {
quester.killPlayer(quest, evt.getEntity());
}
}
}
}
}
} else if (damager instanceof Player) {
Player player = (Player) damager;
if (plugin.checkQuester(player.getUniqueId()) == false) {
boolean okay = true;
if (plugin.citizens != null) {
if (CitizensAPI.getNPCRegistry().isNPC(player) || CitizensAPI.getNPCRegistry().isNPC(evt.getEntity())) {
okay = false;
}
}
if (okay) {
Quester quester = plugin.getQuester(player.getUniqueId());
for (Quest quest : quester.currentQuests.keySet()) {
if (quester.hasObjective(quest, "killPlayer")) {
quester.killPlayer(quest, evt.getEntity());
}
}
}
}
}
}
}
}
}
Player player = evt.getEntity();
if (plugin.checkQuester(player.getUniqueId()) == false) {
Quester quester = plugin.getQuester(player.getUniqueId());
for (Quest quest : quester.currentQuests.keySet()) {
Stage stage = quester.getCurrentStage(quest);
if (stage != null && stage.deathEvent != null) {
quester.getCurrentStage(quest).deathEvent.fire(quester, quest);
}
}
}
ItemStack found = null;
for(ItemStack stack : evt.getDrops()) {
if(ItemUtil.isJournal(stack)) {
for (ItemStack stack : evt.getDrops()) {
if (ItemUtil.isJournal(stack)) {
found = stack;
break;
}
}
if(found != null) {
if (found != null) {
Quester quester = plugin.getQuester(player.getUniqueId());
evt.getDrops().remove(found);
quester.hasJournal = false;
}
}
@EventHandler
public void onPlayerFish(PlayerFishEvent evt) {
Player player = evt.getPlayer();
if (plugin.checkQuester(player.getUniqueId()) == false) {
Quester quester = plugin.getQuester(player.getUniqueId());
for (Quest quest : quester.currentQuests.keySet()) {
if (quester.hasObjective(quest, "catchFish") && evt.getState().equals(State.CAUGHT_FISH)) {
quester.catchFish(quest);
}
}
}
}
@EventHandler
@ -879,6 +591,7 @@ public class PlayerListener implements Listener {
if (plugin.checkQuester(player.getUniqueId()) == false) {
final Quester quester = plugin.getQuester(player.getUniqueId());
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
quester.findCompassTarget();
@ -889,9 +602,7 @@ public class PlayerListener implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent evt) {
if (plugin.checkQuester(evt.getPlayer().getUniqueId()) == false) {
Quester quester = new Quester(plugin);
quester.id = evt.getPlayer().getUniqueId();
if (new File(plugin.getDataFolder(), "data/" + quester.id + ".yml").exists()) {
@ -899,55 +610,35 @@ public class PlayerListener implements Listener {
} else if (Quests.genFilesOnJoin) {
quester.saveData();
}
plugin.questers.put(evt.getPlayer().getUniqueId(), quester);
if (Quests.useCompass) {
quester.resetCompass();
}
for (String s : quester.completedQuests) {
Quest q = plugin.getQuest(s);
if (q != null) {
if (quester.completedTimes.containsKey(q.name) == false && q.redoDelay > -1) {
quester.completedTimes.put(q.name, System.currentTimeMillis());
}
}
}
for (Quest quest : quester.currentQuests.keySet()) {
quester.checkQuest(quest);
}
for (Quest quest : quester.currentQuests.keySet()) {
if (quester.getCurrentStage(quest).delay > -1) {
quester.startStageTimer(quest);
}
}
if(quester.hasJournal)
if (quester.hasJournal)
quester.updateJournal();
}
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent evt) {
if (plugin.checkQuester(evt.getPlayer().getUniqueId()) == false) {
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
for (Quest quest : quester.currentQuests.keySet()) {
Stage currentStage = quester.getCurrentStage(quest);
if (currentStage == null) {
@ -956,63 +647,43 @@ public class PlayerListener implements Listener {
}
continue;
}
if (currentStage.delay > -1) {
quester.stopStageTimer(quest);
}
if (currentStage.disconnectEvent != null) {
currentStage.disconnectEvent.fire(quester, quest);
}
}
if (quester.hasData()) {
quester.saveData();
}
if (plugin.questFactory.selectingNPCs.contains(evt.getPlayer())) {
plugin.questFactory.selectingNPCs.remove(evt.getPlayer());
}
plugin.questers.remove(quester.id);
}
}
@EventHandler
public void onPlayerMove(PlayerMoveEvent evt) {
if (evt.getFrom().getBlock().equals(evt.getTo().getBlock())) {
return;
}
if (plugin.checkQuester(evt.getPlayer().getUniqueId()) == false) {
boolean isPlayer = true;
if (plugin.citizens != null) {
if (CitizensAPI.getNPCRegistry().isNPC(evt.getPlayer())) {
isPlayer = false;
}
}
if (isPlayer) {
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
for (Quest quest : quester.currentQuests.keySet()) {
if (quester.hasObjective(quest, "reachLocation")) {
quester.reachLocation(quest, evt.getTo());
}
}
}
}
}
}

View File

@ -1,5 +1,17 @@
package me.blackvein.quests;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import com.codisimus.plugins.phatloots.PhatLootsAPI;
import com.codisimus.plugins.phatloots.loot.CommandLoot;
import com.codisimus.plugins.phatloots.loot.LootBundle;
@ -9,23 +21,11 @@ import com.herocraftonline.heroes.characters.Hero;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import me.blackvein.quests.exceptions.InvalidStageException;
import me.blackvein.quests.util.ItemUtil;
import me.blackvein.quests.util.Lang;
import net.citizensnpcs.api.npc.NPC;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
public class Quest {
public String name;
@ -40,8 +40,7 @@ public class Quest {
Location blockStart;
Quests plugin;
Event initialEvent;
//Requirements
// Requirements
int moneyReq = 0;
int questPointsReq = 0;
List<ItemStack> items = new LinkedList<ItemStack>();
@ -55,11 +54,9 @@ public class Quest {
String heroesSecondaryClassReq = null;
Map<String, Map<String, Object>> customRequirements = new HashMap<String, Map<String, Object>>();
Map<String, Map<String, Object>> customRewards = new HashMap<String, Map<String, Object>>();
public String failRequirements = null;
//
//Rewards
// Rewards
int moneyReward = 0;
int questPoints = 0;
int exp = 0;
@ -84,7 +81,6 @@ public class Quest {
}
public void nextStage(Quester q) {
String stageCompleteMessage = q.getCurrentStage(this).completeMessage;
if (stageCompleteMessage != null) {
q.getPlayer().sendMessage(Quests.parseString(stageCompleteMessage, this));
@ -93,112 +89,83 @@ public class Quest {
q.resetCompass();
q.findCompassTarget();
}
if (q.getCurrentStage(this).delay < 0) {
Player player = q.getPlayer();
if (q.currentQuests.get(this) == (orderedStages.size() - 1)) {
if (q.getCurrentStage(this).script != null) {
plugin.trigger.parseQuestTaskTrigger(q.getCurrentStage(this).script, player);
}
if (q.getCurrentStage(this).finishEvent != null) {
q.getCurrentStage(this).finishEvent.fire(q, this);
}
completeQuest(q);
} else {
try {
setStage(q, q.currentQuests.get(this) + 1);
} catch (InvalidStageException e) {
e.printStackTrace();
}
}
if(q.getQuestData(this) != null) {
if (q.getQuestData(this) != null) {
q.getQuestData(this).delayStartTime = 0;
q.getQuestData(this).delayTimeLeft = -1;
}
} else {
q.startStageTimer(this);
}
q.updateJournal();
}
public void setStage(Quester quester, int stage) throws InvalidStageException {
if (orderedStages.size() - 1 < stage) {
throw new InvalidStageException(this, stage);
}
Stage currentStage = quester.getCurrentStage(this);
quester.hardQuit(this);
quester.hardStagePut(this, stage);
quester.addEmptiesFor(this, stage);
if (currentStage.script != null) {
plugin.trigger.parseQuestTaskTrigger(currentStage.script, quester.getPlayer());
}
/*if (quester.getCurrentStage(this).finishEvent != null) {
quester.getCurrentStage(this).finishEvent.fire(quester);
}*/
/*
* if (quester.getCurrentStage(this).finishEvent != null) { quester.getCurrentStage(this).finishEvent.fire(quester); }
*/
Stage nextStage = quester.getCurrentStage(this);
if (nextStage.startEvent != null) {
nextStage.startEvent.fire(quester, this);
}
updateCompass(quester, nextStage);
String msg = Lang.get("questObjectivesTitle");
msg = msg.replaceAll("<quest>", name);
quester.getPlayer().sendMessage(ChatColor.GOLD + msg);
for (String s : quester.getObjectivesReal(this)) {
quester.getPlayer().sendMessage(s);
}
String stageStartMessage = quester.getCurrentStage(this).startMessage;
if (stageStartMessage != null) {
quester.getPlayer().sendMessage(Quests.parseString(stageStartMessage, this));
}
quester.updateJournal();
}
public boolean updateCompass(Quester quester, Stage nextStage)
{
if (!Quests.useCompass) return false;
public boolean updateCompass(Quester quester, Stage nextStage) {
if (!Quests.useCompass)
return false;
Location targetLocation = null;
if (nextStage == null) {
return false;
}
if (nextStage.citizensToInteract != null && nextStage.citizensToInteract.size() > 0)
{
if (nextStage.citizensToInteract != null && nextStage.citizensToInteract.size() > 0) {
targetLocation = plugin.getNPCLocation(nextStage.citizensToInteract.getFirst());
}
else if (nextStage.citizensToKill != null && nextStage.citizensToKill.size() > 0)
{
} else if (nextStage.citizensToKill != null && nextStage.citizensToKill.size() > 0) {
targetLocation = plugin.getNPCLocation(nextStage.citizensToKill.getFirst());
}
else if (nextStage.locationsToReach != null && nextStage.locationsToReach.size() > 0)
{
} else if (nextStage.locationsToReach != null && nextStage.locationsToReach.size() > 0) {
targetLocation = nextStage.locationsToReach.getFirst();
}
if (targetLocation != null && targetLocation.getWorld().equals(quester.getPlayer().getWorld())) {
// plugin.getLogger().info("Setting compass target for " + quester.getPlayer().getName() + " to " + targetLocation);
quester.getPlayer().setCompassTarget(targetLocation);
}
return targetLocation != null;
}
@ -212,72 +179,48 @@ public class Quest {
@SuppressWarnings("deprecation")
public boolean testRequirements(Player player) {
Quester quester = plugin.getQuester(player.getUniqueId());
if (moneyReq != 0 && Quests.economy.getBalance(player.getName()) < moneyReq) {
return false;
}
PlayerInventory inventory = player.getInventory();
int num = 0;
for (ItemStack is : items) {
for (ItemStack stack : inventory.getContents()) {
if (stack != null) {
if (ItemUtil.compareItems(is, stack, true) == 0) {
num += stack.getAmount();
}
}
}
if (num < is.getAmount()) {
return false;
}
num = 0;
}
for (String s : permissionReqs) {
if (player.hasPermission(s) == false) {
return false;
}
}
for (String s : mcMMOSkillReqs) {
final SkillType st = Quests.getMcMMOSkill(s);
final int lvl = mcMMOAmountReqs.get(mcMMOSkillReqs.indexOf(s));
if (UserManager.getPlayer(player).getProfile().getSkillLevel(st) < lvl) {
return false;
}
}
if (heroesPrimaryClassReq != null) {
if (plugin.testPrimaryHeroesClass(heroesPrimaryClassReq, player.getUniqueId()) == false) {
return false;
}
}
if (heroesSecondaryClassReq != null) {
if (plugin.testSecondaryHeroesClass(heroesSecondaryClassReq, player.getUniqueId()) == false) {
return false;
}
}
for (String s : customRequirements.keySet()) {
CustomRequirement found = null;
for (CustomRequirement cr : plugin.customRequirements) {
if (cr.getName().equalsIgnoreCase(s)) {
@ -285,7 +228,6 @@ public class Quest {
break;
}
}
if (found != null) {
if (found.testRequirement(player, customRequirements.get(s)) == false) {
return false;
@ -293,41 +235,33 @@ public class Quest {
} else {
plugin.getLogger().warning("[Quests] Quester \"" + player.getName() + "\" attempted to take Quest \"" + name + "\", but the Custom Requirement \"" + s + "\" could not be found. Does it still exist?");
}
}
if (quester.questPoints < questPointsReq) {
return false;
}
if (quester.completedQuests.containsAll(neededQuests) == false) {
return false;
}
for (String q : blockQuests) {
//TODO make sure this works
// TODO make sure this works
Quest questObject = new Quest();
questObject.name = q;
if (quester.completedQuests.contains(q) || quester.currentQuests.containsKey(questObject)) {
return false;
}
}
return true;
}
@SuppressWarnings("deprecation")
public void completeQuest(Quester q) {
final Player player = plugin.getServer().getPlayer(q.id);
q.hardQuit(this);
q.completedQuests.add(name);
String none = ChatColor.GRAY + "- (" + Lang.get("none") + ")";
final String ps = Quests.parseString(finished, this);
org.bukkit.Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
for (String msg : ps.split("<br>")) {
@ -335,7 +269,6 @@ public class Quest {
}
}
}, 40);
if (moneyReward > 0 && Quests.economy != null) {
Quests.economy.depositPlayer(q.getOfflinePlayer(), moneyReward);
none = null;
@ -343,158 +276,112 @@ public class Quest {
if (redoDelay > -1) {
q.completedTimes.put(this.name, System.currentTimeMillis());
}
for (ItemStack i : itemRewards) {
Quests.addItem(player, i);
none = null;
}
for (String s : commands) {
s = s.replaceAll("<player>", player.getName());
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), s);
none = null;
}
for (String s : permissions) {
Quests.permission.playerAdd(player, s);
none = null;
}
for (String s : mcmmoSkills) {
UserManager.getPlayer(player).getProfile().addLevels(Quests.getMcMMOSkill(s), mcmmoAmounts.get(mcmmoSkills.indexOf(s)));
none = null;
}
for (String s : heroesClasses) {
Hero hero = plugin.getHero(player.getUniqueId());
hero.addExp(heroesAmounts.get(heroesClasses.indexOf(s)), Quests.heroes.getClassManager().getClass(s), player.getLocation());
none = null;
}
LinkedList<ItemStack> phatLootItems = new LinkedList<ItemStack>();
int phatLootExp = 0;
LinkedList<String> phatLootMessages = new LinkedList<String>();
for (String s : phatLootRewards) {
LootBundle lb = PhatLootsAPI.getPhatLoot(s).rollForLoot();
if (lb.getExp() > 0) {
phatLootExp += lb.getExp();
player.giveExp(lb.getExp());
}
if (lb.getMoney() > 0) {
Quests.economy.depositPlayer(player.getName(), lb.getMoney());
}
if (lb.getItemList().isEmpty() == false) {
phatLootItems.addAll(lb.getItemList());
for (ItemStack is : lb.getItemList()) {
Quests.addItem(player, is);
}
}
if (lb.getCommandList().isEmpty() == false) {
for (CommandLoot cl : lb.getCommandList()) {
cl.execute(player);
}
}
if (lb.getMessageList().isEmpty() == false) {
phatLootMessages.addAll(lb.getMessageList());
}
}
if (exp > 0) {
player.giveExp(exp);
none = null;
}
String complete = Lang.get("questCompleteTitle");
complete = complete.replaceAll("<quest>", ChatColor.YELLOW + name + ChatColor.GOLD);
player.sendMessage(ChatColor.GOLD + complete);
player.sendMessage(ChatColor.GREEN + Lang.get("questRewardsTitle"));
if (questPoints > 0) {
player.sendMessage("- " + ChatColor.DARK_GREEN + questPoints + " " + Lang.get("questPoints"));
q.questPoints += questPoints;
none = null;
}
for (ItemStack i : itemRewards) {
if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) {
if (i.getEnchantments().isEmpty()) {
player.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount());
} else {
player.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get("enchantedItem"));
}
} else if (i.getDurability() != 0) {
if (i.getEnchantments().isEmpty()) {
player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getType().name()) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount());
} else {
player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getType().name()) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get("enchantedItem"));
}
} else {
if (i.getEnchantments().isEmpty()) {
player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getType().name()) + ChatColor.GRAY + " x " + i.getAmount());
} else {
player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getType().name()) + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get("enchantedItem"));
}
}
none = null;
}
for (ItemStack i : phatLootItems) {
if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) {
if (i.getEnchantments().isEmpty()) {
player.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount());
} else {
player.sendMessage("- " + ChatColor.DARK_AQUA + ChatColor.ITALIC + i.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get("enchantedItem"));
}
} else if (i.getDurability() != 0) {
if (i.getEnchantments().isEmpty()) {
player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getType().name()) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount());
} else {
player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getType().name()) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get("enchantedItem"));
}
} else {
if (i.getEnchantments().isEmpty()) {
player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getType().name()) + ChatColor.GRAY + " x " + i.getAmount());
} else {
player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getType().name()) + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " " + Lang.get("enchantedItem"));
}
}
none = null;
}
if (moneyReward > 1) {
player.sendMessage("- " + ChatColor.DARK_GREEN + moneyReward + " " + ChatColor.DARK_PURPLE + Quests.getCurrency(true));
none = null;
@ -502,37 +389,30 @@ public class Quest {
player.sendMessage("- " + ChatColor.DARK_GREEN + moneyReward + " " + ChatColor.DARK_PURPLE + Quests.getCurrency(false));
none = null;
}
if (exp > 0 || phatLootExp > 0) {
int tot = exp + phatLootExp;
player.sendMessage("- " + ChatColor.DARK_GREEN + tot + ChatColor.DARK_PURPLE + " " + Lang.get("experience"));
none = null;
}
if (mcmmoSkills.isEmpty() == false) {
for (String s : mcmmoSkills) {
player.sendMessage("- " + ChatColor.DARK_GREEN + mcmmoAmounts.get(mcmmoSkills.indexOf(s)) + " " + ChatColor.DARK_PURPLE + s + " " + Lang.get("experience"));
}
none = null;
}
if (heroesClasses.isEmpty() == false) {
for (String s : heroesClasses) {
player.sendMessage("- " + ChatColor.AQUA + heroesAmounts.get(heroesClasses.indexOf(s)) + " " + ChatColor.BLUE + s + " " + Lang.get("experience"));
}
none = null;
}
if (phatLootMessages.isEmpty() == false) {
for (String s : phatLootMessages) {
player.sendMessage("- " + s);
}
none = null;
}
for (String s : customRewards.keySet()) {
CustomReward found = null;
for (CustomReward cr : plugin.customRewards) {
if (cr.getName().equalsIgnoreCase(s)) {
@ -540,11 +420,9 @@ public class Quest {
break;
}
}
if (found != null) {
Map<String, Object> datamap = customRewards.get(found.getName());
String message = found.getRewardName();
for (String key : datamap.keySet()) {
message = message.replaceAll("%" + ((String) key) + "%", ((String) datamap.get(key)));
}
@ -553,15 +431,11 @@ public class Quest {
} else {
plugin.getLogger().warning("[Quests] Quester \"" + player.getName() + "\" completed the Quest \"" + name + "\", but the Custom Reward \"" + s + "\" could not be found. Does it still exist?");
}
none = null;
}
if (none != null) {
player.sendMessage(none);
}
q.saveData();
player.updateInventory();
q.updateJournal();
@ -570,29 +444,21 @@ public class Quest {
@SuppressWarnings("deprecation")
public void failQuest(Quester q) {
Player player = plugin.getServer().getPlayer(q.id);
String title = Lang.get("questTitle");
title = title.replaceAll("<quest>", ChatColor.DARK_PURPLE + name + ChatColor.AQUA);
player.sendMessage(ChatColor.AQUA + title);
player.sendMessage(ChatColor.RED + Lang.get("questFailed"));
q.hardQuit(this);
q.saveData();
player.updateInventory();
q.updateJournal();
}
@Override
public boolean equals(Object o) {
if (o instanceof Quest) {
Quest other = (Quest) o;
if (other.blockStart != null && blockStart != null) {
if (other.blockStart.equals(blockStart) == false) {
return false;
@ -602,23 +468,18 @@ public class Quest {
} else if (other.blockStart == null && blockStart != null) {
return false;
}
if (commands.size() == other.commands.size()) {
for (int i = 0; i < commands.size(); i++) {
if (commands.get(i).equals(other.commands.get(i)) == false) {
return false;
}
}
} else {
return false;
}
if (other.description.equals(description) == false) {
return false;
}
if (other.initialEvent != null && initialEvent != null) {
if (other.initialEvent.equals(initialEvent) == false) {
return false;
@ -628,11 +489,9 @@ public class Quest {
} else if (other.initialEvent == null && initialEvent != null) {
return false;
}
if (other.exp != exp) {
return false;
}
if (other.failRequirements != null && failRequirements != null) {
if (other.failRequirements.equals(failRequirements) == false) {
return false;
@ -642,67 +501,51 @@ public class Quest {
} else if (other.failRequirements == null && failRequirements != null) {
return false;
}
if (other.finished.equals(finished) == false) {
return false;
}
if (other.items.equals(items) == false) {
return false;
}
if (other.itemRewards.equals(itemRewards) == false) {
return false;
}
if (other.rpgItemRewardIDs.equals(rpgItemRewardIDs) == false) {
return false;
}
if (other.rpgItemRewardAmounts.equals(rpgItemRewardAmounts) == false) {
return false;
}
if (other.mcmmoAmounts.equals(mcmmoAmounts) == false) {
return false;
}
if (other.mcmmoSkills.equals(mcmmoSkills) == false) {
return false;
}
if (other.heroesClasses.equals(heroesClasses) == false) {
return false;
}
if (other.heroesAmounts.equals(heroesAmounts) == false) {
return false;
}
if (other.phatLootRewards.equals(phatLootRewards) == false) {
return false;
}
if (other.moneyReq != moneyReq) {
return false;
}
if (other.moneyReward != moneyReward) {
return false;
}
if (other.name.equals(name) == false) {
return false;
}
if (other.neededQuests.equals(neededQuests) == false) {
return false;
}
if (other.blockQuests.equals(blockQuests) == false) {
return false;
}
if (other.npcStart != null && npcStart != null) {
if (other.npcStart.equals(npcStart) == false) {
return false;
@ -712,11 +555,9 @@ public class Quest {
} else if (other.npcStart == null && npcStart != null) {
return false;
}
if (other.permissionReqs.equals(permissionReqs) == false) {
return false;
}
if (other.heroesPrimaryClassReq != null && heroesPrimaryClassReq != null) {
if (other.heroesPrimaryClassReq.equals(heroesPrimaryClassReq) == false) {
return false;
@ -726,7 +567,6 @@ public class Quest {
} else if (other.heroesPrimaryClassReq == null && heroesPrimaryClassReq != null) {
return false;
}
if (other.heroesSecondaryClassReq != null && heroesSecondaryClassReq != null) {
if (other.heroesSecondaryClassReq.equals(heroesSecondaryClassReq) == false) {
return false;
@ -736,49 +576,37 @@ public class Quest {
} else if (other.heroesSecondaryClassReq == null && heroesSecondaryClassReq != null) {
return false;
}
if (other.customRequirements.equals(customRequirements) == false) {
return false;
}
if (other.customRewards.equals(customRewards) == false) {
return false;
}
if (other.permissions.equals(permissions) == false) {
return false;
}
if (other.mcMMOSkillReqs.equals(mcMMOSkillReqs) == false) {
return false;
}
if (other.mcMMOAmountReqs.equals(mcMMOAmountReqs) == false) {
return false;
}
if (other.questPoints != questPoints) {
return false;
}
if (other.questPointsReq != questPointsReq) {
return false;
}
if (other.redoDelay != redoDelay) {
return false;
}
if (other.orderedStages.equals(orderedStages) == false) {
return false;
}
} else {
return false;
}
return true;
}
@Override
@ -824,23 +652,18 @@ public class Quest {
}
public boolean isInRegion(Player player) {
if (region == null) {
return true;
} else {
ApplicableRegionSet ars = Quests.worldGuard.getRegionManager(player.getWorld()).getApplicableRegions(player.getLocation());
Iterator<ProtectedRegion> i = ars.iterator();
while (i.hasNext()) {
ProtectedRegion pr = i.next();
if (pr.getId().equalsIgnoreCase(region)) {
return true;
}
}
return false;
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,11 @@
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 {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -23,13 +23,11 @@ public class Stage {
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>() {
@ -37,55 +35,38 @@ public class Stage {
@Override
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>() {
private static final long serialVersionUID = -4086855121042524435L;
@Override
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>() {
@ -93,29 +74,20 @@ public class Stage {
@Override
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>();
@ -148,31 +120,23 @@ public class Stage {
@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;
@ -182,7 +146,6 @@ public class Stage {
} else if (other.fishToCatch == null && fishToCatch != null) {
return false;
}
if (other.playersToKill != null && playersToKill != null) {
if (other.playersToKill.equals(playersToKill) == false) {
return false;
@ -192,103 +155,78 @@ public class Stage {
} 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;
@ -298,7 +236,6 @@ public class Stage {
} else if (other.script == null && script != null) {
return false;
}
if (other.startEvent != null && startEvent != null) {
if (other.startEvent.equals(startEvent) == false) {
return false;
@ -308,7 +245,6 @@ public class Stage {
} else if (other.startEvent == null && startEvent != null) {
return false;
}
if (other.deathEvent != null && deathEvent != null) {
if (other.deathEvent.equals(deathEvent) == false) {
return false;
@ -318,7 +254,6 @@ public class Stage {
} else if (other.deathEvent == null && deathEvent != null) {
return false;
}
if (other.finishEvent != null && finishEvent != null) {
if (other.finishEvent.equals(finishEvent) == false) {
return false;
@ -328,15 +263,12 @@ public class Stage {
} 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;
@ -346,7 +278,6 @@ public class Stage {
} else if (other.delayMessage == null && delayMessage != null) {
return false;
}
if (other.startMessage != null && startMessage != null) {
if (other.startMessage.equals(startMessage) == false) {
return false;
@ -356,7 +287,6 @@ public class Stage {
} else if (other.startMessage == null && startMessage != null) {
return false;
}
if (other.completeMessage != null && completeMessage != null) {
if (other.completeMessage.equals(completeMessage) == false) {
return false;
@ -366,7 +296,6 @@ public class Stage {
} else if (other.completeMessage == null && completeMessage != null) {
return false;
}
if (other.objectiveOverride != null && objectiveOverride != null) {
if (other.objectiveOverride.equals(objectiveOverride) == false) {
return false;
@ -376,11 +305,7 @@ public class Stage {
} else if (other.objectiveOverride == null && objectiveOverride != null) {
return false;
}
}
return true;
}
}

View File

@ -1,9 +1,10 @@
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;
@ -11,72 +12,51 @@ public class StageTimer implements Runnable {
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();
}
}
}

View File

@ -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 {
/**
* The version id to use when serialising and deserialising this class.
*/
private static final long serialVersionUID = 1778748295752972651L;
/**
* The Quest instance that an invalid stage was set within.
*/
private final Quest quest;
/**
* The invalid stage number that was attempted to be set.
*/
private final int stage;
/**
* 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;
}
/**
* 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;
}
private static final long serialVersionUID = 1778748295752972651L;
@Override
public void printStackTrace() {
super.printStackTrace();
}
}

View File

@ -25,20 +25,18 @@ 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"
// 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) {
super("0", "1", "2", "3", "4", "5", "6", "7", "8");
oldPrompt = old;
}
@Override
@ -67,19 +65,14 @@ public class ItemStackPrompt extends FixedSetPrompt {
@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);
@ -93,7 +86,6 @@ public class ItemStackPrompt extends FixedSetPrompt {
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, '&');
@ -104,63 +96,48 @@ public class ItemStackPrompt extends FixedSetPrompt {
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);
@ -168,18 +145,14 @@ public class ItemStackPrompt extends FixedSetPrompt {
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");
}
@ -192,15 +165,12 @@ public class ItemStackPrompt extends FixedSetPrompt {
if (cc.getSessionData("tempLore") != null) {
lore = new ArrayList<String>();
LinkedList<String> loadedLore = (LinkedList<String>) cc.getSessionData("tempLore");
for (String line : loadedLore)
{
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);
}
@ -215,18 +185,14 @@ public class ItemStackPrompt extends FixedSetPrompt {
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) {
@ -245,7 +211,6 @@ public class ItemStackPrompt extends FixedSetPrompt {
@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(":");
@ -254,7 +219,6 @@ public class ItemStackPrompt extends FixedSetPrompt {
dataString = splitInput[1];
}
}
Material mat = Material.matchMaterial(input.toUpperCase().replace(" ", "_"));
if (mat == null) {
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("itemCreateInvalidName"));
@ -262,7 +226,6 @@ public class ItemStackPrompt extends FixedSetPrompt {
} else {
cc.setSessionData("tempName", mat.name());
cc.setSessionData("tempAmount", 1);
if (dataString != null) {
try {
short data = Short.parseShort(dataString);
@ -274,14 +237,10 @@ public class ItemStackPrompt extends FixedSetPrompt {
}
return new ItemStackPrompt(oldPrompt);
}
} else {
return new ItemStackPrompt(oldPrompt);
}
}
}
private class AmountPrompt extends StringPrompt {
@ -294,9 +253,7 @@ public class ItemStackPrompt extends FixedSetPrompt {
@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"));
@ -305,19 +262,14 @@ public class ItemStackPrompt extends FixedSetPrompt {
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 {
@ -330,9 +282,7 @@ public class ItemStackPrompt extends FixedSetPrompt {
@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"));
@ -341,63 +291,43 @@ public class ItemStackPrompt extends FixedSetPrompt {
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);
}
@ -418,41 +348,30 @@ public class ItemStackPrompt extends FixedSetPrompt {
@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);
} 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);
}
}
}
}
private class DisplayPrompt extends StringPrompt {
@ -465,21 +384,13 @@ public class ItemStackPrompt extends FixedSetPrompt {
@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 {
@ -492,42 +403,27 @@ public class ItemStackPrompt extends FixedSetPrompt {
@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);
@ -535,54 +431,36 @@ public class ItemStackPrompt extends FixedSetPrompt {
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")
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;
}
}
}

View File

@ -29,118 +29,84 @@ public class QuestAcceptPrompt extends StringPrompt {
@SuppressWarnings("unchecked")
@Override
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;
}
@Override
public Prompt acceptInput(ConversationContext cc, String input) {
int numInput = -1;
try {
numInput = Integer.parseInt(input);
} catch (NumberFormatException e) {
//Continue
// 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);
@ -153,38 +119,23 @@ public class QuestAcceptPrompt extends StringPrompt {
} 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);
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);
}
}

View File

@ -33,127 +33,95 @@ public class RequirementsPrompt extends FixedSetPrompt {
final QuestFactory factory;
public RequirementsPrompt(Quests plugin, QuestFactory qf) {
super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11");
quests = plugin;
factory = qf;
}
@SuppressWarnings("unchecked")
@Override
public String getPromptText(ConversationContext context) {
String text;
String lang = Lang.get("requirementsTitle");
lang = lang.replaceAll("<quest>", ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.DARK_AQUA);
text = ChatColor.DARK_AQUA + lang + "\n";
if (context.getSessionData(CK.REQ_MONEY) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetMoney") + " " + ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n";
} else {
int moneyReq = (Integer) context.getSessionData(CK.REQ_MONEY);
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetMoney") + " (" + moneyReq + " " + (moneyReq > 1 ? Quests.getCurrency(true) : Quests.getCurrency(false)) + ")\n";
}
if (context.getSessionData(CK.REQ_QUEST_POINTS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetQuestPoints") + " " + ChatColor.GRAY + "(" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetQuestPoints") + " " + ChatColor.GRAY + "(" + ChatColor.AQUA + context.getSessionData(CK.REQ_QUEST_POINTS) + " " + Lang.get("questPoints") + ChatColor.GRAY + ")\n";
}
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetItem") + "\n";
if (context.getSessionData(CK.REQ_PERMISSION) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetPerms") + " " + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetPerms") + "\n";
List<String> perms = (List<String>) context.getSessionData(CK.REQ_PERMISSION);
for (String s : perms) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
}
}
if (context.getSessionData(CK.REQ_QUEST) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetQuest") + " " + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetQuest") + "\n";
List<String> qs = (List<String>) context.getSessionData(CK.REQ_QUEST);
for (String s : qs) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
}
}
if (context.getSessionData(CK.REQ_QUEST_BLOCK) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetQuestBlocks") + " " + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetQuestBlocks") + "\n";
List<String> qs = (List<String>) context.getSessionData(CK.REQ_QUEST_BLOCK);
for (String s : qs) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
}
}
if (Quests.mcmmo != null) {
if (context.getSessionData(CK.REQ_MCMMO_SKILLS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetMcMMO") + " " + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetMcMMO") + "\n";
List<String> skills = (List<String>) context.getSessionData(CK.REQ_MCMMO_SKILLS);
List<Integer> amounts = (List<Integer>) context.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS);
for (String s : skills) {
text += ChatColor.GRAY + " - " + ChatColor.DARK_GREEN + s + ChatColor.RESET + ChatColor.YELLOW + " " + Lang.get("mcMMOLevel") + " " + ChatColor.GREEN + amounts.get(skills.indexOf(s)) + "\n";
}
}
} else {
text += ChatColor.GRAY + "6 - " + Lang.get("reqSetMcMMO") + " (" + Lang.get("reqNoMcMMO") + ")\n";
}
if (Quests.heroes != null) {
if (context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) == null && context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetHeroes") + " " + ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetHeroes") + "\n";
if (context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) != null) {
text += ChatColor.AQUA + " " + Lang.get("reqHeroesPrimaryDisplay") + " " + ChatColor.BLUE + (String) context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) + "\n";
}
if (context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) != null) {
text += ChatColor.AQUA + " " + Lang.get("reqHeroesSecondaryDisplay") + " " + ChatColor.BLUE + (String) context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) + "\n";
}
}
} else {
text += ChatColor.GRAY + "8 - " + Lang.get("reqSetHeroes") + " (" + Lang.get("reqNoHeroes") + ")\n";
}
if (context.getSessionData(CK.REQ_CUSTOM) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "9 - " + ChatColor.RESET + ChatColor.ITALIC + ChatColor.DARK_PURPLE + Lang.get("reqSetCustom") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "9 - " + ChatColor.RESET + ChatColor.ITALIC + ChatColor.DARK_PURPLE + Lang.get("reqSetCustom") + "\n";
LinkedList<String> customReqs = (LinkedList<String>) context.getSessionData(CK.REQ_CUSTOM);
for (String s : customReqs) {
text += ChatColor.RESET + "" + ChatColor.DARK_PURPLE + " - " + ChatColor.LIGHT_PURPLE + s + "\n";
}
}
if (context.getSessionData(CK.REQ_MONEY) == null && context.getSessionData(CK.REQ_QUEST_POINTS) == null && context.getSessionData(CK.REQ_QUEST_BLOCK) == null && context.getSessionData(CK.REQ_ITEMS) == null && context.getSessionData(CK.REQ_PERMISSION) == null && context.getSessionData(CK.REQ_QUEST) == null && context.getSessionData(CK.REQ_QUEST_BLOCK) == null && context.getSessionData(CK.REQ_MCMMO_SKILLS) == null && context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) == null && context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) == null && context.getSessionData(CK.REQ_CUSTOM) == null) {
text += ChatColor.GRAY + "" + ChatColor.BOLD + "10 - " + ChatColor.RESET + ChatColor.GRAY + Lang.get("reqSetFail") + " (" + Lang.get("reqNone") + ")\n";
} else if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) {
@ -161,16 +129,12 @@ public class RequirementsPrompt extends FixedSetPrompt {
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "10 - " + ChatColor.RESET + ChatColor.YELLOW + Lang.get("reqSetFail") + ChatColor.GRAY + "(" + ChatColor.AQUA + "\"" + context.getSessionData(CK.Q_FAIL_MESSAGE) + "\"" + ChatColor.GRAY + ")\n";
}
text += ChatColor.GREEN + "" + ChatColor.BOLD + "11" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
return text;
}
@Override
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1")) {
return new MoneyPrompt();
} else if (input.equalsIgnoreCase("2")) {
@ -201,34 +165,27 @@ public class RequirementsPrompt extends FixedSetPrompt {
return new FailMessagePrompt();
} else if (input.equalsIgnoreCase("11")) {
if (context.getSessionData(CK.REQ_MONEY) != null || context.getSessionData(CK.REQ_QUEST_POINTS) != null || context.getSessionData(CK.REQ_ITEMS) != null || context.getSessionData(CK.REQ_PERMISSION) != null || context.getSessionData(CK.REQ_QUEST) != null || context.getSessionData(CK.REQ_QUEST_BLOCK) != null || context.getSessionData(CK.REQ_MCMMO_SKILLS) != null || context.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) != null || context.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) != null || context.getSessionData(CK.REQ_CUSTOM) != null) {
if (context.getSessionData(CK.Q_FAIL_MESSAGE) == null) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqNoMessage"));
return new RequirementsPrompt(quests, factory);
}
}
return factory.returnToMenu();
}
return null;
}
private class MoneyPrompt extends NumericPrompt {
@Override
public String getPromptText(ConversationContext context) {
String text = Lang.get("reqMoneyPrompt");
text = text.replaceAll("<money>", ChatColor.DARK_PURPLE + ((Quests.economy.currencyNamePlural().isEmpty() ? Lang.get("money") : Quests.economy.currencyNamePlural())) + ChatColor.YELLOW);
return ChatColor.YELLOW + text;
}
@Override
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
if (input.intValue() < -1) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqGreaterThanZero"));
return new MoneyPrompt();
@ -238,10 +195,8 @@ public class RequirementsPrompt extends FixedSetPrompt {
context.setSessionData(CK.REQ_MONEY, null);
return new RequirementsPrompt(quests, factory);
}
context.setSessionData(CK.REQ_MONEY, input.intValue());
return new RequirementsPrompt(quests, factory);
}
}
@ -249,14 +204,11 @@ public class RequirementsPrompt extends FixedSetPrompt {
@Override
public String getPromptText(ConversationContext context) {
return ChatColor.YELLOW + Lang.get("reqQuestPointsPrompt");
}
@Override
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
if (input.intValue() < -1) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqGreaterThanZero"));
return new QuestPointsPrompt();
@ -266,10 +218,8 @@ public class RequirementsPrompt extends FixedSetPrompt {
context.setSessionData(CK.REQ_QUEST_POINTS, null);
return new RequirementsPrompt(quests, factory);
}
context.setSessionData(CK.REQ_QUEST_POINTS, input.intValue());
return new RequirementsPrompt(quests, factory);
}
}
@ -283,103 +233,73 @@ public class RequirementsPrompt extends FixedSetPrompt {
@Override
public String getPromptText(ConversationContext context) {
String text = ChatColor.LIGHT_PURPLE + Lang.get("questListTitle") + "\n" + ChatColor.DARK_PURPLE;
boolean none = true;
for (Quest q : quests.getQuests()) {
text += q.getName() + ", ";
none = false;
}
if (none) {
text += "(" + Lang.get("none") + ")\n";
} else {
text = text.substring(0, (text.length() - 2));
text += "\n";
}
String lang = Lang.get("reqQuestPrompt");
lang = lang.replaceAll("<comma>", ChatColor.RED + "" + ChatColor.BOLD + Lang.get("comma") + ChatColor.RESET + ChatColor.YELLOW);
text += ChatColor.YELLOW + lang;
return text;
}
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
String[] args = input.split(",");
LinkedList<String> questNames = new LinkedList<String>();
for (String s : args) {
if (quests.getQuest(s) == null) {
String text = Lang.get("reqNotAQuestName");
text = text.replaceAll("<quest>", ChatColor.LIGHT_PURPLE + s + ChatColor.RED);
context.getForWhom().sendRawMessage(text);
return new QuestListPrompt(isRequiredQuest);
}
if (questNames.contains(s)) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listDuplicate"));
return new QuestListPrompt(isRequiredQuest);
}
questNames.add(s);
}
Collections.sort(questNames, new Comparator<String>() {
@Override
public int compare(String one, String two) {
return one.compareTo(two);
}
});
if (isRequiredQuest) {
context.setSessionData(CK.REQ_QUEST, questNames);
} else {
context.setSessionData(CK.REQ_QUEST_BLOCK, questNames);
}
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
if (isRequiredQuest) {
context.setSessionData(CK.REQ_QUEST, null);
} else {
context.setSessionData(CK.REQ_QUEST_BLOCK, null);
}
}
return new RequirementsPrompt(quests, factory);
}
}
private class ItemListPrompt extends FixedSetPrompt {
public ItemListPrompt() {
super("1", "2", "3", "4");
}
@Override
public String getPromptText(ConversationContext context) {
// Check/add newly made item
if (context.getSessionData("newItem") != null) {
if (context.getSessionData(CK.REQ_ITEMS) != null) {
@ -391,12 +311,9 @@ public class RequirementsPrompt extends FixedSetPrompt {
itemRews.add((ItemStack) context.getSessionData("tempStack"));
context.setSessionData(CK.REQ_ITEMS, itemRews);
}
context.setSessionData("newItem", null);
context.setSessionData("tempStack", null);
}
String text = ChatColor.GOLD + Lang.get("itemRequirementsTitle") + "\n";
if (context.getSessionData(CK.REQ_ITEMS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqAddItem") + "\n";
@ -404,41 +321,27 @@ public class RequirementsPrompt extends FixedSetPrompt {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n";
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
} else {
for (ItemStack is : getItems(context)) {
text += ChatColor.GRAY + " - " + ItemUtil.getDisplayString(is) + "\n";
}
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqAddItem") + "\n";
if (context.getSessionData(CK.REQ_ITEMS_REMOVE) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetRemoveItems") + " (" + Lang.get("reqNoValuesSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetRemoveItems") + "\n";
for (Boolean b : getRemoveItems(context)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + (b.equals(Boolean.TRUE) ? Lang.get("yesWord") : Lang.get("noWord")) + "\n";
}
}
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n";
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
}
return text;
}
@SuppressWarnings("unchecked")
@Override
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1")) {
return new ItemStackPrompt(ItemListPrompt.this);
} else if (input.equalsIgnoreCase("2")) {
@ -454,22 +357,18 @@ public class RequirementsPrompt extends FixedSetPrompt {
context.setSessionData(CK.REQ_ITEMS_REMOVE, null);
return new ItemListPrompt();
} else if (input.equalsIgnoreCase("4")) {
int one;
int two;
if (context.getSessionData(CK.REQ_ITEMS) != null) {
one = ((List<ItemStack>) context.getSessionData(CK.REQ_ITEMS)).size();
} else {
one = 0;
}
if (context.getSessionData(CK.REQ_ITEMS_REMOVE) != null) {
two = ((List<Boolean>) context.getSessionData(CK.REQ_ITEMS_REMOVE)).size();
} else {
two = 0;
}
if (one == two) {
return new RequirementsPrompt(quests, factory);
} else {
@ -478,7 +377,6 @@ public class RequirementsPrompt extends FixedSetPrompt {
}
}
return null;
}
@SuppressWarnings("unchecked")
@ -501,14 +399,10 @@ public class RequirementsPrompt extends FixedSetPrompt {
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
String[] args = input.split(" ");
LinkedList<Boolean> booleans = new LinkedList<Boolean>();
for (String s : args) {
if (s.equalsIgnoreCase(Lang.get("true")) || s.equalsIgnoreCase(Lang.get("yesWord"))) {
booleans.add(true);
} else if (s.equalsIgnoreCase(Lang.get("false")) || s.equalsIgnoreCase(Lang.get("noWord"))) {
@ -519,15 +413,10 @@ public class RequirementsPrompt extends FixedSetPrompt {
context.getForWhom().sendRawMessage(ChatColor.RED + text);
return new RemoveItemsPrompt();
}
}
context.setSessionData(CK.REQ_ITEMS_REMOVE, booleans);
}
return new ItemListPrompt();
}
}
@ -540,21 +429,15 @@ public class RequirementsPrompt extends FixedSetPrompt {
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
String[] args = input.split(" ");
LinkedList<String> permissions = new LinkedList<String>();
permissions.addAll(Arrays.asList(args));
context.setSessionData(CK.REQ_PERMISSION, permissions);
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.REQ_PERMISSION, null);
}
return new RequirementsPrompt(quests, factory);
}
}
@ -570,16 +453,13 @@ public class RequirementsPrompt extends FixedSetPrompt {
text += ChatColor.DARK_PURPLE + " - " + cr.getName() + "\n";
}
}
return text + ChatColor.YELLOW + Lang.get("reqCustomPrompt");
}
@SuppressWarnings("unchecked")
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
CustomRequirement found = null;
for (CustomRequirement cr : quests.customRequirements) {
if (cr.getName().equalsIgnoreCase(input)) {
@ -587,7 +467,6 @@ public class RequirementsPrompt extends FixedSetPrompt {
break;
}
}
if (found == null) {
for (CustomRequirement cr : quests.customRequirements) {
if (cr.getName().toLowerCase().contains(input.toLowerCase())) {
@ -596,9 +475,7 @@ public class RequirementsPrompt extends FixedSetPrompt {
}
}
}
if (found != null) {
if (context.getSessionData(CK.REQ_CUSTOM) != null) {
LinkedList<String> list = (LinkedList<String>) context.getSessionData(CK.REQ_CUSTOM);
LinkedList<Map<String, Object>> datamapList = (LinkedList<Map<String, Object>>) context.getSessionData(CK.REQ_CUSTOM_DATA);
@ -619,30 +496,23 @@ public class RequirementsPrompt extends FixedSetPrompt {
context.setSessionData(CK.REQ_CUSTOM, list);
context.setSessionData(CK.REQ_CUSTOM_DATA, datamapList);
}
//Send user to the custom data prompt if there is any needed
// Send user to the custom data prompt if there is any needed
if (found.datamap.isEmpty() == false) {
context.setSessionData(CK.REQ_CUSTOM_DATA_DESCRIPTIONS, found.descriptions);
return new RequirementCustomDataListPrompt();
}
//
} else {
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("reqCustomNotFound"));
return new CustomRequirementsPrompt();
}
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.REQ_CUSTOM, null);
context.setSessionData(CK.REQ_CUSTOM_DATA, null);
context.setSessionData(CK.REQ_CUSTOM_DATA_TEMP, null);
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("reqCustomCleared"));
}
return new RequirementsPrompt(quests, factory);
}
}
@ -651,86 +521,63 @@ public class RequirementsPrompt extends FixedSetPrompt {
@SuppressWarnings("unchecked")
@Override
public String getPromptText(ConversationContext context) {
String text = ChatColor.BOLD + "" + ChatColor.AQUA + "- ";
LinkedList<String> list = (LinkedList<String>) context.getSessionData(CK.REQ_CUSTOM);
LinkedList<Map<String, Object>> datamapList = (LinkedList<Map<String, Object>>) context.getSessionData(CK.REQ_CUSTOM_DATA);
String reqName = list.getLast();
Map<String, Object> datamap = datamapList.getLast();
text += reqName + " -\n";
int index = 1;
LinkedList<String> datamapKeys = new LinkedList<String>();
for (String key : datamap.keySet()) {
datamapKeys.add(key);
}
Collections.sort(datamapKeys);
for (String dataKey : datamapKeys) {
text += ChatColor.BOLD + "" + ChatColor.DARK_BLUE + index + " - " + ChatColor.RESET + ChatColor.BLUE + dataKey;
if (datamap.get(dataKey) != null) {
text += ChatColor.GREEN + " (" + (String) datamap.get(dataKey) + ")\n";
} else {
text += ChatColor.RED + " (" + Lang.get("valRequired") + ")\n";
}
index++;
}
text += ChatColor.BOLD + "" + ChatColor.DARK_BLUE + index + " - " + ChatColor.AQUA + Lang.get("finish");
return text;
}
@Override
public Prompt acceptInput(ConversationContext context, String input) {
@SuppressWarnings("unchecked")
LinkedList<Map<String, Object>> datamapList = (LinkedList<Map<String, Object>>) context.getSessionData(CK.REQ_CUSTOM_DATA);
Map<String, Object> datamap = datamapList.getLast();
int numInput;
try {
numInput = Integer.parseInt(input);
} catch (NumberFormatException nfe) {
return new RequirementCustomDataListPrompt();
}
if (numInput < 1 || numInput > datamap.size() + 1) {
return new RequirementCustomDataListPrompt();
}
if (numInput < datamap.size() + 1) {
LinkedList<String> datamapKeys = new LinkedList<String>();
for (String key : datamap.keySet()) {
datamapKeys.add(key);
}
Collections.sort(datamapKeys);
String selectedKey = datamapKeys.get(numInput - 1);
context.setSessionData(CK.REQ_CUSTOM_DATA_TEMP, selectedKey);
return new RequirementCustomDataPrompt();
} else {
if (datamap.containsValue(null)) {
return new RequirementCustomDataListPrompt();
} else {
context.setSessionData(CK.REQ_CUSTOM_DATA_DESCRIPTIONS, null);
return new RequirementsPrompt(quests, factory);
}
}
}
}
private class RequirementCustomDataPrompt extends StringPrompt {
@ -744,7 +591,6 @@ public class RequirementsPrompt extends FixedSetPrompt {
if (descriptions.get(temp) != null) {
text += ChatColor.GOLD + descriptions.get(temp) + "\n";
}
String lang = Lang.get("stageEditorCustomDataPrompt");
lang = lang.replaceAll("<data>", temp);
text += ChatColor.YELLOW + lang;
@ -760,7 +606,6 @@ public class RequirementsPrompt extends FixedSetPrompt {
context.setSessionData(CK.REQ_CUSTOM_DATA_TEMP, null);
return new RequirementCustomDataListPrompt();
}
}
private class mcMMOPrompt extends FixedSetPrompt {
@ -771,7 +616,6 @@ public class RequirementsPrompt extends FixedSetPrompt {
@Override
public String getPromptText(ConversationContext cc) {
String text = ChatColor.DARK_GREEN + Lang.get("mcMMORequirementsTitle") + "\n";
if (cc.getSessionData(CK.REQ_MCMMO_SKILLS) == null) {
text += ChatColor.BOLD + "" + ChatColor.GREEN + "1" + ChatColor.RESET + ChatColor.GREEN + " - " + Lang.get("reqSetSkills") + "(" + Lang.get("noneSet") + ")\n";
@ -783,7 +627,6 @@ public class RequirementsPrompt extends FixedSetPrompt {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + skill + "\n";
}
}
if (cc.getSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS) == null) {
text += ChatColor.BOLD + "" + ChatColor.GREEN + "2" + ChatColor.RESET + ChatColor.GREEN + " - " + Lang.get("reqSetSkillAmounts") + " (" + Lang.get("noneSet") + ")\n";
} else {
@ -794,15 +637,12 @@ public class RequirementsPrompt extends FixedSetPrompt {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\n";
}
}
text += ChatColor.BOLD + "" + ChatColor.GREEN + "3" + ChatColor.RESET + ChatColor.GREEN + " - " + Lang.get("done");
return text;
}
@Override
protected Prompt acceptValidatedInput(ConversationContext cc, String input) {
if (input.equalsIgnoreCase("1")) {
return new mcMMOSkillsPrompt();
} else if (input.equalsIgnoreCase("2")) {
@ -810,9 +650,7 @@ public class RequirementsPrompt extends FixedSetPrompt {
} else if (input.equalsIgnoreCase("3")) {
return new RequirementsPrompt(quests, factory);
}
return null;
}
}
@ -820,33 +658,24 @@ public class RequirementsPrompt extends FixedSetPrompt {
@Override
public String getPromptText(ConversationContext context) {
String skillList = ChatColor.DARK_GREEN + Lang.get("skillListTitle") + "\n";
SkillType[] skills = SkillType.values();
for (int i = 0; i < skills.length; i++) {
if (i == (skills.length - 1)) {
skillList += ChatColor.GREEN + skills[i].getName() + "\n";
} else {
skillList += ChatColor.GREEN + skills[i].getName() + "\n\n";
}
}
return skillList + ChatColor.YELLOW + Lang.get("reqMcMMOPrompt");
}
@Override
public Prompt acceptInput(ConversationContext cc, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
LinkedList<String> skills = new LinkedList<String>();
for (String s : input.split(" ")) {
String formatted = MiscUtil.getCapitalized(s);
if (Quests.getMcMMOSkill(formatted) != null) {
skills.add(formatted);
} else if (skills.contains(formatted)) {
@ -858,12 +687,9 @@ public class RequirementsPrompt extends FixedSetPrompt {
cc.getForWhom().sendRawMessage(ChatColor.YELLOW + text);
return new mcMMOSkillsPrompt();
}
}
cc.setSessionData(CK.REQ_MCMMO_SKILLS, skills);
return new mcMMOPrompt();
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
cc.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("reqMcMMOCleared"));
cc.setSessionData(CK.REQ_MCMMO_SKILLS, null);
@ -871,47 +697,34 @@ public class RequirementsPrompt extends FixedSetPrompt {
} else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
return new mcMMOPrompt();
}
return new mcMMOSkillsPrompt();
}
}
private class mcMMOAmountsPrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext context) {
return ChatColor.YELLOW + Lang.get("reqMcMMOAmountsPrompt");
}
@Override
public Prompt acceptInput(ConversationContext cc, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
LinkedList<Integer> amounts = new LinkedList<Integer>();
for (String s : input.split(" ")) {
try {
int i = Integer.parseInt(s);
amounts.add(i);
} catch (NumberFormatException nfe) {
String text = Lang.get("reqNotANumber");
text = text.replaceAll("<input>", ChatColor.RED + s + ChatColor.YELLOW);
cc.getForWhom().sendRawMessage(ChatColor.YELLOW + text);
return new mcMMOAmountsPrompt();
}
}
cc.setSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS, amounts);
return new mcMMOPrompt();
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
cc.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("reqMcMMOAmountsCleared"));
cc.setSessionData(CK.REQ_MCMMO_SKILL_AMOUNTS, null);
@ -919,11 +732,8 @@ public class RequirementsPrompt extends FixedSetPrompt {
} else if (input.equalsIgnoreCase(Lang.get("cmdCancel"))) {
return new mcMMOPrompt();
}
return new mcMMOAmountsPrompt();
}
}
private class HeroesPrompt extends FixedSetPrompt {
@ -934,28 +744,23 @@ public class RequirementsPrompt extends FixedSetPrompt {
@Override
public String getPromptText(ConversationContext cc) {
String text = ChatColor.DARK_GREEN + Lang.get("heroesRequirementsTitle") + "\n";
if (cc.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) == null) {
text += ChatColor.BOLD + "" + ChatColor.GREEN + "1" + ChatColor.RESET + ChatColor.GREEN + " - " + Lang.get("reqHeroesSetPrimary") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BOLD + "" + ChatColor.GREEN + "1" + ChatColor.RESET + ChatColor.GREEN + " - " + Lang.get("reqHeroesSetPrimary") + " (" + ChatColor.AQUA + (String) cc.getSessionData(CK.REQ_HEROES_PRIMARY_CLASS) + ChatColor.GREEN + ")\n";
}
if (cc.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) == null) {
text += ChatColor.BOLD + "" + ChatColor.GREEN + "2" + ChatColor.RESET + ChatColor.GREEN + " - " + Lang.get("reqHeroesSetSecondary") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BOLD + "" + ChatColor.GREEN + "2" + ChatColor.RESET + ChatColor.GREEN + " - " + Lang.get("reqHeroesSetSecondary") + " (" + ChatColor.AQUA + (String) cc.getSessionData(CK.REQ_HEROES_SECONDARY_CLASS) + ChatColor.GREEN + ")\n";
}
text += ChatColor.BOLD + "" + ChatColor.GREEN + "3" + ChatColor.RESET + ChatColor.GREEN + " - " + Lang.get("done");
return text;
}
@Override
protected Prompt acceptValidatedInput(ConversationContext cc, String input) {
if (input.equalsIgnoreCase("1")) {
return new HeroesPrimaryPrompt();
} else if (input.equalsIgnoreCase("2")) {
@ -963,9 +768,7 @@ public class RequirementsPrompt extends FixedSetPrompt {
} else if (input.equalsIgnoreCase("3")) {
return new RequirementsPrompt(quests, factory);
}
return null;
}
}
@ -973,7 +776,6 @@ public class RequirementsPrompt extends FixedSetPrompt {
@Override
public String getPromptText(ConversationContext cc) {
String text = ChatColor.DARK_PURPLE + Lang.get("heroesPrimaryTitle") + "\n";
LinkedList<String> list = new LinkedList<String>();
for (HeroClass hc : Quests.heroes.getClassManager().getClasses()) {
@ -981,61 +783,43 @@ public class RequirementsPrompt extends FixedSetPrompt {
list.add(hc.getName());
}
}
if (list.isEmpty()) {
text += ChatColor.GRAY + "(" + Lang.get("none") + ")\n";
} else {
Collections.sort(list);
for (String s : list) {
text += ChatColor.DARK_PURPLE + "- " + ChatColor.LIGHT_PURPLE + s + "\n";
}
}
text += ChatColor.YELLOW + Lang.get("reqHeroesPrimaryPrompt");
return text;
}
@Override
public Prompt acceptInput(ConversationContext cc, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdClear")) == false && input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
HeroClass hc = Quests.heroes.getClassManager().getClass(input);
if (hc != null) {
if (hc.isPrimary()) {
cc.setSessionData(CK.REQ_HEROES_PRIMARY_CLASS, hc.getName());
return new HeroesPrompt();
} else {
String text = Lang.get("reqHeroesNotPrimary");
text = text.replaceAll("<class>", ChatColor.LIGHT_PURPLE + hc.getName() + ChatColor.RED);
cc.getForWhom().sendRawMessage(ChatColor.RED + text);
return new HeroesPrimaryPrompt();
}
} else {
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqHeroesClassNotFound"));
return new HeroesPrimaryPrompt();
}
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
cc.setSessionData(CK.REQ_HEROES_PRIMARY_CLASS, null);
cc.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("reqHeroesPrimaryCleared"));
return new HeroesPrompt();
} else {
return new HeroesPrompt();
}
}
}
@ -1043,7 +827,6 @@ public class RequirementsPrompt extends FixedSetPrompt {
@Override
public String getPromptText(ConversationContext cc) {
String text = ChatColor.DARK_PURPLE + Lang.get("heroesSecondaryTitle") + "\n";
LinkedList<String> list = new LinkedList<String>();
for (HeroClass hc : Quests.heroes.getClassManager().getClasses()) {
@ -1051,62 +834,43 @@ public class RequirementsPrompt extends FixedSetPrompt {
list.add(hc.getName());
}
}
if (list.isEmpty()) {
text += ChatColor.GRAY + "(" + Lang.get("none") + ")\n";
} else {
Collections.sort(list);
for (String s : list) {
text += ChatColor.DARK_PURPLE + "- " + ChatColor.LIGHT_PURPLE + s + "\n";
}
}
text += ChatColor.YELLOW + Lang.get("reqHeroesSecondaryPrompt");
return text;
}
@Override
public Prompt acceptInput(ConversationContext cc, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdClear")) == false && input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
HeroClass hc = Quests.heroes.getClassManager().getClass(input);
if (hc != null) {
if (hc.isSecondary()) {
cc.setSessionData(CK.REQ_HEROES_SECONDARY_CLASS, hc.getName());
return new HeroesPrompt();
} else {
String text = Lang.get("reqHeroesNotSecondary");
text = text.replaceAll("<class>", ChatColor.LIGHT_PURPLE + hc.getName() + ChatColor.RED);
cc.getForWhom().sendRawMessage(ChatColor.RED + text);
return new HeroesSecondaryPrompt();
}
} else {
cc.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("reqHeroesClassNotFound"));
return new HeroesSecondaryPrompt();
}
} else if (input.equalsIgnoreCase(Lang.get("clear"))) {
cc.setSessionData(CK.REQ_HEROES_SECONDARY_CLASS, null);
cc.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("reqHeroesSecondaryCleared"));
return new HeroesPrompt();
} else {
return new HeroesPrompt();
}
}
}
@ -1119,13 +883,10 @@ public class RequirementsPrompt extends FixedSetPrompt {
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get(Lang.get("cancel"))) == false) {
context.setSessionData(CK.Q_FAIL_MESSAGE, input);
}
return new RequirementsPrompt(quests, factory);
}
}
}

View File

@ -30,160 +30,112 @@ import me.blackvein.quests.util.Lang;
public class RewardsPrompt extends FixedSetPrompt {
final Quests quests;
final QuestFactory factory;
public RewardsPrompt(Quests plugin, QuestFactory qf) {
super("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11");
quests = plugin;
factory = qf;
}
@SuppressWarnings("unchecked")
@Override
public String getPromptText(ConversationContext context) {
String text;
String lang = Lang.get("rewardsTitle");
lang = lang.replaceAll("<quest>", ChatColor.AQUA + (String) context.getSessionData(CK.Q_NAME) + ChatColor.DARK_AQUA);
text = ChatColor.DARK_AQUA + lang + "\n";
if (context.getSessionData(CK.REW_MONEY) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetMoney") + " (" + Lang.get("noneSet") + ")\n";
} else {
int moneyRew = (Integer) context.getSessionData(CK.REW_MONEY);
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetMoney") + " (" + moneyRew + " " + (moneyRew > 1 ? Quests.getCurrency(true) : Quests.getCurrency(false)) + ")\n";
}
if (context.getSessionData(CK.REW_QUEST_POINTS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetQuestPoints") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetQuestPoints") + " (" + context.getSessionData(CK.REW_QUEST_POINTS) + " " + Lang.get("questPoints") + ")\n";
}
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetItems") + "\n";
if (context.getSessionData(CK.REW_EXP) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetExperience") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetExperience") + " (" + context.getSessionData(CK.REW_EXP) + " " + Lang.get("points") + ")\n";
}
if (context.getSessionData(CK.REW_COMMAND) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetCommands") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "5" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetCommands") + "\n";
List<String> commands = (List<String>) context.getSessionData(CK.REW_COMMAND);
for (String cmd : commands) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + cmd + "\n";
}
}
if (context.getSessionData(CK.REW_PERMISSION) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetPermission") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "6" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetPermission") + "\n";
List<String> permissions = (List<String>) context.getSessionData(CK.REW_PERMISSION);
for (String perm : permissions) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + perm + "\n";
}
}
if (Quests.mcmmo != null) {
if (context.getSessionData(CK.REW_MCMMO_SKILLS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetMcMMO") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "7" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetMcMMO") + "\n";
List<String> skills = (List<String>) context.getSessionData(CK.REW_MCMMO_SKILLS);
List<Integer> amounts = (List<Integer>) context.getSessionData(CK.REW_MCMMO_AMOUNTS);
for (String skill : skills) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + skill + ChatColor.GRAY + " x " + ChatColor.DARK_AQUA + amounts.get(skills.indexOf(skill)) + "\n";
}
}
} else {
text += ChatColor.GRAY + "7 - " + Lang.get("rewSetMcMMO") + " (" + Lang.get("reqNoMcMMO") + ")\n";
}
if (Quests.heroes != null) {
if (context.getSessionData(CK.REW_HEROES_CLASSES) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetHeroes") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "8" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetHeroes") + "\n";
List<String> heroClasses = (List<String>) context.getSessionData(CK.REW_HEROES_CLASSES);
List<Double> amounts = (List<Double>) context.getSessionData(CK.REW_HEROES_AMOUNTS);
for (String heroClass : heroClasses) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + amounts.get(heroClasses.indexOf(heroClass)) + " " + ChatColor.DARK_AQUA + heroClass + " " + Lang.get("experience") + "\n";
}
}
} else {
text += ChatColor.GRAY + "8 - " + Lang.get("rewSetHeroes") + " (" + Lang.get("rewNoHeroes") + ")\n";
}
if (Quests.phatLoots != null) {
if (context.getSessionData(CK.REW_PHAT_LOOTS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "9" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetPhat") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "9" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetPhat") + "\n";
List<String> phatLoots = (List<String>) context.getSessionData(CK.REW_PHAT_LOOTS);
for (String phatLoot : phatLoots) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + phatLoot + "\n";
}
}
} else {
text += ChatColor.GRAY + "9 - " + Lang.get("rewSetPhat") + " (" + Lang.get("rewNoPhat") + ")\n";
}
if (context.getSessionData(CK.REW_CUSTOM) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "10 - " + ChatColor.RESET + ChatColor.ITALIC + ChatColor.DARK_PURPLE + Lang.get("rewSetCustom") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "10 - " + ChatColor.RESET + ChatColor.ITALIC + ChatColor.DARK_PURPLE + Lang.get("rewSetCustom") + "\n";
LinkedList<String> customRews = (LinkedList<String>) context.getSessionData(CK.REW_CUSTOM);
for (String s : customRews) {
text += ChatColor.RESET + "" + ChatColor.DARK_PURPLE + " - " + ChatColor.LIGHT_PURPLE + s + "\n";
}
}
text += ChatColor.GREEN + "" + ChatColor.BOLD + "11" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
return text;
}
@Override
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1")) {
return new MoneyPrompt();
} else if (input.equalsIgnoreCase("2")) {
@ -220,23 +172,19 @@ public class RewardsPrompt extends FixedSetPrompt {
return factory.returnToMenu();
}
return null;
}
private class MoneyPrompt extends NumericPrompt {
@Override
public String getPromptText(ConversationContext context) {
String text = Lang.get("rewMoneyPrompt");
text = text.replaceAll("<money>", ChatColor.AQUA + (Quests.economy.currencyNamePlural().isEmpty() ? Lang.get("money") : Quests.economy.currencyNamePlural()) + ChatColor.YELLOW);
return ChatColor.YELLOW + text;
}
@Override
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
if (input.intValue() < -1) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("inputPosNum"));
return new MoneyPrompt();
@ -245,25 +193,19 @@ public class RewardsPrompt extends FixedSetPrompt {
} else if (input.intValue() != -1) {
context.setSessionData(CK.REW_MONEY, input.intValue());
}
return new RewardsPrompt(quests, factory);
}
}
private class ExperiencePrompt extends NumericPrompt {
@Override
public String getPromptText(ConversationContext context) {
return ChatColor.YELLOW + Lang.get("rewExperiencePrompt");
}
@Override
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
if (input.intValue() < -1) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("inputPosNum"));
return new ExperiencePrompt();
@ -272,25 +214,19 @@ public class RewardsPrompt extends FixedSetPrompt {
} else if (input.intValue() != 0) {
context.setSessionData(CK.REW_EXP, input.intValue());
}
return new RewardsPrompt(quests, factory);
}
}
private class QuestPointsPrompt extends NumericPrompt {
@Override
public String getPromptText(ConversationContext context) {
return ChatColor.YELLOW + Lang.get("rewQuestPointsPrompt");
}
@Override
protected Prompt acceptValidatedInput(ConversationContext context, Number input) {
if (input.intValue() < -1) {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("inputPosNum"));
return new QuestPointsPrompt();
@ -299,24 +235,18 @@ public class RewardsPrompt extends FixedSetPrompt {
} else if (input.intValue() != 0) {
context.setSessionData(CK.REW_QUEST_POINTS, input.intValue());
}
return new RewardsPrompt(quests, factory);
}
}
private class ItemListPrompt extends FixedSetPrompt {
public ItemListPrompt() {
super("1", "2", "3");
}
@Override
public String getPromptText(ConversationContext context) {
// Check/add newly made item
if (context.getSessionData("newItem") != null) {
if (context.getSessionData(CK.REW_ITEMS) != null) {
@ -328,12 +258,9 @@ public class RewardsPrompt extends FixedSetPrompt {
itemRews.add((ItemStack) context.getSessionData("tempStack"));
context.setSessionData(CK.REW_ITEMS, itemRews);
}
context.setSessionData("newItem", null);
context.setSessionData("tempStack", null);
}
String text = ChatColor.GOLD + Lang.get("itemRewardsTitle") + "\n";
if (context.getSessionData(CK.REW_ITEMS) == null) {
text += ChatColor.GRAY + " (" + Lang.get("noneSet") + ")\n";
@ -341,25 +268,18 @@ public class RewardsPrompt extends FixedSetPrompt {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n";
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
} else {
for (ItemStack is : getItems(context)) {
text += ChatColor.GRAY + "- " + ItemUtil.getDisplayString(is) + "\n";
}
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqAddItem") + "\n";
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n";
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
}
return text;
}
@Override
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1")) {
return new ItemStackPrompt(ItemListPrompt.this);
} else if (input.equalsIgnoreCase("2")) {
@ -370,14 +290,12 @@ public class RewardsPrompt extends FixedSetPrompt {
return new RewardsPrompt(quests, factory);
}
return null;
}
@SuppressWarnings("unchecked")
private List<ItemStack> getItems(ConversationContext context) {
return (List<ItemStack>) context.getSessionData(CK.REW_ITEMS);
}
}
private class CommandsPrompt extends StringPrompt {
@ -392,31 +310,21 @@ public class RewardsPrompt extends FixedSetPrompt {
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
String[] args = input.split(",");
LinkedList<String> commands = new LinkedList<String>();
for (String s : args) {
if (s.startsWith("/")) {
s = s.substring(1);
}
commands.add(s);
}
context.setSessionData(CK.REW_COMMAND, commands);
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.REW_COMMAND, null);
}
return new RewardsPrompt(quests, factory);
}
}
private class PermissionsPrompt extends StringPrompt {
@ -428,37 +336,27 @@ public class RewardsPrompt extends FixedSetPrompt {
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
String[] args = input.split(" ");
LinkedList<String> permissions = new LinkedList<String>();
permissions.addAll(Arrays.asList(args));
context.setSessionData(CK.REW_PERMISSION, permissions);
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.REW_PERMISSION, null);
}
return new RewardsPrompt(quests, factory);
}
}
}
//mcMMO
// mcMMO
private class mcMMOListPrompt extends FixedSetPrompt {
public mcMMOListPrompt() {
super("1", "2", "3", "4");
}
@Override
public String getPromptText(ConversationContext context) {
String text = ChatColor.GOLD + Lang.get("mcMMORewardsTitle") + "\n";
if (context.getSessionData(CK.REW_MCMMO_SKILLS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetSkills") + " (" + Lang.get("noneSet") + ")\n";
@ -466,40 +364,27 @@ public class RewardsPrompt extends FixedSetPrompt {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n";
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetSkills") + "\n";
for (String s : getSkills(context)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
}
if (context.getSessionData(CK.REW_MCMMO_AMOUNTS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetSkillAmounts") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("reqSetSkillAmounts") + "\n";
for (Integer i : getSkillAmounts(context)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + i + "\n";
}
}
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n";
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
}
return text;
}
@SuppressWarnings("unchecked")
@Override
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1")) {
return new mcMMOSkillsPrompt();
} else if (input.equalsIgnoreCase("2")) {
@ -515,22 +400,18 @@ public class RewardsPrompt extends FixedSetPrompt {
context.setSessionData(CK.REW_MCMMO_AMOUNTS, null);
return new mcMMOListPrompt();
} else if (input.equalsIgnoreCase("4")) {
int one;
int two;
if (context.getSessionData(CK.REW_MCMMO_SKILLS) != null) {
one = ((List<Integer>) context.getSessionData(CK.REW_MCMMO_SKILLS)).size();
} else {
one = 0;
}
if (context.getSessionData(CK.REW_MCMMO_AMOUNTS) != null) {
two = ((List<Integer>) context.getSessionData(CK.REW_MCMMO_AMOUNTS)).size();
} else {
two = 0;
}
if (one == two) {
return new RewardsPrompt(quests, factory);
} else {
@ -539,7 +420,6 @@ public class RewardsPrompt extends FixedSetPrompt {
}
}
return null;
}
@SuppressWarnings("unchecked")
@ -551,64 +431,48 @@ public class RewardsPrompt extends FixedSetPrompt {
private List<Integer> getSkillAmounts(ConversationContext context) {
return (List<Integer>) context.getSessionData(CK.REW_MCMMO_AMOUNTS);
}
}
private class mcMMOSkillsPrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext context) {
String skillList = ChatColor.DARK_GREEN + Lang.get("skillListTitle") + "\n";
SkillType[] skills = SkillType.values();
for (int i = 0; i < skills.length; i++) {
if (i == (skills.length - 1)) {
skillList += ChatColor.GREEN + skills[i].getName() + "\n";
} else {
skillList += ChatColor.GREEN + skills[i].getName() + "\n\n";
}
}
return skillList + Lang.get("rewMcMMOPrompt") + "\n" + ChatColor.GOLD + Lang.get("rewMcMMOPromptHint");
}
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
String[] args = input.split(" ");
LinkedList<String> skills = new LinkedList<String>();
for (String s : args) {
if (Quests.getMcMMOSkill(s) != null) {
if (skills.contains(s) == false) {
skills.add(Quester.getCapitalized(s));
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + Lang.get("listDuplicate"));
return new mcMMOSkillsPrompt();
}
} else {
String text = Lang.get("reqMcMMOError");
text = text.replaceAll("<input>", ChatColor.LIGHT_PURPLE + s + ChatColor.RED);
context.getForWhom().sendRawMessage(ChatColor.RED + text);
return new mcMMOSkillsPrompt();
}
}
context.setSessionData(CK.REW_MCMMO_SKILLS, skills);
}
return new mcMMOListPrompt();
}
}
private class mcMMOAmountsPrompt extends StringPrompt {
@ -620,47 +484,33 @@ public class RewardsPrompt extends FixedSetPrompt {
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
String[] args = input.split(" ");
LinkedList<Integer> amounts = new LinkedList<Integer>();
for (String s : args) {
try {
amounts.add(Integer.parseInt(s));
} catch (NumberFormatException e) {
String text = Lang.get("reqNotANumber");
text = text.replaceAll("<input>", ChatColor.LIGHT_PURPLE + s + ChatColor.RED);
context.getForWhom().sendRawMessage(ChatColor.RED + text);
return new mcMMOAmountsPrompt();
}
}
context.setSessionData(CK.REW_MCMMO_AMOUNTS, amounts);
}
return new mcMMOListPrompt();
}
}
private class HeroesListPrompt extends FixedSetPrompt {
public HeroesListPrompt() {
super("1", "2", "3", "4");
}
@Override
public String getPromptText(ConversationContext context) {
String text = ChatColor.GOLD + Lang.get("heroesRewardsTitle") + "\n";
if (context.getSessionData(CK.REW_HEROES_CLASSES) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetHeroesClasses") + " (" + Lang.get("noneSet") + ")\n";
@ -668,40 +518,27 @@ public class RewardsPrompt extends FixedSetPrompt {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n";
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "1" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetHeroesClasses") + "\n";
for (String s : getClasses(context)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + s + "\n";
}
if (context.getSessionData(CK.REW_HEROES_AMOUNTS) == null) {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetHeroesAmounts") + " (" + Lang.get("noneSet") + ")\n";
} else {
text += ChatColor.BLUE + "" + ChatColor.BOLD + "2" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("rewSetHeroesAmounts") + "\n";
for (Double d : getClassAmounts(context)) {
text += ChatColor.GRAY + " - " + ChatColor.AQUA + d + "\n";
}
}
text += ChatColor.BLUE + "" + ChatColor.BOLD + "3" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("clear") + "\n";
text += ChatColor.BLUE + "" + ChatColor.BOLD + "4" + ChatColor.RESET + ChatColor.YELLOW + " - " + Lang.get("done");
}
return text;
}
@SuppressWarnings("unchecked")
@Override
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("1")) {
return new HeroesClassesPrompt();
} else if (input.equalsIgnoreCase("2")) {
@ -717,22 +554,18 @@ public class RewardsPrompt extends FixedSetPrompt {
context.setSessionData(CK.REW_HEROES_AMOUNTS, null);
return new HeroesListPrompt();
} else if (input.equalsIgnoreCase("4")) {
int one;
int two;
if (context.getSessionData(CK.REW_HEROES_CLASSES) != null) {
one = ((List<Integer>) context.getSessionData(CK.REW_HEROES_CLASSES)).size();
} else {
one = 0;
}
if (context.getSessionData(CK.REW_HEROES_AMOUNTS) != null) {
two = ((List<Double>) context.getSessionData(CK.REW_HEROES_AMOUNTS)).size();
} else {
two = 0;
}
if (one == two) {
return new RewardsPrompt(quests, factory);
} else {
@ -741,7 +574,6 @@ public class RewardsPrompt extends FixedSetPrompt {
}
}
return null;
}
@SuppressWarnings("unchecked")
@ -753,49 +585,36 @@ public class RewardsPrompt extends FixedSetPrompt {
private List<Double> getClassAmounts(ConversationContext context) {
return (List<Double>) context.getSessionData(CK.REW_HEROES_AMOUNTS);
}
}
private class HeroesClassesPrompt extends StringPrompt {
@Override
public String getPromptText(ConversationContext cc) {
String text = ChatColor.DARK_PURPLE + Lang.get("heroesClassesTitle") + "\n";
LinkedList<String> list = new LinkedList<String>();
for (HeroClass hc : Quests.heroes.getClassManager().getClasses()) {
list.add(hc.getName());
}
if (list.isEmpty()) {
text += ChatColor.GRAY + "(" + Lang.get("none") + ")\n";
} else {
Collections.sort(list);
for (String s : list) {
text += ChatColor.LIGHT_PURPLE + s + ", ";
}
text = text.substring(0, text.length() - 2) + "\n";
}
text += ChatColor.YELLOW + Lang.get("rewHeroesClassesPrompt");
return text;
}
@Override
public Prompt acceptInput(ConversationContext cc, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
String[] arr = input.split(" ");
LinkedList<String> classes = new LinkedList<String>();
for (String s : arr) {
HeroClass hc = Quests.heroes.getClassManager().getClass(s);
if (hc == null) {
String text = Lang.get("rewHeroesInvalidClass");
@ -805,17 +624,12 @@ public class RewardsPrompt extends FixedSetPrompt {
} else {
classes.add(hc.getName());
}
}
cc.setSessionData(CK.REW_HEROES_CLASSES, classes);
return new HeroesListPrompt();
} else {
return new HeroesListPrompt();
}
}
}
@ -823,45 +637,32 @@ public class RewardsPrompt extends FixedSetPrompt {
@Override
public String getPromptText(ConversationContext cc) {
String text = Lang.get("heroesExperienceTitle") + "\n";
text += ChatColor.YELLOW + Lang.get("rewHeroesExperiencePrompt");
return text;
}
@Override
public Prompt acceptInput(ConversationContext cc, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false) {
String[] arr = input.split(" ");
LinkedList<Double> amounts = new LinkedList<Double>();
for (String s : arr) {
try {
double d = Double.parseDouble(s);
amounts.add(d);
} catch (NumberFormatException nfe) {
String text = Lang.get("reqNotANumber");
text = text.replaceAll("<input>", ChatColor.LIGHT_PURPLE + s + ChatColor.RED);
cc.getForWhom().sendRawMessage(ChatColor.RED + text);
return new HeroesExperiencePrompt();
}
}
cc.setSessionData(CK.REW_HEROES_AMOUNTS, amounts);
return new HeroesListPrompt();
} else {
return new HeroesListPrompt();
}
}
}
@ -869,53 +670,37 @@ public class RewardsPrompt extends FixedSetPrompt {
@Override
public String getPromptText(ConversationContext cc) {
String text = ChatColor.DARK_AQUA + Lang.get("phatLootsRewardsTitle") + "\n";
for (PhatLoot pl : PhatLootsAPI.getAllPhatLoots()) {
text += ChatColor.GRAY + "- " + ChatColor.BLUE + pl.name + "\n";
}
text += ChatColor.YELLOW + Lang.get("rewPhatLootsPrompt");
return text;
}
@Override
public Prompt acceptInput(ConversationContext cc, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
String[] arr = input.split(" ");
LinkedList<String> loots = new LinkedList<String>();
for (String s : arr) {
if (PhatLootsAPI.getPhatLoot(s) == null) {
String text = Lang.get("rewPhatLootsInvalid");
text = text.replaceAll("<input>", ChatColor.DARK_RED + s + ChatColor.RED);
cc.getForWhom().sendRawMessage(ChatColor.RED + text);
return new PhatLootsPrompt();
}
}
loots.addAll(Arrays.asList(arr));
cc.setSessionData(CK.REW_PHAT_LOOTS, loots);
return new RewardsPrompt(quests, factory);
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
cc.setSessionData(CK.REW_PHAT_LOOTS, null);
cc.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("rewPhatLootsCleared"));
return new RewardsPrompt(quests, factory);
} else {
return new RewardsPrompt(quests, factory);
}
}
}
@ -931,16 +716,13 @@ public class RewardsPrompt extends FixedSetPrompt {
text += ChatColor.DARK_PURPLE + " - " + cr.getName() + "\n";
}
}
return text + ChatColor.YELLOW + Lang.get("rewCustomRewardPrompt");
}
@SuppressWarnings("unchecked")
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase(Lang.get("cmdCancel")) == false && input.equalsIgnoreCase(Lang.get("cmdClear")) == false) {
CustomReward found = null;
for (CustomReward cr : quests.customRewards) {
if (cr.getName().equalsIgnoreCase(input)) {
@ -948,7 +730,6 @@ public class RewardsPrompt extends FixedSetPrompt {
break;
}
}
if (found == null) {
for (CustomReward cr : quests.customRewards) {
if (cr.getName().toLowerCase().contains(input.toLowerCase())) {
@ -957,9 +738,7 @@ public class RewardsPrompt extends FixedSetPrompt {
}
}
}
if (found != null) {
if (context.getSessionData(CK.REW_CUSTOM) != null) {
LinkedList<String> list = (LinkedList<String>) context.getSessionData(CK.REW_CUSTOM);
LinkedList<Map<String, Object>> datamapList = (LinkedList<Map<String, Object>>) context.getSessionData(CK.REW_CUSTOM_DATA);
@ -980,30 +759,23 @@ public class RewardsPrompt extends FixedSetPrompt {
context.setSessionData(CK.REW_CUSTOM, list);
context.setSessionData(CK.REW_CUSTOM_DATA, datamapList);
}
//Send user to the custom data prompt if there is any needed
// Send user to the custom data prompt if there is any needed
if (found.datamap.isEmpty() == false) {
context.setSessionData(CK.REW_CUSTOM_DATA_DESCRIPTIONS, found.descriptions);
return new RewardCustomDataListPrompt();
}
//
} else {
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("rewCustomNotFound"));
return new CustomRewardsPrompt();
}
} else if (input.equalsIgnoreCase(Lang.get("cmdClear"))) {
context.setSessionData(CK.REW_CUSTOM, null);
context.setSessionData(CK.REW_CUSTOM_DATA, null);
context.setSessionData(CK.REW_CUSTOM_DATA_TEMP, null);
context.getForWhom().sendRawMessage(ChatColor.YELLOW + Lang.get("rewCustomCleared"));
}
return new RewardsPrompt(quests, factory);
}
}
@ -1012,86 +784,63 @@ public class RewardsPrompt extends FixedSetPrompt {
@SuppressWarnings("unchecked")
@Override
public String getPromptText(ConversationContext context) {
String text = ChatColor.BOLD + "" + ChatColor.AQUA + "- ";
LinkedList<String> list = (LinkedList<String>) context.getSessionData(CK.REW_CUSTOM);
LinkedList<Map<String, Object>> datamapList = (LinkedList<Map<String, Object>>) context.getSessionData(CK.REW_CUSTOM_DATA);
String rewName = list.getLast();
Map<String, Object> datamap = datamapList.getLast();
text += rewName + " -\n";
int index = 1;
LinkedList<String> datamapKeys = new LinkedList<String>();
for (String key : datamap.keySet()) {
datamapKeys.add(key);
}
Collections.sort(datamapKeys);
for (String dataKey : datamapKeys) {
text += ChatColor.BOLD + "" + ChatColor.DARK_BLUE + index + " - " + ChatColor.RESET + ChatColor.BLUE + dataKey;
if (datamap.get(dataKey) != null) {
text += ChatColor.GREEN + " (" + (String) datamap.get(dataKey) + ")\n";
} else {
text += ChatColor.RED + " (" + Lang.get("valRequired") + ")\n";
}
index++;
}
text += ChatColor.BOLD + "" + ChatColor.DARK_BLUE + index + " - " + ChatColor.AQUA + Lang.get("finish");
return text;
}
@Override
public Prompt acceptInput(ConversationContext context, String input) {
@SuppressWarnings("unchecked")
LinkedList<Map<String, Object>> datamapList = (LinkedList<Map<String, Object>>) context.getSessionData(CK.REW_CUSTOM_DATA);
Map<String, Object> datamap = datamapList.getLast();
int numInput;
try {
numInput = Integer.parseInt(input);
} catch (NumberFormatException nfe) {
return new RewardCustomDataListPrompt();
}
if (numInput < 1 || numInput > datamap.size() + 1) {
return new RewardCustomDataListPrompt();
}
if (numInput < datamap.size() + 1) {
LinkedList<String> datamapKeys = new LinkedList<String>();
for (String key : datamap.keySet()) {
datamapKeys.add(key);
}
Collections.sort(datamapKeys);
String selectedKey = datamapKeys.get(numInput - 1);
context.setSessionData(CK.REW_CUSTOM_DATA_TEMP, selectedKey);
return new RewardCustomDataPrompt();
} else {
if (datamap.containsValue(null)) {
return new RewardCustomDataListPrompt();
} else {
context.setSessionData(CK.REW_CUSTOM_DATA_DESCRIPTIONS, null);
return new RewardsPrompt(quests, factory);
}
}
}
}
private class RewardCustomDataPrompt extends StringPrompt {
@ -1105,7 +854,6 @@ public class RewardsPrompt extends FixedSetPrompt {
if (descriptions.get(temp) != null) {
text += ChatColor.GOLD + descriptions.get(temp) + "\n";
}
String lang = Lang.get("stageEditorCustomDataPrompt");
lang = lang.replaceAll("<data>", temp);
text += ChatColor.YELLOW + lang;
@ -1121,7 +869,5 @@ public class RewardsPrompt extends FixedSetPrompt {
context.setSessionData(CK.REW_CUSTOM_DATA_TEMP, null);
return new RewardCustomDataListPrompt();
}
}
}

View File

@ -14,47 +14,32 @@ 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) {
@ -66,224 +51,160 @@ public class StagesPrompt extends StringPrompt {
} 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);
}
}
}

View File

@ -5,8 +5,7 @@ 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
// Quests
public static final String Q_NAME = "questName";
public static final String Q_ASK_MESSAGE = "askMessage";
public static final String Q_FINISH_MESSAGE = "finishMessage";
@ -17,8 +16,7 @@ public class CK {
public static final String Q_INITIAL_EVENT = "initialEvent";
public static final String Q_REGION = "region";
public static final String Q_GUIDISPLAY = "guiDisplay";
//Requirements
// Requirements
public static final String REQ_MONEY = "moneyReq";
public static final String REQ_QUEST_POINTS = "questPointsReq";
public static final String REQ_ITEMS = "itemReqs";
@ -34,8 +32,7 @@ public class CK {
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
// Rewards
public static final String REW_MONEY = "moneyRew";
public static final String REW_QUEST_POINTS = "questPointsRew";
public static final String REW_ITEMS = "itemRews";
@ -51,7 +48,7 @@ public class CK {
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
// 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";
@ -110,8 +107,7 @@ public class CK {
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
// Events
public static final String E_OLD_EVENT = "oldEvent";
public static final String E_NAME = "evtName";
public static final String E_MESSAGE = "evtMessage";
@ -136,8 +132,6 @@ public class CK {
public static final String E_HEALTH = "evtHealth";
public static final String E_TELEPORT = "evtTeleportLocation";
public static final String E_COMMANDS = "evtCommands";
//Party
// Party
public static final String P_INVITER = "inviter";
}

View File

@ -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,6 +10,10 @@ 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;
@ -22,10 +22,11 @@ public class ItemUtil {
* 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>
* @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&nbsp;-> stack names are unequal<br>
* @return -2&nbsp;-> stack amounts are unequal<br>
* @return -3&nbsp;-> stack data is unequal<br>
@ -33,15 +34,12 @@ public class ItemUtil {
* @return -5&nbsp;-> 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) {
@ -49,9 +47,7 @@ public class ItemUtil {
} 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()) {
@ -69,9 +65,7 @@ public class ItemUtil {
} 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 {
@ -79,20 +73,19 @@ public class ItemUtil {
}
}
//Formats -> name-name:amount-amount:data-data:enchantment-enchantment level:displayname-displayname:lore-lore:
//Returns null if invalid format
// 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
// Attempt to match item name. Returns null if invalid format
try {
stack = new ItemStack(Material.matchMaterial(arg.substring(5)));
} catch (NullPointerException npe) {
@ -114,41 +107,30 @@ public class ItemUtil {
} 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();
@ -158,15 +140,11 @@ public class ItemUtil {
serial += ":lore-" + s;
}
}
}
return serial;
}
public static String getDisplayString(ItemStack is) {
String text;
if (is == null) {
return null;
@ -178,23 +156,16 @@ public class ItemUtil {
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 {
@ -202,19 +173,13 @@ public class ItemUtil {
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 {
@ -225,36 +190,24 @@ public class ItemUtil {
ne.printStackTrace();
}
}
return text;
}
public static boolean isItem(ItemStack is) {
if(is == null)
if (is == null)
return false;
if(is.getType().equals(Material.AIR))
if (is.getType().equals(Material.AIR))
return false;
return true;
}
public static boolean isJournal(ItemStack is) {
if(is == null)
if (is == null)
return false;
if(is.hasItemMeta() == false)
if (is.hasItemMeta() == false)
return false;
if(is.getItemMeta().hasDisplayName() == false)
if (is.getItemMeta().hasDisplayName() == false)
return false;
return is.getItemMeta().getDisplayName().equals(ChatColor.LIGHT_PURPLE + Lang.get("journalTitle"));
}
}

View File

@ -8,19 +8,17 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import me.blackvein.quests.Quests;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import me.blackvein.quests.Quests;
public class Lang {
public static String lang = "en";
private static final LangToken tokens = new LangToken();
private static final LinkedHashMap<String, String> langMap = new LinkedHashMap<String, String>();
private final Quests plugin;
public Lang(Quests plugin) {
@ -33,31 +31,21 @@ public class Lang {
}
public static String getKey(String val) {
for (Entry<String, String> entry : langMap.entrySet()) {
if (entry.getValue().equals(val)) {
return entry.getKey();
}
}
return "NULL";
}
public static String getCommandKey(String val) {
for (Entry<String, String> entry : langMap.entrySet()) {
if (entry.getValue().equalsIgnoreCase(val) && entry.getKey().toUpperCase().startsWith("COMMAND_")) {
return entry.getKey();
}
}
return "NULL";
}
public static void clearPhrases() {
@ -69,21 +57,15 @@ public class Lang {
}
public static String getModified(String key, String[] tokens) {
String orig = langMap.get(key);
for (int i = 0; i < tokens.length; i++) {
orig = orig.replaceAll("%" + (i + 1), tokens[i]);
}
return orig;
}
public void initPhrases() {
//Quests
// Quests
langMap.put("questFailed", "*QUEST FAILED*");
langMap.put("questMaxAllowed", "You may only have up to <number> Quests.");
langMap.put("questAlreadyOn", "You are already on that Quest!");
@ -91,98 +73,69 @@ public class Lang {
langMap.put("questAlreadyCompleted", "You have already completed <quest>.");
langMap.put("questInvalidLocation", "You may not take <quest> at this location.");
langMap.put("questInvalidDeliveryItem", "<item> is not a required item for this quest!");
langMap.put("questSelectedLocation", "Selected location");
langMap.put("questDisplayHelp", "- Display this help");
//Commands
// Commands
langMap.put("COMMAND_LIST", "list");
langMap.put("COMMAND_LIST_HELP", "list [page] - List available Quests");
langMap.put("COMMAND_TAKE", "take");
langMap.put("COMMAND_TAKE_HELP", "take [quest name] - Accept a Quest");
langMap.put("COMMAND_TAKE_USAGE", "Usage: /quests take [quest]");
langMap.put("COMMAND_QUIT", "quit");
langMap.put("COMMAND_QUIT_HELP", "quit [quest] - Quit a current Quest");
langMap.put("COMMAND_EDITOR", "editor");
langMap.put("COMMAND_EDITOR_HELP", "editor - Create/Edit Quests");
langMap.put("COMMAND_EVENTS_EDITOR", "events");
langMap.put("COMMAND_EVENTS_EDITOR_HELP", "events - Create/Edit Events");
langMap.put("COMMAND_STATS", "stats");
langMap.put("COMMAND_STATS_HELP", "stats - View your Questing stats");
langMap.put("COMMAND_TOP", "top");
langMap.put("COMMAND_TOP_HELP", "top [number] - View top Questers");
langMap.put("COMMAND_TOP_USAGE", "Usage: /quests top [number]");
langMap.put("COMMAND_INFO", "info");
langMap.put("COMMAND_INFO_HELP", "info - Display plugin information");
langMap.put("COMMAND_JOURNAL", "journal");
langMap.put("COMMAND_JOURNAL_HELP", "journal - View/Put away your Quest Journal");
langMap.put("COMMAND_QUEST_HELP", "- Display current Quest objectives");
langMap.put("COMMAND_QUESTINFO_HELP", "[quest name] - Display Quest information");
langMap.put("COMMAND_QUESTADMIN_HELP", "- View Questadmin help");
langMap.put("COMMAND_QUESTADMIN_STATS", "stats");
langMap.put("COMMAND_QUESTADMIN_STATS_HELP", "stats [player] - View Questing statistics of a player");
langMap.put("COMMAND_QUESTADMIN_GIVE", "give");
langMap.put("COMMAND_QUESTADMIN_GIVE_HELP", "give [player] [quest] - Force a player to take a Quest");
langMap.put("COMMAND_QUESTADMIN_QUIT", "quit");
langMap.put("COMMAND_QUESTADMIN_QUIT_HELP", "quit [player] [quest] - Force a player to quit their Quest");
langMap.put("COMMAND_QUESTADMIN_POINTS", "points");
langMap.put("COMMAND_QUESTADMIN_POINTS_HELP", "points [player] [amount] - Set a players Quest Points");
langMap.put("COMMAND_QUESTADMIN_TAKEPOINTS", "takepoints");
langMap.put("COMMAND_QUESTADMIN_TAKEPOINTS_HELP", "takepoints [player] [amount] - Take a players Quest Points");
langMap.put("COMMAND_QUESTADMIN_GIVEPOINTS", "givepoints");
langMap.put("COMMAND_QUESTADMIN_GIVEPOINTS_HELP", "givepoints [player] [amount] - Give a player Quest Points");
langMap.put("COMMAND_QUESTADMIN_POINTSALL", "pointsall");
langMap.put("COMMAND_QUESTADMIN_POINTSALL_HELP", "pointsall [amount] - Set ALL players' Quest Points");
langMap.put("COMMAND_QUESTADMIN_FINISH", "finish");
langMap.put("COMMAND_QUESTADMIN_FINISH_HELP", "finish [player] [quest] - Immediately force Quest completion for a player");
langMap.put("COMMAND_QUESTADMIN_NEXTSTAGE", "nextstage");
langMap.put("COMMAND_QUESTADMIN_NEXTSTAGE_HELP", "nextstage [player] [quest] - Immediately force Stage completion for a player");
langMap.put("COMMAND_QUESTADMIN_SETSTAGE", "setstage");
langMap.put("COMMAND_QUESTADMIN_SETSTAGE_HELP", "setstage [player] [quest] [stage] - Set the current Stage for a player");
langMap.put("COMMAND_QUESTADMIN_SETSTAGE_USAGE", "Usage: /questadmin setstage [player] [quest] [stage]");
langMap.put("COMMAND_QUESTADMIN_PURGE", "purge");
langMap.put("COMMAND_QUESTADMIN_PURGE_HELP", "purge [player] - Clear all Quests data of a player AND BLACKLISTS THEM");
langMap.put("COMMAND_QUESTADMIN_RESET", "reset");
langMap.put("COMMAND_QUESTADMIN_RESET_HELP", "reset [player] - Clear all Quests data of a player");
langMap.put("COMMAND_QUESTADMIN_REMOVE", "remove");
langMap.put("COMMAND_QUESTADMIN_REMOVE_HELP", "remove [player] [quest] - Remove a completed Quest from a player");
langMap.put("COMMAND_QUESTADMIN_TOGGLEGUI", "togglegui");
langMap.put("COMMAND_QUESTADMIN_TOGGLEGUI_HELP", "togglegui [npc id] - Toggle GUI Quest Display on an NPC");
langMap.put("COMMAND_QUESTADMIN_RELOAD", "reload");
langMap.put("COMMAND_QUESTADMIN_RELOAD_HELP", "reload - Reload all Quests");
//Quest create menu
// Quest create menu
langMap.put("questEditorHeader", "Create Quest");
langMap.put("questEditorCreate", "Create new Quest");
langMap.put("questEditorEdit", "Edit a Quest");
langMap.put("questEditorDelete", "Delete Quest");
langMap.put("questEditorName", "Set name");
langMap.put("questEditorAskMessage", "Set ask message");
langMap.put("questEditorFinishMessage", "Set finish message");
langMap.put("questEditorRedoDelay", "Set redo delay");
@ -193,7 +146,6 @@ public class Lang {
langMap.put("questEditorReqs", "Edit Requirements");
langMap.put("questEditorStages", "Edit Stages");
langMap.put("questEditorRews", "Edit Rewards");
langMap.put("questEditorEnterQuestName", "Enter Quest name (or 'cancel' to return)");
langMap.put("questEditorEditEnterQuestName", "Enter Quest name to edit, or 'cancel' to return");
langMap.put("questEditorEnterAskMessage", "Enter ask message (or 'cancel' to return)");
@ -202,27 +154,21 @@ public class Lang {
langMap.put("questEditorEnterNPCStart", "Enter NPC ID, -1 to clear the NPC start or -2 to cancel");
langMap.put("questEditorEnterBlockStart", "Right-click on a block to use as a start point, then enter 'done' to save, or enter 'clear' to clear the block start, or 'cancel' to return");
langMap.put("questEditorEnterInitialEvent", "Enter an Event name, or enter 'clear' to clear the initial Event, or 'cancel' to return");
langMap.put("questRequiredNoneSet", "Required, none set");
langMap.put("questWGSetRegion", "Set Region");
langMap.put("questWGNotInstalled", "WorldGuard not installed");
langMap.put("questWGPrompt", "Enter WorldGuard region, or enter 'clear' to clear the region, or 'cancel' to return.");
langMap.put("questWGInvalidRegion", "<region> is not a valid WorldGuard region!");
langMap.put("questWGRegionCleared", "Quest region cleared.");
langMap.put("questCitNotInstalled", "Citizens not installed");
langMap.put("questDenNotInstalled", "Denizen not installed");
langMap.put("questGUIError", "Error: That item is already being used as the GUI Display for the Quest <quest>.");
langMap.put("questCurrentItem", "Current item:");
langMap.put("questSetItem", "Set Item");
langMap.put("questClearItem", "Clear Item");
langMap.put("questGUICleared", "Quest GUI Item Display cleared.");
langMap.put("questDeleted", "Quest deleted! Quests and Events have been reloaded.");
//Quest create menu errors
// Quest create menu errors
langMap.put("questEditorNameExists", "A Quest with that name already exists!");
langMap.put("questEditorBeingEdited", "Someone is creating/editing a Quest with that name!");
langMap.put("questEditorInvalidQuestName", "Name may not contain periods or commas!");
@ -234,27 +180,23 @@ public class Lang {
langMap.put("questEditorQuestAsRequirement2", "as a requirement:");
langMap.put("questEditorQuestAsRequirement3", "You must modify these Quests so that they do not use it before deleting it.");
langMap.put("questEditorQuestNotFound", "Quest not found!");
langMap.put("questEditorEventCleared", "Initial Event cleared.");
langMap.put("questEditorSave", "Finish and save");
langMap.put("questEditorNeedAskMessage", "You must set an ask message!");
langMap.put("questEditorNeedFinishMessage", "You must set a finish message!");
langMap.put("questEditorNeedStages", "Your Quest has no Stages!");
langMap.put("questEditorSaved", "Quest saved! (You will need to perform a Quest reload for it to appear)");
langMap.put("questEditorExited", "Are you sure you want to exit without saving?");
langMap.put("questEditorDeleted", "Are you sure you want to delete the Quest");
langMap.put("questEditorNoPermsCreate", "You do not have permission to create Quests.");
langMap.put("questEditorNoPermsEdit", "You do not have permission to edit Quests.");
langMap.put("questEditorNoPermsDelete", "You do not have permission to delete Quests.");
//
//Stages
//Menu
// Stages
// Menu
langMap.put("stageEditorEditStage", "Edit Stage");
langMap.put("stageEditorNewStage", "Add new Stage");
//create prompt
// create prompt
langMap.put("stageEditorStages", "Stages");
langMap.put("stageEditorStage", "Stage");
langMap.put("stageEditorBreakBlocks", "Break Blocks");
@ -295,7 +237,6 @@ public class Lang {
langMap.put("stageEditorStartMessage", "Start Message");
langMap.put("stageEditorCompleteMessage", "Complete Message");
langMap.put("stageEditorDelete", "Delete Stage");
langMap.put("stageEditorSetBlockNames", "Set block names");
langMap.put("stageEditorSetBlockAmounts", "Set block amounts");
langMap.put("stageEditorSetBlockDurability", "Set block durability");
@ -331,7 +272,6 @@ public class Lang {
langMap.put("stageEditorCustomAlreadyAdded", "That custom objective has already been added!");
langMap.put("stageEditorCustomCleared", "Custom objectives cleared.");
langMap.put("stageEditorCustomDataPrompt", "Enter value for <data>:");
langMap.put("stageEditorEnterBlockNames", "Enter block names, separating each one by a space, or enter \'cancel\' to return.");
langMap.put("stageEditorBreakBlocksPrompt", "Enter block amounts (numbers), separating each one by a space, or enter \'cancel\' to return.");
langMap.put("stageEditorDamageBlocksPrompt", "Enter damage amounts (numbers), separating each one by a space, or enter \'cancel\' to return.");
@ -372,15 +312,12 @@ public class Lang {
langMap.put("stageEditorPasswordPhrasePrompt", "Enter a password phrase, or 'cancel' to return");
langMap.put("stageEditorPasswordPhraseHint1", "(This is the text that a player has to say to complete the objective)");
langMap.put("stageEditorPasswordPhraseHint2", "If you want multiple password phrases, seperate them by a | (pipe)");
langMap.put("stageEditorObjectiveOverridePrompt", "Enter objective display override, or 'clear' to clear the override, or 'cancel' to return.");
langMap.put("stageEditorObjectiveOverrideHint", "(The objective display override will show up as the players current objective)");
langMap.put("stageEditorObjectiveOverrideCleared", "Objective display override cleared.");
langMap.put("stageEditorDeliveryAddItem", "Add item");
langMap.put("stageEditorDeliveryNPCs", "Set NPC IDs");
langMap.put("stageEditorDeliveryMessages", "Set delivery messages");
langMap.put("stageEditorContainsDuplicates", "List contains duplicates!");
langMap.put("stageEditorInvalidBlockName", "is not a valid block name!");
langMap.put("stageEditorInvalidEnchantment", "is not a valid enchantment name!");
@ -393,10 +330,8 @@ public class Lang {
langMap.put("stageEditorDuplicateEvent", "Event is already in the list!");
langMap.put("stageEditorInvalidDelay", "Delay must be at least one second!");
langMap.put("stageEditorInvalidScript", "Denizen script not found!");
langMap.put("stageEditorNoCitizens", "Citizens is not installed!");
langMap.put("stageEditorNoDenizen", "Denizen is not installed!");
langMap.put("stageEditorPositiveAmount", "You must enter a positive number!");
langMap.put("stageEditorNoNumber", "Input was not a number!");
langMap.put("stageEditorNotGreaterThanZero", "is not greater than 0!");
@ -412,13 +347,11 @@ public class Lang {
langMap.put("stageEditorNoBlockSelected", "You must select a block first.");
langMap.put("stageEditorNoColors", "You must set colors first!");
langMap.put("stageEditorNoLocations", "You must set locations first!");
langMap.put("stageEditorNoEnchantmentsSet", "No enchantments set");
langMap.put("stageEditorNoItemsSet", "No items set");
langMap.put("stageEditorNoMobTypesSet", "No mob types set");
langMap.put("stageEditorNoLocationsSet", "No locations set");
langMap.put("stageEditorNoColorsSet", "No colors set");
langMap.put("stageEditorListNotSameSize", "The block names list and the amounts list are not the same size!");
langMap.put("stageEditorEnchantmentNotSameSize", "The enchantments list, the item id list and the enchant amount list are not the same size!");
langMap.put("stageEditorDeliveriesNotSameSize", "The item list and the NPC list are not equal in size!");
@ -427,17 +360,13 @@ public class Lang {
langMap.put("stageEditorMobTypesNotSameSize", "The mob types list and the mob amounts list are not the same size!");
langMap.put("stageEditorTameMobsNotSameSize", "The mob types list and the tame amounts list are not the same size!");
langMap.put("stageEditorShearNotSameSize", "The sheep colors list and the shear amounts list are not the same size!");
langMap.put("stageEditorMustSetPasswordDisplays", "You must add at least one password display first!");
langMap.put("stageEditorAddPasswordCleared", "Password Objectives cleared.");
langMap.put("stageEditorPasswordNotSameSize", "The password display and password phrase lists are not the same size!");
langMap.put("stageEditorListContainsDuplicates", " List contains duplicates!");
langMap.put("stageEditorDelayCleared", "Delay cleared.");
langMap.put("stageEditorDelayMessageCleared", "Delay message cleared.");
langMap.put("stageEditorDenizenCleared", "Denizen script cleared.");
langMap.put("stageEditorBreakBlocksCleared", "Break blocks objective cleared.");
langMap.put("stageEditorDamageBlocksCleared", "Damage blocks objective cleared.");
langMap.put("stageEditorPlaceBlocksCleared", "Place blocks objective cleared.");
@ -452,55 +381,45 @@ public class Lang {
langMap.put("stageEditorShearCleared", "Shear Sheep objective cleared.");
langMap.put("stageEditorStartMessageCleared", "Start message cleared.");
langMap.put("stageEditorCompleteMessageCleared", "Complete message cleared.");
langMap.put("stageEditorConfirmStageDelete", "Are you sure you want to delete this stage?");
langMap.put("stageEditorConfirmStageNote", "Any Stages after will be shifted back one spot");
langMap.put("stageEditorDeleteSucces", "Stage deleted successfully.");
langMap.put("stageEditorEnchantments", "Enchantments");
langMap.put("stageEditorNPCNote", "Note: You may specify the name of the NPC with <npc>");
langMap.put("stageEditorOptional", "Optional");
langMap.put("stageEditorColors", "Sheep Colors");
langMap.put("allListsNotSameSize", "All of your lists are not the same size!");
//Events
// Events
langMap.put("eventEditorCreate", "Create new Event");
langMap.put("eventEditorEdit", "Edit an Event");
langMap.put("eventEditorDelete", "Delete an Event");
langMap.put("eventEditorCreatePermisssions", "You do not have permission to create new Events.");
langMap.put("eventEditorEditPermisssions", "You do not have permission to edit Events.");
langMap.put("eventEditorDeletePermisssions", "You do not have permission to delete Events.");
langMap.put("eventEditorNoneToEdit", "No Events currently exist to be edited!");
langMap.put("eventEditorNoneToDelete", "No Events currently exist to be deleted!");
langMap.put("eventEditorNotFound", "Event not found!");
langMap.put("eventEditorExists", "Event already exists!");
langMap.put("eventEditorSomeone", "Someone is already creating or editing an Event with that name!");
langMap.put("eventEditorAlpha", "Name must be alphanumeric!");
langMap.put("eventEditorErrorReadingFile", "Error reading Events file.");
langMap.put("eventEditorErrorSaving", "An error occurred while saving.");
langMap.put("eventEditorDeleted", "Event deleted, Quests and Events reloaded.");
langMap.put("eventEditorSaved", "Event saved, Quests and Events reloaded.");
langMap.put("eventEditorEnterEventName", "Enter an Event name, or 'cancel' to return.");
langMap.put("eventEditorDeletePrompt", "Are you sure you want to delete the Event");
langMap.put("eventEditorQuitWithoutSaving", "Are you sure you want to quit without saving?");
langMap.put("eventEditorFinishAndSave", "Are you sure you want to finish and save the Event");
langMap.put("eventEditorModifiedNote", "Note: You have modified an Event that the following Quests use:");
langMap.put("eventEditorForcedToQuit", "If you save the Event, anyone who is actively doing any of these Quests will be forced to quit them.");
langMap.put("eventEditorEventInUse", "The following Quests use the Event");
langMap.put("eventEditorMustModifyQuests", "eventEditorNotFound");
langMap.put("eventEditorListSizeMismatch", "The lists are not the same size!");
langMap.put("eventEditorListDuplicates", "List contains duplicates!");
langMap.put("eventEditorNotANumberList", "Input was not a list of numbers!");
langMap.put("eventEditorInvalidEntry", "Invalid entry");
langMap.put("eventEditorSetName", "Set name");
langMap.put("eventEditorSetMessage", "Set message");
langMap.put("eventEditorClearInv", "Clear player inventory");
langMap.put("eventEditorFailQuest", "Fail the quest");
langMap.put("eventEditorSetExplosions", "Set explosion locations");
@ -515,7 +434,6 @@ public class Lang {
langMap.put("eventEditorSetHealth", "Set player health level");
langMap.put("eventEditorSetTeleport", "Set player teleport location");
langMap.put("eventEditorSetCommands", "Set commands to execute");
langMap.put("eventEditorItems", "Event Items");
langMap.put("eventEditorSetItems", "Give items");
langMap.put("eventEditorItemsCleared", "Event items cleared.");
@ -527,7 +445,6 @@ public class Lang {
langMap.put("eventEditorInvalidName", "is not a valid item name!");
langMap.put("eventEditorNotGreaterThanZero", "is not greater than 0!");
langMap.put("eventEditorNotANumber", "is not a number!");
langMap.put("eventEditorStorm", "Event Storm");
langMap.put("eventEditorSetWorld", "Set world");
langMap.put("eventEditorSetDuration", "Set duration");
@ -540,12 +457,10 @@ public class Lang {
langMap.put("eventEditorEnterDuration", "Enter duration (in seconds)");
langMap.put("eventEditorAtLeastOneSecond", "Amount must be at least 1 second!");
langMap.put("eventEditorNotGreaterThanOneSecond", "is not greater than 1 second!");
langMap.put("eventEditorThunder", "Event Thunder");
langMap.put("eventEditorMustSetThunderDuration", "You must set a thunder duration!");
langMap.put("eventEditorThunderCleared", "Thunder data cleared.");
langMap.put("eventEditorEnterThunderWorld", "Enter a world name for the thunder to occur in, or enter 'cancel' to return");
langMap.put("eventEditorEffects", "Event Effects");
langMap.put("eventEditorAddEffect", "Add effect");
langMap.put("eventEditorAddEffectLocation", "Add effect location");
@ -554,7 +469,6 @@ public class Lang {
langMap.put("eventEditorInvalidEffect", "is not a valid effect name!");
langMap.put("eventEditorEffectsCleared", "Event effects cleared.");
langMap.put("eventEditorEffectLocationPrompt", "Right-click on a block to play an effect at, then enter 'add' to add it to the list, or enter 'cancel' to return");
langMap.put("eventEditorMobSpawns", "Event Mob Spawns");
langMap.put("eventEditorAddMobTypes", "Add mob");
langMap.put("eventEditorNoTypesSet", "(No type set)");
@ -582,9 +496,7 @@ public class Lang {
langMap.put("eventEditorSetMobSpawnAmount", "Set the amount of mobs to spawn");
langMap.put("eventEditorSetDropChance", "Set the drop chance");
langMap.put("eventEditorInvalidDropChance", "Drop chance has to be between 0.0 and 1.0");
langMap.put("eventEditorLightningPrompt", "Right-click on a block to spawn a lightning strike at, then enter 'add' to add it to the list, or enter 'clear' to clear the locations list, or 'cancel' to return");
langMap.put("eventEditorPotionEffects", "Event Potion Effects");
langMap.put("eventEditorSetPotionEffectTypes", "Set potion effect types");
langMap.put("eventEditorMustSetPotionTypesFirst", "You must set potion effect types first!");
@ -595,7 +507,6 @@ public class Lang {
langMap.put("eventEditorSetPotionMagnitudes", "Set potion effect magnitudes");
langMap.put("eventEditorPotionsCleared", "Potion effects cleared.");
langMap.put("eventEditorInvalidPotionType", "is not a valid potion effect type!");
langMap.put("eventEditorEnterNPCId", "Enter NPC ID (or -1 to return)");
langMap.put("eventEditorNoNPCExists", "No NPC exists with that id!");
langMap.put("eventEditorExplosionPrompt", "Right-click on a block to spawn an explosion at, then enter 'add' to add it to the list, or enter 'clear' to clear the explosions list, or 'cancel' to return");
@ -620,8 +531,7 @@ public class Lang {
langMap.put("eventEditorCommandsNote", "Note: You may use <player> to refer to the player's name.");
langMap.put("eventEditorSetCommandsPrompt", "Enter commands separating each one by a comma, or enter 'clear' to clear the list, or enter 'cancel' to return.");
//
//Requirements Prompt
// Requirements Prompt
langMap.put("reqSetMoney", "Set money requirement");
langMap.put("reqSetQuestPoints", "Set Quest Points requirement");
langMap.put("reqSetItem", "Set item requirements");
@ -636,7 +546,6 @@ public class Lang {
langMap.put("reqSetSkillAmounts", "Set skill amounts");
langMap.put("reqHeroesSetPrimary", "Set Primary Class");
langMap.put("reqHeroesSetSecondary", "Set Secondary Class");
langMap.put("reqMoneyPrompt", "Enter amount of <money>, or 0 to clear the money requirement, or -1 to cancel");
langMap.put("reqQuestPointsPrompt", "Enter amount of Quest Points, or 0 to clear the Quest Point requirement, or -1 to cancel");
langMap.put("reqQuestPrompt", "Enter a list of Quest names separating each one by a <comma>, or enter \'clear\' to clear the list, or \'cancel\' to return.");
@ -648,15 +557,12 @@ public class Lang {
langMap.put("reqHeroesPrimaryPrompt", "Enter a Heroes Primary Class name, or enter 'clear' to clear the requirement, or 'cancel' to return.");
langMap.put("reqHeroesSecondaryPrompt", "Enter a Heroes Secondary Class name, or enter 'clear' to clear the requirement, or 'cancel' to return.");
langMap.put("reqFailMessagePrompt", "Enter fail requirements message, or enter \'cancel\' to return.");
langMap.put("reqAddItem", "Add item");
langMap.put("reqSetRemoveItems", "Set remove items");
langMap.put("reqNoItemsSet", "No items set");
langMap.put("reqNoValuesSet", "No values set");
langMap.put("reqHeroesPrimaryDisplay", "Primary Class:");
langMap.put("reqHeroesSecondaryDisplay", "Secondary Class:");
langMap.put("reqGreaterThanZero", "Amount must be greater than 0!");
langMap.put("reqNotAQuestName", "<quest> is not a Quest name!");
langMap.put("reqItemCleared", "Item requirements cleared.");
@ -673,7 +579,6 @@ public class Lang {
langMap.put("reqHeroesNotSecondary", "The <class> class is not secondary!");
langMap.put("reqHeroesSecondaryCleared", "Heroes Secondary Class requirement cleared.");
langMap.put("reqHeroesClassNotFound", "Class not found!");
langMap.put("reqNone", "No requirements set");
langMap.put("reqNotANumber", "<input> is not a number!");
langMap.put("reqMustAddItem", "You must add at least one item first!");
@ -681,8 +586,7 @@ public class Lang {
langMap.put("reqNoMcMMO", "mcMMO not installed");
langMap.put("reqNoHeroes", "Heroes not installed");
//
//Rewards Prompt
// Rewards Prompt
langMap.put("rewSetMoney", "Set money reward");
langMap.put("rewSetQuestPoints", "Set Quest Points reward");
langMap.put("rewSetItems", "Set item rewards");
@ -695,7 +599,6 @@ public class Lang {
langMap.put("rewSetCustom", "Set Custom Rewards");
langMap.put("rewSetHeroesClasses", "Set classes");
langMap.put("rewSetHeroesAmounts", "Set experience amounts");
langMap.put("rewMoneyPrompt", "Enter amount of <money>, or 0 to clear the money reward, or -1 to cancel");
langMap.put("rewExperiencePrompt", "Enter amount of experience, or 0 to clear the experience reward, or -1 to cancel");
langMap.put("rewCommandPrompt", "Enter command rewards separating each one by a <comma>, or enter \'clear\' to clear the list, or enter \'cancel\' to return.");
@ -708,7 +611,6 @@ public class Lang {
langMap.put("rewHeroesExperiencePrompt", "Enter experience amounts (numbers, decimals are allowed) separating each one by a space, or enter 'cancel' to return.");
langMap.put("rewPhatLootsPrompt", "Enter PhatLoots separating each one by a space, or enter 'clear' to clear the list, or 'cancel' to return.");
langMap.put("rewCustomRewardPrompt", "Enter the name of a custom reward to add, or enter \'clear\' to clear all custom rewards, or \'cancel\' to return.");
langMap.put("rewItemsCleared", "Item rewards cleared.");
langMap.put("rewNoMcMMOSkills", "No skills set");
langMap.put("rewNoHeroesClasses", "No classes set");
@ -724,11 +626,9 @@ public class Lang {
langMap.put("rewCustomAlreadyAdded", "That custom reward has already been added!");
langMap.put("rewCustomNotFound", "Custom reward module not found.");
langMap.put("rewCustomCleared", "Custom rewards cleared.");
langMap.put("rewNoPhat", "PhatLoots not installed");
//
//Item Prompt
// Item Prompt
langMap.put("itemCreateLoadHand", "Load item in hand");
langMap.put("itemCreateSetName", "Set name");
langMap.put("itemCreateSetAmount", "Set amount");
@ -736,7 +636,6 @@ public class Lang {
langMap.put("itemCreateSetEnchs", "Add/clear enchantments");
langMap.put("itemCreateSetDisplay", "Set display name");
langMap.put("itemCreateSetLore", "Set lore");
langMap.put("itemCreateEnterName", "Enter an item name, or 'cancel' to return.");
langMap.put("itemCreateEnterAmount", "Enter item amount (max. 64), or 'cancel' to return.");
langMap.put("itemCreateEnterDurab", "Enter item durability, or 'clear' to clear the data, or 'cancel' to return.");
@ -744,7 +643,6 @@ public class Lang {
langMap.put("itemCreateEnterLevel", "Enter a level (number) for <enchantment>");
langMap.put("itemCreateEnterDisplay", "Enter item display name, or 'clear' to clear the display name, or 'cancel' to return.");
langMap.put("itemCreateEnterLore", "Enter item lore, separating each line by a semi-colon ; or 'clear' to clear the lore, or 'cancel' to return.");
langMap.put("itemCreateLoaded", "Item loaded.");
langMap.put("itemCreateNoItem", "No item in hand!");
langMap.put("itemCreateNoName", "You must set a name first!");
@ -755,19 +653,15 @@ public class Lang {
langMap.put("itemCreateInvalidLevel", "Level must be greater than 0!");
langMap.put("itemCreateInvalidInput", "Invalid input!");
langMap.put("itemCreateNotNumber", "Input was not a number!");
langMap.put("itemCreateNoNameAmount", "You must set a name and amount first!");
langMap.put("itemCreateCriticalError", "A critical error has occurred.");
//
//Titles
// Titles
langMap.put("questTitle", "-- <quest> --");
langMap.put("questObjectivesTitle", "---(<quest>)---");
langMap.put("questCompleteTitle", "**QUEST COMPLETE: <quest>**");
langMap.put("questRewardsTitle", "Rewards:");
langMap.put("journalTitle", "Quest Journal");
langMap.put("questsTitle", "- Quests -");
langMap.put("questHelpTitle", "- Quests -");
langMap.put("questListTitle", "- Quests -");
@ -799,10 +693,8 @@ public class Lang {
langMap.put("topQuestersTitle", "- Top <number> Questers -");
langMap.put("createItemTitle", "- Create Item -");
langMap.put("enchantmentsTitle", "- Enchantments -");
langMap.put("questGUITitle", "- GUI Item Display -");
langMap.put("questRegionTitle", "- Quest Region -");
langMap.put("eventEditorGiveItemsTitle", "- Give Items -");
langMap.put("eventEditorEffectsTitle", "- Effects -");
langMap.put("eventEditorStormTitle", "- Event Storm -");
@ -812,11 +704,9 @@ public class Lang {
langMap.put("eventEditorAddMobTypesTitle", "- Add Mob -");
langMap.put("eventEditorPotionEffectsTitle", "- Event Potion Effects -");
langMap.put("eventEditorPotionTypesTitle", "- Event Potion Types -");
langMap.put("eventEditorWorldsTitle", "- Worlds -");
//
//Effects
// Effects
langMap.put("effBlazeShoot", "Sound of a Blaze firing");
langMap.put("effBowFire", "Sound of a bow firing");
langMap.put("effClick1", "A click sound");
@ -828,24 +718,21 @@ public class Lang {
langMap.put("effZombieWood", "Sound of a Zombie chewing an iron door");
langMap.put("effZombieIron", "Sound of a Zombie chewing a wooden door");
langMap.put("effEnterName", "Enter an effect name to add it to the list, or enter 'cancel' to return");
//
//Inputs
// Inputs
langMap.put("cmdCancel", "cancel");
langMap.put("cmdAdd", "add");
langMap.put("cmdClear", "clear");
langMap.put("cmdNone", "none");
langMap.put("cmdDone", "done");
//
//User end
// User end
langMap.put("acceptQuest", "Accept Quest?");
langMap.put("enterAnOption", "Enter an option");
langMap.put("questAccepted", "Quest accepted: <quest>");
langMap.put("currentQuest", "Current Quests:");
langMap.put("noMoreQuest", "No more quests available.");
//Objectives
// Objectives
langMap.put("damage", "Damage");
langMap.put("break", "Break");
langMap.put("place", "Place");
@ -861,10 +748,8 @@ public class Lang {
langMap.put("tame", "Tame");
langMap.put("shearSheep", "Shear <color> sheep");
langMap.put("goTo", "Go to <location>");
langMap.put("completed", "Completed");
//
langMap.put("invalidSelection", "Invalid selection!");
langMap.put("noActiveQuest", "You do not currently have any active Quests.");
langMap.put("speakTo", "Start: Speak to <npc>");
@ -877,16 +762,13 @@ public class Lang {
langMap.put("cannotComplete", "Cannot complete <quest>");
langMap.put("questNotFound", "Quest not found.");
langMap.put("alreadyConversing", "You already are in a conversation!");
langMap.put("inputNum", "Input must be a number.");
langMap.put("inputPosNum", "Input must be a positive number.");
langMap.put("killNotValid", "Kill did not count. You must wait <time> before you can kill <player> again.");
langMap.put("questModified", "Your active Quest <quest> has been modified. You have been forced to quit the Quest.");
langMap.put("questNotExist", "Your active Quest <quest> no longer exists. You have been forced to quit the Quest.");
langMap.put("questInvalidChoice", "Invalid choice. Type \'Yes\' or \'No\'");
langMap.put("questPointsDisplay", "Quest points:");
langMap.put("questNoDrop", "You may not drop Quest items.");
langMap.put("questNoBrew", "You may not brew Quest items.");
langMap.put("questNoStore", "You may not store Quest items.");
@ -895,31 +777,22 @@ public class Lang {
langMap.put("questNoDispense", "You may not put Quest items in dispensers.");
langMap.put("questNoEnchant", "You may not enchant Quest items.");
langMap.put("questNoSmelt", "You may not smelt using Quest items.");
langMap.put("questInfoNoPerms", "You do not have permission to view a Quest's information.");
langMap.put("questCmdNoPerms", "You do not have access to that command.");
langMap.put("pageSelectionNum", "Page selection must be a number.");
langMap.put("pageSelectionPosNum", "Page selection must be a positive number.");
langMap.put("questListNoPerms", "You do not have permission to view the Quests list.");
langMap.put("questTakeNoPerms", "You do not have permission to take Quests via commands.");
langMap.put("questTakeDisabled", "Taking Quests via commands has been disabled.");
langMap.put("questQuit", "You have quit <quest>");
langMap.put("questQuitNoPerms", "You do not have permission to quit Quests.");
langMap.put("questQuitDisabled", "Quitting Quests has been disabled.");
langMap.put("questEditorNoPerms", "You do not have permission to use the Quests Editor.");
langMap.put("eventEditorNoPerms", "You do not have permission to use the Events Editor.");
langMap.put("questsUnknownCommand", "Unknown Quests command. Type /quests for help.");
langMap.put("pageNotExist", "Page does not exist.");
langMap.put("pageFooter", "- Page <current> of <all> -");
//Admin
// Admin
langMap.put("questsReloaded", "Quests reloaded.");
langMap.put("numQuestsLoaded", "<number> Quests loaded.");
langMap.put("questForceTake", "<player> has forcibly started the Quest <quest>.");
@ -935,17 +808,14 @@ public class Lang {
langMap.put("questRemoved", "Quest <quest> has been removed from player <player>'s completed Quests.");
langMap.put("settingAllQuestPoints", "Setting all players' Quest Points...");
langMap.put("allQuestPointsSet", "All players' Quest Points have been set to <number>!");
langMap.put("setQuestPoints", "<player>'s Quest Points have been set to <number>.");
langMap.put("questPointsSet", "<player> has set your Quest Points to <number>.");
langMap.put("takeQuestPoints", "Took away <number> Quest Points from <player>.");
langMap.put("questPointsTaken", "<player> took away <number> Quest Points.");
langMap.put("giveQuestPoints", "Gave <number> Quest Points from <player>.");
langMap.put("questPointsGiven", "<player> gave you <number> Quest Points.");
langMap.put("enableNPCGUI", "<npc> will now provide a GUI Quest Display.");
langMap.put("disableNPCGUI", "<npc> will no longer provide a GUI Quest Display.");
langMap.put("invalidNumber", "Invalid number.");
langMap.put("noCurrentQuest", "<player> does not currently have any active Quests.");
langMap.put("playerNotFound", "Player not found.");
@ -957,7 +827,6 @@ public class Lang {
langMap.put("questsPlayerHasQuestAlready", "<player> is already on the Quest <quest>!");
langMap.put("questsUnknownAdminCommand", "Unknown Questsadmin command. Type /questsadmin for help.");
langMap.put("unknownError", "An unknown error occurred. See console output.");
langMap.put("journalTaken", "You take out your Quest Journal.");
langMap.put("journalPutAway", "You put away your Quest Journal.");
langMap.put("journalAlreadyHave", "You already have your Quest Journal out.");
@ -965,9 +834,8 @@ public class Lang {
langMap.put("journalNoQuests", "You have no accepted quests!");
langMap.put("journalDenied", "You cannot do that with your Quest Journal.");
//
//
//Enchantments
// Enchantments
langMap.put("ENCHANTMENT_ARROW_DAMAGE", "Power");
langMap.put("ENCHANTMENT_ARROW_FIRE", "Flame");
langMap.put("ENCHANTMENT_ARROW_INFINITE", "Infinity");
@ -995,8 +863,7 @@ public class Lang {
langMap.put("ENCHANTMENT_SILK_TOUCH", "SilkTouch");
langMap.put("ENCHANTMENT_THORNS", "Thorns");
langMap.put("ENCHANTMENT_WATER_WORKER", "AquaAffinity");
//Colors
// Colors
langMap.put("COLOR_BLACK", "Black");
langMap.put("COLOR_BLUE", "Blue");
langMap.put("COLOR_BROWN", "Brown");
@ -1013,8 +880,7 @@ public class Lang {
langMap.put("COLOR_SILVER", "Silver");
langMap.put("COLOR_WHITE", "White");
langMap.put("COLOR_YELLOW", "Yellow");
//Time
// Time
langMap.put("timeDay", "Day");
langMap.put("timeDays", "Days");
langMap.put("timeHour", "Hour");
@ -1025,8 +891,7 @@ public class Lang {
langMap.put("timeSeconds", "Seconds");
langMap.put("timeMillisecond", "Millisecond");
langMap.put("timeMilliseconds", "Milliseconds");
//Misc
// Misc
langMap.put("event", "Event");
langMap.put("delay", "Delay");
langMap.put("save", "Save");
@ -1072,135 +937,89 @@ public class Lang {
langMap.put("to", "to");
langMap.put("blocksWithin", "within <amount> blocks of");
langMap.put("valRequired", "Value required");
langMap.put("enchantedItem", "*Enchanted*");
langMap.put("experience", "Experience");
//
//Error Messages
// Error Messages
langMap.put("questErrorReadingFile", "Error reading Quests file.");
langMap.put("questSaveError", "An error occurred while saving.");
langMap.put("questBlacklisted", "You are blacklisted. Contact an admin if this is in error.");
//
File file = new File(plugin.getDataFolder(), "/lang/" + lang + ".yml");
YamlConfiguration langFile = YamlConfiguration.loadConfiguration(file);
for (Entry<String, Object> e : langFile.getValues(true).entrySet()) {
langMap.put(e.getKey(), (String) e.getValue());
}
}
public void saveNewLang() {
FileConfiguration data = new YamlConfiguration();
File dir = new File(plugin.getDataFolder(), "/lang");
File file = new File(plugin.getDataFolder(), "/lang/en.yml");
for (Entry<String, String> e : langMap.entrySet()) {
data.set(e.getKey(), e.getValue());
}
try {
if (dir.exists() == false || dir.isDirectory() == false) {
dir.mkdir();
}
PrintWriter out = new PrintWriter(file);
for (String key : data.getKeys(false)) {
out.println(key + ": \"" + data.getString(key) + "\"");
}
out.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
public void loadLang() {
File langFile = new File(plugin.getDataFolder(), "/lang/" + lang + ".yml");
boolean newLangs = false;
if (langFile.exists()) {
LinkedHashMap<String, String> tempMap = new LinkedHashMap<String, String>();
LinkedHashMap<String, String> toPut = new LinkedHashMap<String, String>();
LinkedHashMap<String, String> newMap = new LinkedHashMap<String, String>();
FileConfiguration config = new YamlConfiguration();
try {
config.load(langFile);
for (String key : config.getKeys(false)) {
tempMap.put(key, config.getString(key));
}
for (Entry<String, String> entry : langMap.entrySet()) {
if (tempMap.containsKey(entry.getKey())) {
toPut.put(entry.getKey(), tempMap.get(entry.getKey()));
} else {
newLangs = true;
newMap.put(entry.getKey(), entry.getValue());
}
}
langMap.putAll(toPut);
if (newLangs) {
File file = new File(plugin.getDataFolder(), "/lang/" + lang + "_new.yml");
if (file.exists()) {
file.delete();
}
FileConfiguration config2 = new YamlConfiguration();
try {
for (Entry<String, String> entry : newMap.entrySet()) {
config2.set(entry.getKey(), entry.getValue());
}
config2.save(file);
} catch (Exception e) {
plugin.getLogger().severe("An error occurred while trying to dump new language phrases. Operation aborted. Error log:");
e.printStackTrace();
return;
}
plugin.getLogger().info("There are new language phrases with the current version. They have been stored in /lang/"+ lang + "_new.yml");
plugin.getLogger().info("There are new language phrases with the current version. They have been stored in /lang/" + lang + "_new.yml");
}
} catch (Exception e) {
plugin.getLogger().severe("There was an error reading the language file: /lang/" + lang + ".yml");
plugin.getLogger().severe("Language loading aborted. Error log:");
e.printStackTrace();
}
} else {
plugin.getLogger().severe("Attempted to load language file: /lang/" + lang + ".yml but the file was not found. Using default language EN");
}
}
@ -1209,7 +1028,6 @@ public class Lang {
Map<String, String> tokenMap = new HashMap<String, String>();
public void initTokens() {
tokenMap.put("%br%", "\n");
tokenMap.put("%tab%", "\t");
tokenMap.put("%rtr%", "\r");
@ -1235,20 +1053,14 @@ public class Lang {
tokenMap.put("%red%", ChatColor.RED.toString());
tokenMap.put("%darkred%", ChatColor.DARK_RED.toString());
tokenMap.put("%yellow%", ChatColor.YELLOW.toString());
}
public String convertString(String s) {
for (String token : tokenMap.keySet()) {
s = s.replace(token, tokenMap.get(token));
s = s.replace(token.toUpperCase(), tokenMap.get(token));
}
return s;
}
}
}

View File

@ -8,40 +8,31 @@ import org.bukkit.entity.EntityType;
public class MiscUtil {
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;
}
//Time: 7d 24h 5m 10s 20ms
// Time: 7d 24h 5m 10s 20ms
public static long getTimeFromString(String string) {
//if it returns -1 then the string is incorrect.
// if it returns -1 then the string is incorrect.
long timeMilliSeconds = -1;
//replace 2 or more spaces with one space.
// 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")) {
@ -54,79 +45,57 @@ public class MiscUtil {
timeMilliSeconds += t;
}
}
//To balance the -1 at the beginning.
// 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;
@ -135,14 +104,9 @@ public class MiscUtil {
line += piece + wordDelimiter;
currentLength += piece.length() + 1;
}
}
if(line.equals("") == false)
if (line.equals("") == false)
toReturn.add(lineColor + line);
return toReturn;
}
}

View File

@ -1,5 +1,4 @@
package me.blackvein.quests.util;
import me.blackvein.quests.Quests;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -9,6 +8,8 @@ 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;
@ -25,7 +26,6 @@ public class QuestMob {
}
public QuestMob() {
}
public void setSpawnLocation(Location spawnLocation) {
@ -87,21 +87,15 @@ public class QuestMob {
@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{
try {
eq.setItemInHand(inventory[0]);
eq.setBoots(inventory[1]);
eq.setLeggings(inventory[2]);
@ -111,7 +105,6 @@ public class QuestMob {
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]);
}
@ -127,7 +120,6 @@ public class QuestMob {
if (dropChances[4] != null) {
eq.setHelmetDropChance(dropChances[4]);
}
}
}
@ -143,44 +135,36 @@ public class QuestMob {
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-")) {
@ -212,9 +196,7 @@ public class QuestMob {
} 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;
@ -232,9 +214,7 @@ public class QuestMob {
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;
@ -243,15 +223,12 @@ public class QuestMob {
} 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) {
@ -261,15 +238,12 @@ public class QuestMob {
} else {
return false;
}
if (!spawnAmounts.equals(other.spawnAmounts)) {
return false;
}
if (!spawnLocation.equals(other.spawnLocation)) {
return false;
}
return true;
}
}

View File

@ -0,0 +1,5 @@
/**
* Store the particle effect enums, these are used to support multiple versions
* of NMS.
*/
package me.blackvein.particles;

View File

@ -0,0 +1,5 @@
/**
* Contains all the custom classes extending exception that are used within the
* Quests plugin.
*/
package me.blackvein.quests.exceptions;