Continued UUID Conversion (Needs testing)

Updated for 1.7.9.10
This commit is contained in:
Blackvein 2014-07-14 22:57:21 -07:00
parent bd711ce14c
commit 75ab54a82e
19 changed files with 470 additions and 244 deletions

13
pom.xml
View File

@ -25,16 +25,23 @@
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>craftbukkit1</artifactId> <artifactId>craftbukkit1</artifactId>
<version>1.7.10-R0.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/craftbukkit-1.7.10-R0.1.jar</systemPath>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit3</artifactId>
<version>1.7.9-R0.3</version> <version>1.7.9-R0.3</version>
<scope>system</scope> <scope>system</scope>
<systemPath>${project.basedir}/lib/craftbukkit-1.7.2-R0.4.jar</systemPath> <systemPath>${project.basedir}/lib/craftbukkit-1.7.9-R0.3.jar</systemPath>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>craftbukkit2</artifactId> <artifactId>craftbukkit2</artifactId>
<version>1.7.9-R0.3</version> <version>1.7.2-R0.4</version>
<scope>system</scope> <scope>system</scope>
<systemPath>${project.basedir}/lib/craftbukkit-1.7.9-R0.3.jar</systemPath> <systemPath>${project.basedir}/lib/craftbukkit-1.7.2-R0.4.jar</systemPath>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.citizensnpcs</groupId> <groupId>com.citizensnpcs</groupId>

View File

@ -0,0 +1,68 @@
package me.blackvein.particles;
import me.blackvein.quests.util.ReflectionUtil;
import net.minecraft.server.v1_7_R4.PacketPlayOutWorldParticles;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
public enum Eff_1_7_R4 {
HUGE_EXPLOSION("hugeexplosion"),
LARGE_EXPLODE("largeexplode"),
FIREWORKS_SPARK("fireworksSpark"),
BUBBLE("bubble"),
SUSPEND("susgpend"),
DEPTH_SUSPEND("depthSuspend"),
TOWN_AURA("townaura"),
CRIT("crit"),
MAGIC_CRIT("magicCrit"),
MOB_SPELL("mobSpell"),
MOB_SPELL_AMBIENT("mobSpellAmbient"),
SPELL("spell"),
INSTANT_SPELL("instantSpell"),
WITCH_MAGIC("witchMagic"),
NOTE("note"),
PORTAL("portal"),
ENCHANTMENT_TABLE("enchantmenttable"),
EXPLODE("explode"),
FLAME("flame"),
LAVA("lava"),
FOOTSTEP("footstep"),
SPLASH("splash"),
LARGE_SMOKE("largesmoke"),
CLOUD("cloud"),
RED_DUST("reddust"),
SNOWBALL_POOF("snowballpoof"),
DRIP_WATER("dripWater"),
DRIP_LAVA("dripLava"),
SNOW_SHOVEL("snowshovel"),
SLIME("slime"),
HEART("heart"),
ANGRY_VILLAGER("angryVillager"),
HAPPY_VILLAGER("happyVillager"),
ICONCRACK("iconcrack_"),
TILECRACK("tilecrack_");
private final String particleName;
Eff_1_7_R4(String particleName) {
this.particleName = particleName;
}
public void sendToPlayer(Player player, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count) throws Exception {
PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles();
ReflectionUtil.setValue(packet, "a", particleName);
ReflectionUtil.setValue(packet, "b", (float) location.getX());
ReflectionUtil.setValue(packet, "c", (float) location.getY());
ReflectionUtil.setValue(packet, "d", (float) location.getZ());
ReflectionUtil.setValue(packet, "e", offsetX);
ReflectionUtil.setValue(packet, "f", offsetY);
ReflectionUtil.setValue(packet, "g", offsetZ);
ReflectionUtil.setValue(packet, "h", speed);
ReflectionUtil.setValue(packet, "i", count);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}

View File

@ -83,7 +83,7 @@ public abstract class CustomObjective implements Listener {
public Map<String, Object> getDatamap(Player player, CustomObjective obj){ public Map<String, Object> getDatamap(Player player, CustomObjective obj){
Quester quester = Quests.getInstance().getQuester(player.getName()); Quester quester = Quests.getInstance().getQuester(player.getUniqueId());
if(quester != null){ if(quester != null){
int index = -1; int index = -1;
@ -114,7 +114,7 @@ public abstract class CustomObjective implements Listener {
public static void incrementObjective(Player player, CustomObjective obj, int count){ public static void incrementObjective(Player player, CustomObjective obj, int count){
Quester quester = Quests.getInstance().getQuester(player.getName()); Quester quester = Quests.getInstance().getQuester(player.getUniqueId());
if(quester != null){ if(quester != null){
//Check if the player has Quest with objective //Check if the player has Quest with objective
@ -134,9 +134,9 @@ public abstract class CustomObjective implements Listener {
if(quester.customObjectiveCounts.containsKey(obj.getName())){ if(quester.customObjectiveCounts.containsKey(obj.getName())){
int old = quester.customObjectiveCounts.get(obj.getName()); int old = quester.customObjectiveCounts.get(obj.getName());
Quests.getInstance().getQuester(player.getName()).customObjectiveCounts.put(obj.getName(), old + count); Quests.getInstance().getQuester(player.getUniqueId()).customObjectiveCounts.put(obj.getName(), old + count);
}else{ }else{
Quests.getInstance().getQuester(player.getName()).customObjectiveCounts.put(obj.getName(), count); Quests.getInstance().getQuester(player.getUniqueId()).customObjectiveCounts.put(obj.getName(), count);
} }
int index = -1; int index = -1;

View File

@ -250,8 +250,7 @@ public class Event {
if (commands.isEmpty() == false) { if (commands.isEmpty() == false) {
for (String s : commands) { for (String s : commands) {
quester.plugin.getServer().dispatchCommand(quester.plugin.getServer().getConsoleSender(), s.replaceAll("<player>", quester.name)); quester.plugin.getServer().dispatchCommand(quester.plugin.getServer().getConsoleSender(), s.replaceAll("<player>", quester.getPlayer().getName()));
} }
} }

View File

@ -3,6 +3,7 @@ package me.blackvein.quests;
import me.blackvein.particles.Eff_1_7_R3; import me.blackvein.particles.Eff_1_7_R3;
import java.util.List; import java.util.List;
import me.blackvein.particles.Eff_1_7_R1; import me.blackvein.particles.Eff_1_7_R1;
import me.blackvein.particles.Eff_1_7_R4;
import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.npc.NPC;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@ -24,7 +25,7 @@ public class NpcEffectThread implements Runnable{
for(Player player : plugin.getServer().getOnlinePlayers()){ for(Player player : plugin.getServer().getOnlinePlayers()){
Quester quester = plugin.getQuester(player.getName()); Quester quester = plugin.getQuester(player.getUniqueId());
List<Entity> nearby = player.getNearbyEntities(32.0, 32.0, 32.0); List<Entity> nearby = player.getNearbyEntities(32.0, 32.0, 32.0);
if(nearby.isEmpty() == false){ if(nearby.isEmpty() == false){
@ -54,6 +55,118 @@ public class NpcEffectThread implements Runnable{
showEffect_R1(player, npc); showEffect_R1(player, npc);
else if(Bukkit.getVersion().contains("1.7.9")) else if(Bukkit.getVersion().contains("1.7.9"))
showEffect_R3(player, npc); showEffect_R3(player, npc);
else if(Bukkit.getVersion().contains("1.7.10"))
showEffect_R4(player, npc);
}
private static void showEffect_R4(Player player, NPC npc){
if(Quests.effect.equalsIgnoreCase("enchant")){
try{
Eff_1_7_R4.ENCHANTMENT_TABLE.sendToPlayer(player, npc.getBukkitEntity().getEyeLocation(), 0, 1, 0, 1, 10);
}catch(Exception e){
e.printStackTrace();
}
} else if(Quests.effect.equalsIgnoreCase("crit")){
try{
Eff_1_7_R4.CRIT.sendToPlayer(player, npc.getBukkitEntity().getEyeLocation(), 0, 0, 0, (float)0.35, 3);
}catch(Exception e){
e.printStackTrace();
}
} else if(Quests.effect.equalsIgnoreCase("spell")){
try{
Eff_1_7_R4.INSTANT_SPELL.sendToPlayer(player, npc.getBukkitEntity().getEyeLocation(), 0, 0, 0, 1, 3);
}catch(Exception e){
e.printStackTrace();
}
} else if(Quests.effect.equalsIgnoreCase("magiccrit")){
try{
Eff_1_7_R4.MAGIC_CRIT.sendToPlayer(player, npc.getBukkitEntity().getEyeLocation(), 0, 0, 0, (float)0.35, 3);
}catch(Exception e){
e.printStackTrace();
}
} else if(Quests.effect.equalsIgnoreCase("mobspell")){
try{
Eff_1_7_R4.MOB_SPELL.sendToPlayer(player, npc.getBukkitEntity().getEyeLocation(), 0, 0, 0, 1, 3);
}catch(Exception e){
e.printStackTrace();
}
} else if(Quests.effect.equalsIgnoreCase("note")){
try{
Location old = npc.getBukkitEntity().getEyeLocation();
Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float)0.5, old.getZ());
Eff_1_7_R4.NOTE.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1);
}catch(Exception e){
e.printStackTrace();
}
} else if(Quests.effect.equalsIgnoreCase("portal")){
try{
Eff_1_7_R4.PORTAL.sendToPlayer(player, npc.getBukkitEntity().getEyeLocation(), 0, 0, 0, 1, 5);
}catch(Exception e){
e.printStackTrace();
}
} else if(Quests.effect.equalsIgnoreCase("dust")){
try{
Location old = npc.getBukkitEntity().getEyeLocation();
Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float)0.5, old.getZ());
Eff_1_7_R4.RED_DUST.sendToPlayer(player, newLoc, 0, 0, 0, 1, 1);
}catch(Exception e){
e.printStackTrace();
}
} else if(Quests.effect.equalsIgnoreCase("witch")){
try{
Eff_1_7_R4.WITCH_MAGIC.sendToPlayer(player, npc.getBukkitEntity().getEyeLocation(), 0, 0, 0, 1, 3);
}catch(Exception e){
e.printStackTrace();
}
} else if(Quests.effect.equalsIgnoreCase("snowball")){
try{
Location old = npc.getBukkitEntity().getEyeLocation();
Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float)0.5, old.getZ());
Eff_1_7_R4.SNOWBALL_POOF.sendToPlayer(player, newLoc, 0, 0, 0, 1, 3);
}catch(Exception e){
e.printStackTrace();
}
} else if(Quests.effect.equalsIgnoreCase("splash")){
try{
Location old = npc.getBukkitEntity().getEyeLocation();
Location newLoc = new Location(player.getWorld(), old.getX(), old.getY() + (float)0.5, old.getZ());
Eff_1_7_R4.SPLASH.sendToPlayer(player, newLoc, 0, 0, 0, 1, 4);
}catch(Exception e){
e.printStackTrace();
}
} else if(Quests.effect.equalsIgnoreCase("smoke")){
try{
Eff_1_7_R4.TOWN_AURA.sendToPlayer(player, npc.getBukkitEntity().getEyeLocation(), 0, 1, 0, 1, 20);
}catch(Exception e){
e.printStackTrace();
}
}
} }

View File

@ -42,7 +42,7 @@ public class NpcListener implements Listener {
if (evt.getClicker().isConversing() == false) { if (evt.getClicker().isConversing() == false) {
final Player player = evt.getClicker(); final Player player = evt.getClicker();
final Quester quester = plugin.getQuester(player.getName()); final Quester quester = plugin.getQuester(player.getUniqueId());
boolean delivery = false; boolean delivery = false;
if (quester.hasObjective("deliverItem") && player.getItemInHand() != null) { if (quester.hasObjective("deliverItem") && player.getItemInHand() != null) {
@ -217,7 +217,7 @@ public class NpcListener implements Listener {
if (okay) { if (okay) {
Quester quester = plugin.getQuester(player.getName()); Quester quester = plugin.getQuester(player.getUniqueId());
if (quester.hasObjective("killNPC")) { if (quester.hasObjective("killNPC")) {
quester.killNPC(evt.getNPC()); quester.killNPC(evt.getNPC());
} }
@ -238,7 +238,7 @@ public class NpcListener implements Listener {
if (okay) { if (okay) {
Player player = (Player) damager; Player player = (Player) damager;
Quester quester = plugin.getQuester(player.getName()); Quester quester = plugin.getQuester(player.getUniqueId());
if (quester.hasObjective("killNPC")) { if (quester.hasObjective("killNPC")) {
quester.killNPC(evt.getNPC()); quester.killNPC(evt.getNPC());
} }

View File

@ -48,7 +48,7 @@ public class PlayerListener implements Listener, ColorUtil {
if (evt.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { if (evt.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
final Quester quester = plugin.getQuester(evt.getPlayer().getName()); final Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
final Player player = evt.getPlayer(); final Player player = evt.getPlayer();
if (quester.hasObjective("useBlock")) { if (quester.hasObjective("useBlock")) {
@ -179,7 +179,7 @@ public class PlayerListener implements Listener, ColorUtil {
@EventHandler @EventHandler
public void onInventoryClick(InventoryClickEvent evt) { public void onInventoryClick(InventoryClickEvent evt) {
Quester quester = plugin.getQuester(evt.getWhoClicked().getName()); Quester quester = plugin.getQuester(evt.getWhoClicked().getUniqueId());
Player player = (Player) evt.getWhoClicked(); Player player = (Player) evt.getWhoClicked();
if (evt.getInventory().getTitle().equals("Quests")) { if (evt.getInventory().getTitle().equals("Quests")) {
@ -267,7 +267,7 @@ public class PlayerListener implements Listener, ColorUtil {
if (plugin.checkQuester(evt.getPlayer().getName()) == false) { if (plugin.checkQuester(evt.getPlayer().getName()) == false) {
Quester quester = plugin.getQuester(evt.getPlayer().getName()); Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
if (quester.currentStage != null) { if (quester.currentStage != null) {
@ -308,7 +308,7 @@ public class PlayerListener implements Listener, ColorUtil {
if (plugin.checkQuester(evt.getPlayer().getName()) == false) { if (plugin.checkQuester(evt.getPlayer().getName()) == false) {
Quester quester = plugin.getQuester(evt.getPlayer().getName()); Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
if (quester.hasObjective("damageBlock")) { if (quester.hasObjective("damageBlock")) {
quester.damageBlock(evt.getBlock().getType()); quester.damageBlock(evt.getBlock().getType());
@ -324,7 +324,7 @@ public class PlayerListener implements Listener, ColorUtil {
if (plugin.checkQuester(evt.getPlayer().getName()) == false) { if (plugin.checkQuester(evt.getPlayer().getName()) == false) {
Quester quester = plugin.getQuester(evt.getPlayer().getName()); Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
if (quester.hasObjective("placeBlock")) { if (quester.hasObjective("placeBlock")) {
if (evt.isCancelled() == false) { if (evt.isCancelled() == false) {
@ -342,7 +342,7 @@ public class PlayerListener implements Listener, ColorUtil {
if (plugin.checkQuester(evt.getPlayer().getName()) == false) { if (plugin.checkQuester(evt.getPlayer().getName()) == false) {
Quester quester = plugin.getQuester(evt.getPlayer().getName()); Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
if (quester.hasObjective("breakBlock")) { if (quester.hasObjective("breakBlock")) {
if (evt.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH) == false && evt.isCancelled() == false) { if (evt.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH) == false && evt.isCancelled() == false) {
@ -382,7 +382,7 @@ public class PlayerListener implements Listener, ColorUtil {
if (plugin.checkQuester(evt.getPlayer().getName()) == false) { if (plugin.checkQuester(evt.getPlayer().getName()) == false) {
Quester quester = plugin.getQuester(evt.getPlayer().getName()); Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
if (evt.getEntity().getType().equals(EntityType.SHEEP) && quester.hasObjective("shearSheep")) { if (evt.getEntity().getType().equals(EntityType.SHEEP) && quester.hasObjective("shearSheep")) {
Sheep sheep = (Sheep) evt.getEntity(); Sheep sheep = (Sheep) evt.getEntity();
@ -402,7 +402,7 @@ public class PlayerListener implements Listener, ColorUtil {
Player p = (Player) evt.getOwner(); Player p = (Player) evt.getOwner();
if (plugin.checkQuester(p.getName()) == false) { if (plugin.checkQuester(p.getName()) == false) {
Quester quester = plugin.getQuester(p.getName()); Quester quester = plugin.getQuester(p.getUniqueId());
if (quester.hasObjective("tameMob")) { if (quester.hasObjective("tameMob")) {
quester.tameMob(evt.getEntityType()); quester.tameMob(evt.getEntityType());
@ -420,7 +420,7 @@ public class PlayerListener implements Listener, ColorUtil {
if (plugin.checkQuester(evt.getEnchanter().getName()) == false) { if (plugin.checkQuester(evt.getEnchanter().getName()) == false) {
Quester quester = plugin.getQuester(evt.getEnchanter().getName()); Quester quester = plugin.getQuester(evt.getEnchanter().getUniqueId());
if (quester.hasObjective("enchantItem")) { if (quester.hasObjective("enchantItem")) {
for (Enchantment e : evt.getEnchantsToAdd().keySet()) { for (Enchantment e : evt.getEnchantsToAdd().keySet()) {
@ -533,7 +533,7 @@ public class PlayerListener implements Listener, ColorUtil {
if (okay) { if (okay) {
Quester quester = plugin.getQuester(player.getName()); Quester quester = plugin.getQuester(player.getUniqueId());
if (quester.hasObjective("killMob")) { if (quester.hasObjective("killMob")) {
quester.killMob(evt.getEntity().getLocation(), evt.getEntity().getType()); quester.killMob(evt.getEntity().getLocation(), evt.getEntity().getType());
@ -555,7 +555,7 @@ public class PlayerListener implements Listener, ColorUtil {
if (okay) { if (okay) {
Player player = (Player) damager; Player player = (Player) damager;
Quester quester = plugin.getQuester(player.getName()); Quester quester = plugin.getQuester(player.getUniqueId());
if (quester.hasObjective("killMob")) { if (quester.hasObjective("killMob")) {
quester.killMob(evt.getEntity().getLocation(), evt.getEntity().getType()); quester.killMob(evt.getEntity().getLocation(), evt.getEntity().getType());
} }
@ -600,7 +600,7 @@ public class PlayerListener implements Listener, ColorUtil {
if (okay) { if (okay) {
Quester quester = plugin.getQuester(player.getName()); Quester quester = plugin.getQuester(player.getUniqueId());
if (quester.hasObjective("killPlayer")) { if (quester.hasObjective("killPlayer")) {
quester.killPlayer(evt.getEntity().getName()); quester.killPlayer(evt.getEntity().getName());
@ -630,7 +630,7 @@ public class PlayerListener implements Listener, ColorUtil {
if (okay) { if (okay) {
Quester quester = plugin.getQuester(player.getName()); Quester quester = plugin.getQuester(player.getUniqueId());
if (quester.hasObjective("killPlayer")) { if (quester.hasObjective("killPlayer")) {
quester.killPlayer(evt.getEntity().getName()); quester.killPlayer(evt.getEntity().getName());
} }
@ -647,7 +647,7 @@ public class PlayerListener implements Listener, ColorUtil {
Player player = evt.getEntity(); Player player = evt.getEntity();
if (plugin.checkQuester(player.getName()) == false) { if (plugin.checkQuester(player.getName()) == false) {
Quester quester = plugin.getQuester(player.getName()); Quester quester = plugin.getQuester(player.getUniqueId());
if(quester.currentStage != null){ if(quester.currentStage != null){
if(quester.currentStage.deathEvent != null){ if(quester.currentStage.deathEvent != null){
quester.currentStage.deathEvent.fire(quester); quester.currentStage.deathEvent.fire(quester);
@ -664,7 +664,7 @@ public class PlayerListener implements Listener, ColorUtil {
Player player = evt.getPlayer(); Player player = evt.getPlayer();
if (plugin.checkQuester(player.getName()) == false) { if (plugin.checkQuester(player.getName()) == false) {
Quester quester = plugin.getQuester(player.getName()); Quester quester = plugin.getQuester(player.getUniqueId());
if (quester.hasObjective("catchFish") && evt.getState().equals(State.CAUGHT_FISH)) { if (quester.hasObjective("catchFish") && evt.getState().equals(State.CAUGHT_FISH)) {
quester.catchFish(); quester.catchFish();
} }
@ -676,17 +676,19 @@ public class PlayerListener implements Listener, ColorUtil {
@EventHandler @EventHandler
public void onPlayerJoin(PlayerJoinEvent evt) { public void onPlayerJoin(PlayerJoinEvent evt) {
System.out.println("Joined: " + evt.getPlayer().getUniqueId());
if (plugin.checkQuester(evt.getPlayer().getName()) == false) { if (plugin.checkQuester(evt.getPlayer().getName()) == false) {
Quester quester = new Quester(plugin); Quester quester = new Quester(plugin);
quester.name = evt.getPlayer().getName(); quester.id = evt.getPlayer().getUniqueId();
if (new File(plugin.getDataFolder(), "data/" + quester.name + ".yml").exists()) { if (new File(plugin.getDataFolder(), "data/" + quester.id + ".yml").exists()) {
quester.loadData(); quester.loadData();
} else if (Quests.genFilesOnJoin) { } else if (Quests.genFilesOnJoin) {
quester.saveData(); quester.saveData();
} }
plugin.questers.put(evt.getPlayer().getName(), quester); plugin.questers.put(evt.getPlayer().getUniqueId(), quester);
for (String s : quester.completedQuests) { for (String s : quester.completedQuests) {
@ -723,7 +725,7 @@ public class PlayerListener implements Listener, ColorUtil {
if (plugin.checkQuester(evt.getPlayer().getName()) == false) { if (plugin.checkQuester(evt.getPlayer().getName()) == false) {
Quester quester = plugin.getQuester(evt.getPlayer().getName()); Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
if (quester.currentQuest != null) { if (quester.currentQuest != null) {
if (quester.currentStage.delay > -1) { if (quester.currentStage.delay > -1) {
@ -742,7 +744,7 @@ public class PlayerListener implements Listener, ColorUtil {
if(plugin.questFactory.selectingNPCs.contains(evt.getPlayer())) if(plugin.questFactory.selectingNPCs.contains(evt.getPlayer()))
plugin.questFactory.selectingNPCs.remove(evt.getPlayer()); plugin.questFactory.selectingNPCs.remove(evt.getPlayer());
plugin.questers.remove(quester.name); plugin.questers.remove(quester.id);
} }
@ -762,7 +764,7 @@ public class PlayerListener implements Listener, ColorUtil {
if (isPlayer) { if (isPlayer) {
Quester quester = plugin.getQuester(evt.getPlayer().getName()); Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
if (quester.hasObjective("reachLocation")) { if (quester.hasObjective("reachLocation")) {

View File

@ -167,7 +167,7 @@ public class Quest {
public boolean testRequirements(Player player) { public boolean testRequirements(Player player) {
Quester quester = plugin.getQuester(player.getName()); Quester quester = plugin.getQuester(player.getUniqueId());
if (moneyReq != 0 && Quests.economy.getBalance(player.getName()) < moneyReq) { if (moneyReq != 0 && Quests.economy.getBalance(player.getName()) < moneyReq) {
return false; return false;
@ -269,7 +269,7 @@ public class Quest {
public void completeQuest(Quester q) { public void completeQuest(Quester q) {
Player player = plugin.getServer().getPlayerExact(q.name); Player player = plugin.getServer().getPlayer(q.id);
q.resetObjectives(); q.resetObjectives();
q.completedQuests.add(name); q.completedQuests.add(name);
String none = ChatColor.GRAY + "- (" + Lang.get("none") + ")"; String none = ChatColor.GRAY + "- (" + Lang.get("none") + ")";
@ -281,7 +281,7 @@ public class Quest {
} }
if (moneyReward > 0 && Quests.economy != null) { if (moneyReward > 0 && Quests.economy != null) {
Quests.economy.depositPlayer(q.name, moneyReward); Quests.economy.depositPlayer(q.getOfflinePlayer(), moneyReward);
none = null; none = null;
} }
if (redoDelay > -1) { if (redoDelay > -1) {
@ -511,7 +511,7 @@ public class Quest {
public void failQuest(Quester q) { public void failQuest(Quester q) {
Player player = plugin.getServer().getPlayerExact(q.name); Player player = plugin.getServer().getPlayer(q.id);
q.resetObjectives(); q.resetObjectives();
String title = Lang.get("questTitle"); String title = Lang.get("questTitle");

View File

@ -15,6 +15,7 @@ import org.bukkit.ChatColor;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@ -29,7 +30,7 @@ import org.bukkit.potion.Potion;
public class Quester { public class Quester {
String name; UUID id;
boolean editorMode = false; boolean editorMode = false;
boolean holdingQuestItemFromStorage = false; boolean holdingQuestItemFromStorage = false;
boolean delayOver = true; boolean delayOver = true;
@ -80,13 +81,19 @@ public class Quester {
public Player getPlayer() { public Player getPlayer() {
return plugin.getServer().getPlayerExact(name); return Bukkit.getServer().getPlayer(id);
}
public OfflinePlayer getOfflinePlayer() {
return Bukkit.getServer().getOfflinePlayer(id);
} }
public void takeQuest(Quest q, boolean override) { public void takeQuest(Quest q, boolean override) {
Player player = plugin.getServer().getPlayer(name); Player player = getPlayer();
if (q.testRequirements(player) == true || override) { if (q.testRequirements(player) == true || override) {
@ -97,7 +104,7 @@ public class Quester {
if (!override) { if (!override) {
if (q.moneyReq > 0) { if (q.moneyReq > 0) {
Quests.economy.withdrawPlayer(name, q.moneyReq); Quests.economy.withdrawPlayer(getOfflinePlayer(), q.moneyReq);
} }
for (ItemStack is : q.items) { for (ItemStack is : q.items) {
@ -893,7 +900,7 @@ public class Quester {
String error = Lang.get("killNotValid"); String error = Lang.get("killNotValid");
error = error.replaceAll("<time>", ChatColor.DARK_PURPLE + Quests.getTime(comparator - (currentTime - killTime)) + ChatColor.RED); error = error.replaceAll("<time>", ChatColor.DARK_PURPLE + Quests.getTime(comparator - (currentTime - killTime)) + ChatColor.RED);
error = error.replaceAll("<player>", ChatColor.DARK_PURPLE + player + ChatColor.RED); error = error.replaceAll("<player>", ChatColor.DARK_PURPLE + player + ChatColor.RED);
plugin.getServer().getPlayer(name).sendMessage(ChatColor.RED + error); getPlayer().sendMessage(ChatColor.RED + error);
return; return;
} }
@ -1002,7 +1009,7 @@ public class Quester {
public void deliverItem(ItemStack i) { public void deliverItem(ItemStack i) {
Player player = plugin.getServer().getPlayer(name); Player player = getPlayer();
ItemStack found = null; ItemStack found = null;
@ -1084,7 +1091,7 @@ public class Quester {
public void finishObjective(String objective, Material material, ItemStack itemstack, Enchantment enchantment, EntityType mob, String player, NPC npc, Location location, DyeColor color, String pass, CustomObjective co) { public void finishObjective(String objective, Material material, ItemStack itemstack, Enchantment enchantment, EntityType mob, String player, NPC npc, Location location, DyeColor color, String pass, CustomObjective co) {
Player p = plugin.getServer().getPlayerExact(name); Player p = getPlayer();
if (currentStage.objectiveOverride != null) { if (currentStage.objectiveOverride != null) {
@ -1643,7 +1650,7 @@ public class Quester {
FileConfiguration data = getBaseData(); FileConfiguration data = getBaseData();
try { try {
data.save(new File(plugin.getDataFolder(), "data/" + name + ".yml")); data.save(new File(plugin.getDataFolder(), "data/" + id + ".yml"));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -2072,7 +2079,17 @@ public class Quester {
FileConfiguration data = new YamlConfiguration(); FileConfiguration data = new YamlConfiguration();
try { try {
data.load(new File(plugin.getDataFolder(), "data/" + name + ".yml"));
File dataFile = new File(plugin.getDataFolder(), "data/" + id.toString() + ".yml");
if(dataFile.exists() == false) {
OfflinePlayer p = getOfflinePlayer();
dataFile = new File(plugin.getDataFolder(), "data/" + p.getName() + ".yml");
if(dataFile.exists() == false)
return false;
}
data.load(dataFile);
} catch (IOException e) { } catch (IOException e) {
return false; return false;
} catch (InvalidConfigurationException e) { } catch (InvalidConfigurationException e) {
@ -2168,7 +2185,7 @@ public class Quester {
if (stage == null) { if (stage == null) {
currentQuest = quest; currentQuest = quest;
currentQuest.completeQuest(this); currentQuest.completeQuest(this);
Quests.log.log(Level.SEVERE, "[Quests] Invalid stage for player: \"" + name + "\". Quest ended."); Quests.log.log(Level.SEVERE, "[Quests] Invalid stage for player: \"" + id + "\". Quest ended.");
return true; return true;
} }
@ -2521,7 +2538,7 @@ public class Quester {
} else { } else {
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new StageTimer(plugin, this), (long) (currentStage.delay * 0.02)); plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new StageTimer(plugin, this), (long) (currentStage.delay * 0.02));
if (currentStage.delayMessage != null) { if (currentStage.delayMessage != null) {
plugin.getServer().getPlayer(name).sendMessage(Quests.parseString((currentStage.delayMessage), currentQuest)); plugin.getServer().getPlayer(id).sendMessage(Quests.parseString((currentStage.delayMessage), currentQuest));
} }
} }
@ -2581,10 +2598,10 @@ public class Quester {
currentStage = null; currentStage = null;
currentStageIndex = 0; currentStageIndex = 0;
resetObjectives(); resetObjectives();
if (plugin.getServer().getPlayer(name) != null) { if (plugin.getServer().getPlayer(id) != null) {
String error = Lang.get("questModified"); String error = Lang.get("questModified");
error = error.replaceAll("<quest>", ChatColor.DARK_PURPLE + currentQuest.name + ChatColor.RED); error = error.replaceAll("<quest>", ChatColor.DARK_PURPLE + currentQuest.name + ChatColor.RED);
plugin.getServer().getPlayer(name).sendMessage(ChatColor.GOLD + "[Quests] " + ChatColor.RED + error); plugin.getServer().getPlayer(id).sendMessage(ChatColor.GOLD + "[Quests] " + ChatColor.RED + error);
} }
currentQuest = null; currentQuest = null;
@ -2601,10 +2618,10 @@ public class Quester {
currentStage = null; currentStage = null;
currentStageIndex = 0; currentStageIndex = 0;
resetObjectives(); resetObjectives();
if (plugin.getServer().getPlayer(name) != null) { if (plugin.getServer().getPlayer(id) != null) {
String error = Lang.get("questNotExist"); String error = Lang.get("questNotExist");
error = error.replaceAll("<quest>", ChatColor.DARK_PURPLE + currentQuest.name + ChatColor.RED); error = error.replaceAll("<quest>", ChatColor.DARK_PURPLE + currentQuest.name + ChatColor.RED);
plugin.getServer().getPlayer(name).sendMessage(ChatColor.GOLD + "[Quests] " + ChatColor.RED + error); plugin.getServer().getPlayer(id).sendMessage(ChatColor.GOLD + "[Quests] " + ChatColor.RED + error);
} }
currentQuest = null; currentQuest = null;

View File

@ -91,6 +91,7 @@ import java.util.Enumeration;
import java.util.UUID; import java.util.UUID;
import java.util.jar.JarEntry; import java.util.jar.JarEntry;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import org.bukkit.command.ConsoleCommandSender;
public class Quests extends JavaPlugin implements ConversationAbandonedListener, ColorUtil { public class Quests extends JavaPlugin implements ConversationAbandonedListener, ColorUtil {
@ -110,7 +111,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
public static int acceptTimeout = 20; public static int acceptTimeout = 20;
public static int inviteTimeout = 20; public static int inviteTimeout = 20;
public static String effect = "note"; public static String effect = "note";
public final Map<String, Quester> questers = new HashMap<String, Quester>(); public final Map<UUID, Quester> questers = new HashMap<UUID, Quester>();
public final List<String> questerBlacklist = new LinkedList<String>(); public final List<String> questerBlacklist = new LinkedList<String>();
public final List<CustomRequirement> customRequirements = new LinkedList<CustomRequirement>(); public final List<CustomRequirement> customRequirements = new LinkedList<CustomRequirement>();
public final List<CustomReward> customRewards = new LinkedList<CustomReward>(); public final List<CustomReward> customRewards = new LinkedList<CustomReward>();
@ -347,7 +348,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
printInfo("[Quests] Saving Quester data."); printInfo("[Quests] Saving Quester data.");
for (Player p : getServer().getOnlinePlayers()) { for (Player p : getServer().getOnlinePlayers()) {
Quester quester = getQuester(p.getName()); Quester quester = getQuester(p.getUniqueId());
quester.saveData(); quester.saveData();
} }
@ -367,7 +368,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
if (abandonedEvent.getContext().getForWhom() != null) { if (abandonedEvent.getContext().getForWhom() != null) {
try { try {
abandonedEvent.getContext().getForWhom().sendRawMessage(YELLOW + "Cancelled."); abandonedEvent.getContext().getForWhom().sendRawMessage(YELLOW + Lang.get("questTimeout"));
} catch (Exception e) { } catch (Exception e) {
} }
@ -397,7 +398,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
if (s.equalsIgnoreCase(Lang.get("yesWord"))) { if (s.equalsIgnoreCase(Lang.get("yesWord"))) {
getQuester(player.getName()).takeQuest(getQuest(getQuester(player.getName()).questToTake), false); getQuester(player.getUniqueId()).takeQuest(getQuest(getQuester(player.getUniqueId()).questToTake), false);
return Prompt.END_OF_CONVERSATION; return Prompt.END_OF_CONVERSATION;
} else if (s.equalsIgnoreCase(Lang.get("noWord"))) { } else if (s.equalsIgnoreCase(Lang.get("noWord"))) {
@ -819,22 +820,20 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
points = Integer.parseInt(args[2]); points = Integer.parseInt(args[2]);
Quester quester = getQuester(target.getName()); Quester quester = getQuester(target.getUniqueId());
quester.questPoints += Math.abs(points); quester.questPoints += Math.abs(points);
String msg1 = Lang.get("giveQuestPoints"); String msg1 = Lang.get("giveQuestPoints");
msg1 = msg1.replaceAll("<player>", GREEN + target.getName() + GOLD); msg1 = msg1.replaceAll("<player>", GREEN + target.getName() + GOLD);
msg1 = msg1.replaceAll("<quest>", PURPLE + quester.currentQuest.name + GOLD); msg1 = msg1.replaceAll("<number>", PURPLE + "" + points + GOLD);
cs.sendMessage(GOLD + msg1); cs.sendMessage(GOLD + msg1);
String msg2 = Lang.get("questPointsGiven"); String msg2 = Lang.get("questPointsGiven");
msg2 = msg2.replaceAll("<player>", GREEN + cs.getName() + GOLD); msg2 = msg2.replaceAll("<player>", GREEN + cs.getName() + GOLD);
msg2 = msg2.replaceAll("<quest>", PURPLE + quester.currentQuest.name + GOLD); msg2 = msg2.replaceAll("<number>", PURPLE + "" + points + GOLD);
target.sendMessage(GREEN + msg2); target.sendMessage(GREEN + msg2);
quester.saveData(); quester.saveData();
return;
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
cs.sendMessage(YELLOW + Lang.get("inputNum")); cs.sendMessage(YELLOW + Lang.get("inputNum"));
@ -882,16 +881,17 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
return; return;
} }
Quester quester = getQuester(target.getName()); Quester quester = getQuester(target.getUniqueId());
quester.questPoints -= Math.abs(points); quester.questPoints -= Math.abs(points);
String msg1 = Lang.get("takeQuestPoints"); String msg1 = Lang.get("takeQuestPoints");
msg1 = msg1.replaceAll("<player>", GREEN + target.getName() + GOLD); msg1 = msg1.replaceAll("<player>", GREEN + target.getName() + GOLD);
msg1 = msg1.replaceAll("<quest>", PURPLE + quester.currentQuest.name + GOLD); msg1 = msg1.replaceAll("<number>", PURPLE + "" + points + GOLD);
cs.sendMessage(GOLD + msg1); cs.sendMessage(GOLD + msg1);
String msg2 = Lang.get("questPointsTaken"); String msg2 = Lang.get("questPointsTaken");
msg2 = msg2.replaceAll("<player>", GREEN + cs.getName() + GOLD); msg2 = msg2.replaceAll("<player>", GREEN + cs.getName() + GOLD);
msg2 = msg2.replaceAll("<quest>", PURPLE + quester.currentQuest.name + GOLD); msg2 = msg2.replaceAll("<number>", PURPLE + "" + points + GOLD);
target.sendMessage(GREEN + msg2); target.sendMessage(GREEN + msg2);
quester.saveData(); quester.saveData();
@ -938,16 +938,16 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
Quester quester = getQuester(target.getName()); Quester quester = getQuester(target.getUniqueId());
quester.questPoints = points; quester.questPoints = points;
String msg1 = Lang.get("setQuestPoints"); String msg1 = Lang.get("setQuestPoints");
msg1 = msg1.replaceAll("<player>", GREEN + target.getName() + GOLD); msg1 = msg1.replaceAll("<player>", GREEN + target.getName() + GOLD);
msg1 = msg1.replaceAll("<quest>", PURPLE + quester.currentQuest.name + GOLD); msg1 = msg1.replaceAll("<number>", PURPLE + "" + points + GOLD);
cs.sendMessage(GOLD + msg1); cs.sendMessage(GOLD + msg1);
String msg2 = Lang.get("questPointsSet"); String msg2 = Lang.get("questPointsSet");
msg2 = msg2.replaceAll("<player>", GREEN + cs.getName() + GOLD); msg2 = msg2.replaceAll("<player>", GREEN + cs.getName() + GOLD);
msg2 = msg2.replaceAll("<quest>", PURPLE + quester.currentQuest.name + GOLD); msg2 = msg2.replaceAll("<number>", PURPLE + "" + points + GOLD);
target.sendMessage(GREEN + msg2); target.sendMessage(GREEN + msg2);
quester.saveData(); quester.saveData();
@ -1028,16 +1028,16 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} else { } else {
Quester quester = getQuester(target.getName()); Quester quester = getQuester(target.getUniqueId());
quester.resetObjectives(); quester.resetObjectives();
String msg1 = Lang.get("questForceTake"); String msg1 = Lang.get("questForceTake");
msg1 = msg1.replaceAll("<player>", GREEN + target.getName() + GOLD); msg1 = msg1.replaceAll("<player>", GREEN + target.getName() + GOLD);
msg1 = msg1.replaceAll("<quest>", PURPLE + quester.currentQuest.name + GOLD); msg1 = msg1.replaceAll("<quest>", PURPLE + (quester.currentQuest == null ? Lang.get("none") : quester.currentQuest.name)+ GOLD);
cs.sendMessage(GOLD + msg1); cs.sendMessage(GOLD + msg1);
String msg2 = Lang.get("questForcedTake"); String msg2 = Lang.get("questForcedTake");
msg2 = msg2.replaceAll("<player>", GREEN + cs.getName() + GOLD); msg2 = msg2.replaceAll("<player>", GREEN + cs.getName() + GOLD);
msg2 = msg2.replaceAll("<quest>", PURPLE + quester.currentQuest.name + GOLD); msg2 = msg2.replaceAll("<quest>", PURPLE + (quester.currentQuest == null ? Lang.get("none") : quester.currentQuest.name)+ GOLD);
target.sendMessage(GREEN + msg2); target.sendMessage(GREEN + msg2);
quester.takeQuest(questToGive, true); quester.takeQuest(questToGive, true);
@ -1170,7 +1170,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} else { } else {
Quester quester = getQuester(target.getName()); Quester quester = getQuester(target.getUniqueId());
if (quester.currentQuest == null) { if (quester.currentQuest == null) {
String msg = Lang.get("noCurrentQuest"); String msg = Lang.get("noCurrentQuest");
@ -1181,11 +1181,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
String msg1 = Lang.get("questForceFinish"); String msg1 = Lang.get("questForceFinish");
msg1 = msg1.replaceAll("<player>", GREEN + target.getName() + GOLD); msg1 = msg1.replaceAll("<player>", GREEN + target.getName() + GOLD);
msg1 = msg1.replaceAll("<quest>", PURPLE + quester.currentQuest.name + GOLD); msg1 = msg1.replaceAll("<quest>", PURPLE + (quester.currentQuest == null ? Lang.get("none") : quester.currentQuest.name)+ GOLD);
cs.sendMessage(GOLD + msg1); cs.sendMessage(GOLD + msg1);
String msg2 = Lang.get("questForcedFinish"); String msg2 = Lang.get("questForcedFinish");
msg2 = msg2.replaceAll("<player>", GREEN + cs.getName() + GOLD); msg2 = msg2.replaceAll("<player>", GREEN + cs.getName() + GOLD);
msg2 = msg2.replaceAll("<quest>", PURPLE + quester.currentQuest.name + GOLD); msg2 = msg2.replaceAll("<quest>", PURPLE + (quester.currentQuest == null ? Lang.get("none") : quester.currentQuest.name)+ GOLD);
target.sendMessage(GREEN + msg2); target.sendMessage(GREEN + msg2);
quester.currentQuest.completeQuest(quester); quester.currentQuest.completeQuest(quester);
@ -1245,7 +1245,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} else { } else {
Quester quester = getQuester(target.getName()); Quester quester = getQuester(target.getUniqueId());
if (quester.currentQuest == null) { if (quester.currentQuest == null) {
String msg = Lang.get("noCurrentQuest"); String msg = Lang.get("noCurrentQuest");
@ -1295,7 +1295,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} else { } else {
Quester quester = getQuester(target.getName()); Quester quester = getQuester(target.getUniqueId());
if (quester.currentQuest == null) { if (quester.currentQuest == null) {
String msg = Lang.get("noCurrentQuest"); String msg = Lang.get("noCurrentQuest");
@ -1306,11 +1306,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
String msg1 = Lang.get("questForceNextStage"); String msg1 = Lang.get("questForceNextStage");
msg1 = msg1.replaceAll("<player>", GREEN + target.getName() + GOLD); msg1 = msg1.replaceAll("<player>", GREEN + target.getName() + GOLD);
msg1 = msg1.replaceAll("<quest>", PURPLE + quester.currentQuest.name + GOLD); msg1 = msg1.replaceAll("<quest>", PURPLE + (quester.currentQuest == null ? Lang.get("none") : quester.currentQuest.name)+ GOLD);
cs.sendMessage(GOLD + msg1); cs.sendMessage(GOLD + msg1);
String msg2 = Lang.get("questForcedNextStage"); String msg2 = Lang.get("questForcedNextStage");
msg2 = msg2.replaceAll("<player>", GREEN + cs.getName() + GOLD); msg2 = msg2.replaceAll("<player>", GREEN + cs.getName() + GOLD);
msg2 = msg2.replaceAll("<quest>", PURPLE + quester.currentQuest.name + GOLD); msg2 = msg2.replaceAll("<quest>", PURPLE + (quester.currentQuest == null ? Lang.get("none") : quester.currentQuest.name)+ GOLD);
target.sendMessage(GREEN + msg2); target.sendMessage(GREEN + msg2);
quester.currentQuest.nextStage(quester); quester.currentQuest.nextStage(quester);
@ -1347,7 +1347,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} else { } else {
Quester quester = getQuester(target.getName()); Quester quester = getQuester(target.getUniqueId());
if (quester.currentQuest == null) { if (quester.currentQuest == null) {
String msg = Lang.get("noCurrentQuest"); String msg = Lang.get("noCurrentQuest");
@ -1361,11 +1361,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
quester.currentStageIndex = 0; quester.currentStageIndex = 0;
String msg1 = Lang.get("questForceQuit"); String msg1 = Lang.get("questForceQuit");
msg1 = msg1.replaceAll("<player>", GREEN + target.getName() + GOLD); msg1 = msg1.replaceAll("<player>", GREEN + target.getName() + GOLD);
msg1 = msg1.replaceAll("<quest>", PURPLE + quester.currentQuest.name + GOLD); msg1 = msg1.replaceAll("<quest>", PURPLE + (quester.currentQuest == null ? Lang.get("none") : quester.currentQuest.name)+ GOLD);
cs.sendMessage(GOLD + msg1); cs.sendMessage(GOLD + msg1);
String msg2 = Lang.get("questForcedQuit"); String msg2 = Lang.get("questForcedQuit");
msg2 = msg2.replaceAll("<player>", GREEN + cs.getName() + GOLD); msg2 = msg2.replaceAll("<player>", GREEN + cs.getName() + GOLD);
msg2 = msg2.replaceAll("<quest>", PURPLE + quester.currentQuest.name + GOLD); msg2 = msg2.replaceAll("<quest>", PURPLE + (quester.currentQuest == null ? Lang.get("none") : quester.currentQuest.name)+ GOLD);
target.sendMessage(GREEN + msg2); target.sendMessage(GREEN + msg2);
quester.currentQuest = null; quester.currentQuest = null;
@ -1397,15 +1397,15 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_TAKE"))) { } else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_TAKE"))) {
questsTake(cs, args); questsTake((Player) cs, args);
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUIT"))) { } else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_QUIT"))) {
questsQuit(cs); questsQuit((Player) cs);
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_STATS"))) { } else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_STATS"))) {
questsStats(cs); questsStats((Player)cs);
} else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_TOP"))) { } else if (args[0].equalsIgnoreCase(Lang.get("COMMAND_TOP"))) {
@ -1432,6 +1432,26 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
} else if (args.length == 1) {
if (args[0].equalsIgnoreCase("convert")) {
if(cs instanceof ConsoleCommandSender) {
convertQuesters();
}else {
cs.sendMessage(YELLOW + Lang.get("questsUnknownCommand"));
return true;
}
} else {
cs.sendMessage(YELLOW + "This command may only be performed in-game.");
return true;
}
} else { } else {
cs.sendMessage(YELLOW + "This command may only be performed in-game."); cs.sendMessage(YELLOW + "This command may only be performed in-game.");
@ -1542,14 +1562,14 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
return true; return true;
} }
private void questsStats(final CommandSender cs) { private void questsStats(final Player player) {
Quester quester = getQuester(cs.getName()); Quester quester = getQuester(player.getUniqueId());
cs.sendMessage(GOLD + "- " + cs.getName() + " -"); player.sendMessage(GOLD + "- " + player.getName() + " -");
cs.sendMessage(YELLOW + Lang.get("questPointsDisplay") + " " + PURPLE + quester.questPoints + "/" + totalQuestPoints); player.sendMessage(YELLOW + Lang.get("questPointsDisplay") + " " + PURPLE + quester.questPoints + "/" + totalQuestPoints);
if (quester.currentQuest == null) { if (quester.currentQuest == null) {
cs.sendMessage(YELLOW + Lang.get("currentQuest") + " " + PURPLE + Lang.get("none")); player.sendMessage(YELLOW + Lang.get("currentQuest") + " " + PURPLE + Lang.get("none"));
} else { } else {
cs.sendMessage(YELLOW + Lang.get("currentQuest") + " " + PURPLE + quester.currentQuest.name); player.sendMessage(YELLOW + Lang.get("currentQuest") + " " + PURPLE + quester.currentQuest.name);
} }
String completed; String completed;
@ -1575,16 +1595,16 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
cs.sendMessage(YELLOW + Lang.get("completedQuestsTitle")); player.sendMessage(YELLOW + Lang.get("completedQuestsTitle"));
cs.sendMessage(completed); player.sendMessage(completed);
} }
private boolean questsQuit(final CommandSender cs) { private boolean questsQuit(final Player player) {
if (allowQuitting == true) { if (allowQuitting == true) {
if (((Player) cs).hasPermission("quests.quit")) { if (((Player) player).hasPermission("quests.quit")) {
Quester quester = getQuester(cs.getName()); Quester quester = getQuester(player.getUniqueId());
if (quester.currentQuest != null) { if (quester.currentQuest != null) {
quester.resetObjectives(); quester.resetObjectives();
@ -1592,7 +1612,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
quester.currentStageIndex = 0; quester.currentStageIndex = 0;
String msg = Lang.get("questQuit"); String msg = Lang.get("questQuit");
msg = msg.replaceAll("<quest>", PURPLE + quester.currentQuest.name + YELLOW); msg = msg.replaceAll("<quest>", PURPLE + quester.currentQuest.name + YELLOW);
cs.sendMessage(YELLOW + msg); player.sendMessage(YELLOW + msg);
quester.currentQuest = null; quester.currentQuest = null;
quester.saveData(); quester.saveData();
quester.loadData(); quester.loadData();
@ -1600,34 +1620,33 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} else { } else {
cs.sendMessage(YELLOW + Lang.get("noActiveQuest")); player.sendMessage(YELLOW + Lang.get("noActiveQuest"));
return true; return true;
} }
} else { } else {
cs.sendMessage(RED + Lang.get("questQuitNoPerms")); player.sendMessage(RED + Lang.get("questQuitNoPerms"));
return true; return true;
} }
} else { } else {
cs.sendMessage(YELLOW + Lang.get("questQuitDisabled")); player.sendMessage(YELLOW + Lang.get("questQuitDisabled"));
return true; return true;
} }
} }
private void questsTake(final CommandSender cs, String[] args) { private void questsTake(final Player player, String[] args) {
if (allowCommands == true) { if (allowCommands == true) {
if (((Player) cs).hasPermission("quests.take")) { if (((Player) player).hasPermission("quests.take")) {
if (args.length == 1) { if (args.length == 1) {
cs.sendMessage(YELLOW + Lang.get("COMMAND_TAKE_USAGE")); player.sendMessage(YELLOW + Lang.get("COMMAND_TAKE_USAGE"));
return;
} else { } else {
@ -1672,40 +1691,40 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
if (questToFind != null) { if (questToFind != null) {
final Quest quest = questToFind; final Quest q = questToFind;
final Quester quester = getQuester(cs.getName()); final Quester quester = getQuester(player.getUniqueId());
if (quester.currentQuest != null) { if (quester.currentQuest != null) {
cs.sendMessage(YELLOW + Lang.get("questOneActive")); player.sendMessage(YELLOW + Lang.get("questOneActive"));
} else if (quester.completedQuests.contains(quest.name) && quest.redoDelay < 0) { } else if (quester.completedQuests.contains(q.name) && q.redoDelay < 0) {
String msg = Lang.get("questAlreadyCompleted"); String msg = Lang.get("questAlreadyCompleted");
msg = msg.replaceAll("<quest>", PURPLE + quest.name + YELLOW); msg = msg.replaceAll("<quest>", PURPLE + q.name + YELLOW);
cs.sendMessage(YELLOW + msg); player.sendMessage(YELLOW + msg);
} else if (quest.npcStart != null && allowCommandsForNpcQuests == false) { } else if (q.npcStart != null && allowCommandsForNpcQuests == false) {
String msg = Lang.get("mustSpeakTo"); String msg = Lang.get("mustSpeakTo");
msg = msg.replaceAll("<npc>", PURPLE + quest.npcStart.getName() + YELLOW); msg = msg.replaceAll("<npc>", PURPLE + q.npcStart.getName() + YELLOW);
cs.sendMessage(YELLOW + msg); player.sendMessage(YELLOW + msg);
} else if (quest.blockStart != null) { } else if (q.blockStart != null) {
String msg = Lang.get("noCommandStart"); String msg = Lang.get("noCommandStart");
msg = msg.replaceAll("<quest>", PURPLE + quest.name + YELLOW); msg = msg.replaceAll("<quest>", PURPLE + q.name + YELLOW);
cs.sendMessage(YELLOW + msg); player.sendMessage(YELLOW + msg);
} else { } else {
boolean takeable = true; boolean takeable = true;
if (quester.completedQuests.contains(quest.name)) { if (quester.completedQuests.contains(q.name)) {
if (quester.getDifference(quest) > 0) { if (quester.getDifference(q) > 0) {
String early = Lang.get("questTooEarly"); String early = Lang.get("questTooEarly");
early = early.replaceAll("<quest>", ChatColor.AQUA + quest.name + ChatColor.YELLOW); early = early.replaceAll("<quest>", ChatColor.AQUA + q.name + ChatColor.YELLOW);
early = early.replaceAll("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(quest)) + ChatColor.YELLOW); early = early.replaceAll("<time>", ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(q)) + ChatColor.YELLOW);
cs.sendMessage(YELLOW + early); player.sendMessage(YELLOW + early);
takeable = false; takeable = false;
} }
} }
if (quest.region != null) { if (q.region != null) {
boolean inRegion = false; boolean inRegion = false;
Player p = quester.getPlayer(); Player p = quester.getPlayer();
@ -1713,7 +1732,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
Iterator<ProtectedRegion> it = rm.getApplicableRegions(p.getLocation()).iterator(); Iterator<ProtectedRegion> it = rm.getApplicableRegions(p.getLocation()).iterator();
while (it.hasNext()) { while (it.hasNext()) {
ProtectedRegion pr = it.next(); ProtectedRegion pr = it.next();
if (pr.getId().equalsIgnoreCase(quest.region)) { if (pr.getId().equalsIgnoreCase(q.region)) {
inRegion = true; inRegion = true;
break; break;
} }
@ -1721,8 +1740,8 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
if (inRegion == false) { if (inRegion == false) {
String msg = Lang.get("questInvalidLocation"); String msg = Lang.get("questInvalidLocation");
msg = msg.replaceAll("<quest>", AQUA + quest.name + YELLOW); msg = msg.replaceAll("<quest>", AQUA + q.name + YELLOW);
cs.sendMessage(YELLOW + msg); player.sendMessage(YELLOW + msg);
takeable = false; takeable = false;
} }
@ -1730,11 +1749,11 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
if (takeable == true) { if (takeable == true) {
if (cs instanceof Conversable) { if (player instanceof Conversable) {
if (((Player) cs).isConversing() == false) { if (((Player) player).isConversing() == false) {
quester.questToTake = quest.name; quester.questToTake = q.name;
String s String s
= GOLD + "- " + PURPLE + quester.questToTake + GOLD + " -\n" = GOLD + "- " + PURPLE + quester.questToTake + GOLD + " -\n"
@ -1742,20 +1761,17 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
+ RESET + getQuest(quester.questToTake).description + "\n"; + RESET + getQuest(quester.questToTake).description + "\n";
for (String msg : s.split("<br>")) { for (String msg : s.split("<br>")) {
cs.sendMessage(msg); player.sendMessage(msg);
} }
conversationFactory.buildConversation((Conversable) cs).begin(); conversationFactory.buildConversation((Conversable) player).begin();
} else { } else {
cs.sendMessage(YELLOW + Lang.get("alreadyConversing")); player.sendMessage(YELLOW + Lang.get("alreadyConversing"));
} }
return;
} else { } else {
return;
} }
} }
@ -1763,23 +1779,20 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
} else { } else {
cs.sendMessage(YELLOW + Lang.get("questNotFound")); player.sendMessage(YELLOW + Lang.get("questNotFound"));
return;
} }
} }
} else { } else {
cs.sendMessage(RED + Lang.get("questTakeNoPerms")); player.sendMessage(RED + Lang.get("questTakeNoPerms"));
return;
} }
} else { } else {
cs.sendMessage(YELLOW + Lang.get("questTakeDisabled")); player.sendMessage(YELLOW + Lang.get("questTakeDisabled"));
return;
} }
} }
@ -1811,14 +1824,12 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
listQuests((Player) cs, page); listQuests((Player) cs, page);
return;
} }
} else { } else {
cs.sendMessage(RED + Lang.get("questListNoPerms")); cs.sendMessage(RED + Lang.get("questListNoPerms"));
return;
} }
} }
@ -1842,7 +1853,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
if (args.length == 0) { if (args.length == 0) {
showObjectives(cs); showObjectives((Player) cs);
} else { } else {
@ -1890,32 +1901,32 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
} }
Quest quest = findQuest(name); Quest q = findQuest(name);
if (quest != null) { if (q != null) {
Player player = (Player) cs; Player player = (Player) cs;
Quester quester = getQuester(player.getName()); Quester quester = getQuester(player.getUniqueId());
cs.sendMessage(GOLD + "- " + quest.name + " -"); cs.sendMessage(GOLD + "- " + q.name + " -");
cs.sendMessage(" "); cs.sendMessage(" ");
if (quest.redoDelay > -1) { if (q.redoDelay > -1) {
if (quest.redoDelay == 0) { if (q.redoDelay == 0) {
cs.sendMessage(DARKAQUA + Lang.get("readoable")); cs.sendMessage(DARKAQUA + Lang.get("readoable"));
} else { } else {
String msg = Lang.get("redoableEvery"); String msg = Lang.get("redoableEvery");
msg = msg.replaceAll("<time>", AQUA + getTime(quest.redoDelay) + DARKAQUA); msg = msg.replaceAll("<time>", AQUA + getTime(q.redoDelay) + DARKAQUA);
cs.sendMessage(DARKAQUA + msg); cs.sendMessage(DARKAQUA + msg);
} }
} }
if (quest.npcStart != null) { if (q.npcStart != null) {
String msg = Lang.get("speakTo"); String msg = Lang.get("speakTo");
msg = msg.replaceAll("<npc>", quest.npcStart.getName()); msg = msg.replaceAll("<npc>", q.npcStart.getName());
cs.sendMessage(YELLOW + msg); cs.sendMessage(YELLOW + msg);
} else { } else {
cs.sendMessage(YELLOW + quest.description); cs.sendMessage(YELLOW + q.description);
} }
cs.sendMessage(" "); cs.sendMessage(" ");
@ -1924,9 +1935,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
cs.sendMessage(GOLD + Lang.get("requirements")); cs.sendMessage(GOLD + Lang.get("requirements"));
if (quest.permissionReqs.isEmpty() == false) { if (q.permissionReqs.isEmpty() == false) {
for (String perm : quest.permissionReqs) { for (String perm : q.permissionReqs) {
if (permission.has(player, perm)) { if (permission.has(player, perm)) {
cs.sendMessage(GREEN + Lang.get("permissionDisplay") + " " + perm); cs.sendMessage(GREEN + Lang.get("permissionDisplay") + " " + perm);
@ -1938,32 +1949,32 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
if (quest.heroesPrimaryClassReq != null) { if (q.heroesPrimaryClassReq != null) {
if (this.testPrimaryHeroesClass(quest.heroesPrimaryClassReq, player.getName())) { if (this.testPrimaryHeroesClass(q.heroesPrimaryClassReq, player.getName())) {
cs.sendMessage(BOLD + "" + GREEN + quest.heroesPrimaryClassReq + RESET + "" + DARKGREEN + " " + Lang.get("heroesClass")); cs.sendMessage(BOLD + "" + GREEN + q.heroesPrimaryClassReq + RESET + "" + DARKGREEN + " " + Lang.get("heroesClass"));
} else { } else {
cs.sendMessage(BOLD + "" + DARKRED + quest.heroesPrimaryClassReq + RESET + "" + RED + " " + Lang.get("heroesClass")); cs.sendMessage(BOLD + "" + DARKRED + q.heroesPrimaryClassReq + RESET + "" + RED + " " + Lang.get("heroesClass"));
} }
} }
if (quest.heroesSecondaryClassReq != null) { if (q.heroesSecondaryClassReq != null) {
if (this.testSecondaryHeroesClass(quest.heroesSecondaryClassReq, player.getName())) { if (this.testSecondaryHeroesClass(q.heroesSecondaryClassReq, player.getName())) {
cs.sendMessage(BOLD + "" + DARKRED + quest.heroesSecondaryClassReq + RESET + "" + RED + " " + Lang.get("heroesClass")); cs.sendMessage(BOLD + "" + DARKRED + q.heroesSecondaryClassReq + RESET + "" + RED + " " + Lang.get("heroesClass"));
} else { } else {
cs.sendMessage(BOLD + "" + GREEN + quest.heroesSecondaryClassReq + RESET + "" + DARKGREEN + " " + Lang.get("heroesClass")); cs.sendMessage(BOLD + "" + GREEN + q.heroesSecondaryClassReq + RESET + "" + DARKGREEN + " " + Lang.get("heroesClass"));
} }
} }
if (quest.mcMMOSkillReqs.isEmpty() == false) { if (q.mcMMOSkillReqs.isEmpty() == false) {
for (String skill : quest.mcMMOSkillReqs) { for (String skill : q.mcMMOSkillReqs) {
int level = Quests.getMCMMOSkillLevel(Quests.getMcMMOSkill(skill), player.getName()); int level = Quests.getMCMMOSkillLevel(Quests.getMcMMOSkill(skill), player.getName());
int req = quest.mcMMOAmountReqs.get(quest.mcMMOSkillReqs.indexOf(skill)); int req = q.mcMMOAmountReqs.get(q.mcMMOSkillReqs.indexOf(skill));
String skillName = MiscUtil.getCapitalized(skill); String skillName = MiscUtil.getCapitalized(skill);
if (level >= req) { if (level >= req) {
@ -1976,37 +1987,37 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
if (quest.questPointsReq != 0) { if (q.questPointsReq != 0) {
if (quester.questPoints >= quest.questPointsReq) { if (quester.questPoints >= q.questPointsReq) {
cs.sendMessage(GRAY + "- " + GREEN + quest.questPointsReq + " " + Lang.get("questPoints")); cs.sendMessage(GRAY + "- " + GREEN + q.questPointsReq + " " + Lang.get("questPoints"));
} else { } else {
cs.sendMessage(GRAY + "- " + RED + quest.questPointsReq + " " + Lang.get("questPoints")); cs.sendMessage(GRAY + "- " + RED + q.questPointsReq + " " + Lang.get("questPoints"));
} }
} }
if (quest.moneyReq != 0) { if (q.moneyReq != 0) {
if (economy.getBalance(quester.name) >= quest.moneyReq) { if (economy.getBalance(quester.getOfflinePlayer()) >= q.moneyReq) {
if (quest.moneyReq == 1) { if (q.moneyReq == 1) {
cs.sendMessage(GRAY + "- " + GREEN + quest.moneyReq + " " + Quests.getCurrency(false)); cs.sendMessage(GRAY + "- " + GREEN + q.moneyReq + " " + Quests.getCurrency(false));
} else { } else {
cs.sendMessage(GRAY + "- " + GREEN + quest.moneyReq + " " + Quests.getCurrency(true)); cs.sendMessage(GRAY + "- " + GREEN + q.moneyReq + " " + Quests.getCurrency(true));
} }
} else { } else {
if (quest.moneyReq == 1) { if (q.moneyReq == 1) {
cs.sendMessage(GRAY + "- " + RED + quest.moneyReq + " " + Quests.getCurrency(false)); cs.sendMessage(GRAY + "- " + RED + q.moneyReq + " " + Quests.getCurrency(false));
} else { } else {
cs.sendMessage(GRAY + "- " + RED + quest.moneyReq + " " + Quests.getCurrency(true)); cs.sendMessage(GRAY + "- " + RED + q.moneyReq + " " + Quests.getCurrency(true));
} }
} }
} }
if (quest.items.isEmpty() == false) { if (q.items.isEmpty() == false) {
for (ItemStack is : quest.items) { for (ItemStack is : q.items) {
if (hasItem(player, is) == true) { if (hasItem(player, is) == true) {
cs.sendMessage(GRAY + "- " + GREEN + ItemUtil.getString(is)); cs.sendMessage(GRAY + "- " + GREEN + ItemUtil.getString(is));
@ -2018,9 +2029,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
if (quest.neededQuests.isEmpty() == false) { if (q.neededQuests.isEmpty() == false) {
for (String s : quest.neededQuests) { for (String s : q.neededQuests) {
if (quester.completedQuests.contains(s)) { if (quester.completedQuests.contains(s)) {
cs.sendMessage(GRAY + "- " + GREEN + Lang.get("complete") + " " + ITALIC + s); cs.sendMessage(GRAY + "- " + GREEN + Lang.get("complete") + " " + ITALIC + s);
@ -2032,9 +2043,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
if (quest.blockQuests.isEmpty() == false) { if (q.blockQuests.isEmpty() == false) {
for (String s : quest.blockQuests) { for (String s : q.blockQuests) {
if (quester.completedQuests.contains(s)) { if (quester.completedQuests.contains(s)) {
String msg = Lang.get("haveCompleted"); String msg = Lang.get("haveCompleted");
@ -2055,35 +2066,32 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} else { } else {
cs.sendMessage(YELLOW + Lang.get("questNotFound")); cs.sendMessage(YELLOW + Lang.get("questNotFound"));
return;
} }
} else { } else {
cs.sendMessage(RED + Lang.get("questInfoNoPerms")); cs.sendMessage(RED + Lang.get("questInfoNoPerms"));
return;
} }
} }
private void showObjectives(final CommandSender cs) { private void showObjectives(final Player player) {
if (getQuester(cs.getName()).currentQuest != null) { if (getQuester(player.getUniqueId()).currentQuest != null) {
if (getQuester(cs.getName()).delayStartTime == 0) { if (getQuester(player.getUniqueId()).delayStartTime == 0) {
cs.sendMessage(GOLD + Lang.get("questObjectivesTitle")); player.sendMessage(GOLD + Lang.get("questObjectivesTitle"));
} }
for (String s : getQuester(cs.getName()).getObjectivesReal()) { for (String s : getQuester(player.getUniqueId()).getObjectivesReal()) {
cs.sendMessage(s); player.sendMessage(s);
} }
} else { } else {
cs.sendMessage(YELLOW + Lang.get("noActiveQuest")); player.sendMessage(YELLOW + Lang.get("noActiveQuest"));
return;
} }
} }
@ -2160,9 +2168,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
numOrder++; numOrder++;
} }
for (Quest quest : subQuests) { for (Quest q : subQuests) {
player.sendMessage(YELLOW + Integer.toString(numOrder) + ". " + quest.name); player.sendMessage(YELLOW + Integer.toString(numOrder) + ". " + q.name);
numOrder++; numOrder++;
} }
@ -2199,29 +2207,29 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
public Quester getQuester(String player) { public Quester getQuester(UUID id) {
Quester quester = null; Quester quester = null;
if (questers.containsKey(player)) { if (questers.containsKey(id)) {
quester = questers.get(player); quester = questers.get(id);
} }
if (quester == null) { if (quester == null) {
if (debug == true) { if (debug == true) {
log.log(Level.WARNING, "[Quests] Quester data for player \"" + player + "\" not stored. Attempting manual data retrieval.."); log.log(Level.WARNING, "[Quests] Quester data for player \"" + id.toString() + "\" not stored. Attempting manual data retrieval..");
} }
quester = new Quester(this); quester = new Quester(this);
quester.name = player; quester.id = id;
if (quester.loadData() == false) { if (quester.loadData() == false) {
log.severe("[Quests] Quester not found for player \"" + player + "\". Consider adding them to the Quester blacklist."); log.severe("[Quests] Quester not found for player \"" + id.toString() + "\". Consider adding them to the Quester blacklist.");
} else { } else {
if (debug == true) { if (debug == true) {
log.log(Level.INFO, "[Quests] Manual data retrieval succeeded for player \"" + player + "\""); log.log(Level.INFO, "[Quests] Manual data retrieval succeeded for player \"" + id.toString() + "\"");
} }
questers.put(player, quester); questers.put(id, quester);
} }
} }
@ -2229,18 +2237,18 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
public Map<String, Quester> getOnlineQuesters() { public Map<UUID, Quester> getOnlineQuesters() {
Map<String, Quester> qs = new HashMap<String, Quester>(); Map<UUID, Quester> qs = new HashMap<UUID, Quester>();
for (Player p : getServer().getOnlinePlayers()) { for (Player p : getServer().getOnlinePlayers()) {
Quester quester = new Quester(this); Quester quester = new Quester(this);
quester.name = p.getName(); quester.id = p.getUniqueId();
if (quester.loadData() == false) { if (quester.loadData() == false) {
quester.saveData(); quester.saveData();
} }
qs.put(p.getName(), quester); qs.put(p.getUniqueId(), quester);
} }
@ -2254,7 +2262,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
public void loadQuests() { public void loadQuests() {
boolean failedToLoad = false; boolean failedToLoad;
totalQuestPoints = 0; totalQuestPoints = 0;
needsSaving = false; needsSaving = false;
@ -4957,7 +4965,6 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
}else { }else {
log.severe("[Quests] Enable debug to view the error log."); log.severe("[Quests] Enable debug to view the error log.");
} }
return;
} }
} }
@ -5008,7 +5015,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
failed++; failed++;
} }
names.add(name); names.add(name.toLowerCase());
succeeded++; succeeded++;
} }
@ -5021,7 +5028,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
@Override @Override
public void run() { public void run() {
Quests.printInfo("Done. Converting data..."); Quests.printInfo("Done. Converting data...");
System.out.println("names: " + names);
int converted = 0; int converted = 0;
int failed = 0; int failed = 0;

View File

@ -21,7 +21,7 @@ public class StageTimer implements Runnable{
if(quester.delayOver){ if(quester.delayOver){
Player player = plugin.getServer().getPlayerExact(quester.name); Player player = quester.getPlayer();
if(quester.currentQuest != null){ if(quester.currentQuest != null){

View File

@ -54,6 +54,8 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
@Override @Override
public String getPromptText(ConversationContext context) { public String getPromptText(ConversationContext context) {
try {
context.setSessionData(pref, Boolean.TRUE); context.setSessionData(pref, Boolean.TRUE);
String text = PINK + "- " + AQUA + (String) context.getSessionData(CK.Q_NAME) + PINK + " | " + Lang.get("stageEditorStage") + " " + PURPLE + stageNum + PINK + " -\n"; String text = PINK + "- " + AQUA + (String) context.getSessionData(CK.Q_NAME) + PINK + " | " + Lang.get("stageEditorStage") + " " + PURPLE + stageNum + PINK + " -\n";
@ -111,7 +113,6 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
for (int i = 0; i < ids.size(); i++) { for (int i = 0; i < ids.size(); i++) {
text += GRAY + " - " + BLUE + Quester.prettyItemString(ids.get(i)) + GRAY + " x " + DARKAQUA + amnts.get(i) + "\n"; text += GRAY + " - " + BLUE + Quester.prettyItemString(ids.get(i)) + GRAY + " x " + DARKAQUA + amnts.get(i) + "\n";
} }
} }
if (context.getSessionData(pref + CK.S_CUT_IDS) == null) { if (context.getSessionData(pref + CK.S_CUT_IDS) == null) {
@ -364,8 +365,14 @@ public class CreateStagePrompt extends FixedSetPrompt implements ColorUtil {
text += RED + "" + BOLD + "25 " + RESET + PURPLE + "- " + Lang.get("stageEditorDelete") + "\n"; text += RED + "" + BOLD + "25 " + RESET + PURPLE + "- " + Lang.get("stageEditorDelete") + "\n";
text += GREEN + "" + BOLD + "26 " + RESET + PURPLE + "- " + Lang.get("done") + "\n"; text += GREEN + "" + BOLD + "26 " + RESET + PURPLE + "- " + Lang.get("done") + "\n";
return text; return text;
}catch (Exception e) {
e.printStackTrace();
return "a";
}
} }
@Override @Override

View File

@ -58,8 +58,8 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil{
menu += YELLOW + "" + BOLD + "4. " + RESET + "" + GOLD + Lang.get("itemCreateSetEnchs") + "\n"; menu += YELLOW + "" + BOLD + "4. " + RESET + "" + GOLD + Lang.get("itemCreateSetEnchs") + "\n";
menu += YELLOW + "" + BOLD + "5. " + RESET + "" + ITALIC + GOLD + Lang.get("itemCreateSetName") + "\n"; menu += YELLOW + "" + BOLD + "5. " + RESET + "" + ITALIC + GOLD + Lang.get("itemCreateSetName") + "\n";
menu += YELLOW + "" + BOLD + "6. " + RESET + "" + ITALIC + GOLD + Lang.get("itemCreateSetLore") + "\n"; menu += YELLOW + "" + BOLD + "6. " + RESET + "" + ITALIC + GOLD + Lang.get("itemCreateSetLore") + "\n";
menu += YELLOW + "" + BOLD + "7. " + RESET + "" + GREEN + Lang.get("cancel") + "\n"; menu += YELLOW + "" + BOLD + "7. " + RESET + "" + RED + Lang.get("cancel") + "\n";
menu += YELLOW + "" + BOLD + "8. " + RESET + "" + RED + Lang.get("done") + "\n"; menu += YELLOW + "" + BOLD + "8. " + RESET + "" + GREEN + Lang.get("done") + "\n";
return menu; return menu;
} }
@ -156,6 +156,16 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil{
}else if(input.equalsIgnoreCase("7")) { }else if(input.equalsIgnoreCase("7")) {
cc.setSessionData("tempStack", null);
cc.setSessionData("tempId", null);
cc.setSessionData("tempAmount", null);
cc.setSessionData("tempData", null);
cc.setSessionData("tempEnchantments", null);
cc.setSessionData("tempName", null);
cc.setSessionData("tempLore", null);
}else if(input.equalsIgnoreCase("8")){
if(cc.getSessionData("tempId") != null && cc.getSessionData("tempAmount") != null){ if(cc.getSessionData("tempId") != null && cc.getSessionData("tempAmount") != null){
int id = (Integer) cc.getSessionData("tempId"); int id = (Integer) cc.getSessionData("tempId");
@ -199,15 +209,7 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil{
return new ItemStackPrompt(oldPrompt); return new ItemStackPrompt(oldPrompt);
} }
}else if(input.equalsIgnoreCase("8")) }
cc.setSessionData("tempStack", null);
cc.setSessionData("tempId", null);
cc.setSessionData("tempAmount", null);
cc.setSessionData("tempData", null);
cc.setSessionData("tempEnchantments", null);
cc.setSessionData("tempName", null);
cc.setSessionData("tempLore", null);
try{ try{
return oldPrompt; return oldPrompt;

View File

@ -30,7 +30,7 @@ public class QuestAcceptPrompt extends StringPrompt implements ColorUtil {
public String getPromptText(ConversationContext cc) { public String getPromptText(ConversationContext cc) {
quests = (LinkedList<Quest>) cc.getSessionData("quests"); quests = (LinkedList<Quest>) cc.getSessionData("quests");
quester = plugin.getQuester(((Player) cc.getForWhom()).getName()); quester = plugin.getQuester(((Player) cc.getForWhom()).getUniqueId());
String npc = (String) cc.getSessionData("npc"); String npc = (String) cc.getSessionData("npc");
String text = Lang.get("questNPCListTitle"); String text = Lang.get("questNPCListTitle");

View File

@ -60,7 +60,7 @@ public class CK {
public static final String S_PLACE_AMOUNTS = "placeAmounts"; public static final String S_PLACE_AMOUNTS = "placeAmounts";
public static final String S_USE_IDS = "useIds"; public static final String S_USE_IDS = "useIds";
public static final String S_USE_AMOUNTS = "useAmounts"; public static final String S_USE_AMOUNTS = "useAmounts";
public static final String S_CUT_IDS = "useIds"; public static final String S_CUT_IDS = "cutIds";
public static final String S_CUT_AMOUNTS = "cutAmounts"; public static final String S_CUT_AMOUNTS = "cutAmounts";
public static final String S_FISH = "fish"; public static final String S_FISH = "fish";
public static final String S_PLAYER_KILL = "playerKill"; public static final String S_PLAYER_KILL = "playerKill";

View File

@ -991,6 +991,7 @@ public class Lang {
langMap.put("exited", "Exited"); langMap.put("exited", "Exited");
langMap.put("cancel", "Cancel"); langMap.put("cancel", "Cancel");
langMap.put("cancelled", "Cancelled"); langMap.put("cancelled", "Cancelled");
langMap.put("questTimeout", "Cancelled.");
langMap.put("back", "Back"); langMap.put("back", "Back");
langMap.put("yesWord", "Yes"); langMap.put("yesWord", "Yes");
langMap.put("noWord", "No"); langMap.put("noWord", "No");
@ -1108,7 +1109,6 @@ public class Lang {
} else { } else {
newLangs = true; newLangs = true;
System.out.println("COULD NOT FIND KEY FOR: \"" + entry.getKey() + "\"");
newMap.put(entry.getKey(), entry.getValue()); newMap.put(entry.getKey(), entry.getValue());
} }

View File

@ -1,6 +1,9 @@
package me.blackvein.quests.util; package me.blackvein.quests.util;
import me.blackvein.quests.Quester;
import org.bukkit.Bukkit;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
public class MiscUtil { public class MiscUtil {
@ -114,4 +117,5 @@ public class MiscUtil {
return s; return s;
} }
} }