diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..0882495
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,14 @@
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+indent_size = 4
+indent_style = space
+insert_final_newline = true
+max_line_length = 120
+tab_width = 4
+trim_trailing_whitespace = true
+ij_continuation_indent_size = 4
+[*.yml]
+indent_size = 2
diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml
new file mode 100644
index 0000000..9efa6f4
--- /dev/null
+++ b/.github/workflows/gradle.yml
@@ -0,0 +1,61 @@
+# This workflow uses actions that are not certified by GitHub.
+# They are provided by a third-party and are governed by
+# separate terms of service, privacy policy, and support
+# documentation.
+# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
+# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
+
+name: Java CI with Gradle
+
+on:
+ push:
+ branches:
+ - master
+ - 'dev/**'
+ - 'update/**'
+ pull_request:
+
+permissions:
+ contents: read
+
+jobs:
+ build_plugin:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set up JDK 21
+ uses: actions/setup-java@v4.2.1
+ with:
+ java-version: '21'
+ distribution: 'temurin'
+ - name: Build with Gradle
+ uses: gradle/actions/setup-gradle@v3
+ with:
+ arguments: build
+ - name: Upload a Build Artifact
+ uses: actions/upload-artifact@master
+ with:
+ # Artifact name
+ name: SurvivalPlus-Plugin
+ # A file, directory or wildcard pattern that describes what to upload
+ path: build/libs/SurvivalPlus-*.jar
+ build_resource_pack:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Set up JDK 21
+ uses: actions/setup-java@v4.2.1
+ with:
+ java-version: '21'
+ distribution: 'temurin'
+ - name: Build with Gradle
+ uses: gradle/actions/setup-gradle@v3
+ with:
+ arguments: resourcepack
+ - name: Upload a Build Artifact
+ uses: actions/upload-artifact@master
+ with:
+ # Artifact name
+ name: SurvivalPlus-ResourcePack
+ # A file, directory or wildcard pattern that describes what to upload
+ path: build/libs/SurvivalPlusResourcePack-*.zip
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
deleted file mode 100644
index 70ea463..0000000
--- a/.github/workflows/maven.yml
+++ /dev/null
@@ -1,31 +0,0 @@
-# This workflow will build a Java project with Maven
-# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
-
-name: Java CI with Maven
-
-on:
- push:
- branches: '**'
- pull_request:
- branches: '**'
-
-jobs:
- build:
-
- runs-on: ubuntu-latest
-
- steps:
- - uses: actions/checkout@v2
- - name: Set up JDK 1.8
- uses: actions/setup-java@v1
- with:
- java-version: 1.8
- - name: Build with Maven
- run: mvn -B package --file pom.xml
- - name: Upload a Build Artifact
- uses: actions/upload-artifact@v2.1.4
- with:
- # Artifact name
- name: SurvivalPlus-Artifact
- # A file, directory or wildcard pattern that describes what to upload
- path: target/SurvivalPlus*.jar
diff --git a/.gitignore b/.gitignore
index 7be156d..db3f172 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,34 +1,42 @@
-# Compiled class file
-*.class
+.gradle/
+build/
+!gradle/wrapper/gradle-wrapper.jar
+!**/src/main/**/build/
+!**/src/test/**/build/
-# Log file
-*.log
-
-# BlueJ files
-*.ctxt
-
-# Mobile Tools for Java (J2ME)
-.mtj.tmp/
-
-# Package Files #
-*.jar
-*.war
-*.ear
-*.tar.gz
-*.rar
-
-# IntelliJ Files #
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
*.iml
+*.ipr
+out/
+!**/src/main/**/out/
+!**/src/test/**/out/
-# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
-hs_err_pid*
-
-# Custom #
+### Eclipse ###
+.apt_generated
.classpath
-.settings
+.factorypath
.project
-bin
-JavaDocs/
-out/
-.idea/
-/target/
+.settings
+.springBeans
+.sts4-cache
+bin/
+!**/src/main/**/bin/
+!**/src/test/**/bin/
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
diff --git a/README.md b/README.md
index bc85993..b291c72 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,7 @@
# SurvivalPlus

[](https://discordapp.com/invite/km3UF8Q)
-
-
-
+
## Welcome to SurvivalPlus
@@ -11,4 +9,9 @@ SurvivalPlus is a Minecraft mod that adds new contents and experience to Minecra
All info can be found on the [**WIKI**](https://github.com/ShaneBeeStudios/SurvivalPlus/wiki)
-Plugin downloads can be found on [**SpigotMC**](https://www.spigotmc.org/resources/survival-plus.67351/)
+Plugin downloads can be found on (TBD)
+
+### BUILDING:
+- To build the plugin run `./gradlew build` (This includes the datapack internally)
+- To build the datapack run `./gradlew datapack`
+- To build the resource pack run `./gradlew resourcepack`
diff --git a/build.gradle.kts b/build.gradle.kts
new file mode 100644
index 0000000..ad4204c
--- /dev/null
+++ b/build.gradle.kts
@@ -0,0 +1,104 @@
+plugins {
+ id("java")
+ id("io.github.goooler.shadow") version "8.1.7"
+}
+
+// Where this builds on the server
+val serverLocation = "Skript/1-21-4"
+// Version of SurvivalPlus
+val projectVersion = "1.0.0"
+// Minecraft version to build against
+val minecraftVersion = "1.21.4"
+
+java.sourceCompatibility = JavaVersion.VERSION_21
+
+repositories {
+ mavenCentral()
+ mavenLocal()
+
+ // Paper
+ maven("https://repo.papermc.io/repository/maven-public/")
+
+ // Command Api Snapshots
+ maven("https://s01.oss.sonatype.org/content/repositories")
+
+ // JitPack repo
+ maven("https://jitpack.io")
+
+ // Papi
+ maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
+}
+
+dependencies {
+ // Paper
+ compileOnly("io.papermc.paper:paper-api:${minecraftVersion}-R0.1-SNAPSHOT")
+
+ // FastBoard
+ implementation("fr.mrmicky:fastboard:2.1.3")
+
+ // Command Api
+ implementation("dev.jorel:commandapi-bukkit-shade-mojang-mapped:9.7.0")
+
+ // Papi
+ compileOnly("me.clip:placeholderapi:2.11.6")
+
+ // bStats
+ implementation("org.bstats:bstats-bukkit:3.0.2")
+
+}
+
+tasks {
+ register("server", Copy::class) {
+ dependsOn("shadowJar")
+ from("build/libs") {
+ include("SurvivalPlus-*.jar")
+ destinationDir = file("/Users/ShaneBee/Desktop/Server/${serverLocation}/plugins/")
+ }
+
+ }
+ register("resourcepack", Zip::class) {
+ archiveFileName = "SurvivalPlusResourcePack-${projectVersion}.zip"
+ from("src/main/resources/resource-pack") {
+ exclude("**/.DS_Store")
+ destinationDirectory = file("build/libs/")
+ }
+ }
+ register("datapack", Zip::class) {
+ archiveFileName = "SurvivalPlusDataPack-${projectVersion}.zip"
+ from("src/main/resources/datapack") {
+ exclude("**/.DS_Store")
+ destinationDirectory = file("build/libs/")
+ }
+ }
+ processResources {
+ expand("version" to projectVersion)
+ exclude("resource-pack/*")
+ }
+ compileJava {
+ options.release = 21
+ options.compilerArgs.add("-Xlint:unchecked")
+ options.compilerArgs.add("-Xlint:deprecation")
+ }
+ javadoc {
+ options.encoding = Charsets.UTF_8.name()
+ exclude("com/shanebeestudios/survival/plugin/SurvivalBootstrap.java")
+ exclude("com/shanebeestudios/survival/plugin/commands")
+ exclude("com/shanebeestudios/survival/plugin/listeners")
+ exclude("com/shanebeestudios/survival/plugin/tasks")
+ (options as CoreJavadocOptions).addBooleanOption("Xdoclint:none", true)
+ (options as StandardJavadocDocletOptions).links(
+ "https://jd.papermc.io/paper/${minecraftVersion}/",
+ "https://jd.advntr.dev/api/4.18.0/"
+ )
+ }
+ shadowJar {
+ relocate("fr.mrmicky.fastboard", "com.shanebeestudios.survival.api.fastboard")
+ relocate("dev.jorel.commandapi", "com.shanebeestudios.survival.api.commandapi")
+ relocate("org.bstats", "com.shanebeestudios.survival.api.metrics")
+ archiveFileName = "SurvivalPlus-${projectVersion}.jar"
+ }
+ jar {
+ dependsOn(shadowJar)
+ archiveFileName.set("SurvivalPlus.jar")
+ }
+}
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..a4b76b9
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..cea7a79
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,7 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000..f5feea6
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,252 @@
+#!/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.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+##############################################################################
+#
+# 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/platforms/jvm/plugins-application/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 -P "${APP_HOME:-./}" > /dev/null && printf '%s
+' "$PWD" ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..9d21a21
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,94 @@
+@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
+@rem SPDX-License-Identifier: Apache-2.0
+@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. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 0 goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/pom.xml b/pom.xml
deleted file mode 100644
index 4fef8a1..0000000
--- a/pom.xml
+++ /dev/null
@@ -1,112 +0,0 @@
-
-
Uses {@link FastBoard} for packet based scoreboards
+ */ +@SuppressWarnings("unused") +public class HealthBoard { + + // STATIC STUFF + private static final MiniMessage MINI_MESSAGE = MiniMessage.miniMessage(); + private static final Scoreboard MAIN = Bukkit.getScoreboardManager().getMainScoreboard(); + private static final Scoreboard DUMMY = Bukkit.getScoreboardManager().getNewScoreboard(); + + // OBJECT STUFF + private final Player player; + private FastBoard fastBoard; + private final Component[] lines = new Component[15]; + private final Component[] formats = new Component[15]; + private Component title; + private boolean on; + + public HealthBoard(Player player) { + this.player = player; + this.on = false; + } + + /** + * Set the title of this Board + * + * @param title Title to set + */ + public void setTitle(String title) { + this.title = MINI_MESSAGE.deserialize(title); + } + + /** + * Set a specific line for this Board + *Lines 1 - 15
+ * + * @param line Line to set (1 - 15) + * @param text Text to put in line + */ + public void setLine(int line, @Nullable String text) { + setLine(line, text, null); + } + + public void setLine(int line, @Nullable String text, String format) { + Preconditions.checkArgument(line >= 1 && line <= 15, "Line number must be between 1 and 15, found: " + line); + if (text != null) { + Component component = MINI_MESSAGE.deserialize(text); + this.lines[line - 1] = component; + } else { + this.lines[line - 1] = null; + } + if (format != null) { + Component component = MINI_MESSAGE.deserialize(format); + this.formats[line - 1] = component; + } else { + this.formats[line - 1] = null; + } + } + + /** + * Delete a line in this Board + *Lines 1 - 15
+ * + * @param line Line to delete (1 - 15) + */ + public void deleteLine(int line) { + setLine(line, null); + } + + /** + * Clear all lines of this Board + */ + public void clearBoard() { + for (int i = 1; i < 16; i++) { + deleteLine(i); + } + } + + public void update() { + if (this.fastBoard != null) { + this.fastBoard.updateTitle(this.title); + ListYou can get an instance of PlayerData from {@link tk.shanebee.survival.managers.PlayerManager}
+ *You can get an instance of PlayerData from {@link PlayerManager}
*/ @SuppressWarnings({"unused", "FieldCanBeLocal", "SameParameterValue"}) +@SerializableAs("PlayerData") public class PlayerData implements ConfigurationSerializable { - private final Config config = Survival.getInstance().getSurvivalConfig(); - private final int max_carbs = config.MECHANICS_FOOD_MAX_CARBS; - private final int max_proteins = config.MECHANICS_FOOD_MAX_PROTEINS; - private final int max_salts = config.MECHANICS_FOOD_MAX_SALTS; + private final Config config = SurvivalPlugin.getInstance().getSurvivalConfig(); + private final Player player; private final UUID uuid; - private int thirst; private MapThis is used to determine output durability during repairs
+ * + * @return Repair percent of item + */ + public double getRepairPercent() { + return this.repairPercent; + } + + /** + * Get the repair cost of this item + * + * @return Repair cost of item + */ + public int getRepairCost() { + return this.repairCost; + } + + /** + * Check if an item cannot dual wield + * + * @return Whether item prevents dual wielding + */ + public boolean isPreventDuelWield() { + return this.preventDuelWield; + } + + /** + * Get the {@link Key} of this item + * + * @return Key of this item + */ + public Key getKey() { + return this.key; + } + + /** + * Get the name of this item + * + * @return Name of item + */ + public @Nullable String getName() { + return this.name; + } + + @Override + public String toString() { + return "Item{" + + "key=" + key + + ", recipeKey=" + recipeKey + + ", itemStack=" + itemStack + + ", name='" + name + '\'' + + ", repairPercent=" + repairPercent + + ", repairCost=" + repairCost + + ", preventDuelWield=" + preventDuelWield + + '}'; + } +} diff --git a/src/main/java/com/shanebeestudios/survival/api/item/Items.java b/src/main/java/com/shanebeestudios/survival/api/item/Items.java new file mode 100644 index 0000000..7a5df73 --- /dev/null +++ b/src/main/java/com/shanebeestudios/survival/api/item/Items.java @@ -0,0 +1,296 @@ +package com.shanebeestudios.survival.api.item; + +import com.google.common.collect.Lists; +import io.papermc.paper.datacomponent.DataComponentTypes; +import net.kyori.adventure.key.Key; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Biome; +import org.bukkit.entity.Entity; +import org.bukkit.entity.ItemDisplay; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import com.shanebeestudios.survival.api.item.items.armor.ArmorPiece; +import com.shanebeestudios.survival.api.item.items.armor.ArmorPiece.ArmorMaterial; +import com.shanebeestudios.survival.api.item.items.armor.ArmorPiece.ArmorType; +import com.shanebeestudios.survival.api.item.items.armor.BeekeeperPiece; +import com.shanebeestudios.survival.api.item.items.armor.RainBoots; +import com.shanebeestudios.survival.api.item.items.armor.ReinforcedPiece; +import com.shanebeestudios.survival.api.item.items.armor.SnowBoots; +import com.shanebeestudios.survival.api.item.items.blocks.Campfire; +import com.shanebeestudios.survival.api.item.items.blocks.Workbench; +import com.shanebeestudios.survival.api.item.items.drinks.Coffee; +import com.shanebeestudios.survival.api.item.items.drinks.ColdMilk; +import com.shanebeestudios.survival.api.item.items.drinks.HotMilk; +import com.shanebeestudios.survival.api.item.items.drinks.Water; +import com.shanebeestudios.survival.api.item.items.food.SuspiciousMeat; +import com.shanebeestudios.survival.api.item.items.legendary.BlazeSword; +import com.shanebeestudios.survival.api.item.items.legendary.EnderGiantBlade; +import com.shanebeestudios.survival.api.item.items.legendary.ObsidianMace; +import com.shanebeestudios.survival.api.item.items.legendary.QuartzPickaxe; +import com.shanebeestudios.survival.api.item.items.legendary.ValkyriesAxe; +import com.shanebeestudios.survival.api.item.items.misc.BreedingEgg; +import com.shanebeestudios.survival.api.item.items.misc.CoffeeBean; +import com.shanebeestudios.survival.api.item.items.misc.FermentedSkin; +import com.shanebeestudios.survival.api.item.items.tools.Compass; +import com.shanebeestudios.survival.api.item.items.tools.FireStriker; +import com.shanebeestudios.survival.api.item.items.tools.GrapplingHook; +import com.shanebeestudios.survival.api.item.items.tools.Hammer; +import com.shanebeestudios.survival.api.item.items.tools.Hatchet; +import com.shanebeestudios.survival.api.item.items.tools.Mattock; +import com.shanebeestudios.survival.api.item.items.tools.MedicKit; +import com.shanebeestudios.survival.api.item.items.tools.RecurvedBow; +import com.shanebeestudios.survival.api.item.items.tools.RecurvedCrossbow; +import com.shanebeestudios.survival.api.item.items.tools.Shiv; +import com.shanebeestudios.survival.api.item.items.tools.Sickle; +import com.shanebeestudios.survival.api.util.Utils; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +/** + * Custom SurvivalPlus {@link Item Items} + */ +@SuppressWarnings("UnstableApiUsage") +public class Items { + + static final MapLeaving player null will remove the previous spawned entities
+ * + * @param player Player to spawn at, or null to clear previous spawns + */ + public static void debug(@Nullable Player player) { + if (player == null) { + DEBUG_DISPLAYS.forEach(Entity::remove); + DEBUG_DISPLAYS.clear(); + return; + } + Location location = player.getLocation().getBlock().getLocation().clone().add(0, 1, 0); + + double x = 0; + double y = 0; + World world = player.getWorld(); + for (Item item : ALL_ITEMS.values()) { + Location loc = location.clone().add(x, y, 0); + ItemDisplay itemDisplay = world.spawn(loc, ItemDisplay.class, display -> { + display.setItemStack(item.getItemStack()); + display.customName(Utils.getMini(item.getName())); + display.setCustomNameVisible(true); + }); + DEBUG_DISPLAYS.add(itemDisplay); + x += 3; + if (x > 20) { + x = 0; + y += 1.5; + } + } + } + + /** + * Tags for different {@link Items} groups + */ + public enum Tags { + /** + * Any sickle + */ + SICKLES(FLINT_SICKLE, STONE_SICKLE, IRON_SICKLE, DIAMOND_SICKLE), + /** + * Any reinforced leather armor + */ + REINFORCED_LEATHER_ARMOR(REINFORCED_LEATHER_BOOTS, REINFORCED_LEATHER_TROUSERS, + REINFORCED_LEATHER_TUNIC, REINFORCED_LEATHER_HELMET), + /** + * Any water bottle + */ + WATER_BOTTLE(DIRTY_WATER, MURKY_WATER, SALTY_WATER, CLEAN_WATER, PURIFIED_WATER), + /** + * Any drinkable item + */ + DRINKABLE(DIRTY_WATER, MURKY_WATER, SALTY_WATER, CLEAN_WATER, PURIFIED_WATER, WATER_BOWL, + COLD_MILK, HOT_MILK, COFFEE), + + /** + * Any legendary item + */ + LEGENDARY(BLAZE_SWORD, OBSIDIAN_MACE, VALKYRIES_AXE, ENDER_GIANT_BLADE, QUARTZ_PICKAXE); + + private final Item[] items; + + Tags(Item... items) { + this.items = items; + } + + /** + * Get all items tagged in this group + * + * @return All items tagged in this group + */ + public Item[] getItems() { + return items; + } + + /** + * Check if an ItemStack is tagged in a group of custom {@link Items} + * + * @param itemStack ItemStack to check + * @return True if item matches tag + */ + public boolean isTagged(ItemStack itemStack) { + for (Item item : this.items) { + if (item.is(itemStack)) return true; + } + return false; + } + + } + +} diff --git a/src/main/java/tk/shanebee/survival/item/Nutrition.java b/src/main/java/com/shanebeestudios/survival/api/item/Nutrition.java similarity index 78% rename from src/main/java/tk/shanebee/survival/item/Nutrition.java rename to src/main/java/com/shanebeestudios/survival/api/item/Nutrition.java index 8b425c7..7ff9a22 100644 --- a/src/main/java/tk/shanebee/survival/item/Nutrition.java +++ b/src/main/java/com/shanebeestudios/survival/api/item/Nutrition.java @@ -1,15 +1,20 @@ -package tk.shanebee.survival.item; +package com.shanebeestudios.survival.api.item; import com.google.common.base.Preconditions; +import io.papermc.paper.datacomponent.DataComponentTypes; import org.bukkit.Keyed; import org.bukkit.Material; import org.bukkit.NamespacedKey; +import org.bukkit.Registry; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.ItemType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import tk.shanebee.survival.Survival; +import com.shanebeestudios.survival.plugin.config.ItemConfig; +import com.shanebeestudios.survival.api.util.Utils; import java.util.ArrayList; +import java.util.Comparator; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; @@ -21,7 +26,7 @@ @SuppressWarnings("unused") public class Nutrition implements Keyed { - static void setup() { + public static void setup() { } private static final MapThese are created in the `block-tags.yml` file
+ */ +@SuppressWarnings("unused") +public class BlockTags { + + private BlockTags() { + } + + private static boolean initialized = false; + + /** + * @hidden + */ + public static void initialize() { + if (initialized) { + throw new IllegalStateException("BlockTags already initialized"); + } + initialized = true; + } + + /** + * Concrete blocks + */ + public static TagThese are created in the `item-tags.yml` file
+ */ +public class ItemTags { + + private ItemTags() { + } + + private static boolean initialized = false; + + /** + * @hidden + */ + public static void initialize() { + if (initialized) { + throw new IllegalStateException("BlockTags already initialized"); + } + initialized = true; + } + + public static final TagPrevents them from walking/jumping
+ * + * @param player Player to freeze + * @param freeze Whether to freeze or unfreeze + */ + public static void freezePlayer(@NotNull Player player, boolean freeze) { + AttributeInstance moveAttribute = player.getAttribute(Attribute.MOVEMENT_SPEED); + assert moveAttribute != null; + + if (freeze) { + moveAttribute.setBaseValue(0); + } else { + // Default player value from Minecraft + moveAttribute.setBaseValue(0.10000000149011612D); + } + + AttributeInstance jumpAttribute = player.getAttribute(Attribute.JUMP_STRENGTH); + assert jumpAttribute != null; + + if (freeze) { + jumpAttribute.setBaseValue(0); + } else { + jumpAttribute.setBaseValue(jumpAttribute.getDefaultValue()); + } + } + +} diff --git a/src/main/java/com/shanebeestudios/survival/api/util/Utils.java b/src/main/java/com/shanebeestudios/survival/api/util/Utils.java new file mode 100644 index 0000000..a8141cb --- /dev/null +++ b/src/main/java/com/shanebeestudios/survival/api/util/Utils.java @@ -0,0 +1,265 @@ +package com.shanebeestudios.survival.api.util; + +import net.kyori.adventure.audience.Audience; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.minimessage.MiniMessage; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.Particle; +import org.bukkit.Statistic; +import org.bukkit.entity.Player; +import org.bukkit.metadata.Metadatable; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import com.shanebeestudios.survival.plugin.SurvivalPlugin; + +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Pattern; + +/** + * General utility methods for the plugin + */ +@SuppressWarnings({"WeakerAccess", "unused"}) +public class Utils { + + private static final MiniMessage MINI_MESSAGE = MiniMessage.miniMessage(); + private static final LegacyComponentSerializer COMPONENT_SERIALIZER = LegacyComponentSerializer.legacySection(); + + private static final Pattern HEX_PATTERN = Pattern.compile("<#([A-Fa-f0-9]){6}>"); + + /** + * Get the drops for a certain material + * + * @param material Material that will be broken + * @param grown If the block is grown + * @return List of materials this material will drop + */ + public static ListFormatted in the same style as {@link String#format(String, Object...)}
+ *
+ * @param format Message format
+ * @param objects Objects in format
+ */
+ public static void logMini(String format, Object... objects) {
+ logMini(String.format(format, objects));
+ }
+
+ /**
+ * Spawn a particle at a location for all players
+ *
+ * @param location The location to spawn a particle at
+ * @param particle The particle to spawn
+ * @param amount The amount of particles
+ * @param offsetX Offset by x
+ * @param offsetY Offset by y
+ * @param offsetZ Offset by z
+ */
+ public static void spawnParticle(Location location, Particle particle, int amount, double offsetX, double offsetY, double offsetZ) {
+ assert location.getWorld() != null;
+ location.getWorld().spawnParticle(particle, location, amount, offsetX, offsetY, offsetZ);
+ }
+
+ /**
+ * Spawn a particle at a location for a player
+ *
+ * @param location The location to spawn a particle at
+ * @param particle The particle to spawn
+ * @param amount The amount of particles
+ * @param offsetX Offset by x
+ * @param offsetY Offset by y
+ * @param offsetZ Offset by z
+ * @param player The player to spawn a particle for
+ */
+ public static void spawnParticle(Location location, Particle particle, int amount, double offsetX, double offsetY, double offsetZ, Player player) {
+ player.spawnParticle(particle, location, amount, offsetX, offsetY, offsetZ);
+ }
+
+ /**
+ * Gets the minutes a player has played on the server
+ *
+ * @param player The player to check
+ * @return The number of minutes they have played on the server
+ */
+ @SuppressWarnings("IntegerDivisionInFloatingPointContext")
+ public static int getMinutesPlayed(Player player) {
+ int played = player.getStatistic(Statistic.PLAY_ONE_MINUTE);
+ return Math.round(played / 1200);
+ }
+
+ /**
+ * Check if server is running a minimum Minecraft version
+ *
+ * @param major Major version to check (Most likely just going to be 1)
+ * @param minor Minor version to check
+ * @return True if running this version or higher
+ */
+ public static boolean isRunningMinecraft(int major, int minor) {
+ return isRunningMinecraft(major, minor, 0);
+ }
+
+ /**
+ * Check if server is running a minimum Minecraft version
+ *
+ * @param major Major version to check (Most likely just going to be 1)
+ * @param minor Minor version to check
+ * @param revision Revision to check
+ * @return True if running this version or higher
+ */
+ public static boolean isRunningMinecraft(int major, int minor, int revision) {
+ String[] version = Bukkit.getServer().getBukkitVersion().split("-")[0].split("\\.");
+ int maj = Integer.parseInt(version[0]);
+ int min = Integer.parseInt(version[1]);
+ int rev;
+ try {
+ rev = Integer.parseInt(version[2]);
+ } catch (Exception ignore) {
+ rev = 0;
+ }
+ return maj > major || min > minor || (min == minor && rev >= revision);
+ }
+
+ public static boolean isRunningPaper() {
+ return classExists("io.papermc.paper.ServerBuildInfo");
+ }
+
+ /**
+ * Check if a class exists
+ *
+ * @param className The {@link Class#getCanonicalName() canonical name} of the class
+ * @return True if the class exists
+ */
+ public static boolean classExists(final String className) {
+ try {
+ Class.forName(className);
+ return true;
+ } catch (ClassNotFoundException ex) {
+ return false;
+ }
+ }
+
+ /**
+ * Check if a method exists
+ *
+ * @param c Class the method belongs to
+ * @param methodName Name of method
+ * @param parameterTypes Parameter types for this method
+ * @return True if the method exists
+ */
+ public static boolean methodExists(final Class> c, final String methodName, final Class>... parameterTypes) {
+ try {
+ c.getDeclaredMethod(methodName, parameterTypes);
+ return true;
+ } catch (NoSuchMethodException ex) {
+ return false;
+ }
+ }
+
+ /**
+ * Check if this entity is a Citizens NPC
+ *
+ * @param entity Entity to check
+ * @return True if entity is an NPC
+ */
+ public static boolean isCitizensNPC(Metadatable entity) {
+ return entity.hasMetadata("NPC");
+ }
+
+ /**
+ * Get a {@link NamespacedKey} linked to this plugin
+ *
+ * @param key Key to create
+ * @return New NamespacedKey linked to this plugin
+ */
+ public static NamespacedKey getNamespacedKey(String key) {
+ return new NamespacedKey("survival_plus", key);
+ }
+
+}
diff --git a/src/main/java/com/shanebeestudios/survival/api/util/package-info.java b/src/main/java/com/shanebeestudios/survival/api/util/package-info.java
new file mode 100644
index 0000000..4fb37f3
--- /dev/null
+++ b/src/main/java/com/shanebeestudios/survival/api/util/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * General utility classes
+ */
+package com.shanebeestudios.survival.api.util;
diff --git a/src/main/java/com/shanebeestudios/survival/plugin/SurvivalBootstrap.java b/src/main/java/com/shanebeestudios/survival/plugin/SurvivalBootstrap.java
new file mode 100644
index 0000000..b1b4699
--- /dev/null
+++ b/src/main/java/com/shanebeestudios/survival/plugin/SurvivalBootstrap.java
@@ -0,0 +1,16 @@
+package com.shanebeestudios.survival.plugin;
+
+import com.shanebeestudios.survival.plugin.registry.TagGenerator;
+import io.papermc.paper.plugin.bootstrap.BootstrapContext;
+import io.papermc.paper.plugin.bootstrap.PluginBootstrap;
+import org.jetbrains.annotations.NotNull;
+
+@SuppressWarnings({"UnstableApiUsage", "unused"})
+public class SurvivalBootstrap implements PluginBootstrap {
+
+ @Override
+ public void bootstrap(@NotNull BootstrapContext context) {
+ new TagGenerator(context);
+ }
+
+}
diff --git a/src/main/java/com/shanebeestudios/survival/plugin/SurvivalPlugin.java b/src/main/java/com/shanebeestudios/survival/plugin/SurvivalPlugin.java
new file mode 100644
index 0000000..cdbb784
--- /dev/null
+++ b/src/main/java/com/shanebeestudios/survival/plugin/SurvivalPlugin.java
@@ -0,0 +1,367 @@
+package com.shanebeestudios.survival.plugin;
+
+import com.shanebeestudios.survival.api.registry.ItemTags;
+import com.shanebeestudios.survival.plugin.commands.SurvivalCommand;
+import com.shanebeestudios.survival.plugin.config.Config;
+import com.shanebeestudios.survival.plugin.config.Lang;
+import com.shanebeestudios.survival.plugin.config.PlayerDataConfig;
+import com.shanebeestudios.survival.api.data.PlayerData;
+import com.shanebeestudios.survival.plugin.listeners.EventManager;
+import com.shanebeestudios.survival.plugin.managers.EffectManager;
+import com.shanebeestudios.survival.plugin.managers.LootManager;
+import com.shanebeestudios.survival.plugin.managers.MessageManager;
+import com.shanebeestudios.survival.plugin.managers.PapiPlaceholders;
+import com.shanebeestudios.survival.plugin.managers.PlayerManager;
+import com.shanebeestudios.survival.plugin.managers.RecipeManager;
+import com.shanebeestudios.survival.plugin.managers.ScoreBoardManager;
+import com.shanebeestudios.survival.plugin.tasks.TaskManager;
+import com.shanebeestudios.survival.api.registry.BlockTags;
+import com.shanebeestudios.survival.api.util.Utils;
+import dev.jorel.commandapi.CommandAPI;
+import dev.jorel.commandapi.CommandAPIBukkitConfig;
+import dev.jorel.commandapi.exceptions.UnsupportedVersionException;
+import org.bstats.bukkit.Metrics;
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.block.Block;
+import org.bukkit.command.CommandSender;
+import org.bukkit.configuration.serialization.ConfigurationSerialization;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Listener;
+import org.bukkit.plugin.java.JavaPlugin;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * Main plugin class
+ */
+@SuppressWarnings("UnstableApiUsage")
+public class SurvivalPlugin extends JavaPlugin implements Listener {
+
+ static {
+ ConfigurationSerialization.registerClass(PlayerData.class);
+ }
+
+ private static SurvivalPlugin INSTANCE;
+
+ // Lists & Map
+ private Map