commit 3e12cfea676b1fd09146597533445315e9c74bd7 Author: Ryder Belserion Date: Mon Dec 2 14:35:23 2024 -0500 Add base project diff --git a/.github/ISSUE_TEMPLATE/bugs.yml b/.github/ISSUE_TEMPLATE/bugs.yml new file mode 100644 index 0000000..9da87b9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bugs.yml @@ -0,0 +1,72 @@ +name: "🐛 Bug Report" +description: "Create a report to help us improve the plugin." +labels: [ "bug" ] + +assignees: + - ryderbelserion + +body: + - type: markdown + attributes: + value: | + Note: Search to see if an issue already exists for the bug you are reporting. + + Add any gif / imgur links if need be. Markdown is supported! + + If you have any large stack traces / errors, Please use https://mclo.gs/ + + Spark > https://spark.lucko.me/download + - type: input + attributes: + label: Spark link + description: We ask that Spark profile are shared through a link, not a screenshot. Screenshots inhibit our ability to figure out the real cause of the issue. + placeholder: Output of /spark profiler --timeout 300 + validations: + required: false + - type: input + id: plugin_version + attributes: + label: Plugin Version + description: Type /version plugin-name in-game + validations: + required: true + - type: dropdown + id: version + attributes: + label: Server Version + description: What server version are you on? + options: + - "1.21.1" + - "1.21.2" + validations: + required: true + - type: dropdown + id: platform + attributes: + label: Server Platform + description: What server platform are you using? + options: + - Paper + - Purpur + - Folia + validations: + required: true + - type: textarea + id: bug + attributes: + label: Describe the bug + description: A clear and concise description of what the bug is. + validations: + required: true + - type: textarea + id: steps + attributes: + label: Steps to reproduce + description: Steps to reproduce the behavior. + placeholder: | + 1. Go to '...' + 2. Change value in placeholder.yml '...' + 3. Run command '...' + 4. See error + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/flags.yml b/.github/ISSUE_TEMPLATE/flags.yml new file mode 100644 index 0000000..076732b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/flags.yml @@ -0,0 +1,20 @@ +name: "🚩 Suggest a new flag to add" +description: "Missing a worldguard flag you don't have?" +labels: [ "feature" ] + +body: + - type: textarea + id: feature + attributes: + label: Pick a name for it + description: "What do you want to name the worldguard flag?" + placeholder: "anti stabby max pro" + validations: + required: true + + - type: textarea + attributes: + label: What does the worldguard flag do? + description: Describe what the worldguard flag does + validations: + required: true \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0141be7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +.gradle +.idea +jars +build + +run + +!run/config +!run/spigot.yml +!run/bukkit.yml +!run/eula.txt +!run/server.properties +!run/plugins +!run/ops.json \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..2cf9d44 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,8 @@ +## Changes: +- Updated how flags are handled internally to easily add newer flags. + - Currently working on another flag I am interested in. + +## Fixed: +- Added a null check if the flag is not in the registry. + - This only happens if you enable a config option, and do `/simpleflags reload` + - WorldGuard flags can only be added on startup, as any time after that... the registry is frozen. \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/LICENSE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..177864a --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# SimpleFlags +A plugin that uses WorldGuard to add flags not currently available in WorldGuard. diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..5112768 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,107 @@ +plugins { + alias(libs.plugins.runPaper) + alias(libs.plugins.minotaur) + alias(libs.plugins.shadow) + + `java-library` +} + +rootProject.group = "com.ryderbelserion.simpleflags" +rootProject.version = "1.0.1" +rootProject.description = "A plugin that adds simple worldguard flags." + +repositories { + maven("https://repo.papermc.io/repository/maven-public") + + maven("https://repo.crazycrew.us/libraries") + + maven("https://maven.enginehub.org/repo") +} + +dependencies { + compileOnly(libs.vital.paper) + + compileOnly(libs.worldguard) + + compileOnly(libs.paper) +} + +java { + toolchain.languageVersion.set(JavaLanguageVersion.of("21")) +} + +tasks { + compileJava { + options.encoding = Charsets.UTF_8.name() + options.release.set(21) + } + + javadoc { + options.encoding = Charsets.UTF_8.name() + } + + processResources { + filteringCharset = Charsets.UTF_8.name() + } + + assemble { + dependsOn(shadowJar) + + doLast { + copy { + from(shadowJar.get()) + into(rootProject.projectDir.resolve("jars")) + } + } + } + + shadowJar { + archiveClassifier.set("") + } + + runServer { + jvmArgs("-Dnet.kyori.ansi.colorLevel=truecolor") + + defaultCharacterEncoding = Charsets.UTF_8.name() + + minecraftVersion(libs.versions.minecraft.get()) + } + + modrinth { + token.set(System.getenv("MODRINTH_TOKEN")) + + projectId.set(rootProject.name) + + versionType.set("release") + + versionName.set("${rootProject.name} ${rootProject.version}") + versionNumber.set(rootProject.version as String) + + changelog.set(rootProject.file("CHANGELOG.md").readText(Charsets.UTF_8)) + + uploadFile.set(shadowJar.get()) + + gameVersions.set(listOf(libs.versions.minecraft.get())) + + loaders.addAll(listOf("purpur", "paper", "folia")) + + syncBodyFrom.set(rootProject.file("README.md").readText(Charsets.UTF_8)) + + autoAddDependsOn.set(false) + detectLoaders.set(false) + } + + processResources { + val props = mapOf( + "name" to rootProject.name, + "version" to rootProject.version, + "group" to rootProject.group, + "description" to rootProject.description, + "apiVersion" to libs.versions.minecraft.get() + ) + + filesMatching("paper-plugin.yml") { + expand(props) + } + } +} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..a9d7c8d --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,38 @@ +[plugins] +hangar = { id = "io.papermc.hangar-publish-plugin", version.ref = "hangar" } +runPaper = { id = "xyz.jpenilla.run-paper", version.ref = "runPaper" } +minotaur = { id = "com.modrinth.minotaur", version.ref = "minotaur" } +shadow = { id = "com.gradleup.shadow", version.ref = "shadow" } + +[versions] +# Paper API +paper = "1.21.1-R0.1-SNAPSHOT" +velocity = "3.3.0-SNAPSHOT" +minecraft = "1.21.1" +brigadier = "1.3.10" + +# Vital API +vital-common = "0.0.6" +vital-paper = "1.0.6" + +# Gradle Plugins +runPaper = "2.3.0" +minotaur = "2.8.7" +hangar = "0.1.2" +shadow = "8.3.0" + +[libraries] +# Velocity API +velocity = { module = "com.velocitypowered:velocity-api", version.ref = "velocity" } + +# Mojang API +brigadier = { module = "com.mojang:brigadier", version.ref = "brigadier" } + +# Paper API +paper = { module = "io.papermc.paper:paper-api", version.ref = "paper" } + +worldguard = { group = "com.sk89q.worldguard", name = "worldguard-bukkit", version = "7.1.0-SNAPSHOT" } + +# Vital API +vital-common = { module = "com.ryderbelserion.vital:common", version.ref = "vital-common" } +vital-paper = { module = "com.ryderbelserion.vital:paper", version.ref = "vital-paper" } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..d64cd49 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..ccc1a9b --- /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.10.2-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists \ No newline at end of file diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..1aa94a4 --- /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/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..93e3f59 --- /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. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/run/bukkit.yml b/run/bukkit.yml new file mode 100644 index 0000000..e0be9fa --- /dev/null +++ b/run/bukkit.yml @@ -0,0 +1,32 @@ +settings: + allow-end: false + warn-on-overload: false + permissions-file: permissions.yml + update-folder: update + plugin-profiling: false + connection-throttle: 4000 + query-plugins: false + deprecated-verbose: default + shutdown-message: Server Closed + minimum-api: none + use-map-color-cache: true +spawn-limits: + monsters: 70 + animals: 10 + water-animals: 5 + water-ambient: 20 + water-underground-creature: 5 + axolotls: 5 + ambient: 15 +chunk-gc: + period-in-ticks: 600 +ticks-per: + animal-spawns: 400 + monster-spawns: 1 + water-spawns: 1 + water-ambient-spawns: 1 + water-underground-creature-spawns: 1 + axolotl-spawns: 1 + ambient-spawns: 1 + autosave: 6000 +aliases: now-in-commands.yml diff --git a/run/config/paper-global.yml b/run/config/paper-global.yml new file mode 100644 index 0000000..9dc4c41 --- /dev/null +++ b/run/config/paper-global.yml @@ -0,0 +1,135 @@ +# This is the global configuration file for Paper. +# As you can see, there's a lot to configure. Some options may impact gameplay, so use +# with caution, and make sure you know what each option does before configuring. +# +# If you need help with the configuration or have any questions related to Paper, +# join us in our Discord or check the docs page. +# +# The world configuration options have been moved inside +# their respective world folder. The files are named paper-world.yml +# +# Docs: https://docs.papermc.io/ +# Discord: https://discord.gg/papermc +# Website: https://papermc.io/ + +_version: 29 +block-updates: + disable-chorus-plant-updates: false + disable-mushroom-block-updates: false + disable-noteblock-updates: false + disable-tripwire-updates: false +chunk-loading-advanced: + auto-config-send-distance: true + player-max-concurrent-chunk-generates: 0 + player-max-concurrent-chunk-loads: 0 +chunk-loading-basic: + player-max-chunk-generate-rate: -1.0 + player-max-chunk-load-rate: 100.0 + player-max-chunk-send-rate: 75.0 +chunk-system: + gen-parallelism: default + io-threads: -1 + worker-threads: -1 +collisions: + enable-player-collisions: true + send-full-pos-for-hard-colliding-entities: true +commands: + fix-target-selector-tag-completion: true + suggest-player-names-when-null-tab-completions: true + time-command-affects-all-worlds: false +console: + enable-brigadier-completions: true + enable-brigadier-highlighting: true + has-all-permissions: false +item-validation: + book: + author: 8192 + page: 16384 + title: 8192 + book-size: + page-max: 2560 + total-multiplier: 0.98 + display-name: 8192 + lore-line: 8192 + resolve-selectors-in-books: false +logging: + deobfuscate-stacktraces: true +messages: + kick: + authentication-servers-down: + connection-throttle: Connection throttled! Please wait before reconnecting. + flying-player: + flying-vehicle: + no-permission: I'm sorry, but you do not have permission to perform this command. + Please contact the server administrators if you believe that this is in error. + use-display-name-in-quit-message: false +misc: + chat-threads: + chat-executor-core-size: -1 + chat-executor-max-size: -1 + client-interaction-leniency-distance: default + compression-level: default + fix-entity-position-desync: true + load-permissions-yml-before-plugins: true + max-joins-per-tick: 5 + region-file-cache-size: 256 + strict-advancement-dimension-check: false + use-alternative-luck-formula: false + use-dimension-type-for-custom-spawners: false +packet-limiter: + all-packets: + action: KICK + interval: 7.0 + max-packet-rate: 500.0 + kick-message: + overrides: + ServerboundPlaceRecipePacket: + action: DROP + interval: 4.0 + max-packet-rate: 5.0 +player-auto-save: + max-per-tick: -1 + rate: -1 +proxies: + bungee-cord: + online-mode: false + proxy-protocol: false + velocity: + enabled: false + online-mode: false + secret: '' +scoreboards: + save-empty-scoreboard-teams: false + track-plugin-scoreboards: false +spam-limiter: + incoming-packet-threshold: 300 + recipe-spam-increment: 1 + recipe-spam-limit: 20 + tab-spam-increment: 1 + tab-spam-limit: 500 +spark: + enable-immediately: false + enabled: true +timings: + enabled: false + hidden-config-entries: + - database + - proxies.velocity.secret + history-interval: 300 + history-length: 3600 + server-name: Unknown Server + server-name-privacy: false + url: https://timings.aikar.co/ + verbose: false +unsupported-settings: + allow-headless-pistons: false + allow-permanent-block-break-exploits: false + allow-piston-duplication: false + allow-tripwire-disarming-exploits: false + allow-unsafe-end-portal-teleportation: false + compression-format: ZLIB + perform-username-validation: true + skip-vanilla-damage-tick-when-shield-blocked: false +watchdog: + early-warning-delay: 10000 + early-warning-every: 5000 diff --git a/run/config/paper-world-defaults.yml b/run/config/paper-world-defaults.yml new file mode 100644 index 0000000..22fad16 --- /dev/null +++ b/run/config/paper-world-defaults.yml @@ -0,0 +1,322 @@ +# This is the world defaults configuration file for Paper. +# As you can see, there's a lot to configure. Some options may impact gameplay, so use +# with caution, and make sure you know what each option does before configuring. +# +# If you need help with the configuration or have any questions related to Paper, +# join us in our Discord or check the docs page. +# +# Configuration options here apply to all worlds, unless you specify overrides inside +# the world-specific config file inside each world folder. +# +# Docs: https://docs.papermc.io/ +# Discord: https://discord.gg/papermc +# Website: https://papermc.io/ + +_version: 31 +anticheat: + anti-xray: + enabled: false + engine-mode: 1 + hidden-blocks: + - copper_ore + - deepslate_copper_ore + - gold_ore + - deepslate_gold_ore + - iron_ore + - deepslate_iron_ore + - coal_ore + - deepslate_coal_ore + - lapis_ore + - deepslate_lapis_ore + - mossy_cobblestone + - obsidian + - chest + - diamond_ore + - deepslate_diamond_ore + - redstone_ore + - deepslate_redstone_ore + - clay + - emerald_ore + - deepslate_emerald_ore + - ender_chest + lava-obscures: false + max-block-height: 64 + replacement-blocks: + - stone + - oak_planks + - deepslate + update-radius: 2 + use-permission: false + obfuscation: + items: + hide-durability: false + hide-itemmeta: false + hide-itemmeta-with-visual-effects: false +chunks: + auto-save-interval: default + delay-chunk-unloads-by: 10s + entity-per-chunk-save-limit: + arrow: -1 + ender_pearl: -1 + experience_orb: -1 + fireball: -1 + small_fireball: -1 + snowball: -1 + fixed-chunk-inhabited-time: -1 + flush-regions-on-save: false + max-auto-save-chunks-per-tick: 24 + prevent-moving-into-unloaded-chunks: false +collisions: + allow-player-cramming-damage: false + allow-vehicle-collisions: true + fix-climbing-bypassing-cramming-rule: false + max-entity-collisions: 8 + only-players-collide: false +command-blocks: + force-follow-perm-level: true + permissions-level: 2 +entities: + armor-stands: + do-collision-entity-lookups: true + tick: true + behavior: + allow-spider-world-border-climbing: true + baby-zombie-movement-modifier: 0.5 + disable-chest-cat-detection: false + disable-creeper-lingering-effect: false + disable-player-crits: false + door-breaking-difficulty: + husk: + - HARD + vindicator: + - NORMAL + - HARD + zombie: + - HARD + zombie_villager: + - HARD + zombified_piglin: + - HARD + ender-dragons-death-always-places-dragon-egg: false + experience-merge-max-value: -1 + mobs-can-always-pick-up-loot: + skeletons: false + zombies: false + nerf-pigmen-from-nether-portals: false + only-merge-items-horizontally: false + parrots-are-unaffected-by-player-movement: false + phantoms-do-not-spawn-on-creative-players: true + phantoms-only-attack-insomniacs: true + phantoms-spawn-attempt-max-seconds: 119 + phantoms-spawn-attempt-min-seconds: 60 + piglins-guard-chests: true + pillager-patrols: + disable: false + spawn-chance: 0.2 + spawn-delay: + per-player: false + ticks: 12000 + start: + day: 5 + per-player: false + player-insomnia-start-ticks: 72000 + should-remove-dragon: false + spawner-nerfed-mobs-should-jump: false + zombie-villager-infection-chance: default + zombies-target-turtle-eggs: true + entities-target-with-follow-range: false + markers: + tick: true + mob-effects: + immune-to-wither-effect: + wither: true + wither-skeleton: true + spiders-immune-to-poison-effect: true + sniffer: + boosted-hatch-time: default + hatch-time: default + spawning: + all-chunks-are-slime-chunks: false + alt-item-despawn-rate: + enabled: false + items: + cobblestone: 300 + count-all-mobs-for-spawning: false + creative-arrow-despawn-rate: default + despawn-range-shape: ELLIPSOID + despawn-ranges: + ambient: + hard: 128 + soft: 32 + axolotls: + hard: 128 + soft: 32 + creature: + hard: 128 + soft: 32 + misc: + hard: 128 + soft: 32 + monster: + hard: 128 + soft: 32 + underground_water_creature: + hard: 128 + soft: 32 + water_ambient: + hard: 64 + soft: 32 + water_creature: + hard: 128 + soft: 32 + disable-mob-spawner-spawn-egg-transformation: false + duplicate-uuid: + mode: SAFE_REGEN + safe-regen-delete-range: 32 + filter-bad-tile-entity-nbt-from-falling-blocks: true + filtered-entity-tag-nbt-paths: + - Pos + - Motion + - SleepingX + - SleepingY + - SleepingZ + iron-golems-can-spawn-in-air: false + monster-spawn-max-light-level: default + non-player-arrow-despawn-rate: default + per-player-mob-spawns: true + scan-for-legacy-ender-dragon: true + skeleton-horse-thunder-spawn-chance: default + slime-spawn-height: + slime-chunk: + maximum: 40.0 + surface-biome: + maximum: 70.0 + minimum: 50.0 + spawn-limits: + ambient: -1 + axolotls: -1 + creature: -1 + monster: -1 + underground_water_creature: -1 + water_ambient: -1 + water_creature: -1 + ticks-per-spawn: + ambient: -1 + axolotls: -1 + creature: -1 + monster: -1 + underground_water_creature: -1 + water_ambient: -1 + water_creature: -1 + wandering-trader: + spawn-chance-failure-increment: 25 + spawn-chance-max: 75 + spawn-chance-min: 25 + spawn-day-length: 24000 + spawn-minute-length: 1200 + wateranimal-spawn-height: + maximum: default + minimum: default + tracking-range-y: + animal: default + display: default + enabled: false + misc: default + monster: default + other: default + player: default +environment: + disable-explosion-knockback: false + disable-ice-and-snow: false + disable-teleportation-suffocation-check: false + disable-thunder: false + fire-tick-delay: 30 + frosted-ice: + delay: + max: 40 + min: 20 + enabled: true + generate-flat-bedrock: false + locate-structures-outside-world-border: false + max-block-ticks: 65536 + max-fluid-ticks: 65536 + nether-ceiling-void-damage-height: disabled + optimize-explosions: false + portal-create-radius: 16 + portal-search-radius: 128 + portal-search-vanilla-dimension-scaling: true + treasure-maps: + enabled: true + find-already-discovered: + loot-tables: default + villager-trade: false + void-damage-amount: 4.0 + void-damage-min-build-height-offset: -64.0 + water-over-lava-flow-speed: 5 +feature-seeds: + generate-random-seeds-for-all: false +fishing-time-range: + maximum: 600 + minimum: 100 +fixes: + disable-unloaded-chunk-enderpearl-exploit: true + falling-block-height-nerf: disabled + fix-items-merging-through-walls: false + prevent-tnt-from-moving-in-water: false + split-overstacked-loot: true + tnt-entity-height-nerf: disabled +hopper: + cooldown-when-full: true + disable-move-event: false + ignore-occluding-blocks: false +lootables: + auto-replenish: false + max-refills: -1 + refresh-max: 2d + refresh-min: 12h + reset-seed-on-fill: true + restrict-player-reloot: true + restrict-player-reloot-time: disabled + retain-unlooted-shulker-box-loot-table-on-non-player-break: true +maps: + item-frame-cursor-limit: 128 + item-frame-cursor-update-interval: 10 +max-growth-height: + bamboo: + max: 16 + min: 11 + cactus: 3 + reeds: 3 +misc: + alternate-current-update-order: HORIZONTAL_FIRST_OUTWARD + disable-end-credits: false + disable-relative-projectile-velocity: false + disable-sprint-interruption-on-attack: false + light-queue-size: 20 + max-leash-distance: 10.0 + redstone-implementation: VANILLA + shield-blocking-delay: 5 + show-sign-click-command-failure-msgs-to-player: false + update-pathfinding-on-block-update: true +scoreboards: + allow-non-player-entities-on-scoreboards: true + use-vanilla-world-scoreboard-name-coloring: false +spawn: + allow-using-signs-inside-spawn-protection: false + keep-spawn-loaded: true + keep-spawn-loaded-range: 10 +tick-rates: + behavior: + villager: + validatenearbypoi: -1 + container-update: 1 + dry-farmland: 1 + grass-spread: 1 + mob-spawner: 1 + sensor: + villager: + secondarypoisensor: 40 + wet-farmland: 1 +unsupported-settings: + disable-world-ticking-when-empty: false + fix-invulnerable-end-crystal-exploit: true diff --git a/run/eula.txt b/run/eula.txt new file mode 100644 index 0000000..1dd01a0 --- /dev/null +++ b/run/eula.txt @@ -0,0 +1,3 @@ +#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA). +#Mon Oct 16 20:19:20 EDT 2023 +eula=true diff --git a/run/ops.json b/run/ops.json new file mode 100644 index 0000000..7c45478 --- /dev/null +++ b/run/ops.json @@ -0,0 +1,8 @@ +[ + { + "uuid": "45123240-248b-44e3-93c9-5c89093ffaad", + "name": "ryderbelserion", + "level": 4, + "bypassesPlayerLimit": false + } +] \ No newline at end of file diff --git a/run/server.properties b/run/server.properties new file mode 100644 index 0000000..5e18b5f --- /dev/null +++ b/run/server.properties @@ -0,0 +1,64 @@ +#Minecraft server properties +#Mon Oct 14 12:22:12 EDT 2024 +accepts-transfers=false +allow-flight=false +allow-nether=false +broadcast-console-to-ops=false +broadcast-rcon-to-ops=false +bug-report-link= +debug=false +difficulty=peaceful +enable-command-block=false +enable-jmx-monitoring=false +enable-query=false +enable-rcon=false +enable-status=true +enforce-secure-profile=true +enforce-whitelist=false +entity-broadcast-range-percentage=100 +force-gamemode=false +function-permission-level=2 +gamemode=survival +generate-structures=true +generator-settings={} +hardcore=false +hide-online-players=false +initial-disabled-packs= +initial-enabled-packs=vanilla +level-name=world +level-seed= +level-type=minecraft\:normal +log-ips=false +max-chained-neighbor-updates=1000000 +max-players=5 +max-tick-time=60000 +max-world-size=29999984 +motd=A test server +network-compression-threshold=256 +online-mode=true +op-permission-level=4 +player-idle-timeout=0 +prevent-proxy-connections=false +pvp=true +query.port=25565 +rate-limit=0 +rcon.password= +rcon.port=25575 +region-file-compression=deflate +require-resource-pack=false +resource-pack= +resource-pack-id= +resource-pack-prompt= +resource-pack-sha1= +server-ip= +server-port=25565 +simulation-distance=10 +spawn-animals=true +spawn-monsters=true +spawn-npcs=true +spawn-protection=32 +sync-chunk-writes=false +text-filtering-config= +use-native-transport=true +view-distance=6 +white-list=false diff --git a/run/spigot.yml b/run/spigot.yml new file mode 100644 index 0000000..e976832 --- /dev/null +++ b/run/spigot.yml @@ -0,0 +1,183 @@ +# This is the main configuration file for Spigot. +# As you can see, there's tons to configure. Some options may impact gameplay, so use +# with caution, and make sure you know what each option does before configuring. +# For a reference for any variable inside this file, check out the Spigot wiki at +# http://www.spigotmc.org/wiki/spigot-configuration/ +# +# If you need help with the configuration or have any questions related to Spigot, +# join us at the Discord or drop by our forums and leave a post. +# +# Discord: https://www.spigotmc.org/go/discord +# Forums: http://www.spigotmc.org/ + +settings: + debug: false + timeout-time: 60 + restart-on-crash: false + restart-script: ./start.sh + save-user-cache-on-stop-only: false + moved-too-quickly-multiplier: 10.0 + moved-wrongly-threshold: 0.0625 + player-shuffle: 0 + user-cache-size: 1000 + netty-threads: 4 + attribute: + maxAbsorption: + max: 2048.0 + maxHealth: + max: 2048.0 + movementSpeed: + max: 2048.0 + attackDamage: + max: 2048.0 + log-villager-deaths: false + log-named-deaths: false + sample-count: 12 + bungeecord: false +messages: + restart: Server is restarting + whitelist: You are not whitelisted on this server! + unknown-command: Unknown command. Type "/help" for help. + server-full: The server is full! + outdated-client: Outdated client! Please use {0} + outdated-server: Outdated server! I'm still on {0} +advancements: + disable-saving: true + disabled: + - minecraft:story/disabled +commands: + silent-commandblock-console: false + spam-exclusions: + - /skill + replace-commands: + - setblock + - summon + - testforblock + - tellraw + log: true + tab-complete: 0 + send-namespaced: true +players: + disable-saving: false +world-settings: + default: + unload-frozen-chunks: false + seed-trialchambers: 94251327 + below-zero-generation-in-existing-chunks: true + hanging-tick-frequency: 100 + dragon-death-sound-radius: 0 + wither-spawn-sound-radius: 0 + end-portal-sound-radius: 0 + zombie-aggressive-towards-villager: true + entity-activation-range: + animals: 32 + monsters: 32 + raiders: 48 + misc: 16 + water: 16 + villagers: 32 + flying-monsters: 32 + wake-up-inactive: + animals-max-per-tick: 4 + animals-every: 1200 + animals-for: 100 + monsters-max-per-tick: 8 + monsters-every: 400 + monsters-for: 100 + villagers-max-per-tick: 4 + villagers-every: 600 + villagers-for: 100 + flying-monsters-max-per-tick: 8 + flying-monsters-every: 200 + flying-monsters-for: 100 + villagers-work-immunity-after: 100 + villagers-work-immunity-for: 20 + villagers-active-for-panic: true + tick-inactive-villagers: true + ignore-spectators: false + seed-village: 10387312 + seed-desert: 14357617 + seed-igloo: 14357618 + seed-jungle: 14357619 + seed-swamp: 14357620 + seed-monument: 10387313 + seed-shipwreck: 165745295 + seed-ocean: 14357621 + seed-outpost: 165745296 + seed-endcity: 10387313 + seed-slime: 987234911 + seed-nether: 30084232 + seed-mansion: 10387319 + seed-fossil: 14357921 + seed-portal: 34222645 + seed-ancientcity: 20083232 + seed-trailruins: 83469867 + seed-buriedtreasure: 10387320 + seed-mineshaft: default + seed-stronghold: default + entity-tracking-range: + players: 48 + animals: 48 + monsters: 48 + misc: 32 + display: 128 + other: 64 + ticks-per: + hopper-transfer: 8 + hopper-check: 1 + hopper-amount: 1 + hopper-can-load-chunks: false + max-tnt-per-tick: 100 + max-tick-time: + tile: 50 + entity: 50 + hunger: + jump-walk-exhaustion: 0.05 + jump-sprint-exhaustion: 0.2 + combat-exhaustion: 0.1 + regen-exhaustion: 6.0 + swim-multiplier: 0.01 + sprint-multiplier: 0.1 + other-multiplier: 0.0 + enable-zombie-pigmen-portal-spawns: true + thunder-chance: 100000 + growth: + cactus-modifier: 100 + cane-modifier: 100 + melon-modifier: 100 + mushroom-modifier: 100 + pumpkin-modifier: 100 + sapling-modifier: 100 + beetroot-modifier: 100 + carrot-modifier: 100 + potato-modifier: 100 + torchflower-modifier: 100 + wheat-modifier: 100 + netherwart-modifier: 100 + vine-modifier: 100 + cocoa-modifier: 100 + bamboo-modifier: 100 + sweetberry-modifier: 100 + kelp-modifier: 100 + twistingvines-modifier: 100 + weepingvines-modifier: 100 + cavevines-modifier: 100 + glowberry-modifier: 100 + pitcherplant-modifier: 100 + mob-spawn-range: 8 + simulation-distance: default + merge-radius: + item: 2.5 + exp: 3.0 + arrow-despawn-rate: 1200 + trident-despawn-rate: 1200 + view-distance: default + item-despawn-rate: 6000 + nerf-spawner-mobs: false + verbose: false + worldeditregentempworld: + verbose: false +config-version: 12 +stats: + disable-saving: false + forced-stats: {} diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..bb39212 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "SimpleFlags" \ No newline at end of file diff --git a/src/main/java/com/ryderbelserion/simpleflags/LibraryLoader.java b/src/main/java/com/ryderbelserion/simpleflags/LibraryLoader.java new file mode 100644 index 0000000..02871f7 --- /dev/null +++ b/src/main/java/com/ryderbelserion/simpleflags/LibraryLoader.java @@ -0,0 +1,24 @@ +package com.ryderbelserion.simpleflags; + +import io.papermc.paper.plugin.loader.PluginClasspathBuilder; +import io.papermc.paper.plugin.loader.PluginLoader; +import io.papermc.paper.plugin.loader.library.impl.MavenLibraryResolver; +import org.eclipse.aether.artifact.DefaultArtifact; +import org.eclipse.aether.graph.Dependency; +import org.eclipse.aether.repository.RemoteRepository; +import org.jetbrains.annotations.NotNull; + +public class LibraryLoader implements PluginLoader { + + @Override + public void classloader(@NotNull PluginClasspathBuilder classpathBuilder) { + MavenLibraryResolver resolver = new MavenLibraryResolver(); + + resolver.addDependency(new Dependency(new DefaultArtifact("com.ryderbelserion.vital:paper:1.0.6"), null)); + + resolver.addRepository(new RemoteRepository.Builder("crazycrew-libraries", "default", "https://repo.crazycrew.us/libraries").build()); + resolver.addRepository(new RemoteRepository.Builder("paper", "default", "https://repo.papermc.io/repository/maven-public").build()); + + classpathBuilder.addLibrary(resolver); + } +} \ No newline at end of file diff --git a/src/main/java/com/ryderbelserion/simpleflags/SimpleFlags.java b/src/main/java/com/ryderbelserion/simpleflags/SimpleFlags.java new file mode 100644 index 0000000..2f6ba11 --- /dev/null +++ b/src/main/java/com/ryderbelserion/simpleflags/SimpleFlags.java @@ -0,0 +1,75 @@ +package com.ryderbelserion.simpleflags; + +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import com.ryderbelserion.simpleflags.commands.BaseCommand; +import com.ryderbelserion.simpleflags.commands.types.CommandHelp; +import com.ryderbelserion.simpleflags.commands.types.CommandReload; +import com.ryderbelserion.simpleflags.config.ConfigManager; +import com.ryderbelserion.simpleflags.flags.FlagManager; +import com.ryderbelserion.simpleflags.flags.types.DrownFlag; +import com.ryderbelserion.simpleflags.flags.types.NaturalFlag; +import com.ryderbelserion.simpleflags.listeners.DrowningListener; +import com.ryderbelserion.simpleflags.listeners.NaturalListener; +import com.ryderbelserion.vital.paper.Vital; +import com.sk89q.worldguard.WorldGuard; +import com.sk89q.worldguard.protection.regions.RegionContainer; +import io.papermc.paper.command.brigadier.CommandSourceStack; +import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents; +import org.jetbrains.annotations.NotNull; +import java.util.List; + +public class SimpleFlags extends Vital { + + private WorldGuard worldGuard; + + private FlagManager flagManager; + + @Override + public void onLoad() { + ConfigManager.load(getDataFolder()); + + this.worldGuard = WorldGuard.getInstance(); + + this.flagManager = new FlagManager(); + + List.of( + new DrownFlag(), + new NaturalFlag() + ).forEach(this.flagManager::addFlag); + } + + @Override + public void onEnable() { + getServer().getPluginManager().registerEvents(new NaturalListener(), this); + getServer().getPluginManager().registerEvents(new DrowningListener(), this); + + // Register commands. + getLifecycleManager().registerEventHandler(LifecycleEvents.COMMANDS, event -> { + LiteralArgumentBuilder root = new BaseCommand().registerPermission().literal().createBuilder(); + + List.of( + new CommandReload(), + new CommandHelp() + ).forEach(command -> root.then(command.registerPermission().literal())); + + event.registrar().register(root.build(), "the base command for RedstonePvP"); + }); + } + + @Override + public void onDisable() { + super.onDisable(); + } + + public @NotNull WorldGuard getWorldGuard() { + return this.worldGuard; + } + + public @NotNull RegionContainer getRegions() { + return this.worldGuard.getPlatform().getRegionContainer(); + } + + public @NotNull FlagManager getFlagManager() { + return this.flagManager; + } +} \ No newline at end of file diff --git a/src/main/java/com/ryderbelserion/simpleflags/commands/BaseCommand.java b/src/main/java/com/ryderbelserion/simpleflags/commands/BaseCommand.java new file mode 100644 index 0000000..cc85558 --- /dev/null +++ b/src/main/java/com/ryderbelserion/simpleflags/commands/BaseCommand.java @@ -0,0 +1,61 @@ +package com.ryderbelserion.simpleflags.commands; + +import ch.jalu.configme.SettingsManager; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import com.mojang.brigadier.tree.LiteralCommandNode; +import com.ryderbelserion.simpleflags.SimpleFlags; +import com.ryderbelserion.simpleflags.config.ConfigManager; +import com.ryderbelserion.simpleflags.config.impl.Locale; +import com.ryderbelserion.vital.paper.commands.PaperCommand; +import com.ryderbelserion.vital.paper.commands.context.PaperCommandInfo; +import io.papermc.paper.command.brigadier.CommandSourceStack; +import io.papermc.paper.command.brigadier.Commands; +import org.bukkit.command.CommandSender; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionDefault; +import org.bukkit.plugin.PluginManager; +import org.bukkit.plugin.java.JavaPlugin; +import org.jetbrains.annotations.NotNull; + +public class BaseCommand extends PaperCommand { + + private final SimpleFlags plugin = JavaPlugin.getPlugin(SimpleFlags.class); + + private final SettingsManager locale = ConfigManager.getLocale(); + + @Override + public void execute(final PaperCommandInfo info) { + final CommandSender sender = info.getCommandSender(); + + this.locale.getProperty(Locale.help).forEach(sender::sendRichMessage); + } + + @Override + public @NotNull final String getPermission() { + return "simpleflags.help"; + } + + @Override + public @NotNull final LiteralCommandNode literal() { + final LiteralArgumentBuilder root = Commands.literal("simpleflags").requires(source -> source.getSender().hasPermission(getPermission())); + + return root.executes(context -> { + execute(new PaperCommandInfo(context)); + + return com.mojang.brigadier.Command.SINGLE_SUCCESS; + }).build(); + } + + @Override + public @NotNull final PaperCommand registerPermission() { + final PluginManager pluginManager = this.plugin.getServer().getPluginManager(); + + final Permission permission = pluginManager.getPermission(getPermission()); + + if (permission == null) { + pluginManager.addPermission(new Permission(getPermission(), PermissionDefault.OP)); + } + + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/ryderbelserion/simpleflags/commands/types/CommandHelp.java b/src/main/java/com/ryderbelserion/simpleflags/commands/types/CommandHelp.java new file mode 100644 index 0000000..243d3f6 --- /dev/null +++ b/src/main/java/com/ryderbelserion/simpleflags/commands/types/CommandHelp.java @@ -0,0 +1,61 @@ +package com.ryderbelserion.simpleflags.commands.types; + +import ch.jalu.configme.SettingsManager; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import com.mojang.brigadier.tree.LiteralCommandNode; +import com.ryderbelserion.simpleflags.SimpleFlags; +import com.ryderbelserion.simpleflags.config.ConfigManager; +import com.ryderbelserion.simpleflags.config.impl.Locale; +import com.ryderbelserion.vital.paper.commands.PaperCommand; +import com.ryderbelserion.vital.paper.commands.context.PaperCommandInfo; +import io.papermc.paper.command.brigadier.CommandSourceStack; +import io.papermc.paper.command.brigadier.Commands; +import org.bukkit.command.CommandSender; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionDefault; +import org.bukkit.plugin.PluginManager; +import org.bukkit.plugin.java.JavaPlugin; +import org.jetbrains.annotations.NotNull; + +public class CommandHelp extends PaperCommand { + + private final SimpleFlags plugin = JavaPlugin.getPlugin(SimpleFlags.class); + + private final SettingsManager locale = ConfigManager.getLocale(); + + @Override + public void execute(final PaperCommandInfo info) { + final CommandSender sender = info.getCommandSender(); + + this.locale.getProperty(Locale.help).forEach(sender::sendRichMessage); + } + + @Override + public @NotNull final String getPermission() { + return "simpleflags.help"; + } + + @Override + public @NotNull final LiteralCommandNode literal() { + final LiteralArgumentBuilder root = Commands.literal("help").requires(source -> source.getSender().hasPermission(getPermission())); + + return root.executes(context -> { + execute(new PaperCommandInfo(context)); + + return com.mojang.brigadier.Command.SINGLE_SUCCESS; + }).build(); + } + + @Override + public @NotNull final PaperCommand registerPermission() { + final PluginManager pluginManager = this.plugin.getServer().getPluginManager(); + + final Permission permission = pluginManager.getPermission(getPermission()); + + if (permission == null) { + pluginManager.addPermission(new Permission(getPermission(), PermissionDefault.OP)); + } + + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/ryderbelserion/simpleflags/commands/types/CommandReload.java b/src/main/java/com/ryderbelserion/simpleflags/commands/types/CommandReload.java new file mode 100644 index 0000000..b242168 --- /dev/null +++ b/src/main/java/com/ryderbelserion/simpleflags/commands/types/CommandReload.java @@ -0,0 +1,68 @@ +package com.ryderbelserion.simpleflags.commands.types; + +import ch.jalu.configme.SettingsManager; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import com.mojang.brigadier.tree.LiteralCommandNode; +import com.ryderbelserion.simpleflags.SimpleFlags; +import com.ryderbelserion.simpleflags.config.ConfigManager; +import com.ryderbelserion.simpleflags.config.impl.Config; +import com.ryderbelserion.simpleflags.config.impl.Locale; +import com.ryderbelserion.vital.paper.commands.PaperCommand; +import com.ryderbelserion.vital.paper.commands.context.PaperCommandInfo; +import io.papermc.paper.command.brigadier.CommandSourceStack; +import io.papermc.paper.command.brigadier.Commands; +import org.bukkit.command.CommandSender; +import org.bukkit.permissions.Permission; +import org.bukkit.permissions.PermissionDefault; +import org.bukkit.plugin.PluginManager; +import org.bukkit.plugin.java.JavaPlugin; +import org.jetbrains.annotations.NotNull; + +public class CommandReload extends PaperCommand { + + private final SimpleFlags plugin = JavaPlugin.getPlugin(SimpleFlags.class); + + private final SettingsManager config = ConfigManager.getConfig(); + + private final SettingsManager locale = ConfigManager.getLocale(); + + @Override + public void execute(final PaperCommandInfo info) { + final CommandSender sender = info.getCommandSender(); + + this.config.reload(); + + this.locale.reload(); + + sender.sendRichMessage(this.locale.getProperty(Locale.reload_plugin).replaceAll("\\{prefix}", this.config.getProperty(Config.command_prefix))); + } + + @Override + public @NotNull final String getPermission() { + return "simpleflags.reload"; + } + + @Override + public @NotNull final LiteralCommandNode literal() { + final LiteralArgumentBuilder root = Commands.literal("reload").requires(source -> source.getSender().hasPermission(getPermission())); + + return root.executes(context -> { + execute(new PaperCommandInfo(context)); + + return com.mojang.brigadier.Command.SINGLE_SUCCESS; + }).build(); + } + + @Override + public @NotNull final PaperCommand registerPermission() { + final PluginManager pluginManager = this.plugin.getServer().getPluginManager(); + + final Permission permission = pluginManager.getPermission(getPermission()); + + if (permission == null) { + pluginManager.addPermission(new Permission(getPermission(), PermissionDefault.OP)); + } + + return this; + } +} \ No newline at end of file diff --git a/src/main/java/com/ryderbelserion/simpleflags/config/ConfigManager.java b/src/main/java/com/ryderbelserion/simpleflags/config/ConfigManager.java new file mode 100644 index 0000000..f2c761b --- /dev/null +++ b/src/main/java/com/ryderbelserion/simpleflags/config/ConfigManager.java @@ -0,0 +1,39 @@ +package com.ryderbelserion.simpleflags.config; + +import ch.jalu.configme.SettingsManager; +import ch.jalu.configme.SettingsManagerBuilder; +import ch.jalu.configme.resource.YamlFileResourceOptions; +import com.ryderbelserion.simpleflags.config.impl.Config; +import com.ryderbelserion.simpleflags.config.impl.Locale; +import java.io.File; + +public class ConfigManager { + + private static SettingsManager config; + private static SettingsManager locale; + + public static void load(final File dataFolder) { + // Create config files + YamlFileResourceOptions builder = YamlFileResourceOptions.builder().indentationSize(2).build(); + + config = SettingsManagerBuilder + .withYamlFile(new File(dataFolder, "config.yml"), builder) + .useDefaultMigrationService() + .configurationData(Config.class) + .create(); + + locale = SettingsManagerBuilder + .withYamlFile(new File(dataFolder, "messages.yml"), builder) + .useDefaultMigrationService() + .configurationData(Locale.class) + .create(); + } + + public static SettingsManager getConfig() { + return config; + } + + public static SettingsManager getLocale() { + return locale; + } +} \ No newline at end of file diff --git a/src/main/java/com/ryderbelserion/simpleflags/config/impl/Config.java b/src/main/java/com/ryderbelserion/simpleflags/config/impl/Config.java new file mode 100644 index 0000000..6d9a139 --- /dev/null +++ b/src/main/java/com/ryderbelserion/simpleflags/config/impl/Config.java @@ -0,0 +1,19 @@ +package com.ryderbelserion.simpleflags.config.impl; + +import ch.jalu.configme.Comment; +import ch.jalu.configme.SettingsHolder; +import ch.jalu.configme.properties.Property; +import static ch.jalu.configme.properties.PropertyInitializer.newProperty; + +public class Config implements SettingsHolder { + + @Comment("The prefix that appears in front of messages.") + public static final Property command_prefix = newProperty("root.prefix", "[SimpleFlags]: "); + + @Comment("The flag prevent_drowning as you guessed it, it prevents drowning if enabled.") + public static final Property drowning_flag = newProperty("flags.drowning-flag", false); + + @Comment("The flag prevent_natural_spawning prevents natural mob spawns in regions.") + public static final Property natural_spawning_flag = newProperty("flags.natural-spawning-flag", false); + +} \ No newline at end of file diff --git a/src/main/java/com/ryderbelserion/simpleflags/config/impl/Locale.java b/src/main/java/com/ryderbelserion/simpleflags/config/impl/Locale.java new file mode 100644 index 0000000..9168975 --- /dev/null +++ b/src/main/java/com/ryderbelserion/simpleflags/config/impl/Locale.java @@ -0,0 +1,21 @@ +package com.ryderbelserion.simpleflags.config.impl; + +import ch.jalu.configme.SettingsHolder; +import ch.jalu.configme.properties.Property; + +import java.util.List; + +import static ch.jalu.configme.properties.PropertyInitializer.newListProperty; +import static ch.jalu.configme.properties.PropertyInitializer.newProperty; + +public class Locale implements SettingsHolder { + + public static final Property reload_plugin = newProperty("root.reload-plugin", "{prefix}You have reloaded the plugin."); + + public static final Property> help = newListProperty("root.help-menu", List.of( + "SimpleFlags Help Menu", + "", + " /simpleflags - Shows this menu.", + " /simpleflags reload - Reloads the plugin." + )); +} \ No newline at end of file diff --git a/src/main/java/com/ryderbelserion/simpleflags/flags/FlagBuilder.java b/src/main/java/com/ryderbelserion/simpleflags/flags/FlagBuilder.java new file mode 100644 index 0000000..92e1b8a --- /dev/null +++ b/src/main/java/com/ryderbelserion/simpleflags/flags/FlagBuilder.java @@ -0,0 +1,39 @@ +package com.ryderbelserion.simpleflags.flags; + +import ch.jalu.configme.SettingsManager; +import com.ryderbelserion.simpleflags.SimpleFlags; +import com.ryderbelserion.simpleflags.config.ConfigManager; +import com.sk89q.worldguard.protection.flags.Flag; +import com.sk89q.worldguard.protection.flags.registry.FlagRegistry; +import com.sk89q.worldguard.protection.regions.RegionQuery; +import org.bukkit.plugin.java.JavaPlugin; + +public abstract class FlagBuilder { + + protected SimpleFlags plugin = JavaPlugin.getPlugin(SimpleFlags.class); + + protected SettingsManager config = ConfigManager.getConfig(); + + public abstract void register(); + + public abstract String getName(); + + public abstract T getFlag(); + + public abstract boolean isEnabled(); + + /** + * @return A query of regions. + */ + protected RegionQuery getQuery() { + return this.plugin.getRegions().createQuery(); + } + + /** + * @return The flag registry. + */ + protected FlagRegistry getRegistry() { + return this.plugin.getWorldGuard().getFlagRegistry(); + } + +} \ No newline at end of file diff --git a/src/main/java/com/ryderbelserion/simpleflags/flags/FlagManager.java b/src/main/java/com/ryderbelserion/simpleflags/flags/FlagManager.java new file mode 100644 index 0000000..a672676 --- /dev/null +++ b/src/main/java/com/ryderbelserion/simpleflags/flags/FlagManager.java @@ -0,0 +1,35 @@ +package com.ryderbelserion.simpleflags.flags; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +public class FlagManager { + + private final Map> flags = new HashMap<>(); + + public > void addFlag(F builder) { + // Register the flag. + builder.register(); + + // Add to hashmap. + this.flags.putIfAbsent(builder.getName(), builder); + } + + @SuppressWarnings("BooleanMethodIsAlwaysInverted") + public boolean hasFlag(String name) { + return this.flags.containsKey(name); + } + + public FlagBuilder getFlag(String name) { + return this.flags.get(name); + } + + public void removeFlag(String name) { + this.flags.remove(name); + } + + public Map> getFlags() { + return Collections.unmodifiableMap(this.flags); + } +} \ No newline at end of file diff --git a/src/main/java/com/ryderbelserion/simpleflags/flags/builders/IntegerFlagBuilder.java b/src/main/java/com/ryderbelserion/simpleflags/flags/builders/IntegerFlagBuilder.java new file mode 100644 index 0000000..fc7447f --- /dev/null +++ b/src/main/java/com/ryderbelserion/simpleflags/flags/builders/IntegerFlagBuilder.java @@ -0,0 +1,11 @@ +package com.ryderbelserion.simpleflags.flags.builders; + +import com.ryderbelserion.simpleflags.flags.FlagBuilder; +import com.sk89q.worldguard.protection.flags.IntegerFlag; + +public abstract class IntegerFlagBuilder extends FlagBuilder { + + @Override + public abstract IntegerFlag getFlag(); + +} \ No newline at end of file diff --git a/src/main/java/com/ryderbelserion/simpleflags/flags/builders/StateFlagBuilder.java b/src/main/java/com/ryderbelserion/simpleflags/flags/builders/StateFlagBuilder.java new file mode 100644 index 0000000..f63e755 --- /dev/null +++ b/src/main/java/com/ryderbelserion/simpleflags/flags/builders/StateFlagBuilder.java @@ -0,0 +1,42 @@ +package com.ryderbelserion.simpleflags.flags.builders; + +import com.ryderbelserion.simpleflags.flags.FlagBuilder; +import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldguard.bukkit.WorldGuardPlugin; +import com.sk89q.worldguard.protection.flags.StateFlag; +import org.bukkit.damage.DamageSource; +import org.bukkit.damage.DamageType; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.CreatureSpawnEvent; + +public abstract class StateFlagBuilder extends FlagBuilder { + + @Override + public abstract StateFlag getFlag(); + + /** + * Prevent any type of damage in any region. + * + * @param player the player to prevent damage to. + * @param source the source of the damage. + * @param type the type of the damage to check. + * @param flag the flag. + * @return true or false + */ + public boolean preventDamage(Player player, DamageSource source, DamageType type, StateFlag flag) { + return source.getDamageType() == type && getQuery().testState(BukkitAdapter.adapt(player.getLocation()), WorldGuardPlugin.inst().wrapPlayer(player), flag); + } + + /** + * Prevent spawning based on a supplied spawn reason. + * + * @param location the location to check. + * @param receivingReason the reason from the event. + * @param reason your reason. + * @param flag the flag. + * @return true or false + */ + public boolean preventSpawning(org.bukkit.Location location, CreatureSpawnEvent.SpawnReason receivingReason, CreatureSpawnEvent.SpawnReason reason, StateFlag flag) { + return receivingReason != reason || getQuery().testState(BukkitAdapter.adapt(location), null, flag); + } +} \ No newline at end of file diff --git a/src/main/java/com/ryderbelserion/simpleflags/flags/enums/CustomFlags.java b/src/main/java/com/ryderbelserion/simpleflags/flags/enums/CustomFlags.java new file mode 100644 index 0000000..3211f77 --- /dev/null +++ b/src/main/java/com/ryderbelserion/simpleflags/flags/enums/CustomFlags.java @@ -0,0 +1,18 @@ +package com.ryderbelserion.simpleflags.flags.enums; + +public enum CustomFlags { + + NATURAL_FLAG("prevent_natural_spawning"), + DROWN_FLAG("prevent_drowning"), + CAPACITY_FLAG("max_players"); + + private final String name; + + CustomFlags(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } +} \ No newline at end of file diff --git a/src/main/java/com/ryderbelserion/simpleflags/flags/types/DrownFlag.java b/src/main/java/com/ryderbelserion/simpleflags/flags/types/DrownFlag.java new file mode 100644 index 0000000..91412b0 --- /dev/null +++ b/src/main/java/com/ryderbelserion/simpleflags/flags/types/DrownFlag.java @@ -0,0 +1,48 @@ +package com.ryderbelserion.simpleflags.flags.types; + +import com.ryderbelserion.simpleflags.config.impl.Config; +import com.ryderbelserion.simpleflags.flags.builders.StateFlagBuilder; +import com.ryderbelserion.simpleflags.flags.enums.CustomFlags; +import com.sk89q.worldguard.protection.flags.Flag; +import com.sk89q.worldguard.protection.flags.StateFlag; +import com.sk89q.worldguard.protection.flags.registry.FlagConflictException; +import java.util.logging.Level; + +public class DrownFlag extends StateFlagBuilder { + + private StateFlag flag; + + @Override + public void register() { + if (!isEnabled()) return; + + try { + getRegistry().register(this.flag = new StateFlag("prevent-drowning", true)); + } catch (FlagConflictException exception) { + Flag existingFlag = getRegistry().get("prevent-drowning"); + + if (existingFlag instanceof StateFlag stateFlag) { + this.flag = stateFlag; + + return; + } + + this.plugin.getLogger().log(Level.WARNING, "An error has occurred registering " + getName() + " flag.", exception); + } + } + + @Override + public String getName() { + return CustomFlags.DROWN_FLAG.getName(); + } + + @Override + public StateFlag getFlag() { + return this.flag; + } + + @Override + public boolean isEnabled() { + return this.config.getProperty(Config.drowning_flag); + } +} \ No newline at end of file diff --git a/src/main/java/com/ryderbelserion/simpleflags/flags/types/NaturalFlag.java b/src/main/java/com/ryderbelserion/simpleflags/flags/types/NaturalFlag.java new file mode 100644 index 0000000..21086d4 --- /dev/null +++ b/src/main/java/com/ryderbelserion/simpleflags/flags/types/NaturalFlag.java @@ -0,0 +1,48 @@ +package com.ryderbelserion.simpleflags.flags.types; + +import com.ryderbelserion.simpleflags.config.impl.Config; +import com.ryderbelserion.simpleflags.flags.builders.StateFlagBuilder; +import com.ryderbelserion.simpleflags.flags.enums.CustomFlags; +import com.sk89q.worldguard.protection.flags.Flag; +import com.sk89q.worldguard.protection.flags.StateFlag; +import com.sk89q.worldguard.protection.flags.registry.FlagConflictException; +import java.util.logging.Level; + +public class NaturalFlag extends StateFlagBuilder { + + private StateFlag flag; + + @Override + public void register() { + if (!isEnabled()) return; + + try { + getRegistry().register(this.flag = new StateFlag("prevent-natural-spawning", true)); + } catch (FlagConflictException exception) { + Flag existingFlag = getRegistry().get("prevent-natural-spawning"); + + if (existingFlag instanceof StateFlag stateFlag) { + this.flag = stateFlag; + + return; + } + + this.plugin.getLogger().log(Level.WARNING, "An error has occurred registering " + getName() + " flag.", exception); + } + } + + @Override + public String getName() { + return CustomFlags.NATURAL_FLAG.getName(); + } + + @Override + public StateFlag getFlag() { + return this.flag; + } + + @Override + public boolean isEnabled() { + return this.config.getProperty(Config.natural_spawning_flag); + } +} \ No newline at end of file diff --git a/src/main/java/com/ryderbelserion/simpleflags/listeners/DrowningListener.java b/src/main/java/com/ryderbelserion/simpleflags/listeners/DrowningListener.java new file mode 100644 index 0000000..51b3b1f --- /dev/null +++ b/src/main/java/com/ryderbelserion/simpleflags/listeners/DrowningListener.java @@ -0,0 +1,44 @@ +package com.ryderbelserion.simpleflags.listeners; + +import com.ryderbelserion.simpleflags.SimpleFlags; +import com.ryderbelserion.simpleflags.flags.builders.StateFlagBuilder; +import com.ryderbelserion.simpleflags.flags.FlagManager; +import com.ryderbelserion.simpleflags.flags.enums.CustomFlags; +import com.sk89q.worldguard.protection.flags.StateFlag; +import org.bukkit.damage.DamageType; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.plugin.java.JavaPlugin; + +public class DrowningListener implements Listener { + + private final SimpleFlags plugin = JavaPlugin.getPlugin(SimpleFlags.class); + + private final FlagManager flagManager = this.plugin.getFlagManager(); + + @EventHandler(ignoreCancelled = true) + public void onPlayerDrowning(EntityDamageEvent event) { + final Entity entity = event.getEntity(); + + if (!(entity instanceof Player player)) return; + + final String flagName = CustomFlags.DROWN_FLAG.getName(); + + if (!this.flagManager.hasFlag(flagName)) return; + + final StateFlagBuilder flag = (StateFlagBuilder) this.flagManager.getFlag(flagName); + + if (!flag.isEnabled()) return; + + final StateFlag stateFlag = flag.getFlag(); + + if (stateFlag == null) return; + + if (!flag.preventDamage(player, event.getDamageSource(), DamageType.DROWN, stateFlag)) { + event.setCancelled(true); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/ryderbelserion/simpleflags/listeners/NaturalListener.java b/src/main/java/com/ryderbelserion/simpleflags/listeners/NaturalListener.java new file mode 100644 index 0000000..b5e62d2 --- /dev/null +++ b/src/main/java/com/ryderbelserion/simpleflags/listeners/NaturalListener.java @@ -0,0 +1,38 @@ +package com.ryderbelserion.simpleflags.listeners; + +import com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent; +import com.ryderbelserion.simpleflags.SimpleFlags; +import com.ryderbelserion.simpleflags.flags.builders.StateFlagBuilder; +import com.ryderbelserion.simpleflags.flags.FlagManager; +import com.ryderbelserion.simpleflags.flags.enums.CustomFlags; +import com.sk89q.worldguard.protection.flags.StateFlag; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.plugin.java.JavaPlugin; + +public class NaturalListener implements Listener { + + private final SimpleFlags plugin = JavaPlugin.getPlugin(SimpleFlags.class); + + private final FlagManager flagManager = this.plugin.getFlagManager(); + + @EventHandler(ignoreCancelled = true) + public void onSpawnEvent(PreCreatureSpawnEvent event) { + final String flagName = CustomFlags.NATURAL_FLAG.getName(); + + if (!this.flagManager.hasFlag(flagName)) return; + + final StateFlagBuilder flag = (StateFlagBuilder) this.flagManager.getFlag(flagName); + + if (!flag.isEnabled()) return; + + final StateFlag stateFlag = flag.getFlag(); + + if (stateFlag == null) return; + + if (!flag.preventSpawning(event.getSpawnLocation(), event.getReason(), CreatureSpawnEvent.SpawnReason.NATURAL, stateFlag)) { + event.setCancelled(true); + } + } +} \ No newline at end of file diff --git a/src/main/resources/paper-plugin.yml b/src/main/resources/paper-plugin.yml new file mode 100644 index 0000000..0977779 --- /dev/null +++ b/src/main/resources/paper-plugin.yml @@ -0,0 +1,15 @@ +name: '${name}' +main: '${group}.${name}' + +version: '${version}' +api-version: '${apiVersion}' +description: '${description}' + +loader: '${group}.LibraryLoader' + +dependencies: + server: + WorldGuard: + load: AFTER + required: true + join-classpath: true \ No newline at end of file