diff --git a/src/main/java/net/citizensnpcs/Citizens.java b/src/main/java/net/citizensnpcs/Citizens.java index 4508ed096..6f105df9d 100644 --- a/src/main/java/net/citizensnpcs/Citizens.java +++ b/src/main/java/net/citizensnpcs/Citizens.java @@ -8,6 +8,8 @@ import java.util.Iterator; import net.citizensnpcs.Settings.Setting; import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.CitizensPlugin; +import net.citizensnpcs.api.event.CitizensDisableEvent; +import net.citizensnpcs.api.event.CitizensEnableEvent; import net.citizensnpcs.api.event.CitizensReloadEvent; import net.citizensnpcs.api.exception.NPCLoadException; import net.citizensnpcs.api.npc.NPC; @@ -225,6 +227,7 @@ public class Citizens extends JavaPlugin implements CitizensPlugin { startMetrics(); enableSubPlugins(); scheduleSaveTask(Setting.SAVE_TASK_DELAY.asInt()); + Bukkit.getPluginManager().callEvent(new CitizensEnableEvent()); } }) == -1) { Messaging.severe("NPC load task couldn't be scheduled - disabling..."); diff --git a/src/main/java/net/citizensnpcs/CitizensDisableEvent.java b/src/main/java/net/citizensnpcs/CitizensDisableEvent.java deleted file mode 100644 index 5407ad970..000000000 --- a/src/main/java/net/citizensnpcs/CitizensDisableEvent.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.citizensnpcs; - -import net.citizensnpcs.api.event.CitizensEvent; - -import org.bukkit.event.HandlerList; - -public class CitizensDisableEvent extends CitizensEvent { - @Override - public HandlerList getHandlers() { - return handlers; - } - - private static final HandlerList handlers = new HandlerList(); - - public static HandlerList getHandlerList() { - return handlers; - } -} diff --git a/src/main/java/net/citizensnpcs/command/CommandContext.java b/src/main/java/net/citizensnpcs/command/CommandContext.java index 7eaf07cd1..b1bb13688 100644 --- a/src/main/java/net/citizensnpcs/command/CommandContext.java +++ b/src/main/java/net/citizensnpcs/command/CommandContext.java @@ -89,7 +89,7 @@ public class CommandContext { } List copied = Lists.newArrayList(); for (String arg : args) { - if (arg == null || arg.isEmpty()) + if (arg == null || arg.trim().isEmpty()) continue; copied.add(arg); } @@ -178,7 +178,7 @@ public class CommandContext { StringBuilder buffer = new StringBuilder(args[initialIndex]); for (int i = initialIndex + 1; i < args.length; i++) buffer.append(delimiter).append(args[i]); - return buffer.toString(); + return buffer.toString().trim(); } public String[] getPaddedSlice(int index, int padding) { diff --git a/src/main/java/net/citizensnpcs/command/command/AdminCommands.java b/src/main/java/net/citizensnpcs/command/command/AdminCommands.java index b1ea89d58..e46ad4f1a 100644 --- a/src/main/java/net/citizensnpcs/command/command/AdminCommands.java +++ b/src/main/java/net/citizensnpcs/command/command/AdminCommands.java @@ -22,8 +22,10 @@ public class AdminCommands { @Command(aliases = { "citizens" }, desc = "Show basic plugin information", max = 0, permission = "admin") public void citizens(CommandContext args, CommandSender player, NPC npc) { - Messaging.send(player, - " " + StringHelper.wrapHeader("Citizens v" + plugin.getDescription().getVersion())); + Messaging.send( + player, + " " + + StringHelper.wrapHeader("Citizens v" + plugin.getDescription().getVersion())); Messaging.send(player, " <7>-- Written by fullwall and aPunch"); Messaging.send(player, " <7>-- Source: http://github.com/CitizensDev"); Messaging.send(player, " <7>-- Website: " + plugin.getDescription().getWebsite()); diff --git a/src/main/java/net/citizensnpcs/command/command/NPCCommands.java b/src/main/java/net/citizensnpcs/command/command/NPCCommands.java index cc776d146..bb0bc916e 100644 --- a/src/main/java/net/citizensnpcs/command/command/NPCCommands.java +++ b/src/main/java/net/citizensnpcs/command/command/NPCCommands.java @@ -202,11 +202,13 @@ public class NPCCommands { } } if (args.hasValueFlag("trait")) { + msg += " with traits "; Iterable parts = Splitter.on(",").trimResults().split(args.getFlag("trait")); for (String tr : parts) { Class clazz = CitizensAPI.getTraitFactory().getTraitClass(tr); - if (clazz != null) + if (clazz != null) { npc.addTrait(clazz); + } } msg += " with the specified traits"; } @@ -374,6 +376,12 @@ public class NPCCommands { Messaging.send(sender, StringHelper.wrapHeader(npc.getName())); Messaging.send(sender, " ID: " + npc.getId()); Messaging.send(sender, " Type: " + npc.getTrait(MobType.class).getType()); + Messaging.send(sender, " Traits"); + for (Trait trait : npc.getTraits()) { + if (CitizensAPI.getTraitFactory().isInternalTrait(trait)) + continue; + Messaging.send(sender, " - " + trait.getName() + ""); + } } @Command( diff --git a/src/main/java/net/citizensnpcs/npc/CitizensTraitFactory.java b/src/main/java/net/citizensnpcs/npc/CitizensTraitFactory.java index 45490d1c0..f4dd0de0e 100644 --- a/src/main/java/net/citizensnpcs/npc/CitizensTraitFactory.java +++ b/src/main/java/net/citizensnpcs/npc/CitizensTraitFactory.java @@ -104,7 +104,12 @@ public class CitizensTraitFactory implements TraitFactory { @Override public Class getTraitClass(String name) { - return registered.get(name); + return registered.get(name.toLowerCase()); + } + + @Override + public boolean isInternalTrait(Trait trait) { + return INTERNAL_TRAITS.contains(trait.getName()); } @Override diff --git a/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java b/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java index 540f66494..535bca03a 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java +++ b/src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java @@ -41,6 +41,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder { netServerHandler = new EmptyNetHandler(minecraftServer, netMgr, this); netMgr.a(netServerHandler); + W = STEP_HEIGHT; // fix moving up slabs and steps try { socket.close(); @@ -89,7 +90,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder { navigation.e(); moveOnCurrentHeading(); } else if (motX != 0 || motZ != 0 || motY != 0) { - // a(0, 0); + // e(0, 0); is this necessary? it does gravity/controllable but + // sometimes players sink into the ground } if (noDamageTicks > 0) --noDamageTicks; @@ -101,7 +103,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder { getControllerLook().a(); getControllerJump().b(); - // taken from EntityLiving + // taken from EntityLiving update method if (bu) { boolean inLiquid = H() || J(); if (inLiquid) { @@ -114,10 +116,16 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder { } else { bE = 0; } - + br *= 0.98F; bs *= 0.98F; + bt *= 0.9F; + + float prev = aG; aG *= bs(); - e(br, bs); - as = yaw; + e(br, bs); // movement method + aG = prev; + as = yaw; // update head yaw to match entity yaw } + + private static final float STEP_HEIGHT = 1F; } \ No newline at end of file