Skip to content

Commit

Permalink
Add messages for /npc sheep
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Mar 22, 2015
1 parent a364cf5 commit 5f3856d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 23 deletions.
11 changes: 7 additions & 4 deletions src/main/java/net/citizensnpcs/commands/NPCCommands.java
Expand Up @@ -272,7 +272,7 @@ public void copy(CommandContext args, CommandSender sender, NPC npc) throws Comm
}

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();
Expand Down Expand Up @@ -348,7 +348,7 @@ public void create(CommandContext args, CommandSender sender, NPC npc) throws Co
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();
Expand Down Expand Up @@ -1025,7 +1025,7 @@ public void pose(CommandContext args, CommandSender sender, NPC npc) throws Comm
@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(
Expand Down Expand Up @@ -1063,7 +1063,7 @@ public void rabbitType(CommandContext args, CommandSender sender, NPC npc) throw
}

@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) {
Expand Down Expand Up @@ -1209,6 +1209,9 @@ public void sheep(CommandContext args, CommandSender sender, NPC npc) {
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()));
}
}
}
Expand Down
Expand Up @@ -79,6 +79,7 @@ public boolean cc() {
}
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
Expand All @@ -94,18 +95,9 @@ public boolean d(NBTTagCompound save) {
}

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

Expand Down Expand Up @@ -153,16 +145,25 @@ public NPC getNPC() {
}

@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());
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 void D() {
if (npc == null) {
super.D();
}
protected String z() {
return npc == null || !npc.data().has(NPC.AMBIENT_SOUND_METADATA) ? super.z() : npc.data().get(
NPC.AMBIENT_SOUND_METADATA, super.z());
}
}
}
2 changes: 2 additions & 0 deletions src/main/java/net/citizensnpcs/util/Messages.java
Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 5f3856d

Please sign in to comment.