mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-08 16:32:01 +01:00
Add /npc bossbar --track and fix equipment caching logic
This commit is contained in:
parent
48798ff9b3
commit
3685d33980
@ -165,16 +165,17 @@ public class NPCCommands {
|
|||||||
Messaging.sendTr(sender, trait.toggle() ? Messages.AGE_LOCKED : Messages.AGE_UNLOCKED);
|
Messaging.sendTr(sender, trait.toggle() ? Messages.AGE_LOCKED : Messages.AGE_UNLOCKED);
|
||||||
}
|
}
|
||||||
if (args.argsLength() <= 1) {
|
if (args.argsLength() <= 1) {
|
||||||
if (!toggleLock)
|
if (!toggleLock) {
|
||||||
trait.describe(sender);
|
trait.describe(sender);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int age = 0;
|
int age = 0;
|
||||||
try {
|
try {
|
||||||
age = args.getInteger(1);
|
age = args.getInteger(1);
|
||||||
if (age > 0) {
|
if (age > 0)
|
||||||
throw new CommandException(Messages.INVALID_AGE);
|
throw new CommandException(Messages.INVALID_AGE);
|
||||||
}
|
|
||||||
Messaging.sendTr(sender, Messages.AGE_SET_NORMAL, npc.getName(), age);
|
Messaging.sendTr(sender, Messages.AGE_SET_NORMAL, npc.getName(), age);
|
||||||
} catch (NumberFormatException ex) {
|
} catch (NumberFormatException ex) {
|
||||||
if (args.getString(1).equalsIgnoreCase("baby")) {
|
if (args.getString(1).equalsIgnoreCase("baby")) {
|
||||||
@ -535,12 +536,14 @@ public class NPCCommands {
|
|||||||
Messaging.sendErrorTr(sender, Messages.NPC_NAME_TOO_LONG, nameLength);
|
Messaging.sendErrorTr(sender, Messages.NPC_NAME_TOO_LONG, nameLength);
|
||||||
name = name.substring(0, nameLength);
|
name = name.substring(0, nameLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name.length() == 0)
|
if (name.length() == 0)
|
||||||
throw new CommandException();
|
throw new CommandException();
|
||||||
|
|
||||||
if (!sender.hasPermission("citizens.npc.create.*") && !sender.hasPermission("citizens.npc.createall")
|
if (!sender.hasPermission("citizens.npc.create.*") && !sender.hasPermission("citizens.npc.createall")
|
||||||
&& !sender.hasPermission("citizens.npc.create." + type.name().toLowerCase().replace("_", "")))
|
&& !sender.hasPermission("citizens.npc.create." + type.name().toLowerCase().replace("_", "")))
|
||||||
throw new NoPermissionsException();
|
throw new NoPermissionsException();
|
||||||
|
|
||||||
NPCRegistry registry = CitizensAPI.getNPCRegistry();
|
NPCRegistry registry = CitizensAPI.getNPCRegistry();
|
||||||
if (args.hasValueFlag("registry")) {
|
if (args.hasValueFlag("registry")) {
|
||||||
registry = CitizensAPI.getNamedNPCRegistry(args.getFlag("registry"));
|
registry = CitizensAPI.getNamedNPCRegistry(args.getFlag("registry"));
|
||||||
@ -554,14 +557,14 @@ public class NPCCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
npc = registry.createNPC(type, name);
|
npc = registry.createNPC(type, name);
|
||||||
String msg = "You created [[" + npc.getName() + "]] (ID [[" + npc.getId() + "]])";
|
String msg = "Created [[" + npc.getName() + "]] (ID [[" + npc.getId() + "]])";
|
||||||
|
|
||||||
int age = 0;
|
int age = 0;
|
||||||
if (args.hasFlag('b')) {
|
if (args.hasFlag('b')) {
|
||||||
if (!Ageable.class.isAssignableFrom(type.getEntityClass()))
|
if (!Ageable.class.isAssignableFrom(type.getEntityClass())) {
|
||||||
Messaging.sendErrorTr(sender, Messages.MOBTYPE_CANNOT_BE_AGED,
|
Messaging.sendErrorTr(sender, Messages.MOBTYPE_CANNOT_BE_AGED,
|
||||||
type.name().toLowerCase().replace("_", "-"));
|
type.name().toLowerCase().replace("_", "-"));
|
||||||
else {
|
} else {
|
||||||
age = -24000;
|
age = -24000;
|
||||||
msg += " as a baby";
|
msg += " as a baby";
|
||||||
}
|
}
|
||||||
|
@ -197,9 +197,11 @@ public class HologramTrait extends Trait {
|
|||||||
onDespawn();
|
onDespawn();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentLoc == null) {
|
if (currentLoc == null) {
|
||||||
currentLoc = npc.getStoredLocation();
|
currentLoc = npc.getStoredLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean nameplateVisible = Boolean
|
boolean nameplateVisible = Boolean
|
||||||
.parseBoolean(npc.data().<Object> get(NPC.Metadata.NAMEPLATE_VISIBLE, true).toString());
|
.parseBoolean(npc.data().<Object> get(NPC.Metadata.NAMEPLATE_VISIBLE, true).toString());
|
||||||
if (npc.requiresNameHologram()) {
|
if (npc.requiresNameHologram()) {
|
||||||
@ -210,6 +212,7 @@ public class HologramTrait extends Trait {
|
|||||||
nameNPC = createHologram(npc.getFullName(), 0);
|
nameNPC = createHologram(npc.getFullName(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean update = currentLoc.getWorld() != npc.getStoredLocation().getWorld()
|
boolean update = currentLoc.getWorld() != npc.getStoredLocation().getWorld()
|
||||||
|| currentLoc.distance(npc.getStoredLocation()) >= 0.001 || lastNameplateVisible != nameplateVisible
|
|| currentLoc.distance(npc.getStoredLocation()) >= 0.001 || lastNameplateVisible != nameplateVisible
|
||||||
|| Math.abs(lastEntityHeight - getEntityHeight()) >= 0.05;
|
|| Math.abs(lastEntityHeight - getEntityHeight()) >= 0.05;
|
||||||
@ -219,28 +222,34 @@ public class HologramTrait extends Trait {
|
|||||||
currentLoc = npc.getStoredLocation();
|
currentLoc = npc.getStoredLocation();
|
||||||
lastEntityHeight = getEntityHeight();
|
lastEntityHeight = getEntityHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nameNPC != null && nameNPC.isSpawned()) {
|
if (nameNPC != null && nameNPC.isSpawned()) {
|
||||||
if (update) {
|
if (update) {
|
||||||
nameNPC.teleport(currentLoc.clone().add(0, getEntityHeight(), 0), TeleportCause.PLUGIN);
|
nameNPC.teleport(currentLoc.clone().add(0, getEntityHeight(), 0), TeleportCause.PLUGIN);
|
||||||
}
|
}
|
||||||
nameNPC.setName(npc.getFullName());
|
nameNPC.setName(npc.getFullName());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < lineHolograms.size(); i++) {
|
for (int i = 0; i < lineHolograms.size(); i++) {
|
||||||
NPC hologramNPC = lineHolograms.get(i);
|
NPC hologramNPC = lineHolograms.get(i);
|
||||||
if (!hologramNPC.isSpawned())
|
if (!hologramNPC.isSpawned())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (update) {
|
if (update) {
|
||||||
hologramNPC.teleport(currentLoc.clone().add(0, getEntityHeight() + getHeight(i), 0),
|
hologramNPC.teleport(currentLoc.clone().add(0, getEntityHeight() + getHeight(i), 0),
|
||||||
TeleportCause.PLUGIN);
|
TeleportCause.PLUGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i >= lines.size()) {
|
if (i >= lines.size()) {
|
||||||
Messaging.severe("More hologram NPCs than lines for ID", npc.getId(), "lines", lines);
|
Messaging.severe("More hologram NPCs than lines for ID", npc.getId(), "lines", lines);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
String text = lines.get(i);
|
String text = lines.get(i);
|
||||||
if (ITEM_MATCHER.matcher(text).matches()) {
|
if (ITEM_MATCHER.matcher(text).matches()) {
|
||||||
text = null;
|
text = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text != null && !ChatColor.stripColor(Colorizer.parseColors(text)).isEmpty()) {
|
if (text != null && !ChatColor.stripColor(Colorizer.parseColors(text)).isEmpty()) {
|
||||||
hologramNPC.setName(Placeholders.replace(text, null, npc));
|
hologramNPC.setName(Placeholders.replace(text, null, npc));
|
||||||
hologramNPC.data().set(NPC.Metadata.NAMEPLATE_VISIBLE, true);
|
hologramNPC.data().set(NPC.Metadata.NAMEPLATE_VISIBLE, true);
|
||||||
@ -280,6 +289,7 @@ public class HologramTrait extends Trait {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onDespawn();
|
onDespawn();
|
||||||
onSpawn();
|
onSpawn();
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,14 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.boss.BarColor;
|
import org.bukkit.boss.BarColor;
|
||||||
import org.bukkit.boss.BarFlag;
|
import org.bukkit.boss.BarFlag;
|
||||||
import org.bukkit.boss.BarStyle;
|
import org.bukkit.boss.BarStyle;
|
||||||
import org.bukkit.boss.BossBar;
|
import org.bukkit.boss.BossBar;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
@ -18,6 +20,7 @@ import net.citizensnpcs.Settings.Setting;
|
|||||||
import net.citizensnpcs.api.persistence.Persist;
|
import net.citizensnpcs.api.persistence.Persist;
|
||||||
import net.citizensnpcs.api.trait.Trait;
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
import net.citizensnpcs.api.trait.TraitName;
|
import net.citizensnpcs.api.trait.TraitName;
|
||||||
|
import net.citizensnpcs.api.util.Placeholders;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
|
|
||||||
@TraitName("bossbar")
|
@TraitName("bossbar")
|
||||||
@ -31,6 +34,8 @@ public class BossBarTrait extends Trait {
|
|||||||
private BarStyle style = BarStyle.SOLID;
|
private BarStyle style = BarStyle.SOLID;
|
||||||
@Persist("title")
|
@Persist("title")
|
||||||
private String title = "";
|
private String title = "";
|
||||||
|
@Persist("track")
|
||||||
|
private String track;
|
||||||
@Persist("visible")
|
@Persist("visible")
|
||||||
private boolean visible = true;
|
private boolean visible = true;
|
||||||
|
|
||||||
@ -64,6 +69,10 @@ public class BossBarTrait extends Trait {
|
|||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTrackingVariable() {
|
||||||
|
return track;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isBoss(Entity entity) {
|
private boolean isBoss(Entity entity) {
|
||||||
boolean isBoss = entity.getType() == EntityType.ENDER_DRAGON || entity.getType() == EntityType.WITHER
|
boolean isBoss = entity.getType() == EntityType.ENDER_DRAGON || entity.getType() == EntityType.WITHER
|
||||||
|| entity.getType() == EntityType.GUARDIAN;
|
|| entity.getType() == EntityType.GUARDIAN;
|
||||||
@ -94,6 +103,29 @@ public class BossBarTrait extends Trait {
|
|||||||
if (bar == null) {
|
if (bar == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (track != null && !track.isEmpty() && npc.getEntity() instanceof LivingEntity) {
|
||||||
|
LivingEntity entity = (LivingEntity) npc.getEntity();
|
||||||
|
if (track.equalsIgnoreCase("health")) {
|
||||||
|
double maxHealth = entity.getMaxHealth();
|
||||||
|
if (SUPPORT_ATTRIBUTES) {
|
||||||
|
try {
|
||||||
|
maxHealth = entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
|
||||||
|
} catch (Throwable t) {
|
||||||
|
SUPPORT_ATTRIBUTES = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bar.setProgress(entity.getHealth() / maxHealth);
|
||||||
|
} else {
|
||||||
|
String replaced = Placeholders.replace(track,
|
||||||
|
npc.getEntity() instanceof Player ? (Player) npc.getEntity() : null);
|
||||||
|
if (!track.equals(replaced)) {
|
||||||
|
try {
|
||||||
|
bar.setProgress(Double.parseDouble(replaced));
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
bar.setStyle(style);
|
bar.setStyle(style);
|
||||||
bar.setVisible(visible);
|
bar.setVisible(visible);
|
||||||
if (color != null) {
|
if (color != null) {
|
||||||
@ -139,7 +171,13 @@ public class BossBarTrait extends Trait {
|
|||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTrackVariable(String variable) {
|
||||||
|
this.track = variable;
|
||||||
|
}
|
||||||
|
|
||||||
public void setVisible(boolean visible) {
|
public void setVisible(boolean visible) {
|
||||||
this.visible = visible;
|
this.visible = visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean SUPPORT_ATTRIBUTES = true;
|
||||||
}
|
}
|
||||||
|
@ -410,7 +410,10 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updatePackets(boolean navigating) {
|
private void updatePackets(boolean navigating) {
|
||||||
updateCounter++;
|
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
|
||||||
|
Setting.PACKET_UPDATE_DELAY.asInt()))
|
||||||
|
return;
|
||||||
|
updateCounter = 0;
|
||||||
boolean itemChanged = false;
|
boolean itemChanged = false;
|
||||||
for (EnumItemSlot slot : EnumItemSlot.values()) {
|
for (EnumItemSlot slot : EnumItemSlot.values()) {
|
||||||
ItemStack equipment = getEquipment(slot);
|
ItemStack equipment = getEquipment(slot);
|
||||||
@ -421,10 +424,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
}
|
}
|
||||||
equipmentCache.put(slot, equipment);
|
equipmentCache.put(slot, equipment);
|
||||||
}
|
}
|
||||||
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
|
if (!itemChanged)
|
||||||
Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
|
|
||||||
return;
|
return;
|
||||||
updateCounter = 0;
|
|
||||||
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
||||||
Packet<?>[] packets = new Packet[EnumItemSlot.values().length];
|
Packet<?>[] packets = new Packet[EnumItemSlot.values().length];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -30,7 +30,7 @@ import net.citizensnpcs.util.Util;
|
|||||||
public class Commands {
|
public class Commands {
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags]",
|
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags] --track [health | placeholder]",
|
||||||
desc = "Edit bossbar properties",
|
desc = "Edit bossbar properties",
|
||||||
modifiers = { "bossbar" },
|
modifiers = { "bossbar" },
|
||||||
min = 1,
|
min = 1,
|
||||||
@ -50,6 +50,9 @@ public class Commands {
|
|||||||
trait.setColor(color);
|
trait.setColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (args.hasValueFlag("track")) {
|
||||||
|
trait.setTrackVariable(args.getFlag("track"));
|
||||||
|
}
|
||||||
if (args.hasValueFlag("title")) {
|
if (args.hasValueFlag("title")) {
|
||||||
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
||||||
}
|
}
|
||||||
|
@ -416,7 +416,10 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updatePackets(boolean navigating) {
|
private void updatePackets(boolean navigating) {
|
||||||
updateCounter++;
|
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
|
||||||
|
Setting.PACKET_UPDATE_DELAY.asInt()))
|
||||||
|
return;
|
||||||
|
updateCounter = 0;
|
||||||
boolean itemChanged = false;
|
boolean itemChanged = false;
|
||||||
for (EnumItemSlot slot : EnumItemSlot.values()) {
|
for (EnumItemSlot slot : EnumItemSlot.values()) {
|
||||||
ItemStack equipment = getEquipment(slot);
|
ItemStack equipment = getEquipment(slot);
|
||||||
@ -427,11 +430,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
}
|
}
|
||||||
equipmentCache.put(slot, equipment);
|
equipmentCache.put(slot, equipment);
|
||||||
}
|
}
|
||||||
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
|
if (!itemChanged)
|
||||||
Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
updateCounter = 0;
|
|
||||||
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
||||||
Packet<?>[] packets = new Packet[EnumItemSlot.values().length];
|
Packet<?>[] packets = new Packet[EnumItemSlot.values().length];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -33,7 +33,7 @@ import net.citizensnpcs.util.Util;
|
|||||||
public class Commands {
|
public class Commands {
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags]",
|
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags] --track [health | placeholder]",
|
||||||
desc = "Edit bossbar properties",
|
desc = "Edit bossbar properties",
|
||||||
modifiers = { "bossbar" },
|
modifiers = { "bossbar" },
|
||||||
min = 1,
|
min = 1,
|
||||||
@ -53,6 +53,9 @@ public class Commands {
|
|||||||
trait.setColor(color);
|
trait.setColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (args.hasValueFlag("track")) {
|
||||||
|
trait.setTrackVariable(args.getFlag("track"));
|
||||||
|
}
|
||||||
if (args.hasValueFlag("title")) {
|
if (args.hasValueFlag("title")) {
|
||||||
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
||||||
}
|
}
|
||||||
|
@ -442,7 +442,10 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updatePackets(boolean navigating) {
|
private void updatePackets(boolean navigating) {
|
||||||
updateCounter++;
|
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
|
||||||
|
Setting.PACKET_UPDATE_DELAY.asInt()))
|
||||||
|
return;
|
||||||
|
updateCounter = 0;
|
||||||
boolean itemChanged = false;
|
boolean itemChanged = false;
|
||||||
for (EnumItemSlot slot : EnumItemSlot.values()) {
|
for (EnumItemSlot slot : EnumItemSlot.values()) {
|
||||||
ItemStack equipment = getEquipment(slot);
|
ItemStack equipment = getEquipment(slot);
|
||||||
@ -453,11 +456,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
}
|
}
|
||||||
equipmentCache.put(slot, equipment);
|
equipmentCache.put(slot, equipment);
|
||||||
}
|
}
|
||||||
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
|
if (!itemChanged)
|
||||||
Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
updateCounter = 0;
|
|
||||||
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
||||||
Packet<?>[] packets = new Packet[EnumItemSlot.values().length];
|
Packet<?>[] packets = new Packet[EnumItemSlot.values().length];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -35,7 +35,7 @@ import net.citizensnpcs.util.Util;
|
|||||||
public class Commands {
|
public class Commands {
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags]",
|
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags] --track [health | placeholder]",
|
||||||
desc = "Edit bossbar properties",
|
desc = "Edit bossbar properties",
|
||||||
modifiers = { "bossbar" },
|
modifiers = { "bossbar" },
|
||||||
min = 1,
|
min = 1,
|
||||||
@ -55,6 +55,9 @@ public class Commands {
|
|||||||
trait.setColor(color);
|
trait.setColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (args.hasValueFlag("track")) {
|
||||||
|
trait.setTrackVariable(args.getFlag("track"));
|
||||||
|
}
|
||||||
if (args.hasValueFlag("title")) {
|
if (args.hasValueFlag("title")) {
|
||||||
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
||||||
}
|
}
|
||||||
|
@ -434,7 +434,10 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updatePackets(boolean navigating) {
|
private void updatePackets(boolean navigating) {
|
||||||
updateCounter++;
|
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
|
||||||
|
Setting.PACKET_UPDATE_DELAY.asInt()))
|
||||||
|
return;
|
||||||
|
updateCounter = 0;
|
||||||
boolean itemChanged = false;
|
boolean itemChanged = false;
|
||||||
for (EnumItemSlot slot : EnumItemSlot.values()) {
|
for (EnumItemSlot slot : EnumItemSlot.values()) {
|
||||||
ItemStack equipment = getEquipment(slot);
|
ItemStack equipment = getEquipment(slot);
|
||||||
@ -445,11 +448,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
}
|
}
|
||||||
equipmentCache.put(slot, equipment);
|
equipmentCache.put(slot, equipment);
|
||||||
}
|
}
|
||||||
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
|
if (!itemChanged)
|
||||||
Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
updateCounter = 0;
|
|
||||||
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
||||||
Packet<?>[] packets = new Packet[EnumItemSlot.values().length];
|
Packet<?>[] packets = new Packet[EnumItemSlot.values().length];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -39,7 +39,7 @@ import net.citizensnpcs.util.Util;
|
|||||||
public class Commands {
|
public class Commands {
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags]",
|
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags] --track [health | placeholder]",
|
||||||
desc = "Edit bossbar properties",
|
desc = "Edit bossbar properties",
|
||||||
modifiers = { "bossbar" },
|
modifiers = { "bossbar" },
|
||||||
min = 1,
|
min = 1,
|
||||||
@ -59,6 +59,9 @@ public class Commands {
|
|||||||
trait.setColor(color);
|
trait.setColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (args.hasValueFlag("track")) {
|
||||||
|
trait.setTrackVariable(args.getFlag("track"));
|
||||||
|
}
|
||||||
if (args.hasValueFlag("title")) {
|
if (args.hasValueFlag("title")) {
|
||||||
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
||||||
}
|
}
|
||||||
|
@ -438,7 +438,10 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updatePackets(boolean navigating) {
|
private void updatePackets(boolean navigating) {
|
||||||
updateCounter++;
|
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
|
||||||
|
Setting.PACKET_UPDATE_DELAY.asInt()))
|
||||||
|
return;
|
||||||
|
updateCounter = 0;
|
||||||
boolean itemChanged = false;
|
boolean itemChanged = false;
|
||||||
for (EnumItemSlot slot : EnumItemSlot.values()) {
|
for (EnumItemSlot slot : EnumItemSlot.values()) {
|
||||||
ItemStack equipment = getEquipment(slot);
|
ItemStack equipment = getEquipment(slot);
|
||||||
@ -449,11 +452,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
}
|
}
|
||||||
equipmentCache.put(slot, equipment);
|
equipmentCache.put(slot, equipment);
|
||||||
}
|
}
|
||||||
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
|
if (!itemChanged)
|
||||||
Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
updateCounter = 0;
|
|
||||||
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
||||||
Packet<?>[] packets = new Packet[EnumItemSlot.values().length];
|
Packet<?>[] packets = new Packet[EnumItemSlot.values().length];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -52,7 +52,7 @@ import net.citizensnpcs.util.Util;
|
|||||||
public class Commands {
|
public class Commands {
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags]",
|
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags] --track [health | placeholder]",
|
||||||
desc = "Edit bossbar properties",
|
desc = "Edit bossbar properties",
|
||||||
modifiers = { "bossbar" },
|
modifiers = { "bossbar" },
|
||||||
min = 1,
|
min = 1,
|
||||||
@ -72,6 +72,9 @@ public class Commands {
|
|||||||
trait.setColor(color);
|
trait.setColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (args.hasValueFlag("track")) {
|
||||||
|
trait.setTrackVariable(args.getFlag("track"));
|
||||||
|
}
|
||||||
if (args.hasValueFlag("title")) {
|
if (args.hasValueFlag("title")) {
|
||||||
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
||||||
}
|
}
|
||||||
|
@ -449,7 +449,10 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updatePackets(boolean navigating) {
|
private void updatePackets(boolean navigating) {
|
||||||
updateCounter++;
|
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
|
||||||
|
Setting.PACKET_UPDATE_DELAY.asInt()))
|
||||||
|
return;
|
||||||
|
updateCounter = 0;
|
||||||
boolean itemChanged = false;
|
boolean itemChanged = false;
|
||||||
for (EnumItemSlot slot : EnumItemSlot.values()) {
|
for (EnumItemSlot slot : EnumItemSlot.values()) {
|
||||||
ItemStack equipment = getEquipment(slot);
|
ItemStack equipment = getEquipment(slot);
|
||||||
@ -460,10 +463,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
}
|
}
|
||||||
equipmentCache.put(slot, equipment);
|
equipmentCache.put(slot, equipment);
|
||||||
}
|
}
|
||||||
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
|
if (!itemChanged)
|
||||||
Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
|
|
||||||
return;
|
return;
|
||||||
updateCounter = 0;
|
|
||||||
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
||||||
Packet<?>[] packets = new Packet[EnumItemSlot.values().length];
|
Packet<?>[] packets = new Packet[EnumItemSlot.values().length];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -91,7 +91,7 @@ public class Commands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags]",
|
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags] --track [health | placeholder]",
|
||||||
desc = "Edit bossbar properties",
|
desc = "Edit bossbar properties",
|
||||||
modifiers = { "bossbar" },
|
modifiers = { "bossbar" },
|
||||||
min = 1,
|
min = 1,
|
||||||
@ -111,6 +111,9 @@ public class Commands {
|
|||||||
trait.setColor(color);
|
trait.setColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (args.hasValueFlag("track")) {
|
||||||
|
trait.setTrackVariable(args.getFlag("track"));
|
||||||
|
}
|
||||||
if (args.hasValueFlag("title")) {
|
if (args.hasValueFlag("title")) {
|
||||||
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
||||||
}
|
}
|
||||||
|
@ -479,7 +479,10 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updatePackets(boolean navigating) {
|
private void updatePackets(boolean navigating) {
|
||||||
updateCounter++;
|
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
|
||||||
|
Setting.PACKET_UPDATE_DELAY.asInt()))
|
||||||
|
return;
|
||||||
|
updateCounter = 0;
|
||||||
boolean itemChanged = false;
|
boolean itemChanged = false;
|
||||||
for (EnumItemSlot slot : EnumItemSlot.values()) {
|
for (EnumItemSlot slot : EnumItemSlot.values()) {
|
||||||
ItemStack equipment = getEquipment(slot);
|
ItemStack equipment = getEquipment(slot);
|
||||||
@ -490,11 +493,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
}
|
}
|
||||||
equipmentCache.put(slot, equipment);
|
equipmentCache.put(slot, equipment);
|
||||||
}
|
}
|
||||||
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
|
if (!itemChanged)
|
||||||
Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
updateCounter = 0;
|
|
||||||
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
||||||
Packet<?>[] packets = new Packet[1];
|
Packet<?>[] packets = new Packet[1];
|
||||||
List<Pair<EnumItemSlot, ItemStack>> vals = Lists.newArrayList();
|
List<Pair<EnumItemSlot, ItemStack>> vals = Lists.newArrayList();
|
||||||
|
@ -91,7 +91,7 @@ public class Commands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags]",
|
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags] --track [health | placeholder]",
|
||||||
desc = "Edit bossbar properties",
|
desc = "Edit bossbar properties",
|
||||||
modifiers = { "bossbar" },
|
modifiers = { "bossbar" },
|
||||||
min = 1,
|
min = 1,
|
||||||
@ -111,6 +111,9 @@ public class Commands {
|
|||||||
trait.setColor(color);
|
trait.setColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (args.hasValueFlag("track")) {
|
||||||
|
trait.setTrackVariable(args.getFlag("track"));
|
||||||
|
}
|
||||||
if (args.hasValueFlag("title")) {
|
if (args.hasValueFlag("title")) {
|
||||||
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
||||||
}
|
}
|
||||||
|
@ -489,7 +489,10 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updatePackets(boolean navigating) {
|
private void updatePackets(boolean navigating) {
|
||||||
updateCounter++;
|
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
|
||||||
|
Setting.PACKET_UPDATE_DELAY.asInt()))
|
||||||
|
return;
|
||||||
|
updateCounter = 0;
|
||||||
boolean itemChanged = false;
|
boolean itemChanged = false;
|
||||||
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||||
ItemStack equipment = getItemBySlot(slot);
|
ItemStack equipment = getItemBySlot(slot);
|
||||||
@ -500,11 +503,9 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
|||||||
}
|
}
|
||||||
equipmentCache.put(slot, equipment);
|
equipmentCache.put(slot, equipment);
|
||||||
}
|
}
|
||||||
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
|
if (!itemChanged)
|
||||||
Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
updateCounter = 0;
|
|
||||||
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
||||||
List<Pair<EquipmentSlot, ItemStack>> vals = Lists.newArrayList();
|
List<Pair<EquipmentSlot, ItemStack>> vals = Lists.newArrayList();
|
||||||
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||||
|
@ -127,7 +127,7 @@ public class Commands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags]",
|
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags] --track [health | placeholder]",
|
||||||
desc = "Edit bossbar properties",
|
desc = "Edit bossbar properties",
|
||||||
modifiers = { "bossbar" },
|
modifiers = { "bossbar" },
|
||||||
min = 1,
|
min = 1,
|
||||||
@ -147,6 +147,9 @@ public class Commands {
|
|||||||
trait.setColor(color);
|
trait.setColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (args.hasValueFlag("track")) {
|
||||||
|
trait.setTrackVariable(args.getFlag("track"));
|
||||||
|
}
|
||||||
if (args.hasValueFlag("title")) {
|
if (args.hasValueFlag("title")) {
|
||||||
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
||||||
}
|
}
|
||||||
|
@ -488,22 +488,23 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updatePackets(boolean navigating) {
|
private void updatePackets(boolean navigating) {
|
||||||
updateCounter++;
|
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
|
||||||
|
Setting.PACKET_UPDATE_DELAY.asInt()))
|
||||||
|
return;
|
||||||
|
updateCounter = 0;
|
||||||
boolean itemChanged = false;
|
boolean itemChanged = false;
|
||||||
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||||
ItemStack equipment = getItemBySlot(slot);
|
ItemStack equipment = getItemBySlot(slot);
|
||||||
ItemStack cache = equipmentCache.get(slot);
|
ItemStack cache = equipmentCache.get(slot);
|
||||||
if (!(cache == null && equipment == null)
|
if (!(cache == null && equipment == null)
|
||||||
&& (cache == null ^ equipment == null || !ItemStack.isSame(cache, equipment))) {
|
&& (cache == null ^ equipment == null || !ItemStack.isSame(cache, equipment))) {
|
||||||
|
System.out.println("item changed " + cache + " " + equipment);
|
||||||
itemChanged = true;
|
itemChanged = true;
|
||||||
}
|
}
|
||||||
equipmentCache.put(slot, equipment);
|
equipmentCache.put(slot, equipment);
|
||||||
}
|
}
|
||||||
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
|
if (!itemChanged)
|
||||||
Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
updateCounter = 0;
|
|
||||||
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
||||||
List<Pair<EquipmentSlot, ItemStack>> vals = Lists.newArrayList();
|
List<Pair<EquipmentSlot, ItemStack>> vals = Lists.newArrayList();
|
||||||
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||||
|
@ -127,7 +127,7 @@ public class Commands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags]",
|
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags] --track [health | placeholder]",
|
||||||
desc = "Edit bossbar properties",
|
desc = "Edit bossbar properties",
|
||||||
modifiers = { "bossbar" },
|
modifiers = { "bossbar" },
|
||||||
min = 1,
|
min = 1,
|
||||||
@ -147,6 +147,9 @@ public class Commands {
|
|||||||
trait.setColor(color);
|
trait.setColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (args.hasValueFlag("track")) {
|
||||||
|
trait.setTrackVariable(args.getFlag("track"));
|
||||||
|
}
|
||||||
if (args.hasValueFlag("title")) {
|
if (args.hasValueFlag("title")) {
|
||||||
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
|
||||||
}
|
}
|
||||||
|
@ -399,7 +399,10 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updatePackets(boolean navigating) {
|
private void updatePackets(boolean navigating) {
|
||||||
updateCounter++;
|
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
|
||||||
|
Setting.PACKET_UPDATE_DELAY.asInt()))
|
||||||
|
return;
|
||||||
|
updateCounter = 0;
|
||||||
boolean itemChanged = false;
|
boolean itemChanged = false;
|
||||||
for (int slot = 0; slot < this.inventory.armor.length; slot++) {
|
for (int slot = 0; slot < this.inventory.armor.length; slot++) {
|
||||||
ItemStack equipment = getEquipment(slot);
|
ItemStack equipment = getEquipment(slot);
|
||||||
@ -410,10 +413,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
}
|
}
|
||||||
equipmentCache.put(slot, equipment);
|
equipmentCache.put(slot, equipment);
|
||||||
}
|
}
|
||||||
if (updateCounter++ <= npc.data().<Integer> get(NPC.Metadata.PACKET_UPDATE_DELAY,
|
if (!itemChanged)
|
||||||
Setting.PACKET_UPDATE_DELAY.asInt()) && !itemChanged)
|
|
||||||
return;
|
return;
|
||||||
updateCounter = 0;
|
|
||||||
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
||||||
Packet<?>[] packets = new Packet[this.inventory.armor.length];
|
Packet<?>[] packets = new Packet[this.inventory.armor.length];
|
||||||
for (int i = 0; i < this.inventory.armor.length; i++) {
|
for (int i = 0; i < this.inventory.armor.length; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user