Fix equipment editing

This commit is contained in:
fullwall 2012-07-24 14:21:59 +08:00
parent 6f30ed3496
commit 7158aa6bfb
7 changed files with 21 additions and 19 deletions

View File

@ -67,8 +67,8 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
Iterator<NPC> 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);
}
}

View File

@ -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();
}
}

View File

@ -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)
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())
+ ".");
}
}

View File

@ -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) {

View File

@ -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<EntityType, Float> 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);

View File

@ -89,13 +89,14 @@ public class CitizensHumanNPC extends CitizensNPC implements Equipable {
trait.set(i, null);
}
}
Messaging.sendF(equipper, "<e>%s<a>had all of its items removed.", getName());
Messaging.sendF(equipper, "<e>%s<a> 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) {

View File

@ -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;
}