First commit.
This commit is contained in:
commit
55370dcd53
61 changed files with 928 additions and 0 deletions
BIN
.gradle/8.8/checksums/checksums.lock
Normal file
BIN
.gradle/8.8/checksums/checksums.lock
Normal file
Binary file not shown.
BIN
.gradle/8.8/checksums/md5-checksums.bin
Normal file
BIN
.gradle/8.8/checksums/md5-checksums.bin
Normal file
Binary file not shown.
BIN
.gradle/8.8/checksums/sha1-checksums.bin
Normal file
BIN
.gradle/8.8/checksums/sha1-checksums.bin
Normal file
Binary file not shown.
0
.gradle/8.8/dependencies-accessors/gc.properties
Normal file
0
.gradle/8.8/dependencies-accessors/gc.properties
Normal file
BIN
.gradle/8.8/executionHistory/executionHistory.bin
Normal file
BIN
.gradle/8.8/executionHistory/executionHistory.bin
Normal file
Binary file not shown.
BIN
.gradle/8.8/executionHistory/executionHistory.lock
Normal file
BIN
.gradle/8.8/executionHistory/executionHistory.lock
Normal file
Binary file not shown.
BIN
.gradle/8.8/fileChanges/last-build.bin
Normal file
BIN
.gradle/8.8/fileChanges/last-build.bin
Normal file
Binary file not shown.
BIN
.gradle/8.8/fileHashes/fileHashes.bin
Normal file
BIN
.gradle/8.8/fileHashes/fileHashes.bin
Normal file
Binary file not shown.
BIN
.gradle/8.8/fileHashes/fileHashes.lock
Normal file
BIN
.gradle/8.8/fileHashes/fileHashes.lock
Normal file
Binary file not shown.
BIN
.gradle/8.8/fileHashes/resourceHashesCache.bin
Normal file
BIN
.gradle/8.8/fileHashes/resourceHashesCache.bin
Normal file
Binary file not shown.
0
.gradle/8.8/gc.properties
Normal file
0
.gradle/8.8/gc.properties
Normal file
BIN
.gradle/buildOutputCleanup/buildOutputCleanup.lock
Normal file
BIN
.gradle/buildOutputCleanup/buildOutputCleanup.lock
Normal file
Binary file not shown.
2
.gradle/buildOutputCleanup/cache.properties
Normal file
2
.gradle/buildOutputCleanup/cache.properties
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
#Mon Dec 01 17:53:37 BRT 2025
|
||||||
|
gradle.version=8.8
|
||||||
BIN
.gradle/buildOutputCleanup/outputFiles.bin
Normal file
BIN
.gradle/buildOutputCleanup/outputFiles.bin
Normal file
Binary file not shown.
BIN
.gradle/file-system.probe
Normal file
BIN
.gradle/file-system.probe
Normal file
Binary file not shown.
0
.gradle/vcs-1/gc.properties
Normal file
0
.gradle/vcs-1/gc.properties
Normal file
3
.idea/.gitignore
generated
vendored
Normal file
3
.idea/.gitignore
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
9
.idea/artifacts/regions_jar.xml
generated
Normal file
9
.idea/artifacts/regions_jar.xml
generated
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
<component name="ArtifactManager">
|
||||||
|
<artifact type="jar" name="regions:jar">
|
||||||
|
<output-path>$USER_HOME$/Desktop/regionstestserver/plugins/</output-path>
|
||||||
|
<root id="archive" name="regions.jar">
|
||||||
|
<element id="module-output" name="regions.main" />
|
||||||
|
<element id="dir-copy" path="$PROJECT_DIR$/src/main/resources" />
|
||||||
|
</root>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
||||||
6
.idea/compiler.xml
generated
Normal file
6
.idea/compiler.xml
generated
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="21" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
17
.idea/gradle.xml
generated
Normal file
17
.idea/gradle.xml
generated
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="gradleJvm" value="17" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
7
.idea/misc.xml
generated
Normal file
7
.idea/misc.xml
generated
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/modules/regions.main.iml" filepath="$PROJECT_DIR$/.idea/modules/regions.main.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
14
.idea/modules/regions.main.iml
generated
Normal file
14
.idea/modules/regions.main.iml
generated
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module version="4">
|
||||||
|
<component name="FacetManager">
|
||||||
|
<facet type="minecraft" name="Minecraft">
|
||||||
|
<configuration>
|
||||||
|
<autoDetectTypes>
|
||||||
|
<platformType>PAPER</platformType>
|
||||||
|
<platformType>ADVENTURE</platformType>
|
||||||
|
</autoDetectTypes>
|
||||||
|
<projectReimportVersion>1</projectReimportVersion>
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
55
build.gradle
Normal file
55
build.gradle
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
plugins {
|
||||||
|
id 'java'
|
||||||
|
id("xyz.jpenilla.run-paper") version "2.3.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
group = 'io.github.adrianvic'
|
||||||
|
version = '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
maven {
|
||||||
|
name = "papermc-repo"
|
||||||
|
url = "https://repo.papermc.io/repository/maven-public/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnly("io.papermc.paper:paper-api:1.21.10-R0.1-SNAPSHOT")
|
||||||
|
}
|
||||||
|
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def targetJavaVersion = 21
|
||||||
|
java {
|
||||||
|
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
|
||||||
|
sourceCompatibility = javaVersion
|
||||||
|
targetCompatibility = javaVersion
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
build/classes/java/main/io/github/adrianvic/regions/Config.class
Normal file
BIN
build/classes/java/main/io/github/adrianvic/regions/Config.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4
build/resources/main/plugin.yml
Normal file
4
build/resources/main/plugin.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
name: regions
|
||||||
|
version: '1.0-SNAPSHOT'
|
||||||
|
main: io.github.adrianvic.regions.Regions
|
||||||
|
api-version: '1.21'
|
||||||
Binary file not shown.
Binary file not shown.
BIN
build/tmp/compileJava/previous-compilation-data.bin
Normal file
BIN
build/tmp/compileJava/previous-compilation-data.bin
Normal file
Binary file not shown.
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
Executable file
249
gradlew
vendored
Executable file
|
|
@ -0,0 +1,249 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright © 2015-2021 the original authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/HEAD/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
|
||||||
14
out/production/resources/plugin.yml
Normal file
14
out/production/resources/plugin.yml
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
name: regions
|
||||||
|
version: '1.0-SNAPSHOT'
|
||||||
|
main: io.github.adrianvic.regions.Regions
|
||||||
|
api-version: '1.21'
|
||||||
|
author: 'Adrian Victor'
|
||||||
|
website: https://github.io/adrianvic
|
||||||
|
description: Change what players can do based in custom criteria.
|
||||||
|
commands:
|
||||||
|
mrlistpolicies:
|
||||||
|
description: "Lists all loaded policies"
|
||||||
|
usage: "/mrlistpolicies"
|
||||||
|
mrpolicyinfo:
|
||||||
|
description: "Show info about a policy"
|
||||||
|
usage: "/mrpolicyinfo"
|
||||||
33
out/production/resources/settings.yml
Normal file
33
out/production/resources/settings.yml
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
Policies:
|
||||||
|
Location:
|
||||||
|
- name: "spawn-protection"
|
||||||
|
allowlist: false
|
||||||
|
nodes:
|
||||||
|
# example PolicyNode fields — adapt to your actual structure
|
||||||
|
canHit: false
|
||||||
|
canHarvest: false
|
||||||
|
message: "You cannot use tools here."
|
||||||
|
locations:
|
||||||
|
# first group (ArrayList<BoundingBox>)
|
||||||
|
-
|
||||||
|
# region 1 in group 1
|
||||||
|
- corner1: { x: 100, y: 60, z: 100 }
|
||||||
|
corner2: { x: 110, y: 70, z: 110 }
|
||||||
|
# region 2 in group 1
|
||||||
|
- corner1: { x: 120, y: 58, z: 95 }
|
||||||
|
corner2: { x: 125, y: 64, z: 100 }
|
||||||
|
# second group (another ArrayList<BoundingBox>)
|
||||||
|
-
|
||||||
|
- corner1: { x: -50, y: 50, z: -50 }
|
||||||
|
corner2: { x: -40, y: 60, z: -40 }
|
||||||
|
|
||||||
|
- name: "farm-area"
|
||||||
|
allowlist: true
|
||||||
|
nodes:
|
||||||
|
canHit: true
|
||||||
|
canHarvest: true
|
||||||
|
message: "Farming allowed."
|
||||||
|
locations:
|
||||||
|
-
|
||||||
|
- corner1: { x: 200, y: 62, z: 200 }
|
||||||
|
corner2: { x: 220, y: 66, z: 220 }
|
||||||
1
settings.gradle
Normal file
1
settings.gradle
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
rootProject.name = 'regions'
|
||||||
61
src/main/java/io/github/adrianvic/regions/Config.java
Normal file
61
src/main/java/io/github/adrianvic/regions/Config.java
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
package io.github.adrianvic.regions;
|
||||||
|
|
||||||
|
import io.github.adrianvic.regions.policy.LocationPolicy;
|
||||||
|
import io.github.adrianvic.regions.policy.PermissionPolicy;
|
||||||
|
import io.github.adrianvic.regions.policy.PlayerNamePolicy;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Config {
|
||||||
|
private final static Config instance = new Config();
|
||||||
|
private File file;
|
||||||
|
private YamlConfiguration config;
|
||||||
|
|
||||||
|
private List<LocationPolicy> locationPolicies;
|
||||||
|
private List<PermissionPolicy> permissionPolicies;
|
||||||
|
private List<PlayerNamePolicy> playerNamePolicies;
|
||||||
|
|
||||||
|
private Config() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void load() {
|
||||||
|
file = new File(Regions.getInstance().getDataFolder(), "settings.yml");
|
||||||
|
|
||||||
|
if (!file.exists())
|
||||||
|
Regions.getInstance().saveResource("settings.yml", false);
|
||||||
|
|
||||||
|
config = new YamlConfiguration();
|
||||||
|
config.options().parseComments(true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
config.load(file);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
locationPolicies = LocationPolicy.parseLocationPolicy(config.getMapList("Policies.Location"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
try {
|
||||||
|
config.save(file);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(String path, Object value) {
|
||||||
|
config.set(path, value);
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<LocationPolicy> getLocationPolicies() {
|
||||||
|
return locationPolicies;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Config getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
package io.github.adrianvic.regions;
|
||||||
|
|
||||||
|
public class DataShifter {
|
||||||
|
}
|
||||||
33
src/main/java/io/github/adrianvic/regions/PlaceListener.java
Normal file
33
src/main/java/io/github/adrianvic/regions/PlaceListener.java
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
package io.github.adrianvic.regions;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
|
public class PlaceListener implements Listener {
|
||||||
|
Validator val = new Validator();
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
|
event.setCancelled(!val.isHumanoidAbleToHarvest(event.getPlayer()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onInteractionEvent(PlayerInteractEvent event) {
|
||||||
|
if (event.getItem() != null) {
|
||||||
|
event.setCancelled(!val.isItemValid(event.getItem().getType()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) {
|
||||||
|
if (event.getDamager() instanceof HumanEntity player) {
|
||||||
|
boolean canceled = !val.isHumanoidAbleToHit(player);
|
||||||
|
event.setCancelled(canceled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
25
src/main/java/io/github/adrianvic/regions/Regions.java
Normal file
25
src/main/java/io/github/adrianvic/regions/Regions.java
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
package io.github.adrianvic.regions;
|
||||||
|
|
||||||
|
import io.github.adrianvic.regions.commands.ListPolicies;
|
||||||
|
import io.github.adrianvic.regions.commands.PolicyInfo;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
public final class Regions extends JavaPlugin {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
getServer().getPluginManager().registerEvents(new PlaceListener(), this);
|
||||||
|
Config.getInstance().load();
|
||||||
|
getCommand("mrlistpolicies").setExecutor(new ListPolicies());
|
||||||
|
getCommand("mrpolicyinfo").setExecutor(new PolicyInfo());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
// Plugin shutdown logic
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Regions getInstance() {
|
||||||
|
return getPlugin(Regions.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
38
src/main/java/io/github/adrianvic/regions/Validator.java
Normal file
38
src/main/java/io/github/adrianvic/regions/Validator.java
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
package io.github.adrianvic.regions;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
|
||||||
|
public class Validator {
|
||||||
|
ArrayList<Material> blacklistedItems = new ArrayList<Material>();
|
||||||
|
|
||||||
|
public Validator() {
|
||||||
|
blacklistedItems.add(Material.COPPER_SWORD);
|
||||||
|
blacklistedItems.add(Material.COPPER_AXE);
|
||||||
|
blacklistedItems.add(Material.COPPER_HOE);
|
||||||
|
blacklistedItems.add(Material.ROTTEN_FLESH);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHumanoidAbleToHit(HumanEntity damager) {
|
||||||
|
return isItemValid(damager.getInventory().getItemInMainHand().getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHumanoidAbleToHarvest(HumanEntity harvester) {
|
||||||
|
return isItemValid(harvester.getInventory().getItemInMainHand().getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isItemValid(Material item) {
|
||||||
|
return !blacklistedItems.contains(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warnPlayer(Player player) {
|
||||||
|
Location loc = player.getLocation();
|
||||||
|
loc.getWorld().strikeLightningEffect(loc);
|
||||||
|
player.sendMessage("Please note that you are not allowed to do this here!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package io.github.adrianvic.regions.commands;
|
||||||
|
|
||||||
|
import io.github.adrianvic.regions.Config;
|
||||||
|
import io.github.adrianvic.regions.policy.LocationPolicy;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ListPolicies implements CommandExecutor, TabCompleter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String @NotNull [] strings) {
|
||||||
|
List<String> rstr = new ArrayList<>();
|
||||||
|
for (LocationPolicy p : Config.getInstance().getLocationPolicies()) {
|
||||||
|
rstr.add(p.name());
|
||||||
|
}
|
||||||
|
commandSender.sendMessage(String.join(", ", rstr) + ".");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String @NotNull [] strings) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
package io.github.adrianvic.regions.commands;
|
||||||
|
|
||||||
|
import io.github.adrianvic.regions.Config;
|
||||||
|
import io.github.adrianvic.regions.policy.LocationPolicy;
|
||||||
|
import io.github.adrianvic.regions.policy.PolicyNode;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PolicyInfo implements CommandExecutor, TabCompleter {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String @NotNull [] strings) {
|
||||||
|
List<LocationPolicy> policies = Config.getInstance().getLocationPolicies();
|
||||||
|
for (LocationPolicy lp : policies) {
|
||||||
|
if (lp.name().equals(strings[0])) {
|
||||||
|
String locations = lp.locations().toString();
|
||||||
|
|
||||||
|
List<PolicyNode> nodes = lp.nodes();
|
||||||
|
List<String> nodeNames = new ArrayList<>();
|
||||||
|
for (PolicyNode n : nodes) {
|
||||||
|
nodeNames.add(n.type());
|
||||||
|
}
|
||||||
|
String nodesStr = String.join(", ", nodeNames) + ".";
|
||||||
|
|
||||||
|
commandSender.sendMessage(String.format("""
|
||||||
|
Showing info for policy "%s":
|
||||||
|
Type: %s
|
||||||
|
Locations: %s
|
||||||
|
Nodes: %s
|
||||||
|
%s
|
||||||
|
""", lp.name(), "location", locations, nodesStr, lp.allowlist() ? "Is allowlist" : "Is blacklist"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String @NotNull [] strings) {
|
||||||
|
List<String> rstr = new ArrayList<>();
|
||||||
|
for (LocationPolicy p : Config.getInstance().getLocationPolicies()) {
|
||||||
|
rstr.add(p.name());
|
||||||
|
}
|
||||||
|
return rstr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
package io.github.adrianvic.regions.policy;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.util.BoundingBox;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public record LocationPolicy(String name, List<ArrayList<BoundingBox>> locations, List<PolicyNode> nodes, boolean allowlist) {
|
||||||
|
public static List<LocationPolicy> parseLocationPolicy(List<Map<?,?>> raw) {
|
||||||
|
List<LocationPolicy> out = new ArrayList<>(raw.size());
|
||||||
|
for (Map<?,?> m : raw) {
|
||||||
|
String name = (String) m.get("name");
|
||||||
|
boolean allowList = Boolean.TRUE.equals(m.get("allowList"));
|
||||||
|
|
||||||
|
// Nodes
|
||||||
|
Object rawNodes = m.get("nodes");
|
||||||
|
List<Map<String, Object>> nodeList = new ArrayList<>();
|
||||||
|
if (rawNodes instanceof List<?> list) {
|
||||||
|
for (Object o : list) {
|
||||||
|
if (o instanceof Map<?, ?> map)
|
||||||
|
nodeList.add((Map<String, Object>) map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<PolicyNode> nodes = PolicyNode.parseNodes(nodeList);
|
||||||
|
|
||||||
|
// Parsing locations
|
||||||
|
List<ArrayList<BoundingBox>> locations = new ArrayList<>();
|
||||||
|
Object rawGroups = m.get("locations");
|
||||||
|
List<?> groups = rawGroups instanceof List ? (List<?>) rawGroups : List.of();
|
||||||
|
|
||||||
|
// Getting groups
|
||||||
|
for (Object gObj : groups) {
|
||||||
|
List<?> group = (List<?>) gObj;
|
||||||
|
ArrayList<BoundingBox> boxes = new ArrayList<>(group.size());
|
||||||
|
|
||||||
|
// Now iterate over regions inside the group
|
||||||
|
for (Object rObj : group) {
|
||||||
|
Map<?,?> region = (Map<?, ?>) rObj;
|
||||||
|
Map<?,?> c1 = (Map<?, ?>) region.get("corner1");
|
||||||
|
Map<?,?> c2 = (Map<?, ?>) region.get("corner2");
|
||||||
|
|
||||||
|
double x1 = ((Number) c1.get("x")).doubleValue();
|
||||||
|
double y1 = ((Number) c1.get("y")).doubleValue();
|
||||||
|
double z1 = ((Number) c1.get("z")).doubleValue();
|
||||||
|
|
||||||
|
double x2 = ((Number) c2.get("x")).doubleValue();
|
||||||
|
double y2 = ((Number) c2.get("y")).doubleValue();
|
||||||
|
double z2 = ((Number) c2.get("z")).doubleValue();
|
||||||
|
|
||||||
|
Location loc1 = new Location(Bukkit.getWorlds().getFirst(), x1, y1, z1);
|
||||||
|
Location loc2 = new Location(Bukkit.getWorlds().getFirst(), x2, y2, z2);
|
||||||
|
|
||||||
|
boxes.add(BoundingBox.of(loc1, loc2));
|
||||||
|
}
|
||||||
|
locations.add(boxes);
|
||||||
|
}
|
||||||
|
out.add(new LocationPolicy(name, locations, nodes, allowList));
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
package io.github.adrianvic.regions.policy;
|
||||||
|
|
||||||
|
import org.bukkit.permissions.Permission;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public record PermissionPolicy(String name, ArrayList<Permission> permissions, PolicyNode nodes, boolean allowlist) {}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
package io.github.adrianvic.regions.policy;
|
||||||
|
|
||||||
|
import org.bukkit.permissions.Permission;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public record PlayerNamePolicy(String name, ArrayList<String> playerName, PolicyNode nodes, boolean allowlist) {}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package io.github.adrianvic.regions.policy;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public record PolicyNode(String type, List<String> values) {
|
||||||
|
public static List<PolicyNode> parseNodes(List<Map<String,Object>> raw) {
|
||||||
|
List<PolicyNode> nodes = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Map<String, Object> m : raw) {
|
||||||
|
for (Map.Entry<String, Object> entry : m.entrySet()) {
|
||||||
|
|
||||||
|
String type = entry.getKey();
|
||||||
|
List<String> values = new ArrayList<>();
|
||||||
|
Object val = entry.getValue();
|
||||||
|
|
||||||
|
if (val instanceof String s) {
|
||||||
|
values.add((s));
|
||||||
|
} else if (val instanceof List<?> l) {
|
||||||
|
for (Object o : l) {
|
||||||
|
if (o instanceof String s) {
|
||||||
|
values.add(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nodes.add(new PolicyNode(type, values));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodes;
|
||||||
|
}
|
||||||
|
}
|
||||||
14
src/main/resources/plugin.yml
Normal file
14
src/main/resources/plugin.yml
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
name: regions
|
||||||
|
version: '1.0-SNAPSHOT'
|
||||||
|
main: io.github.adrianvic.regions.Regions
|
||||||
|
api-version: '1.21'
|
||||||
|
author: 'Adrian Victor'
|
||||||
|
website: https://github.io/adrianvic
|
||||||
|
description: Change what players can do based in custom criteria.
|
||||||
|
commands:
|
||||||
|
mrlistpolicies:
|
||||||
|
description: "Lists all loaded policies"
|
||||||
|
usage: "/mrlistpolicies"
|
||||||
|
mrpolicyinfo:
|
||||||
|
description: "Show info about a policy"
|
||||||
|
usage: "/mrpolicyinfo"
|
||||||
33
src/main/resources/settings.yml
Normal file
33
src/main/resources/settings.yml
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
Policies:
|
||||||
|
Location:
|
||||||
|
- name: "spawn-protection"
|
||||||
|
allowlist: false
|
||||||
|
nodes:
|
||||||
|
# example PolicyNode fields — adapt to your actual structure
|
||||||
|
canHit: false
|
||||||
|
canHarvest: false
|
||||||
|
message: "You cannot use tools here."
|
||||||
|
locations:
|
||||||
|
# first group (ArrayList<BoundingBox>)
|
||||||
|
-
|
||||||
|
# region 1 in group 1
|
||||||
|
- corner1: { x: 100, y: 60, z: 100 }
|
||||||
|
corner2: { x: 110, y: 70, z: 110 }
|
||||||
|
# region 2 in group 1
|
||||||
|
- corner1: { x: 120, y: 58, z: 95 }
|
||||||
|
corner2: { x: 125, y: 64, z: 100 }
|
||||||
|
# second group (another ArrayList<BoundingBox>)
|
||||||
|
-
|
||||||
|
- corner1: { x: -50, y: 50, z: -50 }
|
||||||
|
corner2: { x: -40, y: 60, z: -40 }
|
||||||
|
|
||||||
|
- name: "farm-area"
|
||||||
|
allowlist: true
|
||||||
|
nodes:
|
||||||
|
canHit: true
|
||||||
|
canHarvest: true
|
||||||
|
message: "Farming allowed."
|
||||||
|
locations:
|
||||||
|
-
|
||||||
|
- corner1: { x: 200, y: 62, z: 200 }
|
||||||
|
corner2: { x: 220, y: 66, z: 220 }
|
||||||
Loading…
Add table
Add a link
Reference in a new issue