From 7158aa6bfb37a9456aa83e3cca2683a810f4cbb5 Mon Sep 17 00:00:00 2001 From: fullwall Date: Tue, 24 Jul 2012 14:21:59 +0800 Subject: [PATCH] Fix equipment editing --- src/main/java/net/citizensnpcs/Citizens.java | 4 ++-- src/main/java/net/citizensnpcs/EventListen.java | 2 +- .../citizensnpcs/command/command/NPCCommands.java | 14 ++++++++------ .../net/citizensnpcs/editor/EquipmentEditor.java | 4 ++-- .../net/citizensnpcs/npc/ai/CitizensNavigator.java | 6 +++--- .../citizensnpcs/npc/entity/CitizensHumanNPC.java | 7 ++++--- .../citizensnpcs/npc/entity/EntityHumanNPC.java | 3 +-- 7 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/main/java/net/citizensnpcs/Citizens.java b/src/main/java/net/citizensnpcs/Citizens.java index b7e159c0f..715facfa0 100644 --- a/src/main/java/net/citizensnpcs/Citizens.java +++ b/src/main/java/net/citizensnpcs/Citizens.java @@ -67,8 +67,8 @@ public class Citizens extends JavaPlugin implements CitizensPlugin { Iterator itr = npcRegistry.iterator(); while (itr.hasNext()) { NPC npc = itr.next(); - itr.remove(); npc.despawn(); + itr.remove(); } } @@ -211,7 +211,7 @@ public class Citizens extends JavaPlugin implements CitizensPlugin { enableSubPlugins(); } }) == -1) { - Messaging.severe("Issue enabling plugin. Disabling."); + Messaging.severe("NPC load task couldn't be scheduled - disabling..."); getServer().getPluginManager().disablePlugin(this); } } diff --git a/src/main/java/net/citizensnpcs/EventListen.java b/src/main/java/net/citizensnpcs/EventListen.java index 672b1fd0c..7c9ef02a7 100644 --- a/src/main/java/net/citizensnpcs/EventListen.java +++ b/src/main/java/net/citizensnpcs/EventListen.java @@ -169,8 +169,8 @@ public class EventListen implements Listener { if (!npc.isSpawned() || !npc.getBukkitEntity().getWorld().equals(event.getWorld())) continue; - npc.despawn(); storeForRespawn(npc); + npc.despawn(); } } diff --git a/src/main/java/net/citizensnpcs/command/command/NPCCommands.java b/src/main/java/net/citizensnpcs/command/command/NPCCommands.java index 5307f4f96..f36908f82 100644 --- a/src/main/java/net/citizensnpcs/command/command/NPCCommands.java +++ b/src/main/java/net/citizensnpcs/command/command/NPCCommands.java @@ -465,14 +465,16 @@ public class NPCCommands { + " Use '/npc tphere' to teleport the NPC to your location."); Location location = respawn.getTrait(CurrentLocation.class).getLocation(); - if (location == null && sender instanceof Player) - location = ((Player) sender).getLocation(); - else - throw new CommandException("No stored location available - command must be used ingame."); + if (location == null) { + if (sender instanceof Player) + location = ((Player) sender).getLocation(); + else + throw new CommandException("No stored location available - command must be used ingame."); + } if (respawn.spawn(location)) { selector.select(sender, respawn); - Messaging.send(sender, ChatColor.GREEN + "You respawned " + StringHelper.wrap(respawn.getName()) - + " at your location."); + Messaging.send(sender, ChatColor.GREEN + "You spawned " + StringHelper.wrap(respawn.getName()) + + "."); } } diff --git a/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java b/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java index 17e6997a4..8423016da 100644 --- a/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java +++ b/src/main/java/net/citizensnpcs/editor/EquipmentEditor.java @@ -39,8 +39,8 @@ public class EquipmentEditor extends Editor { @EventHandler public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { - if (!npc.equals(CitizensAPI.getNPCRegistry().getNPC(event.getRightClicked())) - || !event.getPlayer().equals(player)) + if (!event.getPlayer().equals(player) + || !npc.equals(CitizensAPI.getNPCRegistry().getNPC(event.getRightClicked()))) return; if (npc instanceof Equipable) { diff --git a/src/main/java/net/citizensnpcs/npc/ai/CitizensNavigator.java b/src/main/java/net/citizensnpcs/npc/ai/CitizensNavigator.java index b01b4cd37..80261f835 100644 --- a/src/main/java/net/citizensnpcs/npc/ai/CitizensNavigator.java +++ b/src/main/java/net/citizensnpcs/npc/ai/CitizensNavigator.java @@ -123,11 +123,10 @@ public class CitizensNavigator implements Navigator { } } - private static final float DEFAULT_SPEED = 0.3F; + private static final float DEFAULT_SPEED = 0.7F; private static final Map MOVEMENT_SPEEDS = Maps.newEnumMap(EntityType.class); private static Field SPEED_FIELD; static { - MOVEMENT_SPEEDS.put(EntityType.IRON_GOLEM, 0.15F); MOVEMENT_SPEEDS.put(EntityType.CHICKEN, 0.25F); MOVEMENT_SPEEDS.put(EntityType.COW, 0.2F); @@ -135,7 +134,8 @@ public class CitizensNavigator implements Navigator { MOVEMENT_SPEEDS.put(EntityType.VILLAGER, 0.3F); MOVEMENT_SPEEDS.put(EntityType.SNOWMAN, 0.25F); MOVEMENT_SPEEDS.put(EntityType.CREEPER, 0.3F); - MOVEMENT_SPEEDS.put(EntityType.PIG, 0.25F); + MOVEMENT_SPEEDS.put(EntityType.PIG, 0.27F); + MOVEMENT_SPEEDS.put(EntityType.PLAYER, 1F); try { SPEED_FIELD = EntityLiving.class.getDeclaredField("bb"); SPEED_FIELD.setAccessible(true); diff --git a/src/main/java/net/citizensnpcs/npc/entity/CitizensHumanNPC.java b/src/main/java/net/citizensnpcs/npc/entity/CitizensHumanNPC.java index bb0e01076..b35a0d200 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/CitizensHumanNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/CitizensHumanNPC.java @@ -89,13 +89,14 @@ public class CitizensHumanNPC extends CitizensNPC implements Equipable { trait.set(i, null); } } - Messaging.sendF(equipper, "%shad all of its items removed.", getName()); + Messaging.sendF(equipper, "%s had all of its items removed.", getName()); default: break; } // Drop any previous equipment on the ground - if (trait.get(slot) != null && trait.get(slot).getType() != Material.AIR) - equipper.getWorld().dropItemNaturally(getBukkitEntity().getLocation(), trait.get(slot)); + ItemStack equippedItem = trait.get(slot); + if (equippedItem != null && equippedItem.getType() != Material.AIR) + equipper.getWorld().dropItemNaturally(getBukkitEntity().getLocation(), equippedItem); // Now edit the equipment based on the slot if (type != Material.AIR) { diff --git a/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java b/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java index e3dd40993..b663a2cc3 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java @@ -57,7 +57,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder { moveOnCurrentHeading(); } else if (motX != 0 || motZ != 0 || motY != 0) { // a(0, 0); - } if (noDamageTicks > 0) --noDamageTicks; @@ -80,7 +79,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder { if (inLiquid) { motY += 0.04; } else if (onGround && q == 0) { - // ac(); - this doesn't jump high enough + // this.ac(); - this doesn't jump high enough motY = 0.6; q = 10; }