From 432d9d7855f90059526807d90476c1973f237d8d Mon Sep 17 00:00:00 2001 From: fullwall Date: Sun, 22 Mar 2015 16:30:30 +0800 Subject: [PATCH] Add messages for /npc sheep --- .../citizensnpcs/commands/NPCCommands.java | 11 ++++-- .../npc/entity/EnderDragonController.java | 39 ++++++++++--------- .../java/net/citizensnpcs/util/Messages.java | 2 + 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/main/java/net/citizensnpcs/commands/NPCCommands.java b/src/main/java/net/citizensnpcs/commands/NPCCommands.java index 84c0b83e8..e2120f26f 100644 --- a/src/main/java/net/citizensnpcs/commands/NPCCommands.java +++ b/src/main/java/net/citizensnpcs/commands/NPCCommands.java @@ -272,7 +272,7 @@ public class NPCCommands { } CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, copy) - : new CommandSenderCreateNPCEvent(sender, copy); + : new CommandSenderCreateNPCEvent(sender, copy); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { event.getNPC().destroy(); @@ -348,7 +348,7 @@ public class NPCCommands { spawnLoc = args.getSenderLocation(); } CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, npc) - : new CommandSenderCreateNPCEvent(sender, npc); + : new CommandSenderCreateNPCEvent(sender, npc); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) { npc.destroy(); @@ -1025,7 +1025,7 @@ public class NPCCommands { @Requirements(selected = true, ownership = true, types = { EntityType.CREEPER }) public void power(CommandContext args, CommandSender sender, NPC npc) { Messaging - .sendTr(sender, npc.getTrait(Powered.class).toggle() ? Messages.POWERED_SET : Messages.POWERED_STOPPED); + .sendTr(sender, npc.getTrait(Powered.class).toggle() ? Messages.POWERED_SET : Messages.POWERED_STOPPED); } @Command( @@ -1063,7 +1063,7 @@ public class NPCCommands { } @Command(aliases = { "npc" }, usage = "remove|rem (all|id|name)", desc = "Remove a NPC", modifiers = { "remove", - "rem" }, min = 1, max = 2) + "rem" }, min = 1, max = 2) @Requirements public void remove(final CommandContext args, final CommandSender sender, NPC npc) throws CommandException { if (args.argsLength() == 2) { @@ -1209,6 +1209,9 @@ public class NPCCommands { DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("color")); if (color != null) { trait.setColor(color); + Messaging.sendTr(sender, Messages.SHEEP_COLOR_SET, color.toString().toLowerCase()); + } else { + Messaging.sendErrorTr(sender, Messages.INVALID_SHEEP_COLOR, Util.listValuesPretty(DyeColor.values())); } } } diff --git a/src/main/java/net/citizensnpcs/npc/entity/EnderDragonController.java b/src/main/java/net/citizensnpcs/npc/entity/EnderDragonController.java index ab59c8e06..55e310972 100644 --- a/src/main/java/net/citizensnpcs/npc/entity/EnderDragonController.java +++ b/src/main/java/net/citizensnpcs/npc/entity/EnderDragonController.java @@ -79,6 +79,7 @@ public class EnderDragonController extends MobEntityController { } return false; // shouldLeash } + @Override public void collide(net.minecraft.server.v1_8_R2.Entity entity) { // this method is called by both the entities involved - cancelling @@ -94,18 +95,9 @@ public class EnderDragonController extends MobEntityController { } @Override - public void m() { - if (npc != null) { - npc.update(); - if (motX != 0 || motY != 0 || motZ != 0) { - motX *= 0.98; - motY *= 0.98; - motZ *= 0.98; - yaw = getCorrectYaw(locX + motX, locZ + motZ); - setPosition(locX + motX, locY + motY, locZ + motZ); - } - } else { - super.m(); + protected void D() { + if (npc == null) { + super.D(); } } @@ -152,17 +144,26 @@ public class EnderDragonController extends MobEntityController { return npc; } + @Override + public void m() { + if (npc != null) { + npc.update(); + if (motX != 0 || motY != 0 || motZ != 0) { + motX *= 0.98; + motY *= 0.98; + motZ *= 0.98; + yaw = getCorrectYaw(locX + motX, locZ + motZ); + setPosition(locX + motX, locY + motY, locZ + motZ); + } + } else { + super.m(); + } + } + @Override protected String z() { return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get( NPC.AMBIENT_SOUND_METADATA, super.z()); } - - @Override - protected void D() { - if (npc == null) { - super.D(); - } - } } } \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/util/Messages.java b/src/main/java/net/citizensnpcs/util/Messages.java index 4952fe588..42b4feb92 100644 --- a/src/main/java/net/citizensnpcs/util/Messages.java +++ b/src/main/java/net/citizensnpcs/util/Messages.java @@ -102,6 +102,7 @@ public class Messages { public static final String INVALID_POSE_NAME = "citizens.commands.npc.pose.invalid-name"; public static final String INVALID_PROFESSION = "citizens.commands.npc.profession.invalid-profession"; public static final String INVALID_RABBIT_TYPE = "citizens.commands.npc.rabbittype.invalid-type"; + public static final String INVALID_SHEEP_COLOR = "citizens.commands.npc.sheep.invalid-color"; public static final String INVALID_SKELETON_TYPE = "citizens.commands.npc.skeletontype.invalid-type"; public static final String INVALID_SOUND = "citizens.commands.npc.sound.invalid-sound"; public static final String INVALID_SPAWN_LOCATION = "citizens.commands.npc.create.invalid-location"; @@ -184,6 +185,7 @@ public class Messages { public static final String SELECTION_PROMPT_INVALID_CHOICE = "citizens.conversations.selection.invalid-choice"; public static final String SHEARED_SET = "citizens.editors.equipment.sheared-set"; public static final String SHEARED_STOPPED = "citizens.editors.equipment.sheared-stopped"; + public static final String SHEEP_COLOR_SET = "citizens.commands.npc.sheep.color-set"; public static final String SIZE_DESCRIPTION = "citizens.commands.npc.size.description"; public static final String SIZE_SET = "citizens.commands.npc.size.set"; public static final String SKELETON_TYPE_SET = "citizens.commands.npc.skeletontype.set";