mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 18:45:29 +01:00
Use new getOrAddTrait methodf
This commit is contained in:
parent
450bff76ec
commit
7450c4db45
@ -130,7 +130,7 @@ public class EventListen implements Listener {
|
|||||||
int owned = 0;
|
int owned = 0;
|
||||||
for (NPC npc : CitizensAPI.getNPCRegistry()) {
|
for (NPC npc : CitizensAPI.getNPCRegistry()) {
|
||||||
if (!event.getNPC().equals(npc) && npc.hasTrait(Owner.class)
|
if (!event.getNPC().equals(npc) && npc.hasTrait(Owner.class)
|
||||||
&& npc.getTrait(Owner.class).isOwnedBy(event.getCreator())) {
|
&& npc.getTraitNullable(Owner.class).isOwnedBy(event.getCreator())) {
|
||||||
owned++;
|
owned++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -263,7 +263,7 @@ public class EventListen implements Listener {
|
|||||||
Player damager = (Player) damageEvent.getDamager();
|
Player damager = (Player) damageEvent.getDamager();
|
||||||
|
|
||||||
if (npc.hasTrait(ClickRedirectTrait.class)) {
|
if (npc.hasTrait(ClickRedirectTrait.class)) {
|
||||||
npc = npc.getTrait(ClickRedirectTrait.class).getRedirectNPC();
|
npc = npc.getTraitNullable(ClickRedirectTrait.class).getRedirectNPC();
|
||||||
if (npc == null)
|
if (npc == null)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -271,7 +271,7 @@ public class EventListen implements Listener {
|
|||||||
NPCLeftClickEvent leftClickEvent = new NPCLeftClickEvent(npc, damager);
|
NPCLeftClickEvent leftClickEvent = new NPCLeftClickEvent(npc, damager);
|
||||||
Bukkit.getPluginManager().callEvent(leftClickEvent);
|
Bukkit.getPluginManager().callEvent(leftClickEvent);
|
||||||
if (npc.hasTrait(CommandTrait.class)) {
|
if (npc.hasTrait(CommandTrait.class)) {
|
||||||
npc.getTrait(CommandTrait.class).dispatch(damager, CommandTrait.Hand.LEFT);
|
npc.getTraitNullable(CommandTrait.class).dispatch(damager, CommandTrait.Hand.LEFT);
|
||||||
}
|
}
|
||||||
} else if (event instanceof EntityDamageByBlockEvent) {
|
} else if (event instanceof EntityDamageByBlockEvent) {
|
||||||
Bukkit.getPluginManager().callEvent(new NPCDamageByBlockEvent(npc, (EntityDamageByBlockEvent) event));
|
Bukkit.getPluginManager().callEvent(new NPCDamageByBlockEvent(npc, (EntityDamageByBlockEvent) event));
|
||||||
@ -483,7 +483,7 @@ public class EventListen implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (npc.hasTrait(ClickRedirectTrait.class)) {
|
if (npc.hasTrait(ClickRedirectTrait.class)) {
|
||||||
npc = npc.getTrait(ClickRedirectTrait.class).getRedirectNPC();
|
npc = npc.getTraitNullable(ClickRedirectTrait.class).getRedirectNPC();
|
||||||
if (npc == null)
|
if (npc == null)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -494,7 +494,7 @@ public class EventListen implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
if (npc.hasTrait(CommandTrait.class)) {
|
if (npc.hasTrait(CommandTrait.class)) {
|
||||||
npc.getTrait(CommandTrait.class).dispatch(player, CommandTrait.Hand.RIGHT);
|
npc.getTraitNullable(CommandTrait.class).dispatch(player, CommandTrait.Hand.RIGHT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -609,7 +609,7 @@ public class EventListen implements Listener {
|
|||||||
NPCLeftClickEvent leftClickEvent = new NPCLeftClickEvent(npc, damager);
|
NPCLeftClickEvent leftClickEvent = new NPCLeftClickEvent(npc, damager);
|
||||||
Bukkit.getPluginManager().callEvent(leftClickEvent);
|
Bukkit.getPluginManager().callEvent(leftClickEvent);
|
||||||
if (npc.hasTrait(CommandTrait.class)) {
|
if (npc.hasTrait(CommandTrait.class)) {
|
||||||
npc.getTrait(CommandTrait.class).dispatch(damager, CommandTrait.Hand.LEFT);
|
npc.getTraitNullable(CommandTrait.class).dispatch(damager, CommandTrait.Hand.LEFT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -629,7 +629,7 @@ public class EventListen implements Listener {
|
|||||||
return;
|
return;
|
||||||
if ((Util.isHorse(npc.getEntity().getType()) || npc.getEntity().getType() == EntityType.BOAT
|
if ((Util.isHorse(npc.getEntity().getType()) || npc.getEntity().getType() == EntityType.BOAT
|
||||||
|| npc.getEntity().getType() == EntityType.PIG || npc.getEntity() instanceof Minecart)
|
|| npc.getEntity().getType() == EntityType.PIG || npc.getEntity() instanceof Minecart)
|
||||||
&& (!npc.hasTrait(Controllable.class) || !npc.getTrait(Controllable.class).isEnabled())) {
|
&& (!npc.hasTrait(Controllable.class) || !npc.getTraitNullable(Controllable.class).isEnabled())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -706,7 +706,7 @@ public class EventListen implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean spawn(NPC npc) {
|
private boolean spawn(NPC npc) {
|
||||||
Location spawn = npc.getTrait(CurrentLocation.class).getLocation();
|
Location spawn = npc.getOrAddTrait(CurrentLocation.class).getLocation();
|
||||||
if (spawn == null) {
|
if (spawn == null) {
|
||||||
if (Messaging.isDebugging()) {
|
if (Messaging.isDebugging()) {
|
||||||
Messaging.debug("Couldn't find a spawn location for despawned NPC id", npc.getId());
|
Messaging.debug("Couldn't find a spawn location for despawned NPC id", npc.getId());
|
||||||
|
@ -50,7 +50,7 @@ public class EditorCommands {
|
|||||||
permission = "citizens.npc.edit.path")
|
permission = "citizens.npc.edit.path")
|
||||||
@Requirements(selected = true, ownership = true)
|
@Requirements(selected = true, ownership = true)
|
||||||
public void path(CommandContext args, CommandSender player, NPC npc) {
|
public void path(CommandContext args, CommandSender player, NPC npc) {
|
||||||
Editor editor = npc.getTrait(Waypoints.class).getEditor(player, args);
|
Editor editor = npc.getOrAddTrait(Waypoints.class).getEditor(player, args);
|
||||||
if (editor == null)
|
if (editor == null)
|
||||||
return;
|
return;
|
||||||
Editor.enterOrLeave((Player) player, editor);
|
Editor.enterOrLeave((Player) player, editor);
|
||||||
@ -65,6 +65,6 @@ public class EditorCommands {
|
|||||||
max = 1,
|
max = 1,
|
||||||
permission = "citizens.npc.edit.text")
|
permission = "citizens.npc.edit.text")
|
||||||
public void text(CommandContext args, Player player, NPC npc) {
|
public void text(CommandContext args, Player player, NPC npc) {
|
||||||
Editor.enterOrLeave(player, npc.getTrait(Text.class).getEditor(player));
|
Editor.enterOrLeave(player, npc.getOrAddTrait(Text.class).getEditor(player));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,7 @@ import org.bukkit.command.ConsoleCommandSender;
|
|||||||
import org.bukkit.entity.Ageable;
|
import org.bukkit.entity.Ageable;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Horse.Color;
|
import org.bukkit.entity.Horse;
|
||||||
import org.bukkit.entity.Horse.Style;
|
|
||||||
import org.bukkit.entity.ItemFrame;
|
import org.bukkit.entity.ItemFrame;
|
||||||
import org.bukkit.entity.Ocelot;
|
import org.bukkit.entity.Ocelot;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -141,7 +140,7 @@ public class NPCCommands {
|
|||||||
public void age(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void age(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
if (!npc.isSpawned() || (!(npc.getEntity() instanceof Ageable) && !(npc.getEntity() instanceof Zombie)))
|
if (!npc.isSpawned() || (!(npc.getEntity() instanceof Ageable) && !(npc.getEntity() instanceof Zombie)))
|
||||||
throw new CommandException(Messages.MOBTYPE_CANNOT_BE_AGED, npc.getName());
|
throw new CommandException(Messages.MOBTYPE_CANNOT_BE_AGED, npc.getName());
|
||||||
Age trait = npc.getTrait(Age.class);
|
Age trait = npc.getOrAddTrait(Age.class);
|
||||||
boolean toggleLock = args.hasFlag('l');
|
boolean toggleLock = args.hasFlag('l');
|
||||||
if (toggleLock) {
|
if (toggleLock) {
|
||||||
Messaging.sendTr(sender, trait.toggle() ? Messages.AGE_LOCKED : Messages.AGE_UNLOCKED);
|
Messaging.sendTr(sender, trait.toggle() ? Messages.AGE_LOCKED : Messages.AGE_UNLOCKED);
|
||||||
@ -182,7 +181,7 @@ public class NPCCommands {
|
|||||||
max = 3,
|
max = 3,
|
||||||
permission = "citizens.npc.anchor")
|
permission = "citizens.npc.anchor")
|
||||||
public void anchor(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void anchor(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
Anchors trait = npc.getTrait(Anchors.class);
|
Anchors trait = npc.getOrAddTrait(Anchors.class);
|
||||||
if (args.hasValueFlag("save")) {
|
if (args.hasValueFlag("save")) {
|
||||||
if (args.getFlag("save").isEmpty())
|
if (args.getFlag("save").isEmpty())
|
||||||
throw new CommandException(Messages.INVALID_ANCHOR_NAME);
|
throw new CommandException(Messages.INVALID_ANCHOR_NAME);
|
||||||
@ -257,7 +256,7 @@ public class NPCCommands {
|
|||||||
max = 1)
|
max = 1)
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.ARMOR_STAND)
|
@Requirements(selected = true, ownership = true, types = EntityType.ARMOR_STAND)
|
||||||
public void armorstand(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void armorstand(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
ArmorStandTrait trait = npc.getTrait(ArmorStandTrait.class);
|
ArmorStandTrait trait = npc.getOrAddTrait(ArmorStandTrait.class);
|
||||||
if (args.hasValueFlag("visible")) {
|
if (args.hasValueFlag("visible")) {
|
||||||
trait.setVisible(Boolean.valueOf(args.getFlag("visible")));
|
trait.setVisible(Boolean.valueOf(args.getFlag("visible")));
|
||||||
}
|
}
|
||||||
@ -302,7 +301,7 @@ public class NPCCommands {
|
|||||||
flags = "lrpo",
|
flags = "lrpo",
|
||||||
permission = "citizens.npc.command")
|
permission = "citizens.npc.command")
|
||||||
public void command(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void command(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
CommandTrait commands = npc.getTrait(CommandTrait.class);
|
CommandTrait commands = npc.getOrAddTrait(CommandTrait.class);
|
||||||
if (args.argsLength() == 1) {
|
if (args.argsLength() == 1) {
|
||||||
commands.describe(sender);
|
commands.describe(sender);
|
||||||
} else if (args.getString(1).equalsIgnoreCase("add")) {
|
} else if (args.getString(1).equalsIgnoreCase("add")) {
|
||||||
@ -368,7 +367,7 @@ public class NPCCommands {
|
|||||||
if (!npc.hasTrait(Controllable.class)) {
|
if (!npc.hasTrait(Controllable.class)) {
|
||||||
npc.addTrait(new Controllable(false));
|
npc.addTrait(new Controllable(false));
|
||||||
}
|
}
|
||||||
Controllable trait = npc.getTrait(Controllable.class);
|
Controllable trait = npc.getOrAddTrait(Controllable.class);
|
||||||
boolean enabled = trait.toggle();
|
boolean enabled = trait.toggle();
|
||||||
if (args.hasFlag('y')) {
|
if (args.hasFlag('y')) {
|
||||||
enabled = trait.setEnabled(true);
|
enabled = trait.setEnabled(true);
|
||||||
@ -402,7 +401,7 @@ public class NPCCommands {
|
|||||||
Location location = args.getSenderLocation();
|
Location location = args.getSenderLocation();
|
||||||
location.getChunk().load();
|
location.getChunk().load();
|
||||||
copy.teleport(location, TeleportCause.COMMAND);
|
copy.teleport(location, TeleportCause.COMMAND);
|
||||||
copy.getTrait(CurrentLocation.class).setLocation(location);
|
copy.getOrAddTrait(CurrentLocation.class).setLocation(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandSenderCreateNPCEvent event = sender instanceof Player
|
CommandSenderCreateNPCEvent event = sender instanceof Player
|
||||||
@ -474,9 +473,9 @@ public class NPCCommands {
|
|||||||
|
|
||||||
// Initialize necessary traits
|
// Initialize necessary traits
|
||||||
if (!Setting.SERVER_OWNS_NPCS.asBoolean()) {
|
if (!Setting.SERVER_OWNS_NPCS.asBoolean()) {
|
||||||
npc.getTrait(Owner.class).setOwner(sender);
|
npc.getOrAddTrait(Owner.class).setOwner(sender);
|
||||||
}
|
}
|
||||||
npc.getTrait(MobType.class).setType(type);
|
npc.getOrAddTrait(MobType.class).setType(type);
|
||||||
|
|
||||||
Location spawnLoc = null;
|
Location spawnLoc = null;
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
@ -541,7 +540,7 @@ public class NPCCommands {
|
|||||||
|
|
||||||
// Set age after entity spawns
|
// Set age after entity spawns
|
||||||
if (npc.getEntity() instanceof Ageable) {
|
if (npc.getEntity() instanceof Ageable) {
|
||||||
npc.getTrait(Age.class).setAge(age);
|
npc.getOrAddTrait(Age.class).setAge(age);
|
||||||
}
|
}
|
||||||
selector.select(sender, npc);
|
selector.select(sender, npc);
|
||||||
Messaging.send(sender, msg + '.');
|
Messaging.send(sender, msg + '.');
|
||||||
@ -563,7 +562,7 @@ public class NPCCommands {
|
|||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
throw new CommandException(Messages.NO_NPC_WITH_ID_FOUND, args.getString(1));
|
throw new CommandException(Messages.NO_NPC_WITH_ID_FOUND, args.getString(1));
|
||||||
}
|
}
|
||||||
npc.getTrait(Spawned.class).setSpawned(false);
|
npc.getOrAddTrait(Spawned.class).setSpawned(false);
|
||||||
npc.despawn(DespawnReason.REMOVAL);
|
npc.despawn(DespawnReason.REMOVAL);
|
||||||
Messaging.sendTr(sender, Messages.NPC_DESPAWNED, npc.getName());
|
Messaging.sendTr(sender, Messages.NPC_DESPAWNED, npc.getName());
|
||||||
}
|
}
|
||||||
@ -590,7 +589,7 @@ public class NPCCommands {
|
|||||||
permission = "citizens.npc.enderman")
|
permission = "citizens.npc.enderman")
|
||||||
public void enderman(CommandContext args, Player sender, NPC npc) throws CommandException {
|
public void enderman(CommandContext args, Player sender, NPC npc) throws CommandException {
|
||||||
if (args.hasFlag('a')) {
|
if (args.hasFlag('a')) {
|
||||||
boolean angry = npc.getTrait(EndermanTrait.class).toggleAngry();
|
boolean angry = npc.getOrAddTrait(EndermanTrait.class).toggleAngry();
|
||||||
Messaging.sendTr(sender, angry ? Messages.ENDERMAN_ANGRY_SET : Messages.ENDERMAN_ANGRY_UNSET,
|
Messaging.sendTr(sender, angry ? Messages.ENDERMAN_ANGRY_SET : Messages.ENDERMAN_ANGRY_UNSET,
|
||||||
npc.getName());
|
npc.getName());
|
||||||
}
|
}
|
||||||
@ -636,7 +635,7 @@ public class NPCCommands {
|
|||||||
if (player == null) {
|
if (player == null) {
|
||||||
throw new CommandException();
|
throw new CommandException();
|
||||||
}
|
}
|
||||||
boolean following = npc.getTrait(FollowTrait.class).toggle(player, protect);
|
boolean following = npc.getOrAddTrait(FollowTrait.class).toggle(player, protect);
|
||||||
Messaging.sendTr(sender, following ? Messages.FOLLOW_SET : Messages.FOLLOW_UNSET, npc.getName(),
|
Messaging.sendTr(sender, following ? Messages.FOLLOW_SET : Messages.FOLLOW_UNSET, npc.getName(),
|
||||||
player.getName());
|
player.getName());
|
||||||
}
|
}
|
||||||
@ -671,7 +670,7 @@ public class NPCCommands {
|
|||||||
Messaging.sendErrorTr(sender, Messages.GAMEMODE_INVALID, args.getString(1));
|
Messaging.sendErrorTr(sender, Messages.GAMEMODE_INVALID, args.getString(1));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
npc.getTrait(GameModeTrait.class).setGameMode(mode);
|
npc.getOrAddTrait(GameModeTrait.class).setGameMode(mode);
|
||||||
Messaging.sendTr(sender, Messages.GAMEMODE_SET, mode.name().toLowerCase());
|
Messaging.sendTr(sender, Messages.GAMEMODE_SET, mode.name().toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -689,7 +688,7 @@ public class NPCCommands {
|
|||||||
ChatColor chatColor = Util.matchEnum(ChatColor.values(), args.getFlag("color"));
|
ChatColor chatColor = Util.matchEnum(ChatColor.values(), args.getFlag("color"));
|
||||||
if (!(npc.getEntity() instanceof Player))
|
if (!(npc.getEntity() instanceof Player))
|
||||||
throw new CommandException(Messages.GLOWING_COLOR_PLAYER_ONLY);
|
throw new CommandException(Messages.GLOWING_COLOR_PLAYER_ONLY);
|
||||||
npc.getTrait(ScoreboardTrait.class).setColor(chatColor);
|
npc.getOrAddTrait(ScoreboardTrait.class).setColor(chatColor);
|
||||||
if (!npc.data().has(NPC.GLOWING_METADATA)) {
|
if (!npc.data().has(NPC.GLOWING_METADATA)) {
|
||||||
npc.data().setPersistent(NPC.GLOWING_METADATA, true);
|
npc.data().setPersistent(NPC.GLOWING_METADATA, true);
|
||||||
}
|
}
|
||||||
@ -711,7 +710,7 @@ public class NPCCommands {
|
|||||||
max = 1,
|
max = 1,
|
||||||
permission = "citizens.npc.gravity")
|
permission = "citizens.npc.gravity")
|
||||||
public void gravity(CommandContext args, CommandSender sender, NPC npc) {
|
public void gravity(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
boolean enabled = npc.getTrait(Gravity.class).toggle();
|
boolean enabled = npc.getOrAddTrait(Gravity.class).toggle();
|
||||||
String key = !enabled ? Messages.GRAVITY_ENABLED : Messages.GRAVITY_DISABLED;
|
String key = !enabled ? Messages.GRAVITY_ENABLED : Messages.GRAVITY_DISABLED;
|
||||||
Messaging.sendTr(sender, key, npc.getName());
|
Messaging.sendTr(sender, key, npc.getName());
|
||||||
}
|
}
|
||||||
@ -725,7 +724,7 @@ public class NPCCommands {
|
|||||||
max = -1,
|
max = -1,
|
||||||
permission = "citizens.npc.hologram")
|
permission = "citizens.npc.hologram")
|
||||||
public void hologram(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void hologram(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
HologramTrait trait = npc.getTrait(HologramTrait.class);
|
HologramTrait trait = npc.getOrAddTrait(HologramTrait.class);
|
||||||
if (args.argsLength() == 1) {
|
if (args.argsLength() == 1) {
|
||||||
String output = Messaging.tr(Messages.HOLOGRAM_DESCRIBE_HEADER, npc.getName());
|
String output = Messaging.tr(Messages.HOLOGRAM_DESCRIBE_HEADER, npc.getName());
|
||||||
List<String> lines = trait.getLines();
|
List<String> lines = trait.getLines();
|
||||||
@ -792,11 +791,11 @@ public class NPCCommands {
|
|||||||
permission = "citizens.npc.horse")
|
permission = "citizens.npc.horse")
|
||||||
@Requirements(selected = true, ownership = true)
|
@Requirements(selected = true, ownership = true)
|
||||||
public void horse(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void horse(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
EntityType type = npc.getTrait(MobType.class).getType();
|
EntityType type = npc.getOrAddTrait(MobType.class).getType();
|
||||||
if (!Util.isHorse(type)) {
|
if (!Util.isHorse(type)) {
|
||||||
throw new CommandException(CommandMessages.REQUIREMENTS_INVALID_MOB_TYPE, Util.prettyEnum(type));
|
throw new CommandException(CommandMessages.REQUIREMENTS_INVALID_MOB_TYPE, Util.prettyEnum(type));
|
||||||
}
|
}
|
||||||
HorseModifiers horse = npc.getTrait(HorseModifiers.class);
|
HorseModifiers horse = npc.getOrAddTrait(HorseModifiers.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasFlag('c')) {
|
if (args.hasFlag('c')) {
|
||||||
horse.setCarryingChest(true);
|
horse.setCarryingChest(true);
|
||||||
@ -808,18 +807,18 @@ public class NPCCommands {
|
|||||||
|
|
||||||
if (type == EntityType.HORSE && (args.hasValueFlag("color") || args.hasValueFlag("colour"))) {
|
if (type == EntityType.HORSE && (args.hasValueFlag("color") || args.hasValueFlag("colour"))) {
|
||||||
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
||||||
Color color = Util.matchEnum(Color.values(), colorRaw);
|
Horse.Color color = Util.matchEnum(Horse.Color.values(), colorRaw);
|
||||||
if (color == null) {
|
if (color == null) {
|
||||||
String valid = Util.listValuesPretty(Color.values());
|
String valid = Util.listValuesPretty(Horse.Color.values());
|
||||||
throw new CommandException(Messages.INVALID_HORSE_COLOR, valid);
|
throw new CommandException(Messages.INVALID_HORSE_COLOR, valid);
|
||||||
}
|
}
|
||||||
horse.setColor(color);
|
horse.setColor(color);
|
||||||
output += Messaging.tr(Messages.HORSE_COLOR_SET, Util.prettyEnum(color));
|
output += Messaging.tr(Messages.HORSE_COLOR_SET, Util.prettyEnum(color));
|
||||||
}
|
}
|
||||||
if (type == EntityType.HORSE && args.hasValueFlag("style")) {
|
if (type == EntityType.HORSE && args.hasValueFlag("style")) {
|
||||||
Style style = Util.matchEnum(Style.values(), args.getFlag("style"));
|
Horse.Style style = Util.matchEnum(Horse.Style.values(), args.getFlag("style"));
|
||||||
if (style == null) {
|
if (style == null) {
|
||||||
String valid = Util.listValuesPretty(Style.values());
|
String valid = Util.listValuesPretty(Horse.Style.values());
|
||||||
throw new CommandException(Messages.INVALID_HORSE_STYLE, valid);
|
throw new CommandException(Messages.INVALID_HORSE_STYLE, valid);
|
||||||
}
|
}
|
||||||
horse.setStyle(style);
|
horse.setStyle(style);
|
||||||
@ -854,7 +853,7 @@ public class NPCCommands {
|
|||||||
max = 1,
|
max = 1,
|
||||||
permission = "citizens.npc.inventory")
|
permission = "citizens.npc.inventory")
|
||||||
public void inventory(CommandContext args, CommandSender sender, NPC npc) {
|
public void inventory(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
npc.getTrait(Inventory.class).openInventory((Player) sender);
|
npc.getOrAddTrait(Inventory.class).openInventory((Player) sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -937,7 +936,7 @@ public class NPCCommands {
|
|||||||
}
|
}
|
||||||
} else if (args.getValueFlags().size() == 0 && sender instanceof Player) {
|
} else if (args.getValueFlags().size() == 0 && sender instanceof Player) {
|
||||||
for (NPC add : source.sorted()) {
|
for (NPC add : source.sorted()) {
|
||||||
if (!npcs.contains(add) && add.getTrait(Owner.class).isOwnedBy(sender)) {
|
if (!npcs.contains(add) && add.getOrAddTrait(Owner.class).isOwnedBy(sender)) {
|
||||||
npcs.add(add);
|
npcs.add(add);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -945,7 +944,7 @@ public class NPCCommands {
|
|||||||
if (args.hasValueFlag("owner")) {
|
if (args.hasValueFlag("owner")) {
|
||||||
String name = args.getFlag("owner");
|
String name = args.getFlag("owner");
|
||||||
for (NPC add : source.sorted()) {
|
for (NPC add : source.sorted()) {
|
||||||
if (!npcs.contains(add) && add.getTrait(Owner.class).isOwnedBy(name)) {
|
if (!npcs.contains(add) && add.getOrAddTrait(Owner.class).isOwnedBy(name)) {
|
||||||
npcs.add(add);
|
npcs.add(add);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -958,7 +957,7 @@ public class NPCCommands {
|
|||||||
throw new CommandException(Messages.COMMAND_INVALID_MOBTYPE, type);
|
throw new CommandException(Messages.COMMAND_INVALID_MOBTYPE, type);
|
||||||
|
|
||||||
for (NPC add : source) {
|
for (NPC add : source) {
|
||||||
if (!npcs.contains(add) && add.getTrait(MobType.class).getType() == type)
|
if (!npcs.contains(add) && add.getOrAddTrait(MobType.class).getType() == type)
|
||||||
npcs.add(add);
|
npcs.add(add);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -990,7 +989,7 @@ public class NPCCommands {
|
|||||||
boolean toggle = true;
|
boolean toggle = true;
|
||||||
if (args.hasAnyValueFlag("randomlook", "rlook")) {
|
if (args.hasAnyValueFlag("randomlook", "rlook")) {
|
||||||
boolean enableRandomLook = Boolean.parseBoolean(args.getFlag("randomlook", args.getFlag("rlook")));
|
boolean enableRandomLook = Boolean.parseBoolean(args.getFlag("randomlook", args.getFlag("rlook")));
|
||||||
npc.getTrait(LookClose.class).setRandomLook(enableRandomLook);
|
npc.getOrAddTrait(LookClose.class).setRandomLook(enableRandomLook);
|
||||||
Messaging.sendTr(sender,
|
Messaging.sendTr(sender,
|
||||||
enableRandomLook ? Messages.LOOKCLOSE_RANDOM_SET : Messages.LOOKCLOSE_RANDOM_STOPPED,
|
enableRandomLook ? Messages.LOOKCLOSE_RANDOM_SET : Messages.LOOKCLOSE_RANDOM_STOPPED,
|
||||||
npc.getName());
|
npc.getName());
|
||||||
@ -999,7 +998,7 @@ public class NPCCommands {
|
|||||||
if (args.hasAnyValueFlag("randomlookdelay", "rlookdelay")) {
|
if (args.hasAnyValueFlag("randomlookdelay", "rlookdelay")) {
|
||||||
int delay = Integer.parseInt(args.getFlag("randomlookdelay", args.getFlag("rlookdelay")));
|
int delay = Integer.parseInt(args.getFlag("randomlookdelay", args.getFlag("rlookdelay")));
|
||||||
delay = Math.max(1, delay);
|
delay = Math.max(1, delay);
|
||||||
npc.getTrait(LookClose.class).setRandomLookDelay(delay);
|
npc.getOrAddTrait(LookClose.class).setRandomLookDelay(delay);
|
||||||
Messaging.sendTr(sender, Messages.LOOKCLOSE_RANDOM_DELAY_SET, npc.getName(), delay);
|
Messaging.sendTr(sender, Messages.LOOKCLOSE_RANDOM_DELAY_SET, npc.getName(), delay);
|
||||||
toggle = false;
|
toggle = false;
|
||||||
}
|
}
|
||||||
@ -1010,7 +1009,7 @@ public class NPCCommands {
|
|||||||
float min = Float.parseFloat(parts[0]), max = Float.parseFloat(parts[1]);
|
float min = Float.parseFloat(parts[0]), max = Float.parseFloat(parts[1]);
|
||||||
if (min > max)
|
if (min > max)
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
npc.getTrait(LookClose.class).setRandomLookPitchRange(min, max);
|
npc.getOrAddTrait(LookClose.class).setRandomLookPitchRange(min, max);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new CommandException(Messaging.tr(Messages.ERROR_SETTING_LOOKCLOSE_RANGE, flag));
|
throw new CommandException(Messaging.tr(Messages.ERROR_SETTING_LOOKCLOSE_RANGE, flag));
|
||||||
}
|
}
|
||||||
@ -1024,7 +1023,7 @@ public class NPCCommands {
|
|||||||
float min = Float.parseFloat(parts[0]), max = Float.parseFloat(parts[1]);
|
float min = Float.parseFloat(parts[0]), max = Float.parseFloat(parts[1]);
|
||||||
if (min > max)
|
if (min > max)
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
npc.getTrait(LookClose.class).setRandomLookYawRange(min, max);
|
npc.getOrAddTrait(LookClose.class).setRandomLookYawRange(min, max);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new CommandException(Messaging.tr(Messages.ERROR_SETTING_LOOKCLOSE_RANGE, flag));
|
throw new CommandException(Messaging.tr(Messages.ERROR_SETTING_LOOKCLOSE_RANGE, flag));
|
||||||
}
|
}
|
||||||
@ -1033,7 +1032,7 @@ public class NPCCommands {
|
|||||||
}
|
}
|
||||||
if (toggle) {
|
if (toggle) {
|
||||||
Messaging.sendTr(sender,
|
Messaging.sendTr(sender,
|
||||||
npc.getTrait(LookClose.class).toggle() ? Messages.LOOKCLOSE_SET : Messages.LOOKCLOSE_STOPPED,
|
npc.getOrAddTrait(LookClose.class).toggle() ? Messages.LOOKCLOSE_SET : Messages.LOOKCLOSE_STOPPED,
|
||||||
npc.getName());
|
npc.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1138,10 +1137,10 @@ public class NPCCommands {
|
|||||||
NMS.mount(mount.getEntity(), npc.getEntity());
|
NMS.mount(mount.getEntity(), npc.getEntity());
|
||||||
return;
|
return;
|
||||||
} else if (args.hasFlag('c')) {
|
} else if (args.hasFlag('c')) {
|
||||||
npc.getTrait(MountTrait.class).unmount();
|
npc.getOrAddTrait(MountTrait.class).unmount();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean enabled = npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled();
|
boolean enabled = npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled();
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
Messaging.sendTr(sender, Messages.NPC_NOT_CONTROLLABLE, npc.getName());
|
Messaging.sendTr(sender, Messages.NPC_NOT_CONTROLLABLE, npc.getName());
|
||||||
return;
|
return;
|
||||||
@ -1150,7 +1149,7 @@ public class NPCCommands {
|
|||||||
throw new CommandException(CommandMessages.MUST_BE_INGAME);
|
throw new CommandException(CommandMessages.MUST_BE_INGAME);
|
||||||
}
|
}
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
boolean success = npc.getTrait(Controllable.class).mount(player);
|
boolean success = npc.getOrAddTrait(Controllable.class).mount(player);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
Messaging.sendTr(player, Messages.FAILED_TO_MOUNT_NPC, npc.getName());
|
Messaging.sendTr(player, Messages.FAILED_TO_MOUNT_NPC, npc.getName());
|
||||||
}
|
}
|
||||||
@ -1165,7 +1164,7 @@ public class NPCCommands {
|
|||||||
permission = "citizens.npc.moveto")
|
permission = "citizens.npc.moveto")
|
||||||
public void moveto(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void moveto(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
if (!npc.isSpawned()) {
|
if (!npc.isSpawned()) {
|
||||||
npc.spawn(npc.getTrait(CurrentLocation.class).getLocation(), SpawnReason.COMMAND);
|
npc.spawn(npc.getOrAddTrait(CurrentLocation.class).getLocation(), SpawnReason.COMMAND);
|
||||||
}
|
}
|
||||||
if (!npc.isSpawned()) {
|
if (!npc.isSpawned()) {
|
||||||
throw new CommandException("NPC could not be spawned.");
|
throw new CommandException("NPC could not be spawned.");
|
||||||
@ -1233,7 +1232,7 @@ public class NPCCommands {
|
|||||||
public void npc(CommandContext args, CommandSender sender, final NPC npc) {
|
public void npc(CommandContext args, CommandSender sender, final NPC npc) {
|
||||||
Messaging.send(sender, StringHelper.wrapHeader(npc.getName()));
|
Messaging.send(sender, StringHelper.wrapHeader(npc.getName()));
|
||||||
Messaging.send(sender, " <a>ID: <e>" + npc.getId());
|
Messaging.send(sender, " <a>ID: <e>" + npc.getId());
|
||||||
Messaging.send(sender, " <a>Type: <e>" + npc.getTrait(MobType.class).getType());
|
Messaging.send(sender, " <a>Type: <e>" + npc.getOrAddTrait(MobType.class).getType());
|
||||||
if (npc.isSpawned()) {
|
if (npc.isSpawned()) {
|
||||||
Location loc = npc.getEntity().getLocation();
|
Location loc = npc.getEntity().getLocation();
|
||||||
String format = " <a>Spawned at <e>%d, %d, %d <a>in world<e> %s";
|
String format = " <a>Spawned at <e>%d, %d, %d <a>in world<e> %s";
|
||||||
@ -1261,7 +1260,7 @@ public class NPCCommands {
|
|||||||
permission = "citizens.npc.ocelot")
|
permission = "citizens.npc.ocelot")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.OCELOT })
|
@Requirements(selected = true, ownership = true, types = { EntityType.OCELOT })
|
||||||
public void ocelot(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void ocelot(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
OcelotModifiers trait = npc.getTrait(OcelotModifiers.class);
|
OcelotModifiers trait = npc.getOrAddTrait(OcelotModifiers.class);
|
||||||
if (args.hasFlag('s')) {
|
if (args.hasFlag('s')) {
|
||||||
trait.setSitting(true);
|
trait.setSitting(true);
|
||||||
} else if (args.hasFlag('n')) {
|
} else if (args.hasFlag('n')) {
|
||||||
@ -1289,7 +1288,7 @@ public class NPCCommands {
|
|||||||
max = 2,
|
max = 2,
|
||||||
permission = "citizens.npc.owner")
|
permission = "citizens.npc.owner")
|
||||||
public void owner(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void owner(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
Owner ownerTrait = npc.getTrait(Owner.class);
|
Owner ownerTrait = npc.getOrAddTrait(Owner.class);
|
||||||
if (args.argsLength() == 1) {
|
if (args.argsLength() == 1) {
|
||||||
Messaging.sendTr(sender, Messages.NPC_OWNER, npc.getName(), ownerTrait.getOwner());
|
Messaging.sendTr(sender, Messages.NPC_OWNER, npc.getName(), ownerTrait.getOwner());
|
||||||
return;
|
return;
|
||||||
@ -1410,7 +1409,7 @@ public class NPCCommands {
|
|||||||
npc.data().setPersistent("removefromplayerlist", remove);
|
npc.data().setPersistent("removefromplayerlist", remove);
|
||||||
if (npc.isSpawned()) {
|
if (npc.isSpawned()) {
|
||||||
npc.despawn(DespawnReason.PENDING_RESPAWN);
|
npc.despawn(DespawnReason.PENDING_RESPAWN);
|
||||||
npc.spawn(npc.getTrait(CurrentLocation.class).getLocation(), SpawnReason.RESPAWN);
|
npc.spawn(npc.getOrAddTrait(CurrentLocation.class).getLocation(), SpawnReason.RESPAWN);
|
||||||
NMS.addOrRemoveFromPlayerList(npc.getEntity(), remove);
|
NMS.addOrRemoveFromPlayerList(npc.getEntity(), remove);
|
||||||
}
|
}
|
||||||
Messaging.sendTr(sender, remove ? Messages.REMOVED_FROM_PLAYERLIST : Messages.ADDED_TO_PLAYERLIST,
|
Messaging.sendTr(sender, remove ? Messages.REMOVED_FROM_PLAYERLIST : Messages.ADDED_TO_PLAYERLIST,
|
||||||
@ -1427,7 +1426,7 @@ public class NPCCommands {
|
|||||||
max = 2,
|
max = 2,
|
||||||
permission = "citizens.npc.pose")
|
permission = "citizens.npc.pose")
|
||||||
public void pose(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void pose(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
Poses trait = npc.getTrait(Poses.class);
|
Poses trait = npc.getOrAddTrait(Poses.class);
|
||||||
if (args.hasValueFlag("save")) {
|
if (args.hasValueFlag("save")) {
|
||||||
if (args.getFlag("save").isEmpty())
|
if (args.getFlag("save").isEmpty())
|
||||||
throw new CommandException(Messages.INVALID_POSE_NAME);
|
throw new CommandException(Messages.INVALID_POSE_NAME);
|
||||||
@ -1483,7 +1482,7 @@ public class NPCCommands {
|
|||||||
@Requirements(selected = true, ownership = true, types = { EntityType.CREEPER })
|
@Requirements(selected = true, ownership = true, types = { EntityType.CREEPER })
|
||||||
public void power(CommandContext args, CommandSender sender, NPC npc) {
|
public void power(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
Messaging.sendTr(sender,
|
Messaging.sendTr(sender,
|
||||||
npc.getTrait(Powered.class).toggle() ? Messages.POWERED_SET : Messages.POWERED_STOPPED);
|
npc.getOrAddTrait(Powered.class).toggle() ? Messages.POWERED_SET : Messages.POWERED_STOPPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -1496,7 +1495,7 @@ public class NPCCommands {
|
|||||||
permission = "citizens.npc.profession")
|
permission = "citizens.npc.profession")
|
||||||
@Requirements(selected = true, ownership = true)
|
@Requirements(selected = true, ownership = true)
|
||||||
public void profession(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void profession(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
EntityType type = npc.getTrait(MobType.class).getType();
|
EntityType type = npc.getOrAddTrait(MobType.class).getType();
|
||||||
if (type != EntityType.VILLAGER && !type.name().equals("ZOMBIE_VILLAGER")) {
|
if (type != EntityType.VILLAGER && !type.name().equals("ZOMBIE_VILLAGER")) {
|
||||||
throw new RequirementMissingException(Messaging.tr(CommandMessages.REQUIREMENTS_INVALID_MOB_TYPE,
|
throw new RequirementMissingException(Messaging.tr(CommandMessages.REQUIREMENTS_INVALID_MOB_TYPE,
|
||||||
type.name().toLowerCase().replace('_', ' ')));
|
type.name().toLowerCase().replace('_', ' ')));
|
||||||
@ -1507,7 +1506,7 @@ public class NPCCommands {
|
|||||||
throw new CommandException(Messages.INVALID_PROFESSION, args.getString(1),
|
throw new CommandException(Messages.INVALID_PROFESSION, args.getString(1),
|
||||||
Joiner.on(',').join(Profession.values()));
|
Joiner.on(',').join(Profession.values()));
|
||||||
}
|
}
|
||||||
npc.getTrait(VillagerProfession.class).setProfession(parsed);
|
npc.getOrAddTrait(VillagerProfession.class).setProfession(parsed);
|
||||||
Messaging.sendTr(sender, Messages.PROFESSION_SET, npc.getName(), profession);
|
Messaging.sendTr(sender, Messages.PROFESSION_SET, npc.getName(), profession);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1526,7 +1525,7 @@ public class NPCCommands {
|
|||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
throw new CommandException(Messages.INVALID_RABBIT_TYPE, Joiner.on(',').join(Rabbit.Type.values()));
|
throw new CommandException(Messages.INVALID_RABBIT_TYPE, Joiner.on(',').join(Rabbit.Type.values()));
|
||||||
}
|
}
|
||||||
npc.getTrait(RabbitType.class).setType(type);
|
npc.getOrAddTrait(RabbitType.class).setType(type);
|
||||||
Messaging.sendTr(sender, Messages.RABBIT_TYPE_SET, npc.getName(), type.name());
|
Messaging.sendTr(sender, Messages.RABBIT_TYPE_SET, npc.getName(), type.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1543,7 +1542,7 @@ public class NPCCommands {
|
|||||||
String owner = args.getFlag("owner");
|
String owner = args.getFlag("owner");
|
||||||
Collection<NPC> npcs = Lists.newArrayList(CitizensAPI.getNPCRegistry());
|
Collection<NPC> npcs = Lists.newArrayList(CitizensAPI.getNPCRegistry());
|
||||||
for (NPC o : npcs) {
|
for (NPC o : npcs) {
|
||||||
if (o.getTrait(Owner.class).isOwnedBy(owner)) {
|
if (o.getOrAddTrait(Owner.class).isOwnedBy(owner)) {
|
||||||
o.destroy(sender);
|
o.destroy(sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1574,7 +1573,8 @@ public class NPCCommands {
|
|||||||
public void run(NPC npc) throws CommandException {
|
public void run(NPC npc) throws CommandException {
|
||||||
if (npc == null)
|
if (npc == null)
|
||||||
throw new CommandException(Messages.COMMAND_MUST_HAVE_SELECTED);
|
throw new CommandException(Messages.COMMAND_MUST_HAVE_SELECTED);
|
||||||
if (!(sender instanceof ConsoleCommandSender) && !npc.getTrait(Owner.class).isOwnedBy(sender))
|
if (!(sender instanceof ConsoleCommandSender)
|
||||||
|
&& !npc.getOrAddTrait(Owner.class).isOwnedBy(sender))
|
||||||
throw new CommandException(Messages.COMMAND_MUST_BE_OWNER);
|
throw new CommandException(Messages.COMMAND_MUST_BE_OWNER);
|
||||||
if (!sender.hasPermission("citizens.npc.remove") && !sender.hasPermission("citizens.admin"))
|
if (!sender.hasPermission("citizens.npc.remove") && !sender.hasPermission("citizens.admin"))
|
||||||
throw new NoPermissionsException();
|
throw new NoPermissionsException();
|
||||||
@ -1589,7 +1589,7 @@ public class NPCCommands {
|
|||||||
}
|
}
|
||||||
if (npc == null)
|
if (npc == null)
|
||||||
throw new CommandException(Messages.COMMAND_MUST_HAVE_SELECTED);
|
throw new CommandException(Messages.COMMAND_MUST_HAVE_SELECTED);
|
||||||
if (!(sender instanceof ConsoleCommandSender) && !npc.getTrait(Owner.class).isOwnedBy(sender))
|
if (!(sender instanceof ConsoleCommandSender) && !npc.getOrAddTrait(Owner.class).isOwnedBy(sender))
|
||||||
throw new CommandException(Messages.COMMAND_MUST_BE_OWNER);
|
throw new CommandException(Messages.COMMAND_MUST_BE_OWNER);
|
||||||
if (!sender.hasPermission("citizens.npc.remove") && !sender.hasPermission("citizens.admin"))
|
if (!sender.hasPermission("citizens.npc.remove") && !sender.hasPermission("citizens.admin"))
|
||||||
throw new NoPermissionsException();
|
throw new NoPermissionsException();
|
||||||
@ -1607,7 +1607,7 @@ public class NPCCommands {
|
|||||||
public void rename(CommandContext args, CommandSender sender, NPC npc) {
|
public void rename(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
String oldName = npc.getName();
|
String oldName = npc.getName();
|
||||||
String newName = Colorizer.parseColors(args.getJoinedStrings(1));
|
String newName = Colorizer.parseColors(args.getJoinedStrings(1));
|
||||||
int nameLength = SpigotUtil.getMaxNameLength(npc.getTrait(MobType.class).getType());
|
int nameLength = SpigotUtil.getMaxNameLength(npc.getOrAddTrait(MobType.class).getType());
|
||||||
if (newName.length() > nameLength) {
|
if (newName.length() > nameLength) {
|
||||||
Messaging.sendErrorTr(sender, Messages.NPC_NAME_TOO_LONG, nameLength);
|
Messaging.sendErrorTr(sender, Messages.NPC_NAME_TOO_LONG, nameLength);
|
||||||
newName = newName.substring(0, nameLength);
|
newName = newName.substring(0, nameLength);
|
||||||
@ -1644,7 +1644,7 @@ public class NPCCommands {
|
|||||||
max = 1,
|
max = 1,
|
||||||
permission = "citizens.npc.scoreboard")
|
permission = "citizens.npc.scoreboard")
|
||||||
public void scoreboard(CommandContext args, CommandSender sender, NPC npc) {
|
public void scoreboard(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
ScoreboardTrait trait = npc.getTrait(ScoreboardTrait.class);
|
ScoreboardTrait trait = npc.getOrAddTrait(ScoreboardTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("addtag")) {
|
if (args.hasValueFlag("addtag")) {
|
||||||
for (String tag : args.getFlag("addtag").split(",")) {
|
for (String tag : args.getFlag("addtag").split(",")) {
|
||||||
@ -1672,7 +1672,7 @@ public class NPCCommands {
|
|||||||
max = 1,
|
max = 1,
|
||||||
permission = "citizens.npc.script")
|
permission = "citizens.npc.script")
|
||||||
public void script(CommandContext args, CommandSender sender, NPC npc) {
|
public void script(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
ScriptTrait trait = npc.getTrait(ScriptTrait.class);
|
ScriptTrait trait = npc.getOrAddTrait(ScriptTrait.class);
|
||||||
if (args.hasValueFlag("add")) {
|
if (args.hasValueFlag("add")) {
|
||||||
List<String> files = new ArrayList<String>();
|
List<String> files = new ArrayList<String>();
|
||||||
for (String file : args.getFlag("add").split(",")) {
|
for (String file : args.getFlag("add").split(",")) {
|
||||||
@ -1748,7 +1748,7 @@ public class NPCCommands {
|
|||||||
permission = "citizens.npc.sheep")
|
permission = "citizens.npc.sheep")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SHEEP })
|
@Requirements(selected = true, ownership = true, types = { EntityType.SHEEP })
|
||||||
public void sheep(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void sheep(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
SheepTrait trait = npc.getTrait(SheepTrait.class);
|
SheepTrait trait = npc.getOrAddTrait(SheepTrait.class);
|
||||||
boolean hasArg = false;
|
boolean hasArg = false;
|
||||||
if (args.hasValueFlag("sheared")) {
|
if (args.hasValueFlag("sheared")) {
|
||||||
trait.setSheared(Boolean.valueOf(args.getFlag("sheared")));
|
trait.setSheared(Boolean.valueOf(args.getFlag("sheared")));
|
||||||
@ -1781,7 +1781,7 @@ public class NPCCommands {
|
|||||||
@Requirements(types = EntityType.PLAYER, selected = true, ownership = true)
|
@Requirements(types = EntityType.PLAYER, selected = true, ownership = true)
|
||||||
public void skin(final CommandContext args, final CommandSender sender, final NPC npc) throws CommandException {
|
public void skin(final CommandContext args, final CommandSender sender, final NPC npc) throws CommandException {
|
||||||
String skinName = npc.getName();
|
String skinName = npc.getName();
|
||||||
final SkinTrait trait = npc.getTrait(SkinTrait.class);
|
final SkinTrait trait = npc.getOrAddTrait(SkinTrait.class);
|
||||||
if (args.hasFlag('c')) {
|
if (args.hasFlag('c')) {
|
||||||
trait.clearTexture();
|
trait.clearTexture();
|
||||||
} else if (args.hasValueFlag("url")) {
|
} else if (args.hasValueFlag("url")) {
|
||||||
@ -1873,7 +1873,7 @@ public class NPCCommands {
|
|||||||
@Requirements(types = EntityType.PLAYER, selected = true, ownership = true)
|
@Requirements(types = EntityType.PLAYER, selected = true, ownership = true)
|
||||||
public void skinLayers(final CommandContext args, final CommandSender sender, final NPC npc)
|
public void skinLayers(final CommandContext args, final CommandSender sender, final NPC npc)
|
||||||
throws CommandException {
|
throws CommandException {
|
||||||
SkinLayers trait = npc.getTrait(SkinLayers.class);
|
SkinLayers trait = npc.getOrAddTrait(SkinLayers.class);
|
||||||
if (args.hasValueFlag("cape")) {
|
if (args.hasValueFlag("cape")) {
|
||||||
trait.setVisible(Layer.CAPE, Boolean.valueOf(args.getFlag("cape")));
|
trait.setVisible(Layer.CAPE, Boolean.valueOf(args.getFlag("cape")));
|
||||||
}
|
}
|
||||||
@ -1909,7 +1909,7 @@ public class NPCCommands {
|
|||||||
permission = "citizens.npc.size")
|
permission = "citizens.npc.size")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.MAGMA_CUBE, EntityType.SLIME })
|
@Requirements(selected = true, ownership = true, types = { EntityType.MAGMA_CUBE, EntityType.SLIME })
|
||||||
public void slimeSize(CommandContext args, CommandSender sender, NPC npc) {
|
public void slimeSize(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
SlimeSize trait = npc.getTrait(SlimeSize.class);
|
SlimeSize trait = npc.getOrAddTrait(SlimeSize.class);
|
||||||
if (args.argsLength() <= 1) {
|
if (args.argsLength() <= 1) {
|
||||||
trait.describe(sender);
|
trait.describe(sender);
|
||||||
return;
|
return;
|
||||||
@ -2016,7 +2016,7 @@ public class NPCCommands {
|
|||||||
if (respawn.isSpawned()) {
|
if (respawn.isSpawned()) {
|
||||||
throw new CommandException(Messages.NPC_ALREADY_SPAWNED, respawn.getName());
|
throw new CommandException(Messages.NPC_ALREADY_SPAWNED, respawn.getName());
|
||||||
}
|
}
|
||||||
Location location = respawn.getTrait(CurrentLocation.class).getLocation();
|
Location location = respawn.getOrAddTrait(CurrentLocation.class).getLocation();
|
||||||
if (location == null || args.hasValueFlag("location")) {
|
if (location == null || args.hasValueFlag("location")) {
|
||||||
if (args.getSenderLocation() == null)
|
if (args.getSenderLocation() == null)
|
||||||
throw new CommandException(Messages.NO_STORED_SPAWN_LOCATION);
|
throw new CommandException(Messages.NO_STORED_SPAWN_LOCATION);
|
||||||
@ -2048,12 +2048,12 @@ public class NPCCommands {
|
|||||||
min = 2,
|
min = 2,
|
||||||
permission = "citizens.npc.speak")
|
permission = "citizens.npc.speak")
|
||||||
public void speak(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void speak(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
String type = npc.getTrait(Speech.class).getDefaultVocalChord();
|
String type = npc.getOrAddTrait(Speech.class).getDefaultVocalChord();
|
||||||
String message = Colorizer.parseColors(args.getJoinedStrings(1));
|
String message = Colorizer.parseColors(args.getJoinedStrings(1));
|
||||||
|
|
||||||
if (message.length() <= 0) {
|
if (message.length() <= 0) {
|
||||||
Messaging.send(sender, "Default Vocal Chord for " + npc.getName() + ": "
|
Messaging.send(sender, "Default Vocal Chord for " + npc.getName() + ": "
|
||||||
+ npc.getTrait(Speech.class).getDefaultVocalChord());
|
+ npc.getOrAddTrait(Speech.class).getDefaultVocalChord());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2140,7 +2140,7 @@ public class NPCCommands {
|
|||||||
max = 1,
|
max = 1,
|
||||||
permission = "citizens.npc.tp")
|
permission = "citizens.npc.tp")
|
||||||
public void tp(CommandContext args, Player player, NPC npc) {
|
public void tp(CommandContext args, Player player, NPC npc) {
|
||||||
Location to = npc.getTrait(CurrentLocation.class).getLocation();
|
Location to = npc.getOrAddTrait(CurrentLocation.class).getLocation();
|
||||||
if (to == null) {
|
if (to == null) {
|
||||||
Messaging.sendError(player, Messages.TELEPORT_NPC_LOCATION_NOT_FOUND);
|
Messaging.sendError(player, Messages.TELEPORT_NPC_LOCATION_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
@ -2289,7 +2289,7 @@ public class NPCCommands {
|
|||||||
permission = "citizens.npc.wither")
|
permission = "citizens.npc.wither")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER })
|
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER })
|
||||||
public void wither(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void wither(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
WitherTrait trait = npc.getTrait(WitherTrait.class);
|
WitherTrait trait = npc.getOrAddTrait(WitherTrait.class);
|
||||||
if (args.hasValueFlag("charged")) {
|
if (args.hasValueFlag("charged")) {
|
||||||
trait.setCharged(Boolean.valueOf(args.getFlag("charged")));
|
trait.setCharged(Boolean.valueOf(args.getFlag("charged")));
|
||||||
}
|
}
|
||||||
@ -2307,7 +2307,7 @@ public class NPCCommands {
|
|||||||
permission = "citizens.npc.wolf")
|
permission = "citizens.npc.wolf")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.WOLF)
|
@Requirements(selected = true, ownership = true, types = EntityType.WOLF)
|
||||||
public void wolf(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void wolf(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
WolfModifiers trait = npc.getTrait(WolfModifiers.class);
|
WolfModifiers trait = npc.getOrAddTrait(WolfModifiers.class);
|
||||||
if (args.hasFlag('a')) {
|
if (args.hasFlag('a')) {
|
||||||
trait.setAngry(!trait.isAngry());
|
trait.setAngry(!trait.isAngry());
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ public class TraitCommands {
|
|||||||
throw new CommandException(Messages.TRAIT_NOT_CONFIGURABLE);
|
throw new CommandException(Messages.TRAIT_NOT_CONFIGURABLE);
|
||||||
if (!npc.hasTrait(clazz))
|
if (!npc.hasTrait(clazz))
|
||||||
throw new CommandException(Messages.TRAIT_NOT_FOUND_ON_NPC);
|
throw new CommandException(Messages.TRAIT_NOT_FOUND_ON_NPC);
|
||||||
CommandConfigurable trait = (CommandConfigurable) npc.getTrait(clazz);
|
CommandConfigurable trait = (CommandConfigurable) npc.getOrAddTrait(clazz);
|
||||||
trait.configure(args);
|
trait.configure(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ public class WaypointCommands {
|
|||||||
max = 5,
|
max = 5,
|
||||||
permission = "citizens.waypoints.add")
|
permission = "citizens.waypoints.add")
|
||||||
public void add(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void add(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
WaypointProvider provider = npc.getTrait(Waypoints.class).getCurrentProvider();
|
WaypointProvider provider = npc.getOrAddTrait(Waypoints.class).getCurrentProvider();
|
||||||
if (!(provider instanceof LinearWaypointProvider))
|
if (!(provider instanceof LinearWaypointProvider))
|
||||||
throw new CommandException();
|
throw new CommandException();
|
||||||
List<Waypoint> waypoints = (List<Waypoint>) ((LinearWaypointProvider) provider).waypoints();
|
List<Waypoint> waypoints = (List<Waypoint>) ((LinearWaypointProvider) provider).waypoints();
|
||||||
@ -88,7 +88,7 @@ public class WaypointCommands {
|
|||||||
flags = "d",
|
flags = "d",
|
||||||
permission = "citizens.waypoints.provider")
|
permission = "citizens.waypoints.provider")
|
||||||
public void provider(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void provider(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
Waypoints waypoints = npc.getTrait(Waypoints.class);
|
Waypoints waypoints = npc.getOrAddTrait(Waypoints.class);
|
||||||
if (args.argsLength() == 1) {
|
if (args.argsLength() == 1) {
|
||||||
if (args.hasFlag('d')) {
|
if (args.hasFlag('d')) {
|
||||||
waypoints.describeProviders(sender);
|
waypoints.describeProviders(sender);
|
||||||
|
@ -46,7 +46,7 @@ public class CopierEditor extends Editor {
|
|||||||
Location location = player.getLocation();
|
Location location = player.getLocation();
|
||||||
location.getChunk().load();
|
location.getChunk().load();
|
||||||
copy.teleport(location, TeleportCause.PLUGIN);
|
copy.teleport(location, TeleportCause.PLUGIN);
|
||||||
copy.getTrait(CurrentLocation.class).setLocation(location);
|
copy.getOrAddTrait(CurrentLocation.class).setLocation(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
Messaging.sendTr(player, Messages.NPC_COPIED, npc.getName());
|
Messaging.sendTr(player, Messages.NPC_COPIED, npc.getName());
|
||||||
|
@ -42,7 +42,7 @@ public class EndermanEquipper implements Equipper {
|
|||||||
hand.setAmount(hand.getAmount() - 1);
|
hand.setAmount(hand.getAmount() - 1);
|
||||||
equipper.getInventory().setItemInHand(hand);
|
equipper.getInventory().setItemInHand(hand);
|
||||||
}
|
}
|
||||||
npc.getTrait(Equipment.class).set(0, set);
|
npc.getOrAddTrait(Equipment.class).set(0, set);
|
||||||
} else {
|
} else {
|
||||||
MaterialData carried = ((Enderman) npc.getEntity()).getCarriedMaterial();
|
MaterialData carried = ((Enderman) npc.getEntity()).getCarriedMaterial();
|
||||||
if (carried.getItemType() == Material.AIR) {
|
if (carried.getItemType() == Material.AIR) {
|
||||||
@ -61,7 +61,7 @@ public class EndermanEquipper implements Equipper {
|
|||||||
hand.setAmount(hand.getAmount() - 1);
|
hand.setAmount(hand.getAmount() - 1);
|
||||||
equipper.getInventory().setItemInHand(hand);
|
equipper.getInventory().setItemInHand(hand);
|
||||||
}
|
}
|
||||||
npc.getTrait(Equipment.class).set(0, set);
|
npc.getOrAddTrait(Equipment.class).set(0, set);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,13 +66,13 @@ public class EquipmentEditor extends Editor {
|
|||||||
if (hand.getType() == Material.AIR || hand.getAmount() <= 0) {
|
if (hand.getType() == Material.AIR || hand.getAmount() <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ItemStack old = npc.getTrait(Equipment.class).get(finalSlot);
|
ItemStack old = npc.getOrAddTrait(Equipment.class).get(finalSlot);
|
||||||
if (old != null && old.getType() != Material.AIR) {
|
if (old != null && old.getType() != Material.AIR) {
|
||||||
event.getPlayer().getWorld().dropItemNaturally(event.getPlayer().getLocation(), old);
|
event.getPlayer().getWorld().dropItemNaturally(event.getPlayer().getLocation(), old);
|
||||||
}
|
}
|
||||||
ItemStack newStack = hand.clone();
|
ItemStack newStack = hand.clone();
|
||||||
newStack.setAmount(1);
|
newStack.setAmount(1);
|
||||||
npc.getTrait(Equipment.class).set(finalSlot, newStack);
|
npc.getOrAddTrait(Equipment.class).set(finalSlot, newStack);
|
||||||
hand.setAmount(hand.getAmount() - 1);
|
hand.setAmount(hand.getAmount() - 1);
|
||||||
event.getPlayer().getInventory().setItemInHand(hand);
|
event.getPlayer().getInventory().setItemInHand(hand);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ public class GenericEquipper implements Equipper {
|
|||||||
public void equip(Player equipper, NPC toEquip) {
|
public void equip(Player equipper, NPC toEquip) {
|
||||||
// TODO: migrate to an inventory-GUI system
|
// TODO: migrate to an inventory-GUI system
|
||||||
ItemStack hand = equipper.getInventory().getItemInHand();
|
ItemStack hand = equipper.getInventory().getItemInHand();
|
||||||
Equipment trait = toEquip.getTrait(Equipment.class);
|
Equipment trait = toEquip.getOrAddTrait(Equipment.class);
|
||||||
EquipmentSlot slot = EquipmentSlot.HAND;
|
EquipmentSlot slot = EquipmentSlot.HAND;
|
||||||
Material type = hand == null ? Material.AIR : hand.getType();
|
Material type = hand == null ? Material.AIR : hand.getType();
|
||||||
// First, determine the slot to edit
|
// First, determine the slot to edit
|
||||||
|
@ -17,13 +17,13 @@ public class PigEquipper implements Equipper {
|
|||||||
Pig pig = (Pig) toEquip.getEntity();
|
Pig pig = (Pig) toEquip.getEntity();
|
||||||
if (hand.getType() == Material.SADDLE) {
|
if (hand.getType() == Material.SADDLE) {
|
||||||
if (!pig.hasSaddle()) {
|
if (!pig.hasSaddle()) {
|
||||||
toEquip.getTrait(Saddle.class).toggle();
|
toEquip.getOrAddTrait(Saddle.class).toggle();
|
||||||
hand.setAmount(0);
|
hand.setAmount(0);
|
||||||
Messaging.sendTr(equipper, Messages.SADDLED_SET, toEquip.getName());
|
Messaging.sendTr(equipper, Messages.SADDLED_SET, toEquip.getName());
|
||||||
}
|
}
|
||||||
} else if (pig.hasSaddle()) {
|
} else if (pig.hasSaddle()) {
|
||||||
equipper.getWorld().dropItemNaturally(pig.getLocation(), new ItemStack(Material.SADDLE, 1));
|
equipper.getWorld().dropItemNaturally(pig.getLocation(), new ItemStack(Material.SADDLE, 1));
|
||||||
toEquip.getTrait(Saddle.class).toggle();
|
toEquip.getOrAddTrait(Saddle.class).toggle();
|
||||||
Messaging.sendTr(equipper, Messages.SADDLED_STOPPED, toEquip.getName());
|
Messaging.sendTr(equipper, Messages.SADDLED_STOPPED, toEquip.getName());
|
||||||
}
|
}
|
||||||
equipper.getInventory().setItemInHand(hand);
|
equipper.getInventory().setItemInHand(hand);
|
||||||
|
@ -20,20 +20,20 @@ public class SheepEquipper implements Equipper {
|
|||||||
ItemStack hand = equipper.getInventory().getItemInHand();
|
ItemStack hand = equipper.getInventory().getItemInHand();
|
||||||
Sheep sheep = (Sheep) toEquip.getEntity();
|
Sheep sheep = (Sheep) toEquip.getEntity();
|
||||||
if (hand.getType() == Material.SHEARS) {
|
if (hand.getType() == Material.SHEARS) {
|
||||||
Messaging.sendTr(equipper, toEquip.getTrait(SheepTrait.class).toggleSheared() ? Messages.SHEARED_SET
|
Messaging.sendTr(equipper, toEquip.getOrAddTrait(SheepTrait.class).toggleSheared() ? Messages.SHEARED_SET
|
||||||
: Messages.SHEARED_STOPPED, toEquip.getName());
|
: Messages.SHEARED_STOPPED, toEquip.getName());
|
||||||
} else if (hand.getType() == (SpigotUtil.isUsing1_13API() ? Material.INK_SAC : Material.valueOf("INK_SACK"))) {
|
} else if (hand.getType() == (SpigotUtil.isUsing1_13API() ? Material.INK_SAC : Material.valueOf("INK_SACK"))) {
|
||||||
Dye dye = (Dye) hand.getData();
|
Dye dye = (Dye) hand.getData();
|
||||||
if (sheep.getColor() == dye.getColor())
|
if (sheep.getColor() == dye.getColor())
|
||||||
return;
|
return;
|
||||||
DyeColor color = dye.getColor();
|
DyeColor color = dye.getColor();
|
||||||
toEquip.getTrait(WoolColor.class).setColor(color);
|
toEquip.getOrAddTrait(WoolColor.class).setColor(color);
|
||||||
Messaging.sendTr(equipper, Messages.EQUIPMENT_EDITOR_SHEEP_COLOURED, toEquip.getName(),
|
Messaging.sendTr(equipper, Messages.EQUIPMENT_EDITOR_SHEEP_COLOURED, toEquip.getName(),
|
||||||
color.name().toLowerCase().replace("_", " "));
|
color.name().toLowerCase().replace("_", " "));
|
||||||
|
|
||||||
hand.setAmount(hand.getAmount() - 1);
|
hand.setAmount(hand.getAmount() - 1);
|
||||||
} else {
|
} else {
|
||||||
toEquip.getTrait(WoolColor.class).setColor(DyeColor.WHITE);
|
toEquip.getOrAddTrait(WoolColor.class).setColor(DyeColor.WHITE);
|
||||||
Messaging.sendTr(equipper, Messages.EQUIPMENT_EDITOR_SHEEP_COLOURED, toEquip.getName(), "white");
|
Messaging.sendTr(equipper, Messages.EQUIPMENT_EDITOR_SHEEP_COLOURED, toEquip.getName(), "white");
|
||||||
}
|
}
|
||||||
equipper.getInventory().setItemInHand(hand);
|
equipper.getInventory().setItemInHand(hand);
|
||||||
|
@ -85,7 +85,7 @@ public class CitizensNPC extends AbstractNPC {
|
|||||||
getEntity().isValid());
|
getEntity().isValid());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
boolean keepSelected = getTrait(Spawned.class).shouldSpawn();
|
boolean keepSelected = getOrAddTrait(Spawned.class).shouldSpawn();
|
||||||
if (!keepSelected) {
|
if (!keepSelected) {
|
||||||
data().remove("selectors");
|
data().remove("selectors");
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ public class CitizensNPC extends AbstractNPC {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getStoredLocation() {
|
public Location getStoredLocation() {
|
||||||
return isSpawned() ? getEntity().getLocation() : getTrait(CurrentLocation.class).getLocation();
|
return isSpawned() ? getEntity().getLocation() : getOrAddTrait(CurrentLocation.class).getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -156,8 +156,8 @@ public class CitizensNPC extends AbstractNPC {
|
|||||||
public void load(final DataKey root) {
|
public void load(final DataKey root) {
|
||||||
super.load(root);
|
super.load(root);
|
||||||
// Spawn the NPC
|
// Spawn the NPC
|
||||||
CurrentLocation spawnLocation = getTrait(CurrentLocation.class);
|
CurrentLocation spawnLocation = getOrAddTrait(CurrentLocation.class);
|
||||||
if (getTrait(Spawned.class).shouldSpawn() && spawnLocation.getLocation() != null) {
|
if (getOrAddTrait(Spawned.class).shouldSpawn() && spawnLocation.getLocation() != null) {
|
||||||
if (spawnLocation.getLocation() != null) {
|
if (spawnLocation.getLocation() != null) {
|
||||||
spawn(spawnLocation.getLocation(), SpawnReason.RESPAWN);
|
spawn(spawnLocation.getLocation(), SpawnReason.RESPAWN);
|
||||||
} else {
|
} else {
|
||||||
@ -245,7 +245,7 @@ public class CitizensNPC extends AbstractNPC {
|
|||||||
at.getChunk().load();
|
at.getChunk().load();
|
||||||
}
|
}
|
||||||
|
|
||||||
getTrait(CurrentLocation.class).setLocation(at);
|
getOrAddTrait(CurrentLocation.class).setLocation(at);
|
||||||
entityController.spawn(at, this);
|
entityController.spawn(at, this);
|
||||||
|
|
||||||
getEntity().setMetadata(NPC_METADATA_MARKER, new FixedMetadataValue(CitizensAPI.getPlugin(), true));
|
getEntity().setMetadata(NPC_METADATA_MARKER, new FixedMetadataValue(CitizensAPI.getPlugin(), true));
|
||||||
@ -275,8 +275,8 @@ public class CitizensNPC extends AbstractNPC {
|
|||||||
NMS.setBodyYaw(getEntity(), at.getYaw());
|
NMS.setBodyYaw(getEntity(), at.getYaw());
|
||||||
|
|
||||||
// Set the spawned state
|
// Set the spawned state
|
||||||
getTrait(CurrentLocation.class).setLocation(at);
|
getOrAddTrait(CurrentLocation.class).setLocation(at);
|
||||||
getTrait(Spawned.class).setSpawned(true);
|
getOrAddTrait(Spawned.class).setSpawned(true);
|
||||||
|
|
||||||
NPCSpawnEvent spawnEvent = new NPCSpawnEvent(this, at, reason);
|
NPCSpawnEvent spawnEvent = new NPCSpawnEvent(this, at, reason);
|
||||||
Bukkit.getPluginManager().callEvent(spawnEvent);
|
Bukkit.getPluginManager().callEvent(spawnEvent);
|
||||||
@ -419,11 +419,11 @@ public class CitizensNPC extends AbstractNPC {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
getTrait(ScoreboardTrait.class).apply(team, nameVisibility);
|
getOrAddTrait(ScoreboardTrait.class).apply(team, nameVisibility);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateFlyableState() {
|
private void updateFlyableState() {
|
||||||
EntityType type = isSpawned() ? getEntity().getType() : getTrait(MobType.class).getType();
|
EntityType type = isSpawned() ? getEntity().getType() : getOrAddTrait(MobType.class).getType();
|
||||||
if (type == null)
|
if (type == null)
|
||||||
return;
|
return;
|
||||||
if (!Util.isAlwaysFlyable(type))
|
if (!Util.isAlwaysFlyable(type))
|
||||||
@ -432,7 +432,7 @@ public class CitizensNPC extends AbstractNPC {
|
|||||||
data().setPersistent(NPC.FLYABLE_METADATA, true);
|
data().setPersistent(NPC.FLYABLE_METADATA, true);
|
||||||
}
|
}
|
||||||
if (!hasTrait(Gravity.class)) {
|
if (!hasTrait(Gravity.class)) {
|
||||||
getTrait(Gravity.class).setEnabled(true);
|
getOrAddTrait(Gravity.class).setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ public class NPCSelector implements Listener, net.citizensnpcs.api.npc.NPCSelect
|
|||||||
List<MetadataValue> selected = player.getMetadata("selected");
|
List<MetadataValue> selected = player.getMetadata("selected");
|
||||||
if (selected == null || selected.size() == 0 || selected.get(0).asInt() != npc.getId()) {
|
if (selected == null || selected.size() == 0 || selected.get(0).asInt() != npc.getId()) {
|
||||||
if (Util.matchesItemInHand(player, Setting.SELECTION_ITEM.asString())
|
if (Util.matchesItemInHand(player, Setting.SELECTION_ITEM.asString())
|
||||||
&& npc.getTrait(Owner.class).isOwnedBy(player)) {
|
&& npc.getOrAddTrait(Owner.class).isOwnedBy(player)) {
|
||||||
player.removeMetadata("selected", plugin);
|
player.removeMetadata("selected", plugin);
|
||||||
select(player, npc);
|
select(player, npc);
|
||||||
Messaging.sendWithNPC(player, Setting.SELECTION_MESSAGE.asString(), npc);
|
Messaging.sendWithNPC(player, Setting.SELECTION_MESSAGE.asString(), npc);
|
||||||
|
@ -80,7 +80,7 @@ public class Skin {
|
|||||||
Preconditions.checkNotNull(entity);
|
Preconditions.checkNotNull(entity);
|
||||||
|
|
||||||
NPC npc = entity.getNPC();
|
NPC npc = entity.getNPC();
|
||||||
SkinTrait skinTrait = npc.getTrait(SkinTrait.class);
|
SkinTrait skinTrait = npc.getOrAddTrait(SkinTrait.class);
|
||||||
// Use npc cached skin if available.
|
// Use npc cached skin if available.
|
||||||
// If npc requires latest skin, cache is used for faster availability until the latest skin can be loaded.
|
// If npc requires latest skin, cache is used for faster availability until the latest skin can be loaded.
|
||||||
String cachedName = npc.data().get(CACHED_SKIN_UUID_NAME_METADATA);
|
String cachedName = npc.data().get(CACHED_SKIN_UUID_NAME_METADATA);
|
||||||
@ -103,7 +103,7 @@ public class Skin {
|
|||||||
String defaultSkinName = ChatColor.stripColor(npc.getName()).toLowerCase();
|
String defaultSkinName = ChatColor.stripColor(npc.getName()).toLowerCase();
|
||||||
|
|
||||||
if (npc.hasTrait(SkinTrait.class) && this.skinName.equals(defaultSkinName)
|
if (npc.hasTrait(SkinTrait.class) && this.skinName.equals(defaultSkinName)
|
||||||
&& !npc.getTrait(SkinTrait.class).fetchDefaultSkin()) {
|
&& !npc.getOrAddTrait(SkinTrait.class).fetchDefaultSkin()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (hasFetched) {
|
if (hasFetched) {
|
||||||
@ -371,7 +371,7 @@ public class Skin {
|
|||||||
|
|
||||||
private static void setNPCSkinData(SkinnableEntity entity, String skinName, UUID skinId, Property skinProperty) {
|
private static void setNPCSkinData(SkinnableEntity entity, String skinName, UUID skinId, Property skinProperty) {
|
||||||
NPC npc = entity.getNPC();
|
NPC npc = entity.getNPC();
|
||||||
SkinTrait skinTrait = npc.getTrait(SkinTrait.class);
|
SkinTrait skinTrait = npc.getOrAddTrait(SkinTrait.class);
|
||||||
|
|
||||||
// cache skins for faster initial skin availability and
|
// cache skins for faster initial skin availability and
|
||||||
// for use when the latest skin is not required.
|
// for use when the latest skin is not required.
|
||||||
|
@ -88,7 +88,7 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ownerRequired && !npc.getTrait(Owner.class).isOwnedBy(player)) {
|
if (ownerRequired && !npc.getOrAddTrait(Owner.class).isOwnedBy(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NMS.mount(npc.getEntity(), player);
|
NMS.mount(npc.getEntity(), player);
|
||||||
|
@ -53,7 +53,7 @@ public class HologramTrait extends Trait {
|
|||||||
private NPC createHologram(String line, double heightOffset) {
|
private NPC createHologram(String line, double heightOffset) {
|
||||||
NPC hologramNPC = registry.createNPC(EntityType.ARMOR_STAND, line);
|
NPC hologramNPC = registry.createNPC(EntityType.ARMOR_STAND, line);
|
||||||
hologramNPC.addTrait(new ClickRedirectTrait(npc));
|
hologramNPC.addTrait(new ClickRedirectTrait(npc));
|
||||||
ArmorStandTrait trait = hologramNPC.getTrait(ArmorStandTrait.class);
|
ArmorStandTrait trait = hologramNPC.getOrAddTrait(ArmorStandTrait.class);
|
||||||
trait.setVisible(false);
|
trait.setVisible(false);
|
||||||
trait.setSmall(true);
|
trait.setSmall(true);
|
||||||
trait.setMarker(true);
|
trait.setMarker(true);
|
||||||
|
@ -25,8 +25,8 @@ public class OcelotModifiers extends Trait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void migrateToCat() {
|
private void migrateToCat() {
|
||||||
npc.getTrait(CatTrait.class).setSitting(sitting);
|
npc.getOrAddTrait(CatTrait.class).setSitting(sitting);
|
||||||
npc.getTrait(CatTrait.class).setType(type);
|
npc.getOrAddTrait(CatTrait.class).setType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -62,7 +62,7 @@ public class Poses extends Trait {
|
|||||||
|
|
||||||
private void assumePose(float yaw, float pitch) {
|
private void assumePose(float yaw, float pitch) {
|
||||||
if (!npc.isSpawned()) {
|
if (!npc.isSpawned()) {
|
||||||
npc.spawn(npc.getTrait(CurrentLocation.class).getLocation(), SpawnReason.COMMAND);
|
npc.spawn(npc.getOrAddTrait(CurrentLocation.class).getLocation(), SpawnReason.COMMAND);
|
||||||
}
|
}
|
||||||
Util.assumePose(npc.getEntity(), yaw, pitch);
|
Util.assumePose(npc.getEntity(), yaw, pitch);
|
||||||
}
|
}
|
||||||
@ -130,7 +130,7 @@ public class Poses extends Trait {
|
|||||||
if (!hasPose(defaultPose))
|
if (!hasPose(defaultPose))
|
||||||
return;
|
return;
|
||||||
if (!npc.getNavigator().isNavigating()
|
if (!npc.getNavigator().isNavigating()
|
||||||
&& (!npc.hasTrait(LookClose.class) || !npc.getTrait(LookClose.class).canSeeTarget())) {
|
&& (!npc.hasTrait(LookClose.class) || !npc.getOrAddTrait(LookClose.class).canSeeTarget())) {
|
||||||
assumePose(defaultPose);
|
assumePose(defaultPose);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public class DelayTrigger implements WaypointTrigger {
|
|||||||
@Override
|
@Override
|
||||||
public void onWaypointReached(NPC npc, Location waypoint) {
|
public void onWaypointReached(NPC npc, Location waypoint) {
|
||||||
if (delay > 0) {
|
if (delay > 0) {
|
||||||
scheduleTask(npc.getTrait(Waypoints.class).getCurrentProvider());
|
scheduleTask(npc.getOrAddTrait(Waypoints.class).getCurrentProvider());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSkinName() {
|
public String getSkinName() {
|
||||||
String skinName = npc.getTrait(SkinTrait.class).getSkinName();
|
String skinName = npc.getOrAddTrait(SkinTrait.class).getSkinName();
|
||||||
if (skinName == null) {
|
if (skinName == null) {
|
||||||
skinName = npc.getName();
|
skinName = npc.getName();
|
||||||
}
|
}
|
||||||
@ -287,7 +287,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
}
|
}
|
||||||
boolean navigating = npc.getNavigator().isNavigating();
|
boolean navigating = npc.getNavigator().isNavigating();
|
||||||
if (!navigating && getBukkitEntity() != null
|
if (!navigating && getBukkitEntity() != null
|
||||||
&& (!npc.hasTrait(Gravity.class) || npc.getTrait(Gravity.class).hasGravity())
|
&& (!npc.hasTrait(Gravity.class) || npc.getOrAddTrait(Gravity.class).hasGravity())
|
||||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||||
g(0, 0);
|
g(0, 0);
|
||||||
}
|
}
|
||||||
@ -379,17 +379,17 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinName(String name) {
|
public void setSkinName(String name) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinName(name);
|
npc.getOrAddTrait(SkinTrait.class).setSkinName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinName(String name, boolean forceUpdate) {
|
public void setSkinName(String name, boolean forceUpdate) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinName(name, forceUpdate);
|
npc.getOrAddTrait(SkinTrait.class).setSkinName(name, forceUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinPersistent(String skinName, String signature, String data) {
|
public void setSkinPersistent(String skinName, String signature, String data) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data);
|
npc.getOrAddTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTargetLook(Entity target, float yawOffset, float renderOffset) {
|
public void setTargetLook(Entity target, float yawOffset, float renderOffset) {
|
||||||
@ -435,7 +435,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
super((CraftServer) Bukkit.getServer(), entity);
|
super((CraftServer) Bukkit.getServer(), entity);
|
||||||
this.npc = entity.npc;
|
this.npc = entity.npc;
|
||||||
this.cserver = (CraftServer) Bukkit.getServer();
|
this.cserver = (CraftServer) Bukkit.getServer();
|
||||||
npc.getTrait(Inventory.class);
|
npc.getOrAddTrait(Inventory.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,7 +36,7 @@ public class HorseController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public class Commands {
|
|||||||
max = 1)
|
max = 1)
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER, EntityType.ENDER_DRAGON })
|
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER, EntityType.ENDER_DRAGON })
|
||||||
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
BossBarTrait trait = npc.getTrait(BossBarTrait.class);
|
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
|
||||||
if (args.hasValueFlag("color")) {
|
if (args.hasValueFlag("color")) {
|
||||||
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
||||||
trait.setColor(color);
|
trait.setColor(color);
|
||||||
@ -69,7 +69,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.shulker")
|
permission = "citizens.npc.shulker")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
||||||
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
ShulkerTrait trait = npc.getTrait(ShulkerTrait.class);
|
ShulkerTrait trait = npc.getOrAddTrait(ShulkerTrait.class);
|
||||||
boolean hasArg = false;
|
boolean hasArg = false;
|
||||||
if (args.hasValueFlag("peek")) {
|
if (args.hasValueFlag("peek")) {
|
||||||
int peek = (byte) args.getFlagInteger("peek");
|
int peek = (byte) args.getFlagInteger("peek");
|
||||||
@ -103,7 +103,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.snowman")
|
permission = "citizens.npc.snowman")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
||||||
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
SnowmanTrait trait = npc.getTrait(SnowmanTrait.class);
|
SnowmanTrait trait = npc.getOrAddTrait(SnowmanTrait.class);
|
||||||
boolean hasArg = false;
|
boolean hasArg = false;
|
||||||
if (args.hasFlag('d')) {
|
if (args.hasFlag('d')) {
|
||||||
boolean isDerp = trait.toggleDerp();
|
boolean isDerp = trait.toggleDerp();
|
||||||
|
@ -43,14 +43,14 @@ public class PlayerAnimationImpl {
|
|||||||
}
|
}
|
||||||
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
||||||
holder.spawn(player.getBukkitEntity().getLocation());
|
holder.spawn(player.getBukkitEntity().getLocation());
|
||||||
ArmorStandTrait trait = holder.getTrait(ArmorStandTrait.class);
|
ArmorStandTrait trait = holder.getOrAddTrait(ArmorStandTrait.class);
|
||||||
trait.setGravity(false);
|
trait.setGravity(false);
|
||||||
trait.setHasArms(false);
|
trait.setHasArms(false);
|
||||||
trait.setHasBaseplate(false);
|
trait.setHasBaseplate(false);
|
||||||
trait.setSmall(true);
|
trait.setSmall(true);
|
||||||
trait.setMarker(true);
|
trait.setMarker(true);
|
||||||
trait.setVisible(false);
|
trait.setVisible(false);
|
||||||
holder.getTrait(ArmorStandTrait.class).setVisible(false);
|
holder.getOrAddTrait(ArmorStandTrait.class).setVisible(false);
|
||||||
holder.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
|
holder.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
|
||||||
holder.data().set(NPC.DEFAULT_PROTECTED_METADATA, true);
|
holder.data().set(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
|
@ -261,7 +261,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSkinName() {
|
public String getSkinName() {
|
||||||
String skinName = npc.getTrait(SkinTrait.class).getSkinName();
|
String skinName = npc.getOrAddTrait(SkinTrait.class).getSkinName();
|
||||||
if (skinName == null) {
|
if (skinName == null) {
|
||||||
skinName = npc.getName();
|
skinName = npc.getName();
|
||||||
}
|
}
|
||||||
@ -347,7 +347,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
cA();
|
cA();
|
||||||
boolean navigating = npc.getNavigator().isNavigating();
|
boolean navigating = npc.getNavigator().isNavigating();
|
||||||
if (!navigating && getBukkitEntity() != null
|
if (!navigating && getBukkitEntity() != null
|
||||||
&& (!npc.hasTrait(Gravity.class) || npc.getTrait(Gravity.class).hasGravity())
|
&& (!npc.hasTrait(Gravity.class) || npc.getOrAddTrait(Gravity.class).hasGravity())
|
||||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||||
g(0, 0);
|
g(0, 0);
|
||||||
}
|
}
|
||||||
@ -390,17 +390,17 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinName(String name) {
|
public void setSkinName(String name) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinName(name);
|
npc.getOrAddTrait(SkinTrait.class).setSkinName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinName(String name, boolean forceUpdate) {
|
public void setSkinName(String name, boolean forceUpdate) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinName(name, forceUpdate);
|
npc.getOrAddTrait(SkinTrait.class).setSkinName(name, forceUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinPersistent(String skinName, String signature, String data) {
|
public void setSkinPersistent(String skinName, String signature, String data) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data);
|
npc.getOrAddTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTargetLook(Entity target, float yawOffset, float renderOffset) {
|
public void setTargetLook(Entity target, float yawOffset, float renderOffset) {
|
||||||
@ -447,7 +447,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
super((CraftServer) Bukkit.getServer(), entity);
|
super((CraftServer) Bukkit.getServer(), entity);
|
||||||
this.npc = entity.npc;
|
this.npc = entity.npc;
|
||||||
this.cserver = (CraftServer) Bukkit.getServer();
|
this.cserver = (CraftServer) Bukkit.getServer();
|
||||||
npc.getTrait(Inventory.class);
|
npc.getOrAddTrait(Inventory.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,7 +36,7 @@ public class HorseController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public class HorseMuleController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public class HorseSkeletonController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public class HorseZombieController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public class LlamaController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public class Commands {
|
|||||||
max = 1)
|
max = 1)
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER, EntityType.ENDER_DRAGON })
|
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER, EntityType.ENDER_DRAGON })
|
||||||
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
BossBarTrait trait = npc.getTrait(BossBarTrait.class);
|
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
|
||||||
if (args.hasValueFlag("color")) {
|
if (args.hasValueFlag("color")) {
|
||||||
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
||||||
trait.setColor(color);
|
trait.setColor(color);
|
||||||
@ -70,7 +70,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.llama")
|
permission = "citizens.npc.llama")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.LLAMA)
|
@Requirements(selected = true, ownership = true, types = EntityType.LLAMA)
|
||||||
public void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
LlamaTrait trait = npc.getTrait(LlamaTrait.class);
|
LlamaTrait trait = npc.getOrAddTrait(LlamaTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
|
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
|
||||||
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
||||||
@ -101,7 +101,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.shulker")
|
permission = "citizens.npc.shulker")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
||||||
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
ShulkerTrait trait = npc.getTrait(ShulkerTrait.class);
|
ShulkerTrait trait = npc.getOrAddTrait(ShulkerTrait.class);
|
||||||
boolean hasArg = false;
|
boolean hasArg = false;
|
||||||
if (args.hasValueFlag("peek")) {
|
if (args.hasValueFlag("peek")) {
|
||||||
int peek = (byte) args.getFlagInteger("peek");
|
int peek = (byte) args.getFlagInteger("peek");
|
||||||
@ -135,7 +135,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.snowman")
|
permission = "citizens.npc.snowman")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
||||||
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
SnowmanTrait trait = npc.getTrait(SnowmanTrait.class);
|
SnowmanTrait trait = npc.getOrAddTrait(SnowmanTrait.class);
|
||||||
boolean hasArg = false;
|
boolean hasArg = false;
|
||||||
if (args.hasFlag('d')) {
|
if (args.hasFlag('d')) {
|
||||||
boolean isDerp = trait.toggleDerp();
|
boolean isDerp = trait.toggleDerp();
|
||||||
|
@ -43,14 +43,14 @@ public class PlayerAnimationImpl {
|
|||||||
}
|
}
|
||||||
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
||||||
holder.spawn(player.getBukkitEntity().getLocation());
|
holder.spawn(player.getBukkitEntity().getLocation());
|
||||||
ArmorStandTrait trait = holder.getTrait(ArmorStandTrait.class);
|
ArmorStandTrait trait = holder.getOrAddTrait(ArmorStandTrait.class);
|
||||||
trait.setGravity(false);
|
trait.setGravity(false);
|
||||||
trait.setHasArms(false);
|
trait.setHasArms(false);
|
||||||
trait.setHasBaseplate(false);
|
trait.setHasBaseplate(false);
|
||||||
trait.setSmall(true);
|
trait.setSmall(true);
|
||||||
trait.setMarker(true);
|
trait.setMarker(true);
|
||||||
trait.setVisible(false);
|
trait.setVisible(false);
|
||||||
holder.getTrait(ArmorStandTrait.class).setVisible(false);
|
holder.getOrAddTrait(ArmorStandTrait.class).setVisible(false);
|
||||||
holder.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
|
holder.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
|
||||||
holder.data().set(NPC.DEFAULT_PROTECTED_METADATA, true);
|
holder.data().set(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
|
@ -281,7 +281,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSkinName() {
|
public String getSkinName() {
|
||||||
String skinName = npc.getTrait(SkinTrait.class).getSkinName();
|
String skinName = npc.getOrAddTrait(SkinTrait.class).getSkinName();
|
||||||
if (skinName == null) {
|
if (skinName == null) {
|
||||||
skinName = npc.getName();
|
skinName = npc.getName();
|
||||||
}
|
}
|
||||||
@ -374,7 +374,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
Y();
|
Y();
|
||||||
boolean navigating = npc.getNavigator().isNavigating();
|
boolean navigating = npc.getNavigator().isNavigating();
|
||||||
if (!navigating && getBukkitEntity() != null
|
if (!navigating && getBukkitEntity() != null
|
||||||
&& (!npc.hasTrait(Gravity.class) || npc.getTrait(Gravity.class).hasGravity())
|
&& (!npc.hasTrait(Gravity.class) || npc.getOrAddTrait(Gravity.class).hasGravity())
|
||||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||||
a(0, 0, 0);
|
a(0, 0, 0);
|
||||||
}
|
}
|
||||||
@ -417,17 +417,17 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinName(String name) {
|
public void setSkinName(String name) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinName(name);
|
npc.getOrAddTrait(SkinTrait.class).setSkinName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinName(String name, boolean forceUpdate) {
|
public void setSkinName(String name, boolean forceUpdate) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinName(name, forceUpdate);
|
npc.getOrAddTrait(SkinTrait.class).setSkinName(name, forceUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinPersistent(String skinName, String signature, String data) {
|
public void setSkinPersistent(String skinName, String signature, String data) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data);
|
npc.getOrAddTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTargetLook(Entity target, float yawOffset, float renderOffset) {
|
public void setTargetLook(Entity target, float yawOffset, float renderOffset) {
|
||||||
@ -474,7 +474,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
super((CraftServer) Bukkit.getServer(), entity);
|
super((CraftServer) Bukkit.getServer(), entity);
|
||||||
this.npc = entity.npc;
|
this.npc = entity.npc;
|
||||||
this.cserver = (CraftServer) Bukkit.getServer();
|
this.cserver = (CraftServer) Bukkit.getServer();
|
||||||
npc.getTrait(Inventory.class);
|
npc.getOrAddTrait(Inventory.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -39,7 +39,7 @@ public class HorseController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ public class HorseController extends MobEntityController {
|
|||||||
public void M() {
|
public void M() {
|
||||||
super.M();
|
super.M();
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -206,7 +206,7 @@ public class HorseDonkeyController extends MobEntityController {
|
|||||||
public void M() {
|
public void M() {
|
||||||
super.M();
|
super.M();
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -39,7 +39,7 @@ public class HorseMuleController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ public class HorseMuleController extends MobEntityController {
|
|||||||
public void M() {
|
public void M() {
|
||||||
super.M();
|
super.M();
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -39,7 +39,7 @@ public class HorseSkeletonController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ public class HorseSkeletonController extends MobEntityController {
|
|||||||
public void M() {
|
public void M() {
|
||||||
super.M();
|
super.M();
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -39,7 +39,7 @@ public class HorseZombieController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ public class HorseZombieController extends MobEntityController {
|
|||||||
public void M() {
|
public void M() {
|
||||||
super.M();
|
super.M();
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -37,7 +37,7 @@ public class LlamaController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public class Commands {
|
|||||||
max = 1)
|
max = 1)
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER, EntityType.ENDER_DRAGON })
|
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER, EntityType.ENDER_DRAGON })
|
||||||
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
BossBarTrait trait = npc.getTrait(BossBarTrait.class);
|
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
|
||||||
if (args.hasValueFlag("color")) {
|
if (args.hasValueFlag("color")) {
|
||||||
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
||||||
trait.setColor(color);
|
trait.setColor(color);
|
||||||
@ -72,7 +72,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.llama")
|
permission = "citizens.npc.llama")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.LLAMA)
|
@Requirements(selected = true, ownership = true, types = EntityType.LLAMA)
|
||||||
public void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
LlamaTrait trait = npc.getTrait(LlamaTrait.class);
|
LlamaTrait trait = npc.getOrAddTrait(LlamaTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
|
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
|
||||||
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
||||||
@ -103,7 +103,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.parrot")
|
permission = "citizens.npc.parrot")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PARROT)
|
@Requirements(selected = true, ownership = true, types = EntityType.PARROT)
|
||||||
public void parrot(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void parrot(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
ParrotTrait trait = npc.getTrait(ParrotTrait.class);
|
ParrotTrait trait = npc.getOrAddTrait(ParrotTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("variant")) {
|
if (args.hasValueFlag("variant")) {
|
||||||
String variantRaw = args.getFlag("variant");
|
String variantRaw = args.getFlag("variant");
|
||||||
@ -130,7 +130,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.shulker")
|
permission = "citizens.npc.shulker")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
||||||
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
ShulkerTrait trait = npc.getTrait(ShulkerTrait.class);
|
ShulkerTrait trait = npc.getOrAddTrait(ShulkerTrait.class);
|
||||||
boolean hasArg = false;
|
boolean hasArg = false;
|
||||||
if (args.hasValueFlag("peek")) {
|
if (args.hasValueFlag("peek")) {
|
||||||
int peek = (byte) args.getFlagInteger("peek");
|
int peek = (byte) args.getFlagInteger("peek");
|
||||||
@ -164,7 +164,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.snowman")
|
permission = "citizens.npc.snowman")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
||||||
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
SnowmanTrait trait = npc.getTrait(SnowmanTrait.class);
|
SnowmanTrait trait = npc.getOrAddTrait(SnowmanTrait.class);
|
||||||
boolean hasArg = false;
|
boolean hasArg = false;
|
||||||
if (args.hasFlag('d')) {
|
if (args.hasFlag('d')) {
|
||||||
boolean isDerp = trait.toggleDerp();
|
boolean isDerp = trait.toggleDerp();
|
||||||
|
@ -43,7 +43,7 @@ public class PlayerAnimationImpl {
|
|||||||
}
|
}
|
||||||
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
||||||
holder.spawn(player.getBukkitEntity().getLocation());
|
holder.spawn(player.getBukkitEntity().getLocation());
|
||||||
ArmorStandTrait trait = holder.getTrait(ArmorStandTrait.class);
|
ArmorStandTrait trait = holder.getOrAddTrait(ArmorStandTrait.class);
|
||||||
trait.setGravity(false);
|
trait.setGravity(false);
|
||||||
trait.setHasArms(false);
|
trait.setHasArms(false);
|
||||||
trait.setHasBaseplate(false);
|
trait.setHasBaseplate(false);
|
||||||
|
@ -260,7 +260,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSkinName() {
|
public String getSkinName() {
|
||||||
String skinName = npc.getTrait(SkinTrait.class).getSkinName();
|
String skinName = npc.getOrAddTrait(SkinTrait.class).getSkinName();
|
||||||
if (skinName == null) {
|
if (skinName == null) {
|
||||||
skinName = npc.getName();
|
skinName = npc.getName();
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
W();
|
W();
|
||||||
boolean navigating = npc.getNavigator().isNavigating();
|
boolean navigating = npc.getNavigator().isNavigating();
|
||||||
if (!navigating && getBukkitEntity() != null
|
if (!navigating && getBukkitEntity() != null
|
||||||
&& (!npc.hasTrait(Gravity.class) || npc.getTrait(Gravity.class).hasGravity())
|
&& (!npc.hasTrait(Gravity.class) || npc.getOrAddTrait(Gravity.class).hasGravity())
|
||||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||||
a(0, 0, 0);
|
a(0, 0, 0);
|
||||||
}
|
}
|
||||||
@ -387,17 +387,17 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinName(String name) {
|
public void setSkinName(String name) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinName(name);
|
npc.getOrAddTrait(SkinTrait.class).setSkinName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinName(String name, boolean forceUpdate) {
|
public void setSkinName(String name, boolean forceUpdate) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinName(name, forceUpdate);
|
npc.getOrAddTrait(SkinTrait.class).setSkinName(name, forceUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinPersistent(String skinName, String signature, String data) {
|
public void setSkinPersistent(String skinName, String signature, String data) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data);
|
npc.getOrAddTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTargetLook(Entity target, float yawOffset, float renderOffset) {
|
public void setTargetLook(Entity target, float yawOffset, float renderOffset) {
|
||||||
@ -474,7 +474,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
super((CraftServer) Bukkit.getServer(), entity);
|
super((CraftServer) Bukkit.getServer(), entity);
|
||||||
this.npc = entity.npc;
|
this.npc = entity.npc;
|
||||||
this.cserver = (CraftServer) Bukkit.getServer();
|
this.cserver = (CraftServer) Bukkit.getServer();
|
||||||
npc.getTrait(Inventory.class);
|
npc.getOrAddTrait(Inventory.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,7 +42,7 @@ public class HorseController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ public class HorseController extends MobEntityController {
|
|||||||
public void mobTick() {
|
public void mobTick() {
|
||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -209,7 +209,7 @@ public class HorseDonkeyController extends MobEntityController {
|
|||||||
public void mobTick() {
|
public void mobTick() {
|
||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -42,7 +42,7 @@ public class HorseMuleController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ public class HorseMuleController extends MobEntityController {
|
|||||||
public void mobTick() {
|
public void mobTick() {
|
||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -42,7 +42,7 @@ public class HorseSkeletonController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ public class HorseSkeletonController extends MobEntityController {
|
|||||||
public void mobTick() {
|
public void mobTick() {
|
||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -42,7 +42,7 @@ public class HorseZombieController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ public class HorseZombieController extends MobEntityController {
|
|||||||
public void mobTick() {
|
public void mobTick() {
|
||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -40,7 +40,7 @@ public class LlamaController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ public class PufferFishController extends MobEntityController {
|
|||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
npc.update();
|
npc.update();
|
||||||
if (npc.hasTrait(PufferFishTrait.class)) {
|
if (npc.hasTrait(PufferFishTrait.class)) {
|
||||||
setPuffState(npc.getTrait(PufferFishTrait.class).getPuffState());
|
setPuffState(npc.getOrAddTrait(PufferFishTrait.class).getPuffState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ public class Commands {
|
|||||||
max = 1)
|
max = 1)
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER, EntityType.ENDER_DRAGON })
|
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER, EntityType.ENDER_DRAGON })
|
||||||
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
BossBarTrait trait = npc.getTrait(BossBarTrait.class);
|
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
|
||||||
if (args.hasValueFlag("color")) {
|
if (args.hasValueFlag("color")) {
|
||||||
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
||||||
trait.setColor(color);
|
trait.setColor(color);
|
||||||
@ -76,7 +76,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.llama")
|
permission = "citizens.npc.llama")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.LLAMA)
|
@Requirements(selected = true, ownership = true, types = EntityType.LLAMA)
|
||||||
public void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
LlamaTrait trait = npc.getTrait(LlamaTrait.class);
|
LlamaTrait trait = npc.getOrAddTrait(LlamaTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
|
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
|
||||||
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
||||||
@ -107,7 +107,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.parrot")
|
permission = "citizens.npc.parrot")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PARROT)
|
@Requirements(selected = true, ownership = true, types = EntityType.PARROT)
|
||||||
public void parrot(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void parrot(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
ParrotTrait trait = npc.getTrait(ParrotTrait.class);
|
ParrotTrait trait = npc.getOrAddTrait(ParrotTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("variant")) {
|
if (args.hasValueFlag("variant")) {
|
||||||
String variantRaw = args.getFlag("variant");
|
String variantRaw = args.getFlag("variant");
|
||||||
@ -134,7 +134,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.phantom")
|
permission = "citizens.npc.phantom")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PHANTOM)
|
@Requirements(selected = true, ownership = true, types = EntityType.PHANTOM)
|
||||||
public void phantom(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void phantom(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
PhantomTrait trait = npc.getTrait(PhantomTrait.class);
|
PhantomTrait trait = npc.getOrAddTrait(PhantomTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("size")) {
|
if (args.hasValueFlag("size")) {
|
||||||
if (args.getFlagInteger("size") <= 0) {
|
if (args.getFlagInteger("size") <= 0) {
|
||||||
@ -160,7 +160,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.pufferfish")
|
permission = "citizens.npc.pufferfish")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PUFFERFISH)
|
@Requirements(selected = true, ownership = true, types = EntityType.PUFFERFISH)
|
||||||
public void pufferfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void pufferfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
PufferFishTrait trait = npc.getTrait(PufferFishTrait.class);
|
PufferFishTrait trait = npc.getOrAddTrait(PufferFishTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("state")) {
|
if (args.hasValueFlag("state")) {
|
||||||
int state = Math.min(Math.max(args.getFlagInteger("state"), 0), 3);
|
int state = Math.min(Math.max(args.getFlagInteger("state"), 0), 3);
|
||||||
@ -182,7 +182,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.shulker")
|
permission = "citizens.npc.shulker")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
||||||
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
ShulkerTrait trait = npc.getTrait(ShulkerTrait.class);
|
ShulkerTrait trait = npc.getOrAddTrait(ShulkerTrait.class);
|
||||||
boolean hasArg = false;
|
boolean hasArg = false;
|
||||||
if (args.hasValueFlag("peek")) {
|
if (args.hasValueFlag("peek")) {
|
||||||
int peek = (byte) args.getFlagInteger("peek");
|
int peek = (byte) args.getFlagInteger("peek");
|
||||||
@ -215,7 +215,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.tropicalfish")
|
permission = "citizens.npc.tropicalfish")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.TROPICAL_FISH)
|
@Requirements(selected = true, ownership = true, types = EntityType.TROPICAL_FISH)
|
||||||
public void tropicalfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void tropicalfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
TropicalFishTrait trait = npc.getTrait(TropicalFishTrait.class);
|
TropicalFishTrait trait = npc.getOrAddTrait(TropicalFishTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("body")) {
|
if (args.hasValueFlag("body")) {
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("body"));
|
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("body"));
|
||||||
@ -262,7 +262,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.snowman")
|
permission = "citizens.npc.snowman")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
||||||
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
SnowmanTrait trait = npc.getTrait(SnowmanTrait.class);
|
SnowmanTrait trait = npc.getOrAddTrait(SnowmanTrait.class);
|
||||||
boolean hasArg = false;
|
boolean hasArg = false;
|
||||||
if (args.hasFlag('d')) {
|
if (args.hasFlag('d')) {
|
||||||
boolean isDerp = trait.toggleDerp();
|
boolean isDerp = trait.toggleDerp();
|
||||||
|
@ -43,7 +43,7 @@ public class PlayerAnimationImpl {
|
|||||||
}
|
}
|
||||||
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
||||||
holder.spawn(player.getBukkitEntity().getLocation());
|
holder.spawn(player.getBukkitEntity().getLocation());
|
||||||
ArmorStandTrait trait = holder.getTrait(ArmorStandTrait.class);
|
ArmorStandTrait trait = holder.getOrAddTrait(ArmorStandTrait.class);
|
||||||
trait.setGravity(false);
|
trait.setGravity(false);
|
||||||
trait.setHasArms(false);
|
trait.setHasArms(false);
|
||||||
trait.setHasBaseplate(false);
|
trait.setHasBaseplate(false);
|
||||||
|
@ -251,7 +251,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSkinName() {
|
public String getSkinName() {
|
||||||
String skinName = npc.getTrait(SkinTrait.class).getSkinName();
|
String skinName = npc.getOrAddTrait(SkinTrait.class).getSkinName();
|
||||||
if (skinName == null) {
|
if (skinName == null) {
|
||||||
skinName = npc.getName();
|
skinName = npc.getName();
|
||||||
}
|
}
|
||||||
@ -348,7 +348,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
entityBaseTick();
|
entityBaseTick();
|
||||||
boolean navigating = npc.getNavigator().isNavigating();
|
boolean navigating = npc.getNavigator().isNavigating();
|
||||||
if (!navigating && getBukkitEntity() != null
|
if (!navigating && getBukkitEntity() != null
|
||||||
&& (!npc.hasTrait(Gravity.class) || npc.getTrait(Gravity.class).hasGravity())
|
&& (!npc.hasTrait(Gravity.class) || npc.getOrAddTrait(Gravity.class).hasGravity())
|
||||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||||
e(new Vec3D(0, 0, 0));
|
e(new Vec3D(0, 0, 0));
|
||||||
}
|
}
|
||||||
@ -391,17 +391,17 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinName(String name) {
|
public void setSkinName(String name) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinName(name);
|
npc.getOrAddTrait(SkinTrait.class).setSkinName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinName(String name, boolean forceUpdate) {
|
public void setSkinName(String name, boolean forceUpdate) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinName(name, forceUpdate);
|
npc.getOrAddTrait(SkinTrait.class).setSkinName(name, forceUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinPersistent(String skinName, String signature, String data) {
|
public void setSkinPersistent(String skinName, String signature, String data) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data);
|
npc.getOrAddTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTargetLook(Entity target, float yawOffset, float renderOffset) {
|
public void setTargetLook(Entity target, float yawOffset, float renderOffset) {
|
||||||
@ -469,7 +469,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
super((CraftServer) Bukkit.getServer(), entity);
|
super((CraftServer) Bukkit.getServer(), entity);
|
||||||
this.npc = entity.npc;
|
this.npc = entity.npc;
|
||||||
this.cserver = (CraftServer) Bukkit.getServer();
|
this.cserver = (CraftServer) Bukkit.getServer();
|
||||||
npc.getTrait(Inventory.class);
|
npc.getOrAddTrait(Inventory.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -45,7 +45,7 @@ public class HorseController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ public class HorseController extends MobEntityController {
|
|||||||
public void mobTick() {
|
public void mobTick() {
|
||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -227,7 +227,7 @@ public class HorseDonkeyController extends MobEntityController {
|
|||||||
public void mobTick() {
|
public void mobTick() {
|
||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -45,7 +45,7 @@ public class HorseMuleController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ public class HorseMuleController extends MobEntityController {
|
|||||||
public void mobTick() {
|
public void mobTick() {
|
||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -45,7 +45,7 @@ public class HorseSkeletonController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ public class HorseSkeletonController extends MobEntityController {
|
|||||||
public void mobTick() {
|
public void mobTick() {
|
||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -45,7 +45,7 @@ public class HorseZombieController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ public class HorseZombieController extends MobEntityController {
|
|||||||
public void mobTick() {
|
public void mobTick() {
|
||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -43,7 +43,7 @@ public class LlamaController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ public class PufferFishController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
super.tick();
|
super.tick();
|
||||||
if (npc != null && npc.hasTrait(PufferFishTrait.class)) {
|
if (npc != null && npc.hasTrait(PufferFishTrait.class)) {
|
||||||
setPuffState(npc.getTrait(PufferFishTrait.class).getPuffState());
|
setPuffState(npc.getOrAddTrait(PufferFishTrait.class).getPuffState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public class TraderLlamaController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ public class Commands {
|
|||||||
max = 1)
|
max = 1)
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER, EntityType.ENDER_DRAGON })
|
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER, EntityType.ENDER_DRAGON })
|
||||||
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
BossBarTrait trait = npc.getTrait(BossBarTrait.class);
|
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
|
||||||
if (args.hasValueFlag("color")) {
|
if (args.hasValueFlag("color")) {
|
||||||
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
||||||
trait.setColor(color);
|
trait.setColor(color);
|
||||||
@ -91,7 +91,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.cat")
|
permission = "citizens.npc.cat")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.CAT)
|
@Requirements(selected = true, ownership = true, types = EntityType.CAT)
|
||||||
public void cat(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void cat(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
CatTrait trait = npc.getTrait(CatTrait.class);
|
CatTrait trait = npc.getOrAddTrait(CatTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("type")) {
|
if (args.hasValueFlag("type")) {
|
||||||
Cat.Type type = Util.matchEnum(Cat.Type.values(), args.getFlag("type"));
|
Cat.Type type = Util.matchEnum(Cat.Type.values(), args.getFlag("type"));
|
||||||
@ -139,7 +139,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.fox")
|
permission = "citizens.npc.fox")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.FOX)
|
@Requirements(selected = true, ownership = true, types = EntityType.FOX)
|
||||||
public void fox(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void fox(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
FoxTrait trait = npc.getTrait(FoxTrait.class);
|
FoxTrait trait = npc.getOrAddTrait(FoxTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("type")) {
|
if (args.hasValueFlag("type")) {
|
||||||
Fox.Type type = Util.matchEnum(Fox.Type.values(), args.getFlag("type"));
|
Fox.Type type = Util.matchEnum(Fox.Type.values(), args.getFlag("type"));
|
||||||
@ -181,7 +181,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.llama")
|
permission = "citizens.npc.llama")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.LLAMA, EntityType.TRADER_LLAMA })
|
@Requirements(selected = true, ownership = true, types = { EntityType.LLAMA, EntityType.TRADER_LLAMA })
|
||||||
public void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
LlamaTrait trait = npc.getTrait(LlamaTrait.class);
|
LlamaTrait trait = npc.getOrAddTrait(LlamaTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
|
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
|
||||||
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
||||||
@ -212,7 +212,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.mushroomcow")
|
permission = "citizens.npc.mushroomcow")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.MUSHROOM_COW })
|
@Requirements(selected = true, ownership = true, types = { EntityType.MUSHROOM_COW })
|
||||||
public void mushroomcow(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void mushroomcow(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
MushroomCowTrait trait = npc.getTrait(MushroomCowTrait.class);
|
MushroomCowTrait trait = npc.getOrAddTrait(MushroomCowTrait.class);
|
||||||
boolean hasArg = false;
|
boolean hasArg = false;
|
||||||
if (args.hasValueFlag("variant")) {
|
if (args.hasValueFlag("variant")) {
|
||||||
MushroomCow.Variant variant = Util.matchEnum(MushroomCow.Variant.values(), args.getFlag("variant"));
|
MushroomCow.Variant variant = Util.matchEnum(MushroomCow.Variant.values(), args.getFlag("variant"));
|
||||||
@ -240,7 +240,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.panda")
|
permission = "citizens.npc.panda")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PANDA)
|
@Requirements(selected = true, ownership = true, types = EntityType.PANDA)
|
||||||
public void panda(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void panda(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
PandaTrait trait = npc.getTrait(PandaTrait.class);
|
PandaTrait trait = npc.getOrAddTrait(PandaTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("gene")) {
|
if (args.hasValueFlag("gene")) {
|
||||||
Panda.Gene gene = Util.matchEnum(Panda.Gene.values(), args.getFlag("gene"));
|
Panda.Gene gene = Util.matchEnum(Panda.Gene.values(), args.getFlag("gene"));
|
||||||
@ -277,7 +277,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.parrot")
|
permission = "citizens.npc.parrot")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PARROT)
|
@Requirements(selected = true, ownership = true, types = EntityType.PARROT)
|
||||||
public void parrot(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void parrot(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
ParrotTrait trait = npc.getTrait(ParrotTrait.class);
|
ParrotTrait trait = npc.getOrAddTrait(ParrotTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("variant")) {
|
if (args.hasValueFlag("variant")) {
|
||||||
String variantRaw = args.getFlag("variant");
|
String variantRaw = args.getFlag("variant");
|
||||||
@ -304,7 +304,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.phantom")
|
permission = "citizens.npc.phantom")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PHANTOM)
|
@Requirements(selected = true, ownership = true, types = EntityType.PHANTOM)
|
||||||
public void phantom(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void phantom(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
PhantomTrait trait = npc.getTrait(PhantomTrait.class);
|
PhantomTrait trait = npc.getOrAddTrait(PhantomTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("size")) {
|
if (args.hasValueFlag("size")) {
|
||||||
if (args.getFlagInteger("size") <= 0) {
|
if (args.getFlagInteger("size") <= 0) {
|
||||||
@ -330,7 +330,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.pufferfish")
|
permission = "citizens.npc.pufferfish")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PUFFERFISH)
|
@Requirements(selected = true, ownership = true, types = EntityType.PUFFERFISH)
|
||||||
public void pufferfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void pufferfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
PufferFishTrait trait = npc.getTrait(PufferFishTrait.class);
|
PufferFishTrait trait = npc.getOrAddTrait(PufferFishTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("state")) {
|
if (args.hasValueFlag("state")) {
|
||||||
int state = Math.min(Math.max(args.getFlagInteger("state"), 0), 3);
|
int state = Math.min(Math.max(args.getFlagInteger("state"), 0), 3);
|
||||||
@ -352,7 +352,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.shulker")
|
permission = "citizens.npc.shulker")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
||||||
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
ShulkerTrait trait = npc.getTrait(ShulkerTrait.class);
|
ShulkerTrait trait = npc.getOrAddTrait(ShulkerTrait.class);
|
||||||
boolean hasArg = false;
|
boolean hasArg = false;
|
||||||
if (args.hasValueFlag("peek")) {
|
if (args.hasValueFlag("peek")) {
|
||||||
int peek = (byte) args.getFlagInteger("peek");
|
int peek = (byte) args.getFlagInteger("peek");
|
||||||
@ -386,7 +386,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.snowman")
|
permission = "citizens.npc.snowman")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
||||||
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
SnowmanTrait trait = npc.getTrait(SnowmanTrait.class);
|
SnowmanTrait trait = npc.getOrAddTrait(SnowmanTrait.class);
|
||||||
boolean hasArg = false;
|
boolean hasArg = false;
|
||||||
if (args.hasFlag('d')) {
|
if (args.hasFlag('d')) {
|
||||||
boolean isDerp = trait.toggleDerp();
|
boolean isDerp = trait.toggleDerp();
|
||||||
@ -408,7 +408,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.tropicalfish")
|
permission = "citizens.npc.tropicalfish")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.TROPICAL_FISH)
|
@Requirements(selected = true, ownership = true, types = EntityType.TROPICAL_FISH)
|
||||||
public void tropicalfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void tropicalfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
TropicalFishTrait trait = npc.getTrait(TropicalFishTrait.class);
|
TropicalFishTrait trait = npc.getOrAddTrait(TropicalFishTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("body")) {
|
if (args.hasValueFlag("body")) {
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("body"));
|
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("body"));
|
||||||
@ -454,7 +454,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.villager")
|
permission = "citizens.npc.villager")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.VILLAGER)
|
@Requirements(selected = true, ownership = true, types = EntityType.VILLAGER)
|
||||||
public void villager(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void villager(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
VillagerTrait trait = npc.getTrait(VillagerTrait.class);
|
VillagerTrait trait = npc.getOrAddTrait(VillagerTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("level")) {
|
if (args.hasValueFlag("level")) {
|
||||||
if (args.getFlagInteger("level") < 0) {
|
if (args.getFlagInteger("level") < 0) {
|
||||||
@ -478,7 +478,7 @@ public class Commands {
|
|||||||
throw new CommandException(Messages.INVALID_PROFESSION, args.getString(1),
|
throw new CommandException(Messages.INVALID_PROFESSION, args.getString(1),
|
||||||
Joiner.on(',').join(Profession.values()));
|
Joiner.on(',').join(Profession.values()));
|
||||||
}
|
}
|
||||||
npc.getTrait(VillagerProfession.class).setProfession(parsed);
|
npc.getOrAddTrait(VillagerProfession.class).setProfession(parsed);
|
||||||
output += Messaging.tr(Messages.PROFESSION_SET, npc.getName(), args.getFlag("profession"));
|
output += Messaging.tr(Messages.PROFESSION_SET, npc.getName(), args.getFlag("profession"));
|
||||||
}
|
}
|
||||||
if (!output.isEmpty()) {
|
if (!output.isEmpty()) {
|
||||||
|
@ -43,7 +43,7 @@ public class PlayerAnimationImpl {
|
|||||||
}
|
}
|
||||||
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
||||||
holder.spawn(player.getBukkitEntity().getLocation());
|
holder.spawn(player.getBukkitEntity().getLocation());
|
||||||
ArmorStandTrait trait = holder.getTrait(ArmorStandTrait.class);
|
ArmorStandTrait trait = holder.getOrAddTrait(ArmorStandTrait.class);
|
||||||
trait.setGravity(false);
|
trait.setGravity(false);
|
||||||
trait.setHasArms(false);
|
trait.setHasArms(false);
|
||||||
trait.setHasBaseplate(false);
|
trait.setHasBaseplate(false);
|
||||||
|
@ -229,7 +229,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSkinName() {
|
public String getSkinName() {
|
||||||
String skinName = npc.getTrait(SkinTrait.class).getSkinName();
|
String skinName = npc.getOrAddTrait(SkinTrait.class).getSkinName();
|
||||||
if (skinName == null) {
|
if (skinName == null) {
|
||||||
skinName = npc.getName();
|
skinName = npc.getName();
|
||||||
}
|
}
|
||||||
@ -348,7 +348,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
entityBaseTick();
|
entityBaseTick();
|
||||||
boolean navigating = npc.getNavigator().isNavigating();
|
boolean navigating = npc.getNavigator().isNavigating();
|
||||||
if (!navigating && getBukkitEntity() != null
|
if (!navigating && getBukkitEntity() != null
|
||||||
&& (!npc.hasTrait(Gravity.class) || npc.getTrait(Gravity.class).hasGravity())
|
&& (!npc.hasTrait(Gravity.class) || npc.getOrAddTrait(Gravity.class).hasGravity())
|
||||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||||
e(new Vec3D(0, 0, 0));
|
e(new Vec3D(0, 0, 0));
|
||||||
}
|
}
|
||||||
@ -392,17 +392,17 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinName(String name) {
|
public void setSkinName(String name) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinName(name);
|
npc.getOrAddTrait(SkinTrait.class).setSkinName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinName(String name, boolean forceUpdate) {
|
public void setSkinName(String name, boolean forceUpdate) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinName(name, forceUpdate);
|
npc.getOrAddTrait(SkinTrait.class).setSkinName(name, forceUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinPersistent(String skinName, String signature, String data) {
|
public void setSkinPersistent(String skinName, String signature, String data) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data);
|
npc.getOrAddTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTargetLook(Entity target, float yawOffset, float renderOffset) {
|
public void setTargetLook(Entity target, float yawOffset, float renderOffset) {
|
||||||
@ -480,7 +480,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
super((CraftServer) Bukkit.getServer(), entity);
|
super((CraftServer) Bukkit.getServer(), entity);
|
||||||
this.npc = entity.npc;
|
this.npc = entity.npc;
|
||||||
this.cserver = (CraftServer) Bukkit.getServer();
|
this.cserver = (CraftServer) Bukkit.getServer();
|
||||||
npc.getTrait(Inventory.class);
|
npc.getOrAddTrait(Inventory.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -45,7 +45,7 @@ public class HorseController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ public class HorseController extends MobEntityController {
|
|||||||
if (npc == null)
|
if (npc == null)
|
||||||
return;
|
return;
|
||||||
NMSImpl.updateMinecraftAIState(npc, this);
|
NMSImpl.updateMinecraftAIState(npc, this);
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -229,7 +229,7 @@ public class HorseDonkeyController extends MobEntityController {
|
|||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
NMSImpl.updateMinecraftAIState(npc, this);
|
NMSImpl.updateMinecraftAIState(npc, this);
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -45,7 +45,7 @@ public class HorseMuleController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +229,7 @@ public class HorseMuleController extends MobEntityController {
|
|||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
NMSImpl.updateMinecraftAIState(npc, this);
|
NMSImpl.updateMinecraftAIState(npc, this);
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -45,7 +45,7 @@ public class HorseSkeletonController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +230,7 @@ public class HorseSkeletonController extends MobEntityController {
|
|||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
NMSImpl.updateMinecraftAIState(npc, this);
|
NMSImpl.updateMinecraftAIState(npc, this);
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -45,7 +45,7 @@ public class HorseZombieController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +230,7 @@ public class HorseZombieController extends MobEntityController {
|
|||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
NMSImpl.updateMinecraftAIState(npc, this);
|
NMSImpl.updateMinecraftAIState(npc, this);
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -43,7 +43,7 @@ public class LlamaController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ public class PufferFishController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
super.tick();
|
super.tick();
|
||||||
if (npc != null && npc.hasTrait(PufferFishTrait.class)) {
|
if (npc != null && npc.hasTrait(PufferFishTrait.class)) {
|
||||||
setPuffState(npc.getTrait(PufferFishTrait.class).getPuffState());
|
setPuffState(npc.getOrAddTrait(PufferFishTrait.class).getPuffState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public class TraderLlamaController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.bee")
|
permission = "citizens.npc.bee")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.BEE)
|
@Requirements(selected = true, ownership = true, types = EntityType.BEE)
|
||||||
public void bee(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void bee(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
BeeTrait trait = npc.getTrait(BeeTrait.class);
|
BeeTrait trait = npc.getOrAddTrait(BeeTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("anger")) {
|
if (args.hasValueFlag("anger")) {
|
||||||
int anger = args.getFlagInteger("anger");
|
int anger = args.getFlagInteger("anger");
|
||||||
@ -95,7 +95,7 @@ public class Commands {
|
|||||||
max = 1)
|
max = 1)
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER, EntityType.ENDER_DRAGON })
|
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER, EntityType.ENDER_DRAGON })
|
||||||
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
BossBarTrait trait = npc.getTrait(BossBarTrait.class);
|
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
|
||||||
if (args.hasValueFlag("color")) {
|
if (args.hasValueFlag("color")) {
|
||||||
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
||||||
trait.setColor(color);
|
trait.setColor(color);
|
||||||
@ -130,7 +130,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.cat")
|
permission = "citizens.npc.cat")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.CAT)
|
@Requirements(selected = true, ownership = true, types = EntityType.CAT)
|
||||||
public void cat(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void cat(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
CatTrait trait = npc.getTrait(CatTrait.class);
|
CatTrait trait = npc.getOrAddTrait(CatTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("type")) {
|
if (args.hasValueFlag("type")) {
|
||||||
Cat.Type type = Util.matchEnum(Cat.Type.values(), args.getFlag("type"));
|
Cat.Type type = Util.matchEnum(Cat.Type.values(), args.getFlag("type"));
|
||||||
@ -178,7 +178,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.fox")
|
permission = "citizens.npc.fox")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.FOX)
|
@Requirements(selected = true, ownership = true, types = EntityType.FOX)
|
||||||
public void fox(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void fox(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
FoxTrait trait = npc.getTrait(FoxTrait.class);
|
FoxTrait trait = npc.getOrAddTrait(FoxTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("type")) {
|
if (args.hasValueFlag("type")) {
|
||||||
Fox.Type type = Util.matchEnum(Fox.Type.values(), args.getFlag("type"));
|
Fox.Type type = Util.matchEnum(Fox.Type.values(), args.getFlag("type"));
|
||||||
@ -220,7 +220,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.llama")
|
permission = "citizens.npc.llama")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.LLAMA, EntityType.TRADER_LLAMA })
|
@Requirements(selected = true, ownership = true, types = { EntityType.LLAMA, EntityType.TRADER_LLAMA })
|
||||||
public void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
LlamaTrait trait = npc.getTrait(LlamaTrait.class);
|
LlamaTrait trait = npc.getOrAddTrait(LlamaTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
|
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
|
||||||
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
||||||
@ -251,7 +251,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.mushroomcow")
|
permission = "citizens.npc.mushroomcow")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.MUSHROOM_COW })
|
@Requirements(selected = true, ownership = true, types = { EntityType.MUSHROOM_COW })
|
||||||
public void mushroomcow(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void mushroomcow(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
MushroomCowTrait trait = npc.getTrait(MushroomCowTrait.class);
|
MushroomCowTrait trait = npc.getOrAddTrait(MushroomCowTrait.class);
|
||||||
boolean hasArg = false;
|
boolean hasArg = false;
|
||||||
if (args.hasValueFlag("variant")) {
|
if (args.hasValueFlag("variant")) {
|
||||||
MushroomCow.Variant variant = Util.matchEnum(MushroomCow.Variant.values(), args.getFlag("variant"));
|
MushroomCow.Variant variant = Util.matchEnum(MushroomCow.Variant.values(), args.getFlag("variant"));
|
||||||
@ -280,7 +280,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.panda")
|
permission = "citizens.npc.panda")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PANDA)
|
@Requirements(selected = true, ownership = true, types = EntityType.PANDA)
|
||||||
public void panda(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void panda(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
PandaTrait trait = npc.getTrait(PandaTrait.class);
|
PandaTrait trait = npc.getOrAddTrait(PandaTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("gene")) {
|
if (args.hasValueFlag("gene")) {
|
||||||
Panda.Gene gene = Util.matchEnum(Panda.Gene.values(), args.getFlag("gene"));
|
Panda.Gene gene = Util.matchEnum(Panda.Gene.values(), args.getFlag("gene"));
|
||||||
@ -321,7 +321,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.parrot")
|
permission = "citizens.npc.parrot")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PARROT)
|
@Requirements(selected = true, ownership = true, types = EntityType.PARROT)
|
||||||
public void parrot(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void parrot(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
ParrotTrait trait = npc.getTrait(ParrotTrait.class);
|
ParrotTrait trait = npc.getOrAddTrait(ParrotTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("variant")) {
|
if (args.hasValueFlag("variant")) {
|
||||||
String variantRaw = args.getFlag("variant");
|
String variantRaw = args.getFlag("variant");
|
||||||
@ -348,7 +348,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.phantom")
|
permission = "citizens.npc.phantom")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PHANTOM)
|
@Requirements(selected = true, ownership = true, types = EntityType.PHANTOM)
|
||||||
public void phantom(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void phantom(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
PhantomTrait trait = npc.getTrait(PhantomTrait.class);
|
PhantomTrait trait = npc.getOrAddTrait(PhantomTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("size")) {
|
if (args.hasValueFlag("size")) {
|
||||||
if (args.getFlagInteger("size") <= 0) {
|
if (args.getFlagInteger("size") <= 0) {
|
||||||
@ -374,7 +374,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.pufferfish")
|
permission = "citizens.npc.pufferfish")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PUFFERFISH)
|
@Requirements(selected = true, ownership = true, types = EntityType.PUFFERFISH)
|
||||||
public void pufferfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void pufferfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
PufferFishTrait trait = npc.getTrait(PufferFishTrait.class);
|
PufferFishTrait trait = npc.getOrAddTrait(PufferFishTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("state")) {
|
if (args.hasValueFlag("state")) {
|
||||||
int state = Math.min(Math.max(args.getFlagInteger("state"), 0), 3);
|
int state = Math.min(Math.max(args.getFlagInteger("state"), 0), 3);
|
||||||
@ -396,7 +396,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.shulker")
|
permission = "citizens.npc.shulker")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
||||||
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
ShulkerTrait trait = npc.getTrait(ShulkerTrait.class);
|
ShulkerTrait trait = npc.getOrAddTrait(ShulkerTrait.class);
|
||||||
boolean hasArg = false;
|
boolean hasArg = false;
|
||||||
if (args.hasValueFlag("peek")) {
|
if (args.hasValueFlag("peek")) {
|
||||||
int peek = (byte) args.getFlagInteger("peek");
|
int peek = (byte) args.getFlagInteger("peek");
|
||||||
@ -430,7 +430,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.snowman")
|
permission = "citizens.npc.snowman")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
||||||
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
SnowmanTrait trait = npc.getTrait(SnowmanTrait.class);
|
SnowmanTrait trait = npc.getOrAddTrait(SnowmanTrait.class);
|
||||||
boolean hasArg = false;
|
boolean hasArg = false;
|
||||||
if (args.hasFlag('d')) {
|
if (args.hasFlag('d')) {
|
||||||
boolean isDerp = trait.toggleDerp();
|
boolean isDerp = trait.toggleDerp();
|
||||||
@ -452,7 +452,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.tropicalfish")
|
permission = "citizens.npc.tropicalfish")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.TROPICAL_FISH)
|
@Requirements(selected = true, ownership = true, types = EntityType.TROPICAL_FISH)
|
||||||
public void tropicalfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void tropicalfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
TropicalFishTrait trait = npc.getTrait(TropicalFishTrait.class);
|
TropicalFishTrait trait = npc.getOrAddTrait(TropicalFishTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("body")) {
|
if (args.hasValueFlag("body")) {
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("body"));
|
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("body"));
|
||||||
@ -498,7 +498,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.villager")
|
permission = "citizens.npc.villager")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.VILLAGER)
|
@Requirements(selected = true, ownership = true, types = EntityType.VILLAGER)
|
||||||
public void villager(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void villager(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
VillagerTrait trait = npc.getTrait(VillagerTrait.class);
|
VillagerTrait trait = npc.getOrAddTrait(VillagerTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("level")) {
|
if (args.hasValueFlag("level")) {
|
||||||
if (args.getFlagInteger("level") < 0) {
|
if (args.getFlagInteger("level") < 0) {
|
||||||
@ -522,7 +522,7 @@ public class Commands {
|
|||||||
throw new CommandException(Messages.INVALID_PROFESSION, args.getString(1),
|
throw new CommandException(Messages.INVALID_PROFESSION, args.getString(1),
|
||||||
Joiner.on(',').join(Profession.values()));
|
Joiner.on(',').join(Profession.values()));
|
||||||
}
|
}
|
||||||
npc.getTrait(VillagerProfession.class).setProfession(parsed);
|
npc.getOrAddTrait(VillagerProfession.class).setProfession(parsed);
|
||||||
output += Messaging.tr(Messages.PROFESSION_SET, npc.getName(), args.getFlag("profession"));
|
output += Messaging.tr(Messages.PROFESSION_SET, npc.getName(), args.getFlag("profession"));
|
||||||
}
|
}
|
||||||
if (!output.isEmpty()) {
|
if (!output.isEmpty()) {
|
||||||
|
@ -43,7 +43,7 @@ public class PlayerAnimationImpl {
|
|||||||
}
|
}
|
||||||
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
||||||
holder.spawn(player.getBukkitEntity().getLocation());
|
holder.spawn(player.getBukkitEntity().getLocation());
|
||||||
ArmorStandTrait trait = holder.getTrait(ArmorStandTrait.class);
|
ArmorStandTrait trait = holder.getOrAddTrait(ArmorStandTrait.class);
|
||||||
trait.setGravity(false);
|
trait.setGravity(false);
|
||||||
trait.setHasArms(false);
|
trait.setHasArms(false);
|
||||||
trait.setHasBaseplate(false);
|
trait.setHasBaseplate(false);
|
||||||
|
@ -243,7 +243,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSkinName() {
|
public String getSkinName() {
|
||||||
String skinName = npc.getTrait(SkinTrait.class).getSkinName();
|
String skinName = npc.getOrAddTrait(SkinTrait.class).getSkinName();
|
||||||
if (skinName == null) {
|
if (skinName == null) {
|
||||||
skinName = npc.getName();
|
skinName = npc.getName();
|
||||||
}
|
}
|
||||||
@ -379,7 +379,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
entityBaseTick();
|
entityBaseTick();
|
||||||
boolean navigating = npc.getNavigator().isNavigating();
|
boolean navigating = npc.getNavigator().isNavigating();
|
||||||
if (!navigating && getBukkitEntity() != null
|
if (!navigating && getBukkitEntity() != null
|
||||||
&& (!npc.hasTrait(Gravity.class) || npc.getTrait(Gravity.class).hasGravity())
|
&& (!npc.hasTrait(Gravity.class) || npc.getOrAddTrait(Gravity.class).hasGravity())
|
||||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||||
g(new Vec3D(0, 0, 0));
|
g(new Vec3D(0, 0, 0));
|
||||||
}
|
}
|
||||||
@ -423,17 +423,17 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinName(String name) {
|
public void setSkinName(String name) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinName(name);
|
npc.getOrAddTrait(SkinTrait.class).setSkinName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinName(String name, boolean forceUpdate) {
|
public void setSkinName(String name, boolean forceUpdate) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinName(name, forceUpdate);
|
npc.getOrAddTrait(SkinTrait.class).setSkinName(name, forceUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinPersistent(String skinName, String signature, String data) {
|
public void setSkinPersistent(String skinName, String signature, String data) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data);
|
npc.getOrAddTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTargetLook(Entity target, float yawOffset, float renderOffset) {
|
public void setTargetLook(Entity target, float yawOffset, float renderOffset) {
|
||||||
@ -512,7 +512,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
super((CraftServer) Bukkit.getServer(), entity);
|
super((CraftServer) Bukkit.getServer(), entity);
|
||||||
this.npc = entity.npc;
|
this.npc = entity.npc;
|
||||||
this.cserver = (CraftServer) Bukkit.getServer();
|
this.cserver = (CraftServer) Bukkit.getServer();
|
||||||
npc.getTrait(Inventory.class);
|
npc.getOrAddTrait(Inventory.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -45,7 +45,7 @@ public class HorseController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ public class HorseController extends MobEntityController {
|
|||||||
if (npc == null)
|
if (npc == null)
|
||||||
return;
|
return;
|
||||||
NMSImpl.updateMinecraftAIState(npc, this);
|
NMSImpl.updateMinecraftAIState(npc, this);
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -229,7 +229,7 @@ public class HorseDonkeyController extends MobEntityController {
|
|||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
NMSImpl.updateMinecraftAIState(npc, this);
|
NMSImpl.updateMinecraftAIState(npc, this);
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -45,7 +45,7 @@ public class HorseMuleController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +229,7 @@ public class HorseMuleController extends MobEntityController {
|
|||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
NMSImpl.updateMinecraftAIState(npc, this);
|
NMSImpl.updateMinecraftAIState(npc, this);
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -45,7 +45,7 @@ public class HorseSkeletonController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +230,7 @@ public class HorseSkeletonController extends MobEntityController {
|
|||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
NMSImpl.updateMinecraftAIState(npc, this);
|
NMSImpl.updateMinecraftAIState(npc, this);
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -45,7 +45,7 @@ public class HorseZombieController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +230,7 @@ public class HorseZombieController extends MobEntityController {
|
|||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
NMSImpl.updateMinecraftAIState(npc, this);
|
NMSImpl.updateMinecraftAIState(npc, this);
|
||||||
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
|
if (npc.hasTrait(Controllable.class) && npc.getOrAddTrait(Controllable.class).isEnabled()) {
|
||||||
riding = getBukkitEntity().getPassengers().size() > 0;
|
riding = getBukkitEntity().getPassengers().size() > 0;
|
||||||
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
|
||||||
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
|
||||||
|
@ -43,7 +43,7 @@ public class LlamaController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ public class PufferFishController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
super.tick();
|
super.tick();
|
||||||
if (npc != null && npc.hasTrait(PufferFishTrait.class)) {
|
if (npc != null && npc.hasTrait(PufferFishTrait.class)) {
|
||||||
setPuffState(npc.getTrait(PufferFishTrait.class).getPuffState());
|
setPuffState(npc.getOrAddTrait(PufferFishTrait.class).getPuffState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public class TraderLlamaController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.bee")
|
permission = "citizens.npc.bee")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.BEE)
|
@Requirements(selected = true, ownership = true, types = EntityType.BEE)
|
||||||
public void bee(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void bee(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
BeeTrait trait = npc.getTrait(BeeTrait.class);
|
BeeTrait trait = npc.getOrAddTrait(BeeTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("anger")) {
|
if (args.hasValueFlag("anger")) {
|
||||||
int anger = args.getFlagInteger("anger");
|
int anger = args.getFlagInteger("anger");
|
||||||
@ -95,7 +95,7 @@ public class Commands {
|
|||||||
max = 1)
|
max = 1)
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER, EntityType.ENDER_DRAGON })
|
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER, EntityType.ENDER_DRAGON })
|
||||||
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
BossBarTrait trait = npc.getTrait(BossBarTrait.class);
|
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
|
||||||
if (args.hasValueFlag("color")) {
|
if (args.hasValueFlag("color")) {
|
||||||
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
|
||||||
trait.setColor(color);
|
trait.setColor(color);
|
||||||
@ -130,7 +130,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.cat")
|
permission = "citizens.npc.cat")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.CAT)
|
@Requirements(selected = true, ownership = true, types = EntityType.CAT)
|
||||||
public void cat(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void cat(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
CatTrait trait = npc.getTrait(CatTrait.class);
|
CatTrait trait = npc.getOrAddTrait(CatTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("type")) {
|
if (args.hasValueFlag("type")) {
|
||||||
Cat.Type type = Util.matchEnum(Cat.Type.values(), args.getFlag("type"));
|
Cat.Type type = Util.matchEnum(Cat.Type.values(), args.getFlag("type"));
|
||||||
@ -178,7 +178,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.fox")
|
permission = "citizens.npc.fox")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.FOX)
|
@Requirements(selected = true, ownership = true, types = EntityType.FOX)
|
||||||
public void fox(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void fox(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
FoxTrait trait = npc.getTrait(FoxTrait.class);
|
FoxTrait trait = npc.getOrAddTrait(FoxTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("type")) {
|
if (args.hasValueFlag("type")) {
|
||||||
Fox.Type type = Util.matchEnum(Fox.Type.values(), args.getFlag("type"));
|
Fox.Type type = Util.matchEnum(Fox.Type.values(), args.getFlag("type"));
|
||||||
@ -220,7 +220,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.llama")
|
permission = "citizens.npc.llama")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.LLAMA, EntityType.TRADER_LLAMA })
|
@Requirements(selected = true, ownership = true, types = { EntityType.LLAMA, EntityType.TRADER_LLAMA })
|
||||||
public void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void llama(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
LlamaTrait trait = npc.getTrait(LlamaTrait.class);
|
LlamaTrait trait = npc.getOrAddTrait(LlamaTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
|
if (args.hasValueFlag("color") || args.hasValueFlag("colour")) {
|
||||||
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
String colorRaw = args.getFlag("color", args.getFlag("colour"));
|
||||||
@ -251,7 +251,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.mushroomcow")
|
permission = "citizens.npc.mushroomcow")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.MUSHROOM_COW })
|
@Requirements(selected = true, ownership = true, types = { EntityType.MUSHROOM_COW })
|
||||||
public void mushroomcow(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void mushroomcow(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
MushroomCowTrait trait = npc.getTrait(MushroomCowTrait.class);
|
MushroomCowTrait trait = npc.getOrAddTrait(MushroomCowTrait.class);
|
||||||
boolean hasArg = false;
|
boolean hasArg = false;
|
||||||
if (args.hasValueFlag("variant")) {
|
if (args.hasValueFlag("variant")) {
|
||||||
MushroomCow.Variant variant = Util.matchEnum(MushroomCow.Variant.values(), args.getFlag("variant"));
|
MushroomCow.Variant variant = Util.matchEnum(MushroomCow.Variant.values(), args.getFlag("variant"));
|
||||||
@ -280,7 +280,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.panda")
|
permission = "citizens.npc.panda")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PANDA)
|
@Requirements(selected = true, ownership = true, types = EntityType.PANDA)
|
||||||
public void panda(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void panda(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
PandaTrait trait = npc.getTrait(PandaTrait.class);
|
PandaTrait trait = npc.getOrAddTrait(PandaTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("gene")) {
|
if (args.hasValueFlag("gene")) {
|
||||||
Panda.Gene gene = Util.matchEnum(Panda.Gene.values(), args.getFlag("gene"));
|
Panda.Gene gene = Util.matchEnum(Panda.Gene.values(), args.getFlag("gene"));
|
||||||
@ -321,7 +321,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.parrot")
|
permission = "citizens.npc.parrot")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PARROT)
|
@Requirements(selected = true, ownership = true, types = EntityType.PARROT)
|
||||||
public void parrot(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void parrot(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
ParrotTrait trait = npc.getTrait(ParrotTrait.class);
|
ParrotTrait trait = npc.getOrAddTrait(ParrotTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("variant")) {
|
if (args.hasValueFlag("variant")) {
|
||||||
String variantRaw = args.getFlag("variant");
|
String variantRaw = args.getFlag("variant");
|
||||||
@ -348,7 +348,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.phantom")
|
permission = "citizens.npc.phantom")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PHANTOM)
|
@Requirements(selected = true, ownership = true, types = EntityType.PHANTOM)
|
||||||
public void phantom(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void phantom(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
PhantomTrait trait = npc.getTrait(PhantomTrait.class);
|
PhantomTrait trait = npc.getOrAddTrait(PhantomTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("size")) {
|
if (args.hasValueFlag("size")) {
|
||||||
if (args.getFlagInteger("size") <= 0) {
|
if (args.getFlagInteger("size") <= 0) {
|
||||||
@ -374,7 +374,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.pufferfish")
|
permission = "citizens.npc.pufferfish")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.PUFFERFISH)
|
@Requirements(selected = true, ownership = true, types = EntityType.PUFFERFISH)
|
||||||
public void pufferfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void pufferfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
PufferFishTrait trait = npc.getTrait(PufferFishTrait.class);
|
PufferFishTrait trait = npc.getOrAddTrait(PufferFishTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("state")) {
|
if (args.hasValueFlag("state")) {
|
||||||
int state = Math.min(Math.max(args.getFlagInteger("state"), 0), 3);
|
int state = Math.min(Math.max(args.getFlagInteger("state"), 0), 3);
|
||||||
@ -396,7 +396,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.shulker")
|
permission = "citizens.npc.shulker")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
@Requirements(selected = true, ownership = true, types = { EntityType.SHULKER })
|
||||||
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void shulker(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
ShulkerTrait trait = npc.getTrait(ShulkerTrait.class);
|
ShulkerTrait trait = npc.getOrAddTrait(ShulkerTrait.class);
|
||||||
boolean hasArg = false;
|
boolean hasArg = false;
|
||||||
if (args.hasValueFlag("peek")) {
|
if (args.hasValueFlag("peek")) {
|
||||||
int peek = (byte) args.getFlagInteger("peek");
|
int peek = (byte) args.getFlagInteger("peek");
|
||||||
@ -430,7 +430,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.snowman")
|
permission = "citizens.npc.snowman")
|
||||||
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
@Requirements(selected = true, ownership = true, types = { EntityType.SNOWMAN })
|
||||||
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void snowman(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
SnowmanTrait trait = npc.getTrait(SnowmanTrait.class);
|
SnowmanTrait trait = npc.getOrAddTrait(SnowmanTrait.class);
|
||||||
boolean hasArg = false;
|
boolean hasArg = false;
|
||||||
if (args.hasFlag('d')) {
|
if (args.hasFlag('d')) {
|
||||||
boolean isDerp = trait.toggleDerp();
|
boolean isDerp = trait.toggleDerp();
|
||||||
@ -452,7 +452,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.tropicalfish")
|
permission = "citizens.npc.tropicalfish")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.TROPICAL_FISH)
|
@Requirements(selected = true, ownership = true, types = EntityType.TROPICAL_FISH)
|
||||||
public void tropicalfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void tropicalfish(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
TropicalFishTrait trait = npc.getTrait(TropicalFishTrait.class);
|
TropicalFishTrait trait = npc.getOrAddTrait(TropicalFishTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("body")) {
|
if (args.hasValueFlag("body")) {
|
||||||
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("body"));
|
DyeColor color = Util.matchEnum(DyeColor.values(), args.getFlag("body"));
|
||||||
@ -498,7 +498,7 @@ public class Commands {
|
|||||||
permission = "citizens.npc.villager")
|
permission = "citizens.npc.villager")
|
||||||
@Requirements(selected = true, ownership = true, types = EntityType.VILLAGER)
|
@Requirements(selected = true, ownership = true, types = EntityType.VILLAGER)
|
||||||
public void villager(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void villager(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
VillagerTrait trait = npc.getTrait(VillagerTrait.class);
|
VillagerTrait trait = npc.getOrAddTrait(VillagerTrait.class);
|
||||||
String output = "";
|
String output = "";
|
||||||
if (args.hasValueFlag("level")) {
|
if (args.hasValueFlag("level")) {
|
||||||
if (args.getFlagInteger("level") < 0) {
|
if (args.getFlagInteger("level") < 0) {
|
||||||
@ -522,7 +522,7 @@ public class Commands {
|
|||||||
throw new CommandException(Messages.INVALID_PROFESSION, args.getString(1),
|
throw new CommandException(Messages.INVALID_PROFESSION, args.getString(1),
|
||||||
Joiner.on(',').join(Profession.values()));
|
Joiner.on(',').join(Profession.values()));
|
||||||
}
|
}
|
||||||
npc.getTrait(VillagerProfession.class).setProfession(parsed);
|
npc.getOrAddTrait(VillagerProfession.class).setProfession(parsed);
|
||||||
output += Messaging.tr(Messages.PROFESSION_SET, npc.getName(), args.getFlag("profession"));
|
output += Messaging.tr(Messages.PROFESSION_SET, npc.getName(), args.getFlag("profession"));
|
||||||
}
|
}
|
||||||
if (!output.isEmpty()) {
|
if (!output.isEmpty()) {
|
||||||
|
@ -43,7 +43,7 @@ public class PlayerAnimationImpl {
|
|||||||
}
|
}
|
||||||
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
||||||
holder.spawn(player.getBukkitEntity().getLocation());
|
holder.spawn(player.getBukkitEntity().getLocation());
|
||||||
ArmorStandTrait trait = holder.getTrait(ArmorStandTrait.class);
|
ArmorStandTrait trait = holder.getOrAddTrait(ArmorStandTrait.class);
|
||||||
trait.setGravity(false);
|
trait.setGravity(false);
|
||||||
trait.setHasArms(false);
|
trait.setHasArms(false);
|
||||||
trait.setHasBaseplate(false);
|
trait.setHasBaseplate(false);
|
||||||
|
@ -231,7 +231,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSkinName() {
|
public String getSkinName() {
|
||||||
String skinName = npc.getTrait(SkinTrait.class).getSkinName();
|
String skinName = npc.getOrAddTrait(SkinTrait.class).getSkinName();
|
||||||
if (skinName == null) {
|
if (skinName == null) {
|
||||||
skinName = npc.getName();
|
skinName = npc.getName();
|
||||||
}
|
}
|
||||||
@ -292,7 +292,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
}
|
}
|
||||||
boolean navigating = npc.getNavigator().isNavigating();
|
boolean navigating = npc.getNavigator().isNavigating();
|
||||||
if (!navigating && getBukkitEntity() != null
|
if (!navigating && getBukkitEntity() != null
|
||||||
&& (!npc.hasTrait(Gravity.class) || npc.getTrait(Gravity.class).hasGravity())
|
&& (!npc.hasTrait(Gravity.class) || npc.getOrAddTrait(Gravity.class).hasGravity())
|
||||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||||
g(0, 0);
|
g(0, 0);
|
||||||
}
|
}
|
||||||
@ -357,17 +357,17 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinName(String name) {
|
public void setSkinName(String name) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinName(name);
|
npc.getOrAddTrait(SkinTrait.class).setSkinName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinName(String name, boolean forceUpdate) {
|
public void setSkinName(String name, boolean forceUpdate) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinName(name, forceUpdate);
|
npc.getOrAddTrait(SkinTrait.class).setSkinName(name, forceUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSkinPersistent(String skinName, String signature, String data) {
|
public void setSkinPersistent(String skinName, String signature, String data) {
|
||||||
npc.getTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data);
|
npc.getOrAddTrait(SkinTrait.class).setSkinPersistent(skinName, signature, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTargetLook(Entity target, float yawOffset, float renderOffset) {
|
public void setTargetLook(Entity target, float yawOffset, float renderOffset) {
|
||||||
@ -433,7 +433,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
super((CraftServer) Bukkit.getServer(), entity);
|
super((CraftServer) Bukkit.getServer(), entity);
|
||||||
this.npc = entity.npc;
|
this.npc = entity.npc;
|
||||||
this.cserver = (CraftServer) Bukkit.getServer();
|
this.cserver = (CraftServer) Bukkit.getServer();
|
||||||
npc.getTrait(Inventory.class);
|
npc.getOrAddTrait(Inventory.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,7 +35,7 @@ public class HorseController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawn(Location at, NPC npc) {
|
public void spawn(Location at, NPC npc) {
|
||||||
npc.getTrait(HorseModifiers.class);
|
npc.getOrAddTrait(HorseModifiers.class);
|
||||||
super.spawn(at, npc);
|
super.spawn(at, npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ public class PlayerAnimationImpl {
|
|||||||
}
|
}
|
||||||
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
|
||||||
holder.spawn(player.getBukkitEntity().getLocation());
|
holder.spawn(player.getBukkitEntity().getLocation());
|
||||||
ArmorStandTrait trait = holder.getTrait(ArmorStandTrait.class);
|
ArmorStandTrait trait = holder.getOrAddTrait(ArmorStandTrait.class);
|
||||||
trait.setGravity(false);
|
trait.setGravity(false);
|
||||||
trait.setHasArms(false);
|
trait.setHasArms(false);
|
||||||
trait.setHasBaseplate(false);
|
trait.setHasBaseplate(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user