From 0e3d22445d360404d662d1f160eb05667a095d10 Mon Sep 17 00:00:00 2001 From: Vrekt Date: Tue, 24 Aug 2021 18:53:33 -0500 Subject: [PATCH] Misc changes --- src/main/java/me/vrekt/arc/Arc.java | 2 +- .../commands/ArcSummarySubCommand.java | 3 +- .../vrekt/arc/exemption/ExemptionManager.java | 5 +- .../me/vrekt/arc/utility/misc/DeviceType.java | 57 +++++++++++++++++++ src/main/resources/plugin.yml | 2 +- 5 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 src/main/java/me/vrekt/arc/utility/misc/DeviceType.java diff --git a/src/main/java/me/vrekt/arc/Arc.java b/src/main/java/me/vrekt/arc/Arc.java index b499211..d075b5f 100644 --- a/src/main/java/me/vrekt/arc/Arc.java +++ b/src/main/java/me/vrekt/arc/Arc.java @@ -29,7 +29,7 @@ public final class Arc extends PluginBase { /** * IPL version */ - public static final String VERSION_STRING = "1.7-824a-nukkit"; + public static final String VERSION_STRING = "1.7-824b-nukkit"; /** * The instance of this class diff --git a/src/main/java/me/vrekt/arc/command/commands/ArcSummarySubCommand.java b/src/main/java/me/vrekt/arc/command/commands/ArcSummarySubCommand.java index edad2bb..dd9474f 100644 --- a/src/main/java/me/vrekt/arc/command/commands/ArcSummarySubCommand.java +++ b/src/main/java/me/vrekt/arc/command/commands/ArcSummarySubCommand.java @@ -8,6 +8,7 @@ import me.vrekt.arc.check.CheckType; import me.vrekt.arc.permissions.Permissions; import me.vrekt.arc.utility.chat.ColoredChat; +import me.vrekt.arc.utility.misc.DeviceType; import me.vrekt.arc.violation.ViolationHistory; import org.apache.commons.lang3.ArrayUtils; @@ -50,7 +51,7 @@ public void execute(CommandSender sender, String[] arguments) { final int playerPing = player.getPing(); // TODO: Mapping of devices. - final String playerDeviceId = playerDevice == 7 ? "Windows" : "Unknown Device"; + final String playerDeviceId = DeviceType.getByCode(playerDevice).getPrettyName(); final String checksBypassed = bypass.isEmpty() ? " cannot bypass any checks." : " can bypass " + ArrayUtils.toString(bypass); final String playerGameMode = player.getGamemode() == 0 ? "Survival" diff --git a/src/main/java/me/vrekt/arc/exemption/ExemptionManager.java b/src/main/java/me/vrekt/arc/exemption/ExemptionManager.java index 6d18926..dff7074 100644 --- a/src/main/java/me/vrekt/arc/exemption/ExemptionManager.java +++ b/src/main/java/me/vrekt/arc/exemption/ExemptionManager.java @@ -181,7 +181,10 @@ private boolean isFlying(Player player) { * @return {@code true} if so */ private boolean isExemptWhenFlying(CheckType check) { - return check == CheckType.FLIGHT || check == CheckType.SPEED || check == CheckType.PHASE; + return check == CheckType.FLIGHT + || check == CheckType.SPEED + || check == CheckType.PHASE + || check == CheckType.LIQUID_WALK; } @Override diff --git a/src/main/java/me/vrekt/arc/utility/misc/DeviceType.java b/src/main/java/me/vrekt/arc/utility/misc/DeviceType.java new file mode 100644 index 0000000..8fecabc --- /dev/null +++ b/src/main/java/me/vrekt/arc/utility/misc/DeviceType.java @@ -0,0 +1,57 @@ +package me.vrekt.arc.utility.misc; + +/** + * Represents a device type a player is playing on. + */ +public enum DeviceType { + + ANDROID("Android", 1), + IOS("iOS", 2), + MAC_OS("MacOS", 3), + FIRE_OS("FireOS", 4), + GEAR_VR("GearVR", 5), + HOLO_LENS("HoloLens", 6), + WINDOWS_10("Windows", 7), + WINDOWS("Windows", 8), + DEDICATED("Dedicated", 9), + PS4("PS4", 10), + SWITCH("Switch", 11), + UNKNOWN("Unknown", 0); + + /** + * The name + */ + private final String prettyName; + + /** + * The Code + */ + private final int code; + + DeviceType(String prettyName, int code) { + this.prettyName = prettyName; + this.code = code; + } + + public String getPrettyName() { + return prettyName; + } + + public int getCode() { + return code; + } + + /** + * Get the device type from the provided code. + * + * @param code the code + * @return the device type or {@code UNKNOWN} if not found. + */ + public static DeviceType getByCode(int code) { + for (DeviceType value : values()) { + if (value.code == code) return value; + } + return UNKNOWN; + } + +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 7c81855..fe86e4f 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -44,7 +44,7 @@ permissions: description: Allows the player to bypass the Speed check. arc.bypass.moving.phase: description: Allows the player to bypass the Phase check. - arc.bypass.moving.waterwalk: + arc.bypass.moving.liquidwalk: description: Allows the player to bypass the LiquidWalk check. arc.bypass.block: description: Allows the player to bypass block related checks