mirror of
https://github.com/kaboomserver/extras.git
synced 2025-04-22 17:33:36 -04:00
Merge 2b3b036079
into 1c3864e608
This commit is contained in:
commit
e28d0f2a9b
28 changed files with 733 additions and 138 deletions
.github/workflows
.gitignorebuild.gradle.ktscommon
config/checkstyle
folia-platform
gradle/wrapper
gradlewgradlew.batpaper-platform
pom.xmlsettings.gradle.ktssrc/main
16
.github/workflows/main.yml
vendored
16
.github/workflows/main.yml
vendored
|
@ -1,4 +1,4 @@
|
|||
name: Maven CI
|
||||
name: Gradle CI
|
||||
|
||||
on:
|
||||
push:
|
||||
|
@ -17,17 +17,13 @@ jobs:
|
|||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
|
||||
- name: Cache maven packages to speed up build
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.m2
|
||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: ${{ runner.os }}-m2
|
||||
- name: Setup Gradle
|
||||
uses: gradle/gradle-build-action@v2
|
||||
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew --no-daemon build
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Extras
|
||||
path: target/Extras.jar
|
||||
path: build/libs/Extras-master-all.jar
|
||||
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,7 +1,8 @@
|
|||
.idea/
|
||||
.settings/
|
||||
bin/
|
||||
target/
|
||||
build/
|
||||
.gradle/
|
||||
.checkstyle
|
||||
.classpath
|
||||
.project
|
||||
|
|
44
build.gradle.kts
Normal file
44
build.gradle.kts
Normal file
|
@ -0,0 +1,44 @@
|
|||
plugins {
|
||||
id("java")
|
||||
id("checkstyle")
|
||||
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT")
|
||||
|
||||
implementation(project(":common"))
|
||||
implementation(project(":paper-platform"))
|
||||
implementation(project(":folia-platform"))
|
||||
}
|
||||
|
||||
allprojects {
|
||||
apply(plugin = "java")
|
||||
apply(plugin = "checkstyle")
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
}
|
||||
|
||||
group = "pw.kaboom"
|
||||
version = "master"
|
||||
description = "Extras"
|
||||
java.sourceCompatibility = JavaVersion.VERSION_17
|
||||
|
||||
tasks {
|
||||
assemble {
|
||||
dependsOn(checkstyleMain)
|
||||
}
|
||||
|
||||
compileJava {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
assemble {
|
||||
dependsOn(shadowJar)
|
||||
}
|
||||
}
|
3
common/build.gradle.kts
Normal file
3
common/build.gradle.kts
Normal file
|
@ -0,0 +1,3 @@
|
|||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT")
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package pw.kaboom.extras.platform;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public interface IScheduler {
|
||||
void runRepeating(final Plugin plugin, final Runnable runnable, final long delay,
|
||||
final long period, final TimeUnit unit);
|
||||
void runLater(final Plugin plugin, final Runnable runnable,
|
||||
final long delay, final TimeUnit unit);
|
||||
void runSync(final Plugin plugin, final Runnable runnable);
|
||||
void runAsync(final Plugin plugin, final Runnable runnable);
|
||||
void executeOnChunk(final Plugin plugin, final Chunk chunk, final Runnable runnable);
|
||||
void executeOnGlobalRegion(final Plugin plugin, final Runnable runnable);
|
||||
void executeOnEntity(final Plugin plugin, final Entity entity, final Runnable runnable);
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package pw.kaboom.extras.platform;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class PlatformScheduler {
|
||||
private static IScheduler currentScheduler = null;
|
||||
|
||||
public static void setCurrentScheduler(final IScheduler implementation) {
|
||||
if (currentScheduler != null) {
|
||||
throw new IllegalStateException("Tried to set current scheduler, even though " +
|
||||
" it was already set!");
|
||||
}
|
||||
|
||||
currentScheduler = implementation;
|
||||
}
|
||||
|
||||
public static void runRepeating(final Plugin plugin, final Runnable runnable,
|
||||
final long delay, final long period, final TimeUnit unit) {
|
||||
currentScheduler.runRepeating(plugin, runnable, delay, period, unit);
|
||||
}
|
||||
|
||||
public static void runLater(final Plugin plugin, final Runnable runnable,
|
||||
final long delay, final TimeUnit unit) {
|
||||
currentScheduler.runLater(plugin, runnable, delay, unit);
|
||||
}
|
||||
|
||||
public static void runSync(final Plugin plugin, final Runnable runnable) {
|
||||
currentScheduler.runSync(plugin, runnable);
|
||||
}
|
||||
|
||||
public static void runAsync(final Plugin plugin, final Runnable runnable) {
|
||||
currentScheduler.runAsync(plugin, runnable);
|
||||
}
|
||||
|
||||
public static void executeOnChunk(final Plugin plugin, final Chunk chunk,
|
||||
final Runnable runnable) {
|
||||
currentScheduler.executeOnChunk(plugin, chunk, runnable);
|
||||
}
|
||||
|
||||
public static void executeOnGlobalRegion(final Plugin plugin, final Runnable runnable) {
|
||||
currentScheduler.executeOnGlobalRegion(plugin, runnable);
|
||||
}
|
||||
|
||||
public static void executeOnEntity(final Plugin plugin, final Entity entity,
|
||||
final Runnable runnable) {
|
||||
currentScheduler.executeOnEntity(plugin, entity, runnable);
|
||||
}
|
||||
}
|
5
folia-platform/build.gradle.kts
Normal file
5
folia-platform/build.gradle.kts
Normal file
|
@ -0,0 +1,5 @@
|
|||
dependencies {
|
||||
compileOnly("dev.folia:folia-api:1.19.4-R0.1-SNAPSHOT")
|
||||
|
||||
implementation(project(":common"))
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package pw.kaboom.extras.platform.folia;
|
||||
|
||||
import io.papermc.paper.threadedregions.scheduler.AsyncScheduler;
|
||||
import io.papermc.paper.threadedregions.scheduler.GlobalRegionScheduler;
|
||||
import io.papermc.paper.threadedregions.scheduler.RegionScheduler;
|
||||
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import pw.kaboom.extras.platform.IScheduler;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public final class FoliaScheduler implements IScheduler {
|
||||
private static final AsyncScheduler ASYNC_SCHEDULER = Bukkit.getAsyncScheduler();
|
||||
private static final RegionScheduler REGION_SCHEDULER = Bukkit.getRegionScheduler();
|
||||
private static final GlobalRegionScheduler GLOBAL_REGION_SCHEDULER =
|
||||
Bukkit.getGlobalRegionScheduler();
|
||||
|
||||
@Override
|
||||
public void runRepeating(final Plugin plugin, final Runnable runnable,
|
||||
final long delay, final long period,
|
||||
final TimeUnit unit) {
|
||||
ASYNC_SCHEDULER.runAtFixedRate(plugin, FoliaTask.from(runnable), delay, period, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runLater(final Plugin plugin, final Runnable runnable, final long delay,
|
||||
final TimeUnit unit) {
|
||||
ASYNC_SCHEDULER.runDelayed(plugin, FoliaTask.from(runnable), delay, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runSync(final Plugin plugin, final Runnable runnable) {
|
||||
ASYNC_SCHEDULER.runNow(plugin, FoliaTask.from(runnable));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runAsync(final Plugin plugin, final Runnable runnable) {
|
||||
ASYNC_SCHEDULER.runNow(plugin, FoliaTask.from(runnable));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeOnChunk(final Plugin plugin, final Chunk chunk, final Runnable runnable) {
|
||||
final World world = chunk.getWorld();
|
||||
final int chunkX = chunk.getX();
|
||||
final int chunkZ = chunk.getZ();
|
||||
|
||||
REGION_SCHEDULER.execute(plugin, world, chunkX, chunkZ, runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeOnGlobalRegion(final Plugin plugin, final Runnable runnable) {
|
||||
GLOBAL_REGION_SCHEDULER.execute(plugin, runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeOnEntity(final Plugin plugin, final Entity entity, final Runnable runnable) {
|
||||
entity.getScheduler().run(plugin, FoliaTask.from(runnable), () -> {});
|
||||
}
|
||||
|
||||
private static final class FoliaTask implements Consumer<ScheduledTask> {
|
||||
private final Runnable runnable;
|
||||
|
||||
FoliaTask(final Runnable runnable) {
|
||||
this.runnable = runnable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(final ScheduledTask scheduledTask) {
|
||||
this.runnable.run();
|
||||
}
|
||||
|
||||
public static FoliaTask from(final Runnable runnable) {
|
||||
return new FoliaTask(runnable);
|
||||
}
|
||||
}
|
||||
}
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
244
gradlew
vendored
Executable file
244
gradlew
vendored
Executable file
|
@ -0,0 +1,244 @@
|
|||
#!/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##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# 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"'
|
||||
|
||||
# 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
|
||||
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
|
||||
location of your Java installation."
|
||||
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=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=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
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
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" "$@"
|
92
gradlew.bat
vendored
Normal file
92
gradlew.bat
vendored
Normal file
|
@ -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
|
5
paper-platform/build.gradle.kts
Normal file
5
paper-platform/build.gradle.kts
Normal file
|
@ -0,0 +1,5 @@
|
|||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT")
|
||||
|
||||
implementation(project(":common"))
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package pw.kaboom.extras.platform.paper;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import pw.kaboom.extras.platform.IScheduler;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class PaperScheduler implements IScheduler {
|
||||
private static final BukkitScheduler BUKKIT_SCHEDULER = Bukkit.getScheduler();
|
||||
|
||||
private static long convertIntoTicks(final long time, final TimeUnit unit) {
|
||||
final long millis = unit.toMillis(time);
|
||||
|
||||
return millis / 20L;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runRepeating(final Plugin plugin, final Runnable runnable, final long delay,
|
||||
final long period, final TimeUnit unit) {
|
||||
BUKKIT_SCHEDULER.runTaskTimerAsynchronously(plugin, runnable, convertIntoTicks(delay, unit),
|
||||
convertIntoTicks(period, unit));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runLater(final Plugin plugin, final Runnable runnable,
|
||||
final long delay, TimeUnit unit) {
|
||||
BUKKIT_SCHEDULER.runTaskLaterAsynchronously(plugin, runnable,
|
||||
convertIntoTicks(delay, unit));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runSync(final Plugin plugin, final Runnable runnable) {
|
||||
BUKKIT_SCHEDULER.runTask(plugin, runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runAsync(final Plugin plugin, final Runnable runnable) {
|
||||
BUKKIT_SCHEDULER.runTaskAsynchronously(plugin, runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeOnChunk(final Plugin plugin, final Chunk chunk, final Runnable runnable) {
|
||||
BUKKIT_SCHEDULER.runTask(plugin, runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeOnGlobalRegion(final Plugin plugin, final Runnable runnable) {
|
||||
BUKKIT_SCHEDULER.runTask(plugin, runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeOnEntity(final Plugin plugin, final Entity entity, final Runnable runnable) {
|
||||
BUKKIT_SCHEDULER.runTask(plugin, runnable);
|
||||
}
|
||||
}
|
55
pom.xml
55
pom.xml
|
@ -1,55 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>pw.kaboom</groupId>
|
||||
<artifactId>Extras</artifactId>
|
||||
<version>master</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.19.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>checkstyle</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<configLocation>checkstyle.xml</configLocation>
|
||||
<suppressionsLocation>suppressions.xml</suppressionsLocation>
|
||||
<failOnViolation>true</failOnViolation>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
4
settings.gradle.kts
Normal file
4
settings.gradle.kts
Normal file
|
@ -0,0 +1,4 @@
|
|||
rootProject.name = "Extras"
|
||||
include("paper-platform")
|
||||
include("folia-platform")
|
||||
include("common")
|
|
@ -18,16 +18,40 @@ import pw.kaboom.extras.modules.server.ServerCommand;
|
|||
import pw.kaboom.extras.modules.server.ServerGameRule;
|
||||
import pw.kaboom.extras.modules.server.ServerTabComplete;
|
||||
import pw.kaboom.extras.modules.server.ServerTick;
|
||||
import pw.kaboom.extras.platform.PlatformScheduler;
|
||||
import pw.kaboom.extras.platform.folia.FoliaScheduler;
|
||||
import pw.kaboom.extras.platform.paper.PaperScheduler;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
|
||||
public final class Main extends JavaPlugin {
|
||||
private boolean isFolia;
|
||||
private File prefixConfigFile;
|
||||
private FileConfiguration prefixConfig;
|
||||
|
||||
public boolean isFolia() {
|
||||
return this.isFolia;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
try {
|
||||
Class.forName("io.papermc.paper.threadedregions.RegionizedServer");
|
||||
isFolia = true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
isFolia = false;
|
||||
}
|
||||
|
||||
if (isFolia) {
|
||||
PlatformScheduler.setCurrentScheduler(new FoliaScheduler());
|
||||
} else {
|
||||
PlatformScheduler.setCurrentScheduler(new PaperScheduler());
|
||||
}
|
||||
|
||||
/* Fill lists */
|
||||
Collections.addAll(
|
||||
BlockPhysics.getBlockFaces(),
|
||||
|
@ -64,11 +88,11 @@ public final class Main extends JavaPlugin {
|
|||
this.getCommand("prefix").setExecutor(new CommandPrefix());
|
||||
this.getCommand("pumpkin").setExecutor(new CommandPumpkin());
|
||||
this.getCommand("serverinfo").setExecutor(new CommandServerInfo());
|
||||
this.getCommand("skin").setExecutor(new CommandSkin());
|
||||
this.getCommand("username").setExecutor(new CommandUsername());
|
||||
this.getCommand("spawn").setExecutor(new CommandSpawn());
|
||||
this.getCommand("spidey").setExecutor(new CommandSpidey());
|
||||
this.getCommand("tellraw").setExecutor(new CommandTellraw());
|
||||
this.getCommand("username").setExecutor(new CommandUsername());
|
||||
this.getCommand("skin").setExecutor(new CommandSkin());
|
||||
|
||||
/* Block-related modules */
|
||||
BlockPhysics.init(this);
|
||||
|
@ -99,9 +123,15 @@ public final class Main extends JavaPlugin {
|
|||
this.getServer().getPluginManager().registerEvents(new ServerTick(), this);
|
||||
|
||||
/* Custom worlds */
|
||||
this.getServer().createWorld(
|
||||
new WorldCreator("world_flatlands").generateStructures(false).type(WorldType.FLAT)
|
||||
);
|
||||
// Custom worlds are not implemented on Folia!
|
||||
if(!isFolia) {
|
||||
this.getServer().createWorld(
|
||||
new WorldCreator("world_flatlands")
|
||||
.generateStructures(false)
|
||||
.type(WorldType.FLAT)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public File getPrefixConfigFile() {
|
||||
|
|
|
@ -8,6 +8,9 @@ import org.bukkit.command.CommandExecutor;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import pw.kaboom.extras.Main;
|
||||
import pw.kaboom.extras.platform.PlatformScheduler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
@ -20,16 +23,13 @@ public final class CommandDestroyEntities implements CommandExecutor {
|
|||
int entityCount = 0;
|
||||
int worldCount = 0;
|
||||
|
||||
final Main plugin = JavaPlugin.getPlugin(Main.class);
|
||||
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
for (Entity entity : world.getEntities()) {
|
||||
if (!EntityType.PLAYER.equals(entity.getType())) {
|
||||
try {
|
||||
entity.remove();
|
||||
entityCount++;
|
||||
} catch (Exception ignored) {
|
||||
// Broken entity
|
||||
continue;
|
||||
}
|
||||
PlatformScheduler.executeOnEntity(plugin, entity, entity::remove);
|
||||
entityCount++;
|
||||
}
|
||||
}
|
||||
worldCount++;
|
||||
|
|
|
@ -4,12 +4,13 @@ import net.kyori.adventure.text.Component;
|
|||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import pw.kaboom.extras.Main;
|
||||
import pw.kaboom.extras.platform.PlatformScheduler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
@ -27,22 +28,19 @@ public final class CommandSpawn implements CommandExecutor {
|
|||
final World defaultWorld = Bukkit.getWorld("world");
|
||||
final World world = (defaultWorld == null) ? Bukkit.getWorlds().get(0) : defaultWorld;
|
||||
final Location spawnLocation = world.getSpawnLocation();
|
||||
final int maxWorldHeight = 256;
|
||||
|
||||
for (double y = spawnLocation.getY(); y <= maxWorldHeight; y++) {
|
||||
final Location yLocation = new Location(world, spawnLocation.getX(), y,
|
||||
spawnLocation.getZ());
|
||||
final Block coordBlock = world.getBlockAt(yLocation);
|
||||
world.getChunkAtAsync(spawnLocation).thenAccept(chunk -> {
|
||||
final Main plugin = JavaPlugin.getPlugin(Main.class);
|
||||
final Location highestSpawnLocation = world.getHighestBlockAt(spawnLocation)
|
||||
.getLocation()
|
||||
.add(0, 1, 0);
|
||||
|
||||
if (!coordBlock.getType().isSolid()
|
||||
&& !coordBlock.getRelative(BlockFace.UP).getType().isSolid()) {
|
||||
player.teleportAsync(yLocation);
|
||||
break;
|
||||
}
|
||||
}
|
||||
PlatformScheduler.executeOnEntity(plugin, player, () -> {
|
||||
player.teleportAsync(highestSpawnLocation);
|
||||
player.sendMessage(Component.text("Successfully moved to spawn"));
|
||||
});
|
||||
});
|
||||
|
||||
player.sendMessage(Component
|
||||
.text("Successfully moved to spawn"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import org.bukkit.command.Command;
|
|||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import pw.kaboom.extras.Main;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashMap;
|
||||
|
@ -22,6 +24,14 @@ public final class CommandUsername implements CommandExecutor {
|
|||
final @Nonnull Command command,
|
||||
final @Nonnull String label,
|
||||
final String[] args) {
|
||||
final Main plugin = JavaPlugin.getPlugin(Main.class);
|
||||
|
||||
if (plugin.isFolia()) {
|
||||
sender.sendMessage(Component
|
||||
.text("Command cannot be ran on Folia servers!"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof final Player player)) {
|
||||
sender.sendMessage(Component
|
||||
.text("Command has to be run by a player"));
|
||||
|
|
|
@ -6,6 +6,9 @@ import org.bukkit.event.Listener;
|
|||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import pw.kaboom.extras.Main;
|
||||
import pw.kaboom.extras.platform.PlatformScheduler;
|
||||
|
||||
public final class BlockCheck implements Listener {
|
||||
@EventHandler
|
||||
|
@ -25,8 +28,10 @@ public final class BlockCheck implements Listener {
|
|||
|
||||
@EventHandler
|
||||
void onChunkUnload(final ChunkUnloadEvent event) {
|
||||
final Main plugin = JavaPlugin.getPlugin(Main.class);
|
||||
|
||||
for (Chunk chunk : event.getChunk().getWorld().getForceLoadedChunks()) {
|
||||
chunk.setForceLoaded(false);
|
||||
PlatformScheduler.executeOnGlobalRegion(plugin, () -> chunk.setForceLoaded(false));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,23 +1,19 @@
|
|||
package pw.kaboom.extras.modules.block;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.destroystokyo.paper.event.block.BlockDestroyEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockFadeEvent;
|
||||
import org.bukkit.event.block.BlockFormEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
|
||||
import com.destroystokyo.paper.event.block.BlockDestroyEvent;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import pw.kaboom.extras.Main;
|
||||
import pw.kaboom.extras.platform.PlatformScheduler;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class BlockPhysics implements Listener {
|
||||
|
||||
|
@ -178,8 +174,7 @@ public final class BlockPhysics implements Listener {
|
|||
}
|
||||
|
||||
public static void init(final Main main) {
|
||||
final BukkitScheduler scheduler = Bukkit.getScheduler();
|
||||
|
||||
scheduler.runTaskTimer(main, BlockPhysics::updateTPS, 0L, 1200L); // 1 minute
|
||||
PlatformScheduler.runRepeating(main, BlockPhysics::updateTPS, 0L,
|
||||
1L, TimeUnit.MINUTES);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,10 @@ import java.util.HashSet;
|
|||
import java.util.UUID;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public final class PlayerConnection implements Listener {
|
||||
private static final FileConfiguration CONFIG = JavaPlugin.getPlugin(Main.class).getConfig();
|
||||
private static final String TITLE = CONFIG.getString("playerJoinTitle");
|
||||
|
@ -113,7 +117,6 @@ public final class PlayerConnection implements Listener {
|
|||
|
||||
final Server server = Bukkit.getServer();
|
||||
|
||||
|
||||
if (!server.getOnlineMode()) {
|
||||
SkinManager.applySkin(player, player.getName(), false);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,10 @@ import org.bukkit.event.entity.EntityRegainHealthEvent;
|
|||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import pw.kaboom.extras.Main;
|
||||
import pw.kaboom.extras.platform.PlatformScheduler;
|
||||
|
||||
public final class PlayerDamage implements Listener {
|
||||
@EventHandler
|
||||
|
@ -73,11 +76,14 @@ public final class PlayerDamage implements Listener {
|
|||
player.setMaxHealth(20);
|
||||
player.setHealth(20);
|
||||
|
||||
final Main plugin = JavaPlugin.getPlugin(Main.class);
|
||||
|
||||
if (player.getBedSpawnLocation() != null) {
|
||||
player.teleportAsync(player.getBedSpawnLocation());
|
||||
} else {
|
||||
final World world = Bukkit.getWorld("world");
|
||||
player.teleportAsync(world.getSpawnLocation());
|
||||
PlatformScheduler.executeOnGlobalRegion(plugin, () -> player
|
||||
.teleportAsync(world.getSpawnLocation()));
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
player.setMaxHealth(Double.POSITIVE_INFINITY);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package pw.kaboom.extras.modules.player;
|
||||
|
||||
import com.destroystokyo.paper.event.server.ServerTickEndEvent;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -12,7 +13,6 @@ import org.bukkit.event.Listener;
|
|||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import pw.kaboom.extras.Main;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -42,13 +42,6 @@ public final class PlayerPrefix implements Listener {
|
|||
|
||||
OP_TAG = LegacyComponentSerializer.legacySection().deserialize(legacyOpTag);
|
||||
DE_OP_TAG = LegacyComponentSerializer.legacySection().deserialize(legacyDeOpTag);
|
||||
|
||||
final BukkitScheduler scheduler = Bukkit.getScheduler();
|
||||
|
||||
scheduler.runTaskTimerAsynchronously(PLUGIN, PlayerPrefix::checkOpStatus,
|
||||
0L, 1L);
|
||||
scheduler.runTaskTimerAsynchronously(PLUGIN, PlayerPrefix::checkDisplayNames,
|
||||
0L, 1L);
|
||||
}
|
||||
|
||||
public static void removePrefix(Player player) throws IOException {
|
||||
|
@ -110,6 +103,12 @@ public final class PlayerPrefix implements Listener {
|
|||
onUpdate(player);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onTickEnd(final ServerTickEndEvent event) {
|
||||
checkOpStatus();
|
||||
checkDisplayNames();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerQuitEvent(PlayerQuitEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
package pw.kaboom.extras.skin;
|
||||
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import com.destroystokyo.paper.profile.ProfileProperty;
|
||||
import com.google.gson.Gson;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import pw.kaboom.extras.Main;
|
||||
import pw.kaboom.extras.platform.PlatformScheduler;
|
||||
import pw.kaboom.extras.skin.response.ProfileResponse;
|
||||
import pw.kaboom.extras.skin.response.SkinResponse;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
|
@ -8,25 +18,10 @@ import java.net.http.HttpResponse;
|
|||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import com.destroystokyo.paper.profile.ProfileProperty;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import pw.kaboom.extras.Main;
|
||||
import pw.kaboom.extras.skin.response.ProfileResponse;
|
||||
import pw.kaboom.extras.skin.response.SkinResponse;
|
||||
|
||||
public final class SkinManager {
|
||||
private static final HttpClient httpClient = HttpClient.newHttpClient();
|
||||
private static final Gson GSON = new Gson();
|
||||
|
@ -38,10 +33,9 @@ public final class SkinManager {
|
|||
final PlayerProfile playerProfile = player.getPlayerProfile();
|
||||
playerProfile.removeProperty("textures");
|
||||
|
||||
final BukkitScheduler bukkitScheduler = Bukkit.getScheduler();
|
||||
final Main plugin = JavaPlugin.getPlugin(Main.class);
|
||||
|
||||
bukkitScheduler.runTask(plugin, () -> player.setPlayerProfile(playerProfile));
|
||||
PlatformScheduler.executeOnEntity(plugin, player,
|
||||
() -> player.setPlayerProfile(playerProfile));
|
||||
|
||||
if(!shouldSendMessage) {
|
||||
return;
|
||||
|
@ -72,10 +66,8 @@ public final class SkinManager {
|
|||
final String signature = skinData.signature();
|
||||
profile.setProperty(new ProfileProperty("textures", texture, signature));
|
||||
|
||||
final BukkitScheduler bukkitScheduler = Bukkit.getScheduler();
|
||||
final Main plugin = JavaPlugin.getPlugin(Main.class);
|
||||
|
||||
bukkitScheduler.runTask(plugin,
|
||||
PlatformScheduler.executeOnEntity(plugin, player,
|
||||
() -> player.setPlayerProfile(profile));
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ main: pw.kaboom.extras.Main
|
|||
description: Plugin that adds extra functionality to the server.
|
||||
api-version: 1.13
|
||||
version: master
|
||||
folia-supported: true
|
||||
|
||||
commands:
|
||||
broadcastminimessage:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue