Initial (if overdue) commit
This commit is contained in:
commit
3e21e35757
26 changed files with 1474 additions and 0 deletions
120
.gitignore
vendored
Normal file
120
.gitignore
vendored
Normal file
|
@ -0,0 +1,120 @@
|
|||
# User-specific stuff
|
||||
.idea/
|
||||
.kotlin/
|
||||
|
||||
*.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*
|
||||
replay_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/
|
||||
runs/
|
||||
|
||||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||
!gradle-wrapper.jar
|
9
LICENSE
Normal file
9
LICENSE
Normal file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2025 Nick
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
65
build.gradle
Normal file
65
build.gradle
Normal file
|
@ -0,0 +1,65 @@
|
|||
plugins {
|
||||
id 'java'
|
||||
id("xyz.jpenilla.run-paper") version "2.3.1"
|
||||
id 'org.jetbrains.kotlin.jvm'
|
||||
}
|
||||
|
||||
group = 'com.ncguy'
|
||||
version = '1.0-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'https://jitpack.io' }
|
||||
maven {
|
||||
name = "papermc-repo"
|
||||
url = "https://repo.papermc.io/repository/maven-public/"
|
||||
}
|
||||
maven {
|
||||
name = "sonatype"
|
||||
url = "https://oss.sonatype.org/content/groups/public/"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.5-R0.1-SNAPSHOT")
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||
|
||||
implementation 'com.github.DigitalSmile:hexagon:v0.2.1'
|
||||
}
|
||||
|
||||
tasks {
|
||||
runServer {
|
||||
// Configure the Minecraft version for our task.
|
||||
// This is the only required configuration besides applying the plugin.
|
||||
// Your plugin's jar (or shadowJar if present) will be used automatically.
|
||||
minecraftVersion("1.21.5")
|
||||
}
|
||||
}
|
||||
|
||||
def targetJavaVersion = 21
|
||||
java {
|
||||
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
|
||||
if (JavaVersion.current() < javaVersion) {
|
||||
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = 'UTF-8'
|
||||
|
||||
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
|
||||
options.release.set(targetJavaVersion)
|
||||
}
|
||||
}
|
||||
|
||||
processResources {
|
||||
def props = [version: version]
|
||||
inputs.properties props
|
||||
filteringCharset 'UTF-8'
|
||||
filesMatching('plugin.yml') {
|
||||
expand props
|
||||
}
|
||||
}
|
||||
kotlin {
|
||||
jvmToolchain(21)
|
||||
}
|
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.8-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
249
gradlew
vendored
Normal file
249
gradlew
vendored
Normal 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/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 "${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. 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
|
9
settings.gradle
Normal file
9
settings.gradle
Normal file
|
@ -0,0 +1,9 @@
|
|||
pluginManagement {
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.jvm' version '2.1.21'
|
||||
}
|
||||
}
|
||||
plugins {
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
|
||||
}
|
||||
rootProject.name = 'UsefulSkyblock'
|
20
src/main/java/com/ncguy/usefulSkyblock/HexagonalWorld.java
Normal file
20
src/main/java/com/ncguy/usefulSkyblock/HexagonalWorld.java
Normal file
|
@ -0,0 +1,20 @@
|
|||
package com.ncguy.usefulSkyblock;
|
||||
|
||||
import org.digitalsmile.hexgrid.HexagonGrid;
|
||||
import org.digitalsmile.hexgrid.layout.Orientation;
|
||||
import org.digitalsmile.hexgrid.shapes.hexagonal.HexagonalShape;
|
||||
|
||||
public class HexagonalWorld {
|
||||
|
||||
public void Init() {
|
||||
var hexagonGrid = new HexagonGrid.HexagonGridBuilder<>()
|
||||
.shape(new HexagonalShape(5), Orientation.FLAT)
|
||||
.hexagonWidth(150)
|
||||
.build();
|
||||
hexagonGrid.generateHexagons();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
113
src/main/java/com/ncguy/usefulSkyblock/StructureRef.java
Normal file
113
src/main/java/com/ncguy/usefulSkyblock/StructureRef.java
Normal file
|
@ -0,0 +1,113 @@
|
|||
package com.ncguy.usefulSkyblock;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.RegionAccessor;
|
||||
import org.bukkit.block.structure.Mirror;
|
||||
import org.bukkit.block.structure.StructureRotation;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.structure.Palette;
|
||||
import org.bukkit.structure.Structure;
|
||||
import org.bukkit.structure.StructureManager;
|
||||
import org.bukkit.util.BlockTransformer;
|
||||
import org.bukkit.util.BlockVector;
|
||||
import org.bukkit.util.EntityTransformer;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
|
||||
public class StructureRef implements Structure {
|
||||
|
||||
protected Structure actualStructure;
|
||||
protected NamespacedKey name;
|
||||
|
||||
public StructureRef(NamespacedKey name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
private Structure getActualStructure() {
|
||||
if (actualStructure == null) {
|
||||
StructureManager structureManager = Bukkit.getStructureManager();
|
||||
actualStructure = structureManager.loadStructure(name);
|
||||
if(actualStructure == null) {
|
||||
try (InputStream resourceAsStream = getClass().getResourceAsStream("/datapacks/usefulskyblock/data/" + name.getNamespace() + "/structures/" + name.getKey() + ".nbt")) {
|
||||
actualStructure = structureManager.loadStructure(Objects.requireNonNull(resourceAsStream));
|
||||
structureManager.registerStructure(name, actualStructure);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return actualStructure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull BlockVector getSize() {
|
||||
return getActualStructure().getSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<Palette> getPalettes() {
|
||||
return getActualStructure().getPalettes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPaletteCount() {
|
||||
return getActualStructure().getPaletteCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<Entity> getEntities() {
|
||||
return getActualStructure().getEntities();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEntityCount() {
|
||||
return getActualStructure().getEntityCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void place(@NotNull Location location, boolean includeEntities, @NotNull StructureRotation structureRotation, @NotNull Mirror mirror, int palette, float integrity, @NotNull Random random) {
|
||||
getActualStructure().place(location, includeEntities, structureRotation, mirror, palette, integrity, random);
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
@Override
|
||||
public void place(@NotNull Location location, boolean includeEntities, @NotNull StructureRotation structureRotation, @NotNull Mirror mirror, int palette, float integrity, @NotNull Random random, @NotNull Collection<BlockTransformer> blockTransformers, @NotNull Collection<EntityTransformer> entityTransformers) {
|
||||
getActualStructure().place(location, includeEntities, structureRotation, mirror, palette, integrity, random, blockTransformers, entityTransformers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void place(@NotNull RegionAccessor regionAccessor, @NotNull BlockVector location, boolean includeEntities, @NotNull StructureRotation structureRotation, @NotNull Mirror mirror, int palette, float integrity, @NotNull Random random) {
|
||||
getActualStructure().place(regionAccessor, location, includeEntities, structureRotation, mirror, palette, integrity, random);
|
||||
}
|
||||
|
||||
@ApiStatus.Experimental
|
||||
@Override
|
||||
public void place(@NotNull RegionAccessor regionAccessor, @NotNull BlockVector location, boolean includeEntities, @NotNull StructureRotation structureRotation, @NotNull Mirror mirror, int palette, float integrity, @NotNull Random random, @NotNull Collection<BlockTransformer> blockTransformers, @NotNull Collection<EntityTransformer> entityTransformers) {
|
||||
getActualStructure().place(regionAccessor, location, includeEntities, structureRotation, mirror, palette, integrity, random, blockTransformers, entityTransformers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fill(@NotNull Location corner1, @NotNull Location corner2, boolean includeEntities) {
|
||||
getActualStructure().fill(corner1, corner2, includeEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fill(@NotNull Location origin, @NotNull BlockVector size, boolean includeEntities) {
|
||||
getActualStructure().fill(origin, size, includeEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull PersistentDataContainer getPersistentDataContainer() {
|
||||
return getActualStructure().getPersistentDataContainer();
|
||||
}
|
||||
}
|
27
src/main/java/com/ncguy/usefulSkyblock/UsefulSkyblock.java
Normal file
27
src/main/java/com/ncguy/usefulSkyblock/UsefulSkyblock.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
package com.ncguy.usefulSkyblock;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public final class UsefulSkyblock extends JavaPlugin implements Listener {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Plugin startup logic
|
||||
Bukkit.getPluginManager().registerEvents(this, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Plugin shutdown logic
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
event.getPlayer().sendMessage(Component.text("Hello, " + event.getPlayer().getName() + "!"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package com.ncguy.usefulSkyblock;
|
||||
|
||||
import com.ncguy.usefulSkyblock.command.SkyblockAdminCommand;
|
||||
import com.ncguy.usefulSkyblock.command.SkyblockGenCommand;
|
||||
import com.ncguy.usefulSkyblock.hexagon.HexagonRenderer;
|
||||
import io.papermc.paper.datapack.DatapackRegistrar;
|
||||
import io.papermc.paper.datapack.DiscoveredDatapack;
|
||||
import io.papermc.paper.plugin.bootstrap.BootstrapContext;
|
||||
import io.papermc.paper.plugin.bootstrap.PluginBootstrap;
|
||||
import io.papermc.paper.plugin.bootstrap.PluginProviderContext;
|
||||
import io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager;
|
||||
import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Objects;
|
||||
|
||||
public class UsefulSkyblockBootstrap implements PluginBootstrap {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(UsefulSkyblockBootstrap.class);
|
||||
|
||||
@Override
|
||||
public void bootstrap(BootstrapContext context) {
|
||||
final LifecycleEventManager<@NotNull BootstrapContext> manager = context.getLifecycleManager();
|
||||
|
||||
manager.registerEventHandler(LifecycleEvents.COMMANDS, event -> {
|
||||
event.registrar().register(SkyblockGenCommand.create());
|
||||
event.registrar().register(SkyblockAdminCommand.create());
|
||||
event.registrar().register(HexagonRenderer.create());
|
||||
});
|
||||
|
||||
manager.registerEventHandler(LifecycleEvents.DATAPACK_DISCOVERY, event -> {
|
||||
DatapackRegistrar registrar = event.registrar();
|
||||
try{
|
||||
final URI uri = Objects.requireNonNull(
|
||||
UsefulSkyblockBootstrap.class.getResource("/datapacks/usefulskyblock")).toURI();
|
||||
DiscoveredDatapack pack = registrar.discoverPack(uri, "usefulskyblock");
|
||||
log.info("Discovered datapack: {}", pack);
|
||||
}catch(final URISyntaxException | IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaPlugin createPlugin(PluginProviderContext context) {
|
||||
return new UsefulSkyblock();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.ncguy.usefulSkyblock;
|
||||
|
||||
import io.papermc.paper.plugin.loader.PluginClasspathBuilder;
|
||||
import io.papermc.paper.plugin.loader.PluginLoader;
|
||||
|
||||
public class UsefulSkyblockLoader implements PluginLoader {
|
||||
|
||||
@Override
|
||||
public void classloader(PluginClasspathBuilder classpathBuilder) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.ncguy.usefulSkyblock.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class AbstractSkyblockCommand {
|
||||
|
||||
private static Map<Type, AbstractSkyblockCommand> CommandCache = new HashMap<>();
|
||||
|
||||
public static <T extends AbstractSkyblockCommand> T Get(Class<T> type) {
|
||||
//noinspection unchecked
|
||||
if(!CommandCache.containsKey(type))
|
||||
CommandCache.put(type, CreateInstance(type));
|
||||
return (T) CommandCache.get(type);
|
||||
}
|
||||
|
||||
private static <T extends AbstractSkyblockCommand> T CreateInstance(Class<T> type) {
|
||||
try {
|
||||
return type.getConstructor().newInstance();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected AbstractSkyblockCommand() {
|
||||
|
||||
}
|
||||
|
||||
protected NamespacedKey key(String name) {
|
||||
return new NamespacedKey("usefulskyblock", name);
|
||||
}
|
||||
|
||||
protected NamespacedKey overworldKey = key("void");
|
||||
|
||||
private Server serverInstance;
|
||||
protected Server getServer() {
|
||||
if(serverInstance == null)
|
||||
serverInstance = Bukkit.getServer();
|
||||
return serverInstance;
|
||||
}
|
||||
|
||||
private World worldInstance;
|
||||
protected World getOverworld() {
|
||||
if(worldInstance == null)
|
||||
worldInstance = getServer().getWorld(overworldKey);
|
||||
return worldInstance;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.ncguy.usefulSkyblock.command;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface CommandFunction {
|
||||
|
||||
String value();
|
||||
|
||||
}
|
|
@ -0,0 +1,240 @@
|
|||
package com.ncguy.usefulSkyblock.command;
|
||||
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.context.StringRange;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.suggestion.Suggestion;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||
import com.ncguy.usefulSkyblock.StructureRef;
|
||||
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||
import io.papermc.paper.command.brigadier.Commands;
|
||||
import io.papermc.paper.command.brigadier.argument.ArgumentTypes;
|
||||
import io.papermc.paper.command.brigadier.argument.CustomArgumentType;
|
||||
import io.papermc.paper.math.BlockPosition;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.structure.Mirror;
|
||||
import org.bukkit.block.structure.StructureRotation;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.structure.Structure;
|
||||
import org.bukkit.structure.StructureManager;
|
||||
import org.bukkit.util.BlockVector;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.codehaus.plexus.util.cli.Arg;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.xml.stream.events.Namespace;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class SkyblockAdminCommand extends AbstractSkyblockCommand {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SkyblockAdminCommand.class);
|
||||
|
||||
public int executeStructuresList(CommandContext<CommandSourceStack> ctx) {
|
||||
|
||||
StructureManager structureManager = getServer().getStructureManager();
|
||||
Map<NamespacedKey, Structure> structureMap = structureManager.getStructures();
|
||||
|
||||
// Set<NamespacedKey> filteredKeys = structureMap.keySet().stream().filter(k -> k.getNamespace() == "usefulskyblock").collect(Collectors.toSet());
|
||||
Set<NamespacedKey> filteredKeys = structureMap.keySet();
|
||||
|
||||
ctx.getSource().getExecutor().sendMessage("Found " + filteredKeys.size() + " structures");
|
||||
filteredKeys.forEach(k -> ctx.getSource().getExecutor().sendMessage(k.toString()));
|
||||
|
||||
log.info("Classic: {}", structureManager.loadStructure(key("classic")) != null);
|
||||
log.info("Classic-sand: {}", structureManager.loadStructure(key("classic-sand")) != null);
|
||||
log.info("skyblock: {}", structureManager.loadStructure(key("skyblock")) != null);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int executeSave(CommandContext<CommandSourceStack> ctx) {
|
||||
int radius = ctx.getArgument("radius", Integer.class);
|
||||
String name = ctx.getArgument("name", String.class);
|
||||
|
||||
StructureManager structureManager = getServer().getStructureManager();
|
||||
|
||||
Structure structure = structureManager.createStructure();
|
||||
|
||||
Location origin = ctx.getSource().getLocation();
|
||||
|
||||
Location start = origin.clone().subtract(radius, radius, radius);
|
||||
Location end = origin.clone().add(radius, radius, radius);
|
||||
|
||||
structure.fill(start, end, true);
|
||||
|
||||
ctx.getSource().getExecutor().sendMessage("From " + start + " to " + end);
|
||||
ctx.getSource().getExecutor().sendMessage("Palette count: " + (long) structure.getPaletteCount());
|
||||
ctx.getSource().getExecutor().sendMessage("Block count: " + structure.getPalettes().getFirst().getBlockCount());
|
||||
|
||||
NamespacedKey nmKey = key(name);
|
||||
|
||||
try {
|
||||
File f = new File("structures/" + nmKey.getKey() + ".nbt");
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
f.getParentFile().mkdirs();
|
||||
structureManager.saveStructure(f, structure);
|
||||
log.info("Saved structure {} to {}", name, f.getAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int executeDropStructure(CommandContext<CommandSourceStack> ctx) {
|
||||
|
||||
Structure structure = ctx.getArgument("structure", Structure.class);
|
||||
|
||||
if (structure == null) {
|
||||
ctx.getSource().getExecutor().sendMessage("Structure not found");
|
||||
return -1;
|
||||
}
|
||||
|
||||
Location loc = ctx.getSource().getLocation();
|
||||
Vector halfSize = structure.getSize().divide(new Vector(2, 2, 2));
|
||||
loc.subtract(halfSize);
|
||||
|
||||
structure.place(loc, false, StructureRotation.NONE, Mirror.NONE, 0, 1, new Random(System.currentTimeMillis()));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int executePlaceAnchor(CommandContext<CommandSourceStack> ctx) {
|
||||
ctx.getSource().getExecutor().sendMessage("Placing anchor");
|
||||
Location target = ctx.getSource().getExecutor().getLocation().subtract(0, 1, 0);
|
||||
target.getBlock().setType(Material.STONE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int executeP0(CommandContext<CommandSourceStack> ctx) {
|
||||
Entity executor = ctx.getSource().getExecutor();
|
||||
executor.sendMessage("Placing P0");
|
||||
|
||||
if (executor instanceof Player) {
|
||||
Player p = (Player) executor;
|
||||
RayTraceResult rayTraceResult = p.rayTraceBlocks(8);
|
||||
|
||||
Vector hitPosition = rayTraceResult.getHitPosition();
|
||||
p.getPersistentDataContainer().set(key("_p0"), PersistentDataType.INTEGER_ARRAY, new int[]{hitPosition.getBlockX(), hitPosition.getBlockY(), hitPosition.getBlockZ()});
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int executeP1(CommandContext<CommandSourceStack> ctx) {
|
||||
Entity executor = ctx.getSource().getExecutor();
|
||||
executor.sendMessage("Placing P1");
|
||||
|
||||
if (executor instanceof Player) {
|
||||
Player p = (Player) executor;
|
||||
RayTraceResult rayTraceResult = p.rayTraceBlocks(8);
|
||||
|
||||
Vector hitPosition = rayTraceResult.getHitPosition();
|
||||
p.getPersistentDataContainer().set(key("_p1"), PersistentDataType.INTEGER_ARRAY, new int[]{hitPosition.getBlockX(), hitPosition.getBlockY(), hitPosition.getBlockZ()});
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int executePSave(CommandContext<CommandSourceStack> ctx) {
|
||||
Entity executor = ctx.getSource().getExecutor();
|
||||
String name = ctx.getArgument("name", String.class);
|
||||
executor.sendMessage("Saving structure");
|
||||
|
||||
if (!(executor instanceof Player)) return 0;
|
||||
Player p = (Player) executor;
|
||||
|
||||
int[] p0 = p.getPersistentDataContainer().get(key("_p0"), PersistentDataType.INTEGER_ARRAY);
|
||||
int[] p1 = p.getPersistentDataContainer().get(key("_p1"), PersistentDataType.INTEGER_ARRAY);
|
||||
|
||||
if (p0 == null) {
|
||||
executor.sendMessage("No P0 found");
|
||||
return -1;
|
||||
} else if (p1 == null) {
|
||||
executor.sendMessage("No P1 found");
|
||||
return -1;
|
||||
}
|
||||
|
||||
Structure structure = getServer().getStructureManager().createStructure();
|
||||
|
||||
Location p0Loc = new Location(getOverworld(), p0[0], p0[1], p0[2]);
|
||||
Location p1Loc = new Location(getOverworld(), p1[0], p1[1], p1[2]);
|
||||
|
||||
structure.fill(p0Loc, p1Loc, true);
|
||||
|
||||
ctx.getSource().getExecutor().sendMessage("From " + p0Loc + " to " + p1Loc);
|
||||
ctx.getSource().getExecutor().sendMessage("Palette count: " + (long) structure.getPaletteCount());
|
||||
ctx.getSource().getExecutor().sendMessage("Block count: " + structure.getPalettes().getFirst().getBlockCount());
|
||||
|
||||
NamespacedKey nmKey = key(name);
|
||||
|
||||
try {
|
||||
File f = new File("structures/" + nmKey.getKey() + ".nbt");
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
f.getParentFile().mkdirs();
|
||||
getServer().getStructureManager().saveStructure(f, structure);
|
||||
log.info("Saved structure {} to {}", name, f.getAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static LiteralCommandNode<CommandSourceStack> create() {
|
||||
var root = Commands.literal("skyblock-admin");
|
||||
var cmd = Get(SkyblockAdminCommand.class);
|
||||
|
||||
root.requires(cmd::auth);
|
||||
|
||||
var structures = Commands.literal("structures");
|
||||
structures.then(Commands.literal("list").executes(cmd::executeStructuresList));
|
||||
structures.then(Commands.literal("save").then(Commands.argument("radius", IntegerArgumentType.integer()).then(Commands.argument("name", StringArgumentType.word()).executes(cmd::executeSave))));
|
||||
structures.then(Commands.literal("load").then(Commands.argument("structure", new SkyblockStructureArgument()).executes(cmd::executeDropStructure)));
|
||||
structures.then(Commands.literal("anchor").executes(cmd::executePlaceAnchor));
|
||||
|
||||
structures.then(Commands.literal("p0").executes(cmd::executeP0));
|
||||
structures.then(Commands.literal("p1").executes(cmd::executeP1));
|
||||
structures.then(Commands.literal("pSave").then(Commands.argument("name", StringArgumentType.word()).executes(cmd::executePSave)));
|
||||
|
||||
root.then(structures);
|
||||
|
||||
return root.build();
|
||||
}
|
||||
|
||||
private boolean auth(CommandSourceStack stack) {
|
||||
return stack.getSender().isOp();
|
||||
}
|
||||
|
||||
|
||||
public static final class SkyblockStructureArgument implements CustomArgumentType<Structure, String> {
|
||||
|
||||
@Override
|
||||
public Structure parse(StringReader reader) throws CommandSyntaxException {
|
||||
NamespacedKey key = new NamespacedKey("usefulskyblock", reader.readString());
|
||||
return new StructureRef(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArgumentType<String> getNativeType() {
|
||||
return StringArgumentType.word();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
package com.ncguy.usefulSkyblock.command;
|
||||
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||
import com.ncguy.usefulSkyblock.StructureRef;
|
||||
import com.ncguy.usefulSkyblock.utils.MathsUtils;
|
||||
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||
import io.papermc.paper.command.brigadier.Commands;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.structure.Mirror;
|
||||
import org.bukkit.block.structure.StructureRotation;
|
||||
import org.bukkit.structure.Structure;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class SkyblockGenCommand extends AbstractSkyblockCommand {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SkyblockGenCommand.class);
|
||||
|
||||
private StructureRef[] centralIslands = {
|
||||
new StructureRef(key("classic")),
|
||||
};
|
||||
|
||||
private StructureRef[] t1Islands = {
|
||||
new StructureRef(key("classic-sand")),
|
||||
};
|
||||
|
||||
private StructureRef[] t2Islands = {
|
||||
};
|
||||
|
||||
private StructureRef[] t3Islands = {
|
||||
};
|
||||
|
||||
|
||||
private float playerIslandSpacing = 1024;
|
||||
|
||||
private static final int T1_ISLAND_SLOTS = 8;
|
||||
private static final int T2_ISLAND_SLOTS = 16;
|
||||
private static final int T3_ISLAND_SLOTS = 32;
|
||||
|
||||
private static float T1_ISLAND_SPACING = T1_ISLAND_SLOTS << 3;
|
||||
private static float T2_ISLAND_SPACING = T2_ISLAND_SLOTS << 3;
|
||||
private static float T3_ISLAND_SPACING = T3_ISLAND_SLOTS << 3;
|
||||
|
||||
private Location placeStructureAtLocation(Structure structure, Location loc) {
|
||||
Vector extents = structure.getSize().clone().multiply(0.5);
|
||||
loc.subtract(extents);
|
||||
|
||||
structure.place(loc, true, randomEnum(StructureRotation.class), randomEnum(Mirror.class), 0, 1, new Random());
|
||||
return loc;
|
||||
}
|
||||
|
||||
private <T extends Enum<?>> T randomEnum(Class<T> enumCls) {
|
||||
assert(enumCls.isEnum());
|
||||
return randomElement(enumCls.getEnumConstants());
|
||||
}
|
||||
|
||||
private <T> T randomElement(T[] array) {
|
||||
int idx = (int) (Math.random() * array.length);
|
||||
return array[idx];
|
||||
}
|
||||
|
||||
private Location generateIslandNetwork(Location origin) {
|
||||
Location centralIslandSpawnLoc = placeStructureAtLocation(randomElement(centralIslands), origin.clone());
|
||||
|
||||
int[] t1Slots = MathsUtils.sampleUniqueInts(T1_ISLAND_SLOTS, t1Islands.length);
|
||||
// int[] t2Slots = MathsUtils.sampleUniqueInts(T2_ISLAND_SLOTS, t2Islands.length);
|
||||
// int[] t3Slots = MathsUtils.sampleUniqueInts(T3_ISLAND_SLOTS, t3Islands.length);
|
||||
double t1Step = 360.0 / T1_ISLAND_SLOTS;
|
||||
|
||||
Supplier<Float> yNoiseFunc = () -> 0f;
|
||||
|
||||
for (int i = 0; i < t1Islands.length; i++) {
|
||||
StructureRef island = t1Islands[i];
|
||||
int slot = t1Slots[i];
|
||||
double angle = t1Step * slot;
|
||||
double x = Math.cos(angle) * T1_ISLAND_SPACING;
|
||||
double z = Math.sin(angle) * T1_ISLAND_SPACING;
|
||||
double y = yNoiseFunc.get();
|
||||
Location pos = origin.clone().add(x, y, z);
|
||||
placeStructureAtLocation(island, pos);
|
||||
}
|
||||
return centralIslandSpawnLoc;
|
||||
}
|
||||
|
||||
public int executeGenerate(CommandContext<CommandSourceStack> ctx) {
|
||||
ctx.getSource().getExecutor().sendMessage("Generating skyblock world for " + ctx.getSource().getExecutor().getName() + "...");
|
||||
|
||||
// TODO Add team-specific offsets
|
||||
Location originLoc = new Location(getOverworld(), 0, 128, 0);
|
||||
Location tpLoc = generateIslandNetwork(originLoc);
|
||||
ctx.getSource().getExecutor().teleport(tpLoc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static LiteralCommandNode<CommandSourceStack> create() {
|
||||
var root = Commands.literal("skyblock");
|
||||
|
||||
var cmd = Get(SkyblockGenCommand.class);
|
||||
root.then(Commands.literal("generate").executes(cmd::executeGenerate));
|
||||
|
||||
return root.build();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package com.ncguy.usefulSkyblock.hexagon;
|
||||
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||
import io.papermc.paper.command.brigadier.Commands;
|
||||
import io.papermc.paper.entity.LookAnchor;
|
||||
import io.papermc.paper.util.Tick;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.BlockDisplay;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.util.Transformation;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.joml.AxisAngle4f;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HexagonRenderer {
|
||||
|
||||
public static Entity spawnLineEntity(Location from, Location to) {
|
||||
|
||||
Location mid = from.clone().add(to.clone().multiply(0.5));
|
||||
|
||||
float distance = (float) from.distance(to);
|
||||
|
||||
return mid.getWorld().spawn(mid, BlockDisplay.class, dsp -> {
|
||||
dsp.setBlock(Material.AMETHYST_BLOCK.createBlockData());
|
||||
var t = new Transformation(
|
||||
new Vector3f(),
|
||||
new AxisAngle4f(),
|
||||
new Vector3f(distance / 2, 1, 1),
|
||||
new AxisAngle4f()
|
||||
);
|
||||
dsp.setTransformation(t);
|
||||
dsp.lookAt(to.x(), to.y(), to.z(), LookAnchor.FEET);
|
||||
});
|
||||
}
|
||||
|
||||
public static LiteralCommandNode<CommandSourceStack> create() {
|
||||
return Commands.literal("sample").then(
|
||||
Commands.argument("radius", IntegerArgumentType.integer(1)).then(
|
||||
Commands.argument("count", IntegerArgumentType.integer(1)).executes(ctx -> {
|
||||
int radius = ctx.getArgument("radius", Integer.class);
|
||||
int count = ctx.getArgument("count", Integer.class);
|
||||
|
||||
Location loc = ctx.getSource().getLocation();
|
||||
|
||||
List<BlockDisplay> entities = new ArrayList<>();
|
||||
|
||||
World world = loc.getWorld();
|
||||
|
||||
float step = 360.0f / count;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
double rad = Math.toRadians(step * i);
|
||||
double x = Math.cos(rad) * radius;
|
||||
double y = Math.sin(rad) * radius;
|
||||
Vector offset = new Vector(x, 0, y);
|
||||
Location newLoc = loc.clone().add(offset);
|
||||
entities.add(world.spawn(newLoc, BlockDisplay.class, dsp -> {
|
||||
dsp.setBlock(Material.AMETHYST_BLOCK.createBlockData());
|
||||
dsp.setTransformation(new Transformation(
|
||||
new Vector3f(),
|
||||
new AxisAngle4f(),
|
||||
new Vector3f(1, 1, 1),
|
||||
new AxisAngle4f()
|
||||
));
|
||||
}));
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLater(Bukkit.getPluginManager().getPlugin("UsefulSkyblock"), () -> entities.forEach(Entity::remove), Tick.tick().fromDuration(Duration.ofSeconds(10)));
|
||||
|
||||
return 0;
|
||||
}))).build();
|
||||
}
|
||||
|
||||
}
|
117
src/main/java/com/ncguy/usefulSkyblock/utils/BoxVisualizer.java
Normal file
117
src/main/java/com/ncguy/usefulSkyblock/utils/BoxVisualizer.java
Normal file
|
@ -0,0 +1,117 @@
|
|||
package com.ncguy.usefulSkyblock.utils;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.BlockDisplay;
|
||||
import org.bukkit.entity.Display;
|
||||
import org.bukkit.util.Transformation;
|
||||
import org.joml.AxisAngle4f;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BoxVisualizer {
|
||||
private final List<BlockDisplay> displays = new ArrayList<>();
|
||||
private static final Material LINE_MATERIAL = Material.RED_CONCRETE;
|
||||
private static final float LINE_THICKNESS = 0.1f; // Thickness of the lines
|
||||
|
||||
/**
|
||||
* Creates a box visualization between two corners
|
||||
* @param corner1 First corner of the box
|
||||
* @param corner2 Second corner of the box
|
||||
* @return List of created display entities
|
||||
*/
|
||||
public List<BlockDisplay> createBox(Location corner1, Location corner2) {
|
||||
cleanup(); // Remove any existing displays
|
||||
|
||||
World world = corner1.getWorld();
|
||||
if (world == null || !world.equals(corner2.getWorld())) {
|
||||
throw new IllegalArgumentException("Locations must be in the same world");
|
||||
}
|
||||
|
||||
// Get min and max coordinates
|
||||
double minX = Math.min(corner1.getX(), corner2.getX());
|
||||
double minY = Math.min(corner1.getY(), corner2.getY());
|
||||
double minZ = Math.min(corner1.getZ(), corner2.getZ());
|
||||
double maxX = Math.max(corner1.getX(), corner2.getX());
|
||||
double maxY = Math.max(corner1.getY(), corner2.getY());
|
||||
double maxZ = Math.max(corner1.getZ(), corner2.getZ());
|
||||
|
||||
// Create the 12 edges of the box
|
||||
// Bottom rectangle
|
||||
createEdge(world, minX, minY, minZ, maxX, minY, minZ); // Bottom front
|
||||
createEdge(world, minX, minY, maxZ, maxX, minY, maxZ); // Bottom back
|
||||
createEdge(world, minX, minY, minZ, minX, minY, maxZ); // Bottom left
|
||||
createEdge(world, maxX, minY, minZ, maxX, minY, maxZ); // Bottom right
|
||||
|
||||
// Top rectangle
|
||||
createEdge(world, minX, maxY, minZ, maxX, maxY, minZ); // Top front
|
||||
createEdge(world, minX, maxY, maxZ, maxX, maxY, maxZ); // Top back
|
||||
createEdge(world, minX, maxY, minZ, minX, maxY, maxZ); // Top left
|
||||
createEdge(world, maxX, maxY, minZ, maxX, maxY, maxZ); // Top right
|
||||
|
||||
// Vertical edges
|
||||
createEdge(world, minX, minY, minZ, minX, maxY, minZ); // Front left
|
||||
createEdge(world, maxX, minY, minZ, maxX, maxY, minZ); // Front right
|
||||
createEdge(world, minX, minY, maxZ, minX, maxY, maxZ); // Back left
|
||||
createEdge(world, maxX, minY, maxZ, maxX, maxY, maxZ); // Back right
|
||||
|
||||
return new ArrayList<>(displays);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a single edge of the box
|
||||
*/
|
||||
private void createEdge(World world, double x1, double y1, double z1, double x2, double y2, double z2) {
|
||||
// Calculate center point and length
|
||||
double centerX = (x1 + x2) / 2;
|
||||
double centerY = (y1 + y2) / 2;
|
||||
double centerZ = (z1 + z2) / 2;
|
||||
|
||||
// Calculate length and rotation
|
||||
double length = Math.sqrt(
|
||||
Math.pow(x2 - x1, 2) +
|
||||
Math.pow(y2 - y1, 2) +
|
||||
Math.pow(z2 - z1, 2)
|
||||
);
|
||||
|
||||
Location center = new Location(world, centerX, centerY, centerZ);
|
||||
BlockDisplay display = world.spawn(center, BlockDisplay.class, entity -> {
|
||||
entity.setBlock(LINE_MATERIAL.createBlockData());
|
||||
|
||||
// Calculate rotation angles
|
||||
double dx = x2 - x1;
|
||||
double dy = y2 - y1;
|
||||
double dz = z2 - z1;
|
||||
|
||||
// Calculate rotation angles (in radians)
|
||||
double yaw = Math.atan2(dz, dx);
|
||||
double pitch = Math.atan2(dy, Math.sqrt(dx * dx + dz * dz));
|
||||
|
||||
// Create transformation
|
||||
Transformation transformation = new Transformation(
|
||||
new Vector3f(0, 0, 0), // Translation (already at center)
|
||||
new AxisAngle4f((float)pitch, 0, 1, 0), // Pitch rotation
|
||||
new Vector3f((float)length, LINE_THICKNESS, LINE_THICKNESS), // Scale
|
||||
new AxisAngle4f(0, 0, 0, 1) // No additional rotation
|
||||
);
|
||||
|
||||
entity.setTransformation(transformation);
|
||||
entity.setBrightness(new Display.Brightness(15, 15)); // Full brightness
|
||||
entity.setViewRange(64f); // Visible up to 64 blocks away
|
||||
entity.setPersistent(false); // Will be removed when chunk unloads
|
||||
});
|
||||
|
||||
displays.add(display);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all display entities created by this visualizer
|
||||
*/
|
||||
public void cleanup() {
|
||||
displays.forEach(BlockDisplay::remove);
|
||||
displays.clear();
|
||||
}
|
||||
}
|
49
src/main/java/com/ncguy/usefulSkyblock/utils/MathsUtils.java
Normal file
49
src/main/java/com/ncguy/usefulSkyblock/utils/MathsUtils.java
Normal file
|
@ -0,0 +1,49 @@
|
|||
package com.ncguy.usefulSkyblock.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class MathsUtils {
|
||||
|
||||
public static int[] sampleUniqueInts(int max, int count) {
|
||||
if (count > max) {
|
||||
throw new IllegalArgumentException("Count cannot be larger than max");
|
||||
}
|
||||
if (count < 0 || max < 0) {
|
||||
throw new IllegalArgumentException("Count and max must be positive");
|
||||
}
|
||||
|
||||
// For full range, return sequential array
|
||||
if (count == max) {
|
||||
return IntStream.range(0, max).toArray();
|
||||
}
|
||||
|
||||
// For empty request, return empty array
|
||||
if (count == 0) {
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
// Create array with all possible numbers
|
||||
int[] numbers = new int[max];
|
||||
for (int i = 0; i < max; i++) {
|
||||
numbers[i] = i;
|
||||
}
|
||||
|
||||
// Fisher-Yates shuffle, but only up to count
|
||||
Random random = new Random();
|
||||
int[] result = new int[count];
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
int randomIndex = i + random.nextInt(max - i);
|
||||
result[i] = numbers[randomIndex];
|
||||
numbers[randomIndex] = numbers[i]; // Swap to prevent duplicates
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"type": "minecraft:overworld",
|
||||
"generator": {
|
||||
"type": "flat",
|
||||
"settings":{
|
||||
"layers": [],
|
||||
"biome": "minecraft:void",
|
||||
"structure_overrides": []
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
6
src/main/resources/datapacks/usefulskyblock/pack.mcmeta
Normal file
6
src/main/resources/datapacks/usefulskyblock/pack.mcmeta
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"pack": {
|
||||
"pack_format": 71,
|
||||
"description": "Useful Skyblock datapack"
|
||||
}
|
||||
}
|
12
src/main/resources/paper-plugin.yml
Normal file
12
src/main/resources/paper-plugin.yml
Normal file
|
@ -0,0 +1,12 @@
|
|||
name: UsefulSkyblock
|
||||
version: '1.0-SNAPSHOT'
|
||||
main: com.ncguy.usefulSkyblock.UsefulSkyblock
|
||||
description: A useful skyblock plugin
|
||||
api-version: '1.21'
|
||||
bootstrapper: com.ncguy.usefulSkyblock.UsefulSkyblockBootstrap
|
||||
loader: com.ncguy.usefulSkyblock.UsefulSkyblockLoader
|
||||
|
||||
data-pack:
|
||||
load: true
|
||||
name: usefulskyblock
|
||||
description: "UsefulSkyblock Structures"
|
Loading…
Reference in a new issue