diff --git a/bungee/src/main/java/com/sekwah/advancedportals/bungee/AdvancedPortalsBungeePlugin.java b/bungee/src/main/java/com/sekwah/advancedportals/bungee/AdvancedPortalsBungeePlugin.java index ebb37e07..e0a44cd2 100644 --- a/bungee/src/main/java/com/sekwah/advancedportals/bungee/AdvancedPortalsBungeePlugin.java +++ b/bungee/src/main/java/com/sekwah/advancedportals/bungee/AdvancedPortalsBungeePlugin.java @@ -10,12 +10,14 @@ public class AdvancedPortalsBungeePlugin extends Plugin { @Override public void onEnable() { - this.proxyCore = new AdvancedPortalsProxyCore(new BungeeInfoLogger(this), new BungeeProxyContainer(this)); + this.proxyCore = new AdvancedPortalsProxyCore( + new BungeeInfoLogger(this), new BungeeProxyContainer(this)); this.proxyCore.onEnable(); getProxy().registerChannel(ProxyMessages.CHANNEL_NAME); - getProxy().getPluginManager().registerListener(this, new EventListener(this, this.proxyCore)); + getProxy().getPluginManager().registerListener( + this, new EventListener(this, this.proxyCore)); } @Override diff --git a/bungee/src/main/java/com/sekwah/advancedportals/bungee/BungeeInfoLogger.java b/bungee/src/main/java/com/sekwah/advancedportals/bungee/BungeeInfoLogger.java index 58086f95..967404b4 100644 --- a/bungee/src/main/java/com/sekwah/advancedportals/bungee/BungeeInfoLogger.java +++ b/bungee/src/main/java/com/sekwah/advancedportals/bungee/BungeeInfoLogger.java @@ -1,7 +1,6 @@ package com.sekwah.advancedportals.bungee; import com.sekwah.advancedportals.core.util.InfoLogger; - import java.util.logging.Level; public class BungeeInfoLogger extends InfoLogger { diff --git a/bungee/src/main/java/com/sekwah/advancedportals/bungee/EventListener.java b/bungee/src/main/java/com/sekwah/advancedportals/bungee/EventListener.java index b8bf4ef1..cabe2c56 100644 --- a/bungee/src/main/java/com/sekwah/advancedportals/bungee/EventListener.java +++ b/bungee/src/main/java/com/sekwah/advancedportals/bungee/EventListener.java @@ -13,35 +13,40 @@ import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.event.EventHandler; public class EventListener implements Listener { - - private final AdvancedPortalsBungeePlugin plugin; private final AdvancedPortalsProxyCore proxyCore; - public EventListener(AdvancedPortalsBungeePlugin plugin, AdvancedPortalsProxyCore proxyCore) { + public EventListener(AdvancedPortalsBungeePlugin plugin, + AdvancedPortalsProxyCore proxyCore) { this.plugin = plugin; this.proxyCore = proxyCore; } @EventHandler public void onMessageReceived(PluginMessageEvent event) { - if(!event.getTag().equalsIgnoreCase(ProxyMessages.CHANNEL_NAME)) return; + if (!event.getTag().equalsIgnoreCase(ProxyMessages.CHANNEL_NAME)) + return; event.setCancelled(true); - if(!(event.getSender() instanceof Server)) return; + if (!(event.getSender() instanceof Server)) + return; - if(event.getReceiver() instanceof ProxiedPlayer player) { - this.proxyCore.incomingMessage(new BungeeProxyPlayerContainer(player), event.getData()); + if (event.getReceiver() instanceof ProxiedPlayer player) { + this.proxyCore.incomingMessage( + new BungeeProxyPlayerContainer(player), event.getData()); } } @EventHandler public void onServerConnected(ServerConnectedEvent event) { - this.proxyCore.onServerConnect(new BungeeProxyServerContainer(event.getServer()), new BungeeProxyPlayerContainer(event.getPlayer())); + this.proxyCore.onServerConnect( + new BungeeProxyServerContainer(event.getServer()), + new BungeeProxyPlayerContainer(event.getPlayer())); } @EventHandler public void onDisconnect(PlayerDisconnectEvent event) { - this.proxyCore.onPlayerDisconnect(new BungeeProxyPlayerContainer(event.getPlayer())); + this.proxyCore.onPlayerDisconnect( + new BungeeProxyPlayerContainer(event.getPlayer())); } } diff --git a/bungee/src/main/java/com/sekwah/advancedportals/bungee/connector/container/BungeeProxyContainer.java b/bungee/src/main/java/com/sekwah/advancedportals/bungee/connector/container/BungeeProxyContainer.java index a3fb6ad7..2afed451 100644 --- a/bungee/src/main/java/com/sekwah/advancedportals/bungee/connector/container/BungeeProxyContainer.java +++ b/bungee/src/main/java/com/sekwah/advancedportals/bungee/connector/container/BungeeProxyContainer.java @@ -7,7 +7,6 @@ import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerConta import net.md_5.bungee.api.chat.TextComponent; public class BungeeProxyContainer implements ProxyContainer { - private final AdvancedPortalsBungeePlugin plugin; public BungeeProxyContainer(AdvancedPortalsBungeePlugin plugin) { @@ -15,21 +14,26 @@ public class BungeeProxyContainer implements ProxyContainer { } @Override - public void invokeCommand(ProxyPlayerContainer proxyPlayer, String command) { + public void invokeCommand(ProxyPlayerContainer proxyPlayer, + String command) { // Should never not be true but just to be safe - if(proxyPlayer instanceof BungeeProxyPlayerContainer playerContainer) { - plugin.getProxy().getPluginManager().dispatchCommand(playerContainer.getPlayer(), command); + if (proxyPlayer instanceof BungeeProxyPlayerContainer playerContainer) { + plugin.getProxy().getPluginManager().dispatchCommand( + playerContainer.getPlayer(), command); } } @Override - public void transferPlayer(ProxyPlayerContainer proxyPlayer, String serverName) { + public void transferPlayer(ProxyPlayerContainer proxyPlayer, + String serverName) { // Should never not be true but just to be safe - if(proxyPlayer instanceof BungeeProxyPlayerContainer playerContainer) { + if (proxyPlayer instanceof BungeeProxyPlayerContainer playerContainer) { var serverInfo = plugin.getProxy().getServerInfo(serverName); var player = playerContainer.getPlayer(); - if(serverInfo == null) { - player.sendMessage(new TextComponent(Lang.convertColors("&cCould not find server: &e") + serverName)); + if (serverInfo == null) { + player.sendMessage(new TextComponent( + Lang.convertColors("&cCould not find server: &e") + + serverName)); return; } player.connect(serverInfo); diff --git a/bungee/src/main/java/com/sekwah/advancedportals/bungee/connector/container/BungeeProxyPlayerContainer.java b/bungee/src/main/java/com/sekwah/advancedportals/bungee/connector/container/BungeeProxyPlayerContainer.java index cead8dad..7c7ed9f7 100644 --- a/bungee/src/main/java/com/sekwah/advancedportals/bungee/connector/container/BungeeProxyPlayerContainer.java +++ b/bungee/src/main/java/com/sekwah/advancedportals/bungee/connector/container/BungeeProxyPlayerContainer.java @@ -5,7 +5,6 @@ import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerConta import net.md_5.bungee.api.connection.ProxiedPlayer; public class BungeeProxyPlayerContainer implements ProxyPlayerContainer { - private final ProxiedPlayer player; public BungeeProxyPlayerContainer(ProxiedPlayer player) { @@ -29,5 +28,4 @@ public class BungeeProxyPlayerContainer implements ProxyPlayerContainer { public void sendServerPluginMessage(byte[] data) { this.player.getServer().sendData(ProxyMessages.CHANNEL_NAME, data); } - } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/AdvancedPortalsCore.java b/core/src/main/java/com/sekwah/advancedportals/core/AdvancedPortalsCore.java index 152faa02..3e484d7a 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/AdvancedPortalsCore.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/AdvancedPortalsCore.java @@ -20,12 +20,10 @@ import com.sekwah.advancedportals.core.tags.*; import com.sekwah.advancedportals.core.util.GameScheduler; import com.sekwah.advancedportals.core.util.InfoLogger; import com.sekwah.advancedportals.core.util.Lang; - import java.io.File; import java.util.Arrays; public class AdvancedPortalsCore { - private final InfoLogger infoLogger; private final DataStorage dataStorage; @@ -74,8 +72,8 @@ public class AdvancedPortalsCore { this.infoLogger = infoLogger; int[] mcVersionTemp; - infoLogger.info("Loading Advanced Portals Core v" + BuildConstants.VERSION - + " for MC: " + mcVersion); + infoLogger.info("Loading Advanced Portals Core v" + + BuildConstants.VERSION + " for MC: " + mcVersion); try { mcVersionTemp = Arrays.stream(mcVersion.split("\\.")) .mapToInt(Integer::parseInt) @@ -121,9 +119,11 @@ public class AdvancedPortalsCore { private void registerChannels() { this.serverContainer.registerOutgoingChannel(BungeeTag.PACKET_CHANNEL); - if(this.configRepository.getEnableProxySupport()) { - this.serverContainer.registerOutgoingChannel(ProxyMessages.CHANNEL_NAME); - this.serverContainer.registerIncomingChannel(ProxyMessages.CHANNEL_NAME); + if (this.configRepository.getEnableProxySupport()) { + this.serverContainer.registerOutgoingChannel( + ProxyMessages.CHANNEL_NAME); + this.serverContainer.registerIncomingChannel( + ProxyMessages.CHANNEL_NAME); } } @@ -148,7 +148,8 @@ public class AdvancedPortalsCore { } private void registerPortalCommand(CommandRegister commandRegister) { - this.portalCommand = new CommandWithSubCommands(this, Permissions.PORTAL); + this.portalCommand = + new CommandWithSubCommands(this, Permissions.PORTAL); this.portalCommand.registerSubCommand("version", new VersionSubCommand()); diff --git a/core/src/main/java/com/sekwah/advancedportals/core/CoreListeners.java b/core/src/main/java/com/sekwah/advancedportals/core/CoreListeners.java index 9414a2fa..257df346 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/CoreListeners.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/CoreListeners.java @@ -18,7 +18,6 @@ import com.sekwah.advancedportals.core.services.PortalServices; import com.sekwah.advancedportals.core.util.GameScheduler; import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.warphandler.TriggerType; - import java.util.Objects; public class CoreListeners { @@ -44,10 +43,12 @@ public class CoreListeners { } private void setIfInPortal(PlayerContainer player) { - String inPortal = this.portalServices.inPortalRegionGetName(player.getBlockLoc()); + String inPortal = + this.portalServices.inPortalRegionGetName(player.getBlockLoc()); if (inPortal == null) { - inPortal = this.portalServices.inPortalRegionGetName(player.getBlockLoc().addY((int) player.getHeight())); + inPortal = this.portalServices.inPortalRegionGetName( + player.getBlockLoc().addY((int) player.getHeight())); } this.playerDataServices.getPlayerData(player).setInPortal(inPortal); @@ -61,7 +62,8 @@ public class CoreListeners { this.playerDataServices.playerLeave(player); } - public void incomingMessage(PlayerContainer player, String channel, byte[] message) { + public void incomingMessage(PlayerContainer player, String channel, + byte[] message) { var buffer = ByteStreams.newDataInput(message); var messageType = buffer.readUTF(); @@ -135,125 +137,126 @@ public class CoreListeners { } } return true; - } else if (itemInHandName.equals( - "\u00A78End Portal Block Placer")) { - world.setBlock(blockPos, "END_PORTAL"); - return true; - } else if (itemInHandName.equals("\u00A78Gateway Block Placer")) { - world.setBlock(blockPos, "END_GATEWAY"); - world.disableBeacon(blockPos); - return true; - } + } + else if (itemInHandName.equals("\u00A78End Portal Block Placer")) { + world.setBlock(blockPos, "END_PORTAL"); return true; } - if (portalServices.inPortalRegionProtected(blockPos)) { - if (player != null) { - player.sendMessage(Lang.getNegativePrefix() - + Lang.translate("portal.nobuild")); - } - return false; + else if (itemInHandName.equals("\u00A78Gateway Block Placer")) { + world.setBlock(blockPos, "END_GATEWAY"); + world.disableBeacon(blockPos); + return true; } return true; } - - /** - * If the block is allowed to be interacted with e.g. a lever - * @player player causing the event (or null if not a player) - * @param blockPos - * @return - */ - public boolean blockInteract(PlayerContainer player, - BlockLocation blockPos) { - return true; + if (portalServices.inPortalRegionProtected(blockPos)) { + if (player != null) { + player.sendMessage(Lang.getNegativePrefix() + + Lang.translate("portal.nobuild")); + } + return false; } + return true; +} - /** - * @param player - * @param blockLoc - * @param leftClick true = left click, false = right click - * @return if player is allowed to interact with block - */ - public boolean playerInteractWithBlock(PlayerContainer player, - String blockMaterialname, - String itemMaterialName, - String itemName, - BlockLocation blockLoc, - boolean leftClick) { - if (itemName != null - && Permissions.CREATE_PORTAL.hasPermission(player) - && itemMaterialName.equalsIgnoreCase( - this.configRepository.getSelectorMaterial()) - && (!this.configRepository.getUseOnlySpecialAxe() - || itemName.equals("\u00A7ePortal Region Selector"))) { - this.playerDataServices.playerSelectorActivate(player, blockLoc, - leftClick); - return false; - } else if (itemName != null && leftClick - && Objects.equals(itemMaterialName, "PURPLE_WOOL") - && itemName.equals("\u00A75Portal Block Placer") - && Permissions.BUILD.hasPermission(player)) { - if (!Objects.equals(blockMaterialname, "NETHER_PORTAL")) { - return false; - } - WorldContainer world = player.getWorld(); - if (world.getBlockAxis(blockLoc) == BlockAxis.X) { - world.setBlockAxis(blockLoc, BlockAxis.Z); - } else { - world.setBlockAxis(blockLoc, BlockAxis.X); - } +/** + * If the block is allowed to be interacted with e.g. a lever + * @player player causing the event (or null if not a player) + * @param blockPos + * @return + */ +public boolean blockInteract(PlayerContainer player, BlockLocation blockPos) { + return true; +} + +/** + * @param player + * @param blockLoc + * @param leftClick true = left click, false = right click + * @return if player is allowed to interact with block + */ +public boolean playerInteractWithBlock(PlayerContainer player, + String blockMaterialname, + String itemMaterialName, String itemName, + BlockLocation blockLoc, + boolean leftClick) { + if (itemName != null && Permissions.CREATE_PORTAL.hasPermission(player) + && itemMaterialName.equalsIgnoreCase( + this.configRepository.getSelectorMaterial()) + && (!this.configRepository.getUseOnlySpecialAxe() + || itemName.equals("\u00A7ePortal Region Selector"))) { + this.playerDataServices.playerSelectorActivate(player, blockLoc, + leftClick); + return false; + } else if (itemName != null && leftClick + && Objects.equals(itemMaterialName, "PURPLE_WOOL") + && itemName.equals("\u00A75Portal Block Placer") + && Permissions.BUILD.hasPermission(player)) { + if (!Objects.equals(blockMaterialname, "NETHER_PORTAL")) { return false; } - - return true; - } - - public void worldChange(PlayerContainer player) { - this.playerDataServices.setJoinCooldown(player); - this.setIfInPortal(player); - } - - public boolean preventEntityCombust(EntityContainer entity) { - return portalServices.inPortalRegion(entity.getBlockLoc(), 2); - } - - public boolean entityPortalEvent(EntityContainer entity) { - var pos = entity.getBlockLoc(); - if (entity instanceof PlayerContainer player) { - var playerData = playerDataServices.getPlayerData(player); - if (playerData.getPortalBlockCooldown()) { - return false; - } + WorldContainer world = player.getWorld(); + if (world.getBlockAxis(blockLoc) == BlockAxis.X) { + world.setBlockAxis(blockLoc, BlockAxis.Z); + } else { + world.setBlockAxis(blockLoc, BlockAxis.X); } - - return !(portalServices.inPortalRegion(pos, 1) || portalServices.inPortalRegion(pos.addY((int) entity.getHeight()), 1)); + return false; } - public boolean playerPortalEvent(PlayerContainer player, PlayerLocation toLoc) { + return true; +} +public void worldChange(PlayerContainer player) { + this.playerDataServices.setJoinCooldown(player); + this.setIfInPortal(player); +} + +public boolean preventEntityCombust(EntityContainer entity) { + return portalServices.inPortalRegion(entity.getBlockLoc(), 2); +} + +public boolean entityPortalEvent(EntityContainer entity) { + var pos = entity.getBlockLoc(); + if (entity instanceof PlayerContainer player) { var playerData = playerDataServices.getPlayerData(player); - if (playerData.getPortalBlockCooldown()) { return false; } - - var portalResult = this.portalServices.checkPortalActivation(player, toLoc, TriggerType.PORTAL); - - if(portalResult != PortalServices.PortalActivationResult.NOT_IN_PORTAL) { - return false; - } - - // Extra checks to prevent the player from being teleported by touching a portal but not having their body fully in the portal - var pos = player.getBlockLoc(); - - var feetInPortal = portalServices.inPortalRegion(pos, 1); - var headInPortal = portalServices.inPortalRegion( - pos.addY((int) player.getHeight()), 1); - - return !(feetInPortal || headInPortal); } - public boolean physicsEvent(BlockLocation blockLocation, String string) { - return !configRepository.getDisablePhysicsEvents() - || !portalServices.inPortalRegionProtected(blockLocation); - } + return !(portalServices.inPortalRegion(pos, 1) + || portalServices.inPortalRegion( + pos.addY((int) entity.getHeight()), 1)); +} + +public boolean playerPortalEvent(PlayerContainer player, PlayerLocation toLoc) { + var playerData = playerDataServices.getPlayerData(player); + + if (playerData.getPortalBlockCooldown()) { + return false; + } + + var portalResult = this.portalServices.checkPortalActivation( + player, toLoc, TriggerType.PORTAL); + + if (portalResult != PortalServices.PortalActivationResult.NOT_IN_PORTAL) { + return false; + } + + // Extra checks to prevent the player from being teleported by touching a + // portal but not having their body fully in the portal + var pos = player.getBlockLoc(); + + var feetInPortal = portalServices.inPortalRegion(pos, 1); + var headInPortal = + portalServices.inPortalRegion(pos.addY((int) player.getHeight()), 1); + + return !(feetInPortal || headInPortal); +} + +public boolean physicsEvent(BlockLocation blockLocation, String string) { + return !configRepository.getDisablePhysicsEvents() + || !portalServices.inPortalRegionProtected(blockLocation); +} } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/ProxyMessages.java b/core/src/main/java/com/sekwah/advancedportals/core/ProxyMessages.java index b7720b57..715d2aeb 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/ProxyMessages.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/ProxyMessages.java @@ -1,10 +1,10 @@ package com.sekwah.advancedportals.core; /** - * messages going to the proxy will start with proxy: messages going to the server will start with server: + * messages going to the proxy will start with proxy: messages going to the + * server will start with server: */ public class ProxyMessages { - /** * Could split by channel messages we will handle it ourselves */ diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/CommandTemplate.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/CommandTemplate.java index a64215a6..3ef2ba8b 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/CommandTemplate.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/CommandTemplate.java @@ -1,7 +1,6 @@ package com.sekwah.advancedportals.core.commands; import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; - import java.util.List; /** diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java index 614726d2..8686f2a0 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java @@ -5,7 +5,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain import com.sekwah.advancedportals.core.permissions.PermissionBuilder; import com.sekwah.advancedportals.core.registry.SubCommandRegistry; import com.sekwah.advancedportals.core.util.Lang; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -18,7 +17,8 @@ public class CommandWithSubCommands implements CommandTemplate { private final AdvancedPortalsCore pluginCore; private final PermissionBuilder permission; - public CommandWithSubCommands(AdvancedPortalsCore advancedPortalsCore, PermissionBuilder permission) { + public CommandWithSubCommands(AdvancedPortalsCore advancedPortalsCore, + PermissionBuilder permission) { this.subCommandRegistry = new SubCommandRegistry(); this.pluginCore = advancedPortalsCore; this.permission = permission; @@ -57,8 +57,9 @@ public class CommandWithSubCommands implements CommandTemplate { @Override public void onCommand(CommandSenderContainer sender, String commandExecuted, String[] args) { - if(!permission.hasPermission(sender)) { - sender.sendMessage(Lang.getNegativePrefix() + Lang.translate("command.nopermission")); + if (!permission.hasPermission(sender)) { + sender.sendMessage(Lang.getNegativePrefix() + + Lang.translate("command.nopermission")); return; } if (args.length > 0) { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/SubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/SubCommand.java index e30c8a77..233bb26f 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/SubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/SubCommand.java @@ -1,7 +1,6 @@ package com.sekwah.advancedportals.core.commands; import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; - import java.util.List; public interface SubCommand { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/common/CreateTaggedSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/common/CreateTaggedSubCommand.java index f79a2227..2c49b69b 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/common/CreateTaggedSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/common/CreateTaggedSubCommand.java @@ -5,7 +5,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain import com.sekwah.advancedportals.core.serializeddata.DataTag; import com.sekwah.advancedportals.core.util.TagReader; import com.sekwah.advancedportals.core.warphandler.Tag; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/CreateDestiSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/CreateDestiSubCommand.java index b84fabc4..2e126213 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/CreateDestiSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/CreateDestiSubCommand.java @@ -12,7 +12,6 @@ import com.sekwah.advancedportals.core.services.DestinationServices; import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.TagReader; import com.sekwah.advancedportals.core.warphandler.Tag; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/ListDestiSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/ListDestiSubCommand.java index ae7a340a..175adead 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/ListDestiSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/ListDestiSubCommand.java @@ -6,7 +6,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.services.DestinationServices; import com.sekwah.advancedportals.core.util.Lang; - import java.util.List; import java.util.stream.Collectors; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/RemoveDestiSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/RemoveDestiSubCommand.java index 124f13b2..57c46011 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/RemoveDestiSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/RemoveDestiSubCommand.java @@ -6,7 +6,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.services.DestinationServices; import com.sekwah.advancedportals.core.util.Lang; - import java.util.Collections; import java.util.List; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/ShowDestiSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/ShowDestiSubCommand.java index 8a17fff6..0ddffc39 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/ShowDestiSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/ShowDestiSubCommand.java @@ -14,7 +14,6 @@ import com.sekwah.advancedportals.core.services.PlayerDataServices; import com.sekwah.advancedportals.core.util.Debug; import com.sekwah.advancedportals.core.util.GameScheduler; import com.sekwah.advancedportals.core.util.Lang; - import java.awt.*; import java.util.List; import java.util.Objects; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/TeleportDestiSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/TeleportDestiSubCommand.java index 246288f8..3c6b4e89 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/TeleportDestiSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/desti/TeleportDestiSubCommand.java @@ -6,7 +6,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.services.DestinationServices; import com.sekwah.advancedportals.core.util.Lang; - import java.util.Collections; import java.util.List; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/CreatePortalSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/CreatePortalSubCommand.java index 95d1c306..8125020b 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/CreatePortalSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/CreatePortalSubCommand.java @@ -15,7 +15,6 @@ import com.sekwah.advancedportals.core.tags.TriggerBlockTag; import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.TagReader; import com.sekwah.advancedportals.core.warphandler.Tag; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/DisableBeaconSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/DisableBeaconSubCommand.java index e9408e04..8143db13 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/DisableBeaconSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/DisableBeaconSubCommand.java @@ -6,7 +6,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.services.PortalServices; import com.sekwah.advancedportals.core.util.Lang; - import java.util.List; public class DisableBeaconSubCommand implements SubCommand { @@ -18,17 +17,22 @@ public class DisableBeaconSubCommand implements SubCommand { if (args.length > 1) { var portalName = args[1]; var portal = portalServices.getPortal(portalName); - if(portal == null) { - sender.sendMessage(Lang.getNegativePrefix() - + Lang.translateInsertVariables("command.portal.disablebeacon.notfound", portalName)); + if (portal == null) { + sender.sendMessage( + Lang.getNegativePrefix() + + Lang.translateInsertVariables( + "command.portal.disablebeacon.notfound", portalName)); return; } - sender.sendMessage(Lang.getPositivePrefix() - + Lang.translateInsertVariables("command.portal.disablebeacon.complete", portalName)); + sender.sendMessage( + Lang.getPositivePrefix() + + Lang.translateInsertVariables( + "command.portal.disablebeacon.complete", portalName)); sender.getPlayerContainer().getWorld().disableBeacon(portal); } else { - sender.sendMessage(Lang.getNegativePrefix() - + Lang.translate("command.portal.disablebeacon.noname")); + sender.sendMessage( + Lang.getNegativePrefix() + + Lang.translate("command.portal.disablebeacon.noname")); } } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/EndGatewayBlockSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/EndGatewayBlockSubCommand.java index e2931328..0000e305 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/EndGatewayBlockSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/EndGatewayBlockSubCommand.java @@ -7,7 +7,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.util.Lang; - import java.util.List; public class EndGatewayBlockSubCommand implements SubCommand { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/EndPortalBlockSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/EndPortalBlockSubCommand.java index 63ad0107..fad15e0f 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/EndPortalBlockSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/EndPortalBlockSubCommand.java @@ -7,7 +7,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.util.Lang; - import java.util.List; public class EndPortalBlockSubCommand implements SubCommand { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/InfoPortalSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/InfoPortalSubCommand.java index fbd8b4bb..6d6fb1d8 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/InfoPortalSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/InfoPortalSubCommand.java @@ -7,7 +7,6 @@ import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.services.PortalServices; import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.TagReader; - import java.util.List; public class InfoPortalSubCommand implements SubCommand { @@ -19,17 +18,20 @@ public class InfoPortalSubCommand implements SubCommand { if (args.length > 1) { var portalName = args[1]; var portal = portalServices.getPortal(portalName); - if(portal == null) { - sender.sendMessage(Lang.getNegativePrefix() - + Lang.translateInsertVariables("command.portal.info.notfound", portalName)); + if (portal == null) { + sender.sendMessage( + Lang.getNegativePrefix() + + Lang.translateInsertVariables( + "command.portal.info.notfound", portalName)); return; } sender.sendMessage(Lang.getPositivePrefix() - + Lang.translateInsertVariables("command.portal.info.complete", portalName)); + + Lang.translateInsertVariables( + "command.portal.info.complete", portalName)); TagReader.printArgs(sender, portal.getArgs()); } else { sender.sendMessage(Lang.getNegativePrefix() - + Lang.translate("command.portal.info.noname")); + + Lang.translate("command.portal.info.noname")); } } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/LangUpdateSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/LangUpdateSubCommand.java index b17599eb..868d4c44 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/LangUpdateSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/LangUpdateSubCommand.java @@ -7,7 +7,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.repository.ConfigRepository; import com.sekwah.advancedportals.core.util.Lang; - import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.InputStream; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/ListPortalsSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/ListPortalsSubCommand.java index 54b0a4da..aaf4ae50 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/ListPortalsSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/ListPortalsSubCommand.java @@ -6,7 +6,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.services.PortalServices; import com.sekwah.advancedportals.core.util.Lang; - import java.util.List; import java.util.stream.Collectors; @@ -17,8 +16,8 @@ public class ListPortalsSubCommand implements SubCommand { @Override public void onCommand(CommandSenderContainer sender, String[] args) { sender.sendMessage( - Lang.getPositivePrefix() - + Lang.translate("command.portal.list") + " " + Lang.getPositivePrefix() + Lang.translate("command.portal.list") + + " " + portalServices.getPortalNames().stream().sorted().collect( Collectors.joining(", "))); } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/PortalBlockSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/PortalBlockSubCommand.java index 474c4af1..b4f91e4f 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/PortalBlockSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/PortalBlockSubCommand.java @@ -7,7 +7,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.util.Lang; - import java.util.List; public class PortalBlockSubCommand implements SubCommand { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/ReloadPortalSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/ReloadPortalSubCommand.java index a52b46ce..c11fa125 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/ReloadPortalSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/ReloadPortalSubCommand.java @@ -9,7 +9,6 @@ import com.sekwah.advancedportals.core.repository.ConfigRepository; import com.sekwah.advancedportals.core.services.DestinationServices; import com.sekwah.advancedportals.core.services.PortalServices; import com.sekwah.advancedportals.core.util.Lang; - import java.util.List; public class ReloadPortalSubCommand implements SubCommand { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/RemovePortalSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/RemovePortalSubCommand.java index 83c38c0e..6cc87eae 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/RemovePortalSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/RemovePortalSubCommand.java @@ -6,7 +6,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.services.PortalServices; import com.sekwah.advancedportals.core.util.Lang; - import java.util.List; public class RemovePortalSubCommand implements SubCommand { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/SelectorSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/SelectorSubCommand.java index e9b6a145..cbac4db5 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/SelectorSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/SelectorSubCommand.java @@ -8,7 +8,6 @@ import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.repository.ConfigRepository; import com.sekwah.advancedportals.core.util.Lang; - import java.util.List; public class SelectorSubCommand implements SubCommand { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/ShowPortalSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/ShowPortalSubCommand.java index 5408f440..379d391b 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/ShowPortalSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/ShowPortalSubCommand.java @@ -16,7 +16,6 @@ import com.sekwah.advancedportals.core.tags.NameTag; import com.sekwah.advancedportals.core.util.Debug; import com.sekwah.advancedportals.core.util.GameScheduler; import com.sekwah.advancedportals.core.util.Lang; - import java.awt.*; import java.util.List; import java.util.Objects; @@ -120,12 +119,15 @@ public class ShowPortalSubCommand player.getWorldName())) { int widthX = Math.abs(tempData.getPos1().getPosX() - tempData.getPos2().getPosX()); - int widthY = Math.abs(tempData.getPos1().getPosY() - tempData.getPos2().getPosY()); - int widthZ = Math.abs(tempData.getPos1().getPosZ() - tempData.getPos2().getPosZ()); + int widthY = Math.abs(tempData.getPos1().getPosY() + - tempData.getPos2().getPosY()); + int widthZ = Math.abs(tempData.getPos1().getPosZ() + - tempData.getPos2().getPosZ()); int totalBlocks = widthX * widthY * widthZ; if (totalBlocks <= config.getMaxTriggerVisualisationSize()) - debugVisuals(player, tempData.getPos1(), tempData.getPos2(), - SELECTION_COLOR, SHOW_TICKS); + debugVisuals(player, tempData.getPos1(), + tempData.getPos2(), SELECTION_COLOR, + SHOW_TICKS); } if (tempData.getPos1() != null diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/VersionSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/VersionSubCommand.java index 3f07e49e..71ad06a9 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/VersionSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/portal/VersionSubCommand.java @@ -4,14 +4,12 @@ import com.sekwah.advancedportals.core.BuildConstants; import com.sekwah.advancedportals.core.commands.SubCommand; import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; import com.sekwah.advancedportals.core.util.Lang; - import java.util.List; public class VersionSubCommand implements SubCommand { @Override public void onCommand(CommandSenderContainer sender, String[] args) { - sender.sendMessage(Lang.getPositivePrefix() - + " Advanced Portals v" + sender.sendMessage(Lang.getPositivePrefix() + " Advanced Portals v" + BuildConstants.VERSION); } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/connector/containers/GameMode.java b/core/src/main/java/com/sekwah/advancedportals/core/connector/containers/GameMode.java index 54c6b2cc..1388766e 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/connector/containers/GameMode.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/connector/containers/GameMode.java @@ -1,8 +1,3 @@ package com.sekwah.advancedportals.core.connector.containers; -public enum GameMode { - SURVIVAL, - CREATIVE, - ADVENTURE, - SPECTATOR -} +public enum GameMode { SURVIVAL, CREATIVE, ADVENTURE, SPECTATOR } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/connector/containers/PlayerContainer.java b/core/src/main/java/com/sekwah/advancedportals/core/connector/containers/PlayerContainer.java index f5170c64..d2bc2545 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/connector/containers/PlayerContainer.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/connector/containers/PlayerContainer.java @@ -1,7 +1,6 @@ package com.sekwah.advancedportals.core.connector.containers; import com.sekwah.advancedportals.core.serializeddata.BlockLocation; - import java.util.UUID; /** diff --git a/core/src/main/java/com/sekwah/advancedportals/core/connector/containers/ServerContainer.java b/core/src/main/java/com/sekwah/advancedportals/core/connector/containers/ServerContainer.java index 18787f42..97aacbd0 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/connector/containers/ServerContainer.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/connector/containers/ServerContainer.java @@ -1,7 +1,6 @@ package com.sekwah.advancedportals.core.connector.containers; import com.sekwah.advancedportals.core.tags.CommandTag; - import java.util.List; import java.util.UUID; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/destination/Destination.java b/core/src/main/java/com/sekwah/advancedportals/core/destination/Destination.java index b9f625e1..c09cac30 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/destination/Destination.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/destination/Destination.java @@ -9,7 +9,6 @@ import com.sekwah.advancedportals.core.serializeddata.PlayerLocation; import com.sekwah.advancedportals.core.warphandler.ActivationData; import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.TriggerType; - import java.util.*; /** @@ -87,7 +86,7 @@ public class Destination implements TagTarget { public boolean activate(PlayerContainer player) { ActivationData data = new ActivationData(TriggerType.MANUAL); - if(this.portalActivate(player, data)) { + if (this.portalActivate(player, data)) { this.postActivate(player, data); return true; } @@ -95,7 +94,7 @@ public class Destination implements TagTarget { } public boolean portalActivate(PlayerContainer player, ActivationData data) { - if(!isSorted) { + if (!isSorted) { updateDestiTagList(); } DataTag[] destiTags = new DataTag[args.size()]; @@ -104,16 +103,17 @@ public class Destination implements TagTarget { destiTags[i++] = new DataTag(entry.getKey(), entry.getValue()); } for (DataTag destiTag : destiTags) { - Tag.Activation activationHandler = - tagRegistry.getActivationHandler(destiTag.NAME, Tag.TagType.DESTINATION); - if (activationHandler != null && !activationHandler.preActivated( + Tag.Activation activationHandler = tagRegistry.getActivationHandler( + destiTag.NAME, Tag.TagType.DESTINATION); + if (activationHandler != null + && !activationHandler.preActivated( this, player, data, this.getArgValues(destiTag.NAME))) { return false; } } for (DataTag destiTag : destiTags) { - Tag.Activation activationHandler = - tagRegistry.getActivationHandler(destiTag.NAME, Tag.TagType.DESTINATION); + Tag.Activation activationHandler = tagRegistry.getActivationHandler( + destiTag.NAME, Tag.TagType.DESTINATION); if (activationHandler != null) { activationHandler.activated(this, player, data, this.getArgValues(destiTag.NAME)); @@ -129,8 +129,8 @@ public class Destination implements TagTarget { destiTags[i++] = new DataTag(entry.getKey(), entry.getValue()); } for (DataTag destiTag : destiTags) { - Tag.Activation activationHandler = - tagRegistry.getActivationHandler(destiTag.NAME, Tag.TagType.DESTINATION); + Tag.Activation activationHandler = tagRegistry.getActivationHandler( + destiTag.NAME, Tag.TagType.DESTINATION); if (activationHandler != null) { activationHandler.postActivated( this, player, data, this.getArgValues(destiTag.NAME)); diff --git a/core/src/main/java/com/sekwah/advancedportals/core/module/AdvancedPortalsModule.java b/core/src/main/java/com/sekwah/advancedportals/core/module/AdvancedPortalsModule.java index 46d6829f..6883b6e1 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/module/AdvancedPortalsModule.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/module/AdvancedPortalsModule.java @@ -20,10 +20,9 @@ import com.sekwah.advancedportals.core.serializeddata.DataStorage; import com.sekwah.advancedportals.core.serializeddata.config.Config; import com.sekwah.advancedportals.core.serializeddata.config.ConfigProvider; import com.sekwah.advancedportals.core.util.InfoLogger; - -import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.List; +import javax.annotation.Nonnull; public class AdvancedPortalsModule extends AbstractModule { private Injector injector; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/network/ProxyCommandPacket.java b/core/src/main/java/com/sekwah/advancedportals/core/network/ProxyCommandPacket.java index 54dc171c..44682adf 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/network/ProxyCommandPacket.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/network/ProxyCommandPacket.java @@ -6,7 +6,6 @@ import com.google.common.io.ByteStreams; import com.sekwah.advancedportals.core.ProxyMessages; public class ProxyCommandPacket implements Packet { - private final String command; public ProxyCommandPacket(String command) { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/network/ProxyTransferDestiPacket.java b/core/src/main/java/com/sekwah/advancedportals/core/network/ProxyTransferDestiPacket.java index dc0c8224..e24826b2 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/network/ProxyTransferDestiPacket.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/network/ProxyTransferDestiPacket.java @@ -6,7 +6,6 @@ import com.google.common.io.ByteStreams; import com.sekwah.advancedportals.core.ProxyMessages; public class ProxyTransferDestiPacket implements Packet { - private final String serverName; private final String destination; @@ -21,7 +20,6 @@ public class ProxyTransferDestiPacket implements Packet { buffer.writeUTF(this.serverName); buffer.writeUTF(this.destination); return buffer.toByteArray(); - } public static ProxyTransferDestiPacket decode(ByteArrayDataInput buffer) { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/network/ProxyTransferPacket.java b/core/src/main/java/com/sekwah/advancedportals/core/network/ProxyTransferPacket.java index 435f4789..216f36f0 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/network/ProxyTransferPacket.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/network/ProxyTransferPacket.java @@ -6,7 +6,6 @@ import com.google.common.io.ByteStreams; import com.sekwah.advancedportals.core.ProxyMessages; public class ProxyTransferPacket implements Packet { - private final String serverName; public ProxyTransferPacket(String serverName) { @@ -18,7 +17,6 @@ public class ProxyTransferPacket implements Packet { buffer.writeUTF(ProxyMessages.PROXY_TRANSFER); buffer.writeUTF(this.serverName); return buffer.toByteArray(); - } public static ProxyTransferPacket decode(ByteArrayDataInput buffer) { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/network/ServerDestiPacket.java b/core/src/main/java/com/sekwah/advancedportals/core/network/ServerDestiPacket.java index d390f687..33fb9201 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/network/ServerDestiPacket.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/network/ServerDestiPacket.java @@ -6,7 +6,6 @@ import com.google.common.io.ByteStreams; import com.sekwah.advancedportals.core.ProxyMessages; public class ServerDestiPacket implements Packet { - private final String destination; public ServerDestiPacket(String destination) { @@ -18,7 +17,6 @@ public class ServerDestiPacket implements Packet { buffer.writeUTF(ProxyMessages.SERVER_DESTI); buffer.writeUTF(this.destination); return buffer.toByteArray(); - } public static ServerDestiPacket decode(ByteArrayDataInput buffer) { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/permissions/PermissionBuilder.java b/core/src/main/java/com/sekwah/advancedportals/core/permissions/PermissionBuilder.java index cd0aeea2..4a70a3d8 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/permissions/PermissionBuilder.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/permissions/PermissionBuilder.java @@ -2,7 +2,6 @@ package com.sekwah.advancedportals.core.permissions; import com.google.common.collect.ImmutableList; import com.sekwah.advancedportals.core.connector.containers.HasPermission; - import java.util.ArrayList; import java.util.List; @@ -31,13 +30,15 @@ public class PermissionBuilder { this.permissionDefault = parent.permissionDefault; } - PermissionBuilder(String permissionTag, PermissionBuilder parent, PermissionDefault permissionDefault) { + PermissionBuilder(String permissionTag, PermissionBuilder parent, + PermissionDefault permissionDefault) { this.permissionTag = permissionTag; this.parent = parent; this.permissionDefault = permissionDefault; } - PermissionBuilder(String permissionTag, PermissionDefault permissionDefault) { + PermissionBuilder(String permissionTag, + PermissionDefault permissionDefault) { this.permissionTag = permissionTag; this.parent = null; this.permissionDefault = permissionDefault; @@ -54,8 +55,10 @@ public class PermissionBuilder { return child; } - public PermissionBuilder createChild(String permissionTag, PermissionDefault permissionDefault) { - var child = new PermissionBuilder(permissionTag, this, permissionDefault); + public PermissionBuilder createChild(String permissionTag, + PermissionDefault permissionDefault) { + var child = + new PermissionBuilder(permissionTag, this, permissionDefault); children.add(child); return child; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/permissions/Permissions.java b/core/src/main/java/com/sekwah/advancedportals/core/permissions/Permissions.java index cc1b9a99..53cd2b5f 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/permissions/Permissions.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/permissions/Permissions.java @@ -1,12 +1,12 @@ package com.sekwah.advancedportals.core.permissions; public class Permissions { - /** * If true then a permission manager is being used and don't check for op * for platforms like spigot this will always be true. *

- * This is to allow for negative permissions where a value may be defaulted to true. + * This is to allow for negative permissions where a value may be defaulted + * to true. */ public static boolean hasPermissionManager = false; @@ -14,95 +14,116 @@ public class Permissions { new PermissionBuilder("advancedportals").doNotExport(); public static final PermissionBuilder BUILD = - ROOT.createChild("build", PermissionBuilder.PermissionDefault.OP).description("Allows you to build in the portal regions"); - + ROOT.createChild("build", PermissionBuilder.PermissionDefault.OP) + .description("Allows you to build in the portal regions"); public static final PermissionBuilder DESTI = - ROOT.createChild("desti", PermissionBuilder.PermissionDefault.TRUE).description("Allows you to use the destination command"); + ROOT.createChild("desti", PermissionBuilder.PermissionDefault.TRUE) + .description("Allows you to use the destination command"); public static final PermissionBuilder CREATE_DESTI = - DESTI.createChild("create", PermissionBuilder.PermissionDefault.OP).description("Allows you to create destinations"); + DESTI.createChild("create", PermissionBuilder.PermissionDefault.OP) + .description("Allows you to create destinations"); public static final PermissionBuilder TELEPORT_DESTI = - DESTI.createChild("teleport", PermissionBuilder.PermissionDefault.OP).description("Allows you to teleport to destinations"); + DESTI.createChild("teleport", PermissionBuilder.PermissionDefault.OP) + .description("Allows you to teleport to destinations"); public static final PermissionBuilder REMOVE_DESTI = - DESTI.createChild("remove", PermissionBuilder.PermissionDefault.OP).description("Allows you to remove destinations"); + DESTI.createChild("remove", PermissionBuilder.PermissionDefault.OP) + .description("Allows you to remove destinations"); public static final PermissionBuilder LIST_DESTI = - DESTI.createChild("list", PermissionBuilder.PermissionDefault.OP).description("Allows you to list all destinations"); + DESTI.createChild("list", PermissionBuilder.PermissionDefault.OP) + .description("Allows you to list all destinations"); public static final PermissionBuilder SHOW_DESTI = - DESTI.createChild("show", PermissionBuilder.PermissionDefault.OP).description("Allows you to visualise the destination locations"); + DESTI.createChild("show", PermissionBuilder.PermissionDefault.OP) + .description("Allows you to visualise the destination locations"); public static final PermissionBuilder PORTAL = - ROOT.createChild("portal", PermissionBuilder.PermissionDefault.TRUE).description("Allows you to use the portal command"); + ROOT.createChild("portal", PermissionBuilder.PermissionDefault.TRUE) + .description("Allows you to use the portal command"); public static final PermissionBuilder CREATE_PORTAL = - PORTAL.createChild("create", PermissionBuilder.PermissionDefault.OP).description("Allows you to create portals"); + PORTAL.createChild("create", PermissionBuilder.PermissionDefault.OP) + .description("Allows you to create portals"); public static final PermissionBuilder SELECTOR = - PORTAL.createChild("selector", PermissionBuilder.PermissionDefault.OP).description("Allows you to give yourself a portal selector"); + PORTAL.createChild("selector", PermissionBuilder.PermissionDefault.OP) + .description("Allows you to give yourself a portal selector"); public static final PermissionBuilder REMOVE_PORTAL = - PORTAL.createChild("remove", PermissionBuilder.PermissionDefault.OP).description("Allows you to remove portals"); + PORTAL.createChild("remove", PermissionBuilder.PermissionDefault.OP) + .description("Allows you to remove portals"); public static final PermissionBuilder LIST_PORTAL = - PORTAL.createChild("list", PermissionBuilder.PermissionDefault.OP).description("Allows you to list all portals"); + PORTAL.createChild("list", PermissionBuilder.PermissionDefault.OP) + .description("Allows you to list all portals"); - public static final PermissionBuilder LANG_UPDATE = - PORTAL.createChild("lang_update", PermissionBuilder.PermissionDefault.OP); + public static final PermissionBuilder LANG_UPDATE = PORTAL.createChild( + "lang_update", PermissionBuilder.PermissionDefault.OP); public static final PermissionBuilder RELOAD = - PORTAL.createChild("reload", PermissionBuilder.PermissionDefault.OP); + PORTAL.createChild("reload", PermissionBuilder.PermissionDefault.OP); - public static final PermissionBuilder DISABLE_BEACON = - PORTAL.createChild("disable_beacon", PermissionBuilder.PermissionDefault.OP); + public static final PermissionBuilder DISABLE_BEACON = PORTAL.createChild( + "disable_beacon", PermissionBuilder.PermissionDefault.OP); public static final PermissionBuilder IMPORT = - PORTAL.createChild("import", PermissionBuilder.PermissionDefault.OP); + PORTAL.createChild("import", PermissionBuilder.PermissionDefault.OP); public static final PermissionBuilder SHOW_PORTAL = - PORTAL.createChild("show", PermissionBuilder.PermissionDefault.OP).description("Allows you to view the portal regions"); + PORTAL.createChild("show", PermissionBuilder.PermissionDefault.OP) + .description("Allows you to view the portal regions"); private static final PermissionBuilder CREATE_COMMAND_LEVEL = - CREATE_PORTAL.createChild("command_level").doNotExport(); + CREATE_PORTAL.createChild("command_level").doNotExport(); public static final PermissionBuilder CREATE_COMMAND_OP = - CREATE_COMMAND_LEVEL.createChild("op").description("Allows you to increase the users level temporarily to op"); + CREATE_COMMAND_LEVEL.createChild("op").description( + "Allows you to increase the users level temporarily to op"); public static final PermissionBuilder CREATE_COMMAND_CONSOLE = - CREATE_COMMAND_LEVEL.createChild("console").description("Allows you to create portals which execute console commands"); + CREATE_COMMAND_LEVEL.createChild("console").description( + "Allows you to create portals which execute console commands"); public static final PermissionBuilder CREATE_COMMAND_PERMS = - CREATE_COMMAND_LEVEL.createChild("perms_wildcard").description("Allows you to increase the users level temporarily to have all perms"); + CREATE_COMMAND_LEVEL.createChild("perms_wildcard") + .description("Allows you to increase the users level temporarily " + + "to have all perms"); public static final PermissionBuilder PORTAL_INFO = - PORTAL.createChild("info", PermissionBuilder.PermissionDefault.OP).description("Allows you to view portal information"); + PORTAL.createChild("info", PermissionBuilder.PermissionDefault.OP) + .description("Allows you to view portal information"); static { - // These are to add children which will not be used directly e.g. advancedportals.* - ROOT.createChild("*", PermissionBuilder.PermissionDefault.OP).description("Gives access to all portal commands") - .addGrantChild(CREATE_PORTAL) - .addGrantChild(CREATE_DESTI) - .addGrantChild(DESTI) - .addGrantChild(PORTAL) - .addGrantChild(TELEPORT_DESTI) - .addGrantChild(REMOVE_DESTI) - .addGrantChild(LIST_DESTI) - .addGrantChild(SHOW_DESTI) - .addGrantChild(SELECTOR) - .addGrantChild(REMOVE_PORTAL) - .addGrantChild(LIST_PORTAL) - .addGrantChild(LANG_UPDATE) - .addGrantChild(RELOAD) - .addGrantChild(DISABLE_BEACON) - .addGrantChild(IMPORT) - .addGrantChild(SHOW_PORTAL) - .addGrantChild(PORTAL_INFO) - .addGrantChild(BUILD); + // These are to add children which will not be used directly e.g. + // advancedportals.* + ROOT.createChild("*", PermissionBuilder.PermissionDefault.OP) + .description("Gives access to all portal commands") + .addGrantChild(CREATE_PORTAL) + .addGrantChild(CREATE_DESTI) + .addGrantChild(DESTI) + .addGrantChild(PORTAL) + .addGrantChild(TELEPORT_DESTI) + .addGrantChild(REMOVE_DESTI) + .addGrantChild(LIST_DESTI) + .addGrantChild(SHOW_DESTI) + .addGrantChild(SELECTOR) + .addGrantChild(REMOVE_PORTAL) + .addGrantChild(LIST_PORTAL) + .addGrantChild(LANG_UPDATE) + .addGrantChild(RELOAD) + .addGrantChild(DISABLE_BEACON) + .addGrantChild(IMPORT) + .addGrantChild(SHOW_PORTAL) + .addGrantChild(PORTAL_INFO) + .addGrantChild(BUILD); - CREATE_COMMAND_LEVEL.createChild("*", PermissionBuilder.PermissionDefault.OP).description("Gives access to all command level raisers") - .addGrantChild(CREATE_COMMAND_OP) - .addGrantChild(CREATE_COMMAND_CONSOLE) - .addGrantChild(CREATE_COMMAND_PERMS); + CREATE_COMMAND_LEVEL + .createChild("*", PermissionBuilder.PermissionDefault.OP) + .description("Gives access to all command level raisers") + .addGrantChild(CREATE_COMMAND_OP) + .addGrantChild(CREATE_COMMAND_CONSOLE) + .addGrantChild(CREATE_COMMAND_PERMS); } } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/portal/AdvancedPortal.java b/core/src/main/java/com/sekwah/advancedportals/core/portal/AdvancedPortal.java index 035dbaba..98b948a5 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/portal/AdvancedPortal.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/portal/AdvancedPortal.java @@ -14,7 +14,6 @@ import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.warphandler.ActivationData; import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.TriggerType; - import java.util.*; /** @@ -137,8 +136,9 @@ public class AdvancedPortal implements TagTarget { * @param triggerType The type of trigger that activated the portal * @return Whether the portal was successfully activated */ - public ActivationResult activate(PlayerContainer player, TriggerType triggerType) { - if(!isSorted) { + public ActivationResult activate(PlayerContainer player, + TriggerType triggerType) { + if (!isSorted) { updatePortalTagList(); } @@ -162,14 +162,17 @@ public class AdvancedPortal implements TagTarget { ActivationData data = new ActivationData(triggerType); for (DataTag portalTag : this.portalTags) { - Tag.Activation activationHandler = - tagRegistry.getActivationHandler(portalTag.NAME, Tag.TagType.PORTAL); + Tag.Activation activationHandler = tagRegistry.getActivationHandler( + portalTag.NAME, Tag.TagType.PORTAL); if (activationHandler != null) { var preActivated = activationHandler.preActivated( - this, player, data, this.getArgValues(portalTag.NAME)); + this, player, data, this.getArgValues(portalTag.NAME)); - if(!preActivated) { - if(activationHandler instanceof Tag.DenyBehavior denyBehavior && denyBehavior.getDenyBehavior() == Tag.DenyBehavior.Behaviour.SILENT) { + if (!preActivated) { + if (activationHandler + instanceof Tag.DenyBehavior denyBehavior + && denyBehavior.getDenyBehavior() + == Tag.DenyBehavior.Behaviour.SILENT) { return ActivationResult.FAILED_DO_NOTHING; } return ActivationResult.FAILED_DO_KNOCKBACK; @@ -177,8 +180,8 @@ public class AdvancedPortal implements TagTarget { } } for (DataTag portalTag : this.portalTags) { - Tag.Activation activationHandler = - tagRegistry.getActivationHandler(portalTag.NAME, Tag.TagType.PORTAL); + Tag.Activation activationHandler = tagRegistry.getActivationHandler( + portalTag.NAME, Tag.TagType.PORTAL); if (activationHandler != null && !activationHandler.activated( this, player, data, this.getArgValues(portalTag.NAME))) { @@ -186,8 +189,8 @@ public class AdvancedPortal implements TagTarget { } } for (DataTag portalTag : this.portalTags) { - Tag.Activation activationHandler = - tagRegistry.getActivationHandler(portalTag.NAME, Tag.TagType.PORTAL); + Tag.Activation activationHandler = tagRegistry.getActivationHandler( + portalTag.NAME, Tag.TagType.PORTAL); if (activationHandler != null) { activationHandler.postActivated( this, player, data, this.getArgValues(portalTag.NAME)); diff --git a/core/src/main/java/com/sekwah/advancedportals/core/registry/SubCommandRegistry.java b/core/src/main/java/com/sekwah/advancedportals/core/registry/SubCommandRegistry.java index 3cd5b180..9ac4f8e6 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/registry/SubCommandRegistry.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/registry/SubCommandRegistry.java @@ -3,7 +3,6 @@ package com.sekwah.advancedportals.core.registry; import com.google.inject.Inject; import com.sekwah.advancedportals.core.commands.SubCommand; import com.sekwah.advancedportals.core.util.InfoLogger; - import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/registry/TagRegistry.java b/core/src/main/java/com/sekwah/advancedportals/core/registry/TagRegistry.java index 1ea9231d..5bb72eef 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/registry/TagRegistry.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/registry/TagRegistry.java @@ -3,7 +3,6 @@ package com.sekwah.advancedportals.core.registry; import com.google.inject.Inject; import com.sekwah.advancedportals.core.AdvancedPortalsCore; import com.sekwah.advancedportals.core.warphandler.Tag; - import java.util.*; /** @@ -34,10 +33,12 @@ public class TagRegistry { * @param arg * @return */ - public Tag.Activation getActivationHandler(String arg, Tag.TagType targetType) { + public Tag.Activation getActivationHandler(String arg, + Tag.TagType targetType) { var tag = this.activationTags.get(arg); - if (tag != null && Arrays.asList(tag.getTagTypes()).contains(targetType)) { - return tag; + if (tag != null + && Arrays.asList(tag.getTagTypes()).contains(targetType)) { + return tag; } return null; } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/registry/WarpEffectRegistry.java b/core/src/main/java/com/sekwah/advancedportals/core/registry/WarpEffectRegistry.java index 463c980f..07b0634a 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/registry/WarpEffectRegistry.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/registry/WarpEffectRegistry.java @@ -4,7 +4,6 @@ import com.google.inject.Inject; import com.sekwah.advancedportals.core.AdvancedPortalsCore; import com.sekwah.advancedportals.core.effect.WarpEffect; import com.sekwah.advancedportals.core.util.InfoLogger; - import java.util.HashMap; import java.util.Map; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/ConfigRepositoryImpl.java b/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/ConfigRepositoryImpl.java index eb3c3ba6..8bbf8dc3 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/ConfigRepositoryImpl.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/ConfigRepositoryImpl.java @@ -5,7 +5,6 @@ import com.sekwah.advancedportals.core.repository.ConfigRepository; import com.sekwah.advancedportals.core.serializeddata.DataStorage; import com.sekwah.advancedportals.core.serializeddata.config.CommandPortalConfig; import com.sekwah.advancedportals.core.serializeddata.config.Config; - import java.util.HashMap; @Singleton diff --git a/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/DestinationRepositoryImpl.java b/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/DestinationRepositoryImpl.java index bdaffa2c..28d29e33 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/DestinationRepositoryImpl.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/DestinationRepositoryImpl.java @@ -5,10 +5,9 @@ import com.sekwah.advancedportals.core.destination.Destination; import com.sekwah.advancedportals.core.repository.IDestinationRepository; import com.sekwah.advancedportals.core.serializeddata.DataStorage; import com.sekwah.advancedportals.core.tags.NameTag; - -import javax.inject.Singleton; import java.util.ArrayList; import java.util.List; +import javax.inject.Singleton; @Singleton public class DestinationRepositoryImpl implements IDestinationRepository { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/PlayerDataRepositoryImpl.java b/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/PlayerDataRepositoryImpl.java index 635b855b..2265017c 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/PlayerDataRepositoryImpl.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/PlayerDataRepositoryImpl.java @@ -4,7 +4,6 @@ import com.google.inject.Inject; import com.sekwah.advancedportals.core.repository.IPlayerDataRepository; import com.sekwah.advancedportals.core.serializeddata.DataStorage; import com.sekwah.advancedportals.core.serializeddata.PlayerData; - import java.util.List; public class PlayerDataRepositoryImpl implements IPlayerDataRepository { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/PortalRepositoryImpl.java b/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/PortalRepositoryImpl.java index b8f90632..70a7a4bc 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/PortalRepositoryImpl.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/repository/impl/PortalRepositoryImpl.java @@ -7,7 +7,6 @@ import com.sekwah.advancedportals.core.portal.AdvancedPortal; import com.sekwah.advancedportals.core.repository.IPortalRepository; import com.sekwah.advancedportals.core.serializeddata.DataStorage; import com.sekwah.advancedportals.core.tags.NameTag; - import java.util.ArrayList; import java.util.List; @@ -70,9 +69,9 @@ public class PortalRepositoryImpl implements IPortalRepository { if (portal != null) { AdvancedPortalsCore.getInstance() - .getModule() - .getInjector() - .injectMembers(portal); + .getModule() + .getInjector() + .injectMembers(portal); } // Forces the name tag to be up-to-date on load diff --git a/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/DataStorage.java b/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/DataStorage.java index 9ed14752..00c5be2d 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/DataStorage.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/DataStorage.java @@ -3,18 +3,17 @@ package com.sekwah.advancedportals.core.serializeddata; import com.google.inject.Inject; import com.sekwah.advancedportals.core.AdvancedPortalsCore; import com.sekwah.advancedportals.core.util.InfoLogger; -import org.yaml.snakeyaml.DumperOptions; -import org.yaml.snakeyaml.LoaderOptions; -import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.inspector.TagInspector; -import org.yaml.snakeyaml.nodes.Tag; - import java.io.*; import java.lang.reflect.InvocationTargetException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; +import org.yaml.snakeyaml.DumperOptions; +import org.yaml.snakeyaml.LoaderOptions; +import org.yaml.snakeyaml.Yaml; +import org.yaml.snakeyaml.inspector.TagInspector; +import org.yaml.snakeyaml.nodes.Tag; public class DataStorage { private final File dataFolder; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/ReflectiveConstructor.java b/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/ReflectiveConstructor.java index 064b47ea..84cb4035 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/ReflectiveConstructor.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/ReflectiveConstructor.java @@ -1,18 +1,17 @@ package com.sekwah.advancedportals.core.serializeddata; import com.sekwah.advancedportals.core.util.InfoLogger; -import org.yaml.snakeyaml.LoaderOptions; -import org.yaml.snakeyaml.constructor.Constructor; -import org.yaml.snakeyaml.nodes.*; -import sun.misc.Unsafe; - -import javax.inject.Inject; import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.inject.Inject; +import org.yaml.snakeyaml.LoaderOptions; +import org.yaml.snakeyaml.constructor.Constructor; +import org.yaml.snakeyaml.nodes.*; +import sun.misc.Unsafe; public class ReflectiveConstructor extends Constructor { private static final Unsafe unsafe = getUnsafe(); diff --git a/core/src/main/java/com/sekwah/advancedportals/core/services/DestinationServices.java b/core/src/main/java/com/sekwah/advancedportals/core/services/DestinationServices.java index 487ece8b..73abe4db 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/services/DestinationServices.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/services/DestinationServices.java @@ -12,12 +12,11 @@ import com.sekwah.advancedportals.core.serializeddata.DataTag; import com.sekwah.advancedportals.core.serializeddata.PlayerLocation; import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.warphandler.Tag; - -import javax.inject.Singleton; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.inject.Singleton; @Singleton public class DestinationServices { @@ -135,21 +134,22 @@ public class DestinationServices { return teleportToDestination(name, playerContainer, false); } - public boolean teleportToDestination(String name, - PlayerContainer player, boolean doEffect) { - if(doEffect && configRepository.getWarpEffectEnabled()) { - var warpEffectVisual = warpEffectRegistry.getVisualEffect(configRepository.getWarpVisual()); + public boolean teleportToDestination(String name, PlayerContainer player, + boolean doEffect) { + if (doEffect && configRepository.getWarpEffectEnabled()) { + var warpEffectVisual = warpEffectRegistry.getVisualEffect( + configRepository.getWarpVisual()); if (warpEffectVisual != null) { warpEffectVisual.onWarpVisual(player, WarpEffect.Action.ENTER); } - var warpEffectSound = warpEffectRegistry.getSoundEffect(configRepository.getWarpSound()); + var warpEffectSound = warpEffectRegistry.getSoundEffect( + configRepository.getWarpSound()); if (warpEffectSound != null) { warpEffectSound.onWarpSound(player, WarpEffect.Action.ENTER); } } if (this.destinationRepository.containsKey(name)) { - player.teleport( - this.destinationRepository.get(name).getLoc()); + player.teleport(this.destinationRepository.get(name).getLoc()); return true; } return false; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/services/PlayerDataServices.java b/core/src/main/java/com/sekwah/advancedportals/core/services/PlayerDataServices.java index 541445b5..3236ecda 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/services/PlayerDataServices.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/services/PlayerDataServices.java @@ -7,11 +7,10 @@ import com.sekwah.advancedportals.core.repository.IPlayerDataRepository; import com.sekwah.advancedportals.core.serializeddata.BlockLocation; import com.sekwah.advancedportals.core.serializeddata.PlayerData; import com.sekwah.advancedportals.core.util.Lang; - -import javax.inject.Singleton; import java.util.HashMap; import java.util.Map; import java.util.UUID; +import javax.inject.Singleton; @Singleton public final class PlayerDataServices { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/services/PortalServices.java b/core/src/main/java/com/sekwah/advancedportals/core/services/PortalServices.java index 861feea4..3a3be6a7 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/services/PortalServices.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/services/PortalServices.java @@ -15,9 +15,8 @@ import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.PlayerUtils; import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.TriggerType; - -import javax.inject.Singleton; import java.util.*; +import javax.inject.Singleton; @Singleton public class PortalServices { @@ -100,7 +99,8 @@ public class PortalServices { PORTAL_DENIED } - public PortalActivationResult checkPortalActivation(PlayerContainer player, PlayerLocation toLoc, TriggerType triggerType) { + public PortalActivationResult checkPortalActivation( + PlayerContainer player, PlayerLocation toLoc, TriggerType triggerType) { var blockLoc = toLoc.toBlockPos(); var blockEntityTopLoc = blockLoc.addY(player.getHeight()); var world = player.getWorld(); @@ -114,7 +114,7 @@ public class PortalServices { || (portal.isLocationInPortal(blockEntityTopLoc) && portal.isTriggerBlock(blockEntityTopMaterial))) { var portalName = portal.getName(); - if(Objects.equals(playerData.inPortal(), portalName)) { + if (Objects.equals(playerData.inPortal(), portalName)) { return PortalActivationResult.PORTAL_DENIED; } switch (portal.activate(player, triggerType)) { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/tags/BungeeTag.java b/core/src/main/java/com/sekwah/advancedportals/core/tags/BungeeTag.java index f713e200..4ef8ff4c 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/tags/BungeeTag.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/tags/BungeeTag.java @@ -7,17 +7,14 @@ import com.sekwah.advancedportals.core.registry.TagTarget; import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.warphandler.ActivationData; import com.sekwah.advancedportals.core.warphandler.Tag; - import java.util.Random; public class BungeeTag implements Tag.Activation { - public static final String PACKET_CHANNEL = "BungeeCord"; public static String TAG_NAME = "bungee"; - private final TagType[] tagTypes = - new TagType[] {TagType.PORTAL}; + private final TagType[] tagTypes = new TagType[] {TagType.PORTAL}; private final Random random = new Random(); @@ -42,17 +39,19 @@ public class BungeeTag implements Tag.Activation { } @Override - public boolean preActivated(TagTarget target, PlayerContainer player, ActivationData activeData, String[] argData) { + public boolean preActivated(TagTarget target, PlayerContainer player, + ActivationData activeData, String[] argData) { return true; } @Override - public void postActivated(TagTarget target, PlayerContainer player, ActivationData activationData, String[] argData) { - + public void postActivated(TagTarget target, PlayerContainer player, + ActivationData activationData, String[] argData) { } @Override - public boolean activated(TagTarget target, PlayerContainer player, ActivationData activeData, String[] argData) { + public boolean activated(TagTarget target, PlayerContainer player, + ActivationData activeData, String[] argData) { String selectedArg = argData[random.nextInt(argData.length)]; ByteArrayDataOutput outForSend = ByteStreams.newDataOutput(); diff --git a/core/src/main/java/com/sekwah/advancedportals/core/tags/CommandTag.java b/core/src/main/java/com/sekwah/advancedportals/core/tags/CommandTag.java index 18a06189..8fbfb492 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/tags/CommandTag.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/tags/CommandTag.java @@ -10,7 +10,6 @@ import com.sekwah.advancedportals.core.repository.ConfigRepository; import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.warphandler.ActivationData; import com.sekwah.advancedportals.core.warphandler.Tag; - import javax.annotation.Nullable; public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation { @@ -88,7 +87,8 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation { } break; case '%': - if (!commandPortals.proxy || !configRepository.getEnableProxySupport()) { + if (!commandPortals.proxy + || !configRepository.getEnableProxySupport()) { player.sendMessage( Lang.getNegativePrefix() + Lang.translate("tag.command.proxy.disabled")); @@ -128,8 +128,10 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation { CommandLevel.PERMISSION_WILDCARD); break; case '%': - var packet = new ProxyCommandPacket(formattedCommand.substring(1)); - player.sendPacket(ProxyMessages.CHANNEL_NAME, packet.encode()); + var packet = + new ProxyCommandPacket(formattedCommand.substring(1)); + player.sendPacket(ProxyMessages.CHANNEL_NAME, + packet.encode()); break; default: player.getServer().dispatchCommand(player.getUUID(), diff --git a/core/src/main/java/com/sekwah/advancedportals/core/tags/CooldownTag.java b/core/src/main/java/com/sekwah/advancedportals/core/tags/CooldownTag.java index 89ca45cc..a8d9c6f5 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/tags/CooldownTag.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/tags/CooldownTag.java @@ -10,9 +10,8 @@ import com.sekwah.advancedportals.core.util.InfoLogger; import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.warphandler.ActivationData; import com.sekwah.advancedportals.core.warphandler.Tag; - -import javax.annotation.Nullable; import java.util.Random; +import javax.annotation.Nullable; public class CooldownTag implements Tag.Activation, Tag.Creation { @Inject diff --git a/core/src/main/java/com/sekwah/advancedportals/core/tags/DestiTag.java b/core/src/main/java/com/sekwah/advancedportals/core/tags/DestiTag.java index cd0e32bf..e2f4d756 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/tags/DestiTag.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/tags/DestiTag.java @@ -12,7 +12,6 @@ import com.sekwah.advancedportals.core.services.DestinationServices; import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.warphandler.ActivationData; import com.sekwah.advancedportals.core.warphandler.Tag; - import java.util.List; import java.util.Random; @@ -65,24 +64,28 @@ public class DestiTag implements Tag.Activation, Tag.AutoComplete, Tag.Split { activeData.setMetadata(TAG_NAME, selectedArg); - if(activeData.getMetadata(ProxyTag.TAG_NAME) != null) { + if (activeData.getMetadata(ProxyTag.TAG_NAME) != null) { return true; } - if(destinationServices.getDestination(selectedArg) == null) { - player.sendMessage(Lang.getNegativePrefix() + Lang.translateInsertVariables("desti.error.notfound", selectedArg)); + if (destinationServices.getDestination(selectedArg) == null) { + player.sendMessage(Lang.getNegativePrefix() + + Lang.translateInsertVariables( + "desti.error.notfound", selectedArg)); return false; } // Check and trigger all tags on the destination - Destination destination = destinationServices.getDestination(selectedArg); + Destination destination = + destinationServices.getDestination(selectedArg); if (destination != null) { - for (var destiTag : destination.getArgs()) { Tag.Activation activationHandler = - tagRegistry.getActivationHandler(destiTag.NAME, Tag.TagType.DESTINATION); + tagRegistry.getActivationHandler(destiTag.NAME, + Tag.TagType.DESTINATION); if (activationHandler != null - && !activationHandler.preActivated(target, player, activeData, destiTag.VALUES)) { + && !activationHandler.preActivated( + target, player, activeData, destiTag.VALUES)) { return false; } } @@ -94,23 +97,29 @@ public class DestiTag implements Tag.Activation, Tag.AutoComplete, Tag.Split { @Override public void postActivated(TagTarget target, PlayerContainer player, ActivationData activationData, String[] argData) { - if(activationData.getMetadata(ProxyTag.TAG_NAME) != null) { + if (activationData.getMetadata(ProxyTag.TAG_NAME) != null) { return; } var selectedArg = activationData.getMetadata(TAG_NAME); - Destination destination = destinationServices.getDestination(selectedArg); + Destination destination = + destinationServices.getDestination(selectedArg); if (destination != null) { for (var destiTag : destination.getArgs()) { Tag.Activation activationHandler = - tagRegistry.getActivationHandler(destiTag.NAME, Tag.TagType.DESTINATION); + tagRegistry.getActivationHandler(destiTag.NAME, + Tag.TagType.DESTINATION); if (activationHandler != null) { - activationHandler.postActivated(target, player, activationData, argData); + activationHandler.postActivated(target, player, + activationData, argData); } } var message = activationData.getMetadata(MessageTag.TAG_NAME); - if(message == null) { - sendMessage(player, Lang.translateInsertVariables("desti.warpdesti.warp", destination.getName().replaceAll("_", " "))); + if (message == null) { + sendMessage(player, + Lang.translateInsertVariables( + "desti.warpdesti.warp", + destination.getName().replaceAll("_", " "))); } } } @@ -118,7 +127,7 @@ public class DestiTag implements Tag.Activation, Tag.AutoComplete, Tag.Split { @Override public boolean activated(TagTarget target, PlayerContainer player, ActivationData activationData, String[] argData) { - if(activationData.getMetadata(ProxyTag.TAG_NAME) != null) { + if (activationData.getMetadata(ProxyTag.TAG_NAME) != null) { return true; } @@ -126,22 +135,27 @@ public class DestiTag implements Tag.Activation, Tag.AutoComplete, Tag.Split { Destination destination = destinationServices.getDestination(selectedArg); if (destination != null) { - var warpEffectVisual = warpEffectRegistry.getVisualEffect(configRepository.getWarpVisual()); - var warpEffectSound = warpEffectRegistry.getSoundEffect(configRepository.getWarpSound()); - if(configRepository.getWarpEffectEnabled()) { + var warpEffectVisual = warpEffectRegistry.getVisualEffect( + configRepository.getWarpVisual()); + var warpEffectSound = warpEffectRegistry.getSoundEffect( + configRepository.getWarpSound()); + if (configRepository.getWarpEffectEnabled()) { if (warpEffectVisual != null) { - warpEffectVisual.onWarpVisual(player, WarpEffect.Action.ENTER); + warpEffectVisual.onWarpVisual(player, + WarpEffect.Action.ENTER); } if (warpEffectSound != null) { - warpEffectSound.onWarpSound(player, WarpEffect.Action.ENTER); + warpEffectSound.onWarpSound(player, + WarpEffect.Action.ENTER); } } player.teleport(destination.getLoc()); - if(configRepository.getWarpEffectEnabled()) { + if (configRepository.getWarpEffectEnabled()) { if (warpEffectVisual != null) { - warpEffectVisual.onWarpVisual(player, WarpEffect.Action.EXIT); + warpEffectVisual.onWarpVisual(player, + WarpEffect.Action.EXIT); } if (warpEffectSound != null) { warpEffectSound.onWarpSound(player, WarpEffect.Action.EXIT); @@ -153,11 +167,11 @@ public class DestiTag implements Tag.Activation, Tag.AutoComplete, Tag.Split { } public void sendMessage(PlayerContainer player, String message) { - if(this.configRepository.warpMessageOnActionBar()) { + if (this.configRepository.warpMessageOnActionBar()) { player.sendActionBar(Lang.convertColors(message)); - } - else if(this.configRepository.warpMessageInChat()) { - player.sendMessage(Lang.getPositivePrefix() + " " + Lang.convertColors(message)); + } else if (this.configRepository.warpMessageInChat()) { + player.sendMessage(Lang.getPositivePrefix() + " " + + Lang.convertColors(message)); } } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/tags/MessageTag.java b/core/src/main/java/com/sekwah/advancedportals/core/tags/MessageTag.java index 7ca343d2..96314a53 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/tags/MessageTag.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/tags/MessageTag.java @@ -7,11 +7,9 @@ import com.sekwah.advancedportals.core.repository.ConfigRepository; import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.warphandler.ActivationData; import com.sekwah.advancedportals.core.warphandler.Tag; - import java.util.Random; public class MessageTag implements Tag.Activation { - @Inject ConfigRepository configRepository; @@ -43,26 +41,30 @@ public class MessageTag implements Tag.Activation { } @Override - public boolean preActivated(TagTarget target, PlayerContainer player, ActivationData activeData, String[] argData) { + public boolean preActivated(TagTarget target, PlayerContainer player, + ActivationData activeData, String[] argData) { return true; } @Override - public void postActivated(TagTarget target, PlayerContainer player, ActivationData activationData, String[] argData) { - + public void postActivated(TagTarget target, PlayerContainer player, + ActivationData activationData, String[] argData) { var destination = activationData.getMetadata(DestiTag.TAG_NAME); var message = activationData.getMetadata(TAG_NAME); - if(destination == null) { + if (destination == null) { destination = ""; } else { destination = destination.replaceAll("_", " "); } - sendMessage(player, message.replaceAll("@desti", destination).replaceAll("@player", player.getName())); + sendMessage(player, + message.replaceAll("@desti", destination) + .replaceAll("@player", player.getName())); } @Override - public boolean activated(TagTarget target, PlayerContainer player, ActivationData activeData, String[] argData) { + public boolean activated(TagTarget target, PlayerContainer player, + ActivationData activeData, String[] argData) { String selectedArg = argData[random.nextInt(argData.length)]; activeData.setMetadata(TAG_NAME, selectedArg); activeData.setWarpStatus(ActivationData.WarpedStatus.ACTIVATED); @@ -70,11 +72,11 @@ public class MessageTag implements Tag.Activation { } public void sendMessage(PlayerContainer player, String message) { - if(this.configRepository.warpMessageOnActionBar()) { + if (this.configRepository.warpMessageOnActionBar()) { player.sendActionBar(Lang.convertColors(message)); - } - else if(this.configRepository.warpMessageInChat()) { - player.sendMessage(Lang.getPositivePrefix() + " " + Lang.convertColors(message)); + } else if (this.configRepository.warpMessageInChat()) { + player.sendMessage(Lang.getPositivePrefix() + " " + + Lang.convertColors(message)); } } } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/tags/NameTag.java b/core/src/main/java/com/sekwah/advancedportals/core/tags/NameTag.java index e918887b..ce614c6d 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/tags/NameTag.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/tags/NameTag.java @@ -4,7 +4,6 @@ import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; import com.sekwah.advancedportals.core.registry.TagTarget; import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.warphandler.Tag; - import java.util.List; /** diff --git a/core/src/main/java/com/sekwah/advancedportals/core/tags/PermissionTag.java b/core/src/main/java/com/sekwah/advancedportals/core/tags/PermissionTag.java index e8e025b1..8a2baacc 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/tags/PermissionTag.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/tags/PermissionTag.java @@ -8,7 +8,6 @@ import com.sekwah.advancedportals.core.util.InfoLogger; import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.warphandler.ActivationData; import com.sekwah.advancedportals.core.warphandler.Tag; - import javax.annotation.Nullable; import javax.inject.Inject; @@ -26,7 +25,8 @@ public class PermissionTag implements Tag.Activation { private final String[] aliases = new String[] {"perm"}; - private final TagType[] tagTypes = new TagType[] {TagType.PORTAL, TagType.DESTINATION}; + private final TagType[] tagTypes = + new TagType[] {TagType.PORTAL, TagType.DESTINATION}; @Override public TagType[] getTagTypes() { @@ -53,16 +53,18 @@ public class PermissionTag implements Tag.Activation { public boolean preActivated(TagTarget target, PlayerContainer player, ActivationData activeData, String[] argData) { var permission = argData[0]; - if(permission.startsWith("!")) { + if (permission.startsWith("!")) { permission = permission.substring(1); - if(player.hasPermission(permission)) { - player.sendMessage(Lang.getNegativePrefix() + Lang.translate("portal.error.nopermission")); + if (player.hasPermission(permission)) { + player.sendMessage( + Lang.getNegativePrefix() + + Lang.translate("portal.error.nopermission")); return false; } return true; - } - else if (!player.hasPermission(argData[0])) { - player.sendMessage(Lang.getNegativePrefix() + Lang.translate("portal.error.nopermission")); + } else if (!player.hasPermission(argData[0])) { + player.sendMessage(Lang.getNegativePrefix() + + Lang.translate("portal.error.nopermission")); return false; } return true; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/tags/PortalEventTag.java b/core/src/main/java/com/sekwah/advancedportals/core/tags/PortalEventTag.java index 29362cf0..f6194c13 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/tags/PortalEventTag.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/tags/PortalEventTag.java @@ -10,13 +10,13 @@ import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.warphandler.ActivationData; import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.TriggerType; - -import javax.annotation.Nullable; -import javax.inject.Inject; import java.util.List; import java.util.Objects; +import javax.annotation.Nullable; +import javax.inject.Inject; -public class PortalEventTag implements Tag.Activation, Tag.AutoComplete, Tag.DenyBehavior, Tag.OrderPriority { +public class PortalEventTag implements Tag.Activation, Tag.AutoComplete, + Tag.DenyBehavior, Tag.OrderPriority { @Inject PlayerDataServices playerDataServices; @@ -56,10 +56,11 @@ public class PortalEventTag implements Tag.Activation, Tag.AutoComplete, Tag.Den @Override public boolean preActivated(TagTarget target, PlayerContainer player, ActivationData activeData, String[] argData) { - if(player.getGameMode() == GameMode.CREATIVE) { + if (player.getGameMode() == GameMode.CREATIVE) { return true; } - return !Objects.equals(argData[0], "true") || activeData.getTriggerType() == TriggerType.PORTAL; + return !Objects.equals(argData[0], "true") + || activeData.getTriggerType() == TriggerType.PORTAL; } @Override diff --git a/core/src/main/java/com/sekwah/advancedportals/core/tags/ProxyTag.java b/core/src/main/java/com/sekwah/advancedportals/core/tags/ProxyTag.java index 936db9fe..2c71f5c9 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/tags/ProxyTag.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/tags/ProxyTag.java @@ -10,18 +10,15 @@ import com.sekwah.advancedportals.core.repository.ConfigRepository; import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.warphandler.ActivationData; import com.sekwah.advancedportals.core.warphandler.Tag; - import java.util.Random; public class ProxyTag implements Tag.Activation, Tag.OrderPriority, Tag.Split { - @Inject ConfigRepository configRepository; public static String TAG_NAME = "proxy"; - private final TagType[] tagTypes = - new TagType[] {TagType.PORTAL}; + private final TagType[] tagTypes = new TagType[] {TagType.PORTAL}; private final Random random = new Random(); @@ -46,22 +43,24 @@ public class ProxyTag implements Tag.Activation, Tag.OrderPriority, Tag.Split { } @Override - public boolean preActivated(TagTarget target, PlayerContainer player, ActivationData activeData, String[] argData) { + public boolean preActivated(TagTarget target, PlayerContainer player, + ActivationData activeData, String[] argData) { String selectedArg = argData[random.nextInt(argData.length)]; activeData.setMetadata(TAG_NAME, selectedArg); return true; } @Override - public void postActivated(TagTarget target, PlayerContainer player, ActivationData activationData, String[] argData) { - + public void postActivated(TagTarget target, PlayerContainer player, + ActivationData activationData, String[] argData) { } @Override - public boolean activated(TagTarget target, PlayerContainer player, ActivationData activeData, String[] argData) { - - if(!this.configRepository.getEnableProxySupport()) { - player.sendMessage(Lang.getNegativePrefix() + Lang.translate("tag.proxy.notenabled")); + public boolean activated(TagTarget target, PlayerContainer player, + ActivationData activeData, String[] argData) { + if (!this.configRepository.getEnableProxySupport()) { + player.sendMessage(Lang.getNegativePrefix() + + Lang.translate("tag.proxy.notenabled")); return false; } @@ -69,7 +68,9 @@ public class ProxyTag implements Tag.Activation, Tag.OrderPriority, Tag.Split { var desti = activeData.getMetadata(DestiTag.TAG_NAME); - var packet = desti == null ? new ProxyTransferPacket(selectedArg) : new ProxyTransferDestiPacket(selectedArg, desti); + var packet = desti == null + ? new ProxyTransferPacket(selectedArg) + : new ProxyTransferDestiPacket(selectedArg, desti); player.sendPacket(ProxyMessages.CHANNEL_NAME, packet.encode()); activeData.setWarpStatus(ActivationData.WarpedStatus.WARPED); return true; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/tags/TriggerBlockTag.java b/core/src/main/java/com/sekwah/advancedportals/core/tags/TriggerBlockTag.java index 44e85389..7fc2442f 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/tags/TriggerBlockTag.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/tags/TriggerBlockTag.java @@ -4,9 +4,8 @@ import com.google.inject.Inject; import com.sekwah.advancedportals.core.connector.containers.ServerContainer; import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.warphandler.Tag; - -import javax.annotation.Nullable; import java.util.List; +import javax.annotation.Nullable; public class TriggerBlockTag implements Tag.AutoComplete, Tag.Split { @Inject diff --git a/core/src/main/java/com/sekwah/advancedportals/core/util/Debug.java b/core/src/main/java/com/sekwah/advancedportals/core/util/Debug.java index 1fa08403..63bb426f 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/util/Debug.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/util/Debug.java @@ -2,7 +2,6 @@ package com.sekwah.advancedportals.core.util; import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; import com.sekwah.advancedportals.core.serializeddata.BlockLocation; - import java.awt.*; public class Debug { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/util/FriendlyDataOutput.java b/core/src/main/java/com/sekwah/advancedportals/core/util/FriendlyDataOutput.java index a6b352dc..aeafe78f 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/util/FriendlyDataOutput.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/util/FriendlyDataOutput.java @@ -4,7 +4,6 @@ import com.sekwah.advancedportals.core.serializeddata.BlockLocation; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.handler.codec.EncoderException; - import java.nio.charset.StandardCharsets; /** diff --git a/core/src/main/java/com/sekwah/advancedportals/core/util/GameScheduler.java b/core/src/main/java/com/sekwah/advancedportals/core/util/GameScheduler.java index 71f324a2..56ebd7de 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/util/GameScheduler.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/util/GameScheduler.java @@ -1,8 +1,8 @@ package com.sekwah.advancedportals.core.util; -import javax.inject.Singleton; import java.util.ArrayList; import java.util.Iterator; +import javax.inject.Singleton; /** * For all delayed and repeating tasks. diff --git a/core/src/main/java/com/sekwah/advancedportals/core/util/Lang.java b/core/src/main/java/com/sekwah/advancedportals/core/util/Lang.java index 4ff1c573..e115e443 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/util/Lang.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/util/Lang.java @@ -2,7 +2,6 @@ package com.sekwah.advancedportals.core.util; import com.google.inject.Inject; import com.sekwah.advancedportals.core.serializeddata.DataStorage; - import java.io.IOException; import java.io.InputStream; import java.net.URL; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/util/TagReader.java b/core/src/main/java/com/sekwah/advancedportals/core/util/TagReader.java index bfcb89ee..7578367f 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/util/TagReader.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/util/TagReader.java @@ -2,7 +2,6 @@ package com.sekwah.advancedportals.core.util; import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; import com.sekwah.advancedportals.core.serializeddata.DataTag; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -98,18 +97,16 @@ public class TagReader { return null; } - - public static void printArgs(CommandSenderContainer sender, List dataTags) { for (DataTag tag : dataTags) { if (tag.VALUES.length == 1) { sender.sendMessage(" \u00A7a" + tag.NAME + "\u00A77:\u00A7e" - + tag.VALUES[0]); + + tag.VALUES[0]); } else { for (int i = 0; i < tag.VALUES.length; i++) { sender.sendMessage(" \u00A7a" + tag.NAME + "\u00A77[" + i - + "]:\u00A7e" + tag.VALUES[i]); + + "]:\u00A7e" + tag.VALUES[i]); } } } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/warphandler/ActivationData.java b/core/src/main/java/com/sekwah/advancedportals/core/warphandler/ActivationData.java index 34dc9ff5..01cdc815 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/warphandler/ActivationData.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/warphandler/ActivationData.java @@ -1,7 +1,6 @@ package com.sekwah.advancedportals.core.warphandler; import com.sekwah.advancedportals.core.serializeddata.PlayerLocation; - import java.util.HashMap; import java.util.Map; diff --git a/core/src/main/java/com/sekwah/advancedportals/core/warphandler/Tag.java b/core/src/main/java/com/sekwah/advancedportals/core/warphandler/Tag.java index 835e16fe..0e7d1171 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/warphandler/Tag.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/warphandler/Tag.java @@ -2,9 +2,8 @@ package com.sekwah.advancedportals.core.warphandler; import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; import com.sekwah.advancedportals.core.registry.TagTarget; - -import javax.annotation.Nullable; import java.util.List; +import javax.annotation.Nullable; /** * If a tag can be used for any of them then either make it cast the target or diff --git a/core/src/main/java/com/sekwah/advancedportals/core/warphandler/TriggerType.java b/core/src/main/java/com/sekwah/advancedportals/core/warphandler/TriggerType.java index bc35a9fa..2bb5fb6a 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/warphandler/TriggerType.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/warphandler/TriggerType.java @@ -1,7 +1,3 @@ package com.sekwah.advancedportals.core.warphandler; -public enum TriggerType { - MOVEMENT, - PORTAL, - MANUAL -} +public enum TriggerType { MOVEMENT, PORTAL, MANUAL } diff --git a/core/src/main/templates/com/sekwah/advancedportals/core/BuildConstants.java b/core/src/main/templates/com/sekwah/advancedportals/core/BuildConstants.java index fca4bb70..c0b26612 100644 --- a/core/src/main/templates/com/sekwah/advancedportals/core/BuildConstants.java +++ b/core/src/main/templates/com/sekwah/advancedportals/core/BuildConstants.java @@ -1,5 +1,5 @@ package com.sekwah.advancedportals.core; public class BuildConstants { - public static final String VERSION = "${version}"; + public static final String VERSION = "${version}"; } diff --git a/proxycore/src/main/java/com/sekwah/advancedportals/proxycore/AdvancedPortalsProxyCore.java b/proxycore/src/main/java/com/sekwah/advancedportals/proxycore/AdvancedPortalsProxyCore.java index eeceb0b9..5da980fb 100644 --- a/proxycore/src/main/java/com/sekwah/advancedportals/proxycore/AdvancedPortalsProxyCore.java +++ b/proxycore/src/main/java/com/sekwah/advancedportals/proxycore/AdvancedPortalsProxyCore.java @@ -12,17 +12,16 @@ import com.sekwah.advancedportals.proxycore.connector.container.ProxyContainer; import com.sekwah.advancedportals.proxycore.connector.container.ProxyJoinData; import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerContainer; import com.sekwah.advancedportals.proxycore.connector.container.ProxyServerContainer; - import java.util.HashMap; public class AdvancedPortalsProxyCore { - private final InfoLogger logger; private final ProxyContainer proxyContainer; public HashMap playerJoinMap = new HashMap<>(); - public AdvancedPortalsProxyCore(InfoLogger logger, ProxyContainer proxyContainer) { + public AdvancedPortalsProxyCore(InfoLogger logger, + ProxyContainer proxyContainer) { this.logger = logger; this.proxyContainer = proxyContainer; } @@ -35,11 +34,14 @@ public class AdvancedPortalsProxyCore { this.logger.info(Lang.convertColors("&cDisabling plugin!")); } - public void onServerConnect(ProxyServerContainer server, ProxyPlayerContainer player) { - if(this.playerJoinMap.containsKey(player.getUUID())) { + public void onServerConnect(ProxyServerContainer server, + ProxyPlayerContainer player) { + if (this.playerJoinMap.containsKey(player.getUUID())) { var joinData = this.playerJoinMap.get(player.getUUID()); - if(joinData.isExpired()) return; - player.sendServerPluginMessage(new ServerDestiPacket(joinData.destination).encode()); + if (joinData.isExpired()) + return; + player.sendServerPluginMessage( + new ServerDestiPacket(joinData.destination).encode()); this.playerJoinMap.remove(player.getUUID()); } } @@ -49,17 +51,18 @@ public class AdvancedPortalsProxyCore { } /** - * Messages coming on the ProxyMessages.CHANNEL_NAME from the server, others will be filtered out before now. + * Messages coming on the ProxyMessages.CHANNEL_NAME from the server, others + * will be filtered out before now. * @param player * @param message */ public void incomingMessage(ProxyPlayerContainer player, byte[] message) { - var buffer = ByteStreams.newDataInput(message); var messageType = buffer.readUTF(); - // Might be a bit overboard for some as they'll only have one value, but try to keep the decode behavior with - // the encode behavior in the packets + // Might be a bit overboard for some as they'll only have one value, but + // try to keep the decode behavior with the encode behavior in the + // packets switch (messageType) { case ProxyMessages.PROXY_TRANSFER -> { var transferPacket = ProxyTransferPacket.decode(buffer); diff --git a/proxycore/src/main/java/com/sekwah/advancedportals/proxycore/connector/container/ProxyContainer.java b/proxycore/src/main/java/com/sekwah/advancedportals/proxycore/connector/container/ProxyContainer.java index 79eb1d91..53468988 100644 --- a/proxycore/src/main/java/com/sekwah/advancedportals/proxycore/connector/container/ProxyContainer.java +++ b/proxycore/src/main/java/com/sekwah/advancedportals/proxycore/connector/container/ProxyContainer.java @@ -4,5 +4,4 @@ public interface ProxyContainer { void invokeCommand(ProxyPlayerContainer proxyPlayer, String command); void transferPlayer(ProxyPlayerContainer proxyPlayer, String serverName); - } diff --git a/proxycore/src/main/java/com/sekwah/advancedportals/proxycore/connector/container/ProxyJoinData.java b/proxycore/src/main/java/com/sekwah/advancedportals/proxycore/connector/container/ProxyJoinData.java index 16cbff12..8089acfa 100644 --- a/proxycore/src/main/java/com/sekwah/advancedportals/proxycore/connector/container/ProxyJoinData.java +++ b/proxycore/src/main/java/com/sekwah/advancedportals/proxycore/connector/container/ProxyJoinData.java @@ -1,7 +1,6 @@ package com.sekwah.advancedportals.proxycore.connector.container; public class ProxyJoinData { - public final String destination; public final String serverName; public final long joinTime; @@ -13,6 +12,7 @@ public class ProxyJoinData { } public boolean isExpired() { - return System.currentTimeMillis() - this.joinTime > 1000 * 15; // 15 seconds + return System.currentTimeMillis() - this.joinTime + > 1000 * 15; // 15 seconds } } diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/AdvancedPortalsPlugin.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/AdvancedPortalsPlugin.java index 7ab1a02b..9fe80e0f 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/AdvancedPortalsPlugin.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/AdvancedPortalsPlugin.java @@ -11,10 +11,9 @@ import com.sekwah.advancedportals.spigot.connector.command.SpigotCommandRegister import com.sekwah.advancedportals.spigot.connector.container.SpigotServerContainer; import com.sekwah.advancedportals.spigot.metrics.Metrics; import com.sekwah.advancedportals.spigot.warpeffects.SpigotWarpEffects; -import org.bukkit.plugin.java.JavaPlugin; - import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.bukkit.plugin.java.JavaPlugin; public class AdvancedPortalsPlugin extends JavaPlugin { private AdvancedPortalsCore portalsCore; diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/Listeners.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/Listeners.java index 66f5e524..e4397880 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/Listeners.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/Listeners.java @@ -9,6 +9,7 @@ import com.sekwah.advancedportals.spigot.connector.container.SpigotEntityContain import com.sekwah.advancedportals.spigot.connector.container.SpigotPlayerContainer; import com.sekwah.advancedportals.spigot.connector.container.SpigotWorldContainer; import com.sekwah.advancedportals.spigot.utils.ContainerHelpers; +import java.util.List; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -23,8 +24,6 @@ import org.bukkit.event.entity.*; import org.bukkit.event.player.*; import org.bukkit.event.world.ChunkLoadEvent; -import java.util.List; - /** * Some of these will be passed to the core listener to handle the events, * others it's easier to just check directly. @@ -68,7 +67,8 @@ public class Listeners implements Listener { @EventHandler(ignoreCancelled = true) public void onPortalEvent(PlayerPortalEvent event) { if (!this.coreListeners.playerPortalEvent( - new SpigotPlayerContainer(event.getPlayer()), ContainerHelpers.toPlayerLocation(event.getFrom()))) { + new SpigotPlayerContainer(event.getPlayer()), + ContainerHelpers.toPlayerLocation(event.getFrom()))) { event.setCancelled(true); } } @@ -210,25 +210,26 @@ public class Listeners implements Listener { } } - @EventHandler public void onChunkLoad(ChunkLoadEvent event) { - if(!configRepository.getDisableGatewayBeam()) { + if (!configRepository.getDisableGatewayBeam()) { return; } SpigotWorldContainer world = new SpigotWorldContainer(event.getWorld()); BlockState[] tileEntities = event.getChunk().getTileEntities(); - for(BlockState block : tileEntities) { - if(block.getType() == Material.END_GATEWAY) { + for (BlockState block : tileEntities) { + if (block.getType() == Material.END_GATEWAY) { var loc = block.getLocation(); - if(portalServices.inPortalRegion(new BlockLocation(loc.getWorld().getName(), - loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), 2)) { + if (portalServices.inPortalRegion( + new BlockLocation(loc.getWorld().getName(), + loc.getBlockX(), loc.getBlockY(), + loc.getBlockZ()), + 2)) { EndGateway tileState = (EndGateway) block; tileState.setAge(Long.MIN_VALUE); tileState.update(); } } - } } } diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/PermissionsGeneratorSpigot.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/PermissionsGeneratorSpigot.java index d0d7b7d9..77d7a8ae 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/PermissionsGeneratorSpigot.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/PermissionsGeneratorSpigot.java @@ -1,11 +1,9 @@ package com.sekwah.advancedportals.spigot; - import com.sekwah.advancedportals.core.permissions.PermissionBuilder; import com.sekwah.advancedportals.core.permissions.Permissions; public class PermissionsGeneratorSpigot { - private PermissionsGeneratorSpigot() { } @@ -16,25 +14,28 @@ public class PermissionsGeneratorSpigot { public static String toPermBlock(PermissionBuilder permission) { StringBuilder builder = new StringBuilder(); String indent = " "; - if(!permission.isDoNotExport()) { + if (!permission.isDoNotExport()) { builder.append(indent).append(permission).append(":\n"); builder.append(indent).append(indent).append("default: "); - builder.append(permission.getPermissionDefault().toString().toLowerCase()); + builder.append( + permission.getPermissionDefault().toString().toLowerCase()); builder.append("\n"); - if(permission.getDescription() != null) { + if (permission.getDescription() != null) { builder.append(indent).append(indent).append("description: "); builder.append(permission.getDescription()).append("\n"); } var children = permission.getGrantChildren(); - if(!children.isEmpty()) { + if (!children.isEmpty()) { builder.append(indent).append(indent).append("children:\n"); - for(PermissionBuilder child : children) { + for (PermissionBuilder child : children) { builder.append(indent).append(indent).append(indent); - builder.append(child.toString()).append(": true").append("\n"); + builder.append(child.toString()) + .append(": true") + .append("\n"); } } } - for(PermissionBuilder child : permission.getChildren()) { + for (PermissionBuilder child : permission.getChildren()) { builder.append(toPermBlock(child)); } return builder.toString(); diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/SpigotInfoLogger.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/SpigotInfoLogger.java index 0c9b996d..982b55f5 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/SpigotInfoLogger.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/SpigotInfoLogger.java @@ -1,7 +1,6 @@ package com.sekwah.advancedportals.spigot; import com.sekwah.advancedportals.core.util.InfoLogger; - import java.util.logging.Level; public class SpigotInfoLogger extends InfoLogger { diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/commands/subcommands/portal/ImportPortalSubCommand.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/commands/subcommands/portal/ImportPortalSubCommand.java index f9539101..6e3ae5b2 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/commands/subcommands/portal/ImportPortalSubCommand.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/commands/subcommands/portal/ImportPortalSubCommand.java @@ -12,14 +12,12 @@ import com.sekwah.advancedportals.core.services.PortalServices; import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin; import com.sekwah.advancedportals.spigot.commands.subcommands.portal.importer.ConfigAccessor; -import org.bukkit.configuration.ConfigurationSection; - import java.util.ArrayList; import java.util.List; import java.util.Set; +import org.bukkit.configuration.ConfigurationSection; public class ImportPortalSubCommand implements SubCommand { - @Inject DestinationServices destinationServices; @@ -77,7 +75,7 @@ public class ImportPortalSubCommand implements SubCommand { var bungee = config.getString(portalName + ".bungee"); if (bungee != null) { - if(destination == null) { + if (destination == null) { args.add(new DataTag("bungee", bungee.split(","))); } else { args.add(new DataTag("proxy", bungee.split(","))); diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/commands/subcommands/portal/importer/ConfigAccessor.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/commands/subcommands/portal/importer/ConfigAccessor.java index 877cb916..c4dce614 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/commands/subcommands/portal/importer/ConfigAccessor.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/commands/subcommands/portal/importer/ConfigAccessor.java @@ -1,12 +1,11 @@ package com.sekwah.advancedportals.spigot.commands.subcommands.portal.importer; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.plugin.java.JavaPlugin; - import java.io.File; import java.io.IOException; import java.util.logging.Level; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.plugin.java.JavaPlugin; public class ConfigAccessor { private final String fileName; diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/command/SpigotCommandHandler.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/command/SpigotCommandHandler.java index 7d3330aa..c91cce07 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/command/SpigotCommandHandler.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/command/SpigotCommandHandler.java @@ -2,13 +2,12 @@ package com.sekwah.advancedportals.spigot.connector.command; import com.sekwah.advancedportals.core.commands.CommandTemplate; import com.sekwah.advancedportals.spigot.connector.container.SpigotCommandSenderContainer; +import java.util.List; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.command.TabCompleter; -import java.util.List; - public class SpigotCommandHandler implements CommandExecutor, TabCompleter { private final CommandTemplate commandExecutor; diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotPlayerContainer.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotPlayerContainer.java index 150223d7..c93bfc02 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotPlayerContainer.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotPlayerContainer.java @@ -9,6 +9,8 @@ import com.sekwah.advancedportals.core.serializeddata.BlockLocation; import com.sekwah.advancedportals.core.serializeddata.PlayerLocation; import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin; import com.sekwah.advancedportals.spigot.reflection.MinecraftCustomPayload; +import java.util.Arrays; +import java.util.UUID; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; @@ -18,9 +20,6 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import java.util.Arrays; -import java.util.UUID; - /** * Just a temporary container for whenever advanced portals needs to get data * from a player @@ -49,7 +48,8 @@ public class SpigotPlayerContainer @Override public void sendActionBar(String message) { - player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message)); + player.spigot().sendMessage(ChatMessageType.ACTION_BAR, + TextComponent.fromLegacyText(message)); } @Override diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotServerContainer.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotServerContainer.java index 300f6f8b..36605ced 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotServerContainer.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotServerContainer.java @@ -7,15 +7,14 @@ import com.sekwah.advancedportals.core.connector.containers.ServerContainer; import com.sekwah.advancedportals.core.connector.containers.WorldContainer; import com.sekwah.advancedportals.core.tags.CommandTag; import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin; +import java.util.Arrays; +import java.util.List; +import java.util.UUID; import org.bukkit.Material; import org.bukkit.Server; import org.bukkit.entity.Player; import org.bukkit.permissions.PermissionAttachment; -import java.util.Arrays; -import java.util.List; -import java.util.UUID; - public class SpigotServerContainer implements ServerContainer { @Inject private CoreListeners coreListeners; @@ -75,13 +74,17 @@ public class SpigotServerContainer implements ServerContainer { @Override public void registerOutgoingChannel(String channel) { - server.getMessenger().registerOutgoingPluginChannel(AdvancedPortalsPlugin.getInstance(), channel); + server.getMessenger().registerOutgoingPluginChannel( + AdvancedPortalsPlugin.getInstance(), channel); } @Override public void registerIncomingChannel(String channel) { - server.getMessenger().registerIncomingPluginChannel(AdvancedPortalsPlugin.getInstance(), channel, - (s, player, bytes) -> coreListeners.incomingMessage(new SpigotPlayerContainer(player), s, bytes)); + server.getMessenger().registerIncomingPluginChannel( + AdvancedPortalsPlugin.getInstance(), channel, + (s, player, bytes) + -> coreListeners.incomingMessage( + new SpigotPlayerContainer(player), s, bytes)); } // Check if it's a material compatible with making portals diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotWorldContainer.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotWorldContainer.java index 32272a3a..a0506988 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotWorldContainer.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/connector/container/SpigotWorldContainer.java @@ -14,12 +14,14 @@ import org.bukkit.block.data.Orientable; public class SpigotWorldContainer implements WorldContainer { private final World world; - // Should only be false for 1.13 and 1.13.2, though just to avoid possible crashes + // Should only be false for 1.13 and 1.13.2, though just to avoid possible + // crashes private static boolean endGatewaySetAgeExists; static { try { - endGatewaySetAgeExists = EndGateway.class.getMethod("setAge", long.class) != null; + endGatewaySetAgeExists = + EndGateway.class.getMethod("setAge", long.class) != null; } catch (NoSuchMethodException e) { endGatewaySetAgeExists = false; } @@ -74,11 +76,13 @@ public class SpigotWorldContainer implements WorldContainer { @Override public void disableBeacon(BlockLocation location) { - if(!endGatewaySetAgeExists) return; - var block = this.world.getBlockAt(location.getPosX(), location.getPosY(), - location.getPosZ()); + if (!endGatewaySetAgeExists) + return; + var block = this.world.getBlockAt( + location.getPosX(), location.getPosY(), location.getPosZ()); var blockType = block.getType(); - if(blockType == Material.END_GATEWAY && block.getState() instanceof EndGateway endGateway) { + if (blockType == Material.END_GATEWAY + && block.getState() instanceof EndGateway endGateway) { endGateway.setAge(Long.MIN_VALUE); endGateway.update(); } @@ -86,15 +90,16 @@ public class SpigotWorldContainer implements WorldContainer { @Override public void disableBeacon(AdvancedPortal portal) { - if(!endGatewaySetAgeExists) return; + if (!endGatewaySetAgeExists) + return; BlockLocation maxLoc = portal.getMaxLoc(); - BlockLocation minLoc = portal.getMinLoc(); + BlockLocation minLoc = portal.getMinLoc(); for (int x = minLoc.getPosX(); x <= maxLoc.getPosX(); x++) { for (int y = minLoc.getPosY(); y <= maxLoc.getPosY(); y++) { for (int z = minLoc.getPosZ(); z <= maxLoc.getPosZ(); z++) { Block block = world.getBlockAt(x, y, z); - if(block.getType() == Material.END_GATEWAY) { + if (block.getType() == Material.END_GATEWAY) { EndGateway tileState = (EndGateway) block.getState(); tileState.setAge(Long.MIN_VALUE); tileState.update(); diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/metrics/Metrics.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/metrics/Metrics.java index 06294e86..3d37cd2d 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/metrics/Metrics.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/metrics/Metrics.java @@ -3,14 +3,6 @@ package com.sekwah.advancedportals.spigot.metrics; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import org.bukkit.Bukkit; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.RegisteredServiceProvider; -import org.bukkit.plugin.ServicePriority; - -import javax.net.ssl.HttpsURLConnection; import java.io.*; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -20,6 +12,13 @@ import java.util.*; import java.util.concurrent.Callable; import java.util.logging.Level; import java.util.zip.GZIPOutputStream; +import javax.net.ssl.HttpsURLConnection; +import org.bukkit.Bukkit; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.RegisteredServiceProvider; +import org.bukkit.plugin.ServicePriority; /** * bStats collects some data for plugin authors. diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/reflection/MinecraftCustomPayload.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/reflection/MinecraftCustomPayload.java index ee836f65..87f627fc 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/reflection/MinecraftCustomPayload.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/reflection/MinecraftCustomPayload.java @@ -1,9 +1,8 @@ package com.sekwah.advancedportals.spigot.reflection; -import org.bukkit.entity.Player; - import java.lang.reflect.Constructor; import java.lang.reflect.Method; +import org.bukkit.entity.Player; /** * Just a util class to force spigot to allow us to have fun with the diff --git a/spigot/src/main/java/com/sekwah/advancedportals/spigot/warpeffects/SpigotWarpEffects.java b/spigot/src/main/java/com/sekwah/advancedportals/spigot/warpeffects/SpigotWarpEffects.java index abc80e00..d6534d22 100644 --- a/spigot/src/main/java/com/sekwah/advancedportals/spigot/warpeffects/SpigotWarpEffects.java +++ b/spigot/src/main/java/com/sekwah/advancedportals/spigot/warpeffects/SpigotWarpEffects.java @@ -1,7 +1,6 @@ package com.sekwah.advancedportals.spigot.warpeffects; import com.sekwah.advancedportals.core.registry.WarpEffectRegistry; - import javax.inject.Inject; public class SpigotWarpEffects { diff --git a/spigot/src/main/templates/plugin.yml b/spigot/src/main/templates/plugin.yml index d5399cdc..38e4d28f 100644 --- a/spigot/src/main/templates/plugin.yml +++ b/spigot/src/main/templates/plugin.yml @@ -14,4 +14,4 @@ commands: aliases: [desti] usage: / permissions: -${permissions} \ No newline at end of file +${permissions} diff --git a/velocity/src/main/java/com/sekwah/advancedportals/velocity/AdvancedPortalsVelocityPlugin.java b/velocity/src/main/java/com/sekwah/advancedportals/velocity/AdvancedPortalsVelocityPlugin.java index c6e80298..5da8c49f 100644 --- a/velocity/src/main/java/com/sekwah/advancedportals/velocity/AdvancedPortalsVelocityPlugin.java +++ b/velocity/src/main/java/com/sekwah/advancedportals/velocity/AdvancedPortalsVelocityPlugin.java @@ -18,11 +18,11 @@ import com.velocitypowered.api.proxy.ServerConnection; import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier; import org.slf4j.Logger; -@Plugin(authors = {"sekwah41"} ,id = "advancedportals", name = "Advanced Portals", +@Plugin(authors = {"sekwah41"}, id = "advancedportals", + name = "Advanced Portals", url = "https://www.spigotmc.org/resources/advanced-portals.14356/", version = BuildConstants.VERSION) public class AdvancedPortalsVelocityPlugin { - private AdvancedPortalsProxyCore proxyCore; private final Logger logger; @@ -34,7 +34,9 @@ public class AdvancedPortalsVelocityPlugin { public AdvancedPortalsVelocityPlugin(ProxyServer proxy, Logger logger) { this.proxy = proxy; this.logger = logger; - this.proxyCore = new AdvancedPortalsProxyCore(new VelocityInfoLogger(this.logger, this.proxy), new VelocityProxyContainer(this.proxy)); + this.proxyCore = new AdvancedPortalsProxyCore( + new VelocityInfoLogger(this.logger, this.proxy), + new VelocityProxyContainer(this.proxy)); this.proxyCore.onEnable(); } @@ -48,25 +50,32 @@ public class AdvancedPortalsVelocityPlugin { @Subscribe public void onPluginMessage(PluginMessageEvent event) { if (event.getIdentifier().equals(AP_CHANNEL)) { - if(event.getSource() instanceof ServerConnection serverConnection) { - this.proxyCore.incomingMessage(new VelocityProxyPlayerContainer(serverConnection.getPlayer(), AP_CHANNEL), event.getData()); + if (event.getSource() + instanceof ServerConnection serverConnection) { + this.proxyCore.incomingMessage( + new VelocityProxyPlayerContainer( + serverConnection.getPlayer(), AP_CHANNEL), + event.getData()); } - // So that client packets don't make it through to the servers, always trigger on this channel. + // So that client packets don't make it through to the servers, + // always trigger on this channel. event.setResult(PluginMessageEvent.ForwardResult.handled()); } } - @Subscribe public void postJoinEvent(ServerPostConnectEvent event) { event.getPlayer().getCurrentServer().ifPresent(serverConnection -> { - this.proxyCore.onServerConnect(new VelocityProxyServerContainer(serverConnection.getServer()), new VelocityProxyPlayerContainer(event.getPlayer(), AP_CHANNEL)); + this.proxyCore.onServerConnect( + new VelocityProxyServerContainer(serverConnection.getServer()), + new VelocityProxyPlayerContainer(event.getPlayer(), + AP_CHANNEL)); }); } @Subscribe public void onDisconnect(DisconnectEvent event) { - this.proxyCore.onPlayerDisconnect(new VelocityProxyPlayerContainer(event.getPlayer(), AP_CHANNEL)); + this.proxyCore.onPlayerDisconnect( + new VelocityProxyPlayerContainer(event.getPlayer(), AP_CHANNEL)); } - } diff --git a/velocity/src/main/java/com/sekwah/advancedportals/velocity/VelocityInfoLogger.java b/velocity/src/main/java/com/sekwah/advancedportals/velocity/VelocityInfoLogger.java index 415eb8ac..fc14334c 100644 --- a/velocity/src/main/java/com/sekwah/advancedportals/velocity/VelocityInfoLogger.java +++ b/velocity/src/main/java/com/sekwah/advancedportals/velocity/VelocityInfoLogger.java @@ -6,10 +6,14 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.slf4j.Logger; public class VelocityInfoLogger extends InfoLogger { - private final Logger logger; private final ProxyServer proxy; - private final LegacyComponentSerializer serializer = LegacyComponentSerializer.builder().character('&').hexCharacter('#').hexColors().build(); + private final LegacyComponentSerializer serializer = + LegacyComponentSerializer.builder() + .character('&') + .hexCharacter('#') + .hexColors() + .build(); public VelocityInfoLogger(Logger logger, ProxyServer proxy) { this.logger = logger; diff --git a/velocity/src/main/java/com/sekwah/advancedportals/velocity/connector/MinecraftToAnsi.java b/velocity/src/main/java/com/sekwah/advancedportals/velocity/connector/MinecraftToAnsi.java index 716a680f..c424cd01 100644 --- a/velocity/src/main/java/com/sekwah/advancedportals/velocity/connector/MinecraftToAnsi.java +++ b/velocity/src/main/java/com/sekwah/advancedportals/velocity/connector/MinecraftToAnsi.java @@ -4,12 +4,14 @@ import java.util.HashMap; import java.util.Map; /** - * I believe later versions of velocity have some component handlers for this, and I could just send it to the server as components - * but ive decided to throw this in for now just to use the plugin logger. Also, to try to clone the bungee behavior as close as possible. + * I believe later versions of velocity have some component handlers for this, + * and I could just send it to the server as components but ive decided to throw + * this in for now just to use the plugin logger. Also, to try to clone the + * bungee behavior as close as possible. */ public class MinecraftToAnsi { - - private static final Map minecraftToAnsiMap = new HashMap<>(); + private static final Map minecraftToAnsiMap = + new HashMap<>(); static { minecraftToAnsiMap.put('0', "\u001B[30m"); // Black @@ -28,12 +30,12 @@ public class MinecraftToAnsi { minecraftToAnsiMap.put('d', "\u001B[95m"); // Light Purple minecraftToAnsiMap.put('e', "\u001B[93m"); // Yellow minecraftToAnsiMap.put('f', "\u001B[97m"); // White - minecraftToAnsiMap.put('k', "\u001B[5m"); // Obfuscated (Blinking) - minecraftToAnsiMap.put('l', "\u001B[1m"); // Bold - minecraftToAnsiMap.put('m', "\u001B[9m"); // Strikethrough - minecraftToAnsiMap.put('n', "\u001B[4m"); // Underline - minecraftToAnsiMap.put('o', "\u001B[3m"); // Italic - minecraftToAnsiMap.put('r', "\u001B[0m"); // Reset + minecraftToAnsiMap.put('k', "\u001B[5m"); // Obfuscated (Blinking) + minecraftToAnsiMap.put('l', "\u001B[1m"); // Bold + minecraftToAnsiMap.put('m', "\u001B[9m"); // Strikethrough + minecraftToAnsiMap.put('n', "\u001B[4m"); // Underline + minecraftToAnsiMap.put('o', "\u001B[3m"); // Italic + minecraftToAnsiMap.put('r', "\u001B[0m"); // Reset } public static String convert(String text) { diff --git a/velocity/src/main/java/com/sekwah/advancedportals/velocity/connector/container/VelocityProxyContainer.java b/velocity/src/main/java/com/sekwah/advancedportals/velocity/connector/container/VelocityProxyContainer.java index d983be9d..263fd238 100644 --- a/velocity/src/main/java/com/sekwah/advancedportals/velocity/connector/container/VelocityProxyContainer.java +++ b/velocity/src/main/java/com/sekwah/advancedportals/velocity/connector/container/VelocityProxyContainer.java @@ -13,21 +13,32 @@ public class VelocityProxyContainer implements ProxyContainer { } @Override - public void invokeCommand(ProxyPlayerContainer proxyPlayer, String command) { - if(proxyPlayer instanceof VelocityProxyPlayerContainer playerContainer) { - this.proxy.getCommandManager().executeAsync(playerContainer.getPlayer(), command); + public void invokeCommand(ProxyPlayerContainer proxyPlayer, + String command) { + if (proxyPlayer + instanceof VelocityProxyPlayerContainer playerContainer) { + this.proxy.getCommandManager().executeAsync( + playerContainer.getPlayer(), command); } } @Override - public void transferPlayer(ProxyPlayerContainer proxyPlayer, String serverName) { - if(proxyPlayer instanceof VelocityProxyPlayerContainer playerContainer) { - this.proxy.getServer(serverName).ifPresentOrElse( - server -> { - playerContainer.getPlayer().createConnectionRequest(server).fireAndForget(); - }, - () -> playerContainer.getPlayer().sendMessage(Component.text("Could not find server: " + serverName)) - ); + public void transferPlayer(ProxyPlayerContainer proxyPlayer, + String serverName) { + if (proxyPlayer + instanceof VelocityProxyPlayerContainer playerContainer) { + this.proxy.getServer(serverName) + .ifPresentOrElse( + server + -> { + playerContainer.getPlayer() + .createConnectionRequest(server) + .fireAndForget(); + }, + () + -> playerContainer.getPlayer().sendMessage( + Component.text("Could not find server: " + + serverName))); } } } diff --git a/velocity/src/main/java/com/sekwah/advancedportals/velocity/connector/container/VelocityProxyPlayerContainer.java b/velocity/src/main/java/com/sekwah/advancedportals/velocity/connector/container/VelocityProxyPlayerContainer.java index 806c805d..53f7fe1a 100644 --- a/velocity/src/main/java/com/sekwah/advancedportals/velocity/connector/container/VelocityProxyPlayerContainer.java +++ b/velocity/src/main/java/com/sekwah/advancedportals/velocity/connector/container/VelocityProxyPlayerContainer.java @@ -5,11 +5,11 @@ import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier; public class VelocityProxyPlayerContainer implements ProxyPlayerContainer { - private final Player player; private final LegacyChannelIdentifier channel; - public VelocityProxyPlayerContainer(Player player, LegacyChannelIdentifier channel) { + public VelocityProxyPlayerContainer(Player player, + LegacyChannelIdentifier channel) { this.player = player; this.channel = channel; } @@ -26,7 +26,9 @@ public class VelocityProxyPlayerContainer implements ProxyPlayerContainer { @Override public void sendServerPluginMessage(byte[] data) { - player.getCurrentServer().ifPresent(serverConnection -> serverConnection.sendPluginMessage(channel, data)); + player.getCurrentServer().ifPresent( + serverConnection + -> serverConnection.sendPluginMessage(channel, data)); } public Player getPlayer() {