diff --git a/.gitignore b/.gitignore
index 7d9cce2..03c09c2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,151 +1,5 @@
-### Eclipse ###
-
-.metadata
-bin/
-tmp/
-*.tmp
-*.bak
-*.swp
-*~.nib
-local.properties
-.settings/
-.loadpath
-.recommenders
-
-/.idea/
-
-# External tool builders
-.externalToolBuilders/
-
-# Locally stored "Eclipse launch configurations"
-*.launch
-
-# PyDev specific (Python IDE for Eclipse)
-*.pydevproject
-
-# CDT-specific (C/C++ Development Tooling)
-.cproject
-
-# Java annotation processor (APT)
-.factorypath
-
-# PDT-specific (PHP Development Tools)
-.buildpath
-
-# sbteclipse plugin
-.target
-
-# Tern plugin
-.tern-project
-
-# TeXlipse plugin
-.texlipse
-
-# STS (Spring Tool Suite)
-.springBeans
-
-# Code Recommenders
-.recommenders/
-
-# Scala IDE specific (Scala & Java development for Eclipse)
-.cache-main
-.scala_dependencies
-.worksheet
-
-### Eclipse Patch ###
-# Eclipse Core
-.project
-
-# JDT-specific (Eclipse Java Development Tools)
-.classpath
-
-### Intellij ###
-# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
-# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
-
-# User-specific stuff:
-.idea/**/workspace.xml
-.idea/**/tasks.xml
-.idea/dictionaries
-
-# Sensitive or high-churn files:
-.idea/**/dataSources/
-.idea/**/dataSources.ids
-.idea/**/dataSources.xml
-.idea/**/dataSources.local.xml
-.idea/**/sqlDataSources.xml
-.idea/**/dynamic.xml
-.idea/**/uiDesigner.xml
-
-# Gradle:
-.idea/**/gradle.xml
-.idea/**/libraries
-
-# CMake
-cmake-build-debug/
-
-# Mongo Explorer plugin:
-.idea/**/mongoSettings.xml
-
-## File-based project format:
-*.iws
-
-## Plugin-specific files:
-
-# IntelliJ
-/out/
-
-# mpeltonen/sbt-idea plugin
-.idea_modules/
-
-# JIRA plugin
-atlassian-ide-plugin.xml
-
-# Cursive Clojure plugin
-.idea/replstate.xml
-
-# Ruby plugin and RubyMine
-/.rakeTasks
-
-# Crashlytics plugin (for Android Studio and IntelliJ)
-com_crashlytics_export_strings.xml
-crashlytics.properties
-crashlytics-build.properties
-fabric.properties
-
-### Intellij Patch ###
-# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
-
-*.iml
-# modules.xml
-# .idea/misc.xml
-# *.ipr
-
-# Sonarlint plugin
-.idea/sonarlint
-
-### Maven ###
-target/
-pom.xml.tag
-pom.xml.releaseBackup
-pom.xml.versionsBackup
-pom.xml.next
-release.properties
-dependency-reduced-pom.xml
-buildNumber.properties
-.mvn/timing.properties
-
-# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
-!/.mvn/wrapper/maven-wrapper.jar
-
-### NetBeans ###
-nbproject/private/
+.idea/
+.gradle/
build/
-nbbuild/
-dist/
-nbdist/
-.nb-gradle/
-nbactions.xml
-### Piggy's Debugging Shit ###
-server/
\ No newline at end of file
+*.iml
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
new file mode 100644
index 0000000..7fbedac
--- /dev/null
+++ b/build.gradle.kts
@@ -0,0 +1,36 @@
+plugins {
+ java
+ id("com.github.johnrengelman.shadow") version ("7.0.0")
+}
+
+group = "at.helpch.placeholderapi.expansion"
+version = "2.1.0"
+
+repositories {
+ mavenCentral()
+ maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
+ maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
+}
+
+dependencies {
+ compileOnly("org.spigotmc:spigot-api:1.20.6-R0.1-SNAPSHOT")
+ compileOnly("me.clip:placeholderapi:2.11.3")
+}
+
+java {
+ sourceCompatibility = JavaVersion.VERSION_1_8
+ targetCompatibility = JavaVersion.VERSION_1_8
+}
+
+tasks {
+ jar {
+ manifest {
+ attributes["Implementation-Title"] = "player"
+ attributes["Implementation-Version"] = project.version
+ }
+ }
+
+ shadowJar {
+ archiveFileName.set("PAPI-Expansion-Player-${project.version}.jar")
+ }
+}
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..7f93135
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..3fa8f86
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,7 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
new file mode 100644
index 0000000..1aa94a4
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,249 @@
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..93e3f59
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,92 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%"=="" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 0 goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/pom.xml b/pom.xml
deleted file mode 100644
index 32ba863..0000000
--- a/pom.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-
- 4.0.0
-
- com.extendedclip.papi.expansion.player
- player-expansion
- 2.0.8
-
- PAPI-Expansion-Player
- PlaceholderAPI expansion for player placeholders
-
-
- 1.8
- 1.8
- UTF-8
-
-
-
-
- spigot-repo
- https://hub.spigotmc.org/nexus/content/repositories/snapshots/
-
-
- placeholderapi
- https://repo.extendedclip.com/content/repositories/placeholderapi/
-
-
-
-
-
-
- org.spigotmc
- spigot-api
- 1.20-R0.1-SNAPSHOT
- provided
-
-
- me.clip
- placeholderapi
- 2.11.3
- provided
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
- 2.3.2
-
- ${project.name}
-
-
- true
- true
-
-
-
-
-
-
-
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..7ff03fb
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1 @@
+rootProject.name = 'player-expansion'
\ No newline at end of file
diff --git a/src/main/java/at/helpch/placeholderapi/expansion/player/PlayerExpansion.java b/src/main/java/at/helpch/placeholderapi/expansion/player/PlayerExpansion.java
new file mode 100644
index 0000000..2a560ab
--- /dev/null
+++ b/src/main/java/at/helpch/placeholderapi/expansion/player/PlayerExpansion.java
@@ -0,0 +1,526 @@
+package at.helpch.placeholderapi.expansion.player;
+
+import at.helpch.placeholderapi.expansion.player.handler.PlayerLocaleHandler;
+import at.helpch.placeholderapi.expansion.player.ping.PingFormatter;
+import at.helpch.placeholderapi.expansion.player.util.ItemUtil;
+import at.helpch.placeholderapi.expansion.player.util.PlayerUtil;
+import at.helpch.placeholderapi.expansion.player.util.TimeUtil;
+import at.helpch.placeholderapi.expansion.player.util.VersionHelper;
+import com.google.common.collect.ImmutableMap;
+import me.clip.placeholderapi.PlaceholderAPIPlugin;
+import me.clip.placeholderapi.expansion.Configurable;
+import me.clip.placeholderapi.expansion.PlaceholderExpansion;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.NamespacedKey;
+import org.bukkit.OfflinePlayer;
+import org.bukkit.World;
+import org.bukkit.block.BlockFace;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.potion.PotionEffect;
+import org.bukkit.potion.PotionEffectType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.StringJoiner;
+import java.util.concurrent.TimeUnit;
+
+public final class PlayerExpansion extends PlaceholderExpansion implements Configurable {
+
+ private PingFormatter pingFormatter;
+ private Map directionNames;
+
+ @Override
+ public @NotNull String getIdentifier() {
+ return "player";
+ }
+
+ @Override
+ public @NotNull String getAuthor() {
+ return "HelpChat";
+ }
+
+ @Override
+ public @NotNull String getVersion() {
+ return getClass().getPackage().getImplementationVersion();
+ }
+
+ @Override
+ public Map getDefaults() {
+ return ImmutableMap.builder()
+ .put("direction.north", "N")
+ .put("direction.north_east", "NE")
+ .put("direction.east", "E")
+ .put("direction.south_east", "SE")
+ .put("direction.south", "S")
+ .put("direction.south_west", "SW")
+ .put("direction.west", "W")
+ .put("direction.north_west", "NW")
+ .put("ping.formatting.>200", "&4")
+ .put("ping.formatting.>150", "&c")
+ .put("ping.formatting.>100", "&e")
+ .put("ping.formatting.>75", "&2")
+ .put("ping.formatting.>50", "&a")
+ .put("ping.formatting.>25", "&b")
+ .put("ping.formatting.=0", "&9")
+ .build();
+ }
+
+ @Override
+ public boolean canRegister() {
+ pingFormatter = new PingFormatter(getConfigSection("ping.formatting"));
+ directionNames = Optional.ofNullable(getConfigSection("direction"))
+ .map(section -> section.getValues(false))
+ .orElseGet(HashMap::new);
+ return true;
+ }
+
+ /**
+ * Format a {@code boolean} as {@link PlaceholderAPIPlugin#booleanTrue()} or {@link PlaceholderAPIPlugin#booleanFalse()}
+ *
+ * @param bool boolean
+ * @return {@link PlaceholderAPIPlugin#booleanTrue()} if the boolean is true, otherwise {@link PlaceholderAPIPlugin#booleanFalse()}
+ */
+ private @NotNull String bool(final boolean bool) {
+ return bool ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
+ }
+
+ private @NotNull String getItemInfo(@Nullable final ItemStack item, @NotNull final String args) {
+ switch (args) {
+ case "_name":
+ return ItemUtil.getName(item);
+ case "_data":
+ return String.valueOf(ItemUtil.getDamage(item));
+ case "_durability":
+ return String.valueOf(ItemUtil.getDurability(item));
+ default:
+ return ItemUtil.getMaterialName(item);
+ }
+ }
+
+ @SuppressWarnings("SpellCheckingInspection")
+ @Override
+ public @Nullable String onRequest(OfflinePlayer offlinePlayer, @NotNull String params) {
+ final boolean targetedPing = params.startsWith("ping_");
+ final boolean targetedColoredPing = params.startsWith("colored_ping_");
+
+ if (targetedPing || targetedColoredPing) {
+ final String targetName = params.substring((targetedPing ? "ping_" : "colored_ping_").length());
+ return Optional.ofNullable(Bukkit.getPlayerExact(targetName))
+ .map(target -> pingFormatter.getPing(target, targetedColoredPing))
+ .orElse("0");
+ }
+
+ if (offlinePlayer == null) {
+ return "";
+ }
+
+ switch (params) {
+ case "name":
+ return offlinePlayer.getName();
+ case "uuid":
+ return offlinePlayer.getUniqueId().toString();
+ case "first_played":
+ case "first_join":
+ return String.valueOf(offlinePlayer.getFirstPlayed());
+ case "first_played_formatted":
+ case "first_join_date":
+ return PlaceholderAPIPlugin.getDateFormat().format(new Date(offlinePlayer.getFirstPlayed()));
+ case "last_played":
+ case "last_join":
+ //noinspection deprecation
+ return String.valueOf(offlinePlayer.getLastPlayed());
+ case "last_played_formatted":
+ case "last_join_date":
+ //noinspection deprecation
+ return PlaceholderAPIPlugin.getDateFormat().format(new Date(offlinePlayer.getLastPlayed()));
+
+ //
+ case "bed_is_set":
+ return bool(offlinePlayer.getBedSpawnLocation() != null);
+ case "bed_x":
+ return PlayerUtil.getBedLocationInfo(offlinePlayer, "0", Location::getBlockX);
+ case "bed_y":
+ return PlayerUtil.getBedLocationInfo(offlinePlayer, "0", Location::getBlockY);
+ case "bed_z":
+ return PlayerUtil.getBedLocationInfo(offlinePlayer, "0", Location::getBlockZ);
+ case "bed_world":
+ return PlayerUtil.getBedLocationInfo(offlinePlayer, "N/A", location -> location.getWorld().getName());
+ //
+
+ //
+ case "has_played_before":
+ return bool(offlinePlayer.hasPlayedBefore());
+ case "is_banned":
+ return bool(offlinePlayer.isBanned());
+ case "is_op":
+ return bool(offlinePlayer.isOp());
+ case "is_whitelisted":
+ return bool(offlinePlayer.isWhitelisted());
+ case "online":
+ return bool(offlinePlayer.isOnline());
+ //
+ }
+
+ if (!offlinePlayer.isOnline()) {
+ return "";
+ }
+
+ final Player player = offlinePlayer.getPlayer();
+
+ // To get rid of IDE warnings
+ if (player == null) {
+ return "";
+ }
+
+ switch (params) {
+ //
+ case "displayname":
+ //noinspection deprecation
+ return player.getDisplayName();
+ case "custom_name":
+ return Optional.ofNullable(player.getCustomName()).orElseGet(player::getName);
+ case "list_name":
+ //noinspection deprecation
+ return player.getPlayerListName();
+
+ case "absorption": {
+ if (VersionHelper.HAS_ABSORPTION_METHODS) {
+ return String.valueOf((int) player.getAbsorptionAmount());
+ } else {
+ return "-1";
+ }
+ }
+ case "fly_speed":
+ return String.valueOf(player.getFlySpeed());
+ case "food_level":
+ return String.valueOf(player.getFoodLevel());
+
+ case "gamemode":
+ return player.getGameMode().name();
+
+ case "health":
+ return String.valueOf(player.getHealth());
+ case "health_rounded":
+ return String.valueOf(Math.round(player.getHealth()));
+ case "health_scale":
+ return String.valueOf(player.getHealthScale());
+ case "health_boost": {
+ if (player.getHealthScale() > 20) {
+ return String.valueOf(player.getHealthScale() - 20);
+ } else {
+ return "0";
+ }
+ }
+
+ case "last_damage":
+ return String.valueOf(player.getLastDamage());
+ case "max_air":
+ return String.valueOf(player.getMaximumAir());
+ case "max_health":
+ return String.valueOf(PlayerUtil.getMaxHealth(player));
+ case "max_health_rounded":
+ return String.valueOf(Math.round(PlayerUtil.getMaxHealth(player)));
+ case "max_no_damage_ticks":
+ return String.valueOf(player.getMaximumNoDamageTicks());
+ case "no_damage_ticks":
+ return String.valueOf(player.getNoDamageTicks());
+ case "remaining_air":
+ return String.valueOf(player.getRemainingAir());
+ case "saturation":
+ return String.valueOf(player.getSaturation());
+ case "sleep_ticks":
+ return String.valueOf(player.getSleepTicks());
+ case "ticks_lived":
+ return String.valueOf(player.getTicksLived());
+ case "seconds_lived":
+ return String.valueOf(player.getTicksLived() / 20L);
+ case "minutes_lived":
+ return String.valueOf(TimeUnit.SECONDS.toMinutes(player.getTicksLived() / 20L));
+ case "walk_speed":
+ return String.valueOf(player.getWalkSpeed());
+
+ case "ip":
+ return Optional.ofNullable(player.getAddress())
+ .map(InetSocketAddress::getAddress)
+ .map(InetAddress::getHostAddress)
+ .orElse("");
+ case "ping":
+ case "colored_ping":
+ return pingFormatter.getPing(player, params.startsWith("colored"));
+
+ case "time":
+ return String.valueOf(player.getPlayerTime());
+ case "time_offset":
+ return String.valueOf(player.getPlayerTimeOffset());
+ //
+
+ //
+ case "world":
+ return player.getWorld().getName();
+ case "world_type": {
+ final World.Environment environment = player.getWorld().getEnvironment();
+ if (environment == World.Environment.NETHER) {
+ return "Nether";
+ } else if (environment == World.Environment.THE_END) {
+ return "The End";
+ } else if (environment == World.Environment.NORMAL) {
+ return "Overworld";
+ } else if (environment.name().equals("CUSTOM")) {
+ return "Custom";
+ } else {
+ return environment.name();
+ }
+ }
+ case "world_time":
+ return String.valueOf(player.getWorld().getTime());
+ case "world_time_12":
+ case "world_time_24":
+ return TimeUtil.formatWorldTime(player.getWorld().getTime(), params.equals("world_time_24"));
+ case "weather_duration":
+ return String.valueOf(player.getWorld().getWeatherDuration());
+ case "thunder_duration":
+ return String.valueOf(player.getWorld().getThunderDuration());
+
+ case "direction":
+ // NORTH_EAST -> north_east -> value from config (e.g. NE)
+ return Optional.of(PlayerUtil.getDirection(player))
+ .map(BlockFace::name)
+ .map(String::toLowerCase)
+ .map(directionNames::get)
+ .map(String::valueOf)
+ .orElse("");
+ case "direction_xz":
+ return PlayerUtil.getXZDirection(player);
+ case "x":
+ return String.valueOf(player.getLocation().getBlockX());
+ case "x_long":
+ return String.valueOf(player.getLocation().getX());
+ case "y":
+ return String.valueOf(player.getLocation().getBlockY());
+ case "y_long":
+ return String.valueOf(player.getLocation().getY());
+ case "z":
+ return String.valueOf(player.getLocation().getBlockZ());
+ case "z_long":
+ return String.valueOf(player.getLocation().getZ());
+ case "yaw":
+ return String.valueOf(player.getLocation().getYaw());
+ case "pitch":
+ return String.valueOf(player.getLocation().getPitch());
+ case "block_underneath":
+ return String.valueOf(
+ player.getLocation()
+ .clone()
+ .subtract(0, 1, 0)
+ .getBlock()
+ .getType()
+ );
+ case "light_level":
+ return String.valueOf(player.getLocation().getBlock().getLightLevel());
+ case "biome":
+ case "biome_capitalized": {
+ final String biome = player.getLocation().getBlock().getBiome().toString();
+
+ if (!params.endsWith("_capitalized")) {
+ return biome;
+ }
+
+ final StringJoiner joiner = new StringJoiner(" ");
+
+ for (String part : biome.split("_")) {
+ joiner.add(part.substring(0, 1).toUpperCase() + part.substring(1).toLowerCase());
+ }
+
+ return joiner.toString();
+ }
+
+ case "compass_x":
+ return PlayerUtil.getCompassLocationInfo(player, "0", Location::getBlockX);
+ case "compass_y":
+ return PlayerUtil.getCompassLocationInfo(player, "0", Location::getBlockY);
+ case "compass_z":
+ return PlayerUtil.getCompassLocationInfo(player, "0", Location::getBlockZ);
+ case "compass_world":
+ return PlayerUtil.getCompassLocationInfo(player, Bukkit.getWorlds().get(0).getName(), location -> location.getWorld().getName());
+ //
+
+ //
+ case "exp":
+ return String.valueOf(player.getExp());
+ case "current_exp":
+ return String.valueOf(PlayerUtil.getTotalExperience(player));
+ case "total_exp":
+ return String.valueOf(player.getTotalExperience());
+ case "exp_to_level":
+ return String.valueOf(player.getExpToLevel());
+ case "level":
+ return String.valueOf(player.getLevel());
+ //
+
+ //
+ case "has_empty_slot":
+ return bool(player.getInventory().firstEmpty() > -1);
+ case "empty_slots":
+ return String.valueOf(PlayerUtil.getEmptySlotsCount(player));
+
+ case "item_in_hand":
+ case "item_in_hand_name":
+ case "item_in_hand_data":
+ case "item_in_hand_durability":
+ return getItemInfo(PlayerUtil.getItemInMainHand(player), params.substring("item_in_hand".length()));
+
+ case "item_in_offhand":
+ case "item_in_offhand_name":
+ case "item_in_offhand_data":
+ case "item_in_offhand_durability":
+ return getItemInfo(player.getInventory().getItemInOffHand(), params.substring("item_in_offhand".length()));
+
+ case "armor_helmet":
+ case "armor_helmet_name":
+ case "armor_helmet_data":
+ case "armor_helmet_durability":
+ return getItemInfo(player.getInventory().getHelmet(), params.substring("armor_helmet".length()));
+
+ case "armor_chestplate":
+ case "armor_chestplate_name":
+ case "armor_chestplate_data":
+ case "armor_chestplate_durability":
+ return getItemInfo(player.getInventory().getChestplate(), params.substring("armor_chestplate".length()));
+
+ case "armor_leggings":
+ case "armor_leggings_name":
+ case "armor_leggings_data":
+ case "armor_leggings_durability":
+ return getItemInfo(player.getInventory().getLeggings(), params.substring("armor_leggings".length()));
+
+ case "armor_boots":
+ case "armor_boots_name":
+ case "armor_boots_data":
+ case "armor_boots_durability":
+ return getItemInfo(player.getInventory().getBoots(), params.substring("armor_boots".length()));
+ //
+
+ //
+ case "allow_flight":
+ return bool(player.getAllowFlight());
+ case "can_pickup_items":
+ return bool(player.getCanPickupItems());
+ case "has_health_boost":
+ return bool(player.hasPotionEffect(PotionEffectType.HEALTH_BOOST));
+ case "is_conversing":
+ return bool(player.isConversing());
+ case "is_dead":
+ return bool(player.isDead());
+ case "is_flying":
+ return bool(player.isFlying());
+ case "is_gliding":
+ return bool(player.isGliding());
+ case "is_inside_vehicle":
+ return bool(player.isInsideVehicle());
+ case "is_leashed":
+ return bool(player.isLeashed());
+ case "is_sleeping":
+ return bool(player.isSleeping());
+ case "is_sneaking":
+ return bool(player.isSneaking());
+ case "is_sprinting":
+ return bool(player.isSprinting());
+ //
+
+ //
+ case "server":
+ case "servername":
+ return "now available in the server expansion";
+ //
+ }
+
+ // has_permission_
+ if (params.startsWith("has_permission_")) {
+ final String permission = params.substring("has_permission_".length());
+ return bool(player.hasPermission(permission));
+ }
+
+ // has_potioneffect_
+ if (params.startsWith("has_potioneffect_")) {
+ final String effectName = params.substring("has_potioneffect_".length());
+ final Optional effectType = Optional.ofNullable(PotionEffectType.getByName(effectName));
+
+ if (!effectType.isPresent()) {
+ return "Unknown potion effect " + effectName;
+ }
+
+ return effectType.map(player::hasPotionEffect)
+ .map(this::bool)
+ .get();
+ }
+
+ // potion_effect_level_
+ if (params.startsWith("potion_effect_level_")) {
+ final String effectName = params.substring("potion_effect_level_".length());
+ final Optional effectType = Optional.ofNullable(PotionEffectType.getByName(effectName));
+
+ if (!effectType.isPresent()) {
+ return "Unknown potion effect " + effectName;
+ }
+
+ return effectType.filter(player::hasPotionEffect)
+ .map(player::getPotionEffect)
+ .map(PotionEffect::getAmplifier)
+ .map(String::valueOf)
+ .orElse("0");
+ }
+
+ // item_in_hand_level_
+ if (params.startsWith("item_in_hand_level_")) {
+ return ItemUtil.getEnchantmentLevel(PlayerUtil.getItemInMainHand(player), params.substring("item_in_hand_level_".length()));
+ }
+
+ // item_in_offhand_level_
+ if (params.startsWith("item_in_offhand_level_")) {
+ return ItemUtil.getEnchantmentLevel(player.getInventory().getItemInOffHand(), params.substring("item_in_offhand_level_".length()));
+ }
+
+ // locale or locale_