Skip to content

Commit

Permalink
Update to floodgate 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rtm516 committed Mar 25, 2021
1 parent 03b585d commit 494ab05
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 57 deletions.
18 changes: 6 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.rtm516</groupId>
<artifactId>FloodgatePlaceholders</artifactId>
<version>1.1</version>
<version>1.2</version>
<name>FloodgatePlaceholders</name>

<developers>
Expand Down Expand Up @@ -69,22 +69,16 @@
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>nukkitx-snapshot</id>
<url>https://repo.nukkitx.com/maven-snapshots/</url>
<id>opencollab-snapshot</id>
<url>https://repo.opencollab.dev/maven-snapshots/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.geysermc</groupId>
<artifactId>floodgate-common</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.geysermc</groupId>
<artifactId>floodgate-bukkit</artifactId>
<version>1.0-SNAPSHOT</version>
<groupId>org.geysermc.floodgate</groupId>
<artifactId>api</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
23 changes: 10 additions & 13 deletions src/main/java/com/rtm516/FloodgatePlaceholders/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,44 +41,41 @@ public static class DevicePlaceholders {
@JsonProperty("unknown")
private String unknown;

@JsonProperty("android")
private String android;
@JsonProperty("google")
private String google;

@JsonProperty("ios")
private String iOS;

@JsonProperty("osx")
private String OSX;

@JsonProperty("fireos")
private String fireos;
@JsonProperty("amazon")
private String amazon;

@JsonProperty("gearvr")
private String gearVR;

@JsonProperty("hololens")
private String hololens;

@JsonProperty("win10")
private String win10;
@JsonProperty("uwp")
private String uwp;

@JsonProperty("win32")
private String win32;

@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
Expand Down
46 changes: 21 additions & 25 deletions src/main/java/com/rtm516/FloodgatePlaceholders/Placeholder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -44,39 +44,37 @@ 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 {
return plugin.getConfiguration().getLocale().getNone();
}

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();
Expand All @@ -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("&", "§");
}
Expand Down
11 changes: 5 additions & 6 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ main: com.rtm516.FloodgatePlaceholders.Main
version: ${project.version}
author: rtm516
api-version: 1.15
depend: [floodgate-bukkit,PlaceholderAPI]
depend: [floodgate,PlaceholderAPI]

0 comments on commit 494ab05

Please sign in to comment.