Sacred realms
This commit is contained in:
commit
aa1c13c74c
28 changed files with 1651 additions and 0 deletions
118
.gitignore
vendored
Normal file
118
.gitignore
vendored
Normal file
|
@ -0,0 +1,118 @@
|
||||||
|
# User-specific stuff
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Compiled class file
|
||||||
|
*.class
|
||||||
|
|
||||||
|
# Log file
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# BlueJ files
|
||||||
|
*.ctxt
|
||||||
|
|
||||||
|
# Package Files #
|
||||||
|
*.jar
|
||||||
|
*.war
|
||||||
|
*.nar
|
||||||
|
*.ear
|
||||||
|
*.zip
|
||||||
|
*.tar.gz
|
||||||
|
*.rar
|
||||||
|
|
||||||
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
|
hs_err_pid*
|
||||||
|
|
||||||
|
*~
|
||||||
|
|
||||||
|
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||||
|
.fuse_hidden*
|
||||||
|
|
||||||
|
# KDE directory preferences
|
||||||
|
.directory
|
||||||
|
|
||||||
|
# Linux trash folder which might appear on any partition or disk
|
||||||
|
.Trash-*
|
||||||
|
|
||||||
|
# .nfs files are created when an open file is removed but is still being accessed
|
||||||
|
.nfs*
|
||||||
|
|
||||||
|
# General
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Icon must end with two \r
|
||||||
|
Icon
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear in the root of a volume
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
.com.apple.timemachine.donotpresent
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
||||||
|
|
||||||
|
# Windows thumbnail cache files
|
||||||
|
Thumbs.db
|
||||||
|
Thumbs.db:encryptable
|
||||||
|
ehthumbs.db
|
||||||
|
ehthumbs_vista.db
|
||||||
|
|
||||||
|
# Dump file
|
||||||
|
*.stackdump
|
||||||
|
|
||||||
|
# Folder config file
|
||||||
|
[Dd]esktop.ini
|
||||||
|
|
||||||
|
# Recycle Bin used on file shares
|
||||||
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
|
# Windows Installer files
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# Windows shortcuts
|
||||||
|
*.lnk
|
||||||
|
|
||||||
|
.gradle
|
||||||
|
build/
|
||||||
|
|
||||||
|
# Ignore Gradle GUI config
|
||||||
|
gradle-app.setting
|
||||||
|
|
||||||
|
# Cache of project
|
||||||
|
.gradletasknamecache
|
||||||
|
|
||||||
|
**/build/
|
||||||
|
|
||||||
|
# Common working directory
|
||||||
|
run/
|
||||||
|
|
||||||
|
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||||
|
!gradle-wrapper.jar
|
63
build.gradle.kts
Normal file
63
build.gradle.kts
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
plugins {
|
||||||
|
`java-library`
|
||||||
|
id("io.papermc.paperweight.userdev") version "1.5.11"
|
||||||
|
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
group = "me.unurled.sacredrealms"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "The main SR plugin."
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
paperweight.paperDevBundle("1.20.4-R0.1-SNAPSHOT")
|
||||||
|
|
||||||
|
implementation("redis.clients:jedis:5.1.0")
|
||||||
|
|
||||||
|
testCompileOnly("com.github.seeseemelk:MockBukkit-v1.20:3.74.0")
|
||||||
|
testCompileOnly("org.junit.jupiter:junit-jupiter-api:5.10.1")
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
assemble {
|
||||||
|
dependsOn(reobfJar)
|
||||||
|
}
|
||||||
|
|
||||||
|
compileJava {
|
||||||
|
options.encoding = Charsets.UTF_8.name()
|
||||||
|
|
||||||
|
options.release.set(17)
|
||||||
|
}
|
||||||
|
javadoc {
|
||||||
|
options.encoding = Charsets.UTF_8.name()
|
||||||
|
}
|
||||||
|
processResources {
|
||||||
|
filteringCharset = Charsets.UTF_8.name()
|
||||||
|
val props = mapOf(
|
||||||
|
"name" to project.name,
|
||||||
|
"version" to project.version,
|
||||||
|
"description" to project.description,
|
||||||
|
"apiVersion" to "1.20"
|
||||||
|
)
|
||||||
|
inputs.properties(props)
|
||||||
|
filesMatching("paper-plugin.yml") {
|
||||||
|
expand(props)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
shadowJar {
|
||||||
|
archiveClassifier.set("")
|
||||||
|
relocate("com.google", "libs.com.google")
|
||||||
|
relocate("org.apache", "libs.org.apache")
|
||||||
|
relocate("org.json", "libs.org.json")
|
||||||
|
exclude("org.slf4j")
|
||||||
|
relocate("redis", "libs.redis")
|
||||||
|
minimize()
|
||||||
|
}
|
||||||
|
}
|
0
gradle.properties
Normal file
0
gradle.properties
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
249
gradlew
vendored
Executable file
249
gradlew
vendored
Executable file
|
@ -0,0 +1,249 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright © 2015-2021 the original authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
app_path=$0
|
||||||
|
|
||||||
|
# Need this for daisy-chained symlinks.
|
||||||
|
while
|
||||||
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
|
[ -h "$app_path" ]
|
||||||
|
do
|
||||||
|
ls=$( ls -ld "$app_path" )
|
||||||
|
link=${ls#*' -> '}
|
||||||
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
|
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD=maximum
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "$( uname )" in #(
|
||||||
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
|
Darwin* ) darwin=true ;; #(
|
||||||
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
|
NONSTOP* ) nonstop=true ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
|
else
|
||||||
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD=java
|
||||||
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
|
case $MAX_FD in #(
|
||||||
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
|
warn "Could not query maximum file descriptor limit"
|
||||||
|
esac
|
||||||
|
case $MAX_FD in #(
|
||||||
|
'' | soft) :;; #(
|
||||||
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
|
# * args from the command line
|
||||||
|
# * the main class name
|
||||||
|
# * -classpath
|
||||||
|
# * -D...appname settings
|
||||||
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
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
|
1
settings.gradle.kts
Normal file
1
settings.gradle.kts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
rootProject.name = "SR"
|
32
src/main/java/me/unurled/sacredrealms/sr/SR.java
Normal file
32
src/main/java/me/unurled/sacredrealms/sr/SR.java
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
package me.unurled.sacredrealms.sr;
|
||||||
|
|
||||||
|
import me.unurled.sacredrealms.sr.managers.Managers;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
public final class SR extends JavaPlugin {
|
||||||
|
|
||||||
|
private static SR instance;
|
||||||
|
|
||||||
|
private Managers managers;
|
||||||
|
|
||||||
|
public static SR getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
instance = this;
|
||||||
|
|
||||||
|
managers = new Managers();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
managers.unload();
|
||||||
|
managers = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Managers getManagers() {
|
||||||
|
return managers;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,110 @@
|
||||||
|
package me.unurled.sacredrealms.sr.components.attributes;
|
||||||
|
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
|
||||||
|
public enum Attribute {
|
||||||
|
HEALTH(
|
||||||
|
"HEALTH",
|
||||||
|
"Health",
|
||||||
|
100,
|
||||||
|
100000,
|
||||||
|
0,
|
||||||
|
PersistentDataType.DOUBLE,
|
||||||
|
new NamespacedKey("sr", "HEALTH")),
|
||||||
|
STRENGTH(
|
||||||
|
"STRENGTH",
|
||||||
|
"Strength",
|
||||||
|
10,
|
||||||
|
10000,
|
||||||
|
0,
|
||||||
|
PersistentDataType.DOUBLE,
|
||||||
|
new NamespacedKey("sr", "STRENGTH")),
|
||||||
|
DEFENSE(
|
||||||
|
"DEFENSE",
|
||||||
|
"Defense",
|
||||||
|
10,
|
||||||
|
10000,
|
||||||
|
0,
|
||||||
|
PersistentDataType.DOUBLE,
|
||||||
|
new NamespacedKey("sr", "DEFENSE")),
|
||||||
|
AGILITY(
|
||||||
|
"AGILITY",
|
||||||
|
"Agility",
|
||||||
|
100,
|
||||||
|
10000,
|
||||||
|
100,
|
||||||
|
PersistentDataType.DOUBLE,
|
||||||
|
new NamespacedKey("sr", "AGILITY")),
|
||||||
|
LUCK(
|
||||||
|
"LUCK",
|
||||||
|
"Luck",
|
||||||
|
100,
|
||||||
|
99999,
|
||||||
|
-99999,
|
||||||
|
PersistentDataType.INTEGER,
|
||||||
|
new NamespacedKey("sr", "LUCK")),
|
||||||
|
MANA("MANA", "Mana", 100, 10000, 0, PersistentDataType.DOUBLE, new NamespacedKey("sr", "MANA")),
|
||||||
|
CHARISMA(
|
||||||
|
"CHARISMA",
|
||||||
|
"Charisma",
|
||||||
|
0,
|
||||||
|
10000,
|
||||||
|
-10000,
|
||||||
|
PersistentDataType.INTEGER,
|
||||||
|
new NamespacedKey("sr", "CHARISMA")),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
private final String ID;
|
||||||
|
private final int defaultValue;
|
||||||
|
private final int maxValue;
|
||||||
|
private final int minValue;
|
||||||
|
private final PersistentDataType type;
|
||||||
|
private final NamespacedKey key;
|
||||||
|
|
||||||
|
Attribute(
|
||||||
|
String ID,
|
||||||
|
String name,
|
||||||
|
int defaultValue,
|
||||||
|
int maxValue,
|
||||||
|
int minValue,
|
||||||
|
PersistentDataType type,
|
||||||
|
NamespacedKey key) {
|
||||||
|
this.ID = ID;
|
||||||
|
this.name = name;
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
this.maxValue = maxValue;
|
||||||
|
this.minValue = minValue;
|
||||||
|
this.type = type;
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getID() {
|
||||||
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDefaultValue() {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxValue() {
|
||||||
|
return maxValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMinValue() {
|
||||||
|
return minValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PersistentDataType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespacedKey getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
package me.unurled.sacredrealms.sr.components.combat;
|
||||||
|
|
||||||
|
import static me.unurled.sacredrealms.sr.utils.Component.comp;
|
||||||
|
|
||||||
|
import me.unurled.sacredrealms.sr.components.attributes.Attribute;
|
||||||
|
import me.unurled.sacredrealms.sr.managers.Manager;
|
||||||
|
import me.unurled.sacredrealms.sr.utils.Items;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Mob;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
import org.bukkit.inventory.EntityEquipment;
|
||||||
|
|
||||||
|
public class CombatManager extends Manager {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onDamage(EntityDamageByBlockEvent e) {
|
||||||
|
// TODO: Implement
|
||||||
|
// blast enchant :shrug:
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Finish this
|
||||||
|
@EventHandler
|
||||||
|
public void onDamage(EntityDamageByEntityEvent e) {
|
||||||
|
e.setDamage(0.0);
|
||||||
|
|
||||||
|
if (!(e.getDamager() instanceof LivingEntity) || !(e.getEntity() instanceof LivingEntity)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LivingEntity damager = (LivingEntity) e.getDamager();
|
||||||
|
LivingEntity entity = (LivingEntity) e.getEntity();
|
||||||
|
|
||||||
|
if (damager instanceof Player d) {
|
||||||
|
if (entity instanceof Player) {
|
||||||
|
// no pvp
|
||||||
|
e.setCancelled(true);
|
||||||
|
d.sendMessage(comp("<red>You can't attack players!"));
|
||||||
|
d.playSound(d, Sound.BLOCK_ANVIL_HIT, 1.0f, 1.0f);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (entity instanceof Mob) {
|
||||||
|
Double dStrength = Items.getTotalAttribute(d, Attribute.STRENGTH);
|
||||||
|
EntityEquipment equipment = ((Mob) entity).getEquipment();
|
||||||
|
Double eDefense = Items.getTotalAttribute(equipment, Attribute.DEFENSE);
|
||||||
|
|
||||||
|
Double dLuck = Items.getTotalAttribute(d, Attribute.LUCK);
|
||||||
|
Double eLuck = Items.getTotalAttribute(equipment, Attribute.LUCK);
|
||||||
|
|
||||||
|
Double luck = dLuck - eLuck;
|
||||||
|
if (luck < -1000) {
|
||||||
|
// 100% chance of miss
|
||||||
|
luck = -10000d;
|
||||||
|
d.sendMessage(comp("<red>You missed!"));
|
||||||
|
// TODO: play miss sound
|
||||||
|
// d.playSound();
|
||||||
|
e.setCancelled(true);
|
||||||
|
return;
|
||||||
|
} else if (luck > 1000) {
|
||||||
|
// 100% chance of critical hit
|
||||||
|
luck = 10000d;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (luck < 0) {
|
||||||
|
// chances of miss
|
||||||
|
|
||||||
|
} else if (luck > 0) {
|
||||||
|
// chance of critical hit
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} else if (entity instanceof Player) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onDamage(EntityDamageEvent e) {}
|
||||||
|
}
|
|
@ -0,0 +1,149 @@
|
||||||
|
package me.unurled.sacredrealms.sr.components.item;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import me.unurled.sacredrealms.sr.components.attributes.Attribute;
|
||||||
|
import me.unurled.sacredrealms.sr.components.item.abilities.Ability;
|
||||||
|
import me.unurled.sacredrealms.sr.components.item.enchantments.Enchantment;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
/* <b><color of the rarity>rarity
|
||||||
|
* <dark_gray>Description: blablabla
|
||||||
|
* <dark_gray>blabbla
|
||||||
|
* <dark_gray>blabla
|
||||||
|
* <gray>Attributes:
|
||||||
|
* <gray>➤ Health: <green>+100
|
||||||
|
* <gray>➤ Strength: <red>+10
|
||||||
|
* <gray>➤ Mana: <dark_aqua>+10
|
||||||
|
* <gray>Abilities:
|
||||||
|
* <gray>➤ Ability 1,<yellow> On Rightclick unleash a powerful attack
|
||||||
|
* <dark_gray>cooldown: 10s,
|
||||||
|
* <dark_gray>damage: 100,
|
||||||
|
* <dark_gray>mana cost: <dark_aqua>50
|
||||||
|
* <gray>➤ Ability 2,<yellow> On Rightclick unleash a powerful attack
|
||||||
|
* <dark_gray>cooldown: 10s,
|
||||||
|
* <dark_gray>damage: 100,
|
||||||
|
* <dark_gray>mana cost: <dark_aqua>50
|
||||||
|
* <dark_purple>Enchantments:
|
||||||
|
* <blue>➤ Enchantment <if max level gold>1
|
||||||
|
* <blue>➤ Enchantment <if max level gold>2
|
||||||
|
* */
|
||||||
|
public class Item {
|
||||||
|
|
||||||
|
private final String ID;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private Material material;
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
private Rarity rarity;
|
||||||
|
|
||||||
|
private HashMap<Attribute, Double> attributes;
|
||||||
|
|
||||||
|
private HashMap<Enchantment, Integer> enchantments;
|
||||||
|
|
||||||
|
private List<Ability> abilities;
|
||||||
|
|
||||||
|
public Item(String ID, String name, Material material) {
|
||||||
|
this.ID = ID;
|
||||||
|
this.name = name;
|
||||||
|
this.material = material;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getID() {
|
||||||
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material getMaterial() {
|
||||||
|
return material;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaterial(Material material) {
|
||||||
|
this.material = material;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Rarity getRarity() {
|
||||||
|
return rarity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRarity(Rarity rarity) {
|
||||||
|
this.rarity = rarity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<Attribute, Double> getAttributes() {
|
||||||
|
return attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getAttribute(Attribute attribute) {
|
||||||
|
return attributes.get(attribute);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAttributes(HashMap<Attribute, Double> attributes) {
|
||||||
|
this.attributes = attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAttribute(Attribute attribute, double value) {
|
||||||
|
attributes.put(attribute, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAttribute(Attribute attribute) {
|
||||||
|
attributes.remove(attribute);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<Enchantment, Integer> getEnchantments() {
|
||||||
|
return enchantments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnchantments(HashMap<Enchantment, Integer> enchantments) {
|
||||||
|
this.enchantments = enchantments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEnchantment(Enchantment enchantment, int level) {
|
||||||
|
enchantments.put(enchantment, level);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeEnchantment(Enchantment enchantment) {
|
||||||
|
enchantments.remove(enchantment);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Ability> getAbilities() {
|
||||||
|
return abilities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAbilities(List<Ability> abilities) {
|
||||||
|
this.abilities = abilities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAbility(Ability ability) {
|
||||||
|
abilities.add(ability);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAbility(Ability ability) {
|
||||||
|
abilities.remove(ability);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack toItemStack() {
|
||||||
|
ItemStack item = new ItemStack(material);
|
||||||
|
// set item meta
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package me.unurled.sacredrealms.sr.components.item;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import me.unurled.sacredrealms.sr.managers.Manager;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
|
||||||
|
public class ItemManager extends Manager {
|
||||||
|
public static final NamespacedKey ID = new NamespacedKey("sr", "ID");
|
||||||
|
|
||||||
|
public HashMap<String, Item> items;
|
||||||
|
|
||||||
|
public ItemManager() {
|
||||||
|
super();
|
||||||
|
items = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addItem(Item item) {
|
||||||
|
items.put(item.getID(), item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item getItem(String id) {
|
||||||
|
return items.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeItem(String id) {
|
||||||
|
items.remove(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isItem(String id) {
|
||||||
|
return items.containsKey(id);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package me.unurled.sacredrealms.sr.components.item;
|
||||||
|
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
|
||||||
|
public enum Rarity {
|
||||||
|
|
||||||
|
COMMON("<white>Common", "COMMON", 1),
|
||||||
|
UNCOMMON("<green>UnCommon", "UnCOMMON", 2),
|
||||||
|
RARE("<dark_aqua>Rare", "RARE", 3),
|
||||||
|
EPIC("<dark_purple>Epic", "EPIC", 4),
|
||||||
|
LEGENDARY("<gold>Legendary", "LEGENDARY", 5),
|
||||||
|
MYTHIC("<light_purple>Mythic", "MYTHIC", 6),
|
||||||
|
SPECIAL("<red>Special", "SPECIAL", 7),
|
||||||
|
UNIQUE("<yellow>Unique", "UNIQUE", 8),
|
||||||
|
ADMIN("<color:#800000><obf>aa</obf><dark_red>Admin</dark_red><obf>aa</obf></color>", "ADMIN",
|
||||||
|
100);
|
||||||
|
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
private final String ID;
|
||||||
|
private final Integer weight;
|
||||||
|
|
||||||
|
Rarity(String name, String ID, Integer weight) {
|
||||||
|
this.name = name;
|
||||||
|
this.ID = ID;
|
||||||
|
this.weight = weight;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
package me.unurled.sacredrealms.sr.components.item.abilities;
|
||||||
|
|
||||||
|
public class Ability {}
|
|
@ -0,0 +1,3 @@
|
||||||
|
package me.unurled.sacredrealms.sr.components.item.enchantments;
|
||||||
|
|
||||||
|
public class Enchantment {}
|
|
@ -0,0 +1,94 @@
|
||||||
|
package me.unurled.sacredrealms.sr.components.player;
|
||||||
|
|
||||||
|
import static me.unurled.sacredrealms.sr.utils.Logger.error;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.UUID;
|
||||||
|
import me.unurled.sacredrealms.sr.data.DataHandler;
|
||||||
|
import me.unurled.sacredrealms.sr.data.DataManager;
|
||||||
|
import me.unurled.sacredrealms.sr.managers.Manager;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public class PlayerManager extends Manager {
|
||||||
|
|
||||||
|
private final HashMap<UUID, SRPlayer> players;
|
||||||
|
|
||||||
|
public PlayerManager() {
|
||||||
|
super();
|
||||||
|
players = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Save the data */
|
||||||
|
@Override
|
||||||
|
public void saveData() {
|
||||||
|
DataManager dm = (DataManager) DataManager.getInstance(DataManager.class);
|
||||||
|
if (dm == null) {
|
||||||
|
error("DataManager is null, Can't save player data.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DataHandler dh = dm.getDataHandler();
|
||||||
|
Gson gson = new Gson();
|
||||||
|
dh.set("sr.players", gson.toJson(players));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Load the data */
|
||||||
|
@Override
|
||||||
|
public void loadData() {}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public SRPlayer getPlayer(UUID uuid) {
|
||||||
|
return players.get(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPlayer(@NotNull SRPlayer player) {
|
||||||
|
players.put(player.getUuid(), player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePlayer(UUID uuid) {
|
||||||
|
players.remove(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSRPlayer(UUID uuid) {
|
||||||
|
return players.containsKey(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||||
|
SRPlayer player = new SRPlayer(e.getPlayer());
|
||||||
|
// load data from db // TODO: test this after redis cache
|
||||||
|
/*DataManager dm = (DataManager) DataManager.getInstance(DataManager.class);
|
||||||
|
if (dm == null) {
|
||||||
|
error("DataManager is null, Can't load player " + e.getPlayer().getName() + "'s data" + ".");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DataHandler dh = dm.getDataHandler();
|
||||||
|
Gson gson = new Gson();
|
||||||
|
Object json = dh.getGson("sr.players." + e.getPlayer().getUniqueId());*/
|
||||||
|
addPlayer(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: test if it works, i have a doubt about the jsonAppend (key + path seems weird)
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent e) {
|
||||||
|
SRPlayer player = getPlayer(e.getPlayer().getUniqueId());
|
||||||
|
if (player == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// save for player
|
||||||
|
DataManager dm = (DataManager) DataManager.getInstance(DataManager.class);
|
||||||
|
if (dm == null) {
|
||||||
|
error("DataManager is null, Can't save player " + e.getPlayer().getName() + "'s data" + ".");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DataHandler dh = dm.getDataHandler();
|
||||||
|
Gson gson = new Gson();
|
||||||
|
dh.set("sr.players." + e.getPlayer().getUniqueId(), gson.toJson(player));
|
||||||
|
|
||||||
|
removePlayer(e.getPlayer().getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,155 @@
|
||||||
|
package me.unurled.sacredrealms.sr.components.player;
|
||||||
|
|
||||||
|
import static me.unurled.sacredrealms.sr.utils.Logger.warn;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import me.unurled.sacredrealms.sr.components.attributes.Attribute;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.persistence.PersistentDataContainer;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public class SRPlayer {
|
||||||
|
|
||||||
|
private final UUID uuid;
|
||||||
|
|
||||||
|
public SRPlayer(@NotNull Player player) {
|
||||||
|
this.uuid = player.getUniqueId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public UUID getUuid() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Object getAttribute(@NotNull Attribute attribute) {
|
||||||
|
Player p = Bukkit.getPlayer(uuid);
|
||||||
|
if (p == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
PersistentDataContainer pdc = p.getPersistentDataContainer();
|
||||||
|
return pdc.get(new NamespacedKey("sr", attribute.getID()), attribute.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAttribute(@NotNull Attribute attribute, @NotNull Object value) {
|
||||||
|
Player p = Bukkit.getPlayer(uuid);
|
||||||
|
if (p == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PersistentDataContainer pdc = p.getPersistentDataContainer();
|
||||||
|
if (!attribute.getType().getComplexType().isInstance(value)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (attribute.getType().equals(PersistentDataType.DOUBLE)) {
|
||||||
|
double d = (double) value;
|
||||||
|
if (d < attribute.getMinValue() || d > attribute.getMaxValue()) {
|
||||||
|
warn(
|
||||||
|
"(Player "
|
||||||
|
+ p.getName()
|
||||||
|
+ ") Value "
|
||||||
|
+ d
|
||||||
|
+ " for attribute "
|
||||||
|
+ attribute.getID()
|
||||||
|
+ " is out of bounds. Min: "
|
||||||
|
+ attribute.getMinValue()
|
||||||
|
+ " Max: "
|
||||||
|
+ attribute.getMaxValue()
|
||||||
|
+ " Value: "
|
||||||
|
+ d);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (attribute.getType().equals(PersistentDataType.INTEGER)) {
|
||||||
|
int i = (int) value;
|
||||||
|
if (i < attribute.getMinValue() || i > attribute.getMaxValue()) {
|
||||||
|
warn(
|
||||||
|
"(Player "
|
||||||
|
+ p.getName()
|
||||||
|
+ ") Value "
|
||||||
|
+ i
|
||||||
|
+ " for attribute "
|
||||||
|
+ attribute.getID()
|
||||||
|
+ " is out of bounds. Min: "
|
||||||
|
+ attribute.getMinValue()
|
||||||
|
+ " Max: "
|
||||||
|
+ attribute.getMaxValue()
|
||||||
|
+ " Value: "
|
||||||
|
+ i);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pdc.set(new NamespacedKey("sr", attribute.getID()), attribute.getType(), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Object getHandItemAttribute(@NotNull Attribute attribute) {
|
||||||
|
Player p = Bukkit.getPlayer(uuid);
|
||||||
|
if (p == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return p.getInventory()
|
||||||
|
.getItemInMainHand()
|
||||||
|
.getItemMeta()
|
||||||
|
.getPersistentDataContainer()
|
||||||
|
.get(new NamespacedKey("sr", attribute.getID()), attribute.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHandItemAttribute(@NotNull Attribute attribute, @NotNull Object value) {
|
||||||
|
Player p = Bukkit.getPlayer(uuid);
|
||||||
|
if (p == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!attribute.getType().getComplexType().isInstance(value)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (attribute.getType().equals(PersistentDataType.DOUBLE)) {
|
||||||
|
double d = (double) value;
|
||||||
|
if (d < attribute.getMinValue() || d > attribute.getMaxValue()) {
|
||||||
|
warn(
|
||||||
|
"(Player "
|
||||||
|
+ p.getName()
|
||||||
|
+ ") Value "
|
||||||
|
+ d
|
||||||
|
+ " for attribute "
|
||||||
|
+ attribute.getID()
|
||||||
|
+ " is out of bounds. Min: "
|
||||||
|
+ attribute.getMinValue()
|
||||||
|
+ " Max: "
|
||||||
|
+ attribute.getMaxValue()
|
||||||
|
+ " Value: "
|
||||||
|
+ d);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (attribute.getType().equals(PersistentDataType.INTEGER)) {
|
||||||
|
int i = (int) value;
|
||||||
|
if (i < attribute.getMinValue() || i > attribute.getMaxValue()) {
|
||||||
|
warn(
|
||||||
|
"(Player "
|
||||||
|
+ p.getName()
|
||||||
|
+ ") Value "
|
||||||
|
+ i
|
||||||
|
+ " for attribute "
|
||||||
|
+ attribute.getID()
|
||||||
|
+ " is out of bounds. Min: "
|
||||||
|
+ attribute.getMinValue()
|
||||||
|
+ " Max: "
|
||||||
|
+ attribute.getMaxValue()
|
||||||
|
+ " Value: "
|
||||||
|
+ i);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ItemStack i = p.getInventory().getItemInMainHand();
|
||||||
|
ItemMeta im = i.getItemMeta();
|
||||||
|
im.getPersistentDataContainer()
|
||||||
|
.set(new NamespacedKey("sr", attribute.getID()), attribute.getType(), value);
|
||||||
|
im.lore();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
package me.unurled.sacredrealms.sr.data;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public interface DataHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a value from the data source
|
||||||
|
*
|
||||||
|
* @param key The key to get the value from
|
||||||
|
* @return The value of the key
|
||||||
|
*/
|
||||||
|
String get(@NotNull String key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a value from the data source
|
||||||
|
*
|
||||||
|
* @param key The key to get the value from
|
||||||
|
* @return The value of the key
|
||||||
|
*/
|
||||||
|
Object getGson(@NotNull String key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a value in the data source
|
||||||
|
*
|
||||||
|
* @param key The key to set the value to
|
||||||
|
* @param value The value to set
|
||||||
|
*/
|
||||||
|
void set(@NotNull String key, @Nullable String value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a value in the data source
|
||||||
|
*
|
||||||
|
* @param key The key to set the value to
|
||||||
|
* @param value The value to set
|
||||||
|
*/
|
||||||
|
void set(@NotNull String key, Gson value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Append a value to the data source
|
||||||
|
*
|
||||||
|
* @param key The key to append the value to
|
||||||
|
* @param path The path to append the value to
|
||||||
|
* @param json The json to append
|
||||||
|
*/
|
||||||
|
void jsonAppend(@NotNull String key, @NotNull String path, @NotNull Object... json);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a value from the data source
|
||||||
|
*
|
||||||
|
* @param key The key to remove the value from
|
||||||
|
*/
|
||||||
|
void remove(@NotNull String key);
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
package me.unurled.sacredrealms.sr.data;
|
||||||
|
|
||||||
|
import static me.unurled.sacredrealms.sr.utils.Logger.error;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import me.unurled.sacredrealms.sr.SR;
|
||||||
|
import me.unurled.sacredrealms.sr.data.DataHandler;
|
||||||
|
import me.unurled.sacredrealms.sr.data.Redis;
|
||||||
|
import me.unurled.sacredrealms.sr.managers.Manager;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
/** The data and config manager */
|
||||||
|
public class DataManager extends Manager {
|
||||||
|
|
||||||
|
private FileConfiguration config;
|
||||||
|
|
||||||
|
private DataHandler dh;
|
||||||
|
|
||||||
|
/** Load the manager */
|
||||||
|
@Override
|
||||||
|
public void load() {
|
||||||
|
super.load();
|
||||||
|
dh = new Redis();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Save the data */
|
||||||
|
@Override
|
||||||
|
public void saveData() {
|
||||||
|
try {
|
||||||
|
if (config != null) config.save(new File(SR.getInstance().getDataFolder(), "config.yml"));
|
||||||
|
} catch (IOException e) {
|
||||||
|
error("Failed to save config.yml");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Load the data */
|
||||||
|
@Override
|
||||||
|
public void loadData() {
|
||||||
|
SR.getInstance().saveConfig();
|
||||||
|
SR.getInstance().reloadConfig();
|
||||||
|
config = SR.getInstance().getConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the config
|
||||||
|
*
|
||||||
|
* @return The config
|
||||||
|
*/
|
||||||
|
public FileConfiguration getConfig() {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the data handler
|
||||||
|
*
|
||||||
|
* @return The data handler
|
||||||
|
*/
|
||||||
|
public DataHandler getDataHandler() {
|
||||||
|
return dh;
|
||||||
|
}
|
||||||
|
}
|
97
src/main/java/me/unurled/sacredrealms/sr/data/Redis.java
Normal file
97
src/main/java/me/unurled/sacredrealms/sr/data/Redis.java
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
package me.unurled.sacredrealms.sr.data;
|
||||||
|
|
||||||
|
import static me.unurled.sacredrealms.sr.utils.Logger.error;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import me.unurled.sacredrealms.sr.SR;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import redis.clients.jedis.JedisPooled;
|
||||||
|
import redis.clients.jedis.json.Path2;
|
||||||
|
|
||||||
|
public class Redis implements DataHandler {
|
||||||
|
|
||||||
|
JedisPooled client;
|
||||||
|
|
||||||
|
public Redis() {
|
||||||
|
DataManager dm = (DataManager) DataManager.getInstance(DataManager.class);
|
||||||
|
if (dm != null) {
|
||||||
|
String host = dm.getConfig().getString("redis.host", "127.0.0.1");
|
||||||
|
int port = dm.getConfig().getInt("redis.port", 6379);
|
||||||
|
try {
|
||||||
|
client = new JedisPooled(host, port);
|
||||||
|
client.get("test");
|
||||||
|
} catch (Exception e) {
|
||||||
|
error("Failed to connect to Redis, shutting down server.");
|
||||||
|
SR.getInstance().getServer().shutdown();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
error("Failed to get DataManager instance. Can't connect to Redis, shutting down server.");
|
||||||
|
SR.getInstance().getServer().shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a value from the data source
|
||||||
|
*
|
||||||
|
* @param key The key to get the value from
|
||||||
|
* @return The value of the key
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String get(@NotNull String key) {
|
||||||
|
return client.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a value from the data source
|
||||||
|
*
|
||||||
|
* @param key The key to get the value from
|
||||||
|
* @return The value of the key
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Object getGson(@NotNull String key) {
|
||||||
|
return client.jsonGet(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a value in the data source
|
||||||
|
*
|
||||||
|
* @param key The key to set the value to
|
||||||
|
* @param value The value to set
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void set(@NotNull String key, String value) {
|
||||||
|
client.set(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a value in the data source
|
||||||
|
*
|
||||||
|
* @param key The key to set the value to
|
||||||
|
* @param value The value to set
|
||||||
|
*/
|
||||||
|
public void set(@NotNull String key, Gson value) {
|
||||||
|
client.jsonSet(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Append a value to the data source
|
||||||
|
*
|
||||||
|
* @param key The key to append the value to
|
||||||
|
* @param path The path to append the value to
|
||||||
|
* @param json The json to append
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void jsonAppend(@NotNull String key, @NotNull String path, @NotNull Object... json) {
|
||||||
|
client.jsonArrAppend(key, Path2.of(path), json);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a value from the data source
|
||||||
|
*
|
||||||
|
* @param key The key to remove the value from
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void remove(@NotNull String key) {
|
||||||
|
client.del(key);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package me.unurled.sacredrealms.sr.managers;
|
||||||
|
|
||||||
|
import me.unurled.sacredrealms.sr.SR;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
public class Manager implements Listener {
|
||||||
|
|
||||||
|
/** Constructor for the Manager class */
|
||||||
|
public Manager() {
|
||||||
|
SR.getInstance().getManagers().addManager(this);
|
||||||
|
Bukkit.getScheduler()
|
||||||
|
.runTaskAsynchronously(
|
||||||
|
SR.getInstance(),
|
||||||
|
() -> {
|
||||||
|
load();
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, SR.getInstance());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an instance of a manager
|
||||||
|
*
|
||||||
|
* @param clazz The class of the manager
|
||||||
|
* @return The instance of the manager
|
||||||
|
* @param <T> The type of the manager
|
||||||
|
*/
|
||||||
|
public static <T extends Manager> Manager getInstance(Class<? extends Manager> clazz) {
|
||||||
|
return clazz.cast(SR.getInstance().getManagers().getManager(clazz));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Load the manager */
|
||||||
|
public void load() {
|
||||||
|
loadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Unload the manager */
|
||||||
|
public void unload() {
|
||||||
|
saveData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Save the data */
|
||||||
|
public void saveData() {}
|
||||||
|
|
||||||
|
/** Load the data */
|
||||||
|
public void loadData() {}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
package me.unurled.sacredrealms.sr.managers;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import me.unurled.sacredrealms.sr.SR;
|
||||||
|
import me.unurled.sacredrealms.sr.components.combat.CombatManager;
|
||||||
|
import me.unurled.sacredrealms.sr.components.item.ItemManager;
|
||||||
|
import me.unurled.sacredrealms.sr.components.player.PlayerManager;
|
||||||
|
import me.unurled.sacredrealms.sr.data.DataManager;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public class Managers {
|
||||||
|
|
||||||
|
private final List<Manager> managers;
|
||||||
|
|
||||||
|
public Managers() {
|
||||||
|
managers = new ArrayList<>();
|
||||||
|
// register managers here (like a new instance of them)
|
||||||
|
|
||||||
|
Bukkit.getScheduler()
|
||||||
|
.runTaskLater(
|
||||||
|
SR.getInstance(),
|
||||||
|
() -> {
|
||||||
|
new DataManager();
|
||||||
|
new PlayerManager();
|
||||||
|
new ItemManager();
|
||||||
|
new CombatManager();
|
||||||
|
},
|
||||||
|
10L);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addManager(Manager manager) {
|
||||||
|
managers.add(manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unload() {
|
||||||
|
for (Manager manager : managers) {
|
||||||
|
manager.unload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Manager getManager(Class<? extends Manager> clazz) {
|
||||||
|
for (Manager manager : managers) {
|
||||||
|
if (manager.getClass().equals(clazz)) {
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package me.unurled.sacredrealms.sr.utils;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
|
|
||||||
|
public class Component {
|
||||||
|
|
||||||
|
public static net.kyori.adventure.text.Component comp(String msg) {
|
||||||
|
MiniMessage mm = MiniMessage.miniMessage();
|
||||||
|
return mm.deserialize(msg);
|
||||||
|
}
|
||||||
|
}
|
56
src/main/java/me/unurled/sacredrealms/sr/utils/Items.java
Normal file
56
src/main/java/me/unurled/sacredrealms/sr/utils/Items.java
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
package me.unurled.sacredrealms.sr.utils;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import me.unurled.sacredrealms.sr.components.attributes.Attribute;
|
||||||
|
import me.unurled.sacredrealms.sr.components.item.Item;
|
||||||
|
import me.unurled.sacredrealms.sr.components.item.ItemManager;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.EntityEquipment;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.persistence.PersistentDataContainer;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class Items {
|
||||||
|
public static @NotNull Double getTotalAttribute(Player player, Attribute attribute) {
|
||||||
|
return getTotalAttribute(player.getEquipment(), attribute);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @NotNull Double getTotalAttribute(EntityEquipment inv, Attribute attribute) {
|
||||||
|
ItemManager im = (ItemManager) ItemManager.getInstance(ItemManager.class);
|
||||||
|
if (im == null) return 0.0;
|
||||||
|
|
||||||
|
AtomicReference<Double> total = new AtomicReference<>(0.0);
|
||||||
|
|
||||||
|
Arrays.stream(inv.getArmorContents()).toList().forEach(item ->
|
||||||
|
total.updateAndGet(
|
||||||
|
v -> (v + getAttribute(item,
|
||||||
|
attribute))));
|
||||||
|
|
||||||
|
total.updateAndGet(
|
||||||
|
v -> (v + getAttribute(inv.getItemInMainHand(),
|
||||||
|
attribute)));
|
||||||
|
total.updateAndGet(
|
||||||
|
v -> (v + getAttribute(inv.getItemInOffHand(),
|
||||||
|
attribute)));
|
||||||
|
|
||||||
|
return total.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Double getAttribute(ItemStack item, Attribute attribute) {
|
||||||
|
ItemManager im = (ItemManager) ItemManager.getInstance(ItemManager.class);
|
||||||
|
if (im == null) return 0.0;
|
||||||
|
if (item == null) return 0.0;
|
||||||
|
if (item.getType().equals(Material.AIR)) return 0.0;
|
||||||
|
PersistentDataContainer p = item.getItemMeta().getPersistentDataContainer();
|
||||||
|
if (p.has(ItemManager.ID, PersistentDataType.STRING)) {
|
||||||
|
Item i = im.getItem(p.get(ItemManager.ID, PersistentDataType.STRING));
|
||||||
|
if (i != null) {
|
||||||
|
return i.getAttribute(attribute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
}
|
31
src/main/java/me/unurled/sacredrealms/sr/utils/Logger.java
Normal file
31
src/main/java/me/unurled/sacredrealms/sr/utils/Logger.java
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
package me.unurled.sacredrealms.sr.utils;
|
||||||
|
|
||||||
|
import me.unurled.sacredrealms.sr.SR;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
|
public class Logger {
|
||||||
|
|
||||||
|
public static void log(String message) {
|
||||||
|
SR.getInstance().getLogger().info(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void warn(String message) {
|
||||||
|
SR.getInstance().getLogger().warning(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void error(String message) {
|
||||||
|
SR.getInstance().getLogger().severe(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void log(Component message) {
|
||||||
|
SR.getInstance().getComponentLogger().info(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void warn(Component message) {
|
||||||
|
SR.getInstance().getComponentLogger().warn(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void error(Component message) {
|
||||||
|
SR.getInstance().getComponentLogger().error(message);
|
||||||
|
}
|
||||||
|
}
|
3
src/main/resources/config.yml
Normal file
3
src/main/resources/config.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
redis:
|
||||||
|
host: "127.0.0.1"
|
||||||
|
port: 6379
|
16
src/main/resources/paper-plugin.yml
Normal file
16
src/main/resources/paper-plugin.yml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
name: $name
|
||||||
|
version: $version
|
||||||
|
main: me.unurled.sacredrealms.sr.SR
|
||||||
|
api-version: "$apiVersion"
|
||||||
|
description: $description
|
||||||
|
load: POSTWORLD
|
||||||
|
authors:
|
||||||
|
- unurled
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
sr.tutorial:
|
||||||
|
default: not op
|
||||||
|
description: When the player joins and doesn't have finished the tutorial.
|
||||||
|
sr.spawn:
|
||||||
|
default: not op
|
||||||
|
description: When the player have discovered the spawn.
|
Loading…
Add table
Add a link
Reference in a new issue