From bc76c72e090a0ac784e932deddd98786a3643d6a Mon Sep 17 00:00:00 2001 From: Blackvein Date: Tue, 23 Oct 2012 12:01:26 -0700 Subject: [PATCH] Unstable, testing item slots in various inventories --- src/me/blackvein/quests/Event.java | 2 +- src/me/blackvein/quests/PlayerListener.java | 6 +- src/me/blackvein/quests/Quester.java | 21 ++++- src/me/blackvein/quests/Quests.java | 86 ++++++++++++++++++++- 4 files changed, 108 insertions(+), 7 deletions(-) diff --git a/src/me/blackvein/quests/Event.java b/src/me/blackvein/quests/Event.java index 8bfa4433f..c3bac6ae8 100644 --- a/src/me/blackvein/quests/Event.java +++ b/src/me/blackvein/quests/Event.java @@ -215,7 +215,7 @@ public class Event { if(hunger != 0){ - player.setExhaustion(hunger); + player.setFoodLevel(hunger); } diff --git a/src/me/blackvein/quests/PlayerListener.java b/src/me/blackvein/quests/PlayerListener.java index 9504f636f..36c4c0b3d 100644 --- a/src/me/blackvein/quests/PlayerListener.java +++ b/src/me/blackvein/quests/PlayerListener.java @@ -246,7 +246,9 @@ public class PlayerListener implements Listener { @EventHandler public void onInventoryClick(InventoryClickEvent evt) { - if (evt.getWhoClicked() instanceof Player && evt.getCursor() != null) { + System.out.println("Slot: " + evt.getRawSlot() + "\n"); + ((Player)evt.getWhoClicked()).sendMessage("Slot: " + evt.getRawSlot() + "\n"); + /*if (evt.getWhoClicked() instanceof Player && evt.getCursor() != null) { Quester quester = plugin.getQuester(evt.getWhoClicked().getName()); if (quester.currentQuest != null) { @@ -282,7 +284,7 @@ public class PlayerListener implements Listener { } - } + }*/ } diff --git a/src/me/blackvein/quests/Quester.java b/src/me/blackvein/quests/Quester.java index 4a129c59f..cb7e93808 100644 --- a/src/me/blackvein/quests/Quester.java +++ b/src/me/blackvein/quests/Quester.java @@ -380,11 +380,11 @@ public class Quester { if (citizenNumKilled.get(citizensKilled.indexOf(n2)) < currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n))) { - unfinishedObjectives.add(ChatColor.GREEN + "Kill " + n.getFullName() + ChatColor.GREEN); + unfinishedObjectives.add(ChatColor.GREEN + "Kill " + n.getFullName() + ChatColor.GREEN + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n)) + "/" + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n))); - } else {a + } else { - finishedObjectives.add(ChatColor.GRAY + "Kill " + n.getFullName()); + finishedObjectives.add(ChatColor.GRAY + "Kill " + n.getName() + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n)) + "/" + currentStage.citizenNumToKill.get(currentStage.citizensToKill.indexOf(n))); } @@ -878,6 +878,21 @@ public class Quester { } } + + public void killNPC(NPC n) { + + if(citizensKilled.contains(n)){ + + int index = citizensKilled.indexOf(n); + if(citizenNumKilled.get(index) < currentStage.citizenNumToKill.get(index)){ + citizenNumKilled.set(index, citizenNumKilled.get(index) + 1); + if(citizenNumKilled.get(index) == currentStage.citizenNumToKill.get(index)) + finishObjective("killNPC", null, null, null, null, null, n, null, null, 0); + } + + } + + } public void reachLocation(Location l) { diff --git a/src/me/blackvein/quests/Quests.java b/src/me/blackvein/quests/Quests.java index 3475f59eb..6e86da479 100644 --- a/src/me/blackvein/quests/Quests.java +++ b/src/me/blackvein/quests/Quests.java @@ -24,6 +24,7 @@ import org.bukkit.conversations.*; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; @@ -56,6 +57,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener boolean debug = false; boolean load = false; int killDelay = 0; + int totalQuestPoints = 0; public final static Logger log = Logger.getLogger("Minecraft"); @Override @@ -696,7 +698,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener Quester quester = getQuester(cs.getName()); cs.sendMessage(ChatColor.GOLD + "- " + cs.getName() + " -"); - cs.sendMessage(ChatColor.YELLOW + "Quest points: " + ChatColor.DARK_PURPLE + quester.questPoints); + cs.sendMessage(ChatColor.YELLOW + "Quest points: " + ChatColor.DARK_PURPLE + quester.questPoints + "/" + totalQuestPoints); if (quester.currentQuest == null) { cs.sendMessage(ChatColor.YELLOW + "Current Quest: " + ChatColor.DARK_PURPLE + "None"); } else { @@ -1317,6 +1319,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener ConfigurationSection section1 = config.getConfigurationSection("quests"); boolean failedToLoad = false; + totalQuestPoints = 0; for (String s : section1.getKeys(false)) { try { @@ -2788,6 +2791,7 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener if (config.getInt("quests." + s + ".rewards.quest-points", -999) != -999) { quest.questPoints = config.getInt("quests." + s + ".rewards.quest-points"); + totalQuestPoints += quest.questPoints; } else { printSevere(ChatColor.GOLD + "[Quests] " + ChatColor.RED + "quest-points: " + ChatColor.AQUA + "Reward " + ChatColor.GOLD + "in Quest " + ChatColor.DARK_PURPLE + quest.name + ChatColor.GOLD + " is not a number!"); continue; @@ -3601,6 +3605,86 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener return false; } + public static boolean invCheck(Player player, ItemStack stack, Inventory inv, int rawSlot) { + + if (rawSlot < 0) { + player.sendMessage(ChatColor.YELLOW + "You may not discard Quest items."); + return false; + } + + if (inv.getType().equals(InventoryType.CRAFTING)) { + + if (((rawSlot > 8) && (rawSlot < 36)) || ((rawSlot > -1) && (rawSlot < 5))) { + player.sendMessage(ChatColor.YELLOW + "You may not craft using Quest items."); + return false; + } + + } else if (inv.getType().equals(InventoryType.BREWING)) { + + if ((rawSlot > 3) && (rawSlot < 41)) { + player.sendMessage(ChatColor.YELLOW + "You may not brew using Quest items."); + return false; + } + + } else if (inv.getType().equals(InventoryType.ENCHANTING)) { + + if ((rawSlot > 0) && (rawSlot < 28)) { + player.sendMessage(ChatColor.YELLOW + "You may not enchant Quest items."); + return false; + } + + } else if (inv.getType().equals(InventoryType.ENDER_CHEST)) { + + if ((rawSlot > 26) && (rawSlot < 54)) { + player.sendMessage(ChatColor.YELLOW + "You may not store Quest items."); + return false; + } + + } else if (inv.getType().equals(InventoryType.DISPENSER)) { + + if ((rawSlot > 8) && (rawSlot < 36)) { + player.sendMessage(ChatColor.YELLOW + "You may not store Quest items."); + return false; + } + + } else if (inv.getType().equals(InventoryType.FURNACE)) { + + if ((rawSlot > 2) && (rawSlot < 30)) { + player.sendMessage(ChatColor.YELLOW + "You may not smelt using Quest items."); + return false; + } + + } else if (inv.getType().equals(InventoryType.WORKBENCH)) { + if ((rawSlot > 9) && (rawSlot < 37)) { + player.sendMessage(ChatColor.YELLOW + "You may not craft using Quest items."); + return false; + } + + } else if (inv.getType().equals(InventoryType.CHEST)) { + if (inv.getContents().length == 27) { + if ((rawSlot > 26) && (rawSlot < 54)) { + player.sendMessage(ChatColor.YELLOW + "You may not store Quest items."); + return false; + } + + } else if ((rawSlot > 53) && (rawSlot < 81)) { + return false; + + } else if (stack != null) { + if (inv.getItem(rawSlot) != null) { + if (stack.getType().equals(inv.getItem(rawSlot).getType())) { + return false; + + } + + } + + } + + } + return true; + } + public static boolean checkList(List list, Class c) { if (list == null) {