From cf5017644bd4f482618241820f77161dede82769 Mon Sep 17 00:00:00 2001 From: fullwall Date: Tue, 28 Feb 2012 21:03:36 +0800 Subject: [PATCH] Move file --- .../citizensnpcs/editor/EquipmentEditor.java | 32 ++++++++++-------- .../waypoint/LinearWaypointProvider.java | 2 +- .../net/citizensnpcs/util/StorageUtils.java | 33 ------------------- 3 files changed, 19 insertions(+), 48 deletions(-) delete mode 100644 src/main/java/net/citizensnpcs/util/StorageUtils.java diff --git a/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java b/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java index 7bac43046..0670e9230 100644 --- a/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java +++ b/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java @@ -48,7 +48,7 @@ public class EquipmentEditor extends Editor { public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { if (!plugin.getNPCManager().isNPC(event.getRightClicked()) || !plugin.getNPCManager().getNPC(event.getRightClicked()).equals(npc) - || !event.getPlayer().getName().equals(player.getName())) + || !event.getPlayer().equals(player)) return; ItemStack hand = player.getItemInHand(); @@ -92,24 +92,28 @@ public class EquipmentEditor extends Editor { break; case AIR: for (int i = 0; i < 4; i++) { - if (trait.getEquipment(i) != null && trait.getEquipment(i).getType() != Material.AIR) { - player.getWorld().dropItemNaturally(npc.getBukkitEntity().getLocation(), trait.getEquipment(i)); - trait.setEquipment(i, null); + if (trait.get(i) != null && trait.get(i).getType() != Material.AIR) { + player.getWorld().dropItemNaturally(npc.getBukkitEntity().getLocation(), trait.get(i)); + trait.set(i, null); } } Messaging.send(player, "" + npc.getName() + " had all of its items removed."); } // Now edit the equipment based on the slot - if (trait.getEquipment(slot) != null && trait.getEquipment(slot).getType() != Material.AIR) - player.getWorld().dropItemNaturally(npc.getBukkitEntity().getLocation(), trait.getEquipment(slot)); - trait.setEquipment(slot, hand); - if (hand.getAmount() > 1) - hand.setAmount(hand.getAmount() - 1); - else - hand = null; - player.setItemInHand(hand); - if (set.getType() != Material.AIR) + if (trait.get(slot) != null) { + player.getWorld().dropItemNaturally(npc.getBukkitEntity().getLocation(), trait.get(slot)); + } + + ItemStack set = hand; + if (set != null && set.getType() != Material.AIR) { + if (hand.getAmount() > 1) { + hand.setAmount(hand.getAmount() - 1); + } else { + hand = null; + } + player.setItemInHand(hand); set.setAmount(1); - trait.setEquipment(slot, set); + } + trait.set(slot, set); } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java b/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java index 6a076a34c..f695884d5 100644 --- a/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java +++ b/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java @@ -5,9 +5,9 @@ import java.util.List; import net.citizensnpcs.api.ai.AI; import net.citizensnpcs.api.ai.NavigationCallback; import net.citizensnpcs.api.util.DataKey; +import net.citizensnpcs.api.util.StorageUtils; import net.citizensnpcs.editor.Editor; import net.citizensnpcs.util.Messaging; -import net.citizensnpcs.util.StorageUtils; import org.bukkit.ChatColor; import org.bukkit.entity.Player; diff --git a/src/main/java/net/citizensnpcs/util/StorageUtils.java b/src/main/java/net/citizensnpcs/util/StorageUtils.java deleted file mode 100644 index 298bd9aa1..000000000 --- a/src/main/java/net/citizensnpcs/util/StorageUtils.java +++ /dev/null @@ -1,33 +0,0 @@ -package net.citizensnpcs.util; - -import net.citizensnpcs.api.util.DataKey; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -public class StorageUtils { - - public static Location loadLocation(DataKey root) { - root = root.getRelative("location"); - return new Location(Bukkit.getWorld(root.getString("world")), root.getDouble("x"), root.getDouble("y"), root - .getDouble("z"), (float) root.getDouble("yaw", 0), (float) root.getDouble("pitch", 0)); - } - - public static ItemStack loadItemStack(DataKey root) { - root = root.getRelative("item"); - return new ItemStack(Material.matchMaterial(root.getString("id")), root.getInt("amount"), (short) (root - .keyExists("data") ? root.getInt("data") : 0)); - } - - public static void saveLocation(DataKey key, Location location) { - key = key.getRelative("location"); - key.setString("world", location.getWorld().getName()); - key.setDouble("x", location.getX()); - key.setDouble("y", location.getY()); - key.setDouble("z", location.getZ()); - key.setDouble("yaw", location.getYaw()); - key.setDouble("pitch", location.getPitch()); - } -}