mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-10 21:02:36 +01:00
C:/Program Files/Git/npc copy bugfix
This commit is contained in:
parent
9d8c17c376
commit
0fbacb6dc7
@ -90,8 +90,8 @@ public class NPCCommands {
|
||||
min = 1,
|
||||
max = 2,
|
||||
permission = "npc.age")
|
||||
@Requirements(selected = true, ownership = true, types = { EntityType.CHICKEN, EntityType.COW,
|
||||
EntityType.OCELOT, EntityType.PIG, EntityType.SHEEP, EntityType.VILLAGER, EntityType.WOLF })
|
||||
@Requirements(selected = true, ownership = true, types = { EntityType.CHICKEN, EntityType.COW, EntityType.OCELOT,
|
||||
EntityType.PIG, EntityType.SHEEP, EntityType.VILLAGER, EntityType.WOLF })
|
||||
public void age(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||
Age trait = npc.getTrait(Age.class);
|
||||
|
||||
@ -148,8 +148,7 @@ public class NPCCommands {
|
||||
Messaging.sendTr(sender, Messages.ANCHOR_ADDED);
|
||||
} else
|
||||
throw new CommandException(Messages.ANCHOR_ALREADY_EXISTS, args.getFlag("save"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (trait.addAnchor(args.getFlag("save"), args.getSenderLocation())) {
|
||||
Messaging.sendTr(sender, Messages.ANCHOR_ADDED);
|
||||
} else
|
||||
@ -252,8 +251,9 @@ public class NPCCommands {
|
||||
from.save(key);
|
||||
copy.load(key);
|
||||
|
||||
if (copy.isSpawned() && args.getSenderLocation() != null) {
|
||||
if (from.isSpawned() && args.getSenderLocation() != null) {
|
||||
Location location = args.getSenderLocation();
|
||||
location.getChunk().load();
|
||||
copy.getBukkitEntity().teleport(location);
|
||||
copy.getTrait(CurrentLocation.class).setLocation(location);
|
||||
}
|
||||
@ -301,8 +301,8 @@ public class NPCCommands {
|
||||
int age = 0;
|
||||
if (args.hasFlag('b')) {
|
||||
if (!Ageable.class.isAssignableFrom(type.getEntityClass()))
|
||||
Messaging.sendErrorTr(sender, Messages.MOBTYPE_CANNOT_BE_AGED, type.name().toLowerCase()
|
||||
.replace("_", "-"));
|
||||
Messaging.sendErrorTr(sender, Messages.MOBTYPE_CANNOT_BE_AGED,
|
||||
type.name().toLowerCase().replace("_", "-"));
|
||||
else {
|
||||
age = -24000;
|
||||
msg += " as a baby";
|
||||
@ -341,8 +341,8 @@ public class NPCCommands {
|
||||
if (args.hasValueFlag("at")) {
|
||||
String[] parts = Iterables.toArray(Splitter.on(':').split(args.getFlag("at")), String.class);
|
||||
if (parts.length > 0) {
|
||||
String worldName = args.getSenderLocation() != null ? args.getSenderLocation().getWorld()
|
||||
.getName() : "";
|
||||
String worldName = args.getSenderLocation() != null ? args.getSenderLocation().getWorld().getName()
|
||||
: "";
|
||||
int x = 0, y = 0, z = 0;
|
||||
float yaw = 0F, pitch = 0F;
|
||||
switch (parts.length) {
|
||||
@ -590,8 +590,7 @@ public class NPCCommands {
|
||||
Location current = npc.getBukkitEntity().getLocation();
|
||||
Location to;
|
||||
if (args.argsLength() > 1) {
|
||||
String[] parts = Iterables.toArray(Splitter.on(':').split(args.getJoinedStrings(1, ':')),
|
||||
String.class);
|
||||
String[] parts = Iterables.toArray(Splitter.on(':').split(args.getJoinedStrings(1, ':')), String.class);
|
||||
if (parts.length != 4 && parts.length != 3)
|
||||
throw new CommandException(Messages.MOVETO_FORMAT);
|
||||
double x = Double.parseDouble(parts[0]);
|
||||
@ -634,8 +633,8 @@ public class NPCCommands {
|
||||
if (npc.isSpawned()) {
|
||||
Location loc = npc.getBukkitEntity().getLocation();
|
||||
String format = " <a>Spawned at <e>%d, %d, %d <a>in world<e> %s";
|
||||
Messaging.send(sender, String.format(format, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(),
|
||||
loc.getWorld().getName()));
|
||||
Messaging.send(sender,
|
||||
String.format(format, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), loc.getWorld().getName()));
|
||||
}
|
||||
Messaging.send(sender, " <a>Traits<e>");
|
||||
for (Trait trait : npc.getTraits()) {
|
||||
@ -665,18 +664,11 @@ public class NPCCommands {
|
||||
throw new CommandException(Messages.ALREADY_OWNER, name, npc.getName());
|
||||
ownerTrait.setOwner(name);
|
||||
boolean serverOwner = name.equalsIgnoreCase(Owner.SERVER);
|
||||
Messaging.sendTr(sender, serverOwner ? Messages.OWNER_SET_SERVER : Messages.OWNER_SET, npc.getName(),
|
||||
name);
|
||||
Messaging.sendTr(sender, serverOwner ? Messages.OWNER_SET_SERVER : Messages.OWNER_SET, npc.getName(), name);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "pathrange [range]",
|
||||
desc = "Sets an NPC's pathfinding range",
|
||||
modifiers = { "pathrange", "pathfindingrange", "prange" },
|
||||
min = 2,
|
||||
max = 2,
|
||||
permission = "npc.pathfindingrange")
|
||||
@Command(aliases = { "npc" }, usage = "pathrange [range]", desc = "Sets an NPC's pathfinding range", modifiers = {
|
||||
"pathrange", "pathfindingrange", "prange" }, min = 2, max = 2, permission = "npc.pathfindingrange")
|
||||
public void pathfindingRange(CommandContext args, CommandSender sender, NPC npc) {
|
||||
double range = Math.max(1, args.getDouble(1));
|
||||
npc.getNavigator().getDefaultParameters().range((float) range);
|
||||
@ -694,8 +686,7 @@ public class NPCCommands {
|
||||
permission = "npc.playerlist")
|
||||
@Requirements(types = EntityType.PLAYER)
|
||||
public void playerlist(CommandContext args, CommandSender sender, NPC npc) {
|
||||
boolean remove = !npc.data().get("removefromplayerlist",
|
||||
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
||||
boolean remove = !npc.data().get("removefromplayerlist", Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
||||
if (args.hasFlag('a'))
|
||||
remove = false;
|
||||
else if (args.hasFlag('r'))
|
||||
@ -768,8 +759,8 @@ public class NPCCommands {
|
||||
permission = "npc.power")
|
||||
@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);
|
||||
Messaging
|
||||
.sendTr(sender, npc.getTrait(Powered.class).toggle() ? Messages.POWERED_SET : Messages.POWERED_STOPPED);
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -793,8 +784,13 @@ public class NPCCommands {
|
||||
Messaging.sendTr(sender, Messages.PROFESSION_SET, npc.getName(), profession);
|
||||
}
|
||||
|
||||
@Command(aliases = { "npc" }, usage = "remove|rem (all)", desc = "Remove a NPC", modifiers = { "remove",
|
||||
"rem" }, min = 1, max = 2)
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "remove|rem (all)",
|
||||
desc = "Remove a NPC",
|
||||
modifiers = { "remove", "rem" },
|
||||
min = 1,
|
||||
max = 2)
|
||||
@Requirements
|
||||
public void remove(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||
if (args.argsLength() == 2) {
|
||||
@ -863,8 +859,7 @@ public class NPCCommands {
|
||||
Collections.sort(search, new Comparator<Entity>() {
|
||||
@Override
|
||||
public int compare(Entity o1, Entity o2) {
|
||||
double d = o1.getLocation().distanceSquared(location)
|
||||
- o2.getLocation().distanceSquared(location);
|
||||
double d = o1.getLocation().distanceSquared(location) - o2.getLocation().distanceSquared(location);
|
||||
return d > 0 ? 1 : d < 0 ? -1 : 0;
|
||||
}
|
||||
});
|
||||
@ -902,18 +897,12 @@ public class NPCCommands {
|
||||
Messaging.sendWithNPC(sender, Setting.SELECTION_MESSAGE.asString(), toSelect);
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "skeletontype [type]",
|
||||
desc = "Sets the NPC's skeleton type",
|
||||
modifiers = { "skeletontype", "sktype" },
|
||||
min = 2,
|
||||
max = 2,
|
||||
permission = "npc.skeletontype")
|
||||
@Command(aliases = { "npc" }, usage = "skeletontype [type]", desc = "Sets the NPC's skeleton type", modifiers = {
|
||||
"skeletontype", "sktype" }, min = 2, max = 2, permission = "npc.skeletontype")
|
||||
@Requirements(selected = true, ownership = true, types = EntityType.SKELETON)
|
||||
public void skeletonType(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||
SkeletonType type = (type = SkeletonType.getType(args.getInteger(1))) == null ? SkeletonType
|
||||
.valueOf(args.getString(1)) : type;
|
||||
SkeletonType type = (type = SkeletonType.getType(args.getInteger(1))) == null ? SkeletonType.valueOf(args
|
||||
.getString(1)) : type;
|
||||
if (type == null)
|
||||
throw new CommandException(Messages.INVALID_SKELETON_TYPE);
|
||||
npc.getTrait(NPCSkeletonType.class).setType(type);
|
||||
@ -982,7 +971,8 @@ public class NPCCommands {
|
||||
String message = StringHelper.parseColors(args.getJoinedStrings(1));
|
||||
|
||||
if (message.length() <= 0) {
|
||||
Messaging.send(sender, "Default Vocal Chord for " + npc.getName() + ": " + npc.getTrait(Speech.class).getDefaultVocalChord());
|
||||
Messaging.send(sender, "Default Vocal Chord for " + npc.getName() + ": "
|
||||
+ npc.getTrait(Speech.class).getDefaultVocalChord());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1039,8 +1029,8 @@ public class NPCCommands {
|
||||
Messaging.sendTr(player, Messages.TELEPORTED_TO_NPC, npc.getName());
|
||||
}
|
||||
|
||||
@Command(aliases = { "npc" }, usage = "tphere", desc = "Teleport a NPC to your location", modifiers = {
|
||||
"tphere", "tph", "move" }, min = 1, max = 1, permission = "npc.tphere")
|
||||
@Command(aliases = { "npc" }, usage = "tphere", desc = "Teleport a NPC to your location", modifiers = { "tphere",
|
||||
"tph", "move" }, min = 1, max = 1, permission = "npc.tphere")
|
||||
public void tphere(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||
if (args.getSenderLocation() == null)
|
||||
throw new ServerCommandException();
|
||||
@ -1102,13 +1092,12 @@ public class NPCCommands {
|
||||
ZombieModifier trait = npc.getTrait(ZombieModifier.class);
|
||||
if (args.hasFlag('b')) {
|
||||
boolean isBaby = trait.toggleBaby();
|
||||
Messaging.sendTr(sender, isBaby ? Messages.ZOMBIE_BABY_SET : Messages.ZOMBIE_BABY_UNSET,
|
||||
npc.getName());
|
||||
Messaging.sendTr(sender, isBaby ? Messages.ZOMBIE_BABY_SET : Messages.ZOMBIE_BABY_UNSET, npc.getName());
|
||||
}
|
||||
if (args.hasFlag('v')) {
|
||||
boolean isVillager = trait.toggleVillager();
|
||||
Messaging.sendTr(sender, isVillager ? Messages.ZOMBIE_VILLAGER_SET
|
||||
: Messages.ZOMBIE_VILLAGER_UNSET, npc.getName());
|
||||
Messaging.sendTr(sender, isVillager ? Messages.ZOMBIE_VILLAGER_SET : Messages.ZOMBIE_VILLAGER_UNSET,
|
||||
npc.getName());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user