chore: run pre-commit

This commit is contained in:
Sekwah 2024-11-18 05:21:59 +00:00
parent a8c2e13900
commit 335b9f8bd9
95 changed files with 575 additions and 532 deletions

View File

@ -10,12 +10,14 @@ public class AdvancedPortalsBungeePlugin extends Plugin {
@Override @Override
public void onEnable() { 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(); this.proxyCore.onEnable();
getProxy().registerChannel(ProxyMessages.CHANNEL_NAME); getProxy().registerChannel(ProxyMessages.CHANNEL_NAME);
getProxy().getPluginManager().registerListener(this, new EventListener(this, this.proxyCore)); getProxy().getPluginManager().registerListener(
this, new EventListener(this, this.proxyCore));
} }
@Override @Override

View File

@ -1,7 +1,6 @@
package com.sekwah.advancedportals.bungee; package com.sekwah.advancedportals.bungee;
import com.sekwah.advancedportals.core.util.InfoLogger; import com.sekwah.advancedportals.core.util.InfoLogger;
import java.util.logging.Level; import java.util.logging.Level;
public class BungeeInfoLogger extends InfoLogger { public class BungeeInfoLogger extends InfoLogger {

View File

@ -13,35 +13,40 @@ import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventHandler;
public class EventListener implements Listener { public class EventListener implements Listener {
private final AdvancedPortalsBungeePlugin plugin; private final AdvancedPortalsBungeePlugin plugin;
private final AdvancedPortalsProxyCore proxyCore; private final AdvancedPortalsProxyCore proxyCore;
public EventListener(AdvancedPortalsBungeePlugin plugin, AdvancedPortalsProxyCore proxyCore) { public EventListener(AdvancedPortalsBungeePlugin plugin,
AdvancedPortalsProxyCore proxyCore) {
this.plugin = plugin; this.plugin = plugin;
this.proxyCore = proxyCore; this.proxyCore = proxyCore;
} }
@EventHandler @EventHandler
public void onMessageReceived(PluginMessageEvent event) { public void onMessageReceived(PluginMessageEvent event) {
if(!event.getTag().equalsIgnoreCase(ProxyMessages.CHANNEL_NAME)) return; if (!event.getTag().equalsIgnoreCase(ProxyMessages.CHANNEL_NAME))
return;
event.setCancelled(true); event.setCancelled(true);
if(!(event.getSender() instanceof Server)) return; if (!(event.getSender() instanceof Server))
return;
if(event.getReceiver() instanceof ProxiedPlayer player) { if (event.getReceiver() instanceof ProxiedPlayer player) {
this.proxyCore.incomingMessage(new BungeeProxyPlayerContainer(player), event.getData()); this.proxyCore.incomingMessage(
new BungeeProxyPlayerContainer(player), event.getData());
} }
} }
@EventHandler @EventHandler
public void onServerConnected(ServerConnectedEvent event) { 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 @EventHandler
public void onDisconnect(PlayerDisconnectEvent event) { public void onDisconnect(PlayerDisconnectEvent event) {
this.proxyCore.onPlayerDisconnect(new BungeeProxyPlayerContainer(event.getPlayer())); this.proxyCore.onPlayerDisconnect(
new BungeeProxyPlayerContainer(event.getPlayer()));
} }
} }

View File

@ -7,7 +7,6 @@ import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerConta
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
public class BungeeProxyContainer implements ProxyContainer { public class BungeeProxyContainer implements ProxyContainer {
private final AdvancedPortalsBungeePlugin plugin; private final AdvancedPortalsBungeePlugin plugin;
public BungeeProxyContainer(AdvancedPortalsBungeePlugin plugin) { public BungeeProxyContainer(AdvancedPortalsBungeePlugin plugin) {
@ -15,21 +14,26 @@ public class BungeeProxyContainer implements ProxyContainer {
} }
@Override @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 // Should never not be true but just to be safe
if(proxyPlayer instanceof BungeeProxyPlayerContainer playerContainer) { if (proxyPlayer instanceof BungeeProxyPlayerContainer playerContainer) {
plugin.getProxy().getPluginManager().dispatchCommand(playerContainer.getPlayer(), command); plugin.getProxy().getPluginManager().dispatchCommand(
playerContainer.getPlayer(), command);
} }
} }
@Override @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 // 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 serverInfo = plugin.getProxy().getServerInfo(serverName);
var player = playerContainer.getPlayer(); var player = playerContainer.getPlayer();
if(serverInfo == null) { if (serverInfo == null) {
player.sendMessage(new TextComponent(Lang.convertColors("&cCould not find server: &e") + serverName)); player.sendMessage(new TextComponent(
Lang.convertColors("&cCould not find server: &e")
+ serverName));
return; return;
} }
player.connect(serverInfo); player.connect(serverInfo);

View File

@ -5,7 +5,6 @@ import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerConta
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
public class BungeeProxyPlayerContainer implements ProxyPlayerContainer { public class BungeeProxyPlayerContainer implements ProxyPlayerContainer {
private final ProxiedPlayer player; private final ProxiedPlayer player;
public BungeeProxyPlayerContainer(ProxiedPlayer player) { public BungeeProxyPlayerContainer(ProxiedPlayer player) {
@ -29,5 +28,4 @@ public class BungeeProxyPlayerContainer implements ProxyPlayerContainer {
public void sendServerPluginMessage(byte[] data) { public void sendServerPluginMessage(byte[] data) {
this.player.getServer().sendData(ProxyMessages.CHANNEL_NAME, data); this.player.getServer().sendData(ProxyMessages.CHANNEL_NAME, data);
} }
} }

View File

@ -20,12 +20,10 @@ import com.sekwah.advancedportals.core.tags.*;
import com.sekwah.advancedportals.core.util.GameScheduler; import com.sekwah.advancedportals.core.util.GameScheduler;
import com.sekwah.advancedportals.core.util.InfoLogger; import com.sekwah.advancedportals.core.util.InfoLogger;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.Arrays;
public class AdvancedPortalsCore { public class AdvancedPortalsCore {
private final InfoLogger infoLogger; private final InfoLogger infoLogger;
private final DataStorage dataStorage; private final DataStorage dataStorage;
@ -74,8 +72,8 @@ public class AdvancedPortalsCore {
this.infoLogger = infoLogger; this.infoLogger = infoLogger;
int[] mcVersionTemp; int[] mcVersionTemp;
infoLogger.info("Loading Advanced Portals Core v" + BuildConstants.VERSION infoLogger.info("Loading Advanced Portals Core v"
+ " for MC: " + mcVersion); + BuildConstants.VERSION + " for MC: " + mcVersion);
try { try {
mcVersionTemp = Arrays.stream(mcVersion.split("\\.")) mcVersionTemp = Arrays.stream(mcVersion.split("\\."))
.mapToInt(Integer::parseInt) .mapToInt(Integer::parseInt)
@ -121,9 +119,11 @@ public class AdvancedPortalsCore {
private void registerChannels() { private void registerChannels() {
this.serverContainer.registerOutgoingChannel(BungeeTag.PACKET_CHANNEL); this.serverContainer.registerOutgoingChannel(BungeeTag.PACKET_CHANNEL);
if(this.configRepository.getEnableProxySupport()) { if (this.configRepository.getEnableProxySupport()) {
this.serverContainer.registerOutgoingChannel(ProxyMessages.CHANNEL_NAME); this.serverContainer.registerOutgoingChannel(
this.serverContainer.registerIncomingChannel(ProxyMessages.CHANNEL_NAME); ProxyMessages.CHANNEL_NAME);
this.serverContainer.registerIncomingChannel(
ProxyMessages.CHANNEL_NAME);
} }
} }
@ -148,7 +148,8 @@ public class AdvancedPortalsCore {
} }
private void registerPortalCommand(CommandRegister commandRegister) { private void registerPortalCommand(CommandRegister commandRegister) {
this.portalCommand = new CommandWithSubCommands(this, Permissions.PORTAL); this.portalCommand =
new CommandWithSubCommands(this, Permissions.PORTAL);
this.portalCommand.registerSubCommand("version", this.portalCommand.registerSubCommand("version",
new VersionSubCommand()); new VersionSubCommand());

View File

@ -18,7 +18,6 @@ import com.sekwah.advancedportals.core.services.PortalServices;
import com.sekwah.advancedportals.core.util.GameScheduler; import com.sekwah.advancedportals.core.util.GameScheduler;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.warphandler.TriggerType; import com.sekwah.advancedportals.core.warphandler.TriggerType;
import java.util.Objects; import java.util.Objects;
public class CoreListeners { public class CoreListeners {
@ -44,10 +43,12 @@ public class CoreListeners {
} }
private void setIfInPortal(PlayerContainer player) { private void setIfInPortal(PlayerContainer player) {
String inPortal = this.portalServices.inPortalRegionGetName(player.getBlockLoc()); String inPortal =
this.portalServices.inPortalRegionGetName(player.getBlockLoc());
if (inPortal == null) { 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); this.playerDataServices.getPlayerData(player).setInPortal(inPortal);
@ -61,7 +62,8 @@ public class CoreListeners {
this.playerDataServices.playerLeave(player); 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 buffer = ByteStreams.newDataInput(message);
var messageType = buffer.readUTF(); var messageType = buffer.readUTF();
@ -135,125 +137,126 @@ public class CoreListeners {
} }
} }
return true; return true;
} else if (itemInHandName.equals( }
"\u00A78End Portal Block Placer")) { else if (itemInHandName.equals("\u00A78End Portal Block Placer")) {
world.setBlock(blockPos, "END_PORTAL"); world.setBlock(blockPos, "END_PORTAL");
return true;
} else if (itemInHandName.equals("\u00A78Gateway Block Placer")) {
world.setBlock(blockPos, "END_GATEWAY");
world.disableBeacon(blockPos);
return true;
}
return true; return true;
} }
if (portalServices.inPortalRegionProtected(blockPos)) { else if (itemInHandName.equals("\u00A78Gateway Block Placer")) {
if (player != null) { world.setBlock(blockPos, "END_GATEWAY");
player.sendMessage(Lang.getNegativePrefix() world.disableBeacon(blockPos);
+ Lang.translate("portal.nobuild")); return true;
}
return false;
} }
return true; return true;
} }
if (portalServices.inPortalRegionProtected(blockPos)) {
/** if (player != null) {
* If the block is allowed to be interacted with e.g. a lever player.sendMessage(Lang.getNegativePrefix()
* @player player causing the event (or null if not a player) + Lang.translate("portal.nobuild"));
* @param blockPos }
* @return return false;
*/
public boolean blockInteract(PlayerContainer player,
BlockLocation blockPos) {
return true;
} }
return true;
}
/** /**
* @param player * If the block is allowed to be interacted with e.g. a lever
* @param blockLoc * @player player causing the event (or null if not a player)
* @param leftClick true = left click, false = right click * @param blockPos
* @return if player is allowed to interact with block * @return
*/ */
public boolean playerInteractWithBlock(PlayerContainer player, public boolean blockInteract(PlayerContainer player, BlockLocation blockPos) {
String blockMaterialname, return true;
String itemMaterialName, }
String itemName,
BlockLocation blockLoc, /**
boolean leftClick) { * @param player
if (itemName != null * @param blockLoc
&& Permissions.CREATE_PORTAL.hasPermission(player) * @param leftClick true = left click, false = right click
&& itemMaterialName.equalsIgnoreCase( * @return if player is allowed to interact with block
this.configRepository.getSelectorMaterial()) */
&& (!this.configRepository.getUseOnlySpecialAxe() public boolean playerInteractWithBlock(PlayerContainer player,
|| itemName.equals("\u00A7ePortal Region Selector"))) { String blockMaterialname,
this.playerDataServices.playerSelectorActivate(player, blockLoc, String itemMaterialName, String itemName,
leftClick); BlockLocation blockLoc,
return false; boolean leftClick) {
} else if (itemName != null && leftClick if (itemName != null && Permissions.CREATE_PORTAL.hasPermission(player)
&& Objects.equals(itemMaterialName, "PURPLE_WOOL") && itemMaterialName.equalsIgnoreCase(
&& itemName.equals("\u00A75Portal Block Placer") this.configRepository.getSelectorMaterial())
&& Permissions.BUILD.hasPermission(player)) { && (!this.configRepository.getUseOnlySpecialAxe()
if (!Objects.equals(blockMaterialname, "NETHER_PORTAL")) { || itemName.equals("\u00A7ePortal Region Selector"))) {
return false; this.playerDataServices.playerSelectorActivate(player, blockLoc,
} leftClick);
WorldContainer world = player.getWorld(); return false;
if (world.getBlockAxis(blockLoc) == BlockAxis.X) { } else if (itemName != null && leftClick
world.setBlockAxis(blockLoc, BlockAxis.Z); && Objects.equals(itemMaterialName, "PURPLE_WOOL")
} else { && itemName.equals("\u00A75Portal Block Placer")
world.setBlockAxis(blockLoc, BlockAxis.X); && Permissions.BUILD.hasPermission(player)) {
} if (!Objects.equals(blockMaterialname, "NETHER_PORTAL")) {
return false; return false;
} }
WorldContainer world = player.getWorld();
return true; if (world.getBlockAxis(blockLoc) == BlockAxis.X) {
} world.setBlockAxis(blockLoc, BlockAxis.Z);
} else {
public void worldChange(PlayerContainer player) { world.setBlockAxis(blockLoc, BlockAxis.X);
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;
}
} }
return false;
return !(portalServices.inPortalRegion(pos, 1) || portalServices.inPortalRegion(pos.addY((int) entity.getHeight()), 1));
} }
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); var playerData = playerDataServices.getPlayerData(player);
if (playerData.getPortalBlockCooldown()) { if (playerData.getPortalBlockCooldown()) {
return false; 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 !(portalServices.inPortalRegion(pos, 1)
return !configRepository.getDisablePhysicsEvents() || portalServices.inPortalRegion(
|| !portalServices.inPortalRegionProtected(blockLocation); 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);
}
} }

View File

@ -1,10 +1,10 @@
package com.sekwah.advancedportals.core; 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 { public class ProxyMessages {
/** /**
* Could split by channel messages we will handle it ourselves * Could split by channel messages we will handle it ourselves
*/ */

View File

@ -1,7 +1,6 @@
package com.sekwah.advancedportals.core.commands; package com.sekwah.advancedportals.core.commands;
import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer;
import java.util.List; import java.util.List;
/** /**

View File

@ -5,7 +5,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain
import com.sekwah.advancedportals.core.permissions.PermissionBuilder; import com.sekwah.advancedportals.core.permissions.PermissionBuilder;
import com.sekwah.advancedportals.core.registry.SubCommandRegistry; import com.sekwah.advancedportals.core.registry.SubCommandRegistry;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -18,7 +17,8 @@ public class CommandWithSubCommands implements CommandTemplate {
private final AdvancedPortalsCore pluginCore; private final AdvancedPortalsCore pluginCore;
private final PermissionBuilder permission; private final PermissionBuilder permission;
public CommandWithSubCommands(AdvancedPortalsCore advancedPortalsCore, PermissionBuilder permission) { public CommandWithSubCommands(AdvancedPortalsCore advancedPortalsCore,
PermissionBuilder permission) {
this.subCommandRegistry = new SubCommandRegistry(); this.subCommandRegistry = new SubCommandRegistry();
this.pluginCore = advancedPortalsCore; this.pluginCore = advancedPortalsCore;
this.permission = permission; this.permission = permission;
@ -57,8 +57,9 @@ public class CommandWithSubCommands implements CommandTemplate {
@Override @Override
public void onCommand(CommandSenderContainer sender, String commandExecuted, public void onCommand(CommandSenderContainer sender, String commandExecuted,
String[] args) { String[] args) {
if(!permission.hasPermission(sender)) { if (!permission.hasPermission(sender)) {
sender.sendMessage(Lang.getNegativePrefix() + Lang.translate("command.nopermission")); sender.sendMessage(Lang.getNegativePrefix()
+ Lang.translate("command.nopermission"));
return; return;
} }
if (args.length > 0) { if (args.length > 0) {

View File

@ -1,7 +1,6 @@
package com.sekwah.advancedportals.core.commands; package com.sekwah.advancedportals.core.commands;
import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer;
import java.util.List; import java.util.List;
public interface SubCommand { public interface SubCommand {

View File

@ -5,7 +5,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain
import com.sekwah.advancedportals.core.serializeddata.DataTag; import com.sekwah.advancedportals.core.serializeddata.DataTag;
import com.sekwah.advancedportals.core.util.TagReader; import com.sekwah.advancedportals.core.util.TagReader;
import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.Tag;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;

View File

@ -12,7 +12,6 @@ import com.sekwah.advancedportals.core.services.DestinationServices;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.util.TagReader; import com.sekwah.advancedportals.core.util.TagReader;
import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.Tag;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;

View File

@ -6,7 +6,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain
import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.permissions.Permissions;
import com.sekwah.advancedportals.core.services.DestinationServices; import com.sekwah.advancedportals.core.services.DestinationServices;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;

View File

@ -6,7 +6,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain
import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.permissions.Permissions;
import com.sekwah.advancedportals.core.services.DestinationServices; import com.sekwah.advancedportals.core.services.DestinationServices;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;

View File

@ -14,7 +14,6 @@ import com.sekwah.advancedportals.core.services.PlayerDataServices;
import com.sekwah.advancedportals.core.util.Debug; import com.sekwah.advancedportals.core.util.Debug;
import com.sekwah.advancedportals.core.util.GameScheduler; import com.sekwah.advancedportals.core.util.GameScheduler;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import java.awt.*; import java.awt.*;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;

View File

@ -6,7 +6,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain
import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.permissions.Permissions;
import com.sekwah.advancedportals.core.services.DestinationServices; import com.sekwah.advancedportals.core.services.DestinationServices;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;

View File

@ -15,7 +15,6 @@ import com.sekwah.advancedportals.core.tags.TriggerBlockTag;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.util.TagReader; import com.sekwah.advancedportals.core.util.TagReader;
import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.Tag;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;

View File

@ -6,7 +6,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain
import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.permissions.Permissions;
import com.sekwah.advancedportals.core.services.PortalServices; import com.sekwah.advancedportals.core.services.PortalServices;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import java.util.List; import java.util.List;
public class DisableBeaconSubCommand implements SubCommand { public class DisableBeaconSubCommand implements SubCommand {
@ -18,17 +17,22 @@ public class DisableBeaconSubCommand implements SubCommand {
if (args.length > 1) { if (args.length > 1) {
var portalName = args[1]; var portalName = args[1];
var portal = portalServices.getPortal(portalName); var portal = portalServices.getPortal(portalName);
if(portal == null) { if (portal == null) {
sender.sendMessage(Lang.getNegativePrefix() sender.sendMessage(
+ Lang.translateInsertVariables("command.portal.disablebeacon.notfound", portalName)); Lang.getNegativePrefix()
+ Lang.translateInsertVariables(
"command.portal.disablebeacon.notfound", portalName));
return; return;
} }
sender.sendMessage(Lang.getPositivePrefix() sender.sendMessage(
+ Lang.translateInsertVariables("command.portal.disablebeacon.complete", portalName)); Lang.getPositivePrefix()
+ Lang.translateInsertVariables(
"command.portal.disablebeacon.complete", portalName));
sender.getPlayerContainer().getWorld().disableBeacon(portal); sender.getPlayerContainer().getWorld().disableBeacon(portal);
} else { } else {
sender.sendMessage(Lang.getNegativePrefix() sender.sendMessage(
+ Lang.translate("command.portal.disablebeacon.noname")); Lang.getNegativePrefix()
+ Lang.translate("command.portal.disablebeacon.noname"));
} }
} }

View File

@ -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.connector.containers.PlayerContainer;
import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.permissions.Permissions;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import java.util.List; import java.util.List;
public class EndGatewayBlockSubCommand implements SubCommand { public class EndGatewayBlockSubCommand implements SubCommand {

View File

@ -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.connector.containers.PlayerContainer;
import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.permissions.Permissions;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import java.util.List; import java.util.List;
public class EndPortalBlockSubCommand implements SubCommand { public class EndPortalBlockSubCommand implements SubCommand {

View File

@ -7,7 +7,6 @@ import com.sekwah.advancedportals.core.permissions.Permissions;
import com.sekwah.advancedportals.core.services.PortalServices; import com.sekwah.advancedportals.core.services.PortalServices;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.util.TagReader; import com.sekwah.advancedportals.core.util.TagReader;
import java.util.List; import java.util.List;
public class InfoPortalSubCommand implements SubCommand { public class InfoPortalSubCommand implements SubCommand {
@ -19,17 +18,20 @@ public class InfoPortalSubCommand implements SubCommand {
if (args.length > 1) { if (args.length > 1) {
var portalName = args[1]; var portalName = args[1];
var portal = portalServices.getPortal(portalName); var portal = portalServices.getPortal(portalName);
if(portal == null) { if (portal == null) {
sender.sendMessage(Lang.getNegativePrefix() sender.sendMessage(
+ Lang.translateInsertVariables("command.portal.info.notfound", portalName)); Lang.getNegativePrefix()
+ Lang.translateInsertVariables(
"command.portal.info.notfound", portalName));
return; return;
} }
sender.sendMessage(Lang.getPositivePrefix() sender.sendMessage(Lang.getPositivePrefix()
+ Lang.translateInsertVariables("command.portal.info.complete", portalName)); + Lang.translateInsertVariables(
"command.portal.info.complete", portalName));
TagReader.printArgs(sender, portal.getArgs()); TagReader.printArgs(sender, portal.getArgs());
} else { } else {
sender.sendMessage(Lang.getNegativePrefix() sender.sendMessage(Lang.getNegativePrefix()
+ Lang.translate("command.portal.info.noname")); + Lang.translate("command.portal.info.noname"));
} }
} }

View File

@ -7,7 +7,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain
import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.permissions.Permissions;
import com.sekwah.advancedportals.core.repository.ConfigRepository; import com.sekwah.advancedportals.core.repository.ConfigRepository;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.InputStream; import java.io.InputStream;

View File

@ -6,7 +6,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain
import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.permissions.Permissions;
import com.sekwah.advancedportals.core.services.PortalServices; import com.sekwah.advancedportals.core.services.PortalServices;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -17,8 +16,8 @@ public class ListPortalsSubCommand implements SubCommand {
@Override @Override
public void onCommand(CommandSenderContainer sender, String[] args) { public void onCommand(CommandSenderContainer sender, String[] args) {
sender.sendMessage( sender.sendMessage(
Lang.getPositivePrefix() Lang.getPositivePrefix() + Lang.translate("command.portal.list")
+ Lang.translate("command.portal.list") + " " + " "
+ portalServices.getPortalNames().stream().sorted().collect( + portalServices.getPortalNames().stream().sorted().collect(
Collectors.joining(", "))); Collectors.joining(", ")));
} }

View File

@ -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.connector.containers.PlayerContainer;
import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.permissions.Permissions;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import java.util.List; import java.util.List;
public class PortalBlockSubCommand implements SubCommand { public class PortalBlockSubCommand implements SubCommand {

View File

@ -9,7 +9,6 @@ import com.sekwah.advancedportals.core.repository.ConfigRepository;
import com.sekwah.advancedportals.core.services.DestinationServices; import com.sekwah.advancedportals.core.services.DestinationServices;
import com.sekwah.advancedportals.core.services.PortalServices; import com.sekwah.advancedportals.core.services.PortalServices;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import java.util.List; import java.util.List;
public class ReloadPortalSubCommand implements SubCommand { public class ReloadPortalSubCommand implements SubCommand {

View File

@ -6,7 +6,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain
import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.permissions.Permissions;
import com.sekwah.advancedportals.core.services.PortalServices; import com.sekwah.advancedportals.core.services.PortalServices;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import java.util.List; import java.util.List;
public class RemovePortalSubCommand implements SubCommand { public class RemovePortalSubCommand implements SubCommand {

View File

@ -8,7 +8,6 @@ import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.permissions.Permissions;
import com.sekwah.advancedportals.core.repository.ConfigRepository; import com.sekwah.advancedportals.core.repository.ConfigRepository;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import java.util.List; import java.util.List;
public class SelectorSubCommand implements SubCommand { public class SelectorSubCommand implements SubCommand {

View File

@ -16,7 +16,6 @@ import com.sekwah.advancedportals.core.tags.NameTag;
import com.sekwah.advancedportals.core.util.Debug; import com.sekwah.advancedportals.core.util.Debug;
import com.sekwah.advancedportals.core.util.GameScheduler; import com.sekwah.advancedportals.core.util.GameScheduler;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import java.awt.*; import java.awt.*;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -120,12 +119,15 @@ public class ShowPortalSubCommand
player.getWorldName())) { player.getWorldName())) {
int widthX = Math.abs(tempData.getPos1().getPosX() int widthX = Math.abs(tempData.getPos1().getPosX()
- tempData.getPos2().getPosX()); - tempData.getPos2().getPosX());
int widthY = Math.abs(tempData.getPos1().getPosY() - tempData.getPos2().getPosY()); int widthY = Math.abs(tempData.getPos1().getPosY()
int widthZ = Math.abs(tempData.getPos1().getPosZ() - tempData.getPos2().getPosZ()); - tempData.getPos2().getPosY());
int widthZ = Math.abs(tempData.getPos1().getPosZ()
- tempData.getPos2().getPosZ());
int totalBlocks = widthX * widthY * widthZ; int totalBlocks = widthX * widthY * widthZ;
if (totalBlocks <= config.getMaxTriggerVisualisationSize()) if (totalBlocks <= config.getMaxTriggerVisualisationSize())
debugVisuals(player, tempData.getPos1(), tempData.getPos2(), debugVisuals(player, tempData.getPos1(),
SELECTION_COLOR, SHOW_TICKS); tempData.getPos2(), SELECTION_COLOR,
SHOW_TICKS);
} }
if (tempData.getPos1() != null if (tempData.getPos1() != null

View File

@ -4,14 +4,12 @@ import com.sekwah.advancedportals.core.BuildConstants;
import com.sekwah.advancedportals.core.commands.SubCommand; import com.sekwah.advancedportals.core.commands.SubCommand;
import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import java.util.List; import java.util.List;
public class VersionSubCommand implements SubCommand { public class VersionSubCommand implements SubCommand {
@Override @Override
public void onCommand(CommandSenderContainer sender, String[] args) { public void onCommand(CommandSenderContainer sender, String[] args) {
sender.sendMessage(Lang.getPositivePrefix() sender.sendMessage(Lang.getPositivePrefix() + " Advanced Portals v"
+ " Advanced Portals v"
+ BuildConstants.VERSION); + BuildConstants.VERSION);
} }

View File

@ -1,8 +1,3 @@
package com.sekwah.advancedportals.core.connector.containers; package com.sekwah.advancedportals.core.connector.containers;
public enum GameMode { public enum GameMode { SURVIVAL, CREATIVE, ADVENTURE, SPECTATOR }
SURVIVAL,
CREATIVE,
ADVENTURE,
SPECTATOR
}

View File

@ -1,7 +1,6 @@
package com.sekwah.advancedportals.core.connector.containers; package com.sekwah.advancedportals.core.connector.containers;
import com.sekwah.advancedportals.core.serializeddata.BlockLocation; import com.sekwah.advancedportals.core.serializeddata.BlockLocation;
import java.util.UUID; import java.util.UUID;
/** /**

View File

@ -1,7 +1,6 @@
package com.sekwah.advancedportals.core.connector.containers; package com.sekwah.advancedportals.core.connector.containers;
import com.sekwah.advancedportals.core.tags.CommandTag; import com.sekwah.advancedportals.core.tags.CommandTag;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;

View File

@ -9,7 +9,6 @@ import com.sekwah.advancedportals.core.serializeddata.PlayerLocation;
import com.sekwah.advancedportals.core.warphandler.ActivationData; import com.sekwah.advancedportals.core.warphandler.ActivationData;
import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.Tag;
import com.sekwah.advancedportals.core.warphandler.TriggerType; import com.sekwah.advancedportals.core.warphandler.TriggerType;
import java.util.*; import java.util.*;
/** /**
@ -87,7 +86,7 @@ public class Destination implements TagTarget {
public boolean activate(PlayerContainer player) { public boolean activate(PlayerContainer player) {
ActivationData data = new ActivationData(TriggerType.MANUAL); ActivationData data = new ActivationData(TriggerType.MANUAL);
if(this.portalActivate(player, data)) { if (this.portalActivate(player, data)) {
this.postActivate(player, data); this.postActivate(player, data);
return true; return true;
} }
@ -95,7 +94,7 @@ public class Destination implements TagTarget {
} }
public boolean portalActivate(PlayerContainer player, ActivationData data) { public boolean portalActivate(PlayerContainer player, ActivationData data) {
if(!isSorted) { if (!isSorted) {
updateDestiTagList(); updateDestiTagList();
} }
DataTag[] destiTags = new DataTag[args.size()]; DataTag[] destiTags = new DataTag[args.size()];
@ -104,16 +103,17 @@ public class Destination implements TagTarget {
destiTags[i++] = new DataTag(entry.getKey(), entry.getValue()); destiTags[i++] = new DataTag(entry.getKey(), entry.getValue());
} }
for (DataTag destiTag : destiTags) { for (DataTag destiTag : destiTags) {
Tag.Activation activationHandler = Tag.Activation activationHandler = tagRegistry.getActivationHandler(
tagRegistry.getActivationHandler(destiTag.NAME, Tag.TagType.DESTINATION); destiTag.NAME, Tag.TagType.DESTINATION);
if (activationHandler != null && !activationHandler.preActivated( if (activationHandler != null
&& !activationHandler.preActivated(
this, player, data, this.getArgValues(destiTag.NAME))) { this, player, data, this.getArgValues(destiTag.NAME))) {
return false; return false;
} }
} }
for (DataTag destiTag : destiTags) { for (DataTag destiTag : destiTags) {
Tag.Activation activationHandler = Tag.Activation activationHandler = tagRegistry.getActivationHandler(
tagRegistry.getActivationHandler(destiTag.NAME, Tag.TagType.DESTINATION); destiTag.NAME, Tag.TagType.DESTINATION);
if (activationHandler != null) { if (activationHandler != null) {
activationHandler.activated(this, player, data, activationHandler.activated(this, player, data,
this.getArgValues(destiTag.NAME)); this.getArgValues(destiTag.NAME));
@ -129,8 +129,8 @@ public class Destination implements TagTarget {
destiTags[i++] = new DataTag(entry.getKey(), entry.getValue()); destiTags[i++] = new DataTag(entry.getKey(), entry.getValue());
} }
for (DataTag destiTag : destiTags) { for (DataTag destiTag : destiTags) {
Tag.Activation activationHandler = Tag.Activation activationHandler = tagRegistry.getActivationHandler(
tagRegistry.getActivationHandler(destiTag.NAME, Tag.TagType.DESTINATION); destiTag.NAME, Tag.TagType.DESTINATION);
if (activationHandler != null) { if (activationHandler != null) {
activationHandler.postActivated( activationHandler.postActivated(
this, player, data, this.getArgValues(destiTag.NAME)); this, player, data, this.getArgValues(destiTag.NAME));

View File

@ -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.Config;
import com.sekwah.advancedportals.core.serializeddata.config.ConfigProvider; import com.sekwah.advancedportals.core.serializeddata.config.ConfigProvider;
import com.sekwah.advancedportals.core.util.InfoLogger; import com.sekwah.advancedportals.core.util.InfoLogger;
import javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.annotation.Nonnull;
public class AdvancedPortalsModule extends AbstractModule { public class AdvancedPortalsModule extends AbstractModule {
private Injector injector; private Injector injector;

View File

@ -6,7 +6,6 @@ import com.google.common.io.ByteStreams;
import com.sekwah.advancedportals.core.ProxyMessages; import com.sekwah.advancedportals.core.ProxyMessages;
public class ProxyCommandPacket implements Packet { public class ProxyCommandPacket implements Packet {
private final String command; private final String command;
public ProxyCommandPacket(String command) { public ProxyCommandPacket(String command) {

View File

@ -6,7 +6,6 @@ import com.google.common.io.ByteStreams;
import com.sekwah.advancedportals.core.ProxyMessages; import com.sekwah.advancedportals.core.ProxyMessages;
public class ProxyTransferDestiPacket implements Packet { public class ProxyTransferDestiPacket implements Packet {
private final String serverName; private final String serverName;
private final String destination; private final String destination;
@ -21,7 +20,6 @@ public class ProxyTransferDestiPacket implements Packet {
buffer.writeUTF(this.serverName); buffer.writeUTF(this.serverName);
buffer.writeUTF(this.destination); buffer.writeUTF(this.destination);
return buffer.toByteArray(); return buffer.toByteArray();
} }
public static ProxyTransferDestiPacket decode(ByteArrayDataInput buffer) { public static ProxyTransferDestiPacket decode(ByteArrayDataInput buffer) {

View File

@ -6,7 +6,6 @@ import com.google.common.io.ByteStreams;
import com.sekwah.advancedportals.core.ProxyMessages; import com.sekwah.advancedportals.core.ProxyMessages;
public class ProxyTransferPacket implements Packet { public class ProxyTransferPacket implements Packet {
private final String serverName; private final String serverName;
public ProxyTransferPacket(String serverName) { public ProxyTransferPacket(String serverName) {
@ -18,7 +17,6 @@ public class ProxyTransferPacket implements Packet {
buffer.writeUTF(ProxyMessages.PROXY_TRANSFER); buffer.writeUTF(ProxyMessages.PROXY_TRANSFER);
buffer.writeUTF(this.serverName); buffer.writeUTF(this.serverName);
return buffer.toByteArray(); return buffer.toByteArray();
} }
public static ProxyTransferPacket decode(ByteArrayDataInput buffer) { public static ProxyTransferPacket decode(ByteArrayDataInput buffer) {

View File

@ -6,7 +6,6 @@ import com.google.common.io.ByteStreams;
import com.sekwah.advancedportals.core.ProxyMessages; import com.sekwah.advancedportals.core.ProxyMessages;
public class ServerDestiPacket implements Packet { public class ServerDestiPacket implements Packet {
private final String destination; private final String destination;
public ServerDestiPacket(String destination) { public ServerDestiPacket(String destination) {
@ -18,7 +17,6 @@ public class ServerDestiPacket implements Packet {
buffer.writeUTF(ProxyMessages.SERVER_DESTI); buffer.writeUTF(ProxyMessages.SERVER_DESTI);
buffer.writeUTF(this.destination); buffer.writeUTF(this.destination);
return buffer.toByteArray(); return buffer.toByteArray();
} }
public static ServerDestiPacket decode(ByteArrayDataInput buffer) { public static ServerDestiPacket decode(ByteArrayDataInput buffer) {

View File

@ -2,7 +2,6 @@ package com.sekwah.advancedportals.core.permissions;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.sekwah.advancedportals.core.connector.containers.HasPermission; import com.sekwah.advancedportals.core.connector.containers.HasPermission;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -31,13 +30,15 @@ public class PermissionBuilder {
this.permissionDefault = parent.permissionDefault; this.permissionDefault = parent.permissionDefault;
} }
PermissionBuilder(String permissionTag, PermissionBuilder parent, PermissionDefault permissionDefault) { PermissionBuilder(String permissionTag, PermissionBuilder parent,
PermissionDefault permissionDefault) {
this.permissionTag = permissionTag; this.permissionTag = permissionTag;
this.parent = parent; this.parent = parent;
this.permissionDefault = permissionDefault; this.permissionDefault = permissionDefault;
} }
PermissionBuilder(String permissionTag, PermissionDefault permissionDefault) { PermissionBuilder(String permissionTag,
PermissionDefault permissionDefault) {
this.permissionTag = permissionTag; this.permissionTag = permissionTag;
this.parent = null; this.parent = null;
this.permissionDefault = permissionDefault; this.permissionDefault = permissionDefault;
@ -54,8 +55,10 @@ public class PermissionBuilder {
return child; return child;
} }
public PermissionBuilder createChild(String permissionTag, PermissionDefault permissionDefault) { public PermissionBuilder createChild(String permissionTag,
var child = new PermissionBuilder(permissionTag, this, permissionDefault); PermissionDefault permissionDefault) {
var child =
new PermissionBuilder(permissionTag, this, permissionDefault);
children.add(child); children.add(child);
return child; return child;

View File

@ -1,12 +1,12 @@
package com.sekwah.advancedportals.core.permissions; package com.sekwah.advancedportals.core.permissions;
public class Permissions { public class Permissions {
/** /**
* If true then a permission manager is being used and don't check for op * If true then a permission manager is being used and don't check for op
* for platforms like spigot this will always be true. * for platforms like spigot this will always be true.
* <p> * <p>
* 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; public static boolean hasPermissionManager = false;
@ -14,95 +14,116 @@ public class Permissions {
new PermissionBuilder("advancedportals").doNotExport(); new PermissionBuilder("advancedportals").doNotExport();
public static final PermissionBuilder BUILD = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = public static final PermissionBuilder LANG_UPDATE = PORTAL.createChild(
PORTAL.createChild("lang_update", PermissionBuilder.PermissionDefault.OP); "lang_update", PermissionBuilder.PermissionDefault.OP);
public static final PermissionBuilder RELOAD = public static final PermissionBuilder RELOAD =
PORTAL.createChild("reload", PermissionBuilder.PermissionDefault.OP); PORTAL.createChild("reload", PermissionBuilder.PermissionDefault.OP);
public static final PermissionBuilder DISABLE_BEACON = public static final PermissionBuilder DISABLE_BEACON = PORTAL.createChild(
PORTAL.createChild("disable_beacon", PermissionBuilder.PermissionDefault.OP); "disable_beacon", PermissionBuilder.PermissionDefault.OP);
public static final PermissionBuilder IMPORT = public static final PermissionBuilder IMPORT =
PORTAL.createChild("import", PermissionBuilder.PermissionDefault.OP); PORTAL.createChild("import", PermissionBuilder.PermissionDefault.OP);
public static final PermissionBuilder SHOW_PORTAL = 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 = 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 = 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 = 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 = 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 = 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 { static {
// These are to add children which will not be used directly e.g. advancedportals.* // These are to add children which will not be used directly e.g.
ROOT.createChild("*", PermissionBuilder.PermissionDefault.OP).description("Gives access to all portal commands") // advancedportals.*
.addGrantChild(CREATE_PORTAL) ROOT.createChild("*", PermissionBuilder.PermissionDefault.OP)
.addGrantChild(CREATE_DESTI) .description("Gives access to all portal commands")
.addGrantChild(DESTI) .addGrantChild(CREATE_PORTAL)
.addGrantChild(PORTAL) .addGrantChild(CREATE_DESTI)
.addGrantChild(TELEPORT_DESTI) .addGrantChild(DESTI)
.addGrantChild(REMOVE_DESTI) .addGrantChild(PORTAL)
.addGrantChild(LIST_DESTI) .addGrantChild(TELEPORT_DESTI)
.addGrantChild(SHOW_DESTI) .addGrantChild(REMOVE_DESTI)
.addGrantChild(SELECTOR) .addGrantChild(LIST_DESTI)
.addGrantChild(REMOVE_PORTAL) .addGrantChild(SHOW_DESTI)
.addGrantChild(LIST_PORTAL) .addGrantChild(SELECTOR)
.addGrantChild(LANG_UPDATE) .addGrantChild(REMOVE_PORTAL)
.addGrantChild(RELOAD) .addGrantChild(LIST_PORTAL)
.addGrantChild(DISABLE_BEACON) .addGrantChild(LANG_UPDATE)
.addGrantChild(IMPORT) .addGrantChild(RELOAD)
.addGrantChild(SHOW_PORTAL) .addGrantChild(DISABLE_BEACON)
.addGrantChild(PORTAL_INFO) .addGrantChild(IMPORT)
.addGrantChild(BUILD); .addGrantChild(SHOW_PORTAL)
.addGrantChild(PORTAL_INFO)
.addGrantChild(BUILD);
CREATE_COMMAND_LEVEL.createChild("*", PermissionBuilder.PermissionDefault.OP).description("Gives access to all command level raisers") CREATE_COMMAND_LEVEL
.addGrantChild(CREATE_COMMAND_OP) .createChild("*", PermissionBuilder.PermissionDefault.OP)
.addGrantChild(CREATE_COMMAND_CONSOLE) .description("Gives access to all command level raisers")
.addGrantChild(CREATE_COMMAND_PERMS); .addGrantChild(CREATE_COMMAND_OP)
.addGrantChild(CREATE_COMMAND_CONSOLE)
.addGrantChild(CREATE_COMMAND_PERMS);
} }
} }

View File

@ -14,7 +14,6 @@ import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.warphandler.ActivationData; import com.sekwah.advancedportals.core.warphandler.ActivationData;
import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.Tag;
import com.sekwah.advancedportals.core.warphandler.TriggerType; import com.sekwah.advancedportals.core.warphandler.TriggerType;
import java.util.*; import java.util.*;
/** /**
@ -137,8 +136,9 @@ public class AdvancedPortal implements TagTarget {
* @param triggerType The type of trigger that activated the portal * @param triggerType The type of trigger that activated the portal
* @return Whether the portal was successfully activated * @return Whether the portal was successfully activated
*/ */
public ActivationResult activate(PlayerContainer player, TriggerType triggerType) { public ActivationResult activate(PlayerContainer player,
if(!isSorted) { TriggerType triggerType) {
if (!isSorted) {
updatePortalTagList(); updatePortalTagList();
} }
@ -162,14 +162,17 @@ public class AdvancedPortal implements TagTarget {
ActivationData data = new ActivationData(triggerType); ActivationData data = new ActivationData(triggerType);
for (DataTag portalTag : this.portalTags) { for (DataTag portalTag : this.portalTags) {
Tag.Activation activationHandler = Tag.Activation activationHandler = tagRegistry.getActivationHandler(
tagRegistry.getActivationHandler(portalTag.NAME, Tag.TagType.PORTAL); portalTag.NAME, Tag.TagType.PORTAL);
if (activationHandler != null) { if (activationHandler != null) {
var preActivated = activationHandler.preActivated( var preActivated = activationHandler.preActivated(
this, player, data, this.getArgValues(portalTag.NAME)); this, player, data, this.getArgValues(portalTag.NAME));
if(!preActivated) { if (!preActivated) {
if(activationHandler instanceof Tag.DenyBehavior denyBehavior && denyBehavior.getDenyBehavior() == Tag.DenyBehavior.Behaviour.SILENT) { if (activationHandler
instanceof Tag.DenyBehavior denyBehavior
&& denyBehavior.getDenyBehavior()
== Tag.DenyBehavior.Behaviour.SILENT) {
return ActivationResult.FAILED_DO_NOTHING; return ActivationResult.FAILED_DO_NOTHING;
} }
return ActivationResult.FAILED_DO_KNOCKBACK; return ActivationResult.FAILED_DO_KNOCKBACK;
@ -177,8 +180,8 @@ public class AdvancedPortal implements TagTarget {
} }
} }
for (DataTag portalTag : this.portalTags) { for (DataTag portalTag : this.portalTags) {
Tag.Activation activationHandler = Tag.Activation activationHandler = tagRegistry.getActivationHandler(
tagRegistry.getActivationHandler(portalTag.NAME, Tag.TagType.PORTAL); portalTag.NAME, Tag.TagType.PORTAL);
if (activationHandler != null if (activationHandler != null
&& !activationHandler.activated( && !activationHandler.activated(
this, player, data, this.getArgValues(portalTag.NAME))) { this, player, data, this.getArgValues(portalTag.NAME))) {
@ -186,8 +189,8 @@ public class AdvancedPortal implements TagTarget {
} }
} }
for (DataTag portalTag : this.portalTags) { for (DataTag portalTag : this.portalTags) {
Tag.Activation activationHandler = Tag.Activation activationHandler = tagRegistry.getActivationHandler(
tagRegistry.getActivationHandler(portalTag.NAME, Tag.TagType.PORTAL); portalTag.NAME, Tag.TagType.PORTAL);
if (activationHandler != null) { if (activationHandler != null) {
activationHandler.postActivated( activationHandler.postActivated(
this, player, data, this.getArgValues(portalTag.NAME)); this, player, data, this.getArgValues(portalTag.NAME));

View File

@ -3,7 +3,6 @@ package com.sekwah.advancedportals.core.registry;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.sekwah.advancedportals.core.commands.SubCommand; import com.sekwah.advancedportals.core.commands.SubCommand;
import com.sekwah.advancedportals.core.util.InfoLogger; import com.sekwah.advancedportals.core.util.InfoLogger;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;

View File

@ -3,7 +3,6 @@ package com.sekwah.advancedportals.core.registry;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.sekwah.advancedportals.core.AdvancedPortalsCore; import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.Tag;
import java.util.*; import java.util.*;
/** /**
@ -34,10 +33,12 @@ public class TagRegistry {
* @param arg * @param arg
* @return * @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); var tag = this.activationTags.get(arg);
if (tag != null && Arrays.asList(tag.getTagTypes()).contains(targetType)) { if (tag != null
return tag; && Arrays.asList(tag.getTagTypes()).contains(targetType)) {
return tag;
} }
return null; return null;
} }

View File

@ -4,7 +4,6 @@ import com.google.inject.Inject;
import com.sekwah.advancedportals.core.AdvancedPortalsCore; import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.effect.WarpEffect; import com.sekwah.advancedportals.core.effect.WarpEffect;
import com.sekwah.advancedportals.core.util.InfoLogger; import com.sekwah.advancedportals.core.util.InfoLogger;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

View File

@ -5,7 +5,6 @@ import com.sekwah.advancedportals.core.repository.ConfigRepository;
import com.sekwah.advancedportals.core.serializeddata.DataStorage; import com.sekwah.advancedportals.core.serializeddata.DataStorage;
import com.sekwah.advancedportals.core.serializeddata.config.CommandPortalConfig; import com.sekwah.advancedportals.core.serializeddata.config.CommandPortalConfig;
import com.sekwah.advancedportals.core.serializeddata.config.Config; import com.sekwah.advancedportals.core.serializeddata.config.Config;
import java.util.HashMap; import java.util.HashMap;
@Singleton @Singleton

View File

@ -5,10 +5,9 @@ import com.sekwah.advancedportals.core.destination.Destination;
import com.sekwah.advancedportals.core.repository.IDestinationRepository; import com.sekwah.advancedportals.core.repository.IDestinationRepository;
import com.sekwah.advancedportals.core.serializeddata.DataStorage; import com.sekwah.advancedportals.core.serializeddata.DataStorage;
import com.sekwah.advancedportals.core.tags.NameTag; import com.sekwah.advancedportals.core.tags.NameTag;
import javax.inject.Singleton;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.inject.Singleton;
@Singleton @Singleton
public class DestinationRepositoryImpl implements IDestinationRepository { public class DestinationRepositoryImpl implements IDestinationRepository {

View File

@ -4,7 +4,6 @@ import com.google.inject.Inject;
import com.sekwah.advancedportals.core.repository.IPlayerDataRepository; import com.sekwah.advancedportals.core.repository.IPlayerDataRepository;
import com.sekwah.advancedportals.core.serializeddata.DataStorage; import com.sekwah.advancedportals.core.serializeddata.DataStorage;
import com.sekwah.advancedportals.core.serializeddata.PlayerData; import com.sekwah.advancedportals.core.serializeddata.PlayerData;
import java.util.List; import java.util.List;
public class PlayerDataRepositoryImpl implements IPlayerDataRepository { public class PlayerDataRepositoryImpl implements IPlayerDataRepository {

View File

@ -7,7 +7,6 @@ import com.sekwah.advancedportals.core.portal.AdvancedPortal;
import com.sekwah.advancedportals.core.repository.IPortalRepository; import com.sekwah.advancedportals.core.repository.IPortalRepository;
import com.sekwah.advancedportals.core.serializeddata.DataStorage; import com.sekwah.advancedportals.core.serializeddata.DataStorage;
import com.sekwah.advancedportals.core.tags.NameTag; import com.sekwah.advancedportals.core.tags.NameTag;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -70,9 +69,9 @@ public class PortalRepositoryImpl implements IPortalRepository {
if (portal != null) { if (portal != null) {
AdvancedPortalsCore.getInstance() AdvancedPortalsCore.getInstance()
.getModule() .getModule()
.getInjector() .getInjector()
.injectMembers(portal); .injectMembers(portal);
} }
// Forces the name tag to be up-to-date on load // Forces the name tag to be up-to-date on load

View File

@ -3,18 +3,17 @@ package com.sekwah.advancedportals.core.serializeddata;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.sekwah.advancedportals.core.AdvancedPortalsCore; import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.util.InfoLogger; 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.io.*;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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 { public class DataStorage {
private final File dataFolder; private final File dataFolder;

View File

@ -1,18 +1,17 @@
package com.sekwah.advancedportals.core.serializeddata; package com.sekwah.advancedportals.core.serializeddata;
import com.sekwah.advancedportals.core.util.InfoLogger; 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.Array;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; 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<T> extends Constructor { public class ReflectiveConstructor<T> extends Constructor {
private static final Unsafe unsafe = getUnsafe(); private static final Unsafe unsafe = getUnsafe();

View File

@ -12,12 +12,11 @@ import com.sekwah.advancedportals.core.serializeddata.DataTag;
import com.sekwah.advancedportals.core.serializeddata.PlayerLocation; import com.sekwah.advancedportals.core.serializeddata.PlayerLocation;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.Tag;
import javax.inject.Singleton;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.inject.Singleton;
@Singleton @Singleton
public class DestinationServices { public class DestinationServices {
@ -135,21 +134,22 @@ public class DestinationServices {
return teleportToDestination(name, playerContainer, false); return teleportToDestination(name, playerContainer, false);
} }
public boolean teleportToDestination(String name, public boolean teleportToDestination(String name, PlayerContainer player,
PlayerContainer player, boolean doEffect) { boolean doEffect) {
if(doEffect && configRepository.getWarpEffectEnabled()) { if (doEffect && configRepository.getWarpEffectEnabled()) {
var warpEffectVisual = warpEffectRegistry.getVisualEffect(configRepository.getWarpVisual()); var warpEffectVisual = warpEffectRegistry.getVisualEffect(
configRepository.getWarpVisual());
if (warpEffectVisual != null) { if (warpEffectVisual != null) {
warpEffectVisual.onWarpVisual(player, WarpEffect.Action.ENTER); warpEffectVisual.onWarpVisual(player, WarpEffect.Action.ENTER);
} }
var warpEffectSound = warpEffectRegistry.getSoundEffect(configRepository.getWarpSound()); var warpEffectSound = warpEffectRegistry.getSoundEffect(
configRepository.getWarpSound());
if (warpEffectSound != null) { if (warpEffectSound != null) {
warpEffectSound.onWarpSound(player, WarpEffect.Action.ENTER); warpEffectSound.onWarpSound(player, WarpEffect.Action.ENTER);
} }
} }
if (this.destinationRepository.containsKey(name)) { if (this.destinationRepository.containsKey(name)) {
player.teleport( player.teleport(this.destinationRepository.get(name).getLoc());
this.destinationRepository.get(name).getLoc());
return true; return true;
} }
return false; return false;

View File

@ -7,11 +7,10 @@ import com.sekwah.advancedportals.core.repository.IPlayerDataRepository;
import com.sekwah.advancedportals.core.serializeddata.BlockLocation; import com.sekwah.advancedportals.core.serializeddata.BlockLocation;
import com.sekwah.advancedportals.core.serializeddata.PlayerData; import com.sekwah.advancedportals.core.serializeddata.PlayerData;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import javax.inject.Singleton;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import javax.inject.Singleton;
@Singleton @Singleton
public final class PlayerDataServices { public final class PlayerDataServices {

View File

@ -15,9 +15,8 @@ import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.util.PlayerUtils; import com.sekwah.advancedportals.core.util.PlayerUtils;
import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.Tag;
import com.sekwah.advancedportals.core.warphandler.TriggerType; import com.sekwah.advancedportals.core.warphandler.TriggerType;
import javax.inject.Singleton;
import java.util.*; import java.util.*;
import javax.inject.Singleton;
@Singleton @Singleton
public class PortalServices { public class PortalServices {
@ -100,7 +99,8 @@ public class PortalServices {
PORTAL_DENIED 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 blockLoc = toLoc.toBlockPos();
var blockEntityTopLoc = blockLoc.addY(player.getHeight()); var blockEntityTopLoc = blockLoc.addY(player.getHeight());
var world = player.getWorld(); var world = player.getWorld();
@ -114,7 +114,7 @@ public class PortalServices {
|| (portal.isLocationInPortal(blockEntityTopLoc) || (portal.isLocationInPortal(blockEntityTopLoc)
&& portal.isTriggerBlock(blockEntityTopMaterial))) { && portal.isTriggerBlock(blockEntityTopMaterial))) {
var portalName = portal.getName(); var portalName = portal.getName();
if(Objects.equals(playerData.inPortal(), portalName)) { if (Objects.equals(playerData.inPortal(), portalName)) {
return PortalActivationResult.PORTAL_DENIED; return PortalActivationResult.PORTAL_DENIED;
} }
switch (portal.activate(player, triggerType)) { switch (portal.activate(player, triggerType)) {

View File

@ -7,17 +7,14 @@ import com.sekwah.advancedportals.core.registry.TagTarget;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.warphandler.ActivationData; import com.sekwah.advancedportals.core.warphandler.ActivationData;
import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.Tag;
import java.util.Random; import java.util.Random;
public class BungeeTag implements Tag.Activation { public class BungeeTag implements Tag.Activation {
public static final String PACKET_CHANNEL = "BungeeCord"; public static final String PACKET_CHANNEL = "BungeeCord";
public static String TAG_NAME = "bungee"; public static String TAG_NAME = "bungee";
private final TagType[] tagTypes = private final TagType[] tagTypes = new TagType[] {TagType.PORTAL};
new TagType[] {TagType.PORTAL};
private final Random random = new Random(); private final Random random = new Random();
@ -42,17 +39,19 @@ public class BungeeTag implements Tag.Activation {
} }
@Override @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; return true;
} }
@Override @Override
public void postActivated(TagTarget target, PlayerContainer player, ActivationData activationData, String[] argData) { public void postActivated(TagTarget target, PlayerContainer player,
ActivationData activationData, String[] argData) {
} }
@Override @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)]; String selectedArg = argData[random.nextInt(argData.length)];
ByteArrayDataOutput outForSend = ByteStreams.newDataOutput(); ByteArrayDataOutput outForSend = ByteStreams.newDataOutput();

View File

@ -10,7 +10,6 @@ import com.sekwah.advancedportals.core.repository.ConfigRepository;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.warphandler.ActivationData; import com.sekwah.advancedportals.core.warphandler.ActivationData;
import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.Tag;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation { 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; break;
case '%': case '%':
if (!commandPortals.proxy || !configRepository.getEnableProxySupport()) { if (!commandPortals.proxy
|| !configRepository.getEnableProxySupport()) {
player.sendMessage( player.sendMessage(
Lang.getNegativePrefix() Lang.getNegativePrefix()
+ Lang.translate("tag.command.proxy.disabled")); + Lang.translate("tag.command.proxy.disabled"));
@ -128,8 +128,10 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation {
CommandLevel.PERMISSION_WILDCARD); CommandLevel.PERMISSION_WILDCARD);
break; break;
case '%': case '%':
var packet = new ProxyCommandPacket(formattedCommand.substring(1)); var packet =
player.sendPacket(ProxyMessages.CHANNEL_NAME, packet.encode()); new ProxyCommandPacket(formattedCommand.substring(1));
player.sendPacket(ProxyMessages.CHANNEL_NAME,
packet.encode());
break; break;
default: default:
player.getServer().dispatchCommand(player.getUUID(), player.getServer().dispatchCommand(player.getUUID(),

View File

@ -10,9 +10,8 @@ import com.sekwah.advancedportals.core.util.InfoLogger;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.warphandler.ActivationData; import com.sekwah.advancedportals.core.warphandler.ActivationData;
import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.Tag;
import javax.annotation.Nullable;
import java.util.Random; import java.util.Random;
import javax.annotation.Nullable;
public class CooldownTag implements Tag.Activation, Tag.Creation { public class CooldownTag implements Tag.Activation, Tag.Creation {
@Inject @Inject

View File

@ -12,7 +12,6 @@ import com.sekwah.advancedportals.core.services.DestinationServices;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.warphandler.ActivationData; import com.sekwah.advancedportals.core.warphandler.ActivationData;
import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.Tag;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
@ -65,24 +64,28 @@ public class DestiTag implements Tag.Activation, Tag.AutoComplete, Tag.Split {
activeData.setMetadata(TAG_NAME, selectedArg); activeData.setMetadata(TAG_NAME, selectedArg);
if(activeData.getMetadata(ProxyTag.TAG_NAME) != null) { if (activeData.getMetadata(ProxyTag.TAG_NAME) != null) {
return true; return true;
} }
if(destinationServices.getDestination(selectedArg) == null) { if (destinationServices.getDestination(selectedArg) == null) {
player.sendMessage(Lang.getNegativePrefix() + Lang.translateInsertVariables("desti.error.notfound", selectedArg)); player.sendMessage(Lang.getNegativePrefix()
+ Lang.translateInsertVariables(
"desti.error.notfound", selectedArg));
return false; return false;
} }
// Check and trigger all tags on the destination // Check and trigger all tags on the destination
Destination destination = destinationServices.getDestination(selectedArg); Destination destination =
destinationServices.getDestination(selectedArg);
if (destination != null) { if (destination != null) {
for (var destiTag : destination.getArgs()) { for (var destiTag : destination.getArgs()) {
Tag.Activation activationHandler = Tag.Activation activationHandler =
tagRegistry.getActivationHandler(destiTag.NAME, Tag.TagType.DESTINATION); tagRegistry.getActivationHandler(destiTag.NAME,
Tag.TagType.DESTINATION);
if (activationHandler != null if (activationHandler != null
&& !activationHandler.preActivated(target, player, activeData, destiTag.VALUES)) { && !activationHandler.preActivated(
target, player, activeData, destiTag.VALUES)) {
return false; return false;
} }
} }
@ -94,23 +97,29 @@ public class DestiTag implements Tag.Activation, Tag.AutoComplete, Tag.Split {
@Override @Override
public void postActivated(TagTarget target, PlayerContainer player, public void postActivated(TagTarget target, PlayerContainer player,
ActivationData activationData, String[] argData) { ActivationData activationData, String[] argData) {
if(activationData.getMetadata(ProxyTag.TAG_NAME) != null) { if (activationData.getMetadata(ProxyTag.TAG_NAME) != null) {
return; return;
} }
var selectedArg = activationData.getMetadata(TAG_NAME); var selectedArg = activationData.getMetadata(TAG_NAME);
Destination destination = destinationServices.getDestination(selectedArg); Destination destination =
destinationServices.getDestination(selectedArg);
if (destination != null) { if (destination != null) {
for (var destiTag : destination.getArgs()) { for (var destiTag : destination.getArgs()) {
Tag.Activation activationHandler = Tag.Activation activationHandler =
tagRegistry.getActivationHandler(destiTag.NAME, Tag.TagType.DESTINATION); tagRegistry.getActivationHandler(destiTag.NAME,
Tag.TagType.DESTINATION);
if (activationHandler != null) { if (activationHandler != null) {
activationHandler.postActivated(target, player, activationData, argData); activationHandler.postActivated(target, player,
activationData, argData);
} }
} }
var message = activationData.getMetadata(MessageTag.TAG_NAME); var message = activationData.getMetadata(MessageTag.TAG_NAME);
if(message == null) { if (message == null) {
sendMessage(player, Lang.translateInsertVariables("desti.warpdesti.warp", destination.getName().replaceAll("_", " "))); 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 @Override
public boolean activated(TagTarget target, PlayerContainer player, public boolean activated(TagTarget target, PlayerContainer player,
ActivationData activationData, String[] argData) { ActivationData activationData, String[] argData) {
if(activationData.getMetadata(ProxyTag.TAG_NAME) != null) { if (activationData.getMetadata(ProxyTag.TAG_NAME) != null) {
return true; return true;
} }
@ -126,22 +135,27 @@ public class DestiTag implements Tag.Activation, Tag.AutoComplete, Tag.Split {
Destination destination = Destination destination =
destinationServices.getDestination(selectedArg); destinationServices.getDestination(selectedArg);
if (destination != null) { if (destination != null) {
var warpEffectVisual = warpEffectRegistry.getVisualEffect(configRepository.getWarpVisual()); var warpEffectVisual = warpEffectRegistry.getVisualEffect(
var warpEffectSound = warpEffectRegistry.getSoundEffect(configRepository.getWarpSound()); configRepository.getWarpVisual());
if(configRepository.getWarpEffectEnabled()) { var warpEffectSound = warpEffectRegistry.getSoundEffect(
configRepository.getWarpSound());
if (configRepository.getWarpEffectEnabled()) {
if (warpEffectVisual != null) { if (warpEffectVisual != null) {
warpEffectVisual.onWarpVisual(player, WarpEffect.Action.ENTER); warpEffectVisual.onWarpVisual(player,
WarpEffect.Action.ENTER);
} }
if (warpEffectSound != null) { if (warpEffectSound != null) {
warpEffectSound.onWarpSound(player, WarpEffect.Action.ENTER); warpEffectSound.onWarpSound(player,
WarpEffect.Action.ENTER);
} }
} }
player.teleport(destination.getLoc()); player.teleport(destination.getLoc());
if(configRepository.getWarpEffectEnabled()) { if (configRepository.getWarpEffectEnabled()) {
if (warpEffectVisual != null) { if (warpEffectVisual != null) {
warpEffectVisual.onWarpVisual(player, WarpEffect.Action.EXIT); warpEffectVisual.onWarpVisual(player,
WarpEffect.Action.EXIT);
} }
if (warpEffectSound != null) { if (warpEffectSound != null) {
warpEffectSound.onWarpSound(player, WarpEffect.Action.EXIT); 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) { public void sendMessage(PlayerContainer player, String message) {
if(this.configRepository.warpMessageOnActionBar()) { if (this.configRepository.warpMessageOnActionBar()) {
player.sendActionBar(Lang.convertColors(message)); player.sendActionBar(Lang.convertColors(message));
} } else if (this.configRepository.warpMessageInChat()) {
else if(this.configRepository.warpMessageInChat()) { player.sendMessage(Lang.getPositivePrefix() + " "
player.sendMessage(Lang.getPositivePrefix() + " " + Lang.convertColors(message)); + Lang.convertColors(message));
} }
} }

View File

@ -7,11 +7,9 @@ import com.sekwah.advancedportals.core.repository.ConfigRepository;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.warphandler.ActivationData; import com.sekwah.advancedportals.core.warphandler.ActivationData;
import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.Tag;
import java.util.Random; import java.util.Random;
public class MessageTag implements Tag.Activation { public class MessageTag implements Tag.Activation {
@Inject @Inject
ConfigRepository configRepository; ConfigRepository configRepository;
@ -43,26 +41,30 @@ public class MessageTag implements Tag.Activation {
} }
@Override @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; return true;
} }
@Override @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 destination = activationData.getMetadata(DestiTag.TAG_NAME);
var message = activationData.getMetadata(TAG_NAME); var message = activationData.getMetadata(TAG_NAME);
if(destination == null) { if (destination == null) {
destination = ""; destination = "";
} else { } else {
destination = destination.replaceAll("_", " "); destination = destination.replaceAll("_", " ");
} }
sendMessage(player, message.replaceAll("@desti", destination).replaceAll("@player", player.getName())); sendMessage(player,
message.replaceAll("@desti", destination)
.replaceAll("@player", player.getName()));
} }
@Override @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)]; String selectedArg = argData[random.nextInt(argData.length)];
activeData.setMetadata(TAG_NAME, selectedArg); activeData.setMetadata(TAG_NAME, selectedArg);
activeData.setWarpStatus(ActivationData.WarpedStatus.ACTIVATED); activeData.setWarpStatus(ActivationData.WarpedStatus.ACTIVATED);
@ -70,11 +72,11 @@ public class MessageTag implements Tag.Activation {
} }
public void sendMessage(PlayerContainer player, String message) { public void sendMessage(PlayerContainer player, String message) {
if(this.configRepository.warpMessageOnActionBar()) { if (this.configRepository.warpMessageOnActionBar()) {
player.sendActionBar(Lang.convertColors(message)); player.sendActionBar(Lang.convertColors(message));
} } else if (this.configRepository.warpMessageInChat()) {
else if(this.configRepository.warpMessageInChat()) { player.sendMessage(Lang.getPositivePrefix() + " "
player.sendMessage(Lang.getPositivePrefix() + " " + Lang.convertColors(message)); + Lang.convertColors(message));
} }
} }
} }

View File

@ -4,7 +4,6 @@ import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
import com.sekwah.advancedportals.core.registry.TagTarget; import com.sekwah.advancedportals.core.registry.TagTarget;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.Tag;
import java.util.List; import java.util.List;
/** /**

View File

@ -8,7 +8,6 @@ import com.sekwah.advancedportals.core.util.InfoLogger;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.warphandler.ActivationData; import com.sekwah.advancedportals.core.warphandler.ActivationData;
import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.Tag;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.inject.Inject; import javax.inject.Inject;
@ -26,7 +25,8 @@ public class PermissionTag implements Tag.Activation {
private final String[] aliases = new String[] {"perm"}; 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 @Override
public TagType[] getTagTypes() { public TagType[] getTagTypes() {
@ -53,16 +53,18 @@ public class PermissionTag implements Tag.Activation {
public boolean preActivated(TagTarget target, PlayerContainer player, public boolean preActivated(TagTarget target, PlayerContainer player,
ActivationData activeData, String[] argData) { ActivationData activeData, String[] argData) {
var permission = argData[0]; var permission = argData[0];
if(permission.startsWith("!")) { if (permission.startsWith("!")) {
permission = permission.substring(1); permission = permission.substring(1);
if(player.hasPermission(permission)) { if (player.hasPermission(permission)) {
player.sendMessage(Lang.getNegativePrefix() + Lang.translate("portal.error.nopermission")); player.sendMessage(
Lang.getNegativePrefix()
+ Lang.translate("portal.error.nopermission"));
return false; return false;
} }
return true; return true;
} } else if (!player.hasPermission(argData[0])) {
else if (!player.hasPermission(argData[0])) { player.sendMessage(Lang.getNegativePrefix()
player.sendMessage(Lang.getNegativePrefix() + Lang.translate("portal.error.nopermission")); + Lang.translate("portal.error.nopermission"));
return false; return false;
} }
return true; return true;

View File

@ -10,13 +10,13 @@ import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.warphandler.ActivationData; import com.sekwah.advancedportals.core.warphandler.ActivationData;
import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.Tag;
import com.sekwah.advancedportals.core.warphandler.TriggerType; import com.sekwah.advancedportals.core.warphandler.TriggerType;
import javax.annotation.Nullable;
import javax.inject.Inject;
import java.util.List; import java.util.List;
import java.util.Objects; 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 @Inject
PlayerDataServices playerDataServices; PlayerDataServices playerDataServices;
@ -56,10 +56,11 @@ public class PortalEventTag implements Tag.Activation, Tag.AutoComplete, Tag.Den
@Override @Override
public boolean preActivated(TagTarget target, PlayerContainer player, public boolean preActivated(TagTarget target, PlayerContainer player,
ActivationData activeData, String[] argData) { ActivationData activeData, String[] argData) {
if(player.getGameMode() == GameMode.CREATIVE) { if (player.getGameMode() == GameMode.CREATIVE) {
return true; return true;
} }
return !Objects.equals(argData[0], "true") || activeData.getTriggerType() == TriggerType.PORTAL; return !Objects.equals(argData[0], "true")
|| activeData.getTriggerType() == TriggerType.PORTAL;
} }
@Override @Override

View File

@ -10,18 +10,15 @@ import com.sekwah.advancedportals.core.repository.ConfigRepository;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.warphandler.ActivationData; import com.sekwah.advancedportals.core.warphandler.ActivationData;
import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.Tag;
import java.util.Random; import java.util.Random;
public class ProxyTag implements Tag.Activation, Tag.OrderPriority, Tag.Split { public class ProxyTag implements Tag.Activation, Tag.OrderPriority, Tag.Split {
@Inject @Inject
ConfigRepository configRepository; ConfigRepository configRepository;
public static String TAG_NAME = "proxy"; public static String TAG_NAME = "proxy";
private final TagType[] tagTypes = private final TagType[] tagTypes = new TagType[] {TagType.PORTAL};
new TagType[] {TagType.PORTAL};
private final Random random = new Random(); private final Random random = new Random();
@ -46,22 +43,24 @@ public class ProxyTag implements Tag.Activation, Tag.OrderPriority, Tag.Split {
} }
@Override @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)]; String selectedArg = argData[random.nextInt(argData.length)];
activeData.setMetadata(TAG_NAME, selectedArg); activeData.setMetadata(TAG_NAME, selectedArg);
return true; return true;
} }
@Override @Override
public void postActivated(TagTarget target, PlayerContainer player, ActivationData activationData, String[] argData) { public void postActivated(TagTarget target, PlayerContainer player,
ActivationData activationData, String[] argData) {
} }
@Override @Override
public boolean activated(TagTarget target, PlayerContainer player, ActivationData activeData, String[] argData) { public boolean activated(TagTarget target, PlayerContainer player,
ActivationData activeData, String[] argData) {
if(!this.configRepository.getEnableProxySupport()) { if (!this.configRepository.getEnableProxySupport()) {
player.sendMessage(Lang.getNegativePrefix() + Lang.translate("tag.proxy.notenabled")); player.sendMessage(Lang.getNegativePrefix()
+ Lang.translate("tag.proxy.notenabled"));
return false; return false;
} }
@ -69,7 +68,9 @@ public class ProxyTag implements Tag.Activation, Tag.OrderPriority, Tag.Split {
var desti = activeData.getMetadata(DestiTag.TAG_NAME); 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()); player.sendPacket(ProxyMessages.CHANNEL_NAME, packet.encode());
activeData.setWarpStatus(ActivationData.WarpedStatus.WARPED); activeData.setWarpStatus(ActivationData.WarpedStatus.WARPED);
return true; return true;

View File

@ -4,9 +4,8 @@ import com.google.inject.Inject;
import com.sekwah.advancedportals.core.connector.containers.ServerContainer; import com.sekwah.advancedportals.core.connector.containers.ServerContainer;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.Tag;
import javax.annotation.Nullable;
import java.util.List; import java.util.List;
import javax.annotation.Nullable;
public class TriggerBlockTag implements Tag.AutoComplete, Tag.Split { public class TriggerBlockTag implements Tag.AutoComplete, Tag.Split {
@Inject @Inject

View File

@ -2,7 +2,6 @@ package com.sekwah.advancedportals.core.util;
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
import com.sekwah.advancedportals.core.serializeddata.BlockLocation; import com.sekwah.advancedportals.core.serializeddata.BlockLocation;
import java.awt.*; import java.awt.*;
public class Debug { public class Debug {

View File

@ -4,7 +4,6 @@ import com.sekwah.advancedportals.core.serializeddata.BlockLocation;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import io.netty.handler.codec.EncoderException; import io.netty.handler.codec.EncoderException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
/** /**

View File

@ -1,8 +1,8 @@
package com.sekwah.advancedportals.core.util; package com.sekwah.advancedportals.core.util;
import javax.inject.Singleton;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import javax.inject.Singleton;
/** /**
* For all delayed and repeating tasks. * For all delayed and repeating tasks.

View File

@ -2,7 +2,6 @@ package com.sekwah.advancedportals.core.util;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.sekwah.advancedportals.core.serializeddata.DataStorage; import com.sekwah.advancedportals.core.serializeddata.DataStorage;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URL; import java.net.URL;

View File

@ -2,7 +2,6 @@ package com.sekwah.advancedportals.core.util;
import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer; import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer;
import com.sekwah.advancedportals.core.serializeddata.DataTag; import com.sekwah.advancedportals.core.serializeddata.DataTag;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -98,18 +97,16 @@ public class TagReader {
return null; return null;
} }
public static void printArgs(CommandSenderContainer sender, public static void printArgs(CommandSenderContainer sender,
List<DataTag> dataTags) { List<DataTag> dataTags) {
for (DataTag tag : dataTags) { for (DataTag tag : dataTags) {
if (tag.VALUES.length == 1) { if (tag.VALUES.length == 1) {
sender.sendMessage(" \u00A7a" + tag.NAME + "\u00A77:\u00A7e" sender.sendMessage(" \u00A7a" + tag.NAME + "\u00A77:\u00A7e"
+ tag.VALUES[0]); + tag.VALUES[0]);
} else { } else {
for (int i = 0; i < tag.VALUES.length; i++) { for (int i = 0; i < tag.VALUES.length; i++) {
sender.sendMessage(" \u00A7a" + tag.NAME + "\u00A77[" + i sender.sendMessage(" \u00A7a" + tag.NAME + "\u00A77[" + i
+ "]:\u00A7e" + tag.VALUES[i]); + "]:\u00A7e" + tag.VALUES[i]);
} }
} }
} }

View File

@ -1,7 +1,6 @@
package com.sekwah.advancedportals.core.warphandler; package com.sekwah.advancedportals.core.warphandler;
import com.sekwah.advancedportals.core.serializeddata.PlayerLocation; import com.sekwah.advancedportals.core.serializeddata.PlayerLocation;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

View File

@ -2,9 +2,8 @@ package com.sekwah.advancedportals.core.warphandler;
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
import com.sekwah.advancedportals.core.registry.TagTarget; import com.sekwah.advancedportals.core.registry.TagTarget;
import javax.annotation.Nullable;
import java.util.List; 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 * If a tag can be used for any of them then either make it cast the target or

View File

@ -1,7 +1,3 @@
package com.sekwah.advancedportals.core.warphandler; package com.sekwah.advancedportals.core.warphandler;
public enum TriggerType { public enum TriggerType { MOVEMENT, PORTAL, MANUAL }
MOVEMENT,
PORTAL,
MANUAL
}

View File

@ -1,5 +1,5 @@
package com.sekwah.advancedportals.core; package com.sekwah.advancedportals.core;
public class BuildConstants { public class BuildConstants {
public static final String VERSION = "${version}"; public static final String VERSION = "${version}";
} }

View File

@ -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.ProxyJoinData;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerContainer; import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerContainer;
import com.sekwah.advancedportals.proxycore.connector.container.ProxyServerContainer; import com.sekwah.advancedportals.proxycore.connector.container.ProxyServerContainer;
import java.util.HashMap; import java.util.HashMap;
public class AdvancedPortalsProxyCore { public class AdvancedPortalsProxyCore {
private final InfoLogger logger; private final InfoLogger logger;
private final ProxyContainer proxyContainer; private final ProxyContainer proxyContainer;
public HashMap<String, ProxyJoinData> playerJoinMap = new HashMap<>(); public HashMap<String, ProxyJoinData> playerJoinMap = new HashMap<>();
public AdvancedPortalsProxyCore(InfoLogger logger, ProxyContainer proxyContainer) { public AdvancedPortalsProxyCore(InfoLogger logger,
ProxyContainer proxyContainer) {
this.logger = logger; this.logger = logger;
this.proxyContainer = proxyContainer; this.proxyContainer = proxyContainer;
} }
@ -35,11 +34,14 @@ public class AdvancedPortalsProxyCore {
this.logger.info(Lang.convertColors("&cDisabling plugin!")); this.logger.info(Lang.convertColors("&cDisabling plugin!"));
} }
public void onServerConnect(ProxyServerContainer server, ProxyPlayerContainer player) { public void onServerConnect(ProxyServerContainer server,
if(this.playerJoinMap.containsKey(player.getUUID())) { ProxyPlayerContainer player) {
if (this.playerJoinMap.containsKey(player.getUUID())) {
var joinData = this.playerJoinMap.get(player.getUUID()); var joinData = this.playerJoinMap.get(player.getUUID());
if(joinData.isExpired()) return; if (joinData.isExpired())
player.sendServerPluginMessage(new ServerDestiPacket(joinData.destination).encode()); return;
player.sendServerPluginMessage(
new ServerDestiPacket(joinData.destination).encode());
this.playerJoinMap.remove(player.getUUID()); 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 player
* @param message * @param message
*/ */
public void incomingMessage(ProxyPlayerContainer player, byte[] message) { public void incomingMessage(ProxyPlayerContainer player, byte[] message) {
var buffer = ByteStreams.newDataInput(message); var buffer = ByteStreams.newDataInput(message);
var messageType = buffer.readUTF(); 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 // Might be a bit overboard for some as they'll only have one value, but
// the encode behavior in the packets // try to keep the decode behavior with the encode behavior in the
// packets
switch (messageType) { switch (messageType) {
case ProxyMessages.PROXY_TRANSFER -> { case ProxyMessages.PROXY_TRANSFER -> {
var transferPacket = ProxyTransferPacket.decode(buffer); var transferPacket = ProxyTransferPacket.decode(buffer);

View File

@ -4,5 +4,4 @@ public interface ProxyContainer {
void invokeCommand(ProxyPlayerContainer proxyPlayer, String command); void invokeCommand(ProxyPlayerContainer proxyPlayer, String command);
void transferPlayer(ProxyPlayerContainer proxyPlayer, String serverName); void transferPlayer(ProxyPlayerContainer proxyPlayer, String serverName);
} }

View File

@ -1,7 +1,6 @@
package com.sekwah.advancedportals.proxycore.connector.container; package com.sekwah.advancedportals.proxycore.connector.container;
public class ProxyJoinData { public class ProxyJoinData {
public final String destination; public final String destination;
public final String serverName; public final String serverName;
public final long joinTime; public final long joinTime;
@ -13,6 +12,7 @@ public class ProxyJoinData {
} }
public boolean isExpired() { public boolean isExpired() {
return System.currentTimeMillis() - this.joinTime > 1000 * 15; // 15 seconds return System.currentTimeMillis() - this.joinTime
> 1000 * 15; // 15 seconds
} }
} }

View File

@ -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.connector.container.SpigotServerContainer;
import com.sekwah.advancedportals.spigot.metrics.Metrics; import com.sekwah.advancedportals.spigot.metrics.Metrics;
import com.sekwah.advancedportals.spigot.warpeffects.SpigotWarpEffects; import com.sekwah.advancedportals.spigot.warpeffects.SpigotWarpEffects;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.bukkit.plugin.java.JavaPlugin;
public class AdvancedPortalsPlugin extends JavaPlugin { public class AdvancedPortalsPlugin extends JavaPlugin {
private AdvancedPortalsCore portalsCore; private AdvancedPortalsCore portalsCore;

View File

@ -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.SpigotPlayerContainer;
import com.sekwah.advancedportals.spigot.connector.container.SpigotWorldContainer; import com.sekwah.advancedportals.spigot.connector.container.SpigotWorldContainer;
import com.sekwah.advancedportals.spigot.utils.ContainerHelpers; import com.sekwah.advancedportals.spigot.utils.ContainerHelpers;
import java.util.List;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -23,8 +24,6 @@ import org.bukkit.event.entity.*;
import org.bukkit.event.player.*; import org.bukkit.event.player.*;
import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.ChunkLoadEvent;
import java.util.List;
/** /**
* Some of these will be passed to the core listener to handle the events, * Some of these will be passed to the core listener to handle the events,
* others it's easier to just check directly. * others it's easier to just check directly.
@ -68,7 +67,8 @@ public class Listeners implements Listener {
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onPortalEvent(PlayerPortalEvent event) { public void onPortalEvent(PlayerPortalEvent event) {
if (!this.coreListeners.playerPortalEvent( if (!this.coreListeners.playerPortalEvent(
new SpigotPlayerContainer(event.getPlayer()), ContainerHelpers.toPlayerLocation(event.getFrom()))) { new SpigotPlayerContainer(event.getPlayer()),
ContainerHelpers.toPlayerLocation(event.getFrom()))) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -210,25 +210,26 @@ public class Listeners implements Listener {
} }
} }
@EventHandler @EventHandler
public void onChunkLoad(ChunkLoadEvent event) { public void onChunkLoad(ChunkLoadEvent event) {
if(!configRepository.getDisableGatewayBeam()) { if (!configRepository.getDisableGatewayBeam()) {
return; return;
} }
SpigotWorldContainer world = new SpigotWorldContainer(event.getWorld()); SpigotWorldContainer world = new SpigotWorldContainer(event.getWorld());
BlockState[] tileEntities = event.getChunk().getTileEntities(); BlockState[] tileEntities = event.getChunk().getTileEntities();
for(BlockState block : tileEntities) { for (BlockState block : tileEntities) {
if(block.getType() == Material.END_GATEWAY) { if (block.getType() == Material.END_GATEWAY) {
var loc = block.getLocation(); var loc = block.getLocation();
if(portalServices.inPortalRegion(new BlockLocation(loc.getWorld().getName(), if (portalServices.inPortalRegion(
loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), 2)) { new BlockLocation(loc.getWorld().getName(),
loc.getBlockX(), loc.getBlockY(),
loc.getBlockZ()),
2)) {
EndGateway tileState = (EndGateway) block; EndGateway tileState = (EndGateway) block;
tileState.setAge(Long.MIN_VALUE); tileState.setAge(Long.MIN_VALUE);
tileState.update(); tileState.update();
} }
} }
} }
} }
} }

View File

@ -1,11 +1,9 @@
package com.sekwah.advancedportals.spigot; package com.sekwah.advancedportals.spigot;
import com.sekwah.advancedportals.core.permissions.PermissionBuilder; import com.sekwah.advancedportals.core.permissions.PermissionBuilder;
import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.permissions.Permissions;
public class PermissionsGeneratorSpigot { public class PermissionsGeneratorSpigot {
private PermissionsGeneratorSpigot() { private PermissionsGeneratorSpigot() {
} }
@ -16,25 +14,28 @@ public class PermissionsGeneratorSpigot {
public static String toPermBlock(PermissionBuilder permission) { public static String toPermBlock(PermissionBuilder permission) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
String indent = " "; String indent = " ";
if(!permission.isDoNotExport()) { if (!permission.isDoNotExport()) {
builder.append(indent).append(permission).append(":\n"); builder.append(indent).append(permission).append(":\n");
builder.append(indent).append(indent).append("default: "); builder.append(indent).append(indent).append("default: ");
builder.append(permission.getPermissionDefault().toString().toLowerCase()); builder.append(
permission.getPermissionDefault().toString().toLowerCase());
builder.append("\n"); builder.append("\n");
if(permission.getDescription() != null) { if (permission.getDescription() != null) {
builder.append(indent).append(indent).append("description: "); builder.append(indent).append(indent).append("description: ");
builder.append(permission.getDescription()).append("\n"); builder.append(permission.getDescription()).append("\n");
} }
var children = permission.getGrantChildren(); var children = permission.getGrantChildren();
if(!children.isEmpty()) { if (!children.isEmpty()) {
builder.append(indent).append(indent).append("children:\n"); 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(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)); builder.append(toPermBlock(child));
} }
return builder.toString(); return builder.toString();

View File

@ -1,7 +1,6 @@
package com.sekwah.advancedportals.spigot; package com.sekwah.advancedportals.spigot;
import com.sekwah.advancedportals.core.util.InfoLogger; import com.sekwah.advancedportals.core.util.InfoLogger;
import java.util.logging.Level; import java.util.logging.Level;
public class SpigotInfoLogger extends InfoLogger { public class SpigotInfoLogger extends InfoLogger {

View File

@ -12,14 +12,12 @@ import com.sekwah.advancedportals.core.services.PortalServices;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin; import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.spigot.commands.subcommands.portal.importer.ConfigAccessor; import com.sekwah.advancedportals.spigot.commands.subcommands.portal.importer.ConfigAccessor;
import org.bukkit.configuration.ConfigurationSection;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.bukkit.configuration.ConfigurationSection;
public class ImportPortalSubCommand implements SubCommand { public class ImportPortalSubCommand implements SubCommand {
@Inject @Inject
DestinationServices destinationServices; DestinationServices destinationServices;
@ -77,7 +75,7 @@ public class ImportPortalSubCommand implements SubCommand {
var bungee = config.getString(portalName + ".bungee"); var bungee = config.getString(portalName + ".bungee");
if (bungee != null) { if (bungee != null) {
if(destination == null) { if (destination == null) {
args.add(new DataTag("bungee", bungee.split(","))); args.add(new DataTag("bungee", bungee.split(",")));
} else { } else {
args.add(new DataTag("proxy", bungee.split(","))); args.add(new DataTag("proxy", bungee.split(",")));

View File

@ -1,12 +1,11 @@
package com.sekwah.advancedportals.spigot.commands.subcommands.portal.importer; 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.File;
import java.io.IOException; import java.io.IOException;
import java.util.logging.Level; 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 { public class ConfigAccessor {
private final String fileName; private final String fileName;

View File

@ -2,13 +2,12 @@ package com.sekwah.advancedportals.spigot.connector.command;
import com.sekwah.advancedportals.core.commands.CommandTemplate; import com.sekwah.advancedportals.core.commands.CommandTemplate;
import com.sekwah.advancedportals.spigot.connector.container.SpigotCommandSenderContainer; import com.sekwah.advancedportals.spigot.connector.container.SpigotCommandSenderContainer;
import java.util.List;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter; import org.bukkit.command.TabCompleter;
import java.util.List;
public class SpigotCommandHandler implements CommandExecutor, TabCompleter { public class SpigotCommandHandler implements CommandExecutor, TabCompleter {
private final CommandTemplate commandExecutor; private final CommandTemplate commandExecutor;

View File

@ -9,6 +9,8 @@ import com.sekwah.advancedportals.core.serializeddata.BlockLocation;
import com.sekwah.advancedportals.core.serializeddata.PlayerLocation; import com.sekwah.advancedportals.core.serializeddata.PlayerLocation;
import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin; import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.spigot.reflection.MinecraftCustomPayload; 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.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -18,9 +20,6 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; 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 * Just a temporary container for whenever advanced portals needs to get data
* from a player * from a player
@ -49,7 +48,8 @@ public class SpigotPlayerContainer
@Override @Override
public void sendActionBar(String message) { public void sendActionBar(String message) {
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message)); player.spigot().sendMessage(ChatMessageType.ACTION_BAR,
TextComponent.fromLegacyText(message));
} }
@Override @Override

View File

@ -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.connector.containers.WorldContainer;
import com.sekwah.advancedportals.core.tags.CommandTag; import com.sekwah.advancedportals.core.tags.CommandTag;
import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin; 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.Material;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionAttachment; import org.bukkit.permissions.PermissionAttachment;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
public class SpigotServerContainer implements ServerContainer { public class SpigotServerContainer implements ServerContainer {
@Inject @Inject
private CoreListeners coreListeners; private CoreListeners coreListeners;
@ -75,13 +74,17 @@ public class SpigotServerContainer implements ServerContainer {
@Override @Override
public void registerOutgoingChannel(String channel) { public void registerOutgoingChannel(String channel) {
server.getMessenger().registerOutgoingPluginChannel(AdvancedPortalsPlugin.getInstance(), channel); server.getMessenger().registerOutgoingPluginChannel(
AdvancedPortalsPlugin.getInstance(), channel);
} }
@Override @Override
public void registerIncomingChannel(String channel) { public void registerIncomingChannel(String channel) {
server.getMessenger().registerIncomingPluginChannel(AdvancedPortalsPlugin.getInstance(), channel, server.getMessenger().registerIncomingPluginChannel(
(s, player, bytes) -> coreListeners.incomingMessage(new SpigotPlayerContainer(player), s, bytes)); AdvancedPortalsPlugin.getInstance(), channel,
(s, player, bytes)
-> coreListeners.incomingMessage(
new SpigotPlayerContainer(player), s, bytes));
} }
// Check if it's a material compatible with making portals // Check if it's a material compatible with making portals

View File

@ -14,12 +14,14 @@ import org.bukkit.block.data.Orientable;
public class SpigotWorldContainer implements WorldContainer { public class SpigotWorldContainer implements WorldContainer {
private final World world; 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; private static boolean endGatewaySetAgeExists;
static { static {
try { try {
endGatewaySetAgeExists = EndGateway.class.getMethod("setAge", long.class) != null; endGatewaySetAgeExists =
EndGateway.class.getMethod("setAge", long.class) != null;
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
endGatewaySetAgeExists = false; endGatewaySetAgeExists = false;
} }
@ -74,11 +76,13 @@ public class SpigotWorldContainer implements WorldContainer {
@Override @Override
public void disableBeacon(BlockLocation location) { public void disableBeacon(BlockLocation location) {
if(!endGatewaySetAgeExists) return; if (!endGatewaySetAgeExists)
var block = this.world.getBlockAt(location.getPosX(), location.getPosY(), return;
location.getPosZ()); var block = this.world.getBlockAt(
location.getPosX(), location.getPosY(), location.getPosZ());
var blockType = block.getType(); 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.setAge(Long.MIN_VALUE);
endGateway.update(); endGateway.update();
} }
@ -86,15 +90,16 @@ public class SpigotWorldContainer implements WorldContainer {
@Override @Override
public void disableBeacon(AdvancedPortal portal) { public void disableBeacon(AdvancedPortal portal) {
if(!endGatewaySetAgeExists) return; if (!endGatewaySetAgeExists)
return;
BlockLocation maxLoc = portal.getMaxLoc(); BlockLocation maxLoc = portal.getMaxLoc();
BlockLocation minLoc = portal.getMinLoc(); BlockLocation minLoc = portal.getMinLoc();
for (int x = minLoc.getPosX(); x <= maxLoc.getPosX(); x++) { for (int x = minLoc.getPosX(); x <= maxLoc.getPosX(); x++) {
for (int y = minLoc.getPosY(); y <= maxLoc.getPosY(); y++) { for (int y = minLoc.getPosY(); y <= maxLoc.getPosY(); y++) {
for (int z = minLoc.getPosZ(); z <= maxLoc.getPosZ(); z++) { for (int z = minLoc.getPosZ(); z <= maxLoc.getPosZ(); z++) {
Block block = world.getBlockAt(x, y, 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(); EndGateway tileState = (EndGateway) block.getState();
tileState.setAge(Long.MIN_VALUE); tileState.setAge(Long.MIN_VALUE);
tileState.update(); tileState.update();

View File

@ -3,14 +3,6 @@ package com.sekwah.advancedportals.spigot.metrics;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; 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.io.*;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -20,6 +12,13 @@ import java.util.*;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.zip.GZIPOutputStream; 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. * bStats collects some data for plugin authors.

View File

@ -1,9 +1,8 @@
package com.sekwah.advancedportals.spigot.reflection; package com.sekwah.advancedportals.spigot.reflection;
import org.bukkit.entity.Player;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Method; 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 * Just a util class to force spigot to allow us to have fun with the

View File

@ -1,7 +1,6 @@
package com.sekwah.advancedportals.spigot.warpeffects; package com.sekwah.advancedportals.spigot.warpeffects;
import com.sekwah.advancedportals.core.registry.WarpEffectRegistry; import com.sekwah.advancedportals.core.registry.WarpEffectRegistry;
import javax.inject.Inject; import javax.inject.Inject;
public class SpigotWarpEffects { public class SpigotWarpEffects {

View File

@ -14,4 +14,4 @@ commands:
aliases: [desti] aliases: [desti]
usage: /<command> usage: /<command>
permissions: permissions:
${permissions} ${permissions}

View File

@ -18,11 +18,11 @@ import com.velocitypowered.api.proxy.ServerConnection;
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier; import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
import org.slf4j.Logger; 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/", url = "https://www.spigotmc.org/resources/advanced-portals.14356/",
version = BuildConstants.VERSION) version = BuildConstants.VERSION)
public class AdvancedPortalsVelocityPlugin { public class AdvancedPortalsVelocityPlugin {
private AdvancedPortalsProxyCore proxyCore; private AdvancedPortalsProxyCore proxyCore;
private final Logger logger; private final Logger logger;
@ -34,7 +34,9 @@ public class AdvancedPortalsVelocityPlugin {
public AdvancedPortalsVelocityPlugin(ProxyServer proxy, Logger logger) { public AdvancedPortalsVelocityPlugin(ProxyServer proxy, Logger logger) {
this.proxy = proxy; this.proxy = proxy;
this.logger = logger; 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(); this.proxyCore.onEnable();
} }
@ -48,25 +50,32 @@ public class AdvancedPortalsVelocityPlugin {
@Subscribe @Subscribe
public void onPluginMessage(PluginMessageEvent event) { public void onPluginMessage(PluginMessageEvent event) {
if (event.getIdentifier().equals(AP_CHANNEL)) { if (event.getIdentifier().equals(AP_CHANNEL)) {
if(event.getSource() instanceof ServerConnection serverConnection) { if (event.getSource()
this.proxyCore.incomingMessage(new VelocityProxyPlayerContainer(serverConnection.getPlayer(), AP_CHANNEL), event.getData()); 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()); event.setResult(PluginMessageEvent.ForwardResult.handled());
} }
} }
@Subscribe @Subscribe
public void postJoinEvent(ServerPostConnectEvent event) { public void postJoinEvent(ServerPostConnectEvent event) {
event.getPlayer().getCurrentServer().ifPresent(serverConnection -> { 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 @Subscribe
public void onDisconnect(DisconnectEvent event) { public void onDisconnect(DisconnectEvent event) {
this.proxyCore.onPlayerDisconnect(new VelocityProxyPlayerContainer(event.getPlayer(), AP_CHANNEL)); this.proxyCore.onPlayerDisconnect(
new VelocityProxyPlayerContainer(event.getPlayer(), AP_CHANNEL));
} }
} }

View File

@ -6,10 +6,14 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.slf4j.Logger; import org.slf4j.Logger;
public class VelocityInfoLogger extends InfoLogger { public class VelocityInfoLogger extends InfoLogger {
private final Logger logger; private final Logger logger;
private final ProxyServer proxy; 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) { public VelocityInfoLogger(Logger logger, ProxyServer proxy) {
this.logger = logger; this.logger = logger;

View File

@ -4,12 +4,14 @@ import java.util.HashMap;
import java.util.Map; 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 * I believe later versions of velocity have some component handlers for this,
* 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. * 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 { public class MinecraftToAnsi {
private static final Map<Character, String> minecraftToAnsiMap =
private static final Map<Character, String> minecraftToAnsiMap = new HashMap<>(); new HashMap<>();
static { static {
minecraftToAnsiMap.put('0', "\u001B[30m"); // Black minecraftToAnsiMap.put('0', "\u001B[30m"); // Black
@ -28,12 +30,12 @@ public class MinecraftToAnsi {
minecraftToAnsiMap.put('d', "\u001B[95m"); // Light Purple minecraftToAnsiMap.put('d', "\u001B[95m"); // Light Purple
minecraftToAnsiMap.put('e', "\u001B[93m"); // Yellow minecraftToAnsiMap.put('e', "\u001B[93m"); // Yellow
minecraftToAnsiMap.put('f', "\u001B[97m"); // White minecraftToAnsiMap.put('f', "\u001B[97m"); // White
minecraftToAnsiMap.put('k', "\u001B[5m"); // Obfuscated (Blinking) minecraftToAnsiMap.put('k', "\u001B[5m"); // Obfuscated (Blinking)
minecraftToAnsiMap.put('l', "\u001B[1m"); // Bold minecraftToAnsiMap.put('l', "\u001B[1m"); // Bold
minecraftToAnsiMap.put('m', "\u001B[9m"); // Strikethrough minecraftToAnsiMap.put('m', "\u001B[9m"); // Strikethrough
minecraftToAnsiMap.put('n', "\u001B[4m"); // Underline minecraftToAnsiMap.put('n', "\u001B[4m"); // Underline
minecraftToAnsiMap.put('o', "\u001B[3m"); // Italic minecraftToAnsiMap.put('o', "\u001B[3m"); // Italic
minecraftToAnsiMap.put('r', "\u001B[0m"); // Reset minecraftToAnsiMap.put('r', "\u001B[0m"); // Reset
} }
public static String convert(String text) { public static String convert(String text) {

View File

@ -13,21 +13,32 @@ public class VelocityProxyContainer implements ProxyContainer {
} }
@Override @Override
public void invokeCommand(ProxyPlayerContainer proxyPlayer, String command) { public void invokeCommand(ProxyPlayerContainer proxyPlayer,
if(proxyPlayer instanceof VelocityProxyPlayerContainer playerContainer) { String command) {
this.proxy.getCommandManager().executeAsync(playerContainer.getPlayer(), command); if (proxyPlayer
instanceof VelocityProxyPlayerContainer playerContainer) {
this.proxy.getCommandManager().executeAsync(
playerContainer.getPlayer(), command);
} }
} }
@Override @Override
public void transferPlayer(ProxyPlayerContainer proxyPlayer, String serverName) { public void transferPlayer(ProxyPlayerContainer proxyPlayer,
if(proxyPlayer instanceof VelocityProxyPlayerContainer playerContainer) { String serverName) {
this.proxy.getServer(serverName).ifPresentOrElse( if (proxyPlayer
server -> { instanceof VelocityProxyPlayerContainer playerContainer) {
playerContainer.getPlayer().createConnectionRequest(server).fireAndForget(); this.proxy.getServer(serverName)
}, .ifPresentOrElse(
() -> playerContainer.getPlayer().sendMessage(Component.text("Could not find server: " + serverName)) server
); -> {
playerContainer.getPlayer()
.createConnectionRequest(server)
.fireAndForget();
},
()
-> playerContainer.getPlayer().sendMessage(
Component.text("Could not find server: "
+ serverName)));
} }
} }
} }

View File

@ -5,11 +5,11 @@ import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier; import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
public class VelocityProxyPlayerContainer implements ProxyPlayerContainer { public class VelocityProxyPlayerContainer implements ProxyPlayerContainer {
private final Player player; private final Player player;
private final LegacyChannelIdentifier channel; private final LegacyChannelIdentifier channel;
public VelocityProxyPlayerContainer(Player player, LegacyChannelIdentifier channel) { public VelocityProxyPlayerContainer(Player player,
LegacyChannelIdentifier channel) {
this.player = player; this.player = player;
this.channel = channel; this.channel = channel;
} }
@ -26,7 +26,9 @@ public class VelocityProxyPlayerContainer implements ProxyPlayerContainer {
@Override @Override
public void sendServerPluginMessage(byte[] data) { public void sendServerPluginMessage(byte[] data) {
player.getCurrentServer().ifPresent(serverConnection -> serverConnection.sendPluginMessage(channel, data)); player.getCurrentServer().ifPresent(
serverConnection
-> serverConnection.sendPluginMessage(channel, data));
} }
public Player getPlayer() { public Player getPlayer() {