mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2025-11-10 09:05:05 +01:00
Compare commits
7 Commits
deprecated
...
developmen
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3602e5aea | ||
|
|
b8d4dcd570 | ||
|
|
8a249a9a2e | ||
|
|
915166f78b | ||
|
|
533b892cf4 | ||
|
|
6676e2fa21 | ||
|
|
99e5752352 |
@@ -3,8 +3,8 @@ import org.apache.tools.ant.filters.ReplaceTokens
|
|||||||
plugins {
|
plugins {
|
||||||
id "java"
|
id "java"
|
||||||
id "maven-publish"
|
id "maven-publish"
|
||||||
id "org.cadixdev.licenser" version "0.6.1"
|
id "org.cadixdev.licenser" version "0.6.0"
|
||||||
id "com.github.johnrengelman.shadow" version "7.1.0"
|
id "com.github.johnrengelman.shadow" version "7.0.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
group "me.clip"
|
group "me.clip"
|
||||||
@@ -24,9 +24,10 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "org.bstats:bstats-bukkit:2.2.1"
|
implementation "org.bstats:bstats-bukkit:2.2.1"
|
||||||
implementation "net.kyori:adventure-platform-bukkit:4.0.1"
|
|
||||||
|
|
||||||
compileOnly "org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT"
|
implementation "net.kyori:adventure-platform-bukkit:4.0.0"
|
||||||
|
|
||||||
|
compileOnly "org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT"
|
||||||
compileOnly "org.jetbrains:annotations:22.0.0"
|
compileOnly "org.jetbrains:annotations:22.0.0"
|
||||||
|
|
||||||
testImplementation "org.openjdk.jmh:jmh-core:1.32"
|
testImplementation "org.openjdk.jmh:jmh-core:1.32"
|
||||||
|
|||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
257
gradlew
vendored
257
gradlew
vendored
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright <20> 2015-2021 the original authors.
|
# Copyright 2015 the original author or authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -17,101 +17,67 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
##
|
||||||
# Gradle start up script for POSIX generated by Gradle.
|
## Gradle start up script for UN*X
|
||||||
#
|
##
|
||||||
# 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 <20>$var<61>, <20>${var}<7D>, <20>${var:-default}<7D>, <20>${var+SET}<7D>,
|
|
||||||
# <20>${var#prefix}<7D>, <20>${var%suffix}<7D>, and <20>$( cmd )<29>;
|
|
||||||
# * compound commands having a testable exit status, especially <20>case<73>;
|
|
||||||
# * various built-in commands including <20>command<6E>, <20>set<65>, and <20>ulimit<69>.
|
|
||||||
#
|
|
||||||
# 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/master/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
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
# Resolve links: $0 may be a link
|
||||||
app_path=$0
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
# Need this for daisy-chained symlinks.
|
while [ -h "$PRG" ] ; do
|
||||||
while
|
ls=`ls -ld "$PRG"`
|
||||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
[ -h "$app_path" ]
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
do
|
PRG="$link"
|
||||||
ls=$( ls -ld "$app_path" )
|
else
|
||||||
link=${ls#*' -> '}
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
case $link in #(
|
fi
|
||||||
/*) app_path=$link ;; #(
|
|
||||||
*) app_path=$APP_HOME$link ;;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
APP_NAME="Gradle"
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# 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"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD="maximum"
|
||||||
|
|
||||||
warn () {
|
warn () {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
} >&2
|
}
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
} >&2
|
}
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
# OS specific support (must be 'true' or 'false').
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
nonstop=false
|
nonstop=false
|
||||||
case "$( uname )" in #(
|
case "`uname`" in
|
||||||
CYGWIN* ) cygwin=true ;; #(
|
CYGWIN* )
|
||||||
Darwin* ) darwin=true ;; #(
|
cygwin=true
|
||||||
MSYS* | MINGW* ) msys=true ;; #(
|
;;
|
||||||
NONSTOP* ) nonstop=true ;;
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
@@ -121,9 +87,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
else
|
else
|
||||||
JAVACMD=$JAVA_HOME/bin/java
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
@@ -132,7 +98,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
|||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
JAVACMD="java"
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
which java >/dev/null 2>&1 || 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
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
@@ -140,95 +106,80 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
case $MAX_FD in #(
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
max*)
|
if [ $? -eq 0 ] ; then
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
warn "Could not query maximum file descriptor limit"
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
esac
|
fi
|
||||||
case $MAX_FD in #(
|
ulimit -n $MAX_FD
|
||||||
'' | soft) :;; #(
|
if [ $? -ne 0 ] ; then
|
||||||
*)
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
ulimit -n "$MAX_FD" ||
|
fi
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
else
|
||||||
esac
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java command, stacking in reverse order:
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
# * args from the command line
|
if $darwin; then
|
||||||
# * the main class name
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
# * -classpath
|
fi
|
||||||
# * -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
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
if "$cygwin" || "$msys" ; then
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
for arg do
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
if
|
SEP=""
|
||||||
case $arg in #(
|
for dir in $ROOTDIRSRAW ; do
|
||||||
-*) false ;; # don't mess with options #(
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
SEP="|"
|
||||||
[ -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
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=`expr $i + 1`
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
0) set -- ;;
|
||||||
|
1) set -- "$args0" ;;
|
||||||
|
2) set -- "$args0" "$args1" ;;
|
||||||
|
3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
# Escape application args
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
save () {
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
# double quotes to make sure that they get re-expanded; and
|
echo " "
|
||||||
# * put everything else in single quotes, so that it's not re-expanded.
|
}
|
||||||
|
APP_ARGS=`save "$@"`
|
||||||
|
|
||||||
set -- \
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
-classpath "$CLASSPATH" \
|
|
||||||
org.gradle.wrapper.GradleWrapperMain \
|
|
||||||
"$@"
|
|
||||||
|
|
||||||
# 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" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
|||||||
@@ -22,18 +22,22 @@ package me.clip.placeholderapi;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import me.clip.placeholderapi.expansion.Relational;
|
import me.clip.placeholderapi.expansion.Relational;
|
||||||
|
import me.clip.placeholderapi.expansion.manager.LocalExpansionManager;
|
||||||
import me.clip.placeholderapi.replacer.CharsReplacer;
|
import me.clip.placeholderapi.replacer.CharsReplacer;
|
||||||
import me.clip.placeholderapi.replacer.Replacer;
|
import me.clip.placeholderapi.replacer.Replacer;
|
||||||
import me.clip.placeholderapi.replacer.Replacer.Closure;
|
import me.clip.placeholderapi.replacer.Replacer.Closure;
|
||||||
import me.clip.placeholderapi.util.Msg;
|
import me.clip.placeholderapi.util.Msg;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public final class PlaceholderAPI {
|
public final class PlaceholderAPI {
|
||||||
@@ -77,7 +81,7 @@ public final class PlaceholderAPI {
|
|||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public static List<String> setPlaceholders(final OfflinePlayer player,
|
public static List<String> setPlaceholders(final OfflinePlayer player,
|
||||||
@NotNull final List<@NotNull String> text) {
|
@NotNull final List<String> text) {
|
||||||
return text.stream().map(line -> setPlaceholders(player, line)).collect(Collectors.toList());
|
return text.stream().map(line -> setPlaceholders(player, line)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,7 +136,7 @@ public final class PlaceholderAPI {
|
|||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public static List<String> setBracketPlaceholders(final OfflinePlayer player,
|
public static List<String> setBracketPlaceholders(final OfflinePlayer player,
|
||||||
@NotNull final List<@NotNull String> text) {
|
@NotNull final List<String> text) {
|
||||||
return text.stream().map(line -> setBracketPlaceholders(player, line))
|
return text.stream().map(line -> setBracketPlaceholders(player, line))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
@@ -284,4 +288,335 @@ public final class PlaceholderAPI {
|
|||||||
public static boolean containsBracketPlaceholders(String text) {
|
public static boolean containsBracketPlaceholders(String text) {
|
||||||
return text != null && BRACKET_PLACEHOLDER_PATTERN.matcher(text).find();
|
return text != null && BRACKET_PLACEHOLDER_PATTERN.matcher(text).find();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// === Deprecated API ===
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public static boolean registerExpansion(PlaceholderExpansion expansion)
|
||||||
|
{
|
||||||
|
return expansion.register();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public static boolean unregisterExpansion(PlaceholderExpansion expansion)
|
||||||
|
{
|
||||||
|
return expansion.unregister();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get map of registered placeholders
|
||||||
|
*
|
||||||
|
* @deprecated Use {@link LocalExpansionManager#getExpansions()} instead.
|
||||||
|
*
|
||||||
|
* @return Map of registered placeholders
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public static Map<String, PlaceholderHook> getPlaceholders() {
|
||||||
|
return PlaceholderAPIPlugin.getInstance().getLocalExpansionManager()
|
||||||
|
.getExpansions().stream()
|
||||||
|
.collect(Collectors.toMap(PlaceholderExpansion::getIdentifier, ex -> ex));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Please use {@link PlaceholderExpansion} to
|
||||||
|
* register placeholders instead
|
||||||
|
*
|
||||||
|
* @param plugin The Plugin to register with this {@link PlaceholderHook}
|
||||||
|
* @param placeholderHook The {@link PlaceholderHook} to register
|
||||||
|
* @return always false
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public static boolean registerPlaceholderHook(Plugin plugin, PlaceholderHook placeholderHook) {
|
||||||
|
PlaceholderAPIPlugin.getInstance().getLogger().warning(plugin.getName()
|
||||||
|
+ " is attempting to register placeholders via a PlaceholderHook class which is no longer supported!"
|
||||||
|
+ " Please reach out to " + plugin.getDescription().getAuthors().toString()
|
||||||
|
+ " and let them know that they need to update ASAP!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Please use {@link PlaceholderExpansion} to
|
||||||
|
* register placeholders instead
|
||||||
|
*
|
||||||
|
* @param identifier The identifier to use for the {@link PlaceholderHook}
|
||||||
|
* @param placeholderHook The {@link PlaceholderHook} to register
|
||||||
|
* @return always false
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public static boolean registerPlaceholderHook(String identifier,
|
||||||
|
PlaceholderHook placeholderHook) {
|
||||||
|
PlaceholderAPIPlugin.getInstance().getLogger().warning(identifier
|
||||||
|
+ " is attempting to register placeholders via a PlaceholderHook class which is no longer supported!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Please use {@link PlaceholderExpansion} to
|
||||||
|
* unregister placeholders instead
|
||||||
|
*
|
||||||
|
* @param plugin The plugin to unregister
|
||||||
|
* @return always false
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public static boolean unregisterPlaceholderHook(Plugin plugin) {
|
||||||
|
PlaceholderAPIPlugin.getInstance().getLogger().warning(plugin.getName()
|
||||||
|
+ " is attempting to unregister placeholders via the PlaceholderAPI class which is no longer supported!"
|
||||||
|
+ " Please reach out to " + plugin.getDescription().getAuthors().toString()
|
||||||
|
+ " and let them know that they need to update ASAP!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Please use {@link PlaceholderExpansion} to
|
||||||
|
* unregister placeholders instead
|
||||||
|
*
|
||||||
|
* @param identifier The identifier to unregister
|
||||||
|
* @return always false
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public static boolean unregisterPlaceholderHook(String identifier) {
|
||||||
|
PlaceholderAPIPlugin.getInstance().getLogger().warning(identifier
|
||||||
|
+ " is attempting to unregister placeholders through the PlaceholderAPI class which is no longer supported!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Will be removed in a future release.
|
||||||
|
*
|
||||||
|
* @return Set of registered identifiers
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public static Set<String> getRegisteredPlaceholderPlugins() {
|
||||||
|
return getRegisteredIdentifiers();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Will be removed in a future release.
|
||||||
|
*
|
||||||
|
* @return always null
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public static Set<String> getExternalPlaceholderPlugins() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Please use {@link #setPlaceholders(OfflinePlayer, String)} instead
|
||||||
|
*
|
||||||
|
* @param player The offline player to parse the placeholders against
|
||||||
|
* @param text The text to parse
|
||||||
|
* @param pattern The Pattern to use
|
||||||
|
* @param colorize If PlaceholderAPI should also parse color codes
|
||||||
|
* @return String with the parsed placeholders
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public static String setPlaceholders(OfflinePlayer player,
|
||||||
|
String text, Pattern pattern, boolean colorize) {
|
||||||
|
return setPlaceholders(player, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Please use {@link #setPlaceholders(OfflinePlayer, List)} instead
|
||||||
|
*
|
||||||
|
* @param player The offline player to parse the placeholders against
|
||||||
|
* @param text The List of text to parse
|
||||||
|
* @param pattern The Pattern to use
|
||||||
|
* @param colorize If PlaceholderAPI should also parse color codes
|
||||||
|
* @return String with the parsed placeholders
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public static List<String> setPlaceholders(OfflinePlayer player,
|
||||||
|
List<String> text, Pattern pattern, boolean colorize) {
|
||||||
|
return setPlaceholders(player, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
|
||||||
|
*
|
||||||
|
* @param player The offline player to parse the placeholders against
|
||||||
|
* @param text The List of text to parse
|
||||||
|
* @param colorize If PlaceholderAPI should also parse color codes
|
||||||
|
* @return String with the parsed placeholders
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public static List<String> setPlaceholders(OfflinePlayer player, List<String> text,
|
||||||
|
boolean colorize) {
|
||||||
|
return setPlaceholders(player, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
|
||||||
|
*
|
||||||
|
* @param player The offline player to parse the placeholders against
|
||||||
|
* @param text The List of text to parse
|
||||||
|
* @param pattern The Pattern to use
|
||||||
|
* @return String with the parsed placeholders
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public static List<String> setPlaceholders(OfflinePlayer player, List<String> text,
|
||||||
|
Pattern pattern) {
|
||||||
|
return setPlaceholders(player, text);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @deprecated Will be removed in a future release.
|
||||||
|
*
|
||||||
|
* @param player The offline player to parse the placeholders against
|
||||||
|
* @param text The text to parse
|
||||||
|
* @param colorize If PlaceholderAPI should also parse color codes
|
||||||
|
* @return String with the parsed placeholders
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public static String setPlaceholders(Player player, String text, boolean colorize) {
|
||||||
|
return setPlaceholders(player, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Will be removed in a future release.
|
||||||
|
*
|
||||||
|
* @param player The offline player to parse the placeholders against
|
||||||
|
* @param text The List of text to parse
|
||||||
|
* @param colorize If PlaceholderAPI should also parse color codes
|
||||||
|
* @return String with the parsed placeholders
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public static List<String> setPlaceholders(Player player, List<String> text, boolean colorize) {
|
||||||
|
return setPlaceholders(player, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
|
||||||
|
*
|
||||||
|
* @param player The offline player to parse the placeholders against
|
||||||
|
* @param text The text to parse
|
||||||
|
* @param colorize If PlaceholderAPI should also parse color codes
|
||||||
|
* @return String with the parsed placeholders
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public static String setPlaceholders(OfflinePlayer player, String text, boolean colorize) {
|
||||||
|
return setPlaceholders(player, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
|
||||||
|
*
|
||||||
|
* @param player The offline player to parse the placeholders against
|
||||||
|
* @param text The text to parse
|
||||||
|
* @param pattern The Pattern to use
|
||||||
|
* @return String with the parsed placeholders
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public static String setPlaceholders(OfflinePlayer player, String text, Pattern pattern) {
|
||||||
|
return setPlaceholders(player, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, List)} instead.
|
||||||
|
*
|
||||||
|
* @param player The offline player to parse the placeholders against
|
||||||
|
* @param text The List of text to parse
|
||||||
|
* @param colorize If PlaceholderAPI should also parse color codes
|
||||||
|
* @return String with the parsed placeholders
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public static List<String> setBracketPlaceholders(OfflinePlayer player, List<String> text,
|
||||||
|
boolean colorize) {
|
||||||
|
return setBracketPlaceholders(player, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
|
||||||
|
*
|
||||||
|
* @param player The offline player to parse the placeholders against
|
||||||
|
* @param text The text to parse
|
||||||
|
* @param colorize If PlaceholderAPI should also parse color codes
|
||||||
|
* @return String with the parsed placeholders
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public static String setBracketPlaceholders(OfflinePlayer player, String text, boolean colorize) {
|
||||||
|
return setBracketPlaceholders(player, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Will be removed in a future release.
|
||||||
|
*
|
||||||
|
* @param player The offline player to parse the placeholders against
|
||||||
|
* @param text The text to parse
|
||||||
|
* @param colorize If PlaceholderAPI should also parse color codes
|
||||||
|
* @return String with the parsed placeholders
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public static String setBracketPlaceholders(Player player, String text, boolean colorize) {
|
||||||
|
return setBracketPlaceholders(player, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Will be removed in a future release.
|
||||||
|
*
|
||||||
|
* @param player The offline player to parse the placeholders against
|
||||||
|
* @param text The List of text to parse
|
||||||
|
* @param colorize If PlaceholderAPI should also parse color codes
|
||||||
|
* @return String with the parsed placeholders
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public static List<String> setBracketPlaceholders(Player player, List<String> text,
|
||||||
|
boolean colorize) {
|
||||||
|
return setBracketPlaceholders(player, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set relational placeholders in the text specified placeholders are matched with the pattern
|
||||||
|
* {@literal %<rel_(identifier)_(params)>%} when set with this method
|
||||||
|
*
|
||||||
|
* @param one Player to compare
|
||||||
|
* @param two Player to compare
|
||||||
|
* @param text Text to parse the placeholders in
|
||||||
|
* @param colorize If color codes ({@literal &[0-1a-fk-o]}) should be translated
|
||||||
|
* @return The text containing the parsed relational placeholders
|
||||||
|
* @deprecated Use {@link #setPlaceholders(OfflinePlayer, String)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public static String setRelationalPlaceholders(Player one, Player two, String text,
|
||||||
|
boolean colorize) {
|
||||||
|
return setRelationalPlaceholders(one, two, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Translate placeholders in the provided list based on the relation of the two provided players.
|
||||||
|
* <br>The pattern of a valid placeholder is {@literal %rel_<identifier>_<params>%}.
|
||||||
|
*
|
||||||
|
* @param one First player to compare
|
||||||
|
* @param two Second player to compare
|
||||||
|
* @param text Text to parse the placeholders in
|
||||||
|
* @param colorize If color codes ({@literal &[0-1a-fk-o]}) should be translated
|
||||||
|
* @return The text containing the parsed relational placeholders
|
||||||
|
* @deprecated Use {@link #setRelationalPlaceholders(Player, Player, List)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public static List<String> setRelationalPlaceholders(Player one, Player two, List<String> text,
|
||||||
|
boolean colorize) {
|
||||||
|
return setRelationalPlaceholders(one, two, text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import me.clip.placeholderapi.expansion.manager.LocalExpansionManager;
|
|||||||
import me.clip.placeholderapi.listeners.ServerLoadEventListener;
|
import me.clip.placeholderapi.listeners.ServerLoadEventListener;
|
||||||
import me.clip.placeholderapi.updatechecker.UpdateChecker;
|
import me.clip.placeholderapi.updatechecker.UpdateChecker;
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
import net.kyori.adventure.text.serializer.craftbukkit.MinecraftComponentSerializer;
|
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bstats.charts.AdvancedPie;
|
import org.bstats.charts.AdvancedPie;
|
||||||
import org.bstats.charts.SimplePie;
|
import org.bstats.charts.SimplePie;
|
||||||
@@ -249,7 +248,7 @@ public final class PlaceholderAPIPlugin extends JavaPlugin {
|
|||||||
try {
|
try {
|
||||||
Class.forName("org.bukkit.event.server.ServerLoadEvent");
|
Class.forName("org.bukkit.event.server.ServerLoadEvent");
|
||||||
new ServerLoadEventListener(this);
|
new ServerLoadEventListener(this);
|
||||||
} catch (final ExceptionInInitializerError | ClassNotFoundException ignored) {
|
} catch (final ClassNotFoundException ignored) {
|
||||||
Bukkit.getScheduler()
|
Bukkit.getScheduler()
|
||||||
.runTaskLater(this, () -> getLocalExpansionManager().load(Bukkit.getConsoleSender()), 1);
|
.runTaskLater(this, () -> getLocalExpansionManager().load(Bukkit.getConsoleSender()), 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public abstract class PlaceholderHook {
|
public abstract class PlaceholderHook {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public String onRequest(final OfflinePlayer player, @NotNull final String params) {
|
public String onRequest(final OfflinePlayer player, @NotNull final String params) {
|
||||||
if (player != null && player.isOnline()) {
|
if (player != null && player.isOnline()) {
|
||||||
|
|||||||
@@ -27,11 +27,8 @@ import org.bukkit.event.HandlerList;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event indicates that a <b>single</b> {@link PlaceholderExpansion PlaceholderExpansion} has
|
* Indicates that a {@link PlaceholderExpansion} has been registered by
|
||||||
* been registered in PlaceholderAPI.
|
* PlaceholderAPI.
|
||||||
*
|
|
||||||
* <p>To know when <b>all</b> Expansions have been registered, use the
|
|
||||||
* {@link me.clip.placeholderapi.events.ExpansionsLoadedEvent ExpansionsLoadedEvent} instead.
|
|
||||||
*/
|
*/
|
||||||
public final class ExpansionRegisterEvent extends Event implements Cancellable {
|
public final class ExpansionRegisterEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
@@ -51,25 +48,15 @@ public final class ExpansionRegisterEvent extends Event implements Cancellable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link PlaceholderExpansion PlaceholderExpansion} that was registered in PlaceholderAPI.
|
* The {@link PlaceholderExpansion expansion} that was registered.
|
||||||
* <br>The PlaceholderExpansion will be available for use when the event
|
|
||||||
* {@link #isCancelled() was not cancelled}!
|
|
||||||
*
|
*
|
||||||
* @return Current instance of the registered {@link PlaceholderExpansion PlaceholderExpansion}
|
* @return The {@link PlaceholderExpansion} instance.
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public PlaceholderExpansion getExpansion() {
|
public PlaceholderExpansion getExpansion() {
|
||||||
return expansion;
|
return expansion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates if this event was cancelled or not.
|
|
||||||
* <br>A cancelled Event will result in the {@link #getExpansion() PlaceholderExpansion} NOT
|
|
||||||
* being added to PlaceholderAPI's internal list and will therefore be considered not registered
|
|
||||||
* anymore.
|
|
||||||
*
|
|
||||||
* @return Whether the event has been cancelled or not.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancelled;
|
return cancelled;
|
||||||
|
|||||||
@@ -26,19 +26,15 @@ import org.bukkit.event.HandlerList;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event indicates that a {@link PlaceholderExpansion PlaceholderExpansion} has been
|
* Indicates that a {@link PlaceholderExpansion} had been unregistered by
|
||||||
* unregistered by PlaceholderAPI.
|
* PlaceholderAPI.
|
||||||
*
|
|
||||||
* <p>Note that this event is triggered <b>before</b> the PlaceholderExpansion is completely
|
|
||||||
* removed.
|
|
||||||
* <br>This includes removing any Listeners, stopping active tasks and clearing the cache of
|
|
||||||
* the PlaceholderExpansion.
|
|
||||||
*/
|
*/
|
||||||
public final class ExpansionUnregisterEvent extends Event {
|
public final class ExpansionUnregisterEvent extends Event {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static final HandlerList HANDLERS = new HandlerList();
|
private static final HandlerList HANDLERS = new HandlerList();
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final PlaceholderExpansion expansion;
|
private final PlaceholderExpansion expansion;
|
||||||
|
|
||||||
@@ -52,9 +48,9 @@ public final class ExpansionUnregisterEvent extends Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link PlaceholderExpansion PlaceholderExpansion} that was unregistered.
|
* The {@link PlaceholderExpansion expansion} that was unregistered.
|
||||||
*
|
*
|
||||||
* @return The {@link PlaceholderExpansion PlaceholderExpansion} instance.
|
* @return The {@link PlaceholderExpansion} instance.
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public PlaceholderExpansion getExpansion() {
|
public PlaceholderExpansion getExpansion() {
|
||||||
|
|||||||
@@ -21,42 +21,18 @@
|
|||||||
package me.clip.placeholderapi.events;
|
package me.clip.placeholderapi.events;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event indicated that <b>all</b> {@link PlaceholderExpansion PlaceholderExpansions} have
|
* Indicates that <b>all</b> {@link me.clip.placeholderapi.expansion.PlaceholderExpansion PlayceholderExpansions}
|
||||||
* been registered in PlaceholderAPI and can now be used.
|
* have been loaded.
|
||||||
* <br>This even will also be triggered whenever PlaceholderAPI gets reloaded.
|
* <br/>This event is fired on Server load and when reloading the
|
||||||
*
|
* confiuration.
|
||||||
* <p>All PlaceholderExpansions, except for those loaded by plugins, are loaded
|
|
||||||
* after Spigot triggered its ServerLoadEvent (1.13+), or after PlaceholderAPI has been enabled.
|
|
||||||
*/
|
*/
|
||||||
public class ExpansionsLoadedEvent extends Event {
|
public class ExpansionsLoadedEvent extends Event {
|
||||||
|
|
||||||
private final List<PlaceholderExpansion> expansions;
|
|
||||||
|
|
||||||
public ExpansionsLoadedEvent(List<PlaceholderExpansion> expansions) {
|
|
||||||
this.expansions = Collections.unmodifiableList(expansions);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a unmodifiable list of {@link PlaceholderExpansion PlaceholderExpansions} that
|
|
||||||
* have been registered by PlaceholderAPI.
|
|
||||||
*
|
|
||||||
* <p><b>This list does not include manually registered PlaceholderExpansions.</b>
|
|
||||||
*
|
|
||||||
* @return List of {@link PlaceholderExpansion registered PlaceholderExpansions}.
|
|
||||||
*/
|
|
||||||
@NotNull
|
|
||||||
public final List<PlaceholderExpansion> getExpansions(){
|
|
||||||
return expansions;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static final HandlerList HANDLERS = new HandlerList();
|
private static final HandlerList HANDLERS = new HandlerList();
|
||||||
|
|
||||||
|
|||||||
@@ -21,11 +21,9 @@
|
|||||||
package me.clip.placeholderapi.expansion;
|
package me.clip.placeholderapi.expansion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classes implementing this interface will have a {@link #clear() clear void} that is called
|
* This interface allows a class which extends a {@link PlaceholderExpansion} to have the clear
|
||||||
* by PlaceholderAPI whenever the {@link me.clip.placeholderapi.expansion.PlaceholderExpansion PlaceholderExpansion}
|
* method called when the implementing expansion is unregistered from PlaceholderAPI. This is useful
|
||||||
* is unregistered.
|
* if we want to do things when the implementing hook is unregistered
|
||||||
*
|
|
||||||
* <p>This allows you to execute things such as clearing internal caches, saving data to files, etc.
|
|
||||||
*
|
*
|
||||||
* @author Ryan McCarthy
|
* @author Ryan McCarthy
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -23,11 +23,9 @@ package me.clip.placeholderapi.expansion;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classes implementing this interface will have a {@link #cleanup(Player) cleanup void} that is
|
* This interface allows a class which extends a {@link PlaceholderExpansion} to have the cleanup
|
||||||
* called by PlaceholderAPI whenever a Player leaves the server.
|
* method called every time a player leaves the server. This is useful if we want to clean up after
|
||||||
*
|
* the player
|
||||||
* <p>This can be useful for cases where you keep data of the player in a cache or similar
|
|
||||||
* and want to free up space whenever they leave.
|
|
||||||
*
|
*
|
||||||
* @author Ryan McCarthy
|
* @author Ryan McCarthy
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -23,32 +23,18 @@ package me.clip.placeholderapi.expansion;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementing this interface allows {@link me.clip.placeholderapi.expansion.PlaceholderExpansion PlaceholderExpansions}
|
* Any {@link PlaceholderExpansion} class which implements configurable will have any options listed
|
||||||
* to set a list of default configuration values through the {@link #getDefaults() getDefaults method}
|
* in the {@link #getDefaults()} map automatically added to the PlaceholderAPI config.yml file
|
||||||
* that should be added to the config.yml of PlaceholderAPI.
|
|
||||||
*
|
|
||||||
* <p>The entries will be added under {@code expansions} as their own section.
|
|
||||||
* <h2>Example:</h2>
|
|
||||||
* returning a Map with key {@code foo} and value {@code bar} will result in the following config entry:
|
|
||||||
*
|
|
||||||
* <pre><code>
|
|
||||||
* expansions:
|
|
||||||
* myexpansion:
|
|
||||||
* foo: "bar"
|
|
||||||
* </code></pre>
|
|
||||||
*
|
|
||||||
* <p><b>The configuration is set before the PlaceholderExpansion is registered!</b>
|
|
||||||
*
|
*
|
||||||
* @author Ryan McCarthy
|
* @author Ryan McCarthy
|
||||||
*/
|
*/
|
||||||
public interface Configurable {
|
public interface Configurable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The map returned by this method will be used to set config options in PlaceholderAPI's config.yml.
|
* This method will be called before the implementing class is registered to obtain a map of
|
||||||
*
|
* configuration options that the implementing class needs These paths and values will be added to
|
||||||
* <p>The key and value pairs are set under a section named after your
|
* the PlaceholderAPI config.yml in the configuration section expansions.(placeholder
|
||||||
* {@link me.clip.placeholderapi.expansion.PlaceholderExpansion PlaceholderExpansion} in the
|
* identifier).(your key): (your value)
|
||||||
* {@code expansions} section of the config.
|
|
||||||
*
|
*
|
||||||
* @return Map of config path / values which need to be added / removed from the PlaceholderAPI
|
* @return Map of config path / values which need to be added / removed from the PlaceholderAPI
|
||||||
* config.yml file
|
* config.yml file
|
||||||
|
|||||||
@@ -42,8 +42,7 @@ public enum NMSVersion {
|
|||||||
SPIGOT_1_16_R1("v1_16_R1"),
|
SPIGOT_1_16_R1("v1_16_R1"),
|
||||||
SPIGOT_1_16_R2("v1_16_R2"),
|
SPIGOT_1_16_R2("v1_16_R2"),
|
||||||
SPIGOT_1_16_R3("v1_16_R3"),
|
SPIGOT_1_16_R3("v1_16_R3"),
|
||||||
SPIGOT_1_17_R1("v1_17_R1"),
|
SPIGOT_1_17_R1("v1_17_R1");
|
||||||
SPIGOT_1_18_R1("v1_18_R1");
|
|
||||||
|
|
||||||
private final String version;
|
private final String version;
|
||||||
|
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ package me.clip.placeholderapi.expansion;
|
|||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.PlaceholderHook;
|
import me.clip.placeholderapi.PlaceholderHook;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -81,7 +81,7 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
|
|||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getRequiredPlugin() {
|
public String getRequiredPlugin() {
|
||||||
return null;
|
return getPlugin();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -292,71 +292,6 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
|
|||||||
final ConfigurationSection section = getConfigSection();
|
final ConfigurationSection section = getConfigSection();
|
||||||
return section != null && section.contains(path);
|
return section != null && section.contains(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs the provided message with the provided Level in the console.
|
|
||||||
* <br>The message will be prefixed with {@link #getName() <code>[<expansion name>]</code>}
|
|
||||||
*
|
|
||||||
* @param level The Level at which the message should be logged with
|
|
||||||
* @param msg The message to log
|
|
||||||
*/
|
|
||||||
public void log(Level level, String msg) {
|
|
||||||
getPlaceholderAPI().getLogger().log(level, "[" + getName() + "] " + msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs the provided message and Throwable with the provided Level in the console.
|
|
||||||
* <br>The message will be prefixed with {@link #getName() <code>[<expansion name>]</code>}
|
|
||||||
*
|
|
||||||
* @param level The Level at which the message should be logged with
|
|
||||||
* @param msg The message to log
|
|
||||||
* @param throwable The Throwable to log
|
|
||||||
*/
|
|
||||||
public void log(Level level, String msg, Throwable throwable) {
|
|
||||||
getPlaceholderAPI().getLogger().log(level, "[" + getName() + "] " + msg, throwable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs the provided message with Level "info".
|
|
||||||
* <br>The message will be prefixed with {@link #getName() <code>[<expansion name>]</code>}
|
|
||||||
*
|
|
||||||
* @param msg The message to log
|
|
||||||
*/
|
|
||||||
public void info(String msg) {
|
|
||||||
log(Level.INFO, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs the provided message with Level "warning".
|
|
||||||
* <br>The message will be prefixed with {@link #getName() <code>[<expansion name>]</code>}
|
|
||||||
*
|
|
||||||
* @param msg The message to log
|
|
||||||
*/
|
|
||||||
public void warning(String msg) {
|
|
||||||
log(Level.WARNING, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs the provided message with Level "severe" (error).
|
|
||||||
* <br>The message will be prefixed with {@link #getName() <code>[<expansion name>]</code>}
|
|
||||||
*
|
|
||||||
* @param msg The message to log
|
|
||||||
*/
|
|
||||||
public void severe(String msg) {
|
|
||||||
log(Level.SEVERE, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs the provided message and Throwable with Level "severe" (error).
|
|
||||||
* <br>The message will be prefixed with {@link #getName() <code>[<expansion name>]</code>}
|
|
||||||
*
|
|
||||||
* @param msg The message to log
|
|
||||||
* @param throwable The Throwable to log
|
|
||||||
*/
|
|
||||||
public void severe(String msg, Throwable throwable) {
|
|
||||||
log(Level.SEVERE, msg, throwable);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the provided Object is an instance of this PlaceholderExpansion.
|
* Whether the provided Object is an instance of this PlaceholderExpansion.
|
||||||
@@ -396,4 +331,39 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
|
|||||||
return String.format("PlaceholderExpansion[name: '%s', author: '%s', version: '%s']", getName(),
|
return String.format("PlaceholderExpansion[name: '%s', author: '%s', version: '%s']", getName(),
|
||||||
getAuthor(), getVersion());
|
getAuthor(), getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// === Deprecated API ===
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated As of versions greater than 2.8.7, use {@link #getRequiredPlugin()}
|
||||||
|
*
|
||||||
|
* @return The plugin name.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public String getPlugin() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated As of versions greater than 2.8.7, use the expansion cloud to show a description
|
||||||
|
*
|
||||||
|
* @return The description of the expansion.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public String getDescription() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated As of versions greater than 2.8.7, use the expansion cloud to display a link
|
||||||
|
*
|
||||||
|
* @return The link for the expansion.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@ApiStatus.ScheduledForRemoval(inVersion = "2.11.0")
|
||||||
|
public String getLink() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,22 +22,7 @@ package me.clip.placeholderapi.expansion;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementing this interface allows your {@link me.clip.placeholderapi.expansion.PlaceholderExpansion PlaceholderExpansion}
|
|
||||||
* to be used as a relational placeholder expansion.
|
|
||||||
*
|
|
||||||
* <p>Relational placeholders take two Players as input and are always prefixed with {@code rel_},
|
|
||||||
* so {@code %foo_bar%} becomes {@code %rel_foo_bar%}
|
|
||||||
*/
|
|
||||||
public interface Relational {
|
public interface Relational {
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is called whenever a placeholder starting with {@code rel_} is called.
|
|
||||||
*
|
|
||||||
* @param one The first player used for the placeholder.
|
|
||||||
* @param two The second player used for the placeholder.
|
|
||||||
* @param identifier The text right after the expansion's name (%expansion_<b>identifier</b>%)
|
|
||||||
* @return Parsed String from the expansion.
|
|
||||||
*/
|
|
||||||
String onPlaceholderRequest(Player one, Player two, String identifier);
|
String onPlaceholderRequest(Player one, Player two, String identifier);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,24 +20,18 @@
|
|||||||
|
|
||||||
package me.clip.placeholderapi.expansion;
|
package me.clip.placeholderapi.expansion;
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementing this interface adds the {@link #start() start} and {@link #stop() stop} void
|
|
||||||
* methods to your {@link me.clip.placeholderapi.expansion.PlaceholderExpansion PlaceholderExpansion}.
|
|
||||||
*
|
|
||||||
* <p>This can be used to execute methods and tasks whenever the PlaceholderExpansion has been
|
|
||||||
* successfully (un)registered.
|
|
||||||
*/
|
|
||||||
public interface Taskable {
|
public interface Taskable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the implementing class has successfully been registered to the placeholder map.
|
* Called when the implementing class has successfully been registered to the placeholder map
|
||||||
* <br>Tasks that need to be performed when this expansion is registered should go here
|
* Tasks that need to be performed when this expansion is registered should go here
|
||||||
*/
|
*/
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the implementing class has been unregistered from PlaceholderAPI.
|
* Called when the implementing class has been unregistered from PlaceholderAPI Tasks that need to
|
||||||
* <br>Tasks that need to be performed when this expansion has unregistered should go here
|
* be performed when this expansion has unregistered should go here
|
||||||
*/
|
*/
|
||||||
void stop();
|
void stop();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ public class CloudExpansion {
|
|||||||
this.versions = versions;
|
this.versions = versions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Version {
|
public static class Version {
|
||||||
|
|
||||||
private String url, version, release_notes;
|
private String url, version, release_notes;
|
||||||
|
|
||||||
|
|||||||
@@ -160,11 +160,7 @@ public final class LocalExpansionManager implements Listener {
|
|||||||
@NotNull final Class<? extends PlaceholderExpansion> clazz) {
|
@NotNull final Class<? extends PlaceholderExpansion> clazz) {
|
||||||
try {
|
try {
|
||||||
final PlaceholderExpansion expansion = createExpansionInstance(clazz);
|
final PlaceholderExpansion expansion = createExpansionInstance(clazz);
|
||||||
|
|
||||||
if(expansion == null){
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
Objects.requireNonNull(expansion.getAuthor(), "The expansion author is null!");
|
Objects.requireNonNull(expansion.getAuthor(), "The expansion author is null!");
|
||||||
Objects.requireNonNull(expansion.getIdentifier(), "The expansion identifier is null!");
|
Objects.requireNonNull(expansion.getIdentifier(), "The expansion identifier is null!");
|
||||||
Objects.requireNonNull(expansion.getVersion(), "The expansion version is null!");
|
Objects.requireNonNull(expansion.getVersion(), "The expansion version is null!");
|
||||||
@@ -263,8 +259,7 @@ public final class LocalExpansionManager implements Listener {
|
|||||||
Bukkit.getPluginManager().registerEvents(((Listener) expansion), plugin);
|
Bukkit.getPluginManager().registerEvents(((Listener) expansion), plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.getLogger().info("Successfully registered expansion: " + expansion.getIdentifier() +
|
plugin.getLogger().info("Successfully registered expansion: " + expansion.getIdentifier());
|
||||||
" [" + expansion.getVersion() + "]");
|
|
||||||
|
|
||||||
if (expansion instanceof Taskable) {
|
if (expansion instanceof Taskable) {
|
||||||
((Taskable) expansion).start();
|
((Taskable) expansion).start();
|
||||||
@@ -324,37 +319,18 @@ public final class LocalExpansionManager implements Listener {
|
|||||||
plugin.getLogger().log(Level.SEVERE, "failed to load class files of expansions", exception);
|
plugin.getLogger().log(Level.SEVERE, "failed to load class files of expansions", exception);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<PlaceholderExpansion> registered = classes.stream()
|
final long registered = classes.stream()
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.map(this::register)
|
.map(this::register)
|
||||||
.filter(Optional::isPresent)
|
.filter(Optional::isPresent)
|
||||||
.map(Optional::get)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
final long needsUpdate = registered.stream()
|
|
||||||
.map(expansion -> plugin.getCloudExpansionManager().findCloudExpansionByName(expansion.getName()).orElse(null))
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.filter(CloudExpansion::shouldUpdate)
|
|
||||||
.count();
|
.count();
|
||||||
|
|
||||||
StringBuilder message = new StringBuilder(registered.size() == 0 ? "&6" : "&a")
|
Msg.msg(sender,
|
||||||
.append(registered.size())
|
registered == 0 ? "&6No expansions were registered!"
|
||||||
.append(' ')
|
: registered + "&a placeholder hooks successfully registered!");
|
||||||
.append("placeholder hook(s) registered!");
|
|
||||||
|
|
||||||
if (needsUpdate > 0) {
|
|
||||||
message.append(' ')
|
|
||||||
.append("&6")
|
|
||||||
.append(needsUpdate)
|
|
||||||
.append(' ')
|
|
||||||
.append("placeholder hook(s) have an update available.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Msg.msg(sender, message.toString());
|
|
||||||
|
|
||||||
Bukkit.getPluginManager().callEvent(new ExpansionsLoadedEvent(registered));
|
Bukkit.getPluginManager().callEvent(new ExpansionsLoadedEvent());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,12 +346,7 @@ public final class LocalExpansionManager implements Listener {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public CompletableFuture<@NotNull List<@Nullable Class<? extends PlaceholderExpansion>>> findExpansionsOnDisk() {
|
public CompletableFuture<@NotNull List<@Nullable Class<? extends PlaceholderExpansion>>> findExpansionsOnDisk() {
|
||||||
File[] files = folder.listFiles((dir, name) -> name.endsWith(".jar"));
|
return Arrays.stream(folder.listFiles((dir, name) -> name.endsWith(".jar")))
|
||||||
if(files == null){
|
|
||||||
return CompletableFuture.completedFuture(Collections.emptyList());
|
|
||||||
}
|
|
||||||
|
|
||||||
return Arrays.stream(files)
|
|
||||||
.map(this::findExpansionInFile)
|
.map(this::findExpansionInFile)
|
||||||
.collect(Futures.collector());
|
.collect(Futures.collector());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,16 +39,6 @@ public final class ServerLoadEventListener implements Listener {
|
|||||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method will be called when the server is first loaded
|
|
||||||
* <p>
|
|
||||||
* The goal of the method is to register all the expansions as soon as possible especially before
|
|
||||||
* players can join
|
|
||||||
* <p>
|
|
||||||
* This will ensure no issues with expansions and hooks.
|
|
||||||
*
|
|
||||||
* @param event the server load event
|
|
||||||
*/
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onServerLoad(@NotNull final ServerLoadEvent event) {
|
public void onServerLoad(@NotNull final ServerLoadEvent event) {
|
||||||
HandlerList.unregisterAll(this);
|
HandlerList.unregisterAll(this);
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ public final class CharsReplacer implements Replacer {
|
|||||||
parameters.setLength(0);
|
parameters.setLength(0);
|
||||||
|
|
||||||
if (oopsitsbad) {
|
if (oopsitsbad) {
|
||||||
builder.append(closure.head).append(identifierString);
|
builder.append(closure.head).append(identifier);
|
||||||
|
|
||||||
if (identified) {
|
if (identified) {
|
||||||
builder.append('_').append(parametersString);
|
builder.append('_').append(parametersString);
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public final class Format {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static String buildFormat(@NotNull final Align align, @NotNull final int[] spacing) {
|
private static String buildFormat(@NotNull final Align align, final int[] spacing) {
|
||||||
return stream(spacing)
|
return stream(spacing)
|
||||||
.mapToObj(space -> "%" + (align == Align.LEFT ? "-" : "") + (space + 2) + "s")
|
.mapToObj(space -> "%" + (align == Align.LEFT ? "-" : "") + (space + 2) + "s")
|
||||||
.collect(joining());
|
.collect(joining());
|
||||||
|
|||||||
Reference in New Issue
Block a user