commit 55370dcd53d9adcd4074c8075c49d34a409428a6 Author: tenkuma Date: Wed Dec 3 15:02:05 2025 -0300 First commit. diff --git a/.gradle/8.8/checksums/checksums.lock b/.gradle/8.8/checksums/checksums.lock new file mode 100644 index 0000000..3892913 Binary files /dev/null and b/.gradle/8.8/checksums/checksums.lock differ diff --git a/.gradle/8.8/checksums/md5-checksums.bin b/.gradle/8.8/checksums/md5-checksums.bin new file mode 100644 index 0000000..95a682b Binary files /dev/null and b/.gradle/8.8/checksums/md5-checksums.bin differ diff --git a/.gradle/8.8/checksums/sha1-checksums.bin b/.gradle/8.8/checksums/sha1-checksums.bin new file mode 100644 index 0000000..046fb23 Binary files /dev/null and b/.gradle/8.8/checksums/sha1-checksums.bin differ diff --git a/.gradle/8.8/dependencies-accessors/gc.properties b/.gradle/8.8/dependencies-accessors/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.gradle/8.8/executionHistory/executionHistory.bin b/.gradle/8.8/executionHistory/executionHistory.bin new file mode 100644 index 0000000..99e1191 Binary files /dev/null and b/.gradle/8.8/executionHistory/executionHistory.bin differ diff --git a/.gradle/8.8/executionHistory/executionHistory.lock b/.gradle/8.8/executionHistory/executionHistory.lock new file mode 100644 index 0000000..f69dcd5 Binary files /dev/null and b/.gradle/8.8/executionHistory/executionHistory.lock differ diff --git a/.gradle/8.8/fileChanges/last-build.bin b/.gradle/8.8/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/.gradle/8.8/fileChanges/last-build.bin differ diff --git a/.gradle/8.8/fileHashes/fileHashes.bin b/.gradle/8.8/fileHashes/fileHashes.bin new file mode 100644 index 0000000..d26d2d2 Binary files /dev/null and b/.gradle/8.8/fileHashes/fileHashes.bin differ diff --git a/.gradle/8.8/fileHashes/fileHashes.lock b/.gradle/8.8/fileHashes/fileHashes.lock new file mode 100644 index 0000000..06ab1a1 Binary files /dev/null and b/.gradle/8.8/fileHashes/fileHashes.lock differ diff --git a/.gradle/8.8/fileHashes/resourceHashesCache.bin b/.gradle/8.8/fileHashes/resourceHashesCache.bin new file mode 100644 index 0000000..772a426 Binary files /dev/null and b/.gradle/8.8/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/8.8/gc.properties b/.gradle/8.8/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000..d49b8d6 Binary files /dev/null and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..44a92ec --- /dev/null +++ b/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Mon Dec 01 17:53:37 BRT 2025 +gradle.version=8.8 diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 0000000..83af394 Binary files /dev/null and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe new file mode 100644 index 0000000..0a94ba4 Binary files /dev/null and b/.gradle/file-system.probe differ diff --git a/.gradle/vcs-1/gc.properties b/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/artifacts/regions_jar.xml b/.idea/artifacts/regions_jar.xml new file mode 100644 index 0000000..06f9ef6 --- /dev/null +++ b/.idea/artifacts/regions_jar.xml @@ -0,0 +1,9 @@ + + + $USER_HOME$/Desktop/regionstestserver/plugins/ + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..b86273d --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..f2c1963 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..5cd9a10 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..3312386 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/regions.main.iml b/.idea/modules/regions.main.iml new file mode 100644 index 0000000..bbeeb3e --- /dev/null +++ b/.idea/modules/regions.main.iml @@ -0,0 +1,14 @@ + + + + + + + PAPER + ADVENTURE + + 1 + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..36427d7 --- /dev/null +++ b/build.gradle @@ -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 + } +} diff --git a/build/classes/java/main/io/github/adrianvic/regions/Config.class b/build/classes/java/main/io/github/adrianvic/regions/Config.class new file mode 100644 index 0000000..59a62c2 Binary files /dev/null and b/build/classes/java/main/io/github/adrianvic/regions/Config.class differ diff --git a/build/classes/java/main/io/github/adrianvic/regions/DataShifter.class b/build/classes/java/main/io/github/adrianvic/regions/DataShifter.class new file mode 100644 index 0000000..f0ff7bc Binary files /dev/null and b/build/classes/java/main/io/github/adrianvic/regions/DataShifter.class differ diff --git a/build/classes/java/main/io/github/adrianvic/regions/PlaceListener.class b/build/classes/java/main/io/github/adrianvic/regions/PlaceListener.class new file mode 100644 index 0000000..4f97ea6 Binary files /dev/null and b/build/classes/java/main/io/github/adrianvic/regions/PlaceListener.class differ diff --git a/build/classes/java/main/io/github/adrianvic/regions/Regions.class b/build/classes/java/main/io/github/adrianvic/regions/Regions.class new file mode 100644 index 0000000..f0a9b53 Binary files /dev/null and b/build/classes/java/main/io/github/adrianvic/regions/Regions.class differ diff --git a/build/classes/java/main/io/github/adrianvic/regions/Validator.class b/build/classes/java/main/io/github/adrianvic/regions/Validator.class new file mode 100644 index 0000000..41fd1c5 Binary files /dev/null and b/build/classes/java/main/io/github/adrianvic/regions/Validator.class differ diff --git a/build/classes/java/main/io/github/adrianvic/regions/commands/ListPolicies.class b/build/classes/java/main/io/github/adrianvic/regions/commands/ListPolicies.class new file mode 100644 index 0000000..aaa4fe5 Binary files /dev/null and b/build/classes/java/main/io/github/adrianvic/regions/commands/ListPolicies.class differ diff --git a/build/classes/java/main/io/github/adrianvic/regions/commands/PolicyInfo.class b/build/classes/java/main/io/github/adrianvic/regions/commands/PolicyInfo.class new file mode 100644 index 0000000..f818aa9 Binary files /dev/null and b/build/classes/java/main/io/github/adrianvic/regions/commands/PolicyInfo.class differ diff --git a/build/classes/java/main/io/github/adrianvic/regions/policy/LocationPolicy.class b/build/classes/java/main/io/github/adrianvic/regions/policy/LocationPolicy.class new file mode 100644 index 0000000..e973a58 Binary files /dev/null and b/build/classes/java/main/io/github/adrianvic/regions/policy/LocationPolicy.class differ diff --git a/build/classes/java/main/io/github/adrianvic/regions/policy/PermissionPolicy.class b/build/classes/java/main/io/github/adrianvic/regions/policy/PermissionPolicy.class new file mode 100644 index 0000000..21775d7 Binary files /dev/null and b/build/classes/java/main/io/github/adrianvic/regions/policy/PermissionPolicy.class differ diff --git a/build/classes/java/main/io/github/adrianvic/regions/policy/PlayerNamePolicy.class b/build/classes/java/main/io/github/adrianvic/regions/policy/PlayerNamePolicy.class new file mode 100644 index 0000000..cf617ed Binary files /dev/null and b/build/classes/java/main/io/github/adrianvic/regions/policy/PlayerNamePolicy.class differ diff --git a/build/classes/java/main/io/github/adrianvic/regions/policy/PolicyNode.class b/build/classes/java/main/io/github/adrianvic/regions/policy/PolicyNode.class new file mode 100644 index 0000000..112aa3a Binary files /dev/null and b/build/classes/java/main/io/github/adrianvic/regions/policy/PolicyNode.class differ diff --git a/build/resources/main/plugin.yml b/build/resources/main/plugin.yml new file mode 100644 index 0000000..612eeed --- /dev/null +++ b/build/resources/main/plugin.yml @@ -0,0 +1,4 @@ +name: regions +version: '1.0-SNAPSHOT' +main: io.github.adrianvic.regions.Regions +api-version: '1.21' diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/PlaceListener.class.uniqueId1 b/build/tmp/compileJava/compileTransaction/stash-dir/PlaceListener.class.uniqueId1 new file mode 100644 index 0000000..816f2df Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/PlaceListener.class.uniqueId1 differ diff --git a/build/tmp/compileJava/compileTransaction/stash-dir/Regions.class.uniqueId0 b/build/tmp/compileJava/compileTransaction/stash-dir/Regions.class.uniqueId0 new file mode 100644 index 0000000..fe7a516 Binary files /dev/null and b/build/tmp/compileJava/compileTransaction/stash-dir/Regions.class.uniqueId0 differ diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin new file mode 100644 index 0000000..10eecb4 Binary files /dev/null and b/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..e69de29 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e644113 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..a441313 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..b740cf1 --- /dev/null +++ b/gradlew @@ -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" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..7101f8e --- /dev/null +++ b/gradlew.bat @@ -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 diff --git a/out/production/resources/plugin.yml b/out/production/resources/plugin.yml new file mode 100644 index 0000000..af2b314 --- /dev/null +++ b/out/production/resources/plugin.yml @@ -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" \ No newline at end of file diff --git a/out/production/resources/settings.yml b/out/production/resources/settings.yml new file mode 100644 index 0000000..8057aef --- /dev/null +++ b/out/production/resources/settings.yml @@ -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) + - + # 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) + - + - 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 } \ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..52b1811 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'regions' diff --git a/src/main/java/io/github/adrianvic/regions/Config.java b/src/main/java/io/github/adrianvic/regions/Config.java new file mode 100644 index 0000000..281dc78 --- /dev/null +++ b/src/main/java/io/github/adrianvic/regions/Config.java @@ -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 locationPolicies; + private List permissionPolicies; + private List 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 getLocationPolicies() { + return locationPolicies; + } + + public static Config getInstance() { + return instance; + } +} \ No newline at end of file diff --git a/src/main/java/io/github/adrianvic/regions/DataShifter.java b/src/main/java/io/github/adrianvic/regions/DataShifter.java new file mode 100644 index 0000000..c9cea2a --- /dev/null +++ b/src/main/java/io/github/adrianvic/regions/DataShifter.java @@ -0,0 +1,4 @@ +package io.github.adrianvic.regions; + +public class DataShifter { +} diff --git a/src/main/java/io/github/adrianvic/regions/PlaceListener.java b/src/main/java/io/github/adrianvic/regions/PlaceListener.java new file mode 100644 index 0000000..e5e4eed --- /dev/null +++ b/src/main/java/io/github/adrianvic/regions/PlaceListener.java @@ -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); + } + } +} diff --git a/src/main/java/io/github/adrianvic/regions/Regions.java b/src/main/java/io/github/adrianvic/regions/Regions.java new file mode 100644 index 0000000..4a3e84c --- /dev/null +++ b/src/main/java/io/github/adrianvic/regions/Regions.java @@ -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); + } +} \ No newline at end of file diff --git a/src/main/java/io/github/adrianvic/regions/Validator.java b/src/main/java/io/github/adrianvic/regions/Validator.java new file mode 100644 index 0000000..26fcc63 --- /dev/null +++ b/src/main/java/io/github/adrianvic/regions/Validator.java @@ -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 blacklistedItems = new ArrayList(); + + 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!"); + } +} diff --git a/src/main/java/io/github/adrianvic/regions/commands/ListPolicies.java b/src/main/java/io/github/adrianvic/regions/commands/ListPolicies.java new file mode 100644 index 0000000..585d758 --- /dev/null +++ b/src/main/java/io/github/adrianvic/regions/commands/ListPolicies.java @@ -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 rstr = new ArrayList<>(); + for (LocationPolicy p : Config.getInstance().getLocationPolicies()) { + rstr.add(p.name()); + } + commandSender.sendMessage(String.join(", ", rstr) + "."); + return true; + } + + @Override + public @Nullable List onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String @NotNull [] strings) { + return List.of(); + } +} diff --git a/src/main/java/io/github/adrianvic/regions/commands/PolicyInfo.java b/src/main/java/io/github/adrianvic/regions/commands/PolicyInfo.java new file mode 100644 index 0000000..e4e5021 --- /dev/null +++ b/src/main/java/io/github/adrianvic/regions/commands/PolicyInfo.java @@ -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 policies = Config.getInstance().getLocationPolicies(); + for (LocationPolicy lp : policies) { + if (lp.name().equals(strings[0])) { + String locations = lp.locations().toString(); + + List nodes = lp.nodes(); + List 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 onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String @NotNull [] strings) { + List rstr = new ArrayList<>(); + for (LocationPolicy p : Config.getInstance().getLocationPolicies()) { + rstr.add(p.name()); + } + return rstr; + } +} diff --git a/src/main/java/io/github/adrianvic/regions/policy/LocationPolicy.java b/src/main/java/io/github/adrianvic/regions/policy/LocationPolicy.java new file mode 100644 index 0000000..eb39ad7 --- /dev/null +++ b/src/main/java/io/github/adrianvic/regions/policy/LocationPolicy.java @@ -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> locations, List nodes, boolean allowlist) { + public static List parseLocationPolicy(List> raw) { + List 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> nodeList = new ArrayList<>(); + if (rawNodes instanceof List list) { + for (Object o : list) { + if (o instanceof Map map) + nodeList.add((Map) map); + } + } + + List nodes = PolicyNode.parseNodes(nodeList); + + // Parsing locations + List> 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 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; + } +} \ No newline at end of file diff --git a/src/main/java/io/github/adrianvic/regions/policy/PermissionPolicy.java b/src/main/java/io/github/adrianvic/regions/policy/PermissionPolicy.java new file mode 100644 index 0000000..751c19f --- /dev/null +++ b/src/main/java/io/github/adrianvic/regions/policy/PermissionPolicy.java @@ -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 permissions, PolicyNode nodes, boolean allowlist) {} diff --git a/src/main/java/io/github/adrianvic/regions/policy/PlayerNamePolicy.java b/src/main/java/io/github/adrianvic/regions/policy/PlayerNamePolicy.java new file mode 100644 index 0000000..61cd436 --- /dev/null +++ b/src/main/java/io/github/adrianvic/regions/policy/PlayerNamePolicy.java @@ -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 playerName, PolicyNode nodes, boolean allowlist) {} \ No newline at end of file diff --git a/src/main/java/io/github/adrianvic/regions/policy/PolicyNode.java b/src/main/java/io/github/adrianvic/regions/policy/PolicyNode.java new file mode 100644 index 0000000..97a3a0e --- /dev/null +++ b/src/main/java/io/github/adrianvic/regions/policy/PolicyNode.java @@ -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 values) { + public static List parseNodes(List> raw) { + List nodes = new ArrayList<>(); + + for (Map m : raw) { + for (Map.Entry entry : m.entrySet()) { + + String type = entry.getKey(); + List 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; + } +} \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml new file mode 100644 index 0000000..af2b314 --- /dev/null +++ b/src/main/resources/plugin.yml @@ -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" \ No newline at end of file diff --git a/src/main/resources/settings.yml b/src/main/resources/settings.yml new file mode 100644 index 0000000..8057aef --- /dev/null +++ b/src/main/resources/settings.yml @@ -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) + - + # 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) + - + - 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 } \ No newline at end of file