From 494ab056fbf37e317748bea27721524442b3f1fc Mon Sep 17 00:00:00 2001 From: rtm516 Date: Thu, 25 Mar 2021 17:52:44 +0000 Subject: [PATCH] Update to floodgate 2.0 --- pom.xml | 18 +++----- .../rtm516/FloodgatePlaceholders/Config.java | 23 ++++------ .../FloodgatePlaceholders/Placeholder.java | 46 +++++++++---------- src/main/resources/config.yml | 11 ++--- src/main/resources/plugin.yml | 2 +- 5 files changed, 43 insertions(+), 57 deletions(-) diff --git a/pom.xml b/pom.xml index 18475f4..e4e772e 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.rtm516 FloodgatePlaceholders - 1.1 + 1.2 FloodgatePlaceholders @@ -69,22 +69,16 @@ http://repo.extendedclip.com/content/repositories/placeholderapi/ - nukkitx-snapshot - https://repo.nukkitx.com/maven-snapshots/ + opencollab-snapshot + https://repo.opencollab.dev/maven-snapshots/ - org.geysermc - floodgate-common - 1.0-SNAPSHOT - provided - - - org.geysermc - floodgate-bukkit - 1.0-SNAPSHOT + org.geysermc.floodgate + api + 2.0-SNAPSHOT provided diff --git a/src/main/java/com/rtm516/FloodgatePlaceholders/Config.java b/src/main/java/com/rtm516/FloodgatePlaceholders/Config.java index 477e0f5..a7a3dae 100644 --- a/src/main/java/com/rtm516/FloodgatePlaceholders/Config.java +++ b/src/main/java/com/rtm516/FloodgatePlaceholders/Config.java @@ -41,8 +41,8 @@ public static class DevicePlaceholders { @JsonProperty("unknown") private String unknown; - @JsonProperty("android") - private String android; + @JsonProperty("google") + private String google; @JsonProperty("ios") private String iOS; @@ -50,8 +50,8 @@ public static class DevicePlaceholders { @JsonProperty("osx") private String OSX; - @JsonProperty("fireos") - private String fireos; + @JsonProperty("amazon") + private String amazon; @JsonProperty("gearvr") private String gearVR; @@ -59,8 +59,8 @@ public static class DevicePlaceholders { @JsonProperty("hololens") private String hololens; - @JsonProperty("win10") - private String win10; + @JsonProperty("uwp") + private String uwp; @JsonProperty("win32") private String win32; @@ -68,17 +68,14 @@ public static class DevicePlaceholders { @JsonProperty("dedicated") private String dedicated; - @JsonProperty("orbis") - private String orbis; + @JsonProperty("ps4") + private String ps4; @JsonProperty("nx") private String NX; - @JsonProperty("switch") - private String nintendoSwitch; - - @JsonProperty("xboxOne") - private String xboxOne; + @JsonProperty("xbox") + private String xbox; } @Getter diff --git a/src/main/java/com/rtm516/FloodgatePlaceholders/Placeholder.java b/src/main/java/com/rtm516/FloodgatePlaceholders/Placeholder.java index 49a8db3..d8502a4 100644 --- a/src/main/java/com/rtm516/FloodgatePlaceholders/Placeholder.java +++ b/src/main/java/com/rtm516/FloodgatePlaceholders/Placeholder.java @@ -2,8 +2,8 @@ import me.clip.placeholderapi.expansion.PlaceholderExpansion; import org.bukkit.entity.Player; -import org.geysermc.floodgate.FloodgateAPI; -import org.geysermc.floodgate.FloodgatePlayer; +import org.geysermc.floodgate.api.FloodgateApi; +import org.geysermc.floodgate.api.player.FloodgatePlayer; public class Placeholder extends PlaceholderExpansion { @@ -44,14 +44,15 @@ public String onPlaceholderRequest(Player player, String identifier) { return ""; } + FloodgatePlayer floodgatePlayer = FloodgateApi.getInstance().getPlayer(player.getUniqueId()); + switch (identifier) { case "device": return getPlayerDeviceString(player); case "locale": case "locale_upper": - if (FloodgateAPI.isBedrockPlayer(player.getUniqueId())) { - FloodgatePlayer floodgatePlayer = FloodgateAPI.getPlayer(player.getUniqueId()); + if (floodgatePlayer != null) { boolean upper = identifier.endsWith("_upper"); return plugin.getConfiguration().getLocale().getFound().replace("%locale%", upper ? floodgatePlayer.getLanguageCode().toUpperCase() : floodgatePlayer.getLanguageCode().toLowerCase()); } else { @@ -59,24 +60,21 @@ public String onPlaceholderRequest(Player player, String identifier) { } case "version": - if (FloodgateAPI.isBedrockPlayer(player.getUniqueId())) { - FloodgatePlayer floodgatePlayer = FloodgateAPI.getPlayer(player.getUniqueId()); + if (floodgatePlayer != null) { return plugin.getConfiguration().getVersion().getFound().replace("%version%", floodgatePlayer.getVersion()); } else { return plugin.getConfiguration().getVersion().getNone(); } case "username": - if (FloodgateAPI.isBedrockPlayer(player.getUniqueId())) { - FloodgatePlayer floodgatePlayer = FloodgateAPI.getPlayer(player.getUniqueId()); + if (floodgatePlayer != null) { return plugin.getConfiguration().getXboxUsername().getFound().replace("%username%", floodgatePlayer.getUsername()); } else { return plugin.getConfiguration().getXboxUsername().getNone(); } case "xuid": - if (FloodgateAPI.isBedrockPlayer(player.getUniqueId())) { - FloodgatePlayer floodgatePlayer = FloodgateAPI.getPlayer(player.getUniqueId()); + if (floodgatePlayer != null) { return plugin.getConfiguration().getXboxXuid().getFound().replace("%xuid%", floodgatePlayer.getXuid()); } else { return plugin.getConfiguration().getXboxXuid().getNone(); @@ -93,36 +91,34 @@ public String onPlaceholderRequest(Player player, String identifier) { * @return The formatted device string from config */ private String getPlayerDeviceString(Player player) { - if (FloodgateAPI.isBedrockPlayer(player.getUniqueId())) { + FloodgatePlayer floodgatePlayer = FloodgateApi.getInstance().getPlayer(player.getUniqueId()); + if (floodgatePlayer != null) { if (plugin.getConfiguration().isSpecificDeviceDescriptors()) { - FloodgatePlayer floodgatePlayer = FloodgateAPI.getPlayer(player.getUniqueId()); - switch (floodgatePlayer.getDeviceOS()) { - case ANDROID: - return plugin.getConfiguration().getDevice().getAndroid().replace("&", "§"); + switch (floodgatePlayer.getDeviceOs()) { + case GOOGLE: + return plugin.getConfiguration().getDevice().getGoogle().replace("&", "§"); case IOS: return plugin.getConfiguration().getDevice().getIOS().replace("&", "§"); case OSX: return plugin.getConfiguration().getDevice().getOSX().replace("&", "§"); - case FIREOS: - return plugin.getConfiguration().getDevice().getFireos().replace("&", "§"); + case AMAZON: + return plugin.getConfiguration().getDevice().getAmazon().replace("&", "§"); case GEARVR: return plugin.getConfiguration().getDevice().getGearVR().replace("&", "§"); case HOLOLENS: return plugin.getConfiguration().getDevice().getHololens().replace("&", "§"); - case WIN10: - return plugin.getConfiguration().getDevice().getWin10().replace("&", "§"); + case UWP: + return plugin.getConfiguration().getDevice().getUwp().replace("&", "§"); case WIN32: return plugin.getConfiguration().getDevice().getWin32().replace("&", "§"); case DEDICATED: return plugin.getConfiguration().getDevice().getDedicated().replace("&", "§"); - case ORBIS: - return plugin.getConfiguration().getDevice().getOrbis().replace("&", "§"); + case PS4: + return plugin.getConfiguration().getDevice().getPs4().replace("&", "§"); case NX: return plugin.getConfiguration().getDevice().getNX().replace("&", "§"); - case SWITCH: - return plugin.getConfiguration().getDevice().getNintendoSwitch().replace("&", "§"); - case XBOX_ONE: - return plugin.getConfiguration().getDevice().getXboxOne().replace("&", "§"); + case XBOX: + return plugin.getConfiguration().getDevice().getXbox().replace("&", "§"); default: return plugin.getConfiguration().getDevice().getUnknown().replace("&", "§"); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index bace87b..07306e7 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -6,19 +6,18 @@ device: java: "&8[&aJava&8]" generic: "&8[&7Bedrock&8]" unknown: "&8[&aUnknown&8]" - android: "&8[&aAndroid&8]" + google: "&8[&aAndroid&8]" ios: "&8[&bi&fOS&8]" osx: "&8[&fOS&bX&8]" fireos: "&8[&6F&fireOS&8]" gearvr: "&8[&7Gear&fVR&8]" hololens: "&8[&7Holo&fLens&8]" - win10: "&8[&3Win&f10&8]" + uwp: "&8[&3UWP&8]" win32: "&8[&3Win&f32&8]" dedicated: "&8[&aDED&8]" - orbis: "&8[&3ORBIS&8]" - nx: "&8[&eNX&8]" - switch: "&8[&4Switch&8]" - xboxOne: "&8[&2Xbox&fOne&8]" + ps4: "&8[&3PS4&8]" + nx: "&8[&eSwitch&8]" + xboxOne: "&8[&2Xbox&8]" # The locale format (none for java users) locale: diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index d6d4429..54dc1c6 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -3,4 +3,4 @@ main: com.rtm516.FloodgatePlaceholders.Main version: ${project.version} author: rtm516 api-version: 1.15 -depend: [floodgate-bukkit,PlaceholderAPI] \ No newline at end of file +depend: [floodgate,PlaceholderAPI] \ No newline at end of file