mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-21 18:16:03 +01:00
chore: run pre-commit
This commit is contained in:
parent
a8c2e13900
commit
335b9f8bd9
@ -10,12 +10,14 @@ public class AdvancedPortalsBungeePlugin extends Plugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
this.proxyCore = new AdvancedPortalsProxyCore(new BungeeInfoLogger(this), new BungeeProxyContainer(this));
|
||||
this.proxyCore = new AdvancedPortalsProxyCore(
|
||||
new BungeeInfoLogger(this), new BungeeProxyContainer(this));
|
||||
this.proxyCore.onEnable();
|
||||
|
||||
getProxy().registerChannel(ProxyMessages.CHANNEL_NAME);
|
||||
|
||||
getProxy().getPluginManager().registerListener(this, new EventListener(this, this.proxyCore));
|
||||
getProxy().getPluginManager().registerListener(
|
||||
this, new EventListener(this, this.proxyCore));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.sekwah.advancedportals.bungee;
|
||||
|
||||
import com.sekwah.advancedportals.core.util.InfoLogger;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class BungeeInfoLogger extends InfoLogger {
|
||||
|
@ -13,35 +13,40 @@ import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public class EventListener implements Listener {
|
||||
|
||||
|
||||
private final AdvancedPortalsBungeePlugin plugin;
|
||||
private final AdvancedPortalsProxyCore proxyCore;
|
||||
|
||||
public EventListener(AdvancedPortalsBungeePlugin plugin, AdvancedPortalsProxyCore proxyCore) {
|
||||
public EventListener(AdvancedPortalsBungeePlugin plugin,
|
||||
AdvancedPortalsProxyCore proxyCore) {
|
||||
this.plugin = plugin;
|
||||
this.proxyCore = proxyCore;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMessageReceived(PluginMessageEvent event) {
|
||||
if(!event.getTag().equalsIgnoreCase(ProxyMessages.CHANNEL_NAME)) return;
|
||||
if (!event.getTag().equalsIgnoreCase(ProxyMessages.CHANNEL_NAME))
|
||||
return;
|
||||
event.setCancelled(true);
|
||||
|
||||
if(!(event.getSender() instanceof Server)) return;
|
||||
if (!(event.getSender() instanceof Server))
|
||||
return;
|
||||
|
||||
if(event.getReceiver() instanceof ProxiedPlayer player) {
|
||||
this.proxyCore.incomingMessage(new BungeeProxyPlayerContainer(player), event.getData());
|
||||
if (event.getReceiver() instanceof ProxiedPlayer player) {
|
||||
this.proxyCore.incomingMessage(
|
||||
new BungeeProxyPlayerContainer(player), event.getData());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onServerConnected(ServerConnectedEvent event) {
|
||||
this.proxyCore.onServerConnect(new BungeeProxyServerContainer(event.getServer()), new BungeeProxyPlayerContainer(event.getPlayer()));
|
||||
this.proxyCore.onServerConnect(
|
||||
new BungeeProxyServerContainer(event.getServer()),
|
||||
new BungeeProxyPlayerContainer(event.getPlayer()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDisconnect(PlayerDisconnectEvent event) {
|
||||
this.proxyCore.onPlayerDisconnect(new BungeeProxyPlayerContainer(event.getPlayer()));
|
||||
this.proxyCore.onPlayerDisconnect(
|
||||
new BungeeProxyPlayerContainer(event.getPlayer()));
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerConta
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
public class BungeeProxyContainer implements ProxyContainer {
|
||||
|
||||
private final AdvancedPortalsBungeePlugin plugin;
|
||||
|
||||
public BungeeProxyContainer(AdvancedPortalsBungeePlugin plugin) {
|
||||
@ -15,21 +14,26 @@ public class BungeeProxyContainer implements ProxyContainer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invokeCommand(ProxyPlayerContainer proxyPlayer, String command) {
|
||||
public void invokeCommand(ProxyPlayerContainer proxyPlayer,
|
||||
String command) {
|
||||
// Should never not be true but just to be safe
|
||||
if(proxyPlayer instanceof BungeeProxyPlayerContainer playerContainer) {
|
||||
plugin.getProxy().getPluginManager().dispatchCommand(playerContainer.getPlayer(), command);
|
||||
if (proxyPlayer instanceof BungeeProxyPlayerContainer playerContainer) {
|
||||
plugin.getProxy().getPluginManager().dispatchCommand(
|
||||
playerContainer.getPlayer(), command);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferPlayer(ProxyPlayerContainer proxyPlayer, String serverName) {
|
||||
public void transferPlayer(ProxyPlayerContainer proxyPlayer,
|
||||
String serverName) {
|
||||
// Should never not be true but just to be safe
|
||||
if(proxyPlayer instanceof BungeeProxyPlayerContainer playerContainer) {
|
||||
if (proxyPlayer instanceof BungeeProxyPlayerContainer playerContainer) {
|
||||
var serverInfo = plugin.getProxy().getServerInfo(serverName);
|
||||
var player = playerContainer.getPlayer();
|
||||
if(serverInfo == null) {
|
||||
player.sendMessage(new TextComponent(Lang.convertColors("&cCould not find server: &e") + serverName));
|
||||
if (serverInfo == null) {
|
||||
player.sendMessage(new TextComponent(
|
||||
Lang.convertColors("&cCould not find server: &e")
|
||||
+ serverName));
|
||||
return;
|
||||
}
|
||||
player.connect(serverInfo);
|
||||
|
@ -5,7 +5,6 @@ import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerConta
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
public class BungeeProxyPlayerContainer implements ProxyPlayerContainer {
|
||||
|
||||
private final ProxiedPlayer player;
|
||||
|
||||
public BungeeProxyPlayerContainer(ProxiedPlayer player) {
|
||||
@ -29,5 +28,4 @@ public class BungeeProxyPlayerContainer implements ProxyPlayerContainer {
|
||||
public void sendServerPluginMessage(byte[] data) {
|
||||
this.player.getServer().sendData(ProxyMessages.CHANNEL_NAME, data);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,12 +20,10 @@ import com.sekwah.advancedportals.core.tags.*;
|
||||
import com.sekwah.advancedportals.core.util.GameScheduler;
|
||||
import com.sekwah.advancedportals.core.util.InfoLogger;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class AdvancedPortalsCore {
|
||||
|
||||
private final InfoLogger infoLogger;
|
||||
private final DataStorage dataStorage;
|
||||
|
||||
@ -74,8 +72,8 @@ public class AdvancedPortalsCore {
|
||||
this.infoLogger = infoLogger;
|
||||
|
||||
int[] mcVersionTemp;
|
||||
infoLogger.info("Loading Advanced Portals Core v" + BuildConstants.VERSION
|
||||
+ " for MC: " + mcVersion);
|
||||
infoLogger.info("Loading Advanced Portals Core v"
|
||||
+ BuildConstants.VERSION + " for MC: " + mcVersion);
|
||||
try {
|
||||
mcVersionTemp = Arrays.stream(mcVersion.split("\\."))
|
||||
.mapToInt(Integer::parseInt)
|
||||
@ -121,9 +119,11 @@ public class AdvancedPortalsCore {
|
||||
|
||||
private void registerChannels() {
|
||||
this.serverContainer.registerOutgoingChannel(BungeeTag.PACKET_CHANNEL);
|
||||
if(this.configRepository.getEnableProxySupport()) {
|
||||
this.serverContainer.registerOutgoingChannel(ProxyMessages.CHANNEL_NAME);
|
||||
this.serverContainer.registerIncomingChannel(ProxyMessages.CHANNEL_NAME);
|
||||
if (this.configRepository.getEnableProxySupport()) {
|
||||
this.serverContainer.registerOutgoingChannel(
|
||||
ProxyMessages.CHANNEL_NAME);
|
||||
this.serverContainer.registerIncomingChannel(
|
||||
ProxyMessages.CHANNEL_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,7 +148,8 @@ public class AdvancedPortalsCore {
|
||||
}
|
||||
|
||||
private void registerPortalCommand(CommandRegister commandRegister) {
|
||||
this.portalCommand = new CommandWithSubCommands(this, Permissions.PORTAL);
|
||||
this.portalCommand =
|
||||
new CommandWithSubCommands(this, Permissions.PORTAL);
|
||||
|
||||
this.portalCommand.registerSubCommand("version",
|
||||
new VersionSubCommand());
|
||||
|
@ -18,7 +18,6 @@ import com.sekwah.advancedportals.core.services.PortalServices;
|
||||
import com.sekwah.advancedportals.core.util.GameScheduler;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
import com.sekwah.advancedportals.core.warphandler.TriggerType;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class CoreListeners {
|
||||
@ -44,10 +43,12 @@ public class CoreListeners {
|
||||
}
|
||||
|
||||
private void setIfInPortal(PlayerContainer player) {
|
||||
String inPortal = this.portalServices.inPortalRegionGetName(player.getBlockLoc());
|
||||
String inPortal =
|
||||
this.portalServices.inPortalRegionGetName(player.getBlockLoc());
|
||||
|
||||
if (inPortal == null) {
|
||||
inPortal = this.portalServices.inPortalRegionGetName(player.getBlockLoc().addY((int) player.getHeight()));
|
||||
inPortal = this.portalServices.inPortalRegionGetName(
|
||||
player.getBlockLoc().addY((int) player.getHeight()));
|
||||
}
|
||||
|
||||
this.playerDataServices.getPlayerData(player).setInPortal(inPortal);
|
||||
@ -61,7 +62,8 @@ public class CoreListeners {
|
||||
this.playerDataServices.playerLeave(player);
|
||||
}
|
||||
|
||||
public void incomingMessage(PlayerContainer player, String channel, byte[] message) {
|
||||
public void incomingMessage(PlayerContainer player, String channel,
|
||||
byte[] message) {
|
||||
var buffer = ByteStreams.newDataInput(message);
|
||||
var messageType = buffer.readUTF();
|
||||
|
||||
@ -135,125 +137,126 @@ public class CoreListeners {
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if (itemInHandName.equals(
|
||||
"\u00A78End Portal Block Placer")) {
|
||||
world.setBlock(blockPos, "END_PORTAL");
|
||||
return true;
|
||||
} else if (itemInHandName.equals("\u00A78Gateway Block Placer")) {
|
||||
world.setBlock(blockPos, "END_GATEWAY");
|
||||
world.disableBeacon(blockPos);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (itemInHandName.equals("\u00A78End Portal Block Placer")) {
|
||||
world.setBlock(blockPos, "END_PORTAL");
|
||||
return true;
|
||||
}
|
||||
if (portalServices.inPortalRegionProtected(blockPos)) {
|
||||
if (player != null) {
|
||||
player.sendMessage(Lang.getNegativePrefix()
|
||||
+ Lang.translate("portal.nobuild"));
|
||||
}
|
||||
return false;
|
||||
else if (itemInHandName.equals("\u00A78Gateway Block Placer")) {
|
||||
world.setBlock(blockPos, "END_GATEWAY");
|
||||
world.disableBeacon(blockPos);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the block is allowed to be interacted with e.g. a lever
|
||||
* @player player causing the event (or null if not a player)
|
||||
* @param blockPos
|
||||
* @return
|
||||
*/
|
||||
public boolean blockInteract(PlayerContainer player,
|
||||
BlockLocation blockPos) {
|
||||
return true;
|
||||
if (portalServices.inPortalRegionProtected(blockPos)) {
|
||||
if (player != null) {
|
||||
player.sendMessage(Lang.getNegativePrefix()
|
||||
+ Lang.translate("portal.nobuild"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param blockLoc
|
||||
* @param leftClick true = left click, false = right click
|
||||
* @return if player is allowed to interact with block
|
||||
*/
|
||||
public boolean playerInteractWithBlock(PlayerContainer player,
|
||||
String blockMaterialname,
|
||||
String itemMaterialName,
|
||||
String itemName,
|
||||
BlockLocation blockLoc,
|
||||
boolean leftClick) {
|
||||
if (itemName != null
|
||||
&& Permissions.CREATE_PORTAL.hasPermission(player)
|
||||
&& itemMaterialName.equalsIgnoreCase(
|
||||
this.configRepository.getSelectorMaterial())
|
||||
&& (!this.configRepository.getUseOnlySpecialAxe()
|
||||
|| itemName.equals("\u00A7ePortal Region Selector"))) {
|
||||
this.playerDataServices.playerSelectorActivate(player, blockLoc,
|
||||
leftClick);
|
||||
return false;
|
||||
} else if (itemName != null && leftClick
|
||||
&& Objects.equals(itemMaterialName, "PURPLE_WOOL")
|
||||
&& itemName.equals("\u00A75Portal Block Placer")
|
||||
&& Permissions.BUILD.hasPermission(player)) {
|
||||
if (!Objects.equals(blockMaterialname, "NETHER_PORTAL")) {
|
||||
return false;
|
||||
}
|
||||
WorldContainer world = player.getWorld();
|
||||
if (world.getBlockAxis(blockLoc) == BlockAxis.X) {
|
||||
world.setBlockAxis(blockLoc, BlockAxis.Z);
|
||||
} else {
|
||||
world.setBlockAxis(blockLoc, BlockAxis.X);
|
||||
}
|
||||
/**
|
||||
* If the block is allowed to be interacted with e.g. a lever
|
||||
* @player player causing the event (or null if not a player)
|
||||
* @param blockPos
|
||||
* @return
|
||||
*/
|
||||
public boolean blockInteract(PlayerContainer player, BlockLocation blockPos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param blockLoc
|
||||
* @param leftClick true = left click, false = right click
|
||||
* @return if player is allowed to interact with block
|
||||
*/
|
||||
public boolean playerInteractWithBlock(PlayerContainer player,
|
||||
String blockMaterialname,
|
||||
String itemMaterialName, String itemName,
|
||||
BlockLocation blockLoc,
|
||||
boolean leftClick) {
|
||||
if (itemName != null && Permissions.CREATE_PORTAL.hasPermission(player)
|
||||
&& itemMaterialName.equalsIgnoreCase(
|
||||
this.configRepository.getSelectorMaterial())
|
||||
&& (!this.configRepository.getUseOnlySpecialAxe()
|
||||
|| itemName.equals("\u00A7ePortal Region Selector"))) {
|
||||
this.playerDataServices.playerSelectorActivate(player, blockLoc,
|
||||
leftClick);
|
||||
return false;
|
||||
} else if (itemName != null && leftClick
|
||||
&& Objects.equals(itemMaterialName, "PURPLE_WOOL")
|
||||
&& itemName.equals("\u00A75Portal Block Placer")
|
||||
&& Permissions.BUILD.hasPermission(player)) {
|
||||
if (!Objects.equals(blockMaterialname, "NETHER_PORTAL")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void worldChange(PlayerContainer player) {
|
||||
this.playerDataServices.setJoinCooldown(player);
|
||||
this.setIfInPortal(player);
|
||||
}
|
||||
|
||||
public boolean preventEntityCombust(EntityContainer entity) {
|
||||
return portalServices.inPortalRegion(entity.getBlockLoc(), 2);
|
||||
}
|
||||
|
||||
public boolean entityPortalEvent(EntityContainer entity) {
|
||||
var pos = entity.getBlockLoc();
|
||||
if (entity instanceof PlayerContainer player) {
|
||||
var playerData = playerDataServices.getPlayerData(player);
|
||||
if (playerData.getPortalBlockCooldown()) {
|
||||
return false;
|
||||
}
|
||||
WorldContainer world = player.getWorld();
|
||||
if (world.getBlockAxis(blockLoc) == BlockAxis.X) {
|
||||
world.setBlockAxis(blockLoc, BlockAxis.Z);
|
||||
} else {
|
||||
world.setBlockAxis(blockLoc, BlockAxis.X);
|
||||
}
|
||||
|
||||
return !(portalServices.inPortalRegion(pos, 1) || portalServices.inPortalRegion(pos.addY((int) entity.getHeight()), 1));
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean playerPortalEvent(PlayerContainer player, PlayerLocation toLoc) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void worldChange(PlayerContainer player) {
|
||||
this.playerDataServices.setJoinCooldown(player);
|
||||
this.setIfInPortal(player);
|
||||
}
|
||||
|
||||
public boolean preventEntityCombust(EntityContainer entity) {
|
||||
return portalServices.inPortalRegion(entity.getBlockLoc(), 2);
|
||||
}
|
||||
|
||||
public boolean entityPortalEvent(EntityContainer entity) {
|
||||
var pos = entity.getBlockLoc();
|
||||
if (entity instanceof PlayerContainer player) {
|
||||
var playerData = playerDataServices.getPlayerData(player);
|
||||
|
||||
if (playerData.getPortalBlockCooldown()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var portalResult = this.portalServices.checkPortalActivation(player, toLoc, TriggerType.PORTAL);
|
||||
|
||||
if(portalResult != PortalServices.PortalActivationResult.NOT_IN_PORTAL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Extra checks to prevent the player from being teleported by touching a portal but not having their body fully in the portal
|
||||
var pos = player.getBlockLoc();
|
||||
|
||||
var feetInPortal = portalServices.inPortalRegion(pos, 1);
|
||||
var headInPortal = portalServices.inPortalRegion(
|
||||
pos.addY((int) player.getHeight()), 1);
|
||||
|
||||
return !(feetInPortal || headInPortal);
|
||||
}
|
||||
|
||||
public boolean physicsEvent(BlockLocation blockLocation, String string) {
|
||||
return !configRepository.getDisablePhysicsEvents()
|
||||
|| !portalServices.inPortalRegionProtected(blockLocation);
|
||||
}
|
||||
return !(portalServices.inPortalRegion(pos, 1)
|
||||
|| portalServices.inPortalRegion(
|
||||
pos.addY((int) entity.getHeight()), 1));
|
||||
}
|
||||
|
||||
public boolean playerPortalEvent(PlayerContainer player, PlayerLocation toLoc) {
|
||||
var playerData = playerDataServices.getPlayerData(player);
|
||||
|
||||
if (playerData.getPortalBlockCooldown()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var portalResult = this.portalServices.checkPortalActivation(
|
||||
player, toLoc, TriggerType.PORTAL);
|
||||
|
||||
if (portalResult != PortalServices.PortalActivationResult.NOT_IN_PORTAL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Extra checks to prevent the player from being teleported by touching a
|
||||
// portal but not having their body fully in the portal
|
||||
var pos = player.getBlockLoc();
|
||||
|
||||
var feetInPortal = portalServices.inPortalRegion(pos, 1);
|
||||
var headInPortal =
|
||||
portalServices.inPortalRegion(pos.addY((int) player.getHeight()), 1);
|
||||
|
||||
return !(feetInPortal || headInPortal);
|
||||
}
|
||||
|
||||
public boolean physicsEvent(BlockLocation blockLocation, String string) {
|
||||
return !configRepository.getDisablePhysicsEvents()
|
||||
|| !portalServices.inPortalRegionProtected(blockLocation);
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.sekwah.advancedportals.core;
|
||||
|
||||
/**
|
||||
* messages going to the proxy will start with proxy: messages going to the server will start with server:
|
||||
* messages going to the proxy will start with proxy: messages going to the
|
||||
* server will start with server:
|
||||
*/
|
||||
public class ProxyMessages {
|
||||
|
||||
/**
|
||||
* Could split by channel messages we will handle it ourselves
|
||||
*/
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.sekwah.advancedportals.core.commands;
|
||||
|
||||
import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain
|
||||
import com.sekwah.advancedportals.core.permissions.PermissionBuilder;
|
||||
import com.sekwah.advancedportals.core.registry.SubCommandRegistry;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -18,7 +17,8 @@ public class CommandWithSubCommands implements CommandTemplate {
|
||||
private final AdvancedPortalsCore pluginCore;
|
||||
private final PermissionBuilder permission;
|
||||
|
||||
public CommandWithSubCommands(AdvancedPortalsCore advancedPortalsCore, PermissionBuilder permission) {
|
||||
public CommandWithSubCommands(AdvancedPortalsCore advancedPortalsCore,
|
||||
PermissionBuilder permission) {
|
||||
this.subCommandRegistry = new SubCommandRegistry();
|
||||
this.pluginCore = advancedPortalsCore;
|
||||
this.permission = permission;
|
||||
@ -57,8 +57,9 @@ public class CommandWithSubCommands implements CommandTemplate {
|
||||
@Override
|
||||
public void onCommand(CommandSenderContainer sender, String commandExecuted,
|
||||
String[] args) {
|
||||
if(!permission.hasPermission(sender)) {
|
||||
sender.sendMessage(Lang.getNegativePrefix() + Lang.translate("command.nopermission"));
|
||||
if (!permission.hasPermission(sender)) {
|
||||
sender.sendMessage(Lang.getNegativePrefix()
|
||||
+ Lang.translate("command.nopermission"));
|
||||
return;
|
||||
}
|
||||
if (args.length > 0) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.sekwah.advancedportals.core.commands;
|
||||
|
||||
import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SubCommand {
|
||||
|
@ -5,7 +5,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain
|
||||
import com.sekwah.advancedportals.core.serializeddata.DataTag;
|
||||
import com.sekwah.advancedportals.core.util.TagReader;
|
||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -12,7 +12,6 @@ import com.sekwah.advancedportals.core.services.DestinationServices;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
import com.sekwah.advancedportals.core.util.TagReader;
|
||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -6,7 +6,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain
|
||||
import com.sekwah.advancedportals.core.permissions.Permissions;
|
||||
import com.sekwah.advancedportals.core.services.DestinationServices;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -6,7 +6,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain
|
||||
import com.sekwah.advancedportals.core.permissions.Permissions;
|
||||
import com.sekwah.advancedportals.core.services.DestinationServices;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -14,7 +14,6 @@ import com.sekwah.advancedportals.core.services.PlayerDataServices;
|
||||
import com.sekwah.advancedportals.core.util.Debug;
|
||||
import com.sekwah.advancedportals.core.util.GameScheduler;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
@ -6,7 +6,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain
|
||||
import com.sekwah.advancedportals.core.permissions.Permissions;
|
||||
import com.sekwah.advancedportals.core.services.DestinationServices;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -15,7 +15,6 @@ import com.sekwah.advancedportals.core.tags.TriggerBlockTag;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
import com.sekwah.advancedportals.core.util.TagReader;
|
||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -6,7 +6,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain
|
||||
import com.sekwah.advancedportals.core.permissions.Permissions;
|
||||
import com.sekwah.advancedportals.core.services.PortalServices;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DisableBeaconSubCommand implements SubCommand {
|
||||
@ -18,17 +17,22 @@ public class DisableBeaconSubCommand implements SubCommand {
|
||||
if (args.length > 1) {
|
||||
var portalName = args[1];
|
||||
var portal = portalServices.getPortal(portalName);
|
||||
if(portal == null) {
|
||||
sender.sendMessage(Lang.getNegativePrefix()
|
||||
+ Lang.translateInsertVariables("command.portal.disablebeacon.notfound", portalName));
|
||||
if (portal == null) {
|
||||
sender.sendMessage(
|
||||
Lang.getNegativePrefix()
|
||||
+ Lang.translateInsertVariables(
|
||||
"command.portal.disablebeacon.notfound", portalName));
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(Lang.getPositivePrefix()
|
||||
+ Lang.translateInsertVariables("command.portal.disablebeacon.complete", portalName));
|
||||
sender.sendMessage(
|
||||
Lang.getPositivePrefix()
|
||||
+ Lang.translateInsertVariables(
|
||||
"command.portal.disablebeacon.complete", portalName));
|
||||
sender.getPlayerContainer().getWorld().disableBeacon(portal);
|
||||
} else {
|
||||
sender.sendMessage(Lang.getNegativePrefix()
|
||||
+ Lang.translate("command.portal.disablebeacon.noname"));
|
||||
sender.sendMessage(
|
||||
Lang.getNegativePrefix()
|
||||
+ Lang.translate("command.portal.disablebeacon.noname"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain
|
||||
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
|
||||
import com.sekwah.advancedportals.core.permissions.Permissions;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EndGatewayBlockSubCommand implements SubCommand {
|
||||
|
@ -7,7 +7,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain
|
||||
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
|
||||
import com.sekwah.advancedportals.core.permissions.Permissions;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EndPortalBlockSubCommand implements SubCommand {
|
||||
|
@ -7,7 +7,6 @@ import com.sekwah.advancedportals.core.permissions.Permissions;
|
||||
import com.sekwah.advancedportals.core.services.PortalServices;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
import com.sekwah.advancedportals.core.util.TagReader;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class InfoPortalSubCommand implements SubCommand {
|
||||
@ -19,17 +18,20 @@ public class InfoPortalSubCommand implements SubCommand {
|
||||
if (args.length > 1) {
|
||||
var portalName = args[1];
|
||||
var portal = portalServices.getPortal(portalName);
|
||||
if(portal == null) {
|
||||
sender.sendMessage(Lang.getNegativePrefix()
|
||||
+ Lang.translateInsertVariables("command.portal.info.notfound", portalName));
|
||||
if (portal == null) {
|
||||
sender.sendMessage(
|
||||
Lang.getNegativePrefix()
|
||||
+ Lang.translateInsertVariables(
|
||||
"command.portal.info.notfound", portalName));
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(Lang.getPositivePrefix()
|
||||
+ Lang.translateInsertVariables("command.portal.info.complete", portalName));
|
||||
+ Lang.translateInsertVariables(
|
||||
"command.portal.info.complete", portalName));
|
||||
TagReader.printArgs(sender, portal.getArgs());
|
||||
} else {
|
||||
sender.sendMessage(Lang.getNegativePrefix()
|
||||
+ Lang.translate("command.portal.info.noname"));
|
||||
+ Lang.translate("command.portal.info.noname"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain
|
||||
import com.sekwah.advancedportals.core.permissions.Permissions;
|
||||
import com.sekwah.advancedportals.core.repository.ConfigRepository;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
|
@ -6,7 +6,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain
|
||||
import com.sekwah.advancedportals.core.permissions.Permissions;
|
||||
import com.sekwah.advancedportals.core.services.PortalServices;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -17,8 +16,8 @@ public class ListPortalsSubCommand implements SubCommand {
|
||||
@Override
|
||||
public void onCommand(CommandSenderContainer sender, String[] args) {
|
||||
sender.sendMessage(
|
||||
Lang.getPositivePrefix()
|
||||
+ Lang.translate("command.portal.list") + " "
|
||||
Lang.getPositivePrefix() + Lang.translate("command.portal.list")
|
||||
+ " "
|
||||
+ portalServices.getPortalNames().stream().sorted().collect(
|
||||
Collectors.joining(", ")));
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain
|
||||
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
|
||||
import com.sekwah.advancedportals.core.permissions.Permissions;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PortalBlockSubCommand implements SubCommand {
|
||||
|
@ -9,7 +9,6 @@ import com.sekwah.advancedportals.core.repository.ConfigRepository;
|
||||
import com.sekwah.advancedportals.core.services.DestinationServices;
|
||||
import com.sekwah.advancedportals.core.services.PortalServices;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReloadPortalSubCommand implements SubCommand {
|
||||
|
@ -6,7 +6,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain
|
||||
import com.sekwah.advancedportals.core.permissions.Permissions;
|
||||
import com.sekwah.advancedportals.core.services.PortalServices;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RemovePortalSubCommand implements SubCommand {
|
||||
|
@ -8,7 +8,6 @@ import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
|
||||
import com.sekwah.advancedportals.core.permissions.Permissions;
|
||||
import com.sekwah.advancedportals.core.repository.ConfigRepository;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SelectorSubCommand implements SubCommand {
|
||||
|
@ -16,7 +16,6 @@ import com.sekwah.advancedportals.core.tags.NameTag;
|
||||
import com.sekwah.advancedportals.core.util.Debug;
|
||||
import com.sekwah.advancedportals.core.util.GameScheduler;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@ -120,12 +119,15 @@ public class ShowPortalSubCommand
|
||||
player.getWorldName())) {
|
||||
int widthX = Math.abs(tempData.getPos1().getPosX()
|
||||
- tempData.getPos2().getPosX());
|
||||
int widthY = Math.abs(tempData.getPos1().getPosY() - tempData.getPos2().getPosY());
|
||||
int widthZ = Math.abs(tempData.getPos1().getPosZ() - tempData.getPos2().getPosZ());
|
||||
int widthY = Math.abs(tempData.getPos1().getPosY()
|
||||
- tempData.getPos2().getPosY());
|
||||
int widthZ = Math.abs(tempData.getPos1().getPosZ()
|
||||
- tempData.getPos2().getPosZ());
|
||||
int totalBlocks = widthX * widthY * widthZ;
|
||||
if (totalBlocks <= config.getMaxTriggerVisualisationSize())
|
||||
debugVisuals(player, tempData.getPos1(), tempData.getPos2(),
|
||||
SELECTION_COLOR, SHOW_TICKS);
|
||||
debugVisuals(player, tempData.getPos1(),
|
||||
tempData.getPos2(), SELECTION_COLOR,
|
||||
SHOW_TICKS);
|
||||
}
|
||||
|
||||
if (tempData.getPos1() != null
|
||||
|
@ -4,14 +4,12 @@ import com.sekwah.advancedportals.core.BuildConstants;
|
||||
import com.sekwah.advancedportals.core.commands.SubCommand;
|
||||
import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class VersionSubCommand implements SubCommand {
|
||||
@Override
|
||||
public void onCommand(CommandSenderContainer sender, String[] args) {
|
||||
sender.sendMessage(Lang.getPositivePrefix()
|
||||
+ " Advanced Portals v"
|
||||
sender.sendMessage(Lang.getPositivePrefix() + " Advanced Portals v"
|
||||
+ BuildConstants.VERSION);
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,3 @@
|
||||
package com.sekwah.advancedportals.core.connector.containers;
|
||||
|
||||
public enum GameMode {
|
||||
SURVIVAL,
|
||||
CREATIVE,
|
||||
ADVENTURE,
|
||||
SPECTATOR
|
||||
}
|
||||
public enum GameMode { SURVIVAL, CREATIVE, ADVENTURE, SPECTATOR }
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.sekwah.advancedportals.core.connector.containers;
|
||||
|
||||
import com.sekwah.advancedportals.core.serializeddata.BlockLocation;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.sekwah.advancedportals.core.connector.containers;
|
||||
|
||||
import com.sekwah.advancedportals.core.tags.CommandTag;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -9,7 +9,6 @@ import com.sekwah.advancedportals.core.serializeddata.PlayerLocation;
|
||||
import com.sekwah.advancedportals.core.warphandler.ActivationData;
|
||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||
import com.sekwah.advancedportals.core.warphandler.TriggerType;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@ -87,7 +86,7 @@ public class Destination implements TagTarget {
|
||||
|
||||
public boolean activate(PlayerContainer player) {
|
||||
ActivationData data = new ActivationData(TriggerType.MANUAL);
|
||||
if(this.portalActivate(player, data)) {
|
||||
if (this.portalActivate(player, data)) {
|
||||
this.postActivate(player, data);
|
||||
return true;
|
||||
}
|
||||
@ -95,7 +94,7 @@ public class Destination implements TagTarget {
|
||||
}
|
||||
|
||||
public boolean portalActivate(PlayerContainer player, ActivationData data) {
|
||||
if(!isSorted) {
|
||||
if (!isSorted) {
|
||||
updateDestiTagList();
|
||||
}
|
||||
DataTag[] destiTags = new DataTag[args.size()];
|
||||
@ -104,16 +103,17 @@ public class Destination implements TagTarget {
|
||||
destiTags[i++] = new DataTag(entry.getKey(), entry.getValue());
|
||||
}
|
||||
for (DataTag destiTag : destiTags) {
|
||||
Tag.Activation activationHandler =
|
||||
tagRegistry.getActivationHandler(destiTag.NAME, Tag.TagType.DESTINATION);
|
||||
if (activationHandler != null && !activationHandler.preActivated(
|
||||
Tag.Activation activationHandler = tagRegistry.getActivationHandler(
|
||||
destiTag.NAME, Tag.TagType.DESTINATION);
|
||||
if (activationHandler != null
|
||||
&& !activationHandler.preActivated(
|
||||
this, player, data, this.getArgValues(destiTag.NAME))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (DataTag destiTag : destiTags) {
|
||||
Tag.Activation activationHandler =
|
||||
tagRegistry.getActivationHandler(destiTag.NAME, Tag.TagType.DESTINATION);
|
||||
Tag.Activation activationHandler = tagRegistry.getActivationHandler(
|
||||
destiTag.NAME, Tag.TagType.DESTINATION);
|
||||
if (activationHandler != null) {
|
||||
activationHandler.activated(this, player, data,
|
||||
this.getArgValues(destiTag.NAME));
|
||||
@ -129,8 +129,8 @@ public class Destination implements TagTarget {
|
||||
destiTags[i++] = new DataTag(entry.getKey(), entry.getValue());
|
||||
}
|
||||
for (DataTag destiTag : destiTags) {
|
||||
Tag.Activation activationHandler =
|
||||
tagRegistry.getActivationHandler(destiTag.NAME, Tag.TagType.DESTINATION);
|
||||
Tag.Activation activationHandler = tagRegistry.getActivationHandler(
|
||||
destiTag.NAME, Tag.TagType.DESTINATION);
|
||||
if (activationHandler != null) {
|
||||
activationHandler.postActivated(
|
||||
this, player, data, this.getArgValues(destiTag.NAME));
|
||||
|
@ -20,10 +20,9 @@ import com.sekwah.advancedportals.core.serializeddata.DataStorage;
|
||||
import com.sekwah.advancedportals.core.serializeddata.config.Config;
|
||||
import com.sekwah.advancedportals.core.serializeddata.config.ConfigProvider;
|
||||
import com.sekwah.advancedportals.core.util.InfoLogger;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class AdvancedPortalsModule extends AbstractModule {
|
||||
private Injector injector;
|
||||
|
@ -6,7 +6,6 @@ import com.google.common.io.ByteStreams;
|
||||
import com.sekwah.advancedportals.core.ProxyMessages;
|
||||
|
||||
public class ProxyCommandPacket implements Packet {
|
||||
|
||||
private final String command;
|
||||
|
||||
public ProxyCommandPacket(String command) {
|
||||
|
@ -6,7 +6,6 @@ import com.google.common.io.ByteStreams;
|
||||
import com.sekwah.advancedportals.core.ProxyMessages;
|
||||
|
||||
public class ProxyTransferDestiPacket implements Packet {
|
||||
|
||||
private final String serverName;
|
||||
private final String destination;
|
||||
|
||||
@ -21,7 +20,6 @@ public class ProxyTransferDestiPacket implements Packet {
|
||||
buffer.writeUTF(this.serverName);
|
||||
buffer.writeUTF(this.destination);
|
||||
return buffer.toByteArray();
|
||||
|
||||
}
|
||||
|
||||
public static ProxyTransferDestiPacket decode(ByteArrayDataInput buffer) {
|
||||
|
@ -6,7 +6,6 @@ import com.google.common.io.ByteStreams;
|
||||
import com.sekwah.advancedportals.core.ProxyMessages;
|
||||
|
||||
public class ProxyTransferPacket implements Packet {
|
||||
|
||||
private final String serverName;
|
||||
|
||||
public ProxyTransferPacket(String serverName) {
|
||||
@ -18,7 +17,6 @@ public class ProxyTransferPacket implements Packet {
|
||||
buffer.writeUTF(ProxyMessages.PROXY_TRANSFER);
|
||||
buffer.writeUTF(this.serverName);
|
||||
return buffer.toByteArray();
|
||||
|
||||
}
|
||||
|
||||
public static ProxyTransferPacket decode(ByteArrayDataInput buffer) {
|
||||
|
@ -6,7 +6,6 @@ import com.google.common.io.ByteStreams;
|
||||
import com.sekwah.advancedportals.core.ProxyMessages;
|
||||
|
||||
public class ServerDestiPacket implements Packet {
|
||||
|
||||
private final String destination;
|
||||
|
||||
public ServerDestiPacket(String destination) {
|
||||
@ -18,7 +17,6 @@ public class ServerDestiPacket implements Packet {
|
||||
buffer.writeUTF(ProxyMessages.SERVER_DESTI);
|
||||
buffer.writeUTF(this.destination);
|
||||
return buffer.toByteArray();
|
||||
|
||||
}
|
||||
|
||||
public static ServerDestiPacket decode(ByteArrayDataInput buffer) {
|
||||
|
@ -2,7 +2,6 @@ package com.sekwah.advancedportals.core.permissions;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sekwah.advancedportals.core.connector.containers.HasPermission;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -31,13 +30,15 @@ public class PermissionBuilder {
|
||||
this.permissionDefault = parent.permissionDefault;
|
||||
}
|
||||
|
||||
PermissionBuilder(String permissionTag, PermissionBuilder parent, PermissionDefault permissionDefault) {
|
||||
PermissionBuilder(String permissionTag, PermissionBuilder parent,
|
||||
PermissionDefault permissionDefault) {
|
||||
this.permissionTag = permissionTag;
|
||||
this.parent = parent;
|
||||
this.permissionDefault = permissionDefault;
|
||||
}
|
||||
|
||||
PermissionBuilder(String permissionTag, PermissionDefault permissionDefault) {
|
||||
PermissionBuilder(String permissionTag,
|
||||
PermissionDefault permissionDefault) {
|
||||
this.permissionTag = permissionTag;
|
||||
this.parent = null;
|
||||
this.permissionDefault = permissionDefault;
|
||||
@ -54,8 +55,10 @@ public class PermissionBuilder {
|
||||
return child;
|
||||
}
|
||||
|
||||
public PermissionBuilder createChild(String permissionTag, PermissionDefault permissionDefault) {
|
||||
var child = new PermissionBuilder(permissionTag, this, permissionDefault);
|
||||
public PermissionBuilder createChild(String permissionTag,
|
||||
PermissionDefault permissionDefault) {
|
||||
var child =
|
||||
new PermissionBuilder(permissionTag, this, permissionDefault);
|
||||
children.add(child);
|
||||
|
||||
return child;
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.sekwah.advancedportals.core.permissions;
|
||||
|
||||
public class Permissions {
|
||||
|
||||
/**
|
||||
* If true then a permission manager is being used and don't check for op
|
||||
* for platforms like spigot this will always be true.
|
||||
* <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;
|
||||
|
||||
@ -14,95 +14,116 @@ public class Permissions {
|
||||
new PermissionBuilder("advancedportals").doNotExport();
|
||||
|
||||
public static final PermissionBuilder BUILD =
|
||||
ROOT.createChild("build", PermissionBuilder.PermissionDefault.OP).description("Allows you to build in the portal regions");
|
||||
|
||||
ROOT.createChild("build", PermissionBuilder.PermissionDefault.OP)
|
||||
.description("Allows you to build in the portal regions");
|
||||
|
||||
public static final PermissionBuilder DESTI =
|
||||
ROOT.createChild("desti", PermissionBuilder.PermissionDefault.TRUE).description("Allows you to use the destination command");
|
||||
ROOT.createChild("desti", PermissionBuilder.PermissionDefault.TRUE)
|
||||
.description("Allows you to use the destination command");
|
||||
|
||||
public static final PermissionBuilder CREATE_DESTI =
|
||||
DESTI.createChild("create", PermissionBuilder.PermissionDefault.OP).description("Allows you to create destinations");
|
||||
DESTI.createChild("create", PermissionBuilder.PermissionDefault.OP)
|
||||
.description("Allows you to create destinations");
|
||||
|
||||
public static final PermissionBuilder TELEPORT_DESTI =
|
||||
DESTI.createChild("teleport", PermissionBuilder.PermissionDefault.OP).description("Allows you to teleport to destinations");
|
||||
DESTI.createChild("teleport", PermissionBuilder.PermissionDefault.OP)
|
||||
.description("Allows you to teleport to destinations");
|
||||
|
||||
public static final PermissionBuilder REMOVE_DESTI =
|
||||
DESTI.createChild("remove", PermissionBuilder.PermissionDefault.OP).description("Allows you to remove destinations");
|
||||
DESTI.createChild("remove", PermissionBuilder.PermissionDefault.OP)
|
||||
.description("Allows you to remove destinations");
|
||||
|
||||
public static final PermissionBuilder LIST_DESTI =
|
||||
DESTI.createChild("list", PermissionBuilder.PermissionDefault.OP).description("Allows you to list all destinations");
|
||||
DESTI.createChild("list", PermissionBuilder.PermissionDefault.OP)
|
||||
.description("Allows you to list all destinations");
|
||||
|
||||
public static final PermissionBuilder SHOW_DESTI =
|
||||
DESTI.createChild("show", PermissionBuilder.PermissionDefault.OP).description("Allows you to visualise the destination locations");
|
||||
DESTI.createChild("show", PermissionBuilder.PermissionDefault.OP)
|
||||
.description("Allows you to visualise the destination locations");
|
||||
|
||||
public static final PermissionBuilder PORTAL =
|
||||
ROOT.createChild("portal", PermissionBuilder.PermissionDefault.TRUE).description("Allows you to use the portal command");
|
||||
ROOT.createChild("portal", PermissionBuilder.PermissionDefault.TRUE)
|
||||
.description("Allows you to use the portal command");
|
||||
|
||||
public static final PermissionBuilder CREATE_PORTAL =
|
||||
PORTAL.createChild("create", PermissionBuilder.PermissionDefault.OP).description("Allows you to create portals");
|
||||
PORTAL.createChild("create", PermissionBuilder.PermissionDefault.OP)
|
||||
.description("Allows you to create portals");
|
||||
|
||||
public static final PermissionBuilder SELECTOR =
|
||||
PORTAL.createChild("selector", PermissionBuilder.PermissionDefault.OP).description("Allows you to give yourself a portal selector");
|
||||
PORTAL.createChild("selector", PermissionBuilder.PermissionDefault.OP)
|
||||
.description("Allows you to give yourself a portal selector");
|
||||
|
||||
public static final PermissionBuilder REMOVE_PORTAL =
|
||||
PORTAL.createChild("remove", PermissionBuilder.PermissionDefault.OP).description("Allows you to remove portals");
|
||||
PORTAL.createChild("remove", PermissionBuilder.PermissionDefault.OP)
|
||||
.description("Allows you to remove portals");
|
||||
|
||||
public static final PermissionBuilder LIST_PORTAL =
|
||||
PORTAL.createChild("list", PermissionBuilder.PermissionDefault.OP).description("Allows you to list all portals");
|
||||
PORTAL.createChild("list", PermissionBuilder.PermissionDefault.OP)
|
||||
.description("Allows you to list all portals");
|
||||
|
||||
public static final PermissionBuilder LANG_UPDATE =
|
||||
PORTAL.createChild("lang_update", PermissionBuilder.PermissionDefault.OP);
|
||||
public static final PermissionBuilder LANG_UPDATE = PORTAL.createChild(
|
||||
"lang_update", PermissionBuilder.PermissionDefault.OP);
|
||||
public static final PermissionBuilder RELOAD =
|
||||
PORTAL.createChild("reload", PermissionBuilder.PermissionDefault.OP);
|
||||
PORTAL.createChild("reload", PermissionBuilder.PermissionDefault.OP);
|
||||
|
||||
public static final PermissionBuilder DISABLE_BEACON =
|
||||
PORTAL.createChild("disable_beacon", PermissionBuilder.PermissionDefault.OP);
|
||||
public static final PermissionBuilder DISABLE_BEACON = PORTAL.createChild(
|
||||
"disable_beacon", PermissionBuilder.PermissionDefault.OP);
|
||||
public static final PermissionBuilder IMPORT =
|
||||
PORTAL.createChild("import", PermissionBuilder.PermissionDefault.OP);
|
||||
PORTAL.createChild("import", PermissionBuilder.PermissionDefault.OP);
|
||||
|
||||
public static final PermissionBuilder SHOW_PORTAL =
|
||||
PORTAL.createChild("show", PermissionBuilder.PermissionDefault.OP).description("Allows you to view the portal regions");
|
||||
PORTAL.createChild("show", PermissionBuilder.PermissionDefault.OP)
|
||||
.description("Allows you to view the portal regions");
|
||||
|
||||
private static final PermissionBuilder CREATE_COMMAND_LEVEL =
|
||||
CREATE_PORTAL.createChild("command_level").doNotExport();
|
||||
CREATE_PORTAL.createChild("command_level").doNotExport();
|
||||
|
||||
public static final PermissionBuilder CREATE_COMMAND_OP =
|
||||
CREATE_COMMAND_LEVEL.createChild("op").description("Allows you to increase the users level temporarily to op");
|
||||
CREATE_COMMAND_LEVEL.createChild("op").description(
|
||||
"Allows you to increase the users level temporarily to op");
|
||||
|
||||
public static final PermissionBuilder CREATE_COMMAND_CONSOLE =
|
||||
CREATE_COMMAND_LEVEL.createChild("console").description("Allows you to create portals which execute console commands");
|
||||
CREATE_COMMAND_LEVEL.createChild("console").description(
|
||||
"Allows you to create portals which execute console commands");
|
||||
|
||||
public static final PermissionBuilder CREATE_COMMAND_PERMS =
|
||||
CREATE_COMMAND_LEVEL.createChild("perms_wildcard").description("Allows you to increase the users level temporarily to have all perms");
|
||||
CREATE_COMMAND_LEVEL.createChild("perms_wildcard")
|
||||
.description("Allows you to increase the users level temporarily "
|
||||
+ "to have all perms");
|
||||
|
||||
public static final PermissionBuilder PORTAL_INFO =
|
||||
PORTAL.createChild("info", PermissionBuilder.PermissionDefault.OP).description("Allows you to view portal information");
|
||||
PORTAL.createChild("info", PermissionBuilder.PermissionDefault.OP)
|
||||
.description("Allows you to view portal information");
|
||||
|
||||
static {
|
||||
// These are to add children which will not be used directly e.g. advancedportals.*
|
||||
ROOT.createChild("*", PermissionBuilder.PermissionDefault.OP).description("Gives access to all portal commands")
|
||||
.addGrantChild(CREATE_PORTAL)
|
||||
.addGrantChild(CREATE_DESTI)
|
||||
.addGrantChild(DESTI)
|
||||
.addGrantChild(PORTAL)
|
||||
.addGrantChild(TELEPORT_DESTI)
|
||||
.addGrantChild(REMOVE_DESTI)
|
||||
.addGrantChild(LIST_DESTI)
|
||||
.addGrantChild(SHOW_DESTI)
|
||||
.addGrantChild(SELECTOR)
|
||||
.addGrantChild(REMOVE_PORTAL)
|
||||
.addGrantChild(LIST_PORTAL)
|
||||
.addGrantChild(LANG_UPDATE)
|
||||
.addGrantChild(RELOAD)
|
||||
.addGrantChild(DISABLE_BEACON)
|
||||
.addGrantChild(IMPORT)
|
||||
.addGrantChild(SHOW_PORTAL)
|
||||
.addGrantChild(PORTAL_INFO)
|
||||
.addGrantChild(BUILD);
|
||||
// These are to add children which will not be used directly e.g.
|
||||
// advancedportals.*
|
||||
ROOT.createChild("*", PermissionBuilder.PermissionDefault.OP)
|
||||
.description("Gives access to all portal commands")
|
||||
.addGrantChild(CREATE_PORTAL)
|
||||
.addGrantChild(CREATE_DESTI)
|
||||
.addGrantChild(DESTI)
|
||||
.addGrantChild(PORTAL)
|
||||
.addGrantChild(TELEPORT_DESTI)
|
||||
.addGrantChild(REMOVE_DESTI)
|
||||
.addGrantChild(LIST_DESTI)
|
||||
.addGrantChild(SHOW_DESTI)
|
||||
.addGrantChild(SELECTOR)
|
||||
.addGrantChild(REMOVE_PORTAL)
|
||||
.addGrantChild(LIST_PORTAL)
|
||||
.addGrantChild(LANG_UPDATE)
|
||||
.addGrantChild(RELOAD)
|
||||
.addGrantChild(DISABLE_BEACON)
|
||||
.addGrantChild(IMPORT)
|
||||
.addGrantChild(SHOW_PORTAL)
|
||||
.addGrantChild(PORTAL_INFO)
|
||||
.addGrantChild(BUILD);
|
||||
|
||||
CREATE_COMMAND_LEVEL.createChild("*", PermissionBuilder.PermissionDefault.OP).description("Gives access to all command level raisers")
|
||||
.addGrantChild(CREATE_COMMAND_OP)
|
||||
.addGrantChild(CREATE_COMMAND_CONSOLE)
|
||||
.addGrantChild(CREATE_COMMAND_PERMS);
|
||||
CREATE_COMMAND_LEVEL
|
||||
.createChild("*", PermissionBuilder.PermissionDefault.OP)
|
||||
.description("Gives access to all command level raisers")
|
||||
.addGrantChild(CREATE_COMMAND_OP)
|
||||
.addGrantChild(CREATE_COMMAND_CONSOLE)
|
||||
.addGrantChild(CREATE_COMMAND_PERMS);
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ import com.sekwah.advancedportals.core.util.Lang;
|
||||
import com.sekwah.advancedportals.core.warphandler.ActivationData;
|
||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||
import com.sekwah.advancedportals.core.warphandler.TriggerType;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@ -137,8 +136,9 @@ public class AdvancedPortal implements TagTarget {
|
||||
* @param triggerType The type of trigger that activated the portal
|
||||
* @return Whether the portal was successfully activated
|
||||
*/
|
||||
public ActivationResult activate(PlayerContainer player, TriggerType triggerType) {
|
||||
if(!isSorted) {
|
||||
public ActivationResult activate(PlayerContainer player,
|
||||
TriggerType triggerType) {
|
||||
if (!isSorted) {
|
||||
updatePortalTagList();
|
||||
}
|
||||
|
||||
@ -162,14 +162,17 @@ public class AdvancedPortal implements TagTarget {
|
||||
ActivationData data = new ActivationData(triggerType);
|
||||
|
||||
for (DataTag portalTag : this.portalTags) {
|
||||
Tag.Activation activationHandler =
|
||||
tagRegistry.getActivationHandler(portalTag.NAME, Tag.TagType.PORTAL);
|
||||
Tag.Activation activationHandler = tagRegistry.getActivationHandler(
|
||||
portalTag.NAME, Tag.TagType.PORTAL);
|
||||
if (activationHandler != null) {
|
||||
var preActivated = activationHandler.preActivated(
|
||||
this, player, data, this.getArgValues(portalTag.NAME));
|
||||
this, player, data, this.getArgValues(portalTag.NAME));
|
||||
|
||||
if(!preActivated) {
|
||||
if(activationHandler instanceof Tag.DenyBehavior denyBehavior && denyBehavior.getDenyBehavior() == Tag.DenyBehavior.Behaviour.SILENT) {
|
||||
if (!preActivated) {
|
||||
if (activationHandler
|
||||
instanceof Tag.DenyBehavior denyBehavior
|
||||
&& denyBehavior.getDenyBehavior()
|
||||
== Tag.DenyBehavior.Behaviour.SILENT) {
|
||||
return ActivationResult.FAILED_DO_NOTHING;
|
||||
}
|
||||
return ActivationResult.FAILED_DO_KNOCKBACK;
|
||||
@ -177,8 +180,8 @@ public class AdvancedPortal implements TagTarget {
|
||||
}
|
||||
}
|
||||
for (DataTag portalTag : this.portalTags) {
|
||||
Tag.Activation activationHandler =
|
||||
tagRegistry.getActivationHandler(portalTag.NAME, Tag.TagType.PORTAL);
|
||||
Tag.Activation activationHandler = tagRegistry.getActivationHandler(
|
||||
portalTag.NAME, Tag.TagType.PORTAL);
|
||||
if (activationHandler != null
|
||||
&& !activationHandler.activated(
|
||||
this, player, data, this.getArgValues(portalTag.NAME))) {
|
||||
@ -186,8 +189,8 @@ public class AdvancedPortal implements TagTarget {
|
||||
}
|
||||
}
|
||||
for (DataTag portalTag : this.portalTags) {
|
||||
Tag.Activation activationHandler =
|
||||
tagRegistry.getActivationHandler(portalTag.NAME, Tag.TagType.PORTAL);
|
||||
Tag.Activation activationHandler = tagRegistry.getActivationHandler(
|
||||
portalTag.NAME, Tag.TagType.PORTAL);
|
||||
if (activationHandler != null) {
|
||||
activationHandler.postActivated(
|
||||
this, player, data, this.getArgValues(portalTag.NAME));
|
||||
|
@ -3,7 +3,6 @@ package com.sekwah.advancedportals.core.registry;
|
||||
import com.google.inject.Inject;
|
||||
import com.sekwah.advancedportals.core.commands.SubCommand;
|
||||
import com.sekwah.advancedportals.core.util.InfoLogger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -3,7 +3,6 @@ package com.sekwah.advancedportals.core.registry;
|
||||
import com.google.inject.Inject;
|
||||
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@ -34,10 +33,12 @@ public class TagRegistry {
|
||||
* @param arg
|
||||
* @return
|
||||
*/
|
||||
public Tag.Activation getActivationHandler(String arg, Tag.TagType targetType) {
|
||||
public Tag.Activation getActivationHandler(String arg,
|
||||
Tag.TagType targetType) {
|
||||
var tag = this.activationTags.get(arg);
|
||||
if (tag != null && Arrays.asList(tag.getTagTypes()).contains(targetType)) {
|
||||
return tag;
|
||||
if (tag != null
|
||||
&& Arrays.asList(tag.getTagTypes()).contains(targetType)) {
|
||||
return tag;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import com.google.inject.Inject;
|
||||
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
||||
import com.sekwah.advancedportals.core.effect.WarpEffect;
|
||||
import com.sekwah.advancedportals.core.util.InfoLogger;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -5,7 +5,6 @@ import com.sekwah.advancedportals.core.repository.ConfigRepository;
|
||||
import com.sekwah.advancedportals.core.serializeddata.DataStorage;
|
||||
import com.sekwah.advancedportals.core.serializeddata.config.CommandPortalConfig;
|
||||
import com.sekwah.advancedportals.core.serializeddata.config.Config;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@Singleton
|
||||
|
@ -5,10 +5,9 @@ import com.sekwah.advancedportals.core.destination.Destination;
|
||||
import com.sekwah.advancedportals.core.repository.IDestinationRepository;
|
||||
import com.sekwah.advancedportals.core.serializeddata.DataStorage;
|
||||
import com.sekwah.advancedportals.core.tags.NameTag;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class DestinationRepositoryImpl implements IDestinationRepository {
|
||||
|
@ -4,7 +4,6 @@ import com.google.inject.Inject;
|
||||
import com.sekwah.advancedportals.core.repository.IPlayerDataRepository;
|
||||
import com.sekwah.advancedportals.core.serializeddata.DataStorage;
|
||||
import com.sekwah.advancedportals.core.serializeddata.PlayerData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerDataRepositoryImpl implements IPlayerDataRepository {
|
||||
|
@ -7,7 +7,6 @@ import com.sekwah.advancedportals.core.portal.AdvancedPortal;
|
||||
import com.sekwah.advancedportals.core.repository.IPortalRepository;
|
||||
import com.sekwah.advancedportals.core.serializeddata.DataStorage;
|
||||
import com.sekwah.advancedportals.core.tags.NameTag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -70,9 +69,9 @@ public class PortalRepositoryImpl implements IPortalRepository {
|
||||
|
||||
if (portal != null) {
|
||||
AdvancedPortalsCore.getInstance()
|
||||
.getModule()
|
||||
.getInjector()
|
||||
.injectMembers(portal);
|
||||
.getModule()
|
||||
.getInjector()
|
||||
.injectMembers(portal);
|
||||
}
|
||||
|
||||
// Forces the name tag to be up-to-date on load
|
||||
|
@ -3,18 +3,17 @@ package com.sekwah.advancedportals.core.serializeddata;
|
||||
import com.google.inject.Inject;
|
||||
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
||||
import com.sekwah.advancedportals.core.util.InfoLogger;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.LoaderOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.inspector.TagInspector;
|
||||
import org.yaml.snakeyaml.nodes.Tag;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.LoaderOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.inspector.TagInspector;
|
||||
import org.yaml.snakeyaml.nodes.Tag;
|
||||
|
||||
public class DataStorage {
|
||||
private final File dataFolder;
|
||||
|
@ -1,18 +1,17 @@
|
||||
package com.sekwah.advancedportals.core.serializeddata;
|
||||
|
||||
import com.sekwah.advancedportals.core.util.InfoLogger;
|
||||
import org.yaml.snakeyaml.LoaderOptions;
|
||||
import org.yaml.snakeyaml.constructor.Constructor;
|
||||
import org.yaml.snakeyaml.nodes.*;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.inject.Inject;
|
||||
import org.yaml.snakeyaml.LoaderOptions;
|
||||
import org.yaml.snakeyaml.constructor.Constructor;
|
||||
import org.yaml.snakeyaml.nodes.*;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
public class ReflectiveConstructor<T> extends Constructor {
|
||||
private static final Unsafe unsafe = getUnsafe();
|
||||
|
@ -12,12 +12,11 @@ import com.sekwah.advancedportals.core.serializeddata.DataTag;
|
||||
import com.sekwah.advancedportals.core.serializeddata.PlayerLocation;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class DestinationServices {
|
||||
@ -135,21 +134,22 @@ public class DestinationServices {
|
||||
return teleportToDestination(name, playerContainer, false);
|
||||
}
|
||||
|
||||
public boolean teleportToDestination(String name,
|
||||
PlayerContainer player, boolean doEffect) {
|
||||
if(doEffect && configRepository.getWarpEffectEnabled()) {
|
||||
var warpEffectVisual = warpEffectRegistry.getVisualEffect(configRepository.getWarpVisual());
|
||||
public boolean teleportToDestination(String name, PlayerContainer player,
|
||||
boolean doEffect) {
|
||||
if (doEffect && configRepository.getWarpEffectEnabled()) {
|
||||
var warpEffectVisual = warpEffectRegistry.getVisualEffect(
|
||||
configRepository.getWarpVisual());
|
||||
if (warpEffectVisual != null) {
|
||||
warpEffectVisual.onWarpVisual(player, WarpEffect.Action.ENTER);
|
||||
}
|
||||
var warpEffectSound = warpEffectRegistry.getSoundEffect(configRepository.getWarpSound());
|
||||
var warpEffectSound = warpEffectRegistry.getSoundEffect(
|
||||
configRepository.getWarpSound());
|
||||
if (warpEffectSound != null) {
|
||||
warpEffectSound.onWarpSound(player, WarpEffect.Action.ENTER);
|
||||
}
|
||||
}
|
||||
if (this.destinationRepository.containsKey(name)) {
|
||||
player.teleport(
|
||||
this.destinationRepository.get(name).getLoc());
|
||||
player.teleport(this.destinationRepository.get(name).getLoc());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -7,11 +7,10 @@ import com.sekwah.advancedportals.core.repository.IPlayerDataRepository;
|
||||
import com.sekwah.advancedportals.core.serializeddata.BlockLocation;
|
||||
import com.sekwah.advancedportals.core.serializeddata.PlayerData;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public final class PlayerDataServices {
|
||||
|
@ -15,9 +15,8 @@ import com.sekwah.advancedportals.core.util.Lang;
|
||||
import com.sekwah.advancedportals.core.util.PlayerUtils;
|
||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||
import com.sekwah.advancedportals.core.warphandler.TriggerType;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import java.util.*;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class PortalServices {
|
||||
@ -100,7 +99,8 @@ public class PortalServices {
|
||||
PORTAL_DENIED
|
||||
}
|
||||
|
||||
public PortalActivationResult checkPortalActivation(PlayerContainer player, PlayerLocation toLoc, TriggerType triggerType) {
|
||||
public PortalActivationResult checkPortalActivation(
|
||||
PlayerContainer player, PlayerLocation toLoc, TriggerType triggerType) {
|
||||
var blockLoc = toLoc.toBlockPos();
|
||||
var blockEntityTopLoc = blockLoc.addY(player.getHeight());
|
||||
var world = player.getWorld();
|
||||
@ -114,7 +114,7 @@ public class PortalServices {
|
||||
|| (portal.isLocationInPortal(blockEntityTopLoc)
|
||||
&& portal.isTriggerBlock(blockEntityTopMaterial))) {
|
||||
var portalName = portal.getName();
|
||||
if(Objects.equals(playerData.inPortal(), portalName)) {
|
||||
if (Objects.equals(playerData.inPortal(), portalName)) {
|
||||
return PortalActivationResult.PORTAL_DENIED;
|
||||
}
|
||||
switch (portal.activate(player, triggerType)) {
|
||||
|
@ -7,17 +7,14 @@ import com.sekwah.advancedportals.core.registry.TagTarget;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
import com.sekwah.advancedportals.core.warphandler.ActivationData;
|
||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BungeeTag implements Tag.Activation {
|
||||
|
||||
public static final String PACKET_CHANNEL = "BungeeCord";
|
||||
|
||||
public static String TAG_NAME = "bungee";
|
||||
|
||||
private final TagType[] tagTypes =
|
||||
new TagType[] {TagType.PORTAL};
|
||||
private final TagType[] tagTypes = new TagType[] {TagType.PORTAL};
|
||||
|
||||
private final Random random = new Random();
|
||||
|
||||
@ -42,17 +39,19 @@ public class BungeeTag implements Tag.Activation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preActivated(TagTarget target, PlayerContainer player, ActivationData activeData, String[] argData) {
|
||||
public boolean preActivated(TagTarget target, PlayerContainer player,
|
||||
ActivationData activeData, String[] argData) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postActivated(TagTarget target, PlayerContainer player, ActivationData activationData, String[] argData) {
|
||||
|
||||
public void postActivated(TagTarget target, PlayerContainer player,
|
||||
ActivationData activationData, String[] argData) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activated(TagTarget target, PlayerContainer player, ActivationData activeData, String[] argData) {
|
||||
public boolean activated(TagTarget target, PlayerContainer player,
|
||||
ActivationData activeData, String[] argData) {
|
||||
String selectedArg = argData[random.nextInt(argData.length)];
|
||||
|
||||
ByteArrayDataOutput outForSend = ByteStreams.newDataOutput();
|
||||
|
@ -10,7 +10,6 @@ import com.sekwah.advancedportals.core.repository.ConfigRepository;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
import com.sekwah.advancedportals.core.warphandler.ActivationData;
|
||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation {
|
||||
@ -88,7 +87,8 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation {
|
||||
}
|
||||
break;
|
||||
case '%':
|
||||
if (!commandPortals.proxy || !configRepository.getEnableProxySupport()) {
|
||||
if (!commandPortals.proxy
|
||||
|| !configRepository.getEnableProxySupport()) {
|
||||
player.sendMessage(
|
||||
Lang.getNegativePrefix()
|
||||
+ Lang.translate("tag.command.proxy.disabled"));
|
||||
@ -128,8 +128,10 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation {
|
||||
CommandLevel.PERMISSION_WILDCARD);
|
||||
break;
|
||||
case '%':
|
||||
var packet = new ProxyCommandPacket(formattedCommand.substring(1));
|
||||
player.sendPacket(ProxyMessages.CHANNEL_NAME, packet.encode());
|
||||
var packet =
|
||||
new ProxyCommandPacket(formattedCommand.substring(1));
|
||||
player.sendPacket(ProxyMessages.CHANNEL_NAME,
|
||||
packet.encode());
|
||||
break;
|
||||
default:
|
||||
player.getServer().dispatchCommand(player.getUUID(),
|
||||
|
@ -10,9 +10,8 @@ import com.sekwah.advancedportals.core.util.InfoLogger;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
import com.sekwah.advancedportals.core.warphandler.ActivationData;
|
||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Random;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class CooldownTag implements Tag.Activation, Tag.Creation {
|
||||
@Inject
|
||||
|
@ -12,7 +12,6 @@ import com.sekwah.advancedportals.core.services.DestinationServices;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
import com.sekwah.advancedportals.core.warphandler.ActivationData;
|
||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@ -65,24 +64,28 @@ public class DestiTag implements Tag.Activation, Tag.AutoComplete, Tag.Split {
|
||||
|
||||
activeData.setMetadata(TAG_NAME, selectedArg);
|
||||
|
||||
if(activeData.getMetadata(ProxyTag.TAG_NAME) != null) {
|
||||
if (activeData.getMetadata(ProxyTag.TAG_NAME) != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(destinationServices.getDestination(selectedArg) == null) {
|
||||
player.sendMessage(Lang.getNegativePrefix() + Lang.translateInsertVariables("desti.error.notfound", selectedArg));
|
||||
if (destinationServices.getDestination(selectedArg) == null) {
|
||||
player.sendMessage(Lang.getNegativePrefix()
|
||||
+ Lang.translateInsertVariables(
|
||||
"desti.error.notfound", selectedArg));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check and trigger all tags on the destination
|
||||
Destination destination = destinationServices.getDestination(selectedArg);
|
||||
Destination destination =
|
||||
destinationServices.getDestination(selectedArg);
|
||||
if (destination != null) {
|
||||
|
||||
for (var destiTag : destination.getArgs()) {
|
||||
Tag.Activation activationHandler =
|
||||
tagRegistry.getActivationHandler(destiTag.NAME, Tag.TagType.DESTINATION);
|
||||
tagRegistry.getActivationHandler(destiTag.NAME,
|
||||
Tag.TagType.DESTINATION);
|
||||
if (activationHandler != null
|
||||
&& !activationHandler.preActivated(target, player, activeData, destiTag.VALUES)) {
|
||||
&& !activationHandler.preActivated(
|
||||
target, player, activeData, destiTag.VALUES)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -94,23 +97,29 @@ public class DestiTag implements Tag.Activation, Tag.AutoComplete, Tag.Split {
|
||||
@Override
|
||||
public void postActivated(TagTarget target, PlayerContainer player,
|
||||
ActivationData activationData, String[] argData) {
|
||||
if(activationData.getMetadata(ProxyTag.TAG_NAME) != null) {
|
||||
if (activationData.getMetadata(ProxyTag.TAG_NAME) != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var selectedArg = activationData.getMetadata(TAG_NAME);
|
||||
Destination destination = destinationServices.getDestination(selectedArg);
|
||||
Destination destination =
|
||||
destinationServices.getDestination(selectedArg);
|
||||
if (destination != null) {
|
||||
for (var destiTag : destination.getArgs()) {
|
||||
Tag.Activation activationHandler =
|
||||
tagRegistry.getActivationHandler(destiTag.NAME, Tag.TagType.DESTINATION);
|
||||
tagRegistry.getActivationHandler(destiTag.NAME,
|
||||
Tag.TagType.DESTINATION);
|
||||
if (activationHandler != null) {
|
||||
activationHandler.postActivated(target, player, activationData, argData);
|
||||
activationHandler.postActivated(target, player,
|
||||
activationData, argData);
|
||||
}
|
||||
}
|
||||
var message = activationData.getMetadata(MessageTag.TAG_NAME);
|
||||
if(message == null) {
|
||||
sendMessage(player, Lang.translateInsertVariables("desti.warpdesti.warp", destination.getName().replaceAll("_", " ")));
|
||||
if (message == null) {
|
||||
sendMessage(player,
|
||||
Lang.translateInsertVariables(
|
||||
"desti.warpdesti.warp",
|
||||
destination.getName().replaceAll("_", " ")));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -118,7 +127,7 @@ public class DestiTag implements Tag.Activation, Tag.AutoComplete, Tag.Split {
|
||||
@Override
|
||||
public boolean activated(TagTarget target, PlayerContainer player,
|
||||
ActivationData activationData, String[] argData) {
|
||||
if(activationData.getMetadata(ProxyTag.TAG_NAME) != null) {
|
||||
if (activationData.getMetadata(ProxyTag.TAG_NAME) != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -126,22 +135,27 @@ public class DestiTag implements Tag.Activation, Tag.AutoComplete, Tag.Split {
|
||||
Destination destination =
|
||||
destinationServices.getDestination(selectedArg);
|
||||
if (destination != null) {
|
||||
var warpEffectVisual = warpEffectRegistry.getVisualEffect(configRepository.getWarpVisual());
|
||||
var warpEffectSound = warpEffectRegistry.getSoundEffect(configRepository.getWarpSound());
|
||||
if(configRepository.getWarpEffectEnabled()) {
|
||||
var warpEffectVisual = warpEffectRegistry.getVisualEffect(
|
||||
configRepository.getWarpVisual());
|
||||
var warpEffectSound = warpEffectRegistry.getSoundEffect(
|
||||
configRepository.getWarpSound());
|
||||
if (configRepository.getWarpEffectEnabled()) {
|
||||
if (warpEffectVisual != null) {
|
||||
warpEffectVisual.onWarpVisual(player, WarpEffect.Action.ENTER);
|
||||
warpEffectVisual.onWarpVisual(player,
|
||||
WarpEffect.Action.ENTER);
|
||||
}
|
||||
if (warpEffectSound != null) {
|
||||
warpEffectSound.onWarpSound(player, WarpEffect.Action.ENTER);
|
||||
warpEffectSound.onWarpSound(player,
|
||||
WarpEffect.Action.ENTER);
|
||||
}
|
||||
}
|
||||
|
||||
player.teleport(destination.getLoc());
|
||||
|
||||
if(configRepository.getWarpEffectEnabled()) {
|
||||
if (configRepository.getWarpEffectEnabled()) {
|
||||
if (warpEffectVisual != null) {
|
||||
warpEffectVisual.onWarpVisual(player, WarpEffect.Action.EXIT);
|
||||
warpEffectVisual.onWarpVisual(player,
|
||||
WarpEffect.Action.EXIT);
|
||||
}
|
||||
if (warpEffectSound != null) {
|
||||
warpEffectSound.onWarpSound(player, WarpEffect.Action.EXIT);
|
||||
@ -153,11 +167,11 @@ public class DestiTag implements Tag.Activation, Tag.AutoComplete, Tag.Split {
|
||||
}
|
||||
|
||||
public void sendMessage(PlayerContainer player, String message) {
|
||||
if(this.configRepository.warpMessageOnActionBar()) {
|
||||
if (this.configRepository.warpMessageOnActionBar()) {
|
||||
player.sendActionBar(Lang.convertColors(message));
|
||||
}
|
||||
else if(this.configRepository.warpMessageInChat()) {
|
||||
player.sendMessage(Lang.getPositivePrefix() + " " + Lang.convertColors(message));
|
||||
} else if (this.configRepository.warpMessageInChat()) {
|
||||
player.sendMessage(Lang.getPositivePrefix() + " "
|
||||
+ Lang.convertColors(message));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,11 +7,9 @@ import com.sekwah.advancedportals.core.repository.ConfigRepository;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
import com.sekwah.advancedportals.core.warphandler.ActivationData;
|
||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class MessageTag implements Tag.Activation {
|
||||
|
||||
@Inject
|
||||
ConfigRepository configRepository;
|
||||
|
||||
@ -43,26 +41,30 @@ public class MessageTag implements Tag.Activation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preActivated(TagTarget target, PlayerContainer player, ActivationData activeData, String[] argData) {
|
||||
public boolean preActivated(TagTarget target, PlayerContainer player,
|
||||
ActivationData activeData, String[] argData) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postActivated(TagTarget target, PlayerContainer player, ActivationData activationData, String[] argData) {
|
||||
|
||||
public void postActivated(TagTarget target, PlayerContainer player,
|
||||
ActivationData activationData, String[] argData) {
|
||||
var destination = activationData.getMetadata(DestiTag.TAG_NAME);
|
||||
var message = activationData.getMetadata(TAG_NAME);
|
||||
if(destination == null) {
|
||||
if (destination == null) {
|
||||
destination = "";
|
||||
} else {
|
||||
destination = destination.replaceAll("_", " ");
|
||||
}
|
||||
|
||||
sendMessage(player, message.replaceAll("@desti", destination).replaceAll("@player", player.getName()));
|
||||
sendMessage(player,
|
||||
message.replaceAll("@desti", destination)
|
||||
.replaceAll("@player", player.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activated(TagTarget target, PlayerContainer player, ActivationData activeData, String[] argData) {
|
||||
public boolean activated(TagTarget target, PlayerContainer player,
|
||||
ActivationData activeData, String[] argData) {
|
||||
String selectedArg = argData[random.nextInt(argData.length)];
|
||||
activeData.setMetadata(TAG_NAME, selectedArg);
|
||||
activeData.setWarpStatus(ActivationData.WarpedStatus.ACTIVATED);
|
||||
@ -70,11 +72,11 @@ public class MessageTag implements Tag.Activation {
|
||||
}
|
||||
|
||||
public void sendMessage(PlayerContainer player, String message) {
|
||||
if(this.configRepository.warpMessageOnActionBar()) {
|
||||
if (this.configRepository.warpMessageOnActionBar()) {
|
||||
player.sendActionBar(Lang.convertColors(message));
|
||||
}
|
||||
else if(this.configRepository.warpMessageInChat()) {
|
||||
player.sendMessage(Lang.getPositivePrefix() + " " + Lang.convertColors(message));
|
||||
} else if (this.configRepository.warpMessageInChat()) {
|
||||
player.sendMessage(Lang.getPositivePrefix() + " "
|
||||
+ Lang.convertColors(message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
|
||||
import com.sekwah.advancedportals.core.registry.TagTarget;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -8,7 +8,6 @@ import com.sekwah.advancedportals.core.util.InfoLogger;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
import com.sekwah.advancedportals.core.warphandler.ActivationData;
|
||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
@ -26,7 +25,8 @@ public class PermissionTag implements Tag.Activation {
|
||||
|
||||
private final String[] aliases = new String[] {"perm"};
|
||||
|
||||
private final TagType[] tagTypes = new TagType[] {TagType.PORTAL, TagType.DESTINATION};
|
||||
private final TagType[] tagTypes =
|
||||
new TagType[] {TagType.PORTAL, TagType.DESTINATION};
|
||||
|
||||
@Override
|
||||
public TagType[] getTagTypes() {
|
||||
@ -53,16 +53,18 @@ public class PermissionTag implements Tag.Activation {
|
||||
public boolean preActivated(TagTarget target, PlayerContainer player,
|
||||
ActivationData activeData, String[] argData) {
|
||||
var permission = argData[0];
|
||||
if(permission.startsWith("!")) {
|
||||
if (permission.startsWith("!")) {
|
||||
permission = permission.substring(1);
|
||||
if(player.hasPermission(permission)) {
|
||||
player.sendMessage(Lang.getNegativePrefix() + Lang.translate("portal.error.nopermission"));
|
||||
if (player.hasPermission(permission)) {
|
||||
player.sendMessage(
|
||||
Lang.getNegativePrefix()
|
||||
+ Lang.translate("portal.error.nopermission"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (!player.hasPermission(argData[0])) {
|
||||
player.sendMessage(Lang.getNegativePrefix() + Lang.translate("portal.error.nopermission"));
|
||||
} else if (!player.hasPermission(argData[0])) {
|
||||
player.sendMessage(Lang.getNegativePrefix()
|
||||
+ Lang.translate("portal.error.nopermission"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -10,13 +10,13 @@ import com.sekwah.advancedportals.core.util.Lang;
|
||||
import com.sekwah.advancedportals.core.warphandler.ActivationData;
|
||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||
import com.sekwah.advancedportals.core.warphandler.TriggerType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class PortalEventTag implements Tag.Activation, Tag.AutoComplete, Tag.DenyBehavior, Tag.OrderPriority {
|
||||
public class PortalEventTag implements Tag.Activation, Tag.AutoComplete,
|
||||
Tag.DenyBehavior, Tag.OrderPriority {
|
||||
@Inject
|
||||
PlayerDataServices playerDataServices;
|
||||
|
||||
@ -56,10 +56,11 @@ public class PortalEventTag implements Tag.Activation, Tag.AutoComplete, Tag.Den
|
||||
@Override
|
||||
public boolean preActivated(TagTarget target, PlayerContainer player,
|
||||
ActivationData activeData, String[] argData) {
|
||||
if(player.getGameMode() == GameMode.CREATIVE) {
|
||||
if (player.getGameMode() == GameMode.CREATIVE) {
|
||||
return true;
|
||||
}
|
||||
return !Objects.equals(argData[0], "true") || activeData.getTriggerType() == TriggerType.PORTAL;
|
||||
return !Objects.equals(argData[0], "true")
|
||||
|| activeData.getTriggerType() == TriggerType.PORTAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,18 +10,15 @@ import com.sekwah.advancedportals.core.repository.ConfigRepository;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
import com.sekwah.advancedportals.core.warphandler.ActivationData;
|
||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class ProxyTag implements Tag.Activation, Tag.OrderPriority, Tag.Split {
|
||||
|
||||
@Inject
|
||||
ConfigRepository configRepository;
|
||||
|
||||
public static String TAG_NAME = "proxy";
|
||||
|
||||
private final TagType[] tagTypes =
|
||||
new TagType[] {TagType.PORTAL};
|
||||
private final TagType[] tagTypes = new TagType[] {TagType.PORTAL};
|
||||
|
||||
private final Random random = new Random();
|
||||
|
||||
@ -46,22 +43,24 @@ public class ProxyTag implements Tag.Activation, Tag.OrderPriority, Tag.Split {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preActivated(TagTarget target, PlayerContainer player, ActivationData activeData, String[] argData) {
|
||||
public boolean preActivated(TagTarget target, PlayerContainer player,
|
||||
ActivationData activeData, String[] argData) {
|
||||
String selectedArg = argData[random.nextInt(argData.length)];
|
||||
activeData.setMetadata(TAG_NAME, selectedArg);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postActivated(TagTarget target, PlayerContainer player, ActivationData activationData, String[] argData) {
|
||||
|
||||
public void postActivated(TagTarget target, PlayerContainer player,
|
||||
ActivationData activationData, String[] argData) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activated(TagTarget target, PlayerContainer player, ActivationData activeData, String[] argData) {
|
||||
|
||||
if(!this.configRepository.getEnableProxySupport()) {
|
||||
player.sendMessage(Lang.getNegativePrefix() + Lang.translate("tag.proxy.notenabled"));
|
||||
public boolean activated(TagTarget target, PlayerContainer player,
|
||||
ActivationData activeData, String[] argData) {
|
||||
if (!this.configRepository.getEnableProxySupport()) {
|
||||
player.sendMessage(Lang.getNegativePrefix()
|
||||
+ Lang.translate("tag.proxy.notenabled"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -69,7 +68,9 @@ public class ProxyTag implements Tag.Activation, Tag.OrderPriority, Tag.Split {
|
||||
|
||||
var desti = activeData.getMetadata(DestiTag.TAG_NAME);
|
||||
|
||||
var packet = desti == null ? new ProxyTransferPacket(selectedArg) : new ProxyTransferDestiPacket(selectedArg, desti);
|
||||
var packet = desti == null
|
||||
? new ProxyTransferPacket(selectedArg)
|
||||
: new ProxyTransferDestiPacket(selectedArg, desti);
|
||||
player.sendPacket(ProxyMessages.CHANNEL_NAME, packet.encode());
|
||||
activeData.setWarpStatus(ActivationData.WarpedStatus.WARPED);
|
||||
return true;
|
||||
|
@ -4,9 +4,8 @@ import com.google.inject.Inject;
|
||||
import com.sekwah.advancedportals.core.connector.containers.ServerContainer;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
import com.sekwah.advancedportals.core.warphandler.Tag;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class TriggerBlockTag implements Tag.AutoComplete, Tag.Split {
|
||||
@Inject
|
||||
|
@ -2,7 +2,6 @@ package com.sekwah.advancedportals.core.util;
|
||||
|
||||
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
|
||||
import com.sekwah.advancedportals.core.serializeddata.BlockLocation;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class Debug {
|
||||
|
@ -4,7 +4,6 @@ import com.sekwah.advancedportals.core.serializeddata.BlockLocation;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.EncoderException;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.sekwah.advancedportals.core.util;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* For all delayed and repeating tasks.
|
||||
|
@ -2,7 +2,6 @@ package com.sekwah.advancedportals.core.util;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.sekwah.advancedportals.core.serializeddata.DataStorage;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
@ -2,7 +2,6 @@ package com.sekwah.advancedportals.core.util;
|
||||
|
||||
import com.sekwah.advancedportals.core.connector.containers.CommandSenderContainer;
|
||||
import com.sekwah.advancedportals.core.serializeddata.DataTag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -98,18 +97,16 @@ public class TagReader {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void printArgs(CommandSenderContainer sender,
|
||||
List<DataTag> dataTags) {
|
||||
for (DataTag tag : dataTags) {
|
||||
if (tag.VALUES.length == 1) {
|
||||
sender.sendMessage(" \u00A7a" + tag.NAME + "\u00A77:\u00A7e"
|
||||
+ tag.VALUES[0]);
|
||||
+ tag.VALUES[0]);
|
||||
} else {
|
||||
for (int i = 0; i < tag.VALUES.length; i++) {
|
||||
sender.sendMessage(" \u00A7a" + tag.NAME + "\u00A77[" + i
|
||||
+ "]:\u00A7e" + tag.VALUES[i]);
|
||||
+ "]:\u00A7e" + tag.VALUES[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.sekwah.advancedportals.core.warphandler;
|
||||
|
||||
import com.sekwah.advancedportals.core.serializeddata.PlayerLocation;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -2,9 +2,8 @@ package com.sekwah.advancedportals.core.warphandler;
|
||||
|
||||
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer;
|
||||
import com.sekwah.advancedportals.core.registry.TagTarget;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* If a tag can be used for any of them then either make it cast the target or
|
||||
|
@ -1,7 +1,3 @@
|
||||
package com.sekwah.advancedportals.core.warphandler;
|
||||
|
||||
public enum TriggerType {
|
||||
MOVEMENT,
|
||||
PORTAL,
|
||||
MANUAL
|
||||
}
|
||||
public enum TriggerType { MOVEMENT, PORTAL, MANUAL }
|
||||
|
@ -1,5 +1,5 @@
|
||||
package com.sekwah.advancedportals.core;
|
||||
|
||||
public class BuildConstants {
|
||||
public static final String VERSION = "${version}";
|
||||
public static final String VERSION = "${version}";
|
||||
}
|
||||
|
@ -12,17 +12,16 @@ import com.sekwah.advancedportals.proxycore.connector.container.ProxyContainer;
|
||||
import com.sekwah.advancedportals.proxycore.connector.container.ProxyJoinData;
|
||||
import com.sekwah.advancedportals.proxycore.connector.container.ProxyPlayerContainer;
|
||||
import com.sekwah.advancedportals.proxycore.connector.container.ProxyServerContainer;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class AdvancedPortalsProxyCore {
|
||||
|
||||
private final InfoLogger logger;
|
||||
private final ProxyContainer proxyContainer;
|
||||
|
||||
public HashMap<String, ProxyJoinData> playerJoinMap = new HashMap<>();
|
||||
|
||||
public AdvancedPortalsProxyCore(InfoLogger logger, ProxyContainer proxyContainer) {
|
||||
public AdvancedPortalsProxyCore(InfoLogger logger,
|
||||
ProxyContainer proxyContainer) {
|
||||
this.logger = logger;
|
||||
this.proxyContainer = proxyContainer;
|
||||
}
|
||||
@ -35,11 +34,14 @@ public class AdvancedPortalsProxyCore {
|
||||
this.logger.info(Lang.convertColors("&cDisabling plugin!"));
|
||||
}
|
||||
|
||||
public void onServerConnect(ProxyServerContainer server, ProxyPlayerContainer player) {
|
||||
if(this.playerJoinMap.containsKey(player.getUUID())) {
|
||||
public void onServerConnect(ProxyServerContainer server,
|
||||
ProxyPlayerContainer player) {
|
||||
if (this.playerJoinMap.containsKey(player.getUUID())) {
|
||||
var joinData = this.playerJoinMap.get(player.getUUID());
|
||||
if(joinData.isExpired()) return;
|
||||
player.sendServerPluginMessage(new ServerDestiPacket(joinData.destination).encode());
|
||||
if (joinData.isExpired())
|
||||
return;
|
||||
player.sendServerPluginMessage(
|
||||
new ServerDestiPacket(joinData.destination).encode());
|
||||
this.playerJoinMap.remove(player.getUUID());
|
||||
}
|
||||
}
|
||||
@ -49,17 +51,18 @@ public class AdvancedPortalsProxyCore {
|
||||
}
|
||||
|
||||
/**
|
||||
* Messages coming on the ProxyMessages.CHANNEL_NAME from the server, others will be filtered out before now.
|
||||
* Messages coming on the ProxyMessages.CHANNEL_NAME from the server, others
|
||||
* will be filtered out before now.
|
||||
* @param player
|
||||
* @param message
|
||||
*/
|
||||
public void incomingMessage(ProxyPlayerContainer player, byte[] message) {
|
||||
|
||||
var buffer = ByteStreams.newDataInput(message);
|
||||
var messageType = buffer.readUTF();
|
||||
|
||||
// Might be a bit overboard for some as they'll only have one value, but try to keep the decode behavior with
|
||||
// the encode behavior in the packets
|
||||
// Might be a bit overboard for some as they'll only have one value, but
|
||||
// try to keep the decode behavior with the encode behavior in the
|
||||
// packets
|
||||
switch (messageType) {
|
||||
case ProxyMessages.PROXY_TRANSFER -> {
|
||||
var transferPacket = ProxyTransferPacket.decode(buffer);
|
||||
|
@ -4,5 +4,4 @@ public interface ProxyContainer {
|
||||
void invokeCommand(ProxyPlayerContainer proxyPlayer, String command);
|
||||
|
||||
void transferPlayer(ProxyPlayerContainer proxyPlayer, String serverName);
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.sekwah.advancedportals.proxycore.connector.container;
|
||||
|
||||
public class ProxyJoinData {
|
||||
|
||||
public final String destination;
|
||||
public final String serverName;
|
||||
public final long joinTime;
|
||||
@ -13,6 +12,7 @@ public class ProxyJoinData {
|
||||
}
|
||||
|
||||
public boolean isExpired() {
|
||||
return System.currentTimeMillis() - this.joinTime > 1000 * 15; // 15 seconds
|
||||
return System.currentTimeMillis() - this.joinTime
|
||||
> 1000 * 15; // 15 seconds
|
||||
}
|
||||
}
|
||||
|
@ -11,10 +11,9 @@ import com.sekwah.advancedportals.spigot.connector.command.SpigotCommandRegister
|
||||
import com.sekwah.advancedportals.spigot.connector.container.SpigotServerContainer;
|
||||
import com.sekwah.advancedportals.spigot.metrics.Metrics;
|
||||
import com.sekwah.advancedportals.spigot.warpeffects.SpigotWarpEffects;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||
private AdvancedPortalsCore portalsCore;
|
||||
|
@ -9,6 +9,7 @@ import com.sekwah.advancedportals.spigot.connector.container.SpigotEntityContain
|
||||
import com.sekwah.advancedportals.spigot.connector.container.SpigotPlayerContainer;
|
||||
import com.sekwah.advancedportals.spigot.connector.container.SpigotWorldContainer;
|
||||
import com.sekwah.advancedportals.spigot.utils.ContainerHelpers;
|
||||
import java.util.List;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -23,8 +24,6 @@ import org.bukkit.event.entity.*;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Some of these will be passed to the core listener to handle the events,
|
||||
* others it's easier to just check directly.
|
||||
@ -68,7 +67,8 @@ public class Listeners implements Listener {
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPortalEvent(PlayerPortalEvent event) {
|
||||
if (!this.coreListeners.playerPortalEvent(
|
||||
new SpigotPlayerContainer(event.getPlayer()), ContainerHelpers.toPlayerLocation(event.getFrom()))) {
|
||||
new SpigotPlayerContainer(event.getPlayer()),
|
||||
ContainerHelpers.toPlayerLocation(event.getFrom()))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -210,25 +210,26 @@ public class Listeners implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onChunkLoad(ChunkLoadEvent event) {
|
||||
if(!configRepository.getDisableGatewayBeam()) {
|
||||
if (!configRepository.getDisableGatewayBeam()) {
|
||||
return;
|
||||
}
|
||||
SpigotWorldContainer world = new SpigotWorldContainer(event.getWorld());
|
||||
BlockState[] tileEntities = event.getChunk().getTileEntities();
|
||||
for(BlockState block : tileEntities) {
|
||||
if(block.getType() == Material.END_GATEWAY) {
|
||||
for (BlockState block : tileEntities) {
|
||||
if (block.getType() == Material.END_GATEWAY) {
|
||||
var loc = block.getLocation();
|
||||
if(portalServices.inPortalRegion(new BlockLocation(loc.getWorld().getName(),
|
||||
loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), 2)) {
|
||||
if (portalServices.inPortalRegion(
|
||||
new BlockLocation(loc.getWorld().getName(),
|
||||
loc.getBlockX(), loc.getBlockY(),
|
||||
loc.getBlockZ()),
|
||||
2)) {
|
||||
EndGateway tileState = (EndGateway) block;
|
||||
tileState.setAge(Long.MIN_VALUE);
|
||||
tileState.update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,9 @@
|
||||
package com.sekwah.advancedportals.spigot;
|
||||
|
||||
|
||||
import com.sekwah.advancedportals.core.permissions.PermissionBuilder;
|
||||
import com.sekwah.advancedportals.core.permissions.Permissions;
|
||||
|
||||
public class PermissionsGeneratorSpigot {
|
||||
|
||||
private PermissionsGeneratorSpigot() {
|
||||
}
|
||||
|
||||
@ -16,25 +14,28 @@ public class PermissionsGeneratorSpigot {
|
||||
public static String toPermBlock(PermissionBuilder permission) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String indent = " ";
|
||||
if(!permission.isDoNotExport()) {
|
||||
if (!permission.isDoNotExport()) {
|
||||
builder.append(indent).append(permission).append(":\n");
|
||||
builder.append(indent).append(indent).append("default: ");
|
||||
builder.append(permission.getPermissionDefault().toString().toLowerCase());
|
||||
builder.append(
|
||||
permission.getPermissionDefault().toString().toLowerCase());
|
||||
builder.append("\n");
|
||||
if(permission.getDescription() != null) {
|
||||
if (permission.getDescription() != null) {
|
||||
builder.append(indent).append(indent).append("description: ");
|
||||
builder.append(permission.getDescription()).append("\n");
|
||||
}
|
||||
var children = permission.getGrantChildren();
|
||||
if(!children.isEmpty()) {
|
||||
if (!children.isEmpty()) {
|
||||
builder.append(indent).append(indent).append("children:\n");
|
||||
for(PermissionBuilder child : children) {
|
||||
for (PermissionBuilder child : children) {
|
||||
builder.append(indent).append(indent).append(indent);
|
||||
builder.append(child.toString()).append(": true").append("\n");
|
||||
builder.append(child.toString())
|
||||
.append(": true")
|
||||
.append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
for(PermissionBuilder child : permission.getChildren()) {
|
||||
for (PermissionBuilder child : permission.getChildren()) {
|
||||
builder.append(toPermBlock(child));
|
||||
}
|
||||
return builder.toString();
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.sekwah.advancedportals.spigot;
|
||||
|
||||
import com.sekwah.advancedportals.core.util.InfoLogger;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class SpigotInfoLogger extends InfoLogger {
|
||||
|
@ -12,14 +12,12 @@ import com.sekwah.advancedportals.core.services.PortalServices;
|
||||
import com.sekwah.advancedportals.core.util.Lang;
|
||||
import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.spigot.commands.subcommands.portal.importer.ConfigAccessor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class ImportPortalSubCommand implements SubCommand {
|
||||
|
||||
@Inject
|
||||
DestinationServices destinationServices;
|
||||
|
||||
@ -77,7 +75,7 @@ public class ImportPortalSubCommand implements SubCommand {
|
||||
|
||||
var bungee = config.getString(portalName + ".bungee");
|
||||
if (bungee != null) {
|
||||
if(destination == null) {
|
||||
if (destination == null) {
|
||||
args.add(new DataTag("bungee", bungee.split(",")));
|
||||
} else {
|
||||
args.add(new DataTag("proxy", bungee.split(",")));
|
||||
|
@ -1,12 +1,11 @@
|
||||
package com.sekwah.advancedportals.spigot.commands.subcommands.portal.importer;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class ConfigAccessor {
|
||||
private final String fileName;
|
||||
|
@ -2,13 +2,12 @@ package com.sekwah.advancedportals.spigot.connector.command;
|
||||
|
||||
import com.sekwah.advancedportals.core.commands.CommandTemplate;
|
||||
import com.sekwah.advancedportals.spigot.connector.container.SpigotCommandSenderContainer;
|
||||
import java.util.List;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SpigotCommandHandler implements CommandExecutor, TabCompleter {
|
||||
private final CommandTemplate commandExecutor;
|
||||
|
||||
|
@ -9,6 +9,8 @@ import com.sekwah.advancedportals.core.serializeddata.BlockLocation;
|
||||
import com.sekwah.advancedportals.core.serializeddata.PlayerLocation;
|
||||
import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.spigot.reflection.MinecraftCustomPayload;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -18,9 +20,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Just a temporary container for whenever advanced portals needs to get data
|
||||
* from a player
|
||||
@ -49,7 +48,8 @@ public class SpigotPlayerContainer
|
||||
|
||||
@Override
|
||||
public void sendActionBar(String message) {
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR,
|
||||
TextComponent.fromLegacyText(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,15 +7,14 @@ import com.sekwah.advancedportals.core.connector.containers.ServerContainer;
|
||||
import com.sekwah.advancedportals.core.connector.containers.WorldContainer;
|
||||
import com.sekwah.advancedportals.core.tags.CommandTag;
|
||||
import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SpigotServerContainer implements ServerContainer {
|
||||
@Inject
|
||||
private CoreListeners coreListeners;
|
||||
@ -75,13 +74,17 @@ public class SpigotServerContainer implements ServerContainer {
|
||||
|
||||
@Override
|
||||
public void registerOutgoingChannel(String channel) {
|
||||
server.getMessenger().registerOutgoingPluginChannel(AdvancedPortalsPlugin.getInstance(), channel);
|
||||
server.getMessenger().registerOutgoingPluginChannel(
|
||||
AdvancedPortalsPlugin.getInstance(), channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIncomingChannel(String channel) {
|
||||
server.getMessenger().registerIncomingPluginChannel(AdvancedPortalsPlugin.getInstance(), channel,
|
||||
(s, player, bytes) -> coreListeners.incomingMessage(new SpigotPlayerContainer(player), s, bytes));
|
||||
server.getMessenger().registerIncomingPluginChannel(
|
||||
AdvancedPortalsPlugin.getInstance(), channel,
|
||||
(s, player, bytes)
|
||||
-> coreListeners.incomingMessage(
|
||||
new SpigotPlayerContainer(player), s, bytes));
|
||||
}
|
||||
|
||||
// Check if it's a material compatible with making portals
|
||||
|
@ -14,12 +14,14 @@ import org.bukkit.block.data.Orientable;
|
||||
public class SpigotWorldContainer implements WorldContainer {
|
||||
private final World world;
|
||||
|
||||
// Should only be false for 1.13 and 1.13.2, though just to avoid possible crashes
|
||||
// Should only be false for 1.13 and 1.13.2, though just to avoid possible
|
||||
// crashes
|
||||
private static boolean endGatewaySetAgeExists;
|
||||
|
||||
static {
|
||||
try {
|
||||
endGatewaySetAgeExists = EndGateway.class.getMethod("setAge", long.class) != null;
|
||||
endGatewaySetAgeExists =
|
||||
EndGateway.class.getMethod("setAge", long.class) != null;
|
||||
} catch (NoSuchMethodException e) {
|
||||
endGatewaySetAgeExists = false;
|
||||
}
|
||||
@ -74,11 +76,13 @@ public class SpigotWorldContainer implements WorldContainer {
|
||||
|
||||
@Override
|
||||
public void disableBeacon(BlockLocation location) {
|
||||
if(!endGatewaySetAgeExists) return;
|
||||
var block = this.world.getBlockAt(location.getPosX(), location.getPosY(),
|
||||
location.getPosZ());
|
||||
if (!endGatewaySetAgeExists)
|
||||
return;
|
||||
var block = this.world.getBlockAt(
|
||||
location.getPosX(), location.getPosY(), location.getPosZ());
|
||||
var blockType = block.getType();
|
||||
if(blockType == Material.END_GATEWAY && block.getState() instanceof EndGateway endGateway) {
|
||||
if (blockType == Material.END_GATEWAY
|
||||
&& block.getState() instanceof EndGateway endGateway) {
|
||||
endGateway.setAge(Long.MIN_VALUE);
|
||||
endGateway.update();
|
||||
}
|
||||
@ -86,15 +90,16 @@ public class SpigotWorldContainer implements WorldContainer {
|
||||
|
||||
@Override
|
||||
public void disableBeacon(AdvancedPortal portal) {
|
||||
if(!endGatewaySetAgeExists) return;
|
||||
if (!endGatewaySetAgeExists)
|
||||
return;
|
||||
BlockLocation maxLoc = portal.getMaxLoc();
|
||||
BlockLocation minLoc = portal.getMinLoc();
|
||||
BlockLocation minLoc = portal.getMinLoc();
|
||||
|
||||
for (int x = minLoc.getPosX(); x <= maxLoc.getPosX(); x++) {
|
||||
for (int y = minLoc.getPosY(); y <= maxLoc.getPosY(); y++) {
|
||||
for (int z = minLoc.getPosZ(); z <= maxLoc.getPosZ(); z++) {
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
if(block.getType() == Material.END_GATEWAY) {
|
||||
if (block.getType() == Material.END_GATEWAY) {
|
||||
EndGateway tileState = (EndGateway) block.getState();
|
||||
tileState.setAge(Long.MIN_VALUE);
|
||||
tileState.update();
|
||||
|
@ -3,14 +3,6 @@ package com.sekwah.advancedportals.spigot.metrics;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@ -20,6 +12,13 @@ import java.util.*;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
|
||||
/**
|
||||
* bStats collects some data for plugin authors.
|
||||
|
@ -1,9 +1,8 @@
|
||||
package com.sekwah.advancedportals.spigot.reflection;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Just a util class to force spigot to allow us to have fun with the
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.sekwah.advancedportals.spigot.warpeffects;
|
||||
|
||||
import com.sekwah.advancedportals.core.registry.WarpEffectRegistry;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class SpigotWarpEffects {
|
||||
|
@ -14,4 +14,4 @@ commands:
|
||||
aliases: [desti]
|
||||
usage: /<command>
|
||||
permissions:
|
||||
${permissions}
|
||||
${permissions}
|
||||
|
@ -18,11 +18,11 @@ import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@Plugin(authors = {"sekwah41"} ,id = "advancedportals", name = "Advanced Portals",
|
||||
@Plugin(authors = {"sekwah41"}, id = "advancedportals",
|
||||
name = "Advanced Portals",
|
||||
url = "https://www.spigotmc.org/resources/advanced-portals.14356/",
|
||||
version = BuildConstants.VERSION)
|
||||
public class AdvancedPortalsVelocityPlugin {
|
||||
|
||||
private AdvancedPortalsProxyCore proxyCore;
|
||||
|
||||
private final Logger logger;
|
||||
@ -34,7 +34,9 @@ public class AdvancedPortalsVelocityPlugin {
|
||||
public AdvancedPortalsVelocityPlugin(ProxyServer proxy, Logger logger) {
|
||||
this.proxy = proxy;
|
||||
this.logger = logger;
|
||||
this.proxyCore = new AdvancedPortalsProxyCore(new VelocityInfoLogger(this.logger, this.proxy), new VelocityProxyContainer(this.proxy));
|
||||
this.proxyCore = new AdvancedPortalsProxyCore(
|
||||
new VelocityInfoLogger(this.logger, this.proxy),
|
||||
new VelocityProxyContainer(this.proxy));
|
||||
this.proxyCore.onEnable();
|
||||
}
|
||||
|
||||
@ -48,25 +50,32 @@ public class AdvancedPortalsVelocityPlugin {
|
||||
@Subscribe
|
||||
public void onPluginMessage(PluginMessageEvent event) {
|
||||
if (event.getIdentifier().equals(AP_CHANNEL)) {
|
||||
if(event.getSource() instanceof ServerConnection serverConnection) {
|
||||
this.proxyCore.incomingMessage(new VelocityProxyPlayerContainer(serverConnection.getPlayer(), AP_CHANNEL), event.getData());
|
||||
if (event.getSource()
|
||||
instanceof ServerConnection serverConnection) {
|
||||
this.proxyCore.incomingMessage(
|
||||
new VelocityProxyPlayerContainer(
|
||||
serverConnection.getPlayer(), AP_CHANNEL),
|
||||
event.getData());
|
||||
}
|
||||
// So that client packets don't make it through to the servers, always trigger on this channel.
|
||||
// So that client packets don't make it through to the servers,
|
||||
// always trigger on this channel.
|
||||
event.setResult(PluginMessageEvent.ForwardResult.handled());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void postJoinEvent(ServerPostConnectEvent event) {
|
||||
event.getPlayer().getCurrentServer().ifPresent(serverConnection -> {
|
||||
this.proxyCore.onServerConnect(new VelocityProxyServerContainer(serverConnection.getServer()), new VelocityProxyPlayerContainer(event.getPlayer(), AP_CHANNEL));
|
||||
this.proxyCore.onServerConnect(
|
||||
new VelocityProxyServerContainer(serverConnection.getServer()),
|
||||
new VelocityProxyPlayerContainer(event.getPlayer(),
|
||||
AP_CHANNEL));
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onDisconnect(DisconnectEvent event) {
|
||||
this.proxyCore.onPlayerDisconnect(new VelocityProxyPlayerContainer(event.getPlayer(), AP_CHANNEL));
|
||||
this.proxyCore.onPlayerDisconnect(
|
||||
new VelocityProxyPlayerContainer(event.getPlayer(), AP_CHANNEL));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,10 +6,14 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
public class VelocityInfoLogger extends InfoLogger {
|
||||
|
||||
private final Logger logger;
|
||||
private final ProxyServer proxy;
|
||||
private final LegacyComponentSerializer serializer = LegacyComponentSerializer.builder().character('&').hexCharacter('#').hexColors().build();
|
||||
private final LegacyComponentSerializer serializer =
|
||||
LegacyComponentSerializer.builder()
|
||||
.character('&')
|
||||
.hexCharacter('#')
|
||||
.hexColors()
|
||||
.build();
|
||||
|
||||
public VelocityInfoLogger(Logger logger, ProxyServer proxy) {
|
||||
this.logger = logger;
|
||||
|
@ -4,12 +4,14 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* I believe later versions of velocity have some component handlers for this, and I could just send it to the server as components
|
||||
* but ive decided to throw this in for now just to use the plugin logger. Also, to try to clone the bungee behavior as close as possible.
|
||||
* I believe later versions of velocity have some component handlers for this,
|
||||
* and I could just send it to the server as components but ive decided to throw
|
||||
* this in for now just to use the plugin logger. Also, to try to clone the
|
||||
* bungee behavior as close as possible.
|
||||
*/
|
||||
public class MinecraftToAnsi {
|
||||
|
||||
private static final Map<Character, String> minecraftToAnsiMap = new HashMap<>();
|
||||
private static final Map<Character, String> minecraftToAnsiMap =
|
||||
new HashMap<>();
|
||||
|
||||
static {
|
||||
minecraftToAnsiMap.put('0', "\u001B[30m"); // Black
|
||||
@ -28,12 +30,12 @@ public class MinecraftToAnsi {
|
||||
minecraftToAnsiMap.put('d', "\u001B[95m"); // Light Purple
|
||||
minecraftToAnsiMap.put('e', "\u001B[93m"); // Yellow
|
||||
minecraftToAnsiMap.put('f', "\u001B[97m"); // White
|
||||
minecraftToAnsiMap.put('k', "\u001B[5m"); // Obfuscated (Blinking)
|
||||
minecraftToAnsiMap.put('l', "\u001B[1m"); // Bold
|
||||
minecraftToAnsiMap.put('m', "\u001B[9m"); // Strikethrough
|
||||
minecraftToAnsiMap.put('n', "\u001B[4m"); // Underline
|
||||
minecraftToAnsiMap.put('o', "\u001B[3m"); // Italic
|
||||
minecraftToAnsiMap.put('r', "\u001B[0m"); // Reset
|
||||
minecraftToAnsiMap.put('k', "\u001B[5m"); // Obfuscated (Blinking)
|
||||
minecraftToAnsiMap.put('l', "\u001B[1m"); // Bold
|
||||
minecraftToAnsiMap.put('m', "\u001B[9m"); // Strikethrough
|
||||
minecraftToAnsiMap.put('n', "\u001B[4m"); // Underline
|
||||
minecraftToAnsiMap.put('o', "\u001B[3m"); // Italic
|
||||
minecraftToAnsiMap.put('r', "\u001B[0m"); // Reset
|
||||
}
|
||||
|
||||
public static String convert(String text) {
|
||||
|
@ -13,21 +13,32 @@ public class VelocityProxyContainer implements ProxyContainer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invokeCommand(ProxyPlayerContainer proxyPlayer, String command) {
|
||||
if(proxyPlayer instanceof VelocityProxyPlayerContainer playerContainer) {
|
||||
this.proxy.getCommandManager().executeAsync(playerContainer.getPlayer(), command);
|
||||
public void invokeCommand(ProxyPlayerContainer proxyPlayer,
|
||||
String command) {
|
||||
if (proxyPlayer
|
||||
instanceof VelocityProxyPlayerContainer playerContainer) {
|
||||
this.proxy.getCommandManager().executeAsync(
|
||||
playerContainer.getPlayer(), command);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferPlayer(ProxyPlayerContainer proxyPlayer, String serverName) {
|
||||
if(proxyPlayer instanceof VelocityProxyPlayerContainer playerContainer) {
|
||||
this.proxy.getServer(serverName).ifPresentOrElse(
|
||||
server -> {
|
||||
playerContainer.getPlayer().createConnectionRequest(server).fireAndForget();
|
||||
},
|
||||
() -> playerContainer.getPlayer().sendMessage(Component.text("Could not find server: " + serverName))
|
||||
);
|
||||
public void transferPlayer(ProxyPlayerContainer proxyPlayer,
|
||||
String serverName) {
|
||||
if (proxyPlayer
|
||||
instanceof VelocityProxyPlayerContainer playerContainer) {
|
||||
this.proxy.getServer(serverName)
|
||||
.ifPresentOrElse(
|
||||
server
|
||||
-> {
|
||||
playerContainer.getPlayer()
|
||||
.createConnectionRequest(server)
|
||||
.fireAndForget();
|
||||
},
|
||||
()
|
||||
-> playerContainer.getPlayer().sendMessage(
|
||||
Component.text("Could not find server: "
|
||||
+ serverName)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,11 @@ import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
|
||||
|
||||
public class VelocityProxyPlayerContainer implements ProxyPlayerContainer {
|
||||
|
||||
private final Player player;
|
||||
private final LegacyChannelIdentifier channel;
|
||||
|
||||
public VelocityProxyPlayerContainer(Player player, LegacyChannelIdentifier channel) {
|
||||
public VelocityProxyPlayerContainer(Player player,
|
||||
LegacyChannelIdentifier channel) {
|
||||
this.player = player;
|
||||
this.channel = channel;
|
||||
}
|
||||
@ -26,7 +26,9 @@ public class VelocityProxyPlayerContainer implements ProxyPlayerContainer {
|
||||
|
||||
@Override
|
||||
public void sendServerPluginMessage(byte[] data) {
|
||||
player.getCurrentServer().ifPresent(serverConnection -> serverConnection.sendPluginMessage(channel, data));
|
||||
player.getCurrentServer().ifPresent(
|
||||
serverConnection
|
||||
-> serverConnection.sendPluginMessage(channel, data));
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
|
Loading…
Reference in New Issue
Block a user