commit
a7863c9fe3
24 changed files with 237 additions and 85 deletions
|
@ -13,9 +13,11 @@ import lol.pyr.director.adventure.parse.primitive.DoubleParser;
|
||||||
import lol.pyr.director.adventure.parse.primitive.IntegerParser;
|
import lol.pyr.director.adventure.parse.primitive.IntegerParser;
|
||||||
import lol.pyr.director.common.message.Message;
|
import lol.pyr.director.common.message.Message;
|
||||||
import lol.pyr.znpcsplus.api.NpcApiProvider;
|
import lol.pyr.znpcsplus.api.NpcApiProvider;
|
||||||
|
import lol.pyr.znpcsplus.api.interaction.InteractionType;
|
||||||
import lol.pyr.znpcsplus.commands.*;
|
import lol.pyr.znpcsplus.commands.*;
|
||||||
import lol.pyr.znpcsplus.commands.action.ActionAddCommand;
|
import lol.pyr.znpcsplus.commands.action.ActionAddCommand;
|
||||||
import lol.pyr.znpcsplus.commands.action.ActionDeleteCommand;
|
import lol.pyr.znpcsplus.commands.action.ActionDeleteCommand;
|
||||||
|
import lol.pyr.znpcsplus.commands.action.ActionEditCommand;
|
||||||
import lol.pyr.znpcsplus.commands.action.ActionListCommand;
|
import lol.pyr.znpcsplus.commands.action.ActionListCommand;
|
||||||
import lol.pyr.znpcsplus.commands.hologram.*;
|
import lol.pyr.znpcsplus.commands.hologram.*;
|
||||||
import lol.pyr.znpcsplus.commands.storage.LoadAllCommand;
|
import lol.pyr.znpcsplus.commands.storage.LoadAllCommand;
|
||||||
|
@ -25,7 +27,6 @@ import lol.pyr.znpcsplus.entity.EntityPropertyImpl;
|
||||||
import lol.pyr.znpcsplus.entity.EntityPropertyRegistryImpl;
|
import lol.pyr.znpcsplus.entity.EntityPropertyRegistryImpl;
|
||||||
import lol.pyr.znpcsplus.interaction.ActionRegistry;
|
import lol.pyr.znpcsplus.interaction.ActionRegistry;
|
||||||
import lol.pyr.znpcsplus.interaction.InteractionPacketListener;
|
import lol.pyr.znpcsplus.interaction.InteractionPacketListener;
|
||||||
import lol.pyr.znpcsplus.api.interaction.InteractionType;
|
|
||||||
import lol.pyr.znpcsplus.metadata.*;
|
import lol.pyr.znpcsplus.metadata.*;
|
||||||
import lol.pyr.znpcsplus.npc.*;
|
import lol.pyr.znpcsplus.npc.*;
|
||||||
import lol.pyr.znpcsplus.packets.*;
|
import lol.pyr.znpcsplus.packets.*;
|
||||||
|
@ -117,7 +118,7 @@ public class ZNpcsPlus extends JavaPlugin {
|
||||||
|
|
||||||
log(ChatColor.WHITE + " * Registerring components...");
|
log(ChatColor.WHITE + " * Registerring components...");
|
||||||
typeRegistry.registerDefault(packetEvents, propertyRegistry);
|
typeRegistry.registerDefault(packetEvents, propertyRegistry);
|
||||||
actionRegistry.registerTypes(npcRegistry, scheduler, adventure, bungeeConnector, textSerializer);
|
actionRegistry.registerTypes(scheduler, adventure, bungeeConnector, textSerializer);
|
||||||
packetEvents.getEventManager().registerListener(new InteractionPacketListener(userManager, npcRegistry), PacketListenerPriority.MONITOR);
|
packetEvents.getEventManager().registerListener(new InteractionPacketListener(userManager, npcRegistry), PacketListenerPriority.MONITOR);
|
||||||
new Metrics(this, PLUGIN_ID);
|
new Metrics(this, PLUGIN_ID);
|
||||||
pluginManager.registerEvents(new UserListener(userManager), this);
|
pluginManager.registerEvents(new UserListener(userManager), this);
|
||||||
|
@ -243,8 +244,9 @@ public class ZNpcsPlus extends JavaPlugin {
|
||||||
.addSubcommand("set", new HoloSetCommand(npcRegistry, textSerializer))
|
.addSubcommand("set", new HoloSetCommand(npcRegistry, textSerializer))
|
||||||
.addSubcommand("offset", new HoloOffsetCommand(npcRegistry)))
|
.addSubcommand("offset", new HoloOffsetCommand(npcRegistry)))
|
||||||
.addSubcommand("action", new MultiCommand()
|
.addSubcommand("action", new MultiCommand()
|
||||||
.addSubcommand("add", new ActionAddCommand(actionRegistry))
|
.addSubcommand("add", new ActionAddCommand(npcRegistry, actionRegistry))
|
||||||
.addSubcommand("delete", new ActionDeleteCommand(npcRegistry))
|
.addSubcommand("delete", new ActionDeleteCommand(npcRegistry))
|
||||||
|
.addSubcommand("edit", new ActionEditCommand(npcRegistry, actionRegistry))
|
||||||
.addSubcommand("list", new ActionListCommand()))
|
.addSubcommand("list", new ActionListCommand()))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,12 @@ public class PropertiesCommand implements CommandHandler {
|
||||||
valueName = bukkitStack.toString();
|
valueName = bukkitStack.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (type == NamedTextColor.class && context.argSize() < 1 && npc.getProperty(property) != null) {
|
||||||
|
value = null;
|
||||||
|
valueName = "NONE";
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
value = context.parse(property.getType());
|
value = context.parse(type);
|
||||||
valueName = String.valueOf(value);
|
valueName = String.valueOf(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class SkinCommand implements CommandHandler {
|
||||||
String name = context.dumpAllArgs();
|
String name = context.dumpAllArgs();
|
||||||
context.send(Component.text("Fetching skin \"" + name + "\"...", NamedTextColor.GREEN));
|
context.send(Component.text("Fetching skin \"" + name + "\"...", NamedTextColor.GREEN));
|
||||||
PrefetchedDescriptor.forPlayer(skinCache, name).thenAccept(skin -> {
|
PrefetchedDescriptor.forPlayer(skinCache, name).thenAccept(skin -> {
|
||||||
if (skin == null) {
|
if (skin.getSkin() == null) {
|
||||||
context.send(Component.text("Failed to fetch skin, are you sure the player name is valid?", NamedTextColor.RED));
|
context.send(Component.text("Failed to fetch skin, are you sure the player name is valid?", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,9 @@ import lol.pyr.director.adventure.command.CommandHandler;
|
||||||
import lol.pyr.director.common.command.CommandExecutionException;
|
import lol.pyr.director.common.command.CommandExecutionException;
|
||||||
import lol.pyr.znpcsplus.interaction.ActionRegistry;
|
import lol.pyr.znpcsplus.interaction.ActionRegistry;
|
||||||
import lol.pyr.znpcsplus.interaction.InteractionCommandHandler;
|
import lol.pyr.znpcsplus.interaction.InteractionCommandHandler;
|
||||||
|
import lol.pyr.znpcsplus.npc.NpcEntryImpl;
|
||||||
|
import lol.pyr.znpcsplus.npc.NpcImpl;
|
||||||
|
import lol.pyr.znpcsplus.npc.NpcRegistryImpl;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
|
||||||
|
@ -13,19 +16,22 @@ import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ActionAddCommand implements CommandHandler {
|
public class ActionAddCommand implements CommandHandler {
|
||||||
|
private final NpcRegistryImpl npcRegistry;
|
||||||
private final ActionRegistry actionRegistry;
|
private final ActionRegistry actionRegistry;
|
||||||
|
|
||||||
public ActionAddCommand(ActionRegistry actionRegistry) {
|
public ActionAddCommand(NpcRegistryImpl npcRegistry, ActionRegistry actionRegistry) {
|
||||||
|
this.npcRegistry = npcRegistry;
|
||||||
this.actionRegistry = actionRegistry;
|
this.actionRegistry = actionRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(CommandContext context) throws CommandExecutionException {
|
public void run(CommandContext context) throws CommandExecutionException {
|
||||||
List<InteractionCommandHandler> commands = actionRegistry.getCommands();
|
List<InteractionCommandHandler> commands = actionRegistry.getCommands();
|
||||||
context.setUsage(context.getLabel() + " action add <action type>");
|
context.setUsage(context.getLabel() + " action add <id> <action type> ...");
|
||||||
|
NpcImpl npc = context.parse(NpcEntryImpl.class).getNpc();
|
||||||
String sub = context.popString();
|
String sub = context.popString();
|
||||||
for (InteractionCommandHandler command : commands) if (command.getSubcommandName().equalsIgnoreCase(sub)) {
|
for (InteractionCommandHandler command : commands) if (command.getSubcommandName().equalsIgnoreCase(sub)) {
|
||||||
command.run(context);
|
command.parse(context, npc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
context.send(Component.text("Invalid action type, available action types:\n" +
|
context.send(Component.text("Invalid action type, available action types:\n" +
|
||||||
|
@ -34,8 +40,10 @@ public class ActionAddCommand implements CommandHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> suggest(CommandContext context) throws CommandExecutionException {
|
public List<String> suggest(CommandContext context) throws CommandExecutionException {
|
||||||
|
if (context.argSize() == 1) return context.suggestCollection(npcRegistry.getModifiableIds());
|
||||||
List<InteractionCommandHandler> commands = actionRegistry.getCommands();
|
List<InteractionCommandHandler> commands = actionRegistry.getCommands();
|
||||||
if (context.argSize() == 1) return context.suggestStream(commands.stream().map(InteractionCommandHandler::getSubcommandName));
|
if (context.argSize() == 2) return context.suggestStream(commands.stream().map(InteractionCommandHandler::getSubcommandName));
|
||||||
|
context.popString();
|
||||||
String sub = context.popString();
|
String sub = context.popString();
|
||||||
for (InteractionCommandHandler command : commands) if (command.getSubcommandName().equalsIgnoreCase(sub)) return command.suggest(context);
|
for (InteractionCommandHandler command : commands) if (command.getSubcommandName().equalsIgnoreCase(sub)) return command.suggest(context);
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
package lol.pyr.znpcsplus.commands.action;
|
||||||
|
|
||||||
|
import lol.pyr.director.adventure.command.CommandContext;
|
||||||
|
import lol.pyr.director.adventure.command.CommandHandler;
|
||||||
|
import lol.pyr.director.common.command.CommandExecutionException;
|
||||||
|
import lol.pyr.znpcsplus.interaction.ActionRegistry;
|
||||||
|
import lol.pyr.znpcsplus.interaction.InteractionAction;
|
||||||
|
import lol.pyr.znpcsplus.interaction.InteractionCommandHandler;
|
||||||
|
import lol.pyr.znpcsplus.npc.NpcEntryImpl;
|
||||||
|
import lol.pyr.znpcsplus.npc.NpcRegistryImpl;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
public class ActionEditCommand implements CommandHandler {
|
||||||
|
private final NpcRegistryImpl npcRegistry;
|
||||||
|
private final ActionRegistry actionRegistry;
|
||||||
|
|
||||||
|
private InteractionCommandHandler commandHandler = null;
|
||||||
|
|
||||||
|
public ActionEditCommand(NpcRegistryImpl npcRegistry, ActionRegistry actionRegistry) {
|
||||||
|
this.npcRegistry = npcRegistry;
|
||||||
|
this.actionRegistry = actionRegistry;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(CommandContext context) throws CommandExecutionException {
|
||||||
|
context.setUsage(context.getLabel() + " action edit <id> <action id> <action type> ...");
|
||||||
|
NpcEntryImpl entry = context.parse(NpcEntryImpl.class);
|
||||||
|
int index = context.parse(Integer.class);
|
||||||
|
if (index >= entry.getNpc().getActions().size() || index < 0) context.halt(Component.text("That npc doesn't have any action with the index " + index, NamedTextColor.RED));
|
||||||
|
List<InteractionCommandHandler> commands = actionRegistry.getCommands();
|
||||||
|
String sub = context.popString();
|
||||||
|
for (InteractionCommandHandler command : commands) if (command.getSubcommandName().equalsIgnoreCase(sub)) {
|
||||||
|
this.commandHandler = command;
|
||||||
|
}
|
||||||
|
if (this.commandHandler == null) {
|
||||||
|
context.send(Component.text("Invalid action type, available action types:\n" +
|
||||||
|
commands.stream().map(InteractionCommandHandler::getSubcommandName).collect(Collectors.joining(", ")), NamedTextColor.RED));
|
||||||
|
}
|
||||||
|
InteractionAction newAction = this.commandHandler.parse(context, null);
|
||||||
|
entry.getNpc().editAction(index, newAction);
|
||||||
|
context.send(Component.text("Edited action with index " + index + " of Npc " + entry.getId(), NamedTextColor.GREEN));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> suggest(CommandContext context) throws CommandExecutionException {
|
||||||
|
if (context.argSize() == 1) return context.suggestCollection(npcRegistry.getModifiableIds());
|
||||||
|
if (context.argSize() == 2) return context.suggestStream(Stream.iterate(0, n -> n + 1)
|
||||||
|
.limit(context.suggestionParse(0, NpcEntryImpl.class).getNpc().getActions().size())
|
||||||
|
.map(String::valueOf));
|
||||||
|
List<InteractionCommandHandler> commands = actionRegistry.getCommands();
|
||||||
|
if (context.argSize() == 3) return context.suggestStream(commands.stream().map(InteractionCommandHandler::getSubcommandName));
|
||||||
|
context.popString();
|
||||||
|
context.popString();
|
||||||
|
String sub = context.popString();
|
||||||
|
for (InteractionCommandHandler command : commands) if (command.getSubcommandName().equalsIgnoreCase(sub)) return command.suggest(context);
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,6 +31,7 @@ public class EntityPropertyRegistryImpl implements EntityPropertyRegistry {
|
||||||
registerType("skin", SkinDescriptor.class);
|
registerType("skin", SkinDescriptor.class);
|
||||||
registerType("name", Component.class);
|
registerType("name", Component.class);
|
||||||
registerType("look", false);
|
registerType("look", false);
|
||||||
|
registerType("cape", true);
|
||||||
|
|
||||||
registerType("helmet", ItemStack.class);
|
registerType("helmet", ItemStack.class);
|
||||||
registerType("chestplate", ItemStack.class);
|
registerType("chestplate", ItemStack.class);
|
||||||
|
|
|
@ -4,7 +4,6 @@ import lol.pyr.znpcsplus.interaction.consolecommand.ConsoleCommandActionType;
|
||||||
import lol.pyr.znpcsplus.interaction.message.MessageActionType;
|
import lol.pyr.znpcsplus.interaction.message.MessageActionType;
|
||||||
import lol.pyr.znpcsplus.interaction.playercommand.PlayerCommandActionType;
|
import lol.pyr.znpcsplus.interaction.playercommand.PlayerCommandActionType;
|
||||||
import lol.pyr.znpcsplus.interaction.switchserver.SwitchServerActionType;
|
import lol.pyr.znpcsplus.interaction.switchserver.SwitchServerActionType;
|
||||||
import lol.pyr.znpcsplus.npc.NpcRegistryImpl;
|
|
||||||
import lol.pyr.znpcsplus.scheduling.TaskScheduler;
|
import lol.pyr.znpcsplus.scheduling.TaskScheduler;
|
||||||
import lol.pyr.znpcsplus.util.BungeeConnector;
|
import lol.pyr.znpcsplus.util.BungeeConnector;
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
|
@ -22,11 +21,11 @@ public class ActionRegistry {
|
||||||
public ActionRegistry() {
|
public ActionRegistry() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerTypes(NpcRegistryImpl npcRegistry, TaskScheduler taskScheduler, BukkitAudiences adventure, BungeeConnector bungeeConnector, LegacyComponentSerializer textSerializer) {
|
public void registerTypes(TaskScheduler taskScheduler, BukkitAudiences adventure, BungeeConnector bungeeConnector, LegacyComponentSerializer textSerializer) {
|
||||||
register(new ConsoleCommandActionType(taskScheduler, npcRegistry));
|
register(new ConsoleCommandActionType(taskScheduler));
|
||||||
register(new PlayerCommandActionType(taskScheduler, npcRegistry));
|
register(new PlayerCommandActionType(taskScheduler));
|
||||||
register(new SwitchServerActionType(bungeeConnector, npcRegistry));
|
register(new SwitchServerActionType(bungeeConnector));
|
||||||
register(new MessageActionType(adventure, textSerializer, npcRegistry));
|
register(new MessageActionType(adventure, textSerializer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register(InteractionActionType<?> type) {
|
public void register(InteractionActionType<?> type) {
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
package lol.pyr.znpcsplus.interaction;
|
package lol.pyr.znpcsplus.interaction;
|
||||||
|
|
||||||
|
import lol.pyr.director.adventure.command.CommandContext;
|
||||||
import lol.pyr.director.adventure.command.CommandHandler;
|
import lol.pyr.director.adventure.command.CommandHandler;
|
||||||
|
import lol.pyr.director.common.command.CommandExecutionException;
|
||||||
|
import lol.pyr.znpcsplus.npc.NpcImpl;
|
||||||
|
|
||||||
public interface InteractionCommandHandler extends CommandHandler {
|
public interface InteractionCommandHandler extends CommandHandler {
|
||||||
String getSubcommandName();
|
String getSubcommandName();
|
||||||
|
|
||||||
|
InteractionAction parse(CommandContext context, NpcImpl npc) throws CommandExecutionException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,11 @@ package lol.pyr.znpcsplus.interaction.consolecommand;
|
||||||
|
|
||||||
import lol.pyr.director.adventure.command.CommandContext;
|
import lol.pyr.director.adventure.command.CommandContext;
|
||||||
import lol.pyr.director.common.command.CommandExecutionException;
|
import lol.pyr.director.common.command.CommandExecutionException;
|
||||||
|
import lol.pyr.znpcsplus.api.interaction.InteractionType;
|
||||||
|
import lol.pyr.znpcsplus.interaction.InteractionAction;
|
||||||
import lol.pyr.znpcsplus.interaction.InteractionActionType;
|
import lol.pyr.znpcsplus.interaction.InteractionActionType;
|
||||||
import lol.pyr.znpcsplus.interaction.InteractionCommandHandler;
|
import lol.pyr.znpcsplus.interaction.InteractionCommandHandler;
|
||||||
import lol.pyr.znpcsplus.api.interaction.InteractionType;
|
import lol.pyr.znpcsplus.npc.NpcImpl;
|
||||||
import lol.pyr.znpcsplus.npc.NpcEntryImpl;
|
|
||||||
import lol.pyr.znpcsplus.npc.NpcRegistryImpl;
|
|
||||||
import lol.pyr.znpcsplus.scheduling.TaskScheduler;
|
import lol.pyr.znpcsplus.scheduling.TaskScheduler;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
@ -18,11 +18,9 @@ import java.util.List;
|
||||||
|
|
||||||
public class ConsoleCommandActionType implements InteractionActionType<ConsoleCommandAction>, InteractionCommandHandler {
|
public class ConsoleCommandActionType implements InteractionActionType<ConsoleCommandAction>, InteractionCommandHandler {
|
||||||
private final TaskScheduler scheduler;
|
private final TaskScheduler scheduler;
|
||||||
private final NpcRegistryImpl npcRegistry;
|
|
||||||
|
|
||||||
public ConsoleCommandActionType(TaskScheduler scheduler, NpcRegistryImpl npcRegistry) {
|
public ConsoleCommandActionType(TaskScheduler scheduler) {
|
||||||
this.scheduler = scheduler;
|
this.scheduler = scheduler;
|
||||||
this.npcRegistry = npcRegistry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -48,21 +46,28 @@ public class ConsoleCommandActionType implements InteractionActionType<ConsoleCo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(CommandContext context) throws CommandExecutionException {
|
public InteractionAction parse(CommandContext context, NpcImpl npc) throws CommandExecutionException {
|
||||||
context.setUsage(context.getUsage() + " consolecommand <id> <type> <cooldown seconds> <command>");
|
context.setUsage(context.getUsage() + getSubcommandName() + " <type> <cooldown seconds> <command>");
|
||||||
NpcEntryImpl entry = context.parse(NpcEntryImpl.class);
|
|
||||||
InteractionType type = context.parse(InteractionType.class);
|
InteractionType type = context.parse(InteractionType.class);
|
||||||
long cooldown = (long) (context.parse(Double.class) * 1000D);
|
long cooldown = (long) (context.parse(Double.class) * 1000D);
|
||||||
String command = context.dumpAllArgs();
|
String command = context.dumpAllArgs();
|
||||||
entry.getNpc().addAction(new ConsoleCommandAction(scheduler, command, type, cooldown));
|
ConsoleCommandAction action = new ConsoleCommandAction(scheduler, command, type, cooldown);
|
||||||
context.send(Component.text("Added a console command action to the npc with the command " + command, NamedTextColor.GREEN));
|
if (npc != null) {
|
||||||
|
npc.addAction(action);
|
||||||
|
context.send(Component.text("Added a console command action to the npc with the command " + action.getCommand(), NamedTextColor.GREEN));
|
||||||
|
}
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(CommandContext context) throws CommandExecutionException {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> suggest(CommandContext context) throws CommandExecutionException {
|
public List<String> suggest(CommandContext context) throws CommandExecutionException {
|
||||||
if (context.argSize() == 1) return context.suggestCollection(npcRegistry.getModifiableIds());
|
if (context.argSize() == 1) return context.suggestEnum(InteractionType.values());
|
||||||
if (context.argSize() == 2) return context.suggestEnum(InteractionType.values());
|
if (context.argSize() == 2) return context.suggestLiteral("1");
|
||||||
if (context.argSize() == 3) return context.suggestLiteral("1");
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,10 @@ package lol.pyr.znpcsplus.interaction.message;
|
||||||
import lol.pyr.director.adventure.command.CommandContext;
|
import lol.pyr.director.adventure.command.CommandContext;
|
||||||
import lol.pyr.director.common.command.CommandExecutionException;
|
import lol.pyr.director.common.command.CommandExecutionException;
|
||||||
import lol.pyr.znpcsplus.api.interaction.InteractionType;
|
import lol.pyr.znpcsplus.api.interaction.InteractionType;
|
||||||
|
import lol.pyr.znpcsplus.interaction.InteractionAction;
|
||||||
import lol.pyr.znpcsplus.interaction.InteractionActionType;
|
import lol.pyr.znpcsplus.interaction.InteractionActionType;
|
||||||
import lol.pyr.znpcsplus.interaction.InteractionCommandHandler;
|
import lol.pyr.znpcsplus.interaction.InteractionCommandHandler;
|
||||||
import lol.pyr.znpcsplus.npc.NpcEntryImpl;
|
import lol.pyr.znpcsplus.npc.NpcImpl;
|
||||||
import lol.pyr.znpcsplus.npc.NpcRegistryImpl;
|
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
@ -20,12 +20,10 @@ import java.util.List;
|
||||||
public class MessageActionType implements InteractionActionType<MessageAction>, InteractionCommandHandler {
|
public class MessageActionType implements InteractionActionType<MessageAction>, InteractionCommandHandler {
|
||||||
private final BukkitAudiences adventure;
|
private final BukkitAudiences adventure;
|
||||||
private final LegacyComponentSerializer textSerializer;
|
private final LegacyComponentSerializer textSerializer;
|
||||||
private final NpcRegistryImpl npcRegistry;
|
|
||||||
|
|
||||||
public MessageActionType(BukkitAudiences adventure, LegacyComponentSerializer textSerializer, NpcRegistryImpl npcRegistry) {
|
public MessageActionType(BukkitAudiences adventure, LegacyComponentSerializer textSerializer) {
|
||||||
this.adventure = adventure;
|
this.adventure = adventure;
|
||||||
this.textSerializer = textSerializer;
|
this.textSerializer = textSerializer;
|
||||||
this.npcRegistry = npcRegistry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,21 +49,28 @@ public class MessageActionType implements InteractionActionType<MessageAction>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(CommandContext context) throws CommandExecutionException {
|
public InteractionAction parse(CommandContext context, NpcImpl npc) throws CommandExecutionException {
|
||||||
context.setUsage(context.getUsage() + " message <id> <type> <cooldown seconds> <message>");
|
context.setUsage(context.getUsage() + " <type> <cooldown seconds> <message>");
|
||||||
NpcEntryImpl entry = context.parse(NpcEntryImpl.class);
|
|
||||||
InteractionType type = context.parse(InteractionType.class);
|
InteractionType type = context.parse(InteractionType.class);
|
||||||
long cooldown = (long) (context.parse(Double.class) * 1000D);
|
long cooldown = (long) (context.parse(Double.class) * 1000D);
|
||||||
String message = context.dumpAllArgs();
|
String message = context.dumpAllArgs();
|
||||||
entry.getNpc().addAction(new MessageAction(adventure, message, type, textSerializer, cooldown));
|
MessageAction action = new MessageAction(adventure, message, type, textSerializer, cooldown);
|
||||||
context.send(Component.text("Added a message action to the npc with the message ", NamedTextColor.GREEN).append(Component.text(message)));
|
if (npc != null) {
|
||||||
|
npc.addAction(action);
|
||||||
|
context.send(Component.text("Added a message action to the npc with the message ", NamedTextColor.GREEN).append(Component.text(message)));
|
||||||
|
}
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(CommandContext context) throws CommandExecutionException {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> suggest(CommandContext context) throws CommandExecutionException {
|
public List<String> suggest(CommandContext context) throws CommandExecutionException {
|
||||||
if (context.argSize() == 1) return context.suggestCollection(npcRegistry.getModifiableIds());
|
if (context.argSize() == 1) return context.suggestEnum(InteractionType.values());
|
||||||
if (context.argSize() == 2) return context.suggestEnum(InteractionType.values());
|
if (context.argSize() == 2) return context.suggestLiteral("1");
|
||||||
if (context.argSize() == 3) return context.suggestLiteral("1");
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,11 @@ package lol.pyr.znpcsplus.interaction.playercommand;
|
||||||
|
|
||||||
import lol.pyr.director.adventure.command.CommandContext;
|
import lol.pyr.director.adventure.command.CommandContext;
|
||||||
import lol.pyr.director.common.command.CommandExecutionException;
|
import lol.pyr.director.common.command.CommandExecutionException;
|
||||||
|
import lol.pyr.znpcsplus.api.interaction.InteractionType;
|
||||||
|
import lol.pyr.znpcsplus.interaction.InteractionAction;
|
||||||
import lol.pyr.znpcsplus.interaction.InteractionActionType;
|
import lol.pyr.znpcsplus.interaction.InteractionActionType;
|
||||||
import lol.pyr.znpcsplus.interaction.InteractionCommandHandler;
|
import lol.pyr.znpcsplus.interaction.InteractionCommandHandler;
|
||||||
import lol.pyr.znpcsplus.api.interaction.InteractionType;
|
import lol.pyr.znpcsplus.npc.NpcImpl;
|
||||||
import lol.pyr.znpcsplus.npc.NpcEntryImpl;
|
|
||||||
import lol.pyr.znpcsplus.npc.NpcRegistryImpl;
|
|
||||||
import lol.pyr.znpcsplus.scheduling.TaskScheduler;
|
import lol.pyr.znpcsplus.scheduling.TaskScheduler;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
@ -18,11 +18,9 @@ import java.util.List;
|
||||||
|
|
||||||
public class PlayerCommandActionType implements InteractionActionType<PlayerCommandAction>, InteractionCommandHandler {
|
public class PlayerCommandActionType implements InteractionActionType<PlayerCommandAction>, InteractionCommandHandler {
|
||||||
private final TaskScheduler scheduler;
|
private final TaskScheduler scheduler;
|
||||||
private final NpcRegistryImpl npcRegistry;
|
|
||||||
|
|
||||||
public PlayerCommandActionType(TaskScheduler scheduler, NpcRegistryImpl npcRegistry) {
|
public PlayerCommandActionType(TaskScheduler scheduler) {
|
||||||
this.scheduler = scheduler;
|
this.scheduler = scheduler;
|
||||||
this.npcRegistry = npcRegistry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -48,21 +46,28 @@ public class PlayerCommandActionType implements InteractionActionType<PlayerComm
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(CommandContext context) throws CommandExecutionException {
|
public InteractionAction parse(CommandContext context, NpcImpl npc) throws CommandExecutionException {
|
||||||
context.setUsage(context.getUsage() + " playercommand <id> <type> <cooldown seconds> <command>");
|
context.setUsage(context.getUsage() + getSubcommandName() + " <type> <cooldown seconds> <command>");
|
||||||
NpcEntryImpl entry = context.parse(NpcEntryImpl.class);
|
|
||||||
InteractionType type = context.parse(InteractionType.class);
|
InteractionType type = context.parse(InteractionType.class);
|
||||||
long cooldown = (long) (context.parse(Double.class) * 1000D);
|
long cooldown = (long) (context.parse(Double.class) * 1000D);
|
||||||
String command = context.dumpAllArgs();
|
String command = context.dumpAllArgs();
|
||||||
entry.getNpc().addAction(new PlayerCommandAction(scheduler, command, type, cooldown));
|
PlayerCommandAction action = new PlayerCommandAction(scheduler, command, type, cooldown);
|
||||||
context.send(Component.text("Added a player command action to the npc with the command " + command, NamedTextColor.GREEN));
|
if (npc != null) {
|
||||||
|
npc.addAction(action);
|
||||||
|
context.send(Component.text("Added a player command action to the npc with the command " + action.getCommand(), NamedTextColor.GREEN));
|
||||||
|
}
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(CommandContext context) throws CommandExecutionException {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> suggest(CommandContext context) throws CommandExecutionException {
|
public List<String> suggest(CommandContext context) throws CommandExecutionException {
|
||||||
if (context.argSize() == 1) return context.suggestCollection(npcRegistry.getModifiableIds());
|
if (context.argSize() == 1) return context.suggestEnum(InteractionType.values());
|
||||||
if (context.argSize() == 2) return context.suggestEnum(InteractionType.values());
|
if (context.argSize() == 2) return context.suggestLiteral("1");
|
||||||
if (context.argSize() == 3) return context.suggestLiteral("1");
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,11 @@ package lol.pyr.znpcsplus.interaction.switchserver;
|
||||||
|
|
||||||
import lol.pyr.director.adventure.command.CommandContext;
|
import lol.pyr.director.adventure.command.CommandContext;
|
||||||
import lol.pyr.director.common.command.CommandExecutionException;
|
import lol.pyr.director.common.command.CommandExecutionException;
|
||||||
|
import lol.pyr.znpcsplus.api.interaction.InteractionType;
|
||||||
|
import lol.pyr.znpcsplus.interaction.InteractionAction;
|
||||||
import lol.pyr.znpcsplus.interaction.InteractionActionType;
|
import lol.pyr.znpcsplus.interaction.InteractionActionType;
|
||||||
import lol.pyr.znpcsplus.interaction.InteractionCommandHandler;
|
import lol.pyr.znpcsplus.interaction.InteractionCommandHandler;
|
||||||
import lol.pyr.znpcsplus.api.interaction.InteractionType;
|
import lol.pyr.znpcsplus.npc.NpcImpl;
|
||||||
import lol.pyr.znpcsplus.npc.NpcEntryImpl;
|
|
||||||
import lol.pyr.znpcsplus.npc.NpcRegistryImpl;
|
|
||||||
import lol.pyr.znpcsplus.util.BungeeConnector;
|
import lol.pyr.znpcsplus.util.BungeeConnector;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
@ -18,11 +18,9 @@ import java.util.List;
|
||||||
|
|
||||||
public class SwitchServerActionType implements InteractionActionType<SwitchServerAction>, InteractionCommandHandler {
|
public class SwitchServerActionType implements InteractionActionType<SwitchServerAction>, InteractionCommandHandler {
|
||||||
private final BungeeConnector bungeeConnector;
|
private final BungeeConnector bungeeConnector;
|
||||||
private final NpcRegistryImpl npcRegistry;
|
|
||||||
|
|
||||||
public SwitchServerActionType(BungeeConnector bungeeConnector, NpcRegistryImpl npcRegistry) {
|
public SwitchServerActionType(BungeeConnector bungeeConnector) {
|
||||||
this.bungeeConnector = bungeeConnector;
|
this.bungeeConnector = bungeeConnector;
|
||||||
this.npcRegistry = npcRegistry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -48,21 +46,28 @@ public class SwitchServerActionType implements InteractionActionType<SwitchServe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(CommandContext context) throws CommandExecutionException {
|
public InteractionAction parse(CommandContext context, NpcImpl npc) throws CommandExecutionException {
|
||||||
context.setUsage(context.getUsage() + " switchserver <id> <type> <cooldown seconds> <server>");
|
context.setUsage(context.getUsage() +getSubcommandName() + " <type> <cooldown seconds> <server>");
|
||||||
NpcEntryImpl entry = context.parse(NpcEntryImpl.class);
|
|
||||||
InteractionType type = context.parse(InteractionType.class);
|
InteractionType type = context.parse(InteractionType.class);
|
||||||
long cooldown = (long) (context.parse(Double.class) * 1000D);
|
long cooldown = (long) (context.parse(Double.class) * 1000D);
|
||||||
String server = context.dumpAllArgs();
|
String server = context.dumpAllArgs();
|
||||||
entry.getNpc().addAction(new SwitchServerAction(bungeeConnector, server, type, cooldown));
|
SwitchServerAction action = new SwitchServerAction(bungeeConnector, server, type, cooldown);
|
||||||
context.send(Component.text("Added a switch server action to the npc with the server " + server, NamedTextColor.GREEN));
|
if (npc != null) {
|
||||||
|
npc.addAction(action);
|
||||||
|
context.send(Component.text("Added a switch server action to the npc with the server " + action.getServer(), NamedTextColor.GREEN));
|
||||||
|
}
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(CommandContext context) throws CommandExecutionException {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> suggest(CommandContext context) throws CommandExecutionException {
|
public List<String> suggest(CommandContext context) throws CommandExecutionException {
|
||||||
if (context.argSize() == 1) return context.suggestCollection(npcRegistry.getModifiableIds());
|
if (context.argSize() == 1) return context.suggestEnum(InteractionType.values());
|
||||||
if (context.argSize() == 2) return context.suggestEnum(InteractionType.values());
|
if (context.argSize() == 2) return context.suggestLiteral("1");
|
||||||
if (context.argSize() == 3) return context.suggestLiteral("1");
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,21 +6,21 @@ import net.kyori.adventure.text.Component;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1.8 https://wiki.vg/index.php?title=Entity_metadata&oldid=7415
|
* 1.8 <a href="https://wiki.vg/index.php?title=Entity_metadata&oldid=7415">...</a>
|
||||||
* 1.9 https://wiki.vg/index.php?title=Entity_metadata&oldid=7968
|
* 1.9 <a href="https://wiki.vg/index.php?title=Entity_metadata&oldid=7968">...</a>
|
||||||
* 1.10 https://wiki.vg/index.php?title=Entity_metadata&oldid=8241
|
* 1.10 <a href="https://wiki.vg/index.php?title=Entity_metadata&oldid=8241">...</a>
|
||||||
* 1.11 https://wiki.vg/index.php?title=Entity_metadata&oldid=8534
|
* 1.11 <a href="https://wiki.vg/index.php?title=Entity_metadata&oldid=8534">...</a>
|
||||||
* 1.12 https://wiki.vg/index.php?title=Entity_metadata&oldid=14048
|
* 1.12 <a href="https://wiki.vg/index.php?title=Entity_metadata&oldid=14048">...</a>
|
||||||
* 1.13 https://wiki.vg/index.php?title=Entity_metadata&oldid=14800
|
* 1.13 <a href="https://wiki.vg/index.php?title=Entity_metadata&oldid=14800">...</a>
|
||||||
* 1.14 https://wiki.vg/index.php?title=Entity_metadata&oldid=15240
|
* 1.14 <a href="https://wiki.vg/index.php?title=Entity_metadata&oldid=15240">...</a>
|
||||||
* 1.15 https://wiki.vg/index.php?title=Entity_metadata&oldid=15991
|
* 1.15 <a href="https://wiki.vg/index.php?title=Entity_metadata&oldid=15991">...</a>
|
||||||
* 1.16 https://wiki.vg/index.php?title=Entity_metadata&oldid=16539
|
* 1.16 <a href="https://wiki.vg/index.php?title=Entity_metadata&oldid=16539">...</a>
|
||||||
* 1.17 https://wiki.vg/index.php?title=Entity_metadata&oldid=17521
|
* 1.17 <a href="https://wiki.vg/index.php?title=Entity_metadata&oldid=17521">...</a>
|
||||||
* 1.18 NOTHING CHANGED
|
* 1.18-1.19 <a href="https://wiki.vg/index.php?title=Entity_metadata">...</a>
|
||||||
* 1.19 https://wiki.vg/index.php?title=Entity_metadata
|
|
||||||
*/
|
*/
|
||||||
public interface MetadataFactory {
|
public interface MetadataFactory {
|
||||||
EntityData skinLayers(boolean enabled);
|
EntityData skinLayers(boolean enabled);
|
||||||
|
EntityData cape(boolean enabled);
|
||||||
EntityData effects(boolean onFire, boolean glowing, boolean invisible);
|
EntityData effects(boolean onFire, boolean glowing, boolean invisible);
|
||||||
EntityData silent(boolean enabled);
|
EntityData silent(boolean enabled);
|
||||||
Collection<EntityData> name(Component name);
|
Collection<EntityData> name(Component name);
|
||||||
|
|
|
@ -4,6 +4,11 @@ import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
|
|
||||||
public class V1_10MetadataFactory extends V1_9MetadataFactory {
|
public class V1_10MetadataFactory extends V1_9MetadataFactory {
|
||||||
|
@Override
|
||||||
|
public EntityData cape(boolean enabled) {
|
||||||
|
return createCape(13, enabled);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityData noGravity() {
|
public EntityData noGravity() {
|
||||||
return new EntityData(5, EntityDataTypes.BOOLEAN, true);
|
return new EntityData(5, EntityDataTypes.BOOLEAN, true);
|
||||||
|
|
|
@ -7,4 +7,9 @@ public class V1_14MetadataFactory extends V1_13MetadataFactory {
|
||||||
public EntityData skinLayers(boolean enabled) {
|
public EntityData skinLayers(boolean enabled) {
|
||||||
return createSkinLayers(15, enabled);
|
return createSkinLayers(15, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityData cape(boolean enabled) {
|
||||||
|
return createCape(15, enabled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package lol.pyr.znpcsplus.metadata;
|
||||||
|
|
||||||
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||||
|
|
||||||
|
public class V1_15MetadataFactory extends V1_14MetadataFactory {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityData cape(boolean enabled) {
|
||||||
|
return createCape(16, enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ package lol.pyr.znpcsplus.metadata;
|
||||||
|
|
||||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||||
|
|
||||||
public class V1_16MetadataFactory extends V1_14MetadataFactory {
|
public class V1_16MetadataFactory extends V1_15MetadataFactory {
|
||||||
@Override
|
@Override
|
||||||
public EntityData skinLayers(boolean enabled) {
|
public EntityData skinLayers(boolean enabled) {
|
||||||
return createSkinLayers(16, enabled);
|
return createSkinLayers(16, enabled);
|
||||||
|
|
|
@ -7,4 +7,9 @@ public class V1_17MetadataFactory extends V1_16MetadataFactory {
|
||||||
public EntityData skinLayers(boolean enabled) {
|
public EntityData skinLayers(boolean enabled) {
|
||||||
return createSkinLayers(17, enabled);
|
return createSkinLayers(17, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityData cape(boolean enabled) {
|
||||||
|
return createCape(17, enabled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,11 @@ public class V1_8MetadataFactory implements MetadataFactory {
|
||||||
return createSkinLayers(12, enabled);
|
return createSkinLayers(12, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityData cape(boolean enabled) {
|
||||||
|
return createCape(10, enabled);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityData effects(boolean onFire, boolean glowing, boolean invisible) {
|
public EntityData effects(boolean onFire, boolean glowing, boolean invisible) {
|
||||||
return new EntityData(0, EntityDataTypes.BYTE, (byte) ((onFire ? 0x01 : 0) | (invisible ? 0x20 : 0)));
|
return new EntityData(0, EntityDataTypes.BYTE, (byte) ((onFire ? 0x01 : 0) | (invisible ? 0x20 : 0)));
|
||||||
|
@ -40,4 +45,8 @@ public class V1_8MetadataFactory implements MetadataFactory {
|
||||||
protected EntityData createSkinLayers(int index, boolean enabled) {
|
protected EntityData createSkinLayers(int index, boolean enabled) {
|
||||||
return new EntityData(index, EntityDataTypes.BYTE, enabled ? Byte.MAX_VALUE : 0);
|
return new EntityData(index, EntityDataTypes.BYTE, enabled ? Byte.MAX_VALUE : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected EntityData createCape(int index, boolean enabled) {
|
||||||
|
return new EntityData(index, EntityDataTypes.BYTE, (byte) (enabled ? 0x01 : 0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,11 @@ public class V1_9MetadataFactory extends V1_8MetadataFactory {
|
||||||
return createSkinLayers(13, enabled);
|
return createSkinLayers(13, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityData cape(boolean enabled) {
|
||||||
|
return createCape(12, enabled);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityData effects(boolean onFire, boolean glowing, boolean invisible) {
|
public EntityData effects(boolean onFire, boolean glowing, boolean invisible) {
|
||||||
return new EntityData(0, EntityDataTypes.BYTE, (byte) ((onFire ? 0x01 : 0) | (invisible ? 0x20 : 0) | (glowing ? 0x40 : 0)));
|
return new EntityData(0, EntityDataTypes.BYTE, (byte) ((onFire ? 0x01 : 0) | (invisible ? 0x20 : 0) | (glowing ? 0x40 : 0)));
|
||||||
|
|
|
@ -146,4 +146,8 @@ public class NpcImpl extends Viewable implements Npc {
|
||||||
public void addAction(InteractionAction action) {
|
public void addAction(InteractionAction action) {
|
||||||
actions.add(action);
|
actions.add(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void editAction(int index, InteractionAction action) {
|
||||||
|
actions.set(index, action);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,7 @@ public class NpcTypeImpl implements NpcType {
|
||||||
allowedProperties.add(propertyRegistry.getByName("invisible"));
|
allowedProperties.add(propertyRegistry.getByName("invisible"));
|
||||||
allowedProperties.add(propertyRegistry.getByName("silent"));
|
allowedProperties.add(propertyRegistry.getByName("silent"));
|
||||||
allowedProperties.add(propertyRegistry.getByName("look"));
|
allowedProperties.add(propertyRegistry.getByName("look"));
|
||||||
|
allowedProperties.add(propertyRegistry.getByName("cape"));
|
||||||
if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_9))
|
if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_9))
|
||||||
allowedProperties.add(propertyRegistry.getByName("glow"));
|
allowedProperties.add(propertyRegistry.getByName("glow"));
|
||||||
return new NpcTypeImpl(name, type, hologramOffset, new HashSet<>(allowedProperties));
|
return new NpcTypeImpl(name, type, hologramOffset, new HashSet<>(allowedProperties));
|
||||||
|
|
|
@ -126,7 +126,10 @@ public class V1_8PacketFactory implements PacketFactory {
|
||||||
@Override
|
@Override
|
||||||
public Map<Integer, EntityData> generateMetadata(Player player, PacketEntity entity, PropertyHolder properties) {
|
public Map<Integer, EntityData> generateMetadata(Player player, PacketEntity entity, PropertyHolder properties) {
|
||||||
HashMap<Integer, EntityData> data = new HashMap<>();
|
HashMap<Integer, EntityData> data = new HashMap<>();
|
||||||
if (entity.getType() == EntityTypes.PLAYER) add(data, metadataFactory.skinLayers(properties.getProperty(propertyRegistry.getByName("skin_layers", Boolean.class))));
|
if (entity.getType() == EntityTypes.PLAYER) {
|
||||||
|
add(data, metadataFactory.skinLayers(properties.getProperty(propertyRegistry.getByName("skin_layers", Boolean.class))));
|
||||||
|
add(data, metadataFactory.cape(properties.getProperty(propertyRegistry.getByName("cape", Boolean.class))));
|
||||||
|
}
|
||||||
add(data, metadataFactory.effects(properties.getProperty(propertyRegistry.getByName("fire", Boolean.class)), false, properties.getProperty(propertyRegistry.getByName("fire", Boolean.class))));
|
add(data, metadataFactory.effects(properties.getProperty(propertyRegistry.getByName("fire", Boolean.class)), false, properties.getProperty(propertyRegistry.getByName("fire", Boolean.class))));
|
||||||
add(data, metadataFactory.silent(properties.getProperty(propertyRegistry.getByName("silent", Boolean.class))));
|
add(data, metadataFactory.silent(properties.getProperty(propertyRegistry.getByName("silent", Boolean.class))));
|
||||||
if (properties.hasProperty(propertyRegistry.getByName("name"))) addAll(data, metadataFactory.name(properties.getProperty(propertyRegistry.getByName("name", Component.class))));
|
if (properties.hasProperty(propertyRegistry.getByName("name"))) addAll(data, metadataFactory.name(properties.getProperty(propertyRegistry.getByName("name", Component.class))));
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class SkinCache {
|
||||||
}
|
}
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
if (!configManager.getConfig().disableSkinFetcherWarnings()) {
|
if (!configManager.getConfig().disableSkinFetcherWarnings()) {
|
||||||
logger.warning("Failed to uuid from player name:");
|
logger.warning("Failed to get uuid from player name:");
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Reference in a new issue