Misc. fixes

This commit is contained in:
fullwall 2013-03-16 13:28:26 +08:00
parent d8e7c79c89
commit 482eb05766
7 changed files with 23 additions and 15 deletions

View File

@ -182,8 +182,9 @@ public class EventListen implements Listener {
@EventHandler
public void onNPCDespawn(NPCDespawnEvent event) {
if (event.getReason() == DespawnReason.PLUGIN || event.getReason() == DespawnReason.REMOVAL)
if (event.getReason() == DespawnReason.PLUGIN || event.getReason() == DespawnReason.REMOVAL) {
toRespawn.remove(toCoord(event.getNPC().getBukkitEntity().getLocation()), event.getNPC());
}
}
@EventHandler(ignoreCancelled = true)

View File

@ -1170,9 +1170,14 @@ public class NPCCommands {
wolf.setSitting(args.hasFlag('s'));
wolf.setTamed(args.hasFlag('t'));
if (args.hasValueFlag("collar")) {
String unparsed = args.getFlag("colour");
int rgb = Integer.parseInt(unparsed.replace("#", ""));
DyeColor color = DyeColor.getByColor(org.bukkit.Color.fromRGB(rgb));
String unparsed = args.getFlag("collar");
DyeColor color = null;
try {
DyeColor.valueOf(unparsed.toUpperCase().replace(' ', '_'));
} catch (IllegalArgumentException e) {
int rgb = Integer.parseInt(unparsed.replace("#", ""));
color = DyeColor.getByColor(org.bukkit.Color.fromRGB(rgb));
}
if (color == null)
throw new CommandException(Messages.COLLAR_COLOUR_NOT_RECOGNISED);
wolf.setCollarColor(color);

View File

@ -33,17 +33,17 @@ public class WaypointCommands {
@Command(
aliases = { "waypoints", "waypoint", "wp" },
usage = "provider [provider name] (-a)",
usage = "provider [provider name] (-d)",
desc = "Sets the current waypoint provider",
modifiers = { "provider" },
min = 1,
max = 2,
flags = "a",
flags = "d",
permission = "citizens.waypoints.provider")
public void provider(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
Waypoints waypoints = npc.getTrait(Waypoints.class);
if (args.argsLength() == 1) {
if (args.hasFlag('a')) {
if (args.hasFlag('d')) {
waypoints.describeProviders(sender);
} else
Messaging.sendTr(sender, Messages.CURRENT_WAYPOINT_PROVIDER, waypoints.getCurrentProviderName());

View File

@ -69,7 +69,7 @@ public class CitizensNPC extends AbstractNPC {
for (Trait trait : traits.values())
trait.onDespawn();
entityController.remove();
navigator.onDespawn();
return true;
}

View File

@ -93,6 +93,10 @@ public class CitizensNavigator implements Navigator, Runnable {
defaultParams.stuckAction(null);
}
public void onDespawn() {
stopNavigating(CancelReason.NPC_DESPAWNED);
}
public void onSpawn() {
if (defaultParams.baseSpeed() == UNINITIALISED_SPEED)
defaultParams.baseSpeed(NMS.getSpeedFor(npc));
@ -103,11 +107,6 @@ public class CitizensNavigator implements Navigator, Runnable {
public void run() {
if (!isNavigating())
return;
if (!npc.isSpawned()) {
if (isNavigating())
stopNavigating(CancelReason.NPC_DESPAWNED);
return;
}
if (updateStationaryStatus())
return;
updatePathfindingRange();
@ -235,5 +234,6 @@ public class CitizensNavigator implements Navigator, Runnable {
}
private static final Location STATIONARY_LOCATION = new Location(null, 0, 0, 0);
private static int UNINITIALISED_SPEED = Integer.MIN_VALUE;
}

View File

@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
public class WanderWaypointProvider implements WaypointProvider {
private Goal currentGoal;
private volatile boolean paused;
private int xrange, yrange;
private int xrange = DEFAULT_XRANGE, yrange = DEFAULT_YRANGE;
@Override
public WaypointEditor createEditor(Player player) {

View File

@ -275,8 +275,10 @@ public class NMS {
yaw -= 360.0F;
}
handle.aA = yaw;
if (!(handle instanceof EntityHuman))
if (!(handle instanceof EntityHuman)) {
handle.ay = yaw;
handle.az = yaw;
}
}
public static void setLandSpeedModifier(EntityLiving handle, float speed) {