chore: pre-commit changes [skip ci]

This commit is contained in:
github-actions[bot] 2025-01-13 12:44:49 +00:00
parent dfacc7fbf3
commit 414cda8d25
31 changed files with 276 additions and 239 deletions

View File

@ -20,7 +20,8 @@ public class BungeeProxyContainer implements ProxyContainer {
String command) { String command) {
// Should never not be true but just to be safe // Should never not be true but just to be safe
if (proxyPlayer instanceof BungeeProxyPlayerContainer) { if (proxyPlayer instanceof BungeeProxyPlayerContainer) {
BungeeProxyPlayerContainer playerContainer = (BungeeProxyPlayerContainer) proxyPlayer; BungeeProxyPlayerContainer playerContainer =
(BungeeProxyPlayerContainer) proxyPlayer;
plugin.getProxy().getPluginManager().dispatchCommand( plugin.getProxy().getPluginManager().dispatchCommand(
playerContainer.getPlayer(), command); playerContainer.getPlayer(), command);
} }
@ -31,7 +32,8 @@ public class BungeeProxyContainer implements ProxyContainer {
String serverName) { String serverName) {
// Should never not be true but just to be safe // Should never not be true but just to be safe
if (proxyPlayer instanceof BungeeProxyPlayerContainer) { if (proxyPlayer instanceof BungeeProxyPlayerContainer) {
BungeeProxyPlayerContainer playerContainer = (BungeeProxyPlayerContainer) proxyPlayer; BungeeProxyPlayerContainer playerContainer =
(BungeeProxyPlayerContainer) proxyPlayer;
ServerInfo serverInfo = plugin.getProxy().getServerInfo(serverName); ServerInfo serverInfo = plugin.getProxy().getServerInfo(serverName);
ProxiedPlayer player = playerContainer.getPlayer(); ProxiedPlayer player = playerContainer.getPlayer();
if (serverInfo == null) { if (serverInfo == null) {

View File

@ -218,7 +218,8 @@ public class AdvancedPortalsCore {
} }
public void onDisable() { public void onDisable() {
for (PlayerContainer playerContainer : this.serverContainer.getPlayers()) { for (PlayerContainer playerContainer :
this.serverContainer.getPlayers()) {
playerDataRepository.playerLeave(playerContainer); playerDataRepository.playerLeave(playerContainer);
} }
this.infoLogger.info(Lang.translate("logger.plugindisable")); this.infoLogger.info(Lang.translate("logger.plugindisable"));

View File

@ -70,13 +70,13 @@ public class CoreListeners {
String messageType = buffer.readUTF(); String messageType = buffer.readUTF();
switch (messageType) { switch (messageType) {
case ProxyMessages.SERVER_DESTI: case ProxyMessages.SERVER_DESTI: {
{ ServerDestiPacket serverDestiPacket =
ServerDestiPacket serverDestiPacket = ServerDestiPacket.decode(buffer); ServerDestiPacket.decode(buffer);
this.destinationServices.teleportToDestination(serverDestiPacket.getDestination(), player, true); this.destinationServices.teleportToDestination(
serverDestiPacket.getDestination(), player, true);
} }
} }
} }
public void tick() { public void tick() {
@ -88,7 +88,8 @@ public class CoreListeners {
* @param toLoc * @param toLoc
*/ */
public void playerMove(PlayerContainer player, PlayerLocation toLoc) { public void playerMove(PlayerContainer player, PlayerLocation toLoc) {
this.portalServices.checkPortalActivation(player, toLoc, TriggerType.MOVEMENT); this.portalServices.checkPortalActivation(player, toLoc,
TriggerType.MOVEMENT);
} }
/** /**
@ -132,7 +133,8 @@ public class CoreListeners {
if (itemInHandName.equals("\u00A75Portal Block Placer")) { if (itemInHandName.equals("\u00A75Portal Block Placer")) {
world.setBlock(blockPos, "NETHER_PORTAL"); world.setBlock(blockPos, "NETHER_PORTAL");
for (Direction direction : Direction.values()) { for (Direction direction : Direction.values()) {
BlockLocation checkLoc = new BlockLocation(blockPos, direction); BlockLocation checkLoc =
new BlockLocation(blockPos, direction);
if (world.getBlock(checkLoc).equals("NETHER_PORTAL")) { if (world.getBlock(checkLoc).equals("NETHER_PORTAL")) {
world.setBlockAxis(blockPos, world.setBlockAxis(blockPos,
world.getBlockAxis(checkLoc)); world.getBlockAxis(checkLoc));
@ -140,12 +142,11 @@ public class CoreListeners {
} }
} }
return true; return true;
} } else if (itemInHandName.equals(
else if (itemInHandName.equals("\u00A78End Portal Block Placer")) { "\u00A78End Portal Block Placer")) {
world.setBlock(blockPos, "END_PORTAL"); world.setBlock(blockPos, "END_PORTAL");
return true; return true;
} } else if (itemInHandName.equals("\u00A78Gateway Block Placer")) {
else if (itemInHandName.equals("\u00A78Gateway Block Placer")) {
world.setBlock(blockPos, "END_GATEWAY"); world.setBlock(blockPos, "END_GATEWAY");
world.disableBeacon(blockPos); world.disableBeacon(blockPos);
return true; return true;
@ -160,27 +161,29 @@ public class CoreListeners {
return false; return false;
} }
return true; return true;
} }
/** /**
* If the block is allowed to be interacted with e.g. a lever * If the block is allowed to be interacted with e.g. a lever
* @player player causing the event (or null if not a player) * @player player causing the event (or null if not a player)
* @param blockPos * @param blockPos
* @return * @return
*/ */
public boolean blockInteract(PlayerContainer player, BlockLocation blockPos) { public boolean blockInteract(PlayerContainer player,
BlockLocation blockPos) {
return true; return true;
} }
/** /**
* @param player * @param player
* @param blockLoc * @param blockLoc
* @param leftClick true = left click, false = right click * @param leftClick true = left click, false = right click
* @return if player is allowed to interact with block * @return if player is allowed to interact with block
*/ */
public boolean playerInteractWithBlock(PlayerContainer player, public boolean playerInteractWithBlock(PlayerContainer player,
String blockMaterialname, String blockMaterialname,
String itemMaterialName, String itemName, String itemMaterialName,
String itemName,
BlockLocation blockLoc, BlockLocation blockLoc,
boolean leftClick) { boolean leftClick) {
if (itemName != null && Permissions.CREATE_PORTAL.hasPermission(player) if (itemName != null && Permissions.CREATE_PORTAL.hasPermission(player)
@ -208,20 +211,20 @@ public boolean playerInteractWithBlock(PlayerContainer player,
} }
return true; return true;
} }
public void worldChange(PlayerContainer player) { public void worldChange(PlayerContainer player) {
this.playerDataServices.setJoinCooldown(player); this.playerDataServices.setJoinCooldown(player);
this.setIfInPortal(player); this.setIfInPortal(player);
} }
public boolean preventEntityCombust(EntityContainer entity) { public boolean preventEntityCombust(EntityContainer entity) {
return portalServices.inPortalRegion(entity.getBlockLoc(), 2); return portalServices.inPortalRegion(entity.getBlockLoc(), 2);
} }
public boolean entityPortalEvent(EntityContainer entity) { public boolean entityPortalEvent(EntityContainer entity) {
BlockLocation pos = entity.getBlockLoc(); BlockLocation pos = entity.getBlockLoc();
if (entity instanceof PlayerContainer ) { if (entity instanceof PlayerContainer) {
PlayerContainer player = (PlayerContainer) entity; PlayerContainer player = (PlayerContainer) entity;
PlayerData playerData = playerDataServices.getPlayerData(player); PlayerData playerData = playerDataServices.getPlayerData(player);
if (playerData.getPortalBlockCooldown()) { if (playerData.getPortalBlockCooldown()) {
@ -232,35 +235,38 @@ public boolean entityPortalEvent(EntityContainer entity) {
return !(portalServices.inPortalRegion(pos, 1) return !(portalServices.inPortalRegion(pos, 1)
|| portalServices.inPortalRegion( || portalServices.inPortalRegion(
pos.addY((int) entity.getHeight()), 1)); pos.addY((int) entity.getHeight()), 1));
} }
public boolean playerPortalEvent(PlayerContainer player, PlayerLocation toLoc) { public boolean playerPortalEvent(PlayerContainer player,
PlayerLocation toLoc) {
PlayerData playerData = playerDataServices.getPlayerData(player); PlayerData playerData = playerDataServices.getPlayerData(player);
if (playerData.getPortalBlockCooldown()) { if (playerData.getPortalBlockCooldown()) {
return false; return false;
} }
PortalServices.PortalActivationResult portalResult = this.portalServices.checkPortalActivation( PortalServices.PortalActivationResult portalResult =
player, toLoc, TriggerType.PORTAL); this.portalServices.checkPortalActivation(player, toLoc,
TriggerType.PORTAL);
if (portalResult != PortalServices.PortalActivationResult.NOT_IN_PORTAL) { if (portalResult
!= PortalServices.PortalActivationResult.NOT_IN_PORTAL) {
return false; return false;
} }
// Extra checks to prevent the player from being teleported by touching a // Extra checks to prevent the player from being teleported by touching
// portal but not having their body fully in the portal // a portal but not having their body fully in the portal
BlockLocation pos = player.getBlockLoc(); BlockLocation pos = player.getBlockLoc();
boolean feetInPortal = portalServices.inPortalRegion(pos, 1); boolean feetInPortal = portalServices.inPortalRegion(pos, 1);
boolean headInPortal = boolean headInPortal = portalServices.inPortalRegion(
portalServices.inPortalRegion(pos.addY((int) player.getHeight()), 1); pos.addY((int) player.getHeight()), 1);
return !(feetInPortal || headInPortal); return !(feetInPortal || headInPortal);
} }
public boolean physicsEvent(BlockLocation blockLocation, String string) { public boolean physicsEvent(BlockLocation blockLocation, String string) {
return !configRepository.getDisablePhysicsEvents() return !configRepository.getDisablePhysicsEvents()
|| !portalServices.inPortalRegionProtected(blockLocation); || !portalServices.inPortalRegionProtected(blockLocation);
} }
} }

View File

@ -36,8 +36,9 @@ public class CommandWithSubCommands implements CommandTemplate {
boolean result = boolean result =
this.subCommandRegistry.registerSubCommand(arg, subCommand) this.subCommandRegistry.registerSubCommand(arg, subCommand)
|| hasRegistered; || hasRegistered;
if (subCommand instanceof SubCommand.SubCommandOnInit ) { if (subCommand instanceof SubCommand.SubCommandOnInit) {
SubCommand.SubCommandOnInit init = (SubCommand.SubCommandOnInit) subCommand; SubCommand.SubCommandOnInit init =
(SubCommand.SubCommandOnInit) subCommand;
init.registered(); init.registered();
} }
return result; return result;

View File

@ -5,7 +5,6 @@ import com.sekwah.advancedportals.core.connector.containers.CommandSenderContain
import com.sekwah.advancedportals.core.serializeddata.DataTag; import com.sekwah.advancedportals.core.serializeddata.DataTag;
import com.sekwah.advancedportals.core.util.TagReader; import com.sekwah.advancedportals.core.util.TagReader;
import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.Tag;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -47,14 +46,14 @@ public abstract class CreateTaggedSubCommand implements SubCommand {
} }
} }
if (tag instanceof Tag.AutoComplete if (tag instanceof Tag.AutoComplete && startsWith) {
&& startsWith) {
Tag.AutoComplete autoComplete = (Tag.AutoComplete) tag; Tag.AutoComplete autoComplete = (Tag.AutoComplete) tag;
String argData = split.length == 2 ? split[1] : ""; String argData = split.length == 2 ? split[1] : "";
List<String> tagSuggestions = autoComplete.autoComplete(argData); List<String> tagSuggestions =
autoComplete.autoComplete(argData);
if (tagSuggestions != null) { if (tagSuggestions != null) {
if (tag instanceof Tag.Split ) { if (tag instanceof Tag.Split) {
Tag.Split splitTag = (Tag.Split) tag; Tag.Split splitTag = (Tag.Split) tag;
String multiTagSplit = splitTag.splitString(); String multiTagSplit = splitTag.splitString();
boolean endsWithSplit = boolean endsWithSplit =
@ -76,8 +75,7 @@ public abstract class CreateTaggedSubCommand implements SubCommand {
? argData ? argData
: argData.substring( : argData.substring(
0, 0,
argData.lastIndexOf(multiTagSplit) argData.lastIndexOf(multiTagSplit) + 1);
+ 1);
tagSuggestions = tagSuggestions =
tagSuggestions tagSuggestions
@ -129,7 +127,8 @@ public abstract class CreateTaggedSubCommand implements SubCommand {
suggestions.add(tag.getName()); suggestions.add(tag.getName());
String[] aliases = tag.getAliases(); String[] aliases = tag.getAliases();
if (aliases != null) { if (aliases != null) {
suggestions.addAll(Arrays.stream(aliases).collect(Collectors.toList())); suggestions.addAll(
Arrays.stream(aliases).collect(Collectors.toList()));
} }
}); });
@ -145,7 +144,7 @@ public abstract class CreateTaggedSubCommand implements SubCommand {
for (DataTag dataTag : dataTags) { for (DataTag dataTag : dataTags) {
for (Tag tag : relatedTags) { for (Tag tag : relatedTags) {
if (tag instanceof Tag.Split ) { if (tag instanceof Tag.Split) {
Tag.Split splitTag = (Tag.Split) tag; Tag.Split splitTag = (Tag.Split) tag;
String splitString = splitTag.splitString(); String splitString = splitTag.splitString();
if (splitString != null) { if (splitString != null) {

View File

@ -75,7 +75,7 @@ public class Destination implements TagTarget {
this.destiTags.sort(Comparator.comparingInt(o -> { this.destiTags.sort(Comparator.comparingInt(o -> {
Tag tag = tagRegistry.getTag(o.NAME); Tag tag = tagRegistry.getTag(o.NAME);
if (tag instanceof Tag.OrderPriority ) { if (tag instanceof Tag.OrderPriority) {
Tag.OrderPriority tagPriority = (Tag.OrderPriority) tag; Tag.OrderPriority tagPriority = (Tag.OrderPriority) tag;
return tagPriority.getPriority().ordinal(); return tagPriority.getPriority().ordinal();
} else { } else {

View File

@ -100,7 +100,8 @@ public class PermissionBuilder {
case NOT_OP: case NOT_OP:
return !sender.isOp(); return !sender.isOp();
default: default:
throw new IllegalStateException("Unexpected value: " + permissionDefault); throw new IllegalStateException("Unexpected value: "
+ permissionDefault);
} }
} }
@ -125,10 +126,5 @@ public class PermissionBuilder {
return this; return this;
} }
public enum PermissionDefault { public enum PermissionDefault { TRUE, FALSE, OP, NOT_OP }
TRUE,
FALSE,
OP,
NOT_OP
}
} }

View File

@ -87,7 +87,7 @@ public class AdvancedPortal implements TagTarget {
// sort the tags by priority // sort the tags by priority
this.portalTags.sort(Comparator.comparingInt(o -> { this.portalTags.sort(Comparator.comparingInt(o -> {
Tag tag = tagRegistry.getTag(o.NAME); Tag tag = tagRegistry.getTag(o.NAME);
if (tag instanceof Tag.OrderPriority ) { if (tag instanceof Tag.OrderPriority) {
Tag.OrderPriority tagPriority = (Tag.OrderPriority) tag; Tag.OrderPriority tagPriority = (Tag.OrderPriority) tag;
return tagPriority.getPriority().ordinal(); return tagPriority.getPriority().ordinal();
} else { } else {
@ -172,8 +172,10 @@ public class AdvancedPortal implements TagTarget {
if (!preActivated) { if (!preActivated) {
if (activationHandler instanceof Tag.DenyBehavior) { if (activationHandler instanceof Tag.DenyBehavior) {
Tag.DenyBehavior denyBehaviorHandler = (Tag.DenyBehavior) activationHandler; Tag.DenyBehavior denyBehaviorHandler =
if (denyBehaviorHandler.getDenyBehavior().equals(Tag.DenyBehavior.Behaviour.SILENT)) { (Tag.DenyBehavior) activationHandler;
if (denyBehaviorHandler.getDenyBehavior().equals(
Tag.DenyBehavior.Behaviour.SILENT)) {
return ActivationResult.FAILED_DO_NOTHING; return ActivationResult.FAILED_DO_NOTHING;
} }
} }

View File

@ -43,8 +43,8 @@ public class PortalRepositoryImpl implements IPortalRepository {
@Override @Override
public AdvancedPortal get(String name) { public AdvancedPortal get(String name) {
AdvancedPortal portal = dataStorage.loadFile(AdvancedPortal.class, AdvancedPortal portal = dataStorage.loadFile(
fileLocation + name + ".yaml"); AdvancedPortal.class, fileLocation + name + ".yaml");
if (portal != null) { if (portal != null) {
AdvancedPortalsCore.getInstance() AdvancedPortalsCore.getInstance()
.getModule() .getModule()

View File

@ -41,7 +41,8 @@ public class DataStorage {
ReflectiveRepresenter representer = new ReflectiveRepresenter(options); ReflectiveRepresenter representer = new ReflectiveRepresenter(options);
representer.addClassTag(clazz, Tag.MAP); representer.addClassTag(clazz, Tag.MAP);
representer.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); representer.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
ReflectiveConstructor constructor = new ReflectiveConstructor(clazz, loaderOptions); ReflectiveConstructor constructor =
new ReflectiveConstructor(clazz, loaderOptions);
AdvancedPortalsCore.getInstance() AdvancedPortalsCore.getInstance()
.getModule() .getModule()

View File

@ -72,7 +72,8 @@ public class ReflectiveConstructor<T> extends Constructor {
Node node = tuple.getValueNode(); Node node = tuple.getValueNode();
if (node instanceof ScalarNode) { if (node instanceof ScalarNode) {
Object constructedItem = constructFromScalarNode((ScalarNode) node); Object constructedItem =
constructFromScalarNode((ScalarNode) node);
values.put(key, constructedItem); values.put(key, constructedItem);
} else if (node instanceof SequenceNode) { } else if (node instanceof SequenceNode) {
SequenceNode sequenceNode = (SequenceNode) node; SequenceNode sequenceNode = (SequenceNode) node;
@ -131,8 +132,8 @@ public class ReflectiveConstructor<T> extends Constructor {
} }
} catch (Exception e) { } catch (Exception e) {
infoLogger.warning("Failed to set field " + field.getName() infoLogger.warning("Failed to set field " + field.getName()
+ " in " + currentClass.getName() + " in " + currentClass.getName() + ": "
+ ": " + e.getMessage()); + e.getMessage());
infoLogger.error(e); infoLogger.error(e);
throw new RuntimeException("Failed to set field " throw new RuntimeException("Failed to set field "
+ field.getName() + " in " + field.getName() + " in "

View File

@ -154,13 +154,15 @@ public class DestinationServices {
player.teleport(this.destinationRepository.get(name).getLoc()); player.teleport(this.destinationRepository.get(name).getLoc());
if (doEffect && configRepository.getWarpEffectEnabled()) { if (doEffect && configRepository.getWarpEffectEnabled()) {
WarpEffect.Visual warpEffectVisual = warpEffectRegistry.getVisualEffect( WarpEffect.Visual warpEffectVisual =
warpEffectRegistry.getVisualEffect(
configRepository.getWarpVisual()); configRepository.getWarpVisual());
if (warpEffectVisual != null) { if (warpEffectVisual != null) {
warpEffectVisual.onWarpVisual(player, warpEffectVisual.onWarpVisual(player,
WarpEffect.Action.ENTER); WarpEffect.Action.ENTER);
} }
WarpEffect.Sound warpEffectSound = warpEffectRegistry.getSoundEffect( WarpEffect.Sound warpEffectSound =
warpEffectRegistry.getSoundEffect(
configRepository.getWarpSound()); configRepository.getWarpSound());
if (warpEffectSound != null) { if (warpEffectSound != null) {
warpEffectSound.onWarpSound(player, warpEffectSound.onWarpSound(player,

View File

@ -27,7 +27,8 @@ public final class PlayerDataServices {
public PlayerData getPlayerData(PlayerContainer player) { public PlayerData getPlayerData(PlayerContainer player) {
return tempDataMap.computeIfAbsent(player.getUUID(), uuid -> { return tempDataMap.computeIfAbsent(player.getUUID(), uuid -> {
PlayerData tempData = tempDataRepository.get(player.getUUID().toString()); PlayerData tempData =
tempDataRepository.get(player.getUUID().toString());
if (tempData == null) { if (tempData == null) {
tempData = new PlayerData(); tempData = new PlayerData();

View File

@ -131,7 +131,8 @@ public class PortalServices {
return PortalActivationResult.PORTAL_ACTIVATED; return PortalActivationResult.PORTAL_ACTIVATED;
case FAILED_DO_KNOCKBACK: case FAILED_DO_KNOCKBACK:
playerData.setInPortal(portal.getName()); playerData.setInPortal(portal.getName());
double strength = configRepository.getThrowbackStrength(); double strength =
configRepository.getThrowbackStrength();
PlayerUtils.throwPlayerBack(player, strength); PlayerUtils.throwPlayerBack(player, strength);
return PortalActivationResult.PORTAL_DENIED; return PortalActivationResult.PORTAL_DENIED;
} }

View File

@ -51,7 +51,8 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation {
@Override @Override
public boolean preActivated(TagTarget target, PlayerContainer player, public boolean preActivated(TagTarget target, PlayerContainer player,
ActivationData activeData, String[] argData) { ActivationData activeData, String[] argData) {
CommandPortalConfig commandPortals = configRepository.getCommandPortals(); CommandPortalConfig commandPortals =
configRepository.getCommandPortals();
if (!commandPortals.enabled) { if (!commandPortals.enabled) {
player.sendMessage(Lang.getNegativePrefix() player.sendMessage(Lang.getNegativePrefix()
@ -156,7 +157,9 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation {
public boolean created(TagTarget target, PlayerContainer player, public boolean created(TagTarget target, PlayerContainer player,
String[] argData) { String[] argData) {
if (argData != null) { if (argData != null) {
com.sekwah.advancedportals.core.serializeddata.config.CommandPortalConfig commandPortals = configRepository.getCommandPortals(); com.sekwah.advancedportals.core.serializeddata.config
.CommandPortalConfig commandPortals =
configRepository.getCommandPortals();
if (!commandPortals.enabled) { if (!commandPortals.enabled) {
player.sendMessage(Lang.getNegativePrefix() player.sendMessage(Lang.getNegativePrefix()
+ Lang.translate("tag.command.disabled")); + Lang.translate("tag.command.disabled"));
@ -167,37 +170,51 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation {
switch (executionCommand) { switch (executionCommand) {
case '!': case '!':
if (!commandPortals.op) { if (!commandPortals.op) {
player.sendMessage(Lang.getNegativePrefix() player.sendMessage(
Lang.getNegativePrefix()
+ Lang.translate("tag.command.op.disabled")); + Lang.translate("tag.command.op.disabled"));
return false; return false;
} }
if (!Permissions.CREATE_COMMAND_OP.hasPermission(player)) { if (!Permissions.CREATE_COMMAND_OP.hasPermission(
player.sendMessage(Lang.getNegativePrefix() player)) {
+ Lang.translateInsertVariables("tag.command.nopermission", "OP")); player.sendMessage(
Lang.getNegativePrefix()
+ Lang.translateInsertVariables(
"tag.command.nopermission", "OP"));
return false; return false;
} }
return true; return true;
case '#': case '#':
if (!commandPortals.console) { if (!commandPortals.console) {
player.sendMessage(Lang.getNegativePrefix() player.sendMessage(
+ Lang.translate("tag.command.console.disabled")); Lang.getNegativePrefix()
+ Lang.translate(
"tag.command.console.disabled"));
return false; return false;
} }
if (!Permissions.CREATE_COMMAND_CONSOLE.hasPermission(player)) { if (!Permissions.CREATE_COMMAND_CONSOLE.hasPermission(
player.sendMessage(Lang.getNegativePrefix() player)) {
+ Lang.translateInsertVariables("tag.command.nopermission", "Console")); player.sendMessage(
Lang.getNegativePrefix()
+ Lang.translateInsertVariables(
"tag.command.nopermission", "Console"));
return false; return false;
} }
return true; return true;
case '^': case '^':
if (!commandPortals.permsWildcard) { if (!commandPortals.permsWildcard) {
player.sendMessage(Lang.getNegativePrefix() player.sendMessage(
+ Lang.translate("tag.command.permswildcard.disabled")); Lang.getNegativePrefix()
+ Lang.translate(
"tag.command.permswildcard.disabled"));
return false; return false;
} }
if (!Permissions.CREATE_COMMAND_PERMS.hasPermission(player)) { if (!Permissions.CREATE_COMMAND_PERMS.hasPermission(
player.sendMessage(Lang.getNegativePrefix() player)) {
+ Lang.translateInsertVariables("tag.command.nopermission", "*")); player.sendMessage(
Lang.getNegativePrefix()
+ Lang.translateInsertVariables(
"tag.command.nopermission", "*"));
return false; return false;
} }
return true; return true;
@ -210,14 +227,10 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation {
} }
@Override @Override
public void destroyed(TagTarget target, PlayerContainer player, String[] argData) { public void destroyed(TagTarget target, PlayerContainer player,
String[] argData) {
// Needs created but not destroyed // Needs created but not destroyed
} }
public enum CommandLevel{ public enum CommandLevel { OP, PERMISSION_WILDCARD, CONSOLE, PLAYER }
OP,
PERMISSION_WILDCARD,
CONSOLE,
PLAYER
}
} }

View File

@ -81,7 +81,8 @@ public class CooldownTag implements Tag.Activation, Tag.Creation {
if (activationData.hasActivated()) { if (activationData.hasActivated()) {
if (target instanceof AdvancedPortal) { if (target instanceof AdvancedPortal) {
AdvancedPortal portal = (AdvancedPortal) target; AdvancedPortal portal = (AdvancedPortal) target;
PlayerData playerData = playerDataServices.getPlayerData(player); PlayerData playerData =
playerDataServices.getPlayerData(player);
try { try {
playerData.setPortalCooldown( playerData.setPortalCooldown(
portal.getName(), Integer.parseInt(argData[0]) * 1000); portal.getName(), Integer.parseInt(argData[0]) * 1000);

View File

@ -151,9 +151,11 @@ public class DestiTag implements Tag.Activation, Tag.AutoComplete, Tag.Split {
} }
if (destination != null) { if (destination != null) {
WarpEffect.Visual warpEffectVisual = warpEffectRegistry.getVisualEffect( WarpEffect.Visual warpEffectVisual =
warpEffectRegistry.getVisualEffect(
configRepository.getWarpVisual()); configRepository.getWarpVisual());
WarpEffect.Sound warpEffectSound = warpEffectRegistry.getSoundEffect( WarpEffect.Sound warpEffectSound =
warpEffectRegistry.getSoundEffect(
configRepository.getWarpSound()); configRepository.getWarpSound());
if (configRepository.getWarpEffectEnabled()) { if (configRepository.getWarpEffectEnabled()) {
if (warpEffectVisual != null) { if (warpEffectVisual != null) {

View File

@ -11,7 +11,6 @@ import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.warphandler.ActivationData; import com.sekwah.advancedportals.core.warphandler.ActivationData;
import com.sekwah.advancedportals.core.warphandler.Tag; import com.sekwah.advancedportals.core.warphandler.Tag;
import com.sekwah.advancedportals.core.warphandler.TriggerType; import com.sekwah.advancedportals.core.warphandler.TriggerType;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;

View File

@ -40,7 +40,8 @@ public class TriggerBlockTag
@Override @Override
public List<String> autoComplete(String argData) { public List<String> autoComplete(String argData) {
List<String> triggerBlocks = serverContainer.getCommonTriggerBlocks() List<String> triggerBlocks =
serverContainer.getCommonTriggerBlocks()
.stream() .stream()
.filter(block -> block.contains(argData)) .filter(block -> block.contains(argData))
.collect(Collectors.toList()); .collect(Collectors.toList());

View File

@ -135,7 +135,8 @@ public class Lang {
repeatedEquals.append("="); repeatedEquals.append("=");
} }
return "\u00A7e" + repeatedEquals.toString() + " " + title + " \u00A7e" + repeatedEquals.toString(); return "\u00A7e" + repeatedEquals.toString() + " " + title + " \u00A7e"
+ repeatedEquals.toString();
} }
private void injectTranslations(String fileName) { private void injectTranslations(String fileName) {

View File

@ -66,24 +66,34 @@ public class AdvancedPortalsProxyCore {
// packets // packets
switch (messageType) { switch (messageType) {
case ProxyMessages.PROXY_TRANSFER: case ProxyMessages.PROXY_TRANSFER:
ProxyTransferPacket transferPacket = ProxyTransferPacket.decode(buffer); ProxyTransferPacket transferPacket =
this.logger.info("Transfer request for " + player.getName() + " to " + transferPacket.getServerName()); ProxyTransferPacket.decode(buffer);
this.proxyContainer.transferPlayer(player, transferPacket.getServerName()); this.logger.info("Transfer request for " + player.getName()
+ " to " + transferPacket.getServerName());
this.proxyContainer.transferPlayer(
player, transferPacket.getServerName());
break; break;
case ProxyMessages.PROXY_COMMAND: case ProxyMessages.PROXY_COMMAND:
ProxyCommandPacket commandPacket = ProxyCommandPacket.decode(buffer); ProxyCommandPacket commandPacket =
this.logger.info("Command request for " + player.getName() + " to run /" + commandPacket.getCommand()); ProxyCommandPacket.decode(buffer);
this.proxyContainer.invokeCommand(player, commandPacket.getCommand()); this.logger.info("Command request for " + player.getName()
+ " to run /" + commandPacket.getCommand());
this.proxyContainer.invokeCommand(player,
commandPacket.getCommand());
break; break;
case ProxyMessages.PROXY_TRANSFER_DESTI: case ProxyMessages.PROXY_TRANSFER_DESTI:
ProxyTransferDestiPacket transferDestiPacket = ProxyTransferDestiPacket.decode(buffer); ProxyTransferDestiPacket transferDestiPacket =
this.proxyContainer.transferPlayer(player, transferDestiPacket.getServerName()); ProxyTransferDestiPacket.decode(buffer);
this.playerJoinMap.put(player.getUUID(), new ProxyJoinData(transferDestiPacket.getDestination(), transferDestiPacket.getServerName())); this.proxyContainer.transferPlayer(
player, transferDestiPacket.getServerName());
this.playerJoinMap.put(
player.getUUID(),
new ProxyJoinData(transferDestiPacket.getDestination(),
transferDestiPacket.getServerName()));
break; break;
default: default:
this.logger.info("Unknown message type: " + messageType); this.logger.info("Unknown message type: " + messageType);
break; break;
} }
} }
} }

View File

@ -54,7 +54,8 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
String mcVersion = this.getServer().getVersion(); String mcVersion = this.getServer().getVersion();
Pattern pattern = Pattern.compile("\\(MC: ([\\d.]+)\\)"); Pattern pattern = Pattern.compile("\\(MC: ([\\d.]+)\\)");
Matcher matcher = pattern.matcher(mcVersion); Matcher matcher = pattern.matcher(mcVersion);
SpigotServerContainer serverContainer = new SpigotServerContainer(this.getServer()); SpigotServerContainer serverContainer =
new SpigotServerContainer(this.getServer());
this.portalsCore = new AdvancedPortalsCore( this.portalsCore = new AdvancedPortalsCore(
matcher.find() ? matcher.group(1) : "0.0.0", this.getDataFolder(), matcher.find() ? matcher.group(1) : "0.0.0", this.getDataFolder(),
new SpigotInfoLogger(this), serverContainer); new SpigotInfoLogger(this), serverContainer);

View File

@ -2,7 +2,6 @@ package com.sekwah.advancedportals.spigot;
import com.sekwah.advancedportals.core.permissions.PermissionBuilder; import com.sekwah.advancedportals.core.permissions.PermissionBuilder;
import com.sekwah.advancedportals.core.permissions.Permissions; import com.sekwah.advancedportals.core.permissions.Permissions;
import java.util.List; import java.util.List;
public class PermissionsGeneratorSpigot { public class PermissionsGeneratorSpigot {

View File

@ -12,10 +12,9 @@ import com.sekwah.advancedportals.shadowed.inject.Inject;
import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin; import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.spigot.importer.ConfigAccessor; import com.sekwah.advancedportals.spigot.importer.ConfigAccessor;
import com.sekwah.advancedportals.spigot.importer.LegacyImporter; import com.sekwah.advancedportals.spigot.importer.LegacyImporter;
import org.bukkit.configuration.file.FileConfiguration;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.bukkit.configuration.file.FileConfiguration;
public class ImportPortalSubCommand implements SubCommand { public class ImportPortalSubCommand implements SubCommand {
@Inject @Inject

View File

@ -11,7 +11,6 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.World; import org.bukkit.World;
@ -33,7 +32,9 @@ public class SpigotServerContainer implements ServerContainer {
.collect(Collectors.toList()); .collect(Collectors.toList());
private final List<String> fullTriggerBlockList = private final List<String> fullTriggerBlockList =
Arrays.stream(Material.values()).map(Enum::name).collect(Collectors.toList()); Arrays.stream(Material.values())
.map(Enum::name)
.collect(Collectors.toList());
public SpigotServerContainer(Server server) { public SpigotServerContainer(Server server) {
this.server = server; this.server = server;

View File

@ -12,10 +12,8 @@ import com.sekwah.advancedportals.core.serializeddata.config.WarpEffectConfig;
import com.sekwah.advancedportals.core.services.DestinationServices; import com.sekwah.advancedportals.core.services.DestinationServices;
import com.sekwah.advancedportals.core.services.PortalServices; import com.sekwah.advancedportals.core.services.PortalServices;
import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin; import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
@ -44,7 +42,8 @@ public class LegacyImporter {
config.getInt(portalName + ".pos2.Z")); config.getInt(portalName + ".pos2.Z"));
List<DataTag> args = new ArrayList<>(); List<DataTag> args = new ArrayList<>();
args.add(new DataTag("name", portalName)); args.add(new DataTag("name", portalName));
String triggerblock = config.getString(portalName + ".triggerblock"); String triggerblock =
config.getString(portalName + ".triggerblock");
if (triggerblock != null) if (triggerblock != null)
args.add(new DataTag("triggerblock", triggerblock.split(","))); args.add(new DataTag("triggerblock", triggerblock.split(",")));
// It's called bungee as that's the implementation behind it // It's called bungee as that's the implementation behind it
@ -103,7 +102,8 @@ public class LegacyImporter {
args.removeIf(dataTag -> dataTag.NAME.equals("delayed")); args.removeIf(dataTag -> dataTag.NAME.equals("delayed"));
} }
AdvancedPortal portal = portalServices.createPortal(null, pos1, pos2, args); AdvancedPortal portal =
portalServices.createPortal(null, pos1, pos2, args);
if (portal != null) if (portal != null)
count++; count++;

View File

@ -151,13 +151,13 @@ public class ConditionsTag implements Tag.Activation, Tag.Split, Tag.Creation {
} }
@Override @Override
public boolean created(TagTarget target, PlayerContainer player, String[] argData) { public boolean created(TagTarget target, PlayerContainer player,
String[] argData) {
for (String condition : argData) { for (String condition : argData) {
if (player instanceof SpigotPlayerContainer) { if (player instanceof SpigotPlayerContainer) {
SpigotPlayerContainer spigotPlayer = SpigotPlayerContainer spigotPlayer =
(SpigotPlayerContainer) player; (SpigotPlayerContainer) player;
if (!checkConditions(condition, if (!checkConditions(condition, spigotPlayer.getPlayer())) {
spigotPlayer.getPlayer())) {
spigotPlayer.sendMessage( spigotPlayer.sendMessage(
Lang.getNegativePrefix() Lang.getNegativePrefix()
+ Lang.translate("tag.conditions.invalid")); + Lang.translate("tag.conditions.invalid"));
@ -172,4 +172,4 @@ public class ConditionsTag implements Tag.Activation, Tag.Split, Tag.Creation {
public void destroyed(TagTarget target, PlayerContainer player, public void destroyed(TagTarget target, PlayerContainer player,
String[] argData) { String[] argData) {
} }
} }

View File

@ -10,8 +10,7 @@ public class EnderWarpEffect implements WarpEffect.Visual, WarpEffect.Sound {
@Override @Override
public void onWarpSound(PlayerContainer playerContainer, public void onWarpSound(PlayerContainer playerContainer,
WarpEffect.Action action) { WarpEffect.Action action) {
if (playerContainer if (playerContainer instanceof SpigotPlayerContainer) {
instanceof SpigotPlayerContainer) {
SpigotPlayerContainer spigotPlayerContainer = SpigotPlayerContainer spigotPlayerContainer =
(SpigotPlayerContainer) playerContainer; (SpigotPlayerContainer) playerContainer;
org.bukkit.entity.Player player = spigotPlayerContainer.getPlayer(); org.bukkit.entity.Player player = spigotPlayerContainer.getPlayer();
@ -24,8 +23,7 @@ public class EnderWarpEffect implements WarpEffect.Visual, WarpEffect.Sound {
@Override @Override
public void onWarpVisual(PlayerContainer playerContainer, public void onWarpVisual(PlayerContainer playerContainer,
WarpEffect.Action action) { WarpEffect.Action action) {
if (playerContainer if (playerContainer instanceof SpigotPlayerContainer) {
instanceof SpigotPlayerContainer) {
SpigotPlayerContainer spigotPlayerContainer = SpigotPlayerContainer spigotPlayerContainer =
(SpigotPlayerContainer) playerContainer; (SpigotPlayerContainer) playerContainer;
Player player = spigotPlayerContainer.getPlayer(); Player player = spigotPlayerContainer.getPlayer();

View File

@ -50,9 +50,9 @@ public class AdvancedPortalsVelocityPlugin {
@Subscribe @Subscribe
public void onPluginMessage(PluginMessageEvent event) { public void onPluginMessage(PluginMessageEvent event) {
if (event.getIdentifier().equals(AP_CHANNEL)) { if (event.getIdentifier().equals(AP_CHANNEL)) {
if (event.getSource() if (event.getSource() instanceof ServerConnection) {
instanceof ServerConnection) { ServerConnection serverConnection =
ServerConnection serverConnection = (ServerConnection) event.getSource(); (ServerConnection) event.getSource();
this.proxyCore.incomingMessage( this.proxyCore.incomingMessage(
new VelocityProxyPlayerContainer( new VelocityProxyPlayerContainer(
serverConnection.getPlayer(), AP_CHANNEL), serverConnection.getPlayer(), AP_CHANNEL),

View File

@ -15,10 +15,9 @@ public class VelocityProxyContainer implements ProxyContainer {
@Override @Override
public void invokeCommand(ProxyPlayerContainer proxyPlayer, public void invokeCommand(ProxyPlayerContainer proxyPlayer,
String command) { String command) {
if (proxyPlayer if (proxyPlayer instanceof VelocityProxyPlayerContainer) {
instanceof VelocityProxyPlayerContainer) { VelocityProxyPlayerContainer playerContainer =
VelocityProxyPlayerContainer playerContainer (VelocityProxyPlayerContainer) proxyPlayer;
= (VelocityProxyPlayerContainer) proxyPlayer;
this.proxy.getCommandManager().executeAsync( this.proxy.getCommandManager().executeAsync(
playerContainer.getPlayer(), command); playerContainer.getPlayer(), command);
} }
@ -27,14 +26,14 @@ public class VelocityProxyContainer implements ProxyContainer {
@Override @Override
public void transferPlayer(ProxyPlayerContainer proxyPlayer, public void transferPlayer(ProxyPlayerContainer proxyPlayer,
String serverName) { String serverName) {
if (proxyPlayer if (proxyPlayer instanceof VelocityProxyPlayerContainer) {
instanceof VelocityProxyPlayerContainer) { VelocityProxyPlayerContainer playerContainer =
VelocityProxyPlayerContainer playerContainer (VelocityProxyPlayerContainer) proxyPlayer;
= (VelocityProxyPlayerContainer) proxyPlayer;
this.proxy.getServer(serverName); this.proxy.getServer(serverName);
if (this.proxy.getServer(serverName).isPresent()) { if (this.proxy.getServer(serverName).isPresent()) {
playerContainer.getPlayer() playerContainer.getPlayer()
.createConnectionRequest(this.proxy.getServer(serverName).get()) .createConnectionRequest(
this.proxy.getServer(serverName).get())
.fireAndForget(); .fireAndForget();
} else { } else {
playerContainer.getPlayer().sendMessage( playerContainer.getPlayer().sendMessage(