From 173d33520fd17bb9c4a0d27162e2d8e403d9e93d Mon Sep 17 00:00:00 2001 From: Blackvein Date: Mon, 29 Oct 2012 12:04:31 -0700 Subject: [PATCH] Unstable --- src/me/blackvein/quests/NpcListener.java | 85 +++++++++++---------- src/me/blackvein/quests/PlayerListener.java | 8 +- src/me/blackvein/quests/Quests.java | 11 ++- 3 files changed, 58 insertions(+), 46 deletions(-) diff --git a/src/me/blackvein/quests/NpcListener.java b/src/me/blackvein/quests/NpcListener.java index b157bd492..d140d16c3 100644 --- a/src/me/blackvein/quests/NpcListener.java +++ b/src/me/blackvein/quests/NpcListener.java @@ -24,48 +24,24 @@ public class NpcListener implements Listener { if (plugin.questNPCs.contains(evt.getNPC())) { - final Player player = evt.getClicker(); + final Player player = evt.getClicker(); - if(Quests.checkQuester()) - final Quester quester = plugin.getQuester(player.getName()); - if (quester.hasObjective("talkToNPC")) { + if(plugin.checkQuester(player.getName()) == false){ - quester.interactWithNPC(evt.getNPC()); + final Quester quester = plugin.getQuester(player.getName()); + if (quester.hasObjective("talkToNPC")) { - } else { + quester.interactWithNPC(evt.getNPC()); - for (final Quest q : plugin.quests) { + } else { - if (q.npcStart != null && player.hasPermission("quests.quest")) { + for (final Quest q : plugin.quests) { - if (q.npcStart.equals(evt.getNPC()) && quester.completedQuests.contains(q.name) == false) { + if (q.npcStart != null && player.hasPermission("quests.quest")) { - if (quester.currentQuest == null) { + if (q.npcStart.equals(evt.getNPC()) && quester.completedQuests.contains(q.name) == false) { - 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"; - player.sendMessage(s); - plugin.conversationFactory.buildConversation((Conversable) player).begin(); - - } else if (quester.currentQuest.equals(q) == false) { - - player.sendMessage(ChatColor.YELLOW + "You may only have one active Quest."); - - } - - break; - - } else if (q.npcStart.equals(evt.getNPC()) && quester.completedQuests.contains(q.name) == true) { - - if (quester.currentQuest == null) { - - if (quester.getDifference(q) > 0) { - player.sendMessage(ChatColor.YELLOW + "You may not take " + ChatColor.AQUA + q.name + ChatColor.YELLOW + " again for another " + ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(q)) + ChatColor.YELLOW + "."); - } else { + if (quester.currentQuest == null) { quester.questToTake = q.name; @@ -76,24 +52,51 @@ public class NpcListener implements Listener { player.sendMessage(s); plugin.conversationFactory.buildConversation((Conversable) player).begin(); + } else if (quester.currentQuest.equals(q) == false) { + + player.sendMessage(ChatColor.YELLOW + "You may only have one active Quest."); + } - } else if (quester.currentQuest.equals(q) == false) { + break; - player.sendMessage(ChatColor.YELLOW + "You may only have one active Quest."); + } else if (q.npcStart.equals(evt.getNPC()) && quester.completedQuests.contains(q.name) == true) { + + if (quester.currentQuest == null) { + + if (quester.getDifference(q) > 0) { + player.sendMessage(ChatColor.YELLOW + "You may not take " + ChatColor.AQUA + q.name + ChatColor.YELLOW + " again for another " + ChatColor.DARK_PURPLE + Quests.getTime(quester.getDifference(q)) + ChatColor.YELLOW + "."); + } else { + + 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"; + player.sendMessage(s); + plugin.conversationFactory.buildConversation((Conversable) player).begin(); + + } + + } else if (quester.currentQuest.equals(q) == false) { + + player.sendMessage(ChatColor.YELLOW + "You may only have one active Quest."); + + } + + + + break; } - - - break; - } } } - + } } diff --git a/src/me/blackvein/quests/PlayerListener.java b/src/me/blackvein/quests/PlayerListener.java index b21744414..af86886aa 100644 --- a/src/me/blackvein/quests/PlayerListener.java +++ b/src/me/blackvein/quests/PlayerListener.java @@ -24,6 +24,7 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.player.PlayerFishEvent.State; import org.bukkit.event.player.*; +import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; public class PlayerListener implements Listener { @@ -468,13 +469,14 @@ public class PlayerListener implements Listener { }else{ ItemStack oldStack = evt.getCurrentItem(); - HashMap map = evt.getInventory().addItem(oldStack); - + Inventory inv = plugin.getServer().createInventory(null, evt.getInventory().getType()); + HashMap map = inv.addItem(oldStack); if(map.isEmpty() == false){ ItemStack newStack = oldStack.clone(); - newStack.setAmount(old) + newStack.setAmount(oldStack.getAmount() - map.get(0).getAmount()); + quester.collectItem(newStack); }else{ quester.collectItem(oldStack); diff --git a/src/me/blackvein/quests/Quests.java b/src/me/blackvein/quests/Quests.java index 748126ebb..f56f8cfe5 100644 --- a/src/me/blackvein/quests/Quests.java +++ b/src/me/blackvein/quests/Quests.java @@ -38,7 +38,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener public static Economy economy = null; public static Permission permission = null; public static mcMMO mcmmo = null; - HashSet questerBlacklist = new HashSet(); + List questerBlacklist = new LinkedList(); ConversationFactory conversationFactory; QuestFactory questFactory; Heroes heroes; @@ -3685,9 +3685,16 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener return true; } - public static boolean checkQuester(String name){ + public boolean checkQuester(String name){ + for(String s : questerBlacklist){ + + if(Quests.checkQuester(name, s)) + return true; + + } + return false; }