mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-24 11:38:26 +01:00
Fix equipment editing
This commit is contained in:
parent
6f30ed3496
commit
7158aa6bfb
@ -67,8 +67,8 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
|||||||
Iterator<NPC> itr = npcRegistry.iterator();
|
Iterator<NPC> itr = npcRegistry.iterator();
|
||||||
while (itr.hasNext()) {
|
while (itr.hasNext()) {
|
||||||
NPC npc = itr.next();
|
NPC npc = itr.next();
|
||||||
itr.remove();
|
|
||||||
npc.despawn();
|
npc.despawn();
|
||||||
|
itr.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
|||||||
enableSubPlugins();
|
enableSubPlugins();
|
||||||
}
|
}
|
||||||
}) == -1) {
|
}) == -1) {
|
||||||
Messaging.severe("Issue enabling plugin. Disabling.");
|
Messaging.severe("NPC load task couldn't be scheduled - disabling...");
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,8 +169,8 @@ public class EventListen implements Listener {
|
|||||||
if (!npc.isSpawned() || !npc.getBukkitEntity().getWorld().equals(event.getWorld()))
|
if (!npc.isSpawned() || !npc.getBukkitEntity().getWorld().equals(event.getWorld()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
npc.despawn();
|
|
||||||
storeForRespawn(npc);
|
storeForRespawn(npc);
|
||||||
|
npc.despawn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,14 +465,16 @@ public class NPCCommands {
|
|||||||
+ " Use '/npc tphere' to teleport the NPC to your location.");
|
+ " Use '/npc tphere' to teleport the NPC to your location.");
|
||||||
|
|
||||||
Location location = respawn.getTrait(CurrentLocation.class).getLocation();
|
Location location = respawn.getTrait(CurrentLocation.class).getLocation();
|
||||||
if (location == null && sender instanceof Player)
|
if (location == null) {
|
||||||
|
if (sender instanceof Player)
|
||||||
location = ((Player) sender).getLocation();
|
location = ((Player) sender).getLocation();
|
||||||
else
|
else
|
||||||
throw new CommandException("No stored location available - command must be used ingame.");
|
throw new CommandException("No stored location available - command must be used ingame.");
|
||||||
|
}
|
||||||
if (respawn.spawn(location)) {
|
if (respawn.spawn(location)) {
|
||||||
selector.select(sender, respawn);
|
selector.select(sender, respawn);
|
||||||
Messaging.send(sender, ChatColor.GREEN + "You respawned " + StringHelper.wrap(respawn.getName())
|
Messaging.send(sender, ChatColor.GREEN + "You spawned " + StringHelper.wrap(respawn.getName())
|
||||||
+ " at your location.");
|
+ ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,8 +39,8 @@ public class EquipmentEditor extends Editor {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||||
if (!npc.equals(CitizensAPI.getNPCRegistry().getNPC(event.getRightClicked()))
|
if (!event.getPlayer().equals(player)
|
||||||
|| !event.getPlayer().equals(player))
|
|| !npc.equals(CitizensAPI.getNPCRegistry().getNPC(event.getRightClicked())))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (npc instanceof Equipable) {
|
if (npc instanceof Equipable) {
|
||||||
|
@ -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 final Map<EntityType, Float> MOVEMENT_SPEEDS = Maps.newEnumMap(EntityType.class);
|
||||||
private static Field SPEED_FIELD;
|
private static Field SPEED_FIELD;
|
||||||
static {
|
static {
|
||||||
|
|
||||||
MOVEMENT_SPEEDS.put(EntityType.IRON_GOLEM, 0.15F);
|
MOVEMENT_SPEEDS.put(EntityType.IRON_GOLEM, 0.15F);
|
||||||
MOVEMENT_SPEEDS.put(EntityType.CHICKEN, 0.25F);
|
MOVEMENT_SPEEDS.put(EntityType.CHICKEN, 0.25F);
|
||||||
MOVEMENT_SPEEDS.put(EntityType.COW, 0.2F);
|
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.VILLAGER, 0.3F);
|
||||||
MOVEMENT_SPEEDS.put(EntityType.SNOWMAN, 0.25F);
|
MOVEMENT_SPEEDS.put(EntityType.SNOWMAN, 0.25F);
|
||||||
MOVEMENT_SPEEDS.put(EntityType.CREEPER, 0.3F);
|
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 {
|
try {
|
||||||
SPEED_FIELD = EntityLiving.class.getDeclaredField("bb");
|
SPEED_FIELD = EntityLiving.class.getDeclaredField("bb");
|
||||||
SPEED_FIELD.setAccessible(true);
|
SPEED_FIELD.setAccessible(true);
|
||||||
|
@ -94,8 +94,9 @@ public class CitizensHumanNPC extends CitizensNPC implements Equipable {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Drop any previous equipment on the ground
|
// Drop any previous equipment on the ground
|
||||||
if (trait.get(slot) != null && trait.get(slot).getType() != Material.AIR)
|
ItemStack equippedItem = trait.get(slot);
|
||||||
equipper.getWorld().dropItemNaturally(getBukkitEntity().getLocation(), trait.get(slot));
|
if (equippedItem != null && equippedItem.getType() != Material.AIR)
|
||||||
|
equipper.getWorld().dropItemNaturally(getBukkitEntity().getLocation(), equippedItem);
|
||||||
|
|
||||||
// Now edit the equipment based on the slot
|
// Now edit the equipment based on the slot
|
||||||
if (type != Material.AIR) {
|
if (type != Material.AIR) {
|
||||||
|
@ -57,7 +57,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
|||||||
moveOnCurrentHeading();
|
moveOnCurrentHeading();
|
||||||
} else if (motX != 0 || motZ != 0 || motY != 0) {
|
} else if (motX != 0 || motZ != 0 || motY != 0) {
|
||||||
// a(0, 0);
|
// a(0, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (noDamageTicks > 0)
|
if (noDamageTicks > 0)
|
||||||
--noDamageTicks;
|
--noDamageTicks;
|
||||||
@ -80,7 +79,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
|||||||
if (inLiquid) {
|
if (inLiquid) {
|
||||||
motY += 0.04;
|
motY += 0.04;
|
||||||
} else if (onGround && q == 0) {
|
} else if (onGround && q == 0) {
|
||||||
// ac(); - this doesn't jump high enough
|
// this.ac(); - this doesn't jump high enough
|
||||||
motY = 0.6;
|
motY = 0.6;
|
||||||
q = 10;
|
q = 10;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user