rename BungeeUtil to BungeeConnector
This commit is contained in:
parent
975bae38d8
commit
aff202e5ec
5 changed files with 20 additions and 20 deletions
|
@ -44,7 +44,7 @@ import lol.pyr.znpcsplus.updater.UpdateChecker;
|
|||
import lol.pyr.znpcsplus.updater.UpdateNotificationListener;
|
||||
import lol.pyr.znpcsplus.user.UserListener;
|
||||
import lol.pyr.znpcsplus.user.UserManager;
|
||||
import lol.pyr.znpcsplus.util.BungeeUtil;
|
||||
import lol.pyr.znpcsplus.util.BungeeConnector;
|
||||
import lol.pyr.znpcsplus.util.FoliaUtil;
|
||||
import lol.pyr.znpcsplus.util.LazyLoader;
|
||||
import lol.pyr.znpcsplus.util.ZLocation;
|
||||
|
@ -110,7 +110,7 @@ public class ZNpcsPlus extends JavaPlugin {
|
|||
TaskScheduler scheduler = FoliaUtil.isFolia() ? new FoliaScheduler(this) : new SpigotScheduler(this);
|
||||
MetadataFactory metadataFactory = setupMetadataFactory();
|
||||
PacketFactory packetFactory = setupPacketFactory(scheduler, metadataFactory);
|
||||
BungeeUtil bungeeUtil = new BungeeUtil(this);
|
||||
BungeeConnector bungeeConnector = new BungeeConnector(this);
|
||||
ConfigManager configManager = new ConfigManager(getDataFolder());
|
||||
ActionRegistry actionRegistry = new ActionRegistry();
|
||||
NpcRegistryImpl npcRegistry = new NpcRegistryImpl(configManager, this, packetFactory, actionRegistry);
|
||||
|
@ -119,7 +119,7 @@ public class ZNpcsPlus extends JavaPlugin {
|
|||
|
||||
log(ChatColor.WHITE+ " * Registerring components...");
|
||||
NpcTypeImpl.defineTypes(packetEvents);
|
||||
actionRegistry.registerTypes(npcRegistry, scheduler, adventure, bungeeUtil, textSerializer);
|
||||
actionRegistry.registerTypes(npcRegistry, scheduler, adventure, bungeeConnector, textSerializer);
|
||||
packetEvents.getEventManager().registerListener(new InteractionPacketListener(userManager, npcRegistry), PacketListenerPriority.MONITOR);
|
||||
new Metrics(this, PLUGIN_ID);
|
||||
pluginManager.registerEvents(new UserListener(userManager), this);
|
||||
|
|
|
@ -6,7 +6,7 @@ import lol.pyr.znpcsplus.interaction.playercommand.PlayerCommandActionType;
|
|||
import lol.pyr.znpcsplus.interaction.switchserver.SwitchServerActionType;
|
||||
import lol.pyr.znpcsplus.npc.NpcRegistryImpl;
|
||||
import lol.pyr.znpcsplus.scheduling.TaskScheduler;
|
||||
import lol.pyr.znpcsplus.util.BungeeUtil;
|
||||
import lol.pyr.znpcsplus.util.BungeeConnector;
|
||||
import lol.pyr.znpcsplus.util.StringSerializer;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
@ -23,10 +23,10 @@ public class ActionRegistry {
|
|||
public ActionRegistry() {
|
||||
}
|
||||
|
||||
public void registerTypes(NpcRegistryImpl npcRegistry, TaskScheduler taskScheduler, BukkitAudiences adventure, BungeeUtil bungeeUtil, LegacyComponentSerializer textSerializer) {
|
||||
public void registerTypes(NpcRegistryImpl npcRegistry, TaskScheduler taskScheduler, BukkitAudiences adventure, BungeeConnector bungeeConnector, LegacyComponentSerializer textSerializer) {
|
||||
register(new ConsoleCommandActionType(taskScheduler, npcRegistry));
|
||||
register(new PlayerCommandActionType(taskScheduler, npcRegistry));
|
||||
register(new SwitchServerActionType(bungeeUtil, npcRegistry));
|
||||
register(new SwitchServerActionType(bungeeConnector, npcRegistry));
|
||||
register(new MessageActionType(adventure, textSerializer, npcRegistry));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
package lol.pyr.znpcsplus.interaction.switchserver;
|
||||
|
||||
import lol.pyr.znpcsplus.interaction.InteractionAction;
|
||||
import lol.pyr.znpcsplus.util.BungeeUtil;
|
||||
import lol.pyr.znpcsplus.util.BungeeConnector;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SwitchServerAction extends InteractionAction {
|
||||
private final BungeeUtil bungeeUtil;
|
||||
private final BungeeConnector bungeeConnector;
|
||||
private final String server;
|
||||
|
||||
public SwitchServerAction(BungeeUtil bungeeUtil, String server, long delay) {
|
||||
public SwitchServerAction(BungeeConnector bungeeConnector, String server, long delay) {
|
||||
super(delay);
|
||||
this.bungeeUtil = bungeeUtil;
|
||||
this.bungeeConnector = bungeeConnector;
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Player player) {
|
||||
bungeeUtil.sendPlayerToServer(player, server);
|
||||
bungeeConnector.sendPlayer(player, server);
|
||||
}
|
||||
|
||||
public String getServer() {
|
||||
|
|
|
@ -6,7 +6,7 @@ import lol.pyr.znpcsplus.interaction.InteractionActionType;
|
|||
import lol.pyr.znpcsplus.interaction.InteractionCommandHandler;
|
||||
import lol.pyr.znpcsplus.npc.NpcEntryImpl;
|
||||
import lol.pyr.znpcsplus.npc.NpcRegistryImpl;
|
||||
import lol.pyr.znpcsplus.util.BungeeUtil;
|
||||
import lol.pyr.znpcsplus.util.BungeeConnector;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
|
@ -16,11 +16,11 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
public class SwitchServerActionType implements InteractionActionType<SwitchServerAction>, InteractionCommandHandler {
|
||||
private final BungeeUtil bungeeUtil;
|
||||
private final BungeeConnector bungeeConnector;
|
||||
private final NpcRegistryImpl npcRegistry;
|
||||
|
||||
public SwitchServerActionType(BungeeUtil bungeeUtil, NpcRegistryImpl npcRegistry) {
|
||||
this.bungeeUtil = bungeeUtil;
|
||||
public SwitchServerActionType(BungeeConnector bungeeConnector, NpcRegistryImpl npcRegistry) {
|
||||
this.bungeeConnector = bungeeConnector;
|
||||
this.npcRegistry = npcRegistry;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class SwitchServerActionType implements InteractionActionType<SwitchServe
|
|||
@Override
|
||||
public SwitchServerAction deserialize(String str) {
|
||||
String[] split = str.split(";");
|
||||
return new SwitchServerAction(bungeeUtil, new String(Base64.getDecoder().decode(split[0]), StandardCharsets.UTF_8), Long.parseLong(split[1]));
|
||||
return new SwitchServerAction(bungeeConnector, new String(Base64.getDecoder().decode(split[0]), StandardCharsets.UTF_8), Long.parseLong(split[1]));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -51,7 +51,7 @@ public class SwitchServerActionType implements InteractionActionType<SwitchServe
|
|||
NpcEntryImpl entry = context.parse(NpcEntryImpl.class);
|
||||
long cooldown = (long) (context.parse(Double.class) * 1000D);
|
||||
String server = context.dumpAllArgs();
|
||||
entry.getNpc().addAction(new SwitchServerAction(bungeeUtil, server, cooldown));
|
||||
entry.getNpc().addAction(new SwitchServerAction(bungeeConnector, server, cooldown));
|
||||
context.send(Component.text("Added a switch server action to the npc with the server " + server, NamedTextColor.GREEN));
|
||||
}
|
||||
|
||||
|
|
|
@ -7,14 +7,14 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class BungeeUtil {
|
||||
public class BungeeConnector {
|
||||
private final Plugin plugin;
|
||||
|
||||
public BungeeUtil(Plugin plugin) {
|
||||
public BungeeConnector(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void sendPlayerToServer(Player player, String server) {
|
||||
public void sendPlayer(Player player, String server) {
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(b);
|
||||
try {
|
Loading…
Reference in a new issue