Fixed vanishing item rewards and enchantments

This commit is contained in:
Blackvein 2014-01-06 20:22:58 -08:00
parent fcbce57f6b
commit 91c7e5a26c
4 changed files with 199 additions and 163 deletions

View File

@ -129,9 +129,9 @@ public class Quest {
plugin.trigger.parseQuestTaskTrigger(quester.currentStage.script, quester.getPlayer()); plugin.trigger.parseQuestTaskTrigger(quester.currentStage.script, quester.getPlayer());
} }
if (quester.currentStage.finishEvent != null) { /*if (quester.currentStage.finishEvent != null) {
quester.currentStage.finishEvent.fire(quester); quester.currentStage.finishEvent.fire(quester);
} }*/
quester.currentStage = orderedStages.get(stage); quester.currentStage = orderedStages.get(stage);
@ -389,11 +389,26 @@ public class Quest {
for (ItemStack i : itemRewards) { for (ItemStack i : itemRewards) {
if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) { 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()); 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 + " *Enchanted*");
} else if (i.getDurability() != 0) { } else if (i.getDurability() != 0) {
if(i.getEnchantments().isEmpty())
player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getTypeId()) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount()); player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getTypeId()) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount());
else
player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getTypeId()) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " *Enchanted*");
} else { } else {
if(i.getEnchantments().isEmpty())
player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getTypeId()) + ChatColor.GRAY + " x " + i.getAmount()); player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getTypeId()) + ChatColor.GRAY + " x " + i.getAmount());
else
player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getTypeId()) + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " *Enchanted*");
} }
none = null; none = null;
@ -402,11 +417,26 @@ public class Quest {
for (ItemStack i : phatLootItems) { for (ItemStack i : phatLootItems) {
if (i.hasItemMeta() && i.getItemMeta().hasDisplayName()) { 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()); 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 + " *Enchanted*");
} else if (i.getDurability() != 0) { } else if (i.getDurability() != 0) {
if(i.getEnchantments().isEmpty())
player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getTypeId()) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount()); player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getTypeId()) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount());
else
player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getTypeId()) + ":" + i.getDurability() + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " *Enchanted*");
} else { } else {
if(i.getEnchantments().isEmpty())
player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getTypeId()) + ChatColor.GRAY + " x " + i.getAmount()); player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getTypeId()) + ChatColor.GRAY + " x " + i.getAmount());
else
player.sendMessage("- " + ChatColor.DARK_GREEN + Quester.prettyItemString(i.getTypeId()) + ChatColor.GRAY + " x " + i.getAmount() + ChatColor.DARK_PURPLE + " *Enchanted*");
} }
none = null; none = null;

View File

@ -1511,8 +1511,10 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
stage.set("finish-event", finishEvent); stage.set("finish-event", finishEvent);
stage.set("death-event", deathEvent); stage.set("death-event", deathEvent);
stage.set("disconnect-event", disconnectEvent); stage.set("disconnect-event", disconnectEvent);
if(chatEvents != null && chatEvents.isEmpty() == false){
stage.set("chat-events", chatEvents); stage.set("chat-events", chatEvents);
stage.set("chat-event-triggers", chatEventTriggers); stage.set("chat-event-triggers", chatEventTriggers);
}
stage.set("delay", delay); stage.set("delay", delay);
stage.set("delay-message", delayMessage); stage.set("delay-message", delayMessage);
stage.set("start-message", startMessage); stage.set("start-message", startMessage);
@ -1645,6 +1647,10 @@ public class QuestFactory implements ConversationAbandonedListener, ColorUtil {
cc.setSessionData(CK.REW_EXP, q.exp); cc.setSessionData(CK.REW_EXP, q.exp);
} }
if(q.itemRewards.isEmpty() == false) {
cc.setSessionData(CK.REW_ITEMS, q.itemRewards);
}
if (q.commands.isEmpty() == false) { if (q.commands.isEmpty() == false) {
cc.setSessionData(CK.REW_COMMAND, q.commands); cc.setSessionData(CK.REW_COMMAND, q.commands);
} }

View File

@ -1504,15 +1504,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
} else { } else if (args[0].equalsIgnoreCase("give")) {
cs.sendMessage(YELLOW + "Unknown Questadmin command. Type /questadmin for help.");
}
} else {
if (args[0].equalsIgnoreCase("give")) {
if (cs.hasPermission("quests.admin.give")) { if (cs.hasPermission("quests.admin.give")) {
@ -1925,14 +1917,13 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
} }
ConfigurationSection section1; ConfigurationSection section1;
if(config.contains("quests")) if (config.contains("quests")) {
section1 = config.getConfigurationSection("quests"); section1 = config.getConfigurationSection("quests");
else{ } else {
section1 = config.createSection("quests"); section1 = config.createSection("quests");
needsSaving = true; needsSaving = true;
} }
for (String s : section1.getKeys(false)) { for (String s : section1.getKeys(false)) {
try { try {
@ -4459,14 +4450,16 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
public Quest findQuest(String s) { public Quest findQuest(String s) {
for (Quest q : quests) { for (Quest q : quests) {
if(q.name.equalsIgnoreCase(s)) if (q.name.equalsIgnoreCase(s)) {
return q; return q;
} }
}
for (Quest q : quests) { for (Quest q : quests) {
if(q.name.toLowerCase().contains(s.toLowerCase())) if (q.name.toLowerCase().contains(s.toLowerCase())) {
return q; return q;
} }
}
return null; return null;
@ -4821,8 +4814,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
public void snoop() { public void snoop() {
String ip = getServer().getIp().trim(); String ip = getServer().getIp().trim();
if (ip.isEmpty() || ip.startsWith("192") || ip.startsWith("localhost") || ip.startsWith("127") || ip.startsWith("0.0")) if (ip.isEmpty() || ip.startsWith("192") || ip.startsWith("localhost") || ip.startsWith("127") || ip.startsWith("0.0")) {
return; return;
}
snoop_delete(); snoop_delete();
snoop_insert(); snoop_insert();
@ -4850,9 +4844,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
String inputLine; String inputLine;
while ((inputLine = in.readLine()) != null) { while ((inputLine = in.readLine()) != null) {
if(inputLine.equalsIgnoreCase("false")) if (inputLine.equalsIgnoreCase("false")) {
printWarning("[Quests] An error occurred inserting data into the snooper database!"); printWarning("[Quests] An error occurred inserting data into the snooper database!");
} }
}
in.close(); in.close();
} catch (Exception e) { } catch (Exception e) {
@ -4874,9 +4869,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
String inputLine; String inputLine;
while ((inputLine = in.readLine()) != null) { while ((inputLine = in.readLine()) != null) {
if(inputLine.equalsIgnoreCase("false")) if (inputLine.equalsIgnoreCase("false")) {
printWarning("[Quests] An error occurred removing old data from the snooper database!"); printWarning("[Quests] An error occurred removing old data from the snooper database!");
} }
}
in.close(); in.close();
} catch (Exception e) { } catch (Exception e) {
@ -4916,8 +4912,9 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener,
public Hero getHero(String player) { public Hero getHero(String player) {
Player p = getServer().getPlayer(player); Player p = getServer().getPlayer(player);
if(p == null) if (p == null) {
return null; return null;
}
return heroes.getCharacterManager().getHero(p); return heroes.getCharacterManager().getHero(p);

View File

@ -246,6 +246,7 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil{
} else { } else {
cc.setSessionData("tempId", mat.getId()); cc.setSessionData("tempId", mat.getId());
cc.setSessionData("tempAmount", 1);
if (dataString != null) { if (dataString != null) {
try { try {
@ -415,11 +416,13 @@ public class ItemStackPrompt extends FixedSetPrompt implements ColorUtil{
Map<Enchantment, Integer> enchs = (Map<Enchantment, Integer>) cc.getSessionData("tempEnchantments"); Map<Enchantment, Integer> enchs = (Map<Enchantment, Integer>) cc.getSessionData("tempEnchantments");
enchs.put((Enchantment)cc.getSessionData("tempEnchant"), num); enchs.put((Enchantment)cc.getSessionData("tempEnchant"), num);
cc.setSessionData("tempEnchantments", enchs);
}else{ }else{
Map<Enchantment, Integer> enchs = new HashMap<Enchantment, Integer>(); Map<Enchantment, Integer> enchs = new HashMap<Enchantment, Integer>();
enchs.put((Enchantment)cc.getSessionData("tempEnchant"), num); enchs.put((Enchantment)cc.getSessionData("tempEnchant"), num);
cc.setSessionData("tempEnchantments", enchs);
} }
return new ItemStackPrompt(oldPrompt); return new ItemStackPrompt(oldPrompt);