From 901b4a99897149da5483fa16d02788d58b54e1de Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 31 Aug 2024 01:48:02 +0000 Subject: [PATCH] chore: pre-commit changes [skip ci] --- .../common/CreateTaggedSubCommand.java | 5 +- .../core/portal/AdvancedPortal.java | 46 +++++++-------- .../serializeddata/ReflectiveConstructor.java | 4 +- .../core/tags/activation/CommandTag.java | 56 +++++++++---------- .../core/util/FriendlyDataOutput.java | 6 +- .../core/warphandler/ActivationData.java | 3 +- 6 files changed, 59 insertions(+), 61 deletions(-) diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/common/CreateTaggedSubCommand.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/common/CreateTaggedSubCommand.java index 566285c4..3a2378ea 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/common/CreateTaggedSubCommand.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/subcommands/common/CreateTaggedSubCommand.java @@ -75,9 +75,8 @@ public abstract class CreateTaggedSubCommand implements SubCommand { String baseString = endsWithSplit ? argData : argData.substring( - 0, - argData.lastIndexOf(multiTagSplit) - + 1); + 0, + argData.lastIndexOf(multiTagSplit) + 1); tagSuggestions = tagSuggestions diff --git a/core/src/main/java/com/sekwah/advancedportals/core/portal/AdvancedPortal.java b/core/src/main/java/com/sekwah/advancedportals/core/portal/AdvancedPortal.java index d044ccaa..c910e90d 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/portal/AdvancedPortal.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/portal/AdvancedPortal.java @@ -13,7 +13,6 @@ import com.sekwah.advancedportals.core.tags.activation.TriggerBlockTag; import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.warphandler.ActivationData; import com.sekwah.advancedportals.core.warphandler.Tag; - import java.util.*; /** @@ -105,7 +104,8 @@ public class AdvancedPortal implements TagTarget { }*/ /** - * @param player The player on the server attempting to use an advanced + * @param player The player on the server attempting to use an + * advanced * portal * @param moveActivated if the portal was activated by a move event (won't * trigger knockback) @@ -117,15 +117,15 @@ public class AdvancedPortal implements TagTarget { return false; if (playerData.hasJoinCooldown()) { var cooldown = - (int) Math.ceil(playerData.getJoinCooldownLeft() / 1000D); + (int) Math.ceil(playerData.getJoinCooldownLeft() / 1000D); player.sendMessage(Lang.translateInsertVariables( - "portal.cooldown.join", cooldown, - Lang.translate(cooldown == 1 ? "time.second" - : "time.seconds"))); + "portal.cooldown.join", cooldown, + Lang.translate(cooldown == 1 ? "time.second" + : "time.seconds"))); if (configRepository.playFailSound()) { var rand = new Random(); player.playSound("block.portal.travel", 0.05f, - rand.nextFloat() * 0.4F + 0.8F); + rand.nextFloat() * 0.4F + 0.8F); } return false; } @@ -139,28 +139,28 @@ public class AdvancedPortal implements TagTarget { for (DataTag portalTag : portalTags) { Tag.Activation activationHandler = - tagRegistry.getActivationHandler(portalTag.NAME); - if (activationHandler != null && !activationHandler.preActivated( - this, player, data, - this.getArgValues(portalTag.NAME))) { + tagRegistry.getActivationHandler(portalTag.NAME); + if (activationHandler != null + && !activationHandler.preActivated( + this, player, data, this.getArgValues(portalTag.NAME))) { return false; } } for (DataTag portalTag : portalTags) { Tag.Activation activationHandler = - tagRegistry.getActivationHandler(portalTag.NAME); - if (activationHandler != null && !activationHandler.activated( - this, player, data, - this.getArgValues(portalTag.NAME))) { + tagRegistry.getActivationHandler(portalTag.NAME); + if (activationHandler != null + && !activationHandler.activated( + this, player, data, this.getArgValues(portalTag.NAME))) { return false; } } for (DataTag portalTag : portalTags) { Tag.Activation activationHandler = - tagRegistry.getActivationHandler(portalTag.NAME); + tagRegistry.getActivationHandler(portalTag.NAME); if (activationHandler != null) { activationHandler.postActivated( - this, player, data, this.getArgValues(portalTag.NAME)); + this, player, data, this.getArgValues(portalTag.NAME)); } } if (data.hasActivated()) { @@ -189,12 +189,12 @@ public class AdvancedPortal implements TagTarget { double playerZ = loc.getPosZ(); return Objects.equals(loc.getWorldName(), this.minLoc.getWorldName()) - && playerX >= this.minLoc.getPosX() - additionalArea - && playerX < this.maxLoc.getPosX() + 1 + additionalArea - && playerY >= this.minLoc.getPosY() - additionalArea - && playerY < this.maxLoc.getPosY() + 1 + additionalArea - && playerZ >= this.minLoc.getPosZ() - additionalArea - && playerZ < this.maxLoc.getPosZ() + 1 + additionalArea; + && playerX >= this.minLoc.getPosX() - additionalArea + && playerX < this.maxLoc.getPosX() + 1 + additionalArea + && playerY >= this.minLoc.getPosY() - additionalArea + && playerY < this.maxLoc.getPosY() + 1 + additionalArea + && playerZ >= this.minLoc.getPosZ() - additionalArea + && playerZ < this.maxLoc.getPosZ() + 1 + additionalArea; } public void setArgValues(DataTag portalTag) { diff --git a/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/ReflectiveConstructor.java b/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/ReflectiveConstructor.java index f4c51bc6..faba0051 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/ReflectiveConstructor.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/serializeddata/ReflectiveConstructor.java @@ -127,8 +127,8 @@ public class ReflectiveConstructor extends Constructor { } } catch (Exception e) { infoLogger.warning("Failed to set field " + field.getName() - + " in " + currentClass.getName() - + ": " + e.getMessage()); + + " in " + currentClass.getName() + ": " + + e.getMessage()); infoLogger.error(e); throw new RuntimeException("Failed to set field " + field.getName() + " in " diff --git a/core/src/main/java/com/sekwah/advancedportals/core/tags/activation/CommandTag.java b/core/src/main/java/com/sekwah/advancedportals/core/tags/activation/CommandTag.java index 3f2fc4a7..58e3732e 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/tags/activation/CommandTag.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/tags/activation/CommandTag.java @@ -10,7 +10,6 @@ import com.sekwah.advancedportals.core.warphandler.Tag; import javax.annotation.Nullable; public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation { - @Inject ConfigRepository configRepository; @@ -59,40 +58,41 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation { @Override public void postActivated(TagTarget target, PlayerContainer player, ActivationData activationData, String[] argData) { - for (String command : argData) { - char executionCommand = command.charAt(0); - String formattedCommand = - command.replaceAll("@player", player.getName()); + for (String command : argData) { + char executionCommand = command.charAt(0); + String formattedCommand = + command.replaceAll("@player", player.getName()); - switch (executionCommand) { - case '!': - player.getServer().dispatchCommand( - player.getUUID(), formattedCommand.substring(1), - CommandLevel.OP); - break; - case '#': - player.getServer().dispatchCommand( - player.getUUID(), formattedCommand.substring(1), - CommandLevel.CONSOLE); - break; - case '^': - player.getServer().dispatchCommand( - player.getUUID(), formattedCommand.substring(1), - CommandLevel.PERMISSION_WILDCARD); - break; - default: - player.getServer().dispatchCommand(player.getUUID(), - formattedCommand, - CommandLevel.PLAYER); - break; - } + switch (executionCommand) { + case '!': + player.getServer().dispatchCommand( + player.getUUID(), formattedCommand.substring(1), + CommandLevel.OP); + break; + case '#': + player.getServer().dispatchCommand( + player.getUUID(), formattedCommand.substring(1), + CommandLevel.CONSOLE); + break; + case '^': + player.getServer().dispatchCommand( + player.getUUID(), formattedCommand.substring(1), + CommandLevel.PERMISSION_WILDCARD); + break; + default: + player.getServer().dispatchCommand(player.getUUID(), + formattedCommand, + CommandLevel.PLAYER); + break; } + } } @Override public boolean activated(TagTarget target, PlayerContainer player, ActivationData activationData, String[] argData) { - // Will trigger in the post activation stage to make sure the command triggers after any teleportation + // Will trigger in the post activation stage to make sure the command + // triggers after any teleportation activationData.setWarpStatus(ActivationData.WarpedStatus.ACTIVATED); return true; } diff --git a/core/src/main/java/com/sekwah/advancedportals/core/util/FriendlyDataOutput.java b/core/src/main/java/com/sekwah/advancedportals/core/util/FriendlyDataOutput.java index aeafe78f..b829b118 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/util/FriendlyDataOutput.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/util/FriendlyDataOutput.java @@ -51,15 +51,13 @@ public class FriendlyDataOutput { public void writeUtf(String text, int maxLength) { if (text.length() > maxLength) { throw new EncoderException("String too big (was " + text.length() - + " characters, max " + maxLength - + ")"); + + " characters, max " + maxLength + ")"); } else { byte[] abyte = text.getBytes(StandardCharsets.UTF_8); int i = getMaxEncodedUtfLength(maxLength); if (abyte.length > i) { throw new EncoderException("String too big (was " + abyte.length - + " bytes encoded, max " + i - + ")"); + + " bytes encoded, max " + i + ")"); } else { this.writeVarInt(abyte.length); this.writeBytes(abyte); diff --git a/core/src/main/java/com/sekwah/advancedportals/core/warphandler/ActivationData.java b/core/src/main/java/com/sekwah/advancedportals/core/warphandler/ActivationData.java index 32a2d3f9..075dea74 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/warphandler/ActivationData.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/warphandler/ActivationData.java @@ -25,7 +25,8 @@ public class ActivationData { } public void setWarpStatus(WarpedStatus warped) { - if (this.warpStatus == WarpedStatus.WARPED || (this.warpStatus == WarpedStatus.ACTIVATED + if (this.warpStatus == WarpedStatus.WARPED + || (this.warpStatus == WarpedStatus.ACTIVATED && warped != WarpedStatus.WARPED)) { return; }