Improve /npc text editor, implement speech bubbles, allow armor stands to pathfind using the A* finder, allow /npc bossbar to work on all entities

This commit is contained in:
fullwall 2021-07-19 23:02:41 +08:00
parent 55cf0c4ccd
commit d4c557d5b2
21 changed files with 279 additions and 65 deletions

View File

@ -61,6 +61,7 @@ public class Settings {
ALWAYS_USE_NAME_HOLOGRAM("npc.always-use-name-holograms", false),
ASTAR_ITERATIONS_PER_TICK("npc.pathfinding.new-finder.iterations-per-tick", 5000),
AUTH_SERVER_URL("general.authlib.profile-url", "https://sessionserver.mojang.com/session/minecraft/profile/"),
BOSSBAR_RANGE("npc.default.bossbar-view-range", 64),
CHAT_BYSTANDERS_HEAR_TARGETED_CHAT("npc.chat.options.bystanders-hear-targeted-chat", false),
CHAT_FORMAT("npc.chat.format.no-targets", "[<npc>]: <text>"),
CHAT_FORMAT_TO_BYSTANDERS("npc.chat.format.with-target-to-bystanders", "[<npc>] -> [<target>]: <text>"),
@ -85,7 +86,7 @@ public class Settings {
DEFAULT_NPC_LIMIT("npc.limits.default-limit", 10),
DEFAULT_PATH_DISTANCE_MARGIN("npc.pathfinding.default-path-distance-margin", 1),
DEFAULT_PATHFINDER_UPDATE_PATH_RATE("npc.pathfinding.update-path-rate", 20),
DEFAULT_PATHFINDING_RANGE("npc.default.pathfinding.range", 25F),
DEFAULT_PATHFINDING_RANGE("npc.default.pathfinding.range", 75F),
DEFAULT_RANDOM_LOOK_CLOSE("npc.default.look-close.random-look-enabled", false),
DEFAULT_RANDOM_LOOK_DELAY("npc.default.look-close.random-look-delay", 60),
DEFAULT_RANDOM_TALKER("npc.default.random-talker", false),
@ -103,6 +104,7 @@ public class Settings {
value = list;
}
},
DEFAULT_TEXT_SPEECH_BUBBLE_TICKS("npc.text.speech-bubble-ticks", 50),
DISABLE_LOOKCLOSE_WHILE_NAVIGATING("npc.default.look-close.disable-while-navigating", true),
DISABLE_MC_NAVIGATION_FALLBACK("npc.pathfinding.disable-mc-fallback-navigation", true),
DISABLE_TABLIST("npc.tablist.disable", true),

View File

@ -137,7 +137,7 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
Location currLoc = npc.getEntity().getLocation(NPC_LOCATION);
Vector destVector = new Vector(vector.getX() + 0.5, vector.getY(), vector.getZ() + 0.5);
/* Proper door movement - gets stuck on corners at times
Block block = currLoc.getWorld().getBlockAt(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
if (MinecraftBlockExaminer.isDoor(block.getType())) {
Door door = (Door) block.getState().getData();
@ -165,7 +165,7 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
}
double distance = xzDistance + dY * dY;
if (npc.getEntity() instanceof LivingEntity) {
if (npc.getEntity() instanceof LivingEntity && !npc.getEntity().getType().name().contains("ARMOR_STAND")) {
NMS.setDestination(npc.getEntity(), destVector.getX(), destVector.getY(), destVector.getZ(),
params.speed());
} else {

View File

@ -115,7 +115,7 @@ public class HologramTrait extends Trait {
* @return the hologram lines, in bottom-up order
*/
public List<String> getLines() {
return Lists.newArrayList(lines);
return lines;
}
private double getMaxHeight() {

View File

@ -21,7 +21,7 @@ public class PageChangePrompt extends NumericPrompt {
Player player = (Player) context.getForWhom();
if (!text.sendPage(player, input.intValue())) {
Messaging.sendErrorTr(player, Messages.TEXT_EDITOR_INVALID_PAGE);
return new TextStartPrompt(text);
return new TextBasePrompt(text);
}
return (Prompt) context.getSessionData("previous");
}

View File

@ -31,6 +31,7 @@ import net.citizensnpcs.api.util.DataKey;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.api.util.Paginator;
import net.citizensnpcs.editor.Editor;
import net.citizensnpcs.trait.HologramTrait;
import net.citizensnpcs.trait.Toggleable;
import net.citizensnpcs.util.Messages;
import net.citizensnpcs.util.Util;
@ -40,6 +41,7 @@ import net.citizensnpcs.util.Util;
*/
@TraitName("text")
public class Text extends Trait implements Runnable, Toggleable, Listener, ConversationAbandonedListener {
private int bubbleTicks;
private final Map<UUID, Long> cooldowns = Maps.newHashMap();
private int currentIndex;
private int delay = -1;
@ -48,6 +50,8 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve
private boolean randomTalker = Setting.DEFAULT_RANDOM_TALKER.asBoolean();
private double range = Setting.DEFAULT_TALK_CLOSE_RANGE.asDouble();
private boolean realisticLooker = Setting.DEFAULT_REALISTIC_LOOKING.asBoolean();
private boolean speechBubbles;
private int speechIndex = -1;
private boolean talkClose = Setting.DEFAULT_TALK_CLOSE.asBoolean();
private final List<String> text = new ArrayList<String>();
@ -66,6 +70,14 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve
text.add(string);
}
private void clearBubble() {
if (speechIndex < npc.getOrAddTrait(HologramTrait.class).getLines().size()) {
npc.getOrAddTrait(HologramTrait.class).removeLine(speechIndex);
speechIndex = -1;
}
bubbleTicks = 0;
}
@Override
public void conversationAbandoned(ConversationAbandonedEvent event) {
}
@ -88,7 +100,7 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve
public Editor getEditor(final Player player) {
final Conversation conversation = new ConversationFactory(plugin).addConversationAbandonedListener(this)
.withLocalEcho(false).withEscapeSequence("/npc text").withEscapeSequence("exit").withModality(false)
.withFirstPrompt(new TextStartPrompt(this)).buildConversation(player);
.withFirstPrompt(new TextBasePrompt(this)).buildConversation(player);
return new Editor() {
@Override
public void begin() {
@ -104,6 +116,21 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve
};
}
String getPageText(int page) {
Paginator paginator = new Paginator().header("Current Texts");
for (int i = 0; i < text.size(); i++)
paginator.addLine("<a>" + i + " <7>- <e>" + text.get(i));
return paginator.getPageText(page);
}
/**
* @return The list of all texts
*/
public List<String> getTexts() {
return text;
}
/**
* @return whether there is text at a certain index
*/
@ -114,10 +141,6 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve
@Override
public void load(DataKey key) throws NPCLoadException {
text.clear();
// TODO: legacy, remove later
for (DataKey sub : key.getIntegerSubKeys()) {
text.add(sub.getString(""));
}
for (DataKey sub : key.getRelative("text").getIntegerSubKeys()) {
text.add(sub.getString(""));
}
@ -157,14 +180,21 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve
@Override
public void run() {
if (!talkClose || !npc.isSpawned())
if (!npc.isSpawned())
return;
if (bubbleTicks > 0 && --bubbleTicks == 0) {
clearBubble();
}
if (!talkClose)
return;
List<Entity> nearby = npc.getEntity().getNearbyEntities(range, range, range);
for (Entity search : nearby) {
if (!(search instanceof Player) || ((Player) search).getGameMode() == GameMode.SPECTATOR)
continue;
Player player = (Player) search;
// If the cooldown is not expired, do not send text
Long cooldown = cooldowns.get(player.getUniqueId());
if (cooldown != null) {
if (System.currentTimeMillis() < cooldown) {
@ -173,7 +203,7 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve
cooldowns.remove(player.getUniqueId());
}
sendText(player);
// Add a cooldown if the text was successfully sent
int secondsDelta = delay != -1 ? delay
: RANDOM.nextInt(Setting.TALK_CLOSE_MAXIMUM_COOLDOWN.asInt())
+ Setting.TALK_CLOSE_MINIMUM_COOLDOWN.asInt();
@ -192,16 +222,14 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve
key.setBoolean("realistic-looking", realisticLooker);
key.setDouble("range", range);
key.setString("talkitem", itemInHandPattern);
// TODO: legacy, remove later
for (int i = 0; i < 100; i++)
key.removeKey(String.valueOf(i));
key.removeKey("text");
for (int i = 0; i < text.size(); i++)
for (int i = 0; i < text.size(); i++) {
key.setString("text." + String.valueOf(i), text.get(i));
}
}
boolean sendPage(Player player, int page) {
Paginator paginator = new Paginator().header(npc.getName() + "'s Text Entries");
Paginator paginator = new Paginator().header("Current Texts");
for (int i = 0; i < text.size(); i++)
paginator.addLine("<a>" + i + " <7>- <e>" + text.get(i));
@ -213,15 +241,27 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve
return false;
int index = 0;
if (randomTalker)
if (randomTalker) {
index = RANDOM.nextInt(text.size());
else {
if (currentIndex > text.size() - 1)
} else {
if (currentIndex > text.size() - 1) {
currentIndex = 0;
}
index = currentIndex++;
}
npc.getDefaultSpeechController().speak(new SpeechContext(text.get(index), player));
if (speechBubbles) {
HologramTrait trait = npc.getOrAddTrait(HologramTrait.class);
if (speechIndex == -1) {
speechIndex = trait.getLines().size();
trait.addLine(text.get(index));
bubbleTicks = Setting.DEFAULT_TEXT_SPEECH_BUBBLE_TICKS.asInt();
} else if (speechIndex < trait.getLines().size()) {
trait.setLine(speechIndex, text.get(index));
}
} else {
npc.getDefaultSpeechController().speak(new SpeechContext(text.get(index), player));
}
return true;
}
@ -235,7 +275,13 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve
this.delay = delay;
}
void setItemInHandPattern(String pattern) {
/**
* Sets the item in hand pattern required to talk to NPCs, if enabled.
*
* @param pattern
* The new pattern
*/
public void setItemInHandPattern(String pattern) {
itemInHandPattern = pattern;
}
@ -248,7 +294,10 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve
this.range = range;
}
boolean shouldTalkClose() {
/**
* @return Whether talking close is enabled.
*/
public boolean shouldTalkClose() {
return talkClose;
}
@ -274,14 +323,14 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve
return (realisticLooker = !realisticLooker);
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Text{talk-close=" + talkClose + ",text=");
for (String line : text)
builder.append(line + ",");
builder.append("}");
return builder.toString();
/**
* Toggles using speech bubbles instead of messages.
*/
public boolean toggleSpeechBubbles() {
if (speechBubbles) {
clearBubble();
}
return (speechBubbles = !speechBubbles);
}
private static Random RANDOM = Util.getFastRandom();

View File

@ -0,0 +1,93 @@
package net.citizensnpcs.trait.text;
import java.util.Arrays;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt;
import org.bukkit.conversations.StringPrompt;
import org.bukkit.entity.Player;
import com.google.common.base.Joiner;
import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.util.Messages;
public class TextBasePrompt extends StringPrompt {
private final Text text;
public TextBasePrompt(Text text) {
this.text = text;
}
@Override
public Prompt acceptInput(ConversationContext context, String original) {
String[] parts = ChatColor.stripColor(original.trim()).split(" ");
String input = parts[0];
CommandSender sender = (CommandSender) context.getForWhom();
if (input.equalsIgnoreCase("add")) {
text.add(Joiner.on(' ').join(Arrays.copyOfRange(parts, 1, parts.length)));
return this;
} else if (input.equalsIgnoreCase("edit")) {
return new TextEditStartPrompt(text);
} else if (input.equalsIgnoreCase("remove")) {
return new TextRemovePrompt(text);
} else if (input.equalsIgnoreCase("delay")) {
try {
int delay = Integer.parseInt(parts[1]);
text.setDelay(delay);
Messaging.sendTr(sender, Messages.TEXT_EDITOR_DELAY_SET, delay);
} catch (NumberFormatException e) {
Messaging.sendErrorTr(sender, Messages.TEXT_EDITOR_INVALID_DELAY);
} catch (ArrayIndexOutOfBoundsException e) {
Messaging.sendErrorTr(sender, Messages.TEXT_EDITOR_INVALID_DELAY);
}
} else if (input.equalsIgnoreCase("random")) {
Messaging.sendTr(sender, Messages.TEXT_EDITOR_RANDOM_TALKER_SET, text.toggleRandomTalker());
} else if (original.trim().equalsIgnoreCase("realistic looking")) {
Messaging.sendTr(sender, Messages.TEXT_EDITOR_REALISTIC_LOOKING_SET, text.toggleRealisticLooking());
} else if (original.trim().equalsIgnoreCase("speech bubbles")) {
Messaging.sendTr(sender, Messages.TEXT_EDITOR_SPEECH_BUBBLES_SET, text.toggleSpeechBubbles());
} else if (input.equalsIgnoreCase("close") || original.trim().equalsIgnoreCase("talk close")) {
Messaging.sendTr(sender, Messages.TEXT_EDITOR_CLOSE_TALKER_SET, text.toggle());
} else if (input.equalsIgnoreCase("range")) {
try {
double range = Math.min(Math.max(0, Double.parseDouble(parts[1])), Setting.MAX_TEXT_RANGE.asDouble());
text.setRange(range);
Messaging.sendTr(sender, Messages.TEXT_EDITOR_RANGE_SET, range);
} catch (NumberFormatException e) {
Messaging.sendErrorTr(sender, Messages.TEXT_EDITOR_INVALID_RANGE);
} catch (ArrayIndexOutOfBoundsException e) {
Messaging.sendErrorTr(sender, Messages.TEXT_EDITOR_INVALID_RANGE);
}
} else if (input.equalsIgnoreCase("item")) {
if (parts.length > 1) {
text.setItemInHandPattern(parts[1]);
Messaging.sendTr(sender, Messages.TEXT_EDITOR_SET_ITEM, parts[1]);
} else {
Messaging.sendErrorTr(sender, Messages.TEXT_EDITOR_MISSING_ITEM_PATTERN);
}
} else if (input.equalsIgnoreCase("help")) {
context.setSessionData("said-text", false);
Messaging.send(sender, getPromptText(context));
} else {
Messaging.sendErrorTr(sender, Messages.TEXT_EDITOR_INVALID_EDIT_TYPE);
}
return this;
}
@Override
public String getPromptText(ConversationContext context) {
if (Boolean.TRUE == context.getSessionData("said-text")) {
text.sendPage(((Player) context.getForWhom()), 1);
} else {
Messaging.send((Player) context.getForWhom(), Messaging.tr(Messages.TEXT_EDITOR_START_PROMPT));
text.sendPage(((Player) context.getForWhom()), 1);
context.setSessionData("said-text", Boolean.TRUE);
}
return "";
}
}

View File

@ -21,7 +21,7 @@ public class TextEditPrompt extends StringPrompt {
int index = (Integer) context.getSessionData("index");
text.edit(index, input);
Messaging.sendTr((CommandSender) context.getForWhom(), Messages.TEXT_EDITOR_EDITED_TEXT, index, input);
return new TextStartPrompt(text);
return new TextBasePrompt(text);
}
@Override

View File

@ -22,7 +22,7 @@ public class TextEditStartPrompt extends StringPrompt {
int index = Integer.parseInt(input);
if (!text.hasIndex(index)) {
Messaging.sendErrorTr(player, Messages.TEXT_EDITOR_INVALID_INDEX, index);
return new TextStartPrompt(text);
return new TextBasePrompt(text);
}
context.setSessionData("index", index);
return new TextEditPrompt(text);
@ -33,7 +33,7 @@ public class TextEditStartPrompt extends StringPrompt {
}
}
Messaging.sendErrorTr(player, Messages.TEXT_EDITOR_INVALID_INPUT);
return new TextStartPrompt(text);
return new TextBasePrompt(text);
}
@Override

View File

@ -22,11 +22,11 @@ public class TextRemovePrompt extends StringPrompt {
int index = Integer.parseInt(input);
if (!text.hasIndex(index)) {
Messaging.sendErrorTr(player, Messages.TEXT_EDITOR_INVALID_INDEX, index);
return new TextStartPrompt(text);
return new TextBasePrompt(text);
}
text.remove(index);
Messaging.sendTr(player, Messages.TEXT_EDITOR_REMOVED_ENTRY, index);
return new TextStartPrompt(text);
return new TextBasePrompt(text);
} catch (NumberFormatException ex) {
if (input.equalsIgnoreCase("page")) {
context.setSessionData("previous", this);
@ -34,7 +34,7 @@ public class TextRemovePrompt extends StringPrompt {
}
}
Messaging.sendErrorTr(player, Messages.TEXT_EDITOR_INVALID_INPUT);
return new TextStartPrompt(text);
return new TextBasePrompt(text);
}
@Override

View File

@ -3,14 +3,18 @@ package net.citizensnpcs.trait.versioned;
import java.util.Collection;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import com.google.common.collect.Lists;
import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
@ -18,12 +22,15 @@ import net.citizensnpcs.util.NMS;
@TraitName("bossbar")
public class BossBarTrait extends Trait {
private BossBar barCache;
@Persist("color")
private BarColor color = null;
private BarColor color = BarColor.PURPLE;
@Persist("flags")
private List<BarFlag> flags = Lists.newArrayList();
@Persist("style")
private BarStyle style = BarStyle.SOLID;
@Persist("title")
private String title = null;
private String title = "";
@Persist("visible")
private boolean visible = true;
@ -39,13 +46,21 @@ public class BossBarTrait extends Trait {
return flags;
}
public BarStyle getStyle() {
return style;
}
public String getTitle() {
return title;
}
private boolean isBoss(Entity entity) {
return entity.getType() == EntityType.ENDER_DRAGON || entity.getType() == EntityType.WITHER
boolean isBoss = entity.getType() == EntityType.ENDER_DRAGON || entity.getType() == EntityType.WITHER
|| entity.getType() == EntityType.GUARDIAN;
if (isBoss) {
barCache = null;
}
return isBoss;
}
public boolean isVisible() {
@ -54,12 +69,15 @@ public class BossBarTrait extends Trait {
@Override
public void run() {
if (!npc.isSpawned() || !isBoss(npc.getEntity()))
if (!npc.isSpawned())
return;
BossBar bar = (BossBar) NMS.getBossBar(npc.getEntity());
BossBar bar = isBoss(npc.getEntity()) ? (BossBar) NMS.getBossBar(npc.getEntity())
: barCache == null ? barCache = Bukkit.getServer().createBossBar(npc.getFullName(), color, style,
flags.toArray(new BarFlag[flags.size()])) : barCache;
if (bar == null) {
return;
}
bar.setStyle(style);
bar.setVisible(visible);
if (color != null) {
bar.setColor(color);
@ -73,6 +91,15 @@ public class BossBarTrait extends Trait {
for (BarFlag flag : flags) {
bar.addFlag(flag);
}
if (barCache != null) {
barCache.removeAll();
for (Entity entity : npc.getEntity().getNearbyEntities(Setting.BOSSBAR_RANGE.asInt() / 2,
Setting.BOSSBAR_RANGE.asInt() / 2, Setting.BOSSBAR_RANGE.asInt() / 2)) {
if (entity instanceof Player) {
barCache.addPlayer((Player) entity);
}
}
}
}
public void setColor(BarColor color) {
@ -87,6 +114,10 @@ public class BossBarTrait extends Trait {
this.flags = flags;
}
public void setStyle(BarStyle style) {
this.style = style;
}
public void setTitle(String title) {
this.title = title;
}

View File

@ -354,6 +354,7 @@ public class Messages {
public static final String TEXT_EDITOR_INVALID_INPUT = "citizens.editors.text.invalid-input";
public static final String TEXT_EDITOR_INVALID_PAGE = "citizens.editors.text.invalid-page";
public static final String TEXT_EDITOR_INVALID_RANGE = "citizens.editors.text.invalid-range";
public static final String TEXT_EDITOR_LIST = "citizens.editors.text.text-list-header";
public static final String TEXT_EDITOR_MISSING_ITEM_PATTERN = "citizens.editors.text.missing-item-set-pattern";
public static final String TEXT_EDITOR_PAGE_PROMPT = "citizens.editors.text.change-page-prompt";
public static final String TEXT_EDITOR_RANDOM_TALKER_SET = "citizens.editors.text.random-talker-set";
@ -362,6 +363,7 @@ public class Messages {
public static final String TEXT_EDITOR_REMOVE_PROMPT = "citizens.editors.text.remove-prompt";
public static final String TEXT_EDITOR_REMOVED_ENTRY = "citizens.editors.text.removed-entry";
public static final String TEXT_EDITOR_SET_ITEM = "citizens.editors.text.talk-item-set";
public static final String TEXT_EDITOR_SPEECH_BUBBLES_SET = "citizens.editors.text.speech-bubbles-set";
public static final String TEXT_EDITOR_START_PROMPT = "citizens.editors.text.start-prompt";
public static final String TO_ENTITY_NOT_FOUND = "citizens.commands.npc.tpto.to-not-found";
public static final String TPTO_SUCCESS = "citizens.commands.npc.tpto.success";

View File

@ -324,10 +324,12 @@ citizens.editors.text.random-talker-set=[[Random talking]] set to [[{0}]].
citizens.editors.text.range-set=[[Range]] set to [[{0}]].
citizens.editors.text.delay-set=[[Delay]] set to [[{0}]] seconds.
citizens.editors.text.realistic-looking-set=[[Realistic looking]] set to [[{0}]].
citizens.editors.text.speech-bubbles-set=[[Speech bubbles]] set to [[{0}]].
citizens.editors.text.remove-prompt=Enter the index of the entry you wish to remove or [[page]] to view more pages.
citizens.editors.text.removed-entry=[[Removed]] entry at index [[{0}]].
citizens.editors.text.start-prompt=Type [[add]] to add an entry, [[edit]] to edit entries, [[remove]] to remove entries, [[close]] to toggle the NPC to send messages when players get close, [[item]] to set the talk item in hand pattern (set to [[default]] to clear), [[range]] to set the talking range, [[delay]] to set the talking delay in seconds and [[random]] to toggle the NPC as a random talker. Type [[help]] to show this again.
citizens.editors.text.start-prompt=Type [[add]] <text> to add an entry, [[edit]] to edit entries, [[remove]] to remove entries, [[close]] to toggle the NPC to send messages when players get close, [[item]] to set the talk item in hand pattern (set to [[default]] to clear), [[range]] to set the talking range, [[delay]] to set the talking delay in seconds and [[random]] to toggle the NPC as a random talker. Type [[help]] to show this again.
citizens.editors.text.talk-item-set=[[Talk item pattern]] set to [[{0}]].
citizens.editors.text.text-list-header=Current text:
citizens.editors.waypoints.wander.editing-regions-stop=Exited the region editor.
citizens.editors.waypoints.wander.worldguard-region-not-found=WorldGuard region not found.
citizens.editors.waypoints.wander.worldguard-region-set=WorldGuard region set to [[{0}]].

View File

@ -5,6 +5,7 @@ import java.util.List;
import org.bukkit.DyeColor;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BarStyle;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
@ -29,14 +30,18 @@ import net.citizensnpcs.util.Util;
public class Commands {
@Command(
aliases = { "npc" },
usage = "bossbar --color [color] --title [title] --visible [visible] --flags [flags]",
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags]",
desc = "Edit bossbar properties",
modifiers = { "bossbar" },
min = 1,
max = 1)
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER, EntityType.ENDER_DRAGON })
@Requirements(selected = true, ownership = true)
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
if (args.hasValueFlag("style")) {
BarStyle style = Util.matchEnum(BarStyle.values(), args.getFlag("style"));
trait.setStyle(style);
}
if (args.hasValueFlag("color")) {
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
trait.setColor(color);

View File

@ -5,6 +5,7 @@ import java.util.List;
import org.bukkit.DyeColor;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BarStyle;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Llama.Color;
@ -31,14 +32,18 @@ import net.citizensnpcs.util.Util;
public class Commands {
@Command(
aliases = { "npc" },
usage = "bossbar --color [color] --title [title] --visible [visible] --flags [flags]",
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags]",
desc = "Edit bossbar properties",
modifiers = { "bossbar" },
min = 1,
max = 1)
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER, EntityType.ENDER_DRAGON })
@Requirements(selected = true, ownership = true)
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
if (args.hasValueFlag("style")) {
BarStyle style = Util.matchEnum(BarStyle.values(), args.getFlag("style"));
trait.setStyle(style);
}
if (args.hasValueFlag("color")) {
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
trait.setColor(color);

View File

@ -5,6 +5,7 @@ import java.util.List;
import org.bukkit.DyeColor;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BarStyle;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Llama.Color;
@ -33,14 +34,18 @@ import net.citizensnpcs.util.Util;
public class Commands {
@Command(
aliases = { "npc" },
usage = "bossbar --color [color] --title [title] --visible [visible] --flags [flags]",
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags]",
desc = "Edit bossbar properties",
modifiers = { "bossbar" },
min = 1,
max = 1)
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER, EntityType.ENDER_DRAGON })
@Requirements(selected = true, ownership = true)
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
if (args.hasValueFlag("style")) {
BarStyle style = Util.matchEnum(BarStyle.values(), args.getFlag("style"));
trait.setStyle(style);
}
if (args.hasValueFlag("color")) {
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
trait.setColor(color);

View File

@ -5,6 +5,7 @@ import java.util.List;
import org.bukkit.DyeColor;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BarStyle;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Llama.Color;
@ -37,14 +38,18 @@ import net.citizensnpcs.util.Util;
public class Commands {
@Command(
aliases = { "npc" },
usage = "bossbar --color [color] --title [title] --visible [visible] --flags [flags]",
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags]",
desc = "Edit bossbar properties",
modifiers = { "bossbar" },
min = 1,
max = 1)
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER, EntityType.ENDER_DRAGON })
@Requirements(selected = true, ownership = true)
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
if (args.hasValueFlag("style")) {
BarStyle style = Util.matchEnum(BarStyle.values(), args.getFlag("style"));
trait.setStyle(style);
}
if (args.hasValueFlag("color")) {
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
trait.setColor(color);

View File

@ -5,6 +5,7 @@ import java.util.List;
import org.bukkit.DyeColor;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BarStyle;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Cat;
import org.bukkit.entity.EntityType;
@ -50,19 +51,22 @@ import net.citizensnpcs.util.Util;
public class Commands {
@Command(
aliases = { "npc" },
usage = "bossbar --color [color] --title [title] --visible [visible] --flags [flags]",
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags]",
desc = "Edit bossbar properties",
modifiers = { "bossbar" },
min = 1,
max = 1)
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER, EntityType.ENDER_DRAGON })
@Requirements(selected = true, ownership = true)
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
if (args.hasValueFlag("style")) {
BarStyle style = Util.matchEnum(BarStyle.values(), args.getFlag("style"));
trait.setStyle(style);
}
if (args.hasValueFlag("color")) {
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
trait.setColor(color);
}
if (args.hasValueFlag("title")) {
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
}

View File

@ -5,6 +5,7 @@ import java.util.List;
import org.bukkit.DyeColor;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BarStyle;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Cat;
import org.bukkit.entity.EntityType;
@ -89,19 +90,22 @@ public class Commands {
@Command(
aliases = { "npc" },
usage = "bossbar --color [color] --title [title] --visible [visible] --flags [flags]",
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags]",
desc = "Edit bossbar properties",
modifiers = { "bossbar" },
min = 1,
max = 1)
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER, EntityType.ENDER_DRAGON })
@Requirements(selected = true, ownership = true)
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
if (args.hasValueFlag("style")) {
BarStyle style = Util.matchEnum(BarStyle.values(), args.getFlag("style"));
trait.setStyle(style);
}
if (args.hasValueFlag("color")) {
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
trait.setColor(color);
}
if (args.hasValueFlag("title")) {
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
}

View File

@ -84,7 +84,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
private final Location packetLocationCache = new Location(null, 0, 0, 0);
private PlayerlistTracker playerlistTracker;
private final SkinPacketTracker skinTracker;
private int updateCounter = 0;
public EntityHumanNPC(MinecraftServer minecraftServer, WorldServer world, GameProfile gameProfile,

View File

@ -5,6 +5,7 @@ import java.util.List;
import org.bukkit.DyeColor;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BarStyle;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Cat;
import org.bukkit.entity.EntityType;
@ -89,19 +90,22 @@ public class Commands {
@Command(
aliases = { "npc" },
usage = "bossbar --color [color] --title [title] --visible [visible] --flags [flags]",
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags]",
desc = "Edit bossbar properties",
modifiers = { "bossbar" },
min = 1,
max = 1)
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER, EntityType.ENDER_DRAGON })
@Requirements(selected = true, ownership = true)
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
if (args.hasValueFlag("style")) {
BarStyle style = Util.matchEnum(BarStyle.values(), args.getFlag("style"));
trait.setStyle(style);
}
if (args.hasValueFlag("color")) {
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
trait.setColor(color);
}
if (args.hasValueFlag("title")) {
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
}

View File

@ -5,6 +5,7 @@ import java.util.List;
import org.bukkit.DyeColor;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BarStyle;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Axolotl;
import org.bukkit.entity.Cat;
@ -125,19 +126,22 @@ public class Commands {
@Command(
aliases = { "npc" },
usage = "bossbar --color [color] --title [title] --visible [visible] --flags [flags]",
usage = "bossbar --style [style] --color [color] --title [title] --visible [visible] --flags [flags]",
desc = "Edit bossbar properties",
modifiers = { "bossbar" },
min = 1,
max = 1)
@Requirements(selected = true, ownership = true, types = { EntityType.WITHER, EntityType.ENDER_DRAGON })
@Requirements(selected = true, ownership = true)
public void bossbar(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
BossBarTrait trait = npc.getOrAddTrait(BossBarTrait.class);
if (args.hasValueFlag("style")) {
BarStyle style = Util.matchEnum(BarStyle.values(), args.getFlag("style"));
trait.setStyle(style);
}
if (args.hasValueFlag("color")) {
BarColor color = Util.matchEnum(BarColor.values(), args.getFlag("color"));
trait.setColor(color);
}
if (args.hasValueFlag("title")) {
trait.setTitle(Colorizer.parseColors(args.getFlag("title")));
}