diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index f7b855d..0000000 --- a/.editorconfig +++ /dev/null @@ -1,34 +0,0 @@ -# http://editorconfig.org -root = true - -[*] -indent_style = space -indent_size = 4 -charset = utf-8 -end_of_line = lf -trim_trailing_whitespace = true -insert_final_newline = true - -[*.sh] -shell_variant = bash -binary_next_line = true -switch_case_indent = true -space_redirects = true -keep_padding = true -function_next_line = true -never_split = true - -[.github/**] -ignore = true - -[.rc/**] -ignore = true - -[.git/**] -ignore = true - -[.vscode/**] -ignore = true - -[.idea/**] -ignore = true diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index b1505fd..0000000 --- a/.gitattributes +++ /dev/null @@ -1,82 +0,0 @@ -# Common settings that generally should always be used with your language specific settings - -# Auto detect text files and perform LF normalization -* text=auto - -# -# The above will handle all files NOT found below -# - -# Documents -*.bibtex text diff=bibtex -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain -*.md text diff=markdown -*.mdx text diff=markdown -*.tex text diff=tex -*.adoc text -*.textile text -*.mustache text -*.csv text -*.tab text -*.tsv text -*.txt text -*.sql text - -# Graphics -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.tif binary -*.tiff binary -*.ico binary -# SVG treated as text by default. -*.svg text -# If you want to treat it as binary, -# use the following line instead. -# *.svg binary -*.eps binary - -# Scripts -*.bash text eol=lf -*.fish text eol=lf -*.sh text eol=lf -*.zsh text eol=lf -# These are explicitly windows files and should use crlf -*.bat text eol=crlf -*.cmd text eol=crlf -*.ps1 text eol=crlf - -# Serialisation -*.json text -*.toml text -*.xml text -*.yaml text -*.yml text - -# Archives -*.7z binary -*.gz binary -*.tar binary -*.tgz binary -*.zip binary - -# Text files where line endings should be preserved -*.patch -text - -# -# Exclude files from exporting -# - -.gitattributes export-ignore -.gitignore export-ignore -.gitkeep export-ignore diff --git a/.github/ISSUE_TEMPLATE/blank-issue.md b/.github/ISSUE_TEMPLATE/blank-issue.md deleted file mode 100644 index 36ba99b..0000000 --- a/.github/ISSUE_TEMPLATE/blank-issue.md +++ /dev/null @@ -1,13 +0,0 @@ ---- - -name: 'Blank Issue' -about: 'This template is used to create a blank issue without a template. Please use our templates where applicable.' -title: 'The title of your issue.' -ref: 'main' -labels: - - 'State: Conversation' - ---- - -We are assuming that you are an expert user. Please follow our templates unless -you know what you are doing. diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md deleted file mode 100644 index a443b94..0000000 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ /dev/null @@ -1,31 +0,0 @@ ---- - -name: 'Bug Report' -about: 'This template is used to report unintended behavior of our projects.' -title: '[BUG] A brief overview of your concern.' -ref: 'main' -labels: - - 'Type: Bug' - - 'State: Conversation' - ---- - -**Describe the Bug**: A clear and concise description of what is problematic. - -**Information / Steps to Reproduce**: - -1. Provide detailed steps on how to reproduce the issue. -2. Key aspects of how the environment was set up. -3. Code or repository that can be used to consistently reproduce the behavior. -4. Please include any and all errors that are generated. - -**Expected Behavior**: Please explain the behavior you expected the application -to implement. - -**Current Environment**: Please detail the specs and operating system of the -machine you are currently using. If possible, please replicate this issue across -multiple different operating systems. Please include the version of our project -that you are using. - -**Additional Context**: Please provide any additional information you feel -should be shared, if applicable. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index 5baad47..0000000 --- a/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1,10 +0,0 @@ -blank_issues_enabled: false -contact_links: - - name: Official Support - url: mailto:samuel.voeller@amethyst.live - about: For support, security concerns or violations of Code of Conduct. - - name: Security Reports - url: mailto:report@amethyst.live - - name: Community Live-Chat - url: https://discord.gg/5Z4FXY7 - about: Need faster help or have a small question? Join us on Discord! Get official and community support fast and effectively. diff --git a/.github/ISSUE_TEMPLATE/enhancement-request.md b/.github/ISSUE_TEMPLATE/enhancement-request.md deleted file mode 100644 index 4236c34..0000000 --- a/.github/ISSUE_TEMPLATE/enhancement-request.md +++ /dev/null @@ -1,28 +0,0 @@ ---- - -name: 'Enhancement Request' -about: 'This template is used to request enhancements to be added in our projects.' -title: '[FEAT] A brief overview of your request.' -ref: 'main' -labels: - - 'Type: Enhancement' - - 'State: Conversation' - ---- - -**Describe the Request**: A clear and concise description of what you are -requesting. - -**Information**: - -1. How would you like to see this implemented? -2. How do you feel this will benefit the project? -3. Is there any existing functionality that may need changed to support this? -4. Will this functionality replace or otherwise deprecate existing - functionality? - -**Expected Behavior**: Please explain the behavior you are expecting the -application to implement. - -**Additional Context**: Please provide any additional information you feel -should be shared, if applicable. diff --git a/.github/ISSUE_TEMPLATE/security-concern.md b/.github/ISSUE_TEMPLATE/security-concern.md deleted file mode 100644 index cc5d2c1..0000000 --- a/.github/ISSUE_TEMPLATE/security-concern.md +++ /dev/null @@ -1,31 +0,0 @@ ---- - -name: 'Security Concern' -about: 'This template is used to report concerns over the security implementations in our projects.' -title: '[SEC] A brief overview of your concern.' -ref: 'main' -labels: - - 'Type: Infrastructure' - - 'Priority: Critical' - - 'State: Conversation' - ---- - -**Describe the Concern**: A clear and concise description of what is -problematic. - -**Information / Steps to Reproduce**: - -1. Provide detailed steps on how to reproduce the issue. -2. Key aspects of how the environment was set up. -3. Code or repository that can be used to consistently reproduce the behavior. -4. Please include any and all errors that are generated. - -**Expected Behavior**: Please explain the behavior you expected the application -to implement. - -**Mitigation**: Please explain how you believe that we can mitigate this concern -to prevent exploitation. - -**Additional Context**: Please provide any additional information you feel -should be shared, if applicable. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0a7c83f..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,49 +0,0 @@ -# Pull Request - -## Summary and Information - - - -... - -Referencing Issue(s): # - -Fixing Issue(s): # - -## Summary of Testing - -To what extent did you test this pull request? Did any tests require -modification to result in a passing state (breaking changes)? - -I tested this PR by ... (description of testing methods) - -- [ ] Tests passed with no modification. -- [ ] Tests passed with modification. -- [ ] Tests are not currently passing. -- [ ] Tests need to be added to exist for the case covered in this issue. - -## Checklist for Integrity - -- [ ] The changes follow the style guidelines defined in the project. -- [ ] I have performed a self-review of my code, including testing intentionally - incorrect information. -- [ ] I have commented my code, particularly in hard to understand or complex - areas. -- [ ] The changes have not generated any new errors or warning by - static-analysis tooling. -- [ ] All dependant changes have been merged and published in downstream - modules. -- [ ] To the best of my knowledge, all information in this pull request is - vulnerability free and well researched. - - [ ] This pull request may require more research or analysis of complex logic - or technology. - - [ ] This pull request contains regular expression addition or modifications - which may need verification. - - [ ] This pull request contains database logic which may need verification of - proper user-input sterilization. diff --git a/.github/settings.yml b/.github/settings.yml deleted file mode 100644 index 3d2a18d..0000000 --- a/.github/settings.yml +++ /dev/null @@ -1,85 +0,0 @@ -repository: - security_and_analysis: - advanced_security: - status: enabled - secret_scanning: - status: enabled - - has_issues: true - has_projects: true - has_wiki: true - default_branch: main - - allow_squash_merge: true - allow_merge_commit: true - allow_rebase_merge: true - allow_auto_merge: false - delete_branch_on_merge: true - - enable_automated_security_fixes: true - enable_vulnerability_alerts: true - -labels: - - name: "Complexity: High" - color: "F9D0C4" - - name: "Complexity: Medium" - color: "FEF2C0" - - name: "Complexity: Low" - color: "D4C5F9" - - name: "Priority: Critical" - color: "000000" - - name: "Priority: High" - color: "F9D0C4" - - name: "Priority: Medium" - color: "FEF2C0" - - name: "Priority: Low" - color: "D4C5F9" - - name: "State: Help Wanted" - color: "0E8A16" - - name: "State: Work in Progress" - color: "5319E7" - - name: "State: Conversation" - color: "27828C" - - name: "State: Blocked" - color: "000000" - - name: "State: Postponed" - color: "C5DEF5" - - name: "State: Unassigned" - color: "BFDADC" - - name: "Type: Enhancement" - color: "1D76DB" - - name: "Type: Bug" - color: "B60205" - - name: "Type: Infrastructure" - color: "FBCA04" - - name: "Type: Dependencies" - color: "D4C5F9" - - name: "Meta: Question" - color: "BFDADC" - - name: "Meta: Duplicate" - color: "BFDADC" - - name: "Meta: Abandoned" - color: "808080" - -branches: - - name: main - protection: - required_pull_request_reviews: - dismiss_stale_reviews: true - require_code_owner_reviews: true - required_approving_review_count: 1 - dismissal_restrictions: - users: [] - teams: [] - required_status_checks: - strict: true - contexts: [] - enforce_admins: false - required_linear_history: true - allow_force_pushes: false - allow_deletions: false - required_conversation_resolution: true - restrictions: - apps: [] - users: [] - teams: [] diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index 62253f8..0000000 --- a/.github/stale.yml +++ /dev/null @@ -1,23 +0,0 @@ -daysUntilStale: 14 -daysUntilClose: 3 -exemptLabels: - - "Priority: Critical" - - "Priority: High" - - "Priority: Medium" - - "Priority: Low" - - "State: Help Wanted" - - "State: Postponed" - - "State: Work in Progress" -staleLabel: 'Meta: Abandoned' -markComment: > - This submission has been flagged as abandoned due to lack of activity. Is there something specific that is causing this to be delayed? - - Please leave a comment if this issue has not yet been resolved, otherwise it will be automatically closed in the near future. -closeComment: > - Following with the previous comment, this submission has been automatically closed. - - This was due to the following: - - No activity has been made for the past 14 days. - - There are no labels that indicate this is a protected issue. - - If this issue is still relevant and needs to be opened again in the future, please leave a comment elaborating upon the reason to continue with this issue. diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index 25c3780..409033b 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -1,29 +1,25 @@ name: "Java Continuous Integration" on: - push: - branches: [main, staging] - pull_request: - branches: [main, staging] + push: + branches: [main, staging] + pull_request: + branches: [main, staging] jobs: - validate: - runs-on: ubuntu-latest + validate: + runs-on: ubuntu-latest - name: Java Maven Build - steps: - - uses: actions/checkout@v3 - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'adopt' - architecture: x64 - server-id: github - server-username: GITHUB_USER_REF - server-password: GITHUB_TOKEN_REF - - name: Compile - run: "mvn -B -Pgithub --update-snapshots clean package --file pom.xml" - env: - GITHUB_USER_REF: ${{ secrets.GH_USERNAME }} - GITHUB_TOKEN_REF: ${{ secrets.GH_PAT }} + name: Java Gradle Build + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'adopt' + architecture: x64 + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + - name: Compile + run: ./gradlew shadowJar \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4788b4b..3c37caf 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,11 @@ # IntelliJ out/ +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml # Compiled class file *.class @@ -95,19 +100,19 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk -target/ +.gradle +build/ + +# Ignore Gradle GUI config +gradle-app.setting -pom.xml.tag -pom.xml.releaseBackup -pom.xml.versionsBackup -pom.xml.next +# Cache of project +.gradletasknamecache -release.properties -dependency-reduced-pom.xml -buildNumber.properties -.mvn/timing.properties -.mvn/wrapper/maven-wrapper.jar -.flattened-pom.xml +**/build/ # Common working directory run/ + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 7721ac5..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "java.configuration.updateBuildConfiguration": "automatic", - "java.compile.nullAnalysis.mode": "automatic" -} diff --git a/LICENSE b/LICENSE deleted file mode 100644 index bd7219f..0000000 --- a/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -Permission is hereby granted, without written agreement and without license or -royalty fees, to use, copy, modify, and distribute this software and its -documentation for any purpose, provided that the above copyright notice and the -following two paragraphs appear in all copies of this software. - -IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR DIRECT, -INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE -OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE COPYRIGHT HOLDER HAS BEEN -ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND -THE COPYRIGHT HOLDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, -ENHANCEMENTS, OR MODIFICATIONS. diff --git a/README.md b/README.md deleted file mode 100644 index 6445a41..0000000 --- a/README.md +++ /dev/null @@ -1,60 +0,0 @@ -# DynamicLights - -Emit Light from Held Items using the 1.17 Light Blocks in Spigot/Paper Servers. - -## Usage/Examples - -Commands - -- /dynamiclights lock (dynamiclights.lock) - - Prevents placing Lanterns and Torches from the offhand. Useful for held - lights while exploring or eating. -- /dynamiclights toggle (dynamiclights.toggle) - - Toggle the rendering of lights for your client to reduce client impact. -- /dynamiclights reload (dynamiclights.reload) - - Dynamically reload the `lights.yml` configuration to add or adjust light - levels. - - `config.yml` requires a restart due to async tasks at this time. - -## FAQ - -#### How does this plugin work? - -DynamicLights works by creating a thread for each player and rendering a -[Light Block](https://minecraft.fandom.com/wiki/Light_Block) at their head -location for all online players asynchronously. - -At the player's head location, DynamicLights will send a block change packet to -all players within the culling range. DynamicLights does NOT modify the world. - -This plugin requires ProtocolLib to be present. - -#### Can I change which items glow and work underwater? - -Yes! In the "lights.yml" file you can add any item from -https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html exactly as it -appears to set custom light levels. You can also make them work underwater! - -#### Lights flickers in Blocks like Tall Grass, Sea Grass, and Kelp. Why? - -DynamicLights utilizes the -[Light Block](https://minecraft.fandom.com/wiki/Light_Block) to render the light -in the world for all players. As this is an actual block, it requires there to -be open air or open water to be used and cannot be placed on transparent blocks -or blocks without collision. - -## Deployment - -This plugin is based on the PluginCommon API. Updates to PluginCommon will -provide verioned and shaded assets associated with this plugin. - -Reference GH Actions: https://www.schakko.de/2020/12/19/using-github-workflow-with-maven-dependencies-from-a-private-github-package-registry/ - -1. Update POM XML Plugins and Dependencies. -2. Update POM XML Version. -3. Build Plugin -4. Verify in 1.17 to Latest Version -5. Update GitHub Source Code -6. Tag Version to Last Commit -7. Add Release -8. Update Spigot diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..f2f83d6 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,50 @@ +plugins { + id("io.github.goooler.shadow") version "8.1.8" + id("java") + id("java-library") +} + +group = "github.xCykrix" +version = "1.1.0" + +repositories { + mavenCentral() + + // Core Repositories + maven { + url = uri("https://jitpack.io/") + } + maven { + url = uri("https://oss.sonatype.org/content/groups/public/") + } + + // Spigot Repository + maven { + url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") + } + + // Upstream GitHub Packages + maven { + url = uri("https://maven.pkg.github.com/xCykrix/SpigotDevkit") + credentials { + username = System.getenv("GITHUB_ACTOR") + password = System.getenv("GITHUB_TOKEN") + } + } +} + +dependencies { + compileOnly("org.spigotmc:spigot-api:1.21-R0.1-SNAPSHOT") + implementation("github.xCykrix:spigotdevkit:1.0.1") +} + +// Target Java Build (Java 17 - Minecraft 1.17.x) +val targetJavaVersion = 17 +java { + val javaVersion = JavaVersion.toVersion(targetJavaVersion) + sourceCompatibility = javaVersion + targetCompatibility = javaVersion + if (JavaVersion.current() < javaVersion) { + toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) + } +} 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 100644 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..25da30d --- /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/pom.xml b/pom.xml deleted file mode 100644 index c984462..0000000 --- a/pom.xml +++ /dev/null @@ -1,110 +0,0 @@ - - - 4.0.0 - - com.github.xcykrix - DynamicLights - 1.0.7 - jar - - DynamicLights - - - 17 - 17 - 17 - UTF-8 - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.11.0 - - ${java.version} - ${java.version} - - - - org.apache.maven.plugins - maven-shade-plugin - 3.4.1 - - - package - - shade - - - false - - - - - - - - src/main/resources - true - - - - - - - github - - - github - GitHub PluginCommon - https://maven.pkg.github.com/xcykrix/plugincommon - true - true - - - - - - - - spigotmc-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - - aikar - https://repo.aikar.co/content/groups/aikar/ - - - dmulloy2-repo - https://repo.dmulloy2.net/repository/public/ - - - sonatype - https://oss.sonatype.org/content/groups/public/ - - - - - - org.spigotmc - spigot-api - 1.20.4-R0.1-SNAPSHOT - provided - - - com.github.xcykrix - plugincommon - 1.0.0-SNAPSHOT - - - com.comphenix.protocol - ProtocolLib - 5.2.0-SNAPSHOT - provided - - - diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..e4b6fb4 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,2 @@ +rootProject.name = "DynamicLights" + diff --git a/src/main/java/com/github/xcykrix/dynamiclights/DynamicLights.java b/src/main/java/com/github/xcykrix/dynamiclights/DynamicLights.java deleted file mode 100644 index 7add9df..0000000 --- a/src/main/java/com/github/xcykrix/dynamiclights/DynamicLights.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.github.xcykrix.dynamiclights; - -import com.comphenix.protocol.utility.MinecraftVersion; -import com.github.xcykrix.dynamiclights.module.DynamicLightCommand; -import com.github.xcykrix.dynamiclights.util.LightManager; -import com.github.xcykrix.dynamiclights.util.LightSources; -import com.github.xcykrix.plugincommon.PluginCommon; -import com.github.xcykrix.plugincommon.api.records.Resource; -import org.bukkit.entity.Player; - -@SuppressWarnings({"unused", "Entrypoint to Spigot API"}) -public final class DynamicLights extends PluginCommon { - - private LightManager lightManager; - - @Override - public void initialize() { - // Set Earliest Supported Version - this.setEarliestSupportedVersion(MinecraftVersion.CAVES_CLIFFS_2); - - // Register Configurations - this.configurationAPI - .register(new Resource("config.yml", null, this.getResource("config.yml"))) - .register(new Resource("lights.yml", null, this.getResource("lights.yml"))) - .registerLanguageFile(this.getResource("language.yml")); - - // Initialize Light Manager - this.lightManager = new LightManager(this, new LightSources(this)); - - // Register Commands - this.commandAPI.register(new DynamicLightCommand(this, lightManager)); - - // Register Current Players for Tracking. - for (Player player : this.getServer().getOnlinePlayers()) { - lightManager.addPlayer(player); - } - } - - @Override - public void shutdown() { - if (this.lightManager != null) { - this.lightManager.shutdown(); - } - } -} diff --git a/src/main/java/com/github/xcykrix/dynamiclights/module/DynamicLightCommand.java b/src/main/java/com/github/xcykrix/dynamiclights/module/DynamicLightCommand.java deleted file mode 100644 index 9e2789c..0000000 --- a/src/main/java/com/github/xcykrix/dynamiclights/module/DynamicLightCommand.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.github.xcykrix.dynamiclights.module; - -import com.github.xcykrix.dynamiclights.module.events.PlayerHandlerEvent; -import com.github.xcykrix.dynamiclights.util.LightManager; -import com.github.xcykrix.dynamiclights.util.LightSources; -import com.github.xcykrix.plugincommon.PluginCommon; -import com.github.xcykrix.plugincommon.api.helper.configuration.LanguageFile; -import com.github.xcykrix.plugincommon.extendables.implement.Initialize; -import com.shaded._100.aikar.commands.BaseCommand; -import com.shaded._100.aikar.commands.CommandHelp; -import com.shaded._100.aikar.commands.annotation.CommandAlias; -import com.shaded._100.aikar.commands.annotation.CommandPermission; -import com.shaded._100.aikar.commands.annotation.Description; -import com.shaded._100.aikar.commands.annotation.HelpCommand; -import com.shaded._100.aikar.commands.annotation.Subcommand; -import java.io.IOException; -import org.apache.commons.lang3.exception.ExceptionUtils; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -@CommandAlias("dynamiclights|dynamiclight|dl") -public class DynamicLightCommand extends BaseCommand implements Initialize { - - private final PluginCommon pluginCommon; - private final LightManager lightManager; - private final LanguageFile languageFile; - - public DynamicLightCommand(PluginCommon pluginCommon, LightManager lightManager) { - this.pluginCommon = pluginCommon; - this.lightManager = lightManager; - this.languageFile = this.pluginCommon.configurationAPI.getLanguageFile(); - } - - @Override - public void initialize() { - pluginCommon.getServer().getPluginManager() - .registerEvents(new PlayerHandlerEvent(pluginCommon, this.lightManager), pluginCommon); - } - - @Subcommand("toggle") - @CommandPermission("dynamiclights.toggle") - @Description("Toggle rendering light sources for your client.") - public void toggle(Player player) { - boolean status = this.lightManager.lightToggleStatus.getOrDefault( - player.getUniqueId().toString(), - this.lightManager.toggle); - if (!status) { - this.pluginCommon.adventureAPI.getAudiences().player(player).sendMessage( - this.languageFile.getComponentFromID("toggle-on", true)); - this.lightManager.lightToggleStatus.put(player.getUniqueId().toString(), true); - } else { - this.pluginCommon.adventureAPI.getAudiences().player(player).sendMessage( - this.languageFile.getComponentFromID("toggle-off", true)); - this.lightManager.lightToggleStatus.put(player.getUniqueId().toString(), false); - } - } - - @Subcommand("lock") - @CommandPermission("dynamiclights.lock") - @Description("Toggle placing light sources from your Off Hand.") - public void lock(Player player) { - boolean status = this.lightManager.lightLockStatus.getOrDefault( - player.getUniqueId().toString(), true); - if (!status) { - this.pluginCommon.adventureAPI.getAudiences().player(player).sendMessage( - this.languageFile.getComponentFromID("enable-lock", true)); - this.lightManager.lightLockStatus.put(player.getUniqueId().toString(), true); - } else { - this.pluginCommon.adventureAPI.getAudiences().player(player).sendMessage( - this.languageFile.getComponentFromID("disable-lock", true)); - this.lightManager.lightLockStatus.put(player.getUniqueId().toString(), false); - } - } - - @Subcommand("reload") - @CommandPermission("dynamiclights.reload") - @Description("Reload the light level configuration file. Changes to config.yml require a Server Reboot.") - public void reload(Player player) { - try { - this.pluginCommon.configurationAPI.get("lights.yml").reload(); - this.lightManager.updateLightSources(new LightSources(this.pluginCommon)); - this.pluginCommon.adventureAPI.getAudiences().player(player).sendMessage( - this.languageFile.getComponentFromID("reload", true)); - } catch (IOException e) { - this.pluginCommon.adventureAPI.getAudiences().player(player).sendMessage( - this.languageFile.getComponentFromID("reload-error", true)); - this.pluginCommon.getLogger().severe("Failed to reload lights.yml configuration."); - this.pluginCommon.getLogger().severe(ExceptionUtils.getStackTrace(e)); - } - } - - @HelpCommand - public void help(CommandSender sender, CommandHelp helpCommand) { - helpCommand.showHelp(); - } -} diff --git a/src/main/java/com/github/xcykrix/dynamiclights/module/events/PlayerHandlerEvent.java b/src/main/java/com/github/xcykrix/dynamiclights/module/events/PlayerHandlerEvent.java deleted file mode 100644 index 786a682..0000000 --- a/src/main/java/com/github/xcykrix/dynamiclights/module/events/PlayerHandlerEvent.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.github.xcykrix.dynamiclights.module.events; - -import com.github.xcykrix.dynamiclights.util.LightManager; -import com.github.xcykrix.plugincommon.PluginCommon; -import com.github.xcykrix.plugincommon.api.helper.configuration.LanguageFile; -import com.github.xcykrix.plugincommon.extendables.Stateful; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.inventory.EquipmentSlot; - -public class PlayerHandlerEvent extends Stateful implements Listener { - - private final LightManager lightManager; - private final LanguageFile languageFile; - private final boolean defaultState; - - public PlayerHandlerEvent(PluginCommon pluginCommon, LightManager lightManager) { - super(pluginCommon); - this.lightManager = lightManager; - this.languageFile = this.pluginCommon.configurationAPI.getLanguageFile(); - this.defaultState = this.pluginCommon.configurationAPI.get("config.yml") - .getOptionalBoolean("default-lock-state").orElse(false); - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void playerBlockPlaceEvent(BlockPlaceEvent event) { - if (event.getPlayer().isSneaking()) { - return; - } - - if (event.getHand() == EquipmentSlot.OFF_HAND) { - if (!this.lightManager.lightSources.isProtectedLight(event.getItemInHand().getType())) { - return; - } - if (this.lightManager.lightLockStatus.getOrDefault( - event.getPlayer().getUniqueId().toString(), - defaultState)) { - pluginCommon.adventureAPI.getAudiences().player(event.getPlayer()).sendMessage( - this.languageFile.getComponentFromID("prevent-block-place", true)); - event.setCancelled(true); - } - } - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void PlayerJoinEvent(PlayerJoinEvent event) { - this.lightManager.addPlayer(event.getPlayer()); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void PlayerQuitEvent(PlayerQuitEvent event) { - this.lightManager.removePlayer(event.getPlayer().getUniqueId()); - } -} diff --git a/src/main/java/com/github/xcykrix/dynamiclights/util/LightManager.java b/src/main/java/com/github/xcykrix/dynamiclights/util/LightManager.java deleted file mode 100644 index 74c529f..0000000 --- a/src/main/java/com/github/xcykrix/dynamiclights/util/LightManager.java +++ /dev/null @@ -1,221 +0,0 @@ -package com.github.xcykrix.dynamiclights.util; - -import com.github.xcykrix.plugincommon.PluginCommon; -import com.github.xcykrix.plugincommon.extendables.Stateful; -import com.github.xcykrix.plugincommon.extendables.implement.Shutdown; -import com.shaded._100.org.h2.mvstore.MVMap; -import java.util.HashMap; -import java.util.UUID; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.block.data.Waterlogged; -import org.bukkit.block.data.type.Light; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.scheduler.BukkitTask; - -public class LightManager extends Stateful implements Shutdown { - - public LightSources lightSources; - private final HashMap lastLightLocation = new HashMap<>(); - private final HashMap tasks = new HashMap<>(); - - // Local Database Map - public final MVMap lightToggleStatus; - public final MVMap lightLockStatus; - - // Configuration - private long refresh = 5L; - private int distance = 64; - public boolean toggle = true; - - public LightManager(PluginCommon pluginCommon, LightSources lightSources) { - super(pluginCommon); - this.lightToggleStatus = this.pluginCommon.h2MVStoreAPI.getStore() - .openMap("lightToggleStatus"); - this.lightLockStatus = this.pluginCommon.h2MVStoreAPI.getStore().openMap("lightLockStatus"); - this.lightSources = lightSources; - - this.refresh = this.pluginCommon.configurationAPI.get("config.yml").getLong("update-rate"); - this.distance = this.pluginCommon.configurationAPI.get("config.yml") - .getInt("light-culling-distance"); - this.toggle = this.pluginCommon.configurationAPI.get("config.yml") - .getBoolean("default-toggle-state"); - } - - @Override - public void shutdown() { - synchronized (this.tasks) { - for (UUID uuid : this.tasks.keySet()) { - this.tasks.get(uuid).cancel(); - } - this.tasks.clear(); - } - } - - public void updateLightSources(LightSources lightSources) { - this.lightSources = lightSources; - } - - public void addPlayer(Player player) { - synchronized (this.tasks) { - if (this.tasks.containsKey(player.getUniqueId())) { - return; - } - this.tasks.put(player.getUniqueId(), - this.pluginCommon.getServer().getScheduler() - .runTaskTimerAsynchronously(this.pluginCommon, () -> { - ItemStack mainHand = player.getInventory().getItemInMainHand(); - ItemStack offHand = player.getInventory().getItemInOffHand(); - - // Check Light Source Validity - boolean valid = this.valid(player, mainHand, offHand); - int lightLevel = 0; - if (valid) { - lightLevel = lightSources.getLightLevel(offHand.getType(), - mainHand.getType()); - } - - // Deploy Lighting - for (Player targetPlayer : Bukkit.getOnlinePlayers()) { - // Pull Last Location - String locationId = - player.getUniqueId() + "/" + targetPlayer.getUniqueId(); - Location lastLocation = this.getLastLocation(locationId); - - // Test and Remove Old Lights - if (!valid) { - if (lastLocation != null) { - this.removeLight(targetPlayer, lastLocation); - this.removeLastLocation(locationId); - } - continue; - } - - // Get the Next Location - Location nextLocation = player.getEyeLocation(); - - // Add Light Sources - if (this.lightToggleStatus.getOrDefault( - targetPlayer.getUniqueId().toString(), - this.toggle)) { - if (lightLevel > 0 && differentLocations(lastLocation, - nextLocation)) { - if (player.getWorld().getName() - .equals(targetPlayer.getWorld().getName())) { - if (player.getLocation() - .distance(targetPlayer.getLocation()) - <= this.distance) { - this.addLight(targetPlayer, nextLocation, lightLevel); - this.setLastLocation(locationId, nextLocation); - } - } - } - } - - // Remove Last Locations - if (lastLocation != null && differentLocations(lastLocation, - nextLocation)) { - this.removeLight(targetPlayer, lastLocation); - } - } - }, 50L, refresh)); - } - } - - public void removePlayer(UUID uid) { - synchronized (this.tasks) { - if (this.tasks.containsKey(uid)) { - this.tasks.get(uid).cancel(); - this.tasks.remove(uid); - } - } - } - - public void addLight(Player player, Location location, int lightLevel) { - if (lightLevel == 0) { - return; - } - Light light = (Light) Material.LIGHT.createBlockData(); - if (location.getWorld() == null) { - location.setWorld(player.getWorld()); - } - World world = location.getWorld(); - switch (world.getBlockAt(location).getType()) { - case AIR, CAVE_AIR -> { - light.setWaterlogged(false); - light.setLevel(lightLevel); - } - case WATER -> { - light.setWaterlogged(true); - light.setLevel(lightLevel - 2); - } - default -> { - // NO OP - } - } - player.sendBlockChange(location, light); - } - - public void removeLight(Player player, Location location) { - if (location.getWorld() == null) { - location.setWorld(player.getWorld()); - } - player.sendBlockChange(location, location.getWorld().getBlockAt(location).getBlockData()); - } - - public boolean valid(Player player, ItemStack mainHand, ItemStack offHand) { - Material main = mainHand.getType(); - Material off = offHand.getType(); - boolean hasLightLevel = lightSources.hasLightLevel(off); - if (!hasLightLevel) { - hasLightLevel = lightSources.hasLightLevel(main); - } - if (!hasLightLevel) { - return false; - } - - Block currentLocation = player.getEyeLocation().getBlock(); - if (currentLocation.getType() == Material.AIR - || currentLocation.getType() == Material.CAVE_AIR) { - return true; - } - if (currentLocation instanceof Waterlogged - && ((Waterlogged) currentLocation).isWaterlogged()) { - return false; - } - if (currentLocation.getType() == Material.WATER) { - return lightSources.isSubmersible(off, main); - } - return false; - } - - public Location getLastLocation(String uuid) { - return lastLightLocation.getOrDefault(uuid, null); - } - - public void setLastLocation(String uuid, Location location) { - lastLightLocation.put(uuid, location); - } - - public void removeLastLocation(String uuid) { - lastLightLocation.remove(uuid); - } - - private boolean differentLocations(Location l1, Location l2) { - if (l1 == null || l2 == null) { - return true; - } - if (l1.getWorld() == null || l2.getWorld() == null) { - return true; - } - if (!l1.getWorld().getName().equals(l2.getWorld().getName())) { - return true; - } - return l1.getBlockX() != l2.getBlockX() || l1.getBlockY() != l2.getBlockY() - || l1.getBlockZ() != l2.getBlockZ(); - } -} diff --git a/src/main/java/com/github/xcykrix/dynamiclights/util/LightSources.java b/src/main/java/com/github/xcykrix/dynamiclights/util/LightSources.java deleted file mode 100644 index cbedbb0..0000000 --- a/src/main/java/com/github/xcykrix/dynamiclights/util/LightSources.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.github.xcykrix.dynamiclights.util; - -import com.github.xcykrix.plugincommon.PluginCommon; -import com.github.xcykrix.plugincommon.extendables.Stateful; -import com.shaded._100.dev.dejvokep.boostedyaml.YamlDocument; -import com.shaded._100.dev.dejvokep.boostedyaml.block.Block; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import org.bukkit.Material; - -public class LightSources extends Stateful { - - private final HashMap levelOfLights = new HashMap<>(); - private final HashSet submersibleLights = new HashSet<>(); - private final HashSet protectedLights = new HashSet<>(); - - public LightSources(PluginCommon pluginCommon) { - super(pluginCommon); - YamlDocument lights = this.pluginCommon.configurationAPI.get("lights.yml"); - - // Load Light Levels - Map> levels = lights.getSection("levels").getStoredValue(); - for (Object material : levels.keySet()) { - try { - int level = Integer.parseInt(levels.get(material).getStoredValue().toString()); - this.levelOfLights.put(Material.valueOf((String) material), level); - } catch (Exception exception) { - this.pluginCommon.getLogger() - .warning("Unable to register level for '" + material + "'. " - + exception.getMessage()); - } - } - this.pluginCommon.getLogger() - .info("Registered " + this.levelOfLights.size() + " items for Dynamic Lights."); - - // Load Submersible Status - List submersibles = lights.getStringList("submersibles"); - for (String material : submersibles) { - try { - this.submersibleLights.add(Material.valueOf(material)); - } catch (Exception exception) { - this.pluginCommon.getLogger() - .warning("Unable to register submersible for '" + material + "'. " - + exception.getMessage()); - } - } - this.pluginCommon.getLogger() - .info("Registered " + this.submersibleLights.size() - + " items for Dynamic Submersible Lights."); - - // Load Lockable Status - List lockables = lights.getStringList("lockables"); - for (String material : lockables) { - try { - this.protectedLights.add(Material.valueOf(material)); - } catch (Exception exception) { - this.pluginCommon.getLogger() - .warning("Unable to register lockable for '" + material + "'. " - + exception.getMessage()); - } - } - this.pluginCommon.getLogger() - .info("Registered " + this.protectedLights.size() - + " items for Dynamic Lockable Lights."); - } - - public boolean hasLightLevel(Material material) { - return levelOfLights.containsKey(material); - } - - public Integer getLightLevel(Material material, Material fallback) { - return levelOfLights.getOrDefault(material, levelOfLights.getOrDefault(fallback, 0)); - } - - public boolean isSubmersible(Material offHand, Material mainHand) { - return submersibleLights.contains(offHand) || submersibleLights.contains(mainHand); - } - - public boolean isProtectedLight(Material offHand) { - return protectedLights.contains(offHand); - } -} diff --git a/src/main/java/github/xCykrix/dynamicLights/DynamicLights.java b/src/main/java/github/xCykrix/dynamicLights/DynamicLights.java new file mode 100644 index 0000000..0f5b288 --- /dev/null +++ b/src/main/java/github/xCykrix/dynamicLights/DynamicLights.java @@ -0,0 +1,70 @@ +package github.xCykrix.dynamicLights; + +import github.xCykrix.DevkitPlugin; +import github.xCykrix.dynamicLights.command.BaseCommand; +import github.xCykrix.dynamicLights.event.PlayerHandler; +import github.xCykrix.dynamicLights.util.LightManager; +import github.xCykrix.dynamicLights.util.LightSource; +import github.xCykrix.helper.LanguageFile; +import github.xCykrix.plugin.AdventurePlugin; +import github.xCykrix.plugin.CommandPlugin; +import github.xCykrix.plugin.ConfigurationPlugin; +import github.xCykrix.plugin.H2MVStorePlugin; +import github.xCykrix.plugin.ProtocolLibPlugin; +import github.xCykrix.records.Resource; + +@SuppressWarnings({"unused", "Called by Spigot API."}) +public final class DynamicLights extends DevkitPlugin { + + // Core APIs. + public static ConfigurationPlugin configuration; + public static AdventurePlugin adventure; + public static CommandPlugin command; + + // Third Party APIs. + public static ProtocolLibPlugin protocol; + public static H2MVStorePlugin h2; + + // Internal APIs. + public static LanguageFile language; + public static LightSource source; + public static LightManager manager; + + @Override + protected void pre() { + configuration = this.register(new ConfigurationPlugin(this)); + adventure = this.register(new AdventurePlugin(this)); + command = this.register(new CommandPlugin(this)); + + protocol = this.register(new ProtocolLibPlugin(this)); + h2 = this.register(new H2MVStorePlugin(this)); + } + + @Override + public void initialize() { + // Register Configurations + configuration + .register(new Resource("config.yml", null, this.getResource("config.yml"))) + .register(new Resource("lights.yml", null, this.getResource("lights.yml"))) + .registerLanguageFile(this.getResource("language.yml")); + language = configuration.getLanguageFile(); + + // Register Internal APIs. + source = new LightSource(this); + source.initialize(); + manager = new LightManager(this); + manager.initialize(); + + // Register Events + this.getServer().getPluginManager().registerEvents(new PlayerHandler(this), this); + + // Register Commands + BaseCommand.getOrCreate(this).generate(command); + } + + @Override + public void shutdown() { + manager.shutdown(); + source.shutdown(); + } +} diff --git a/src/main/java/github/xCykrix/dynamicLights/command/BaseCommand.java b/src/main/java/github/xCykrix/dynamicLights/command/BaseCommand.java new file mode 100644 index 0000000..0c16402 --- /dev/null +++ b/src/main/java/github/xCykrix/dynamicLights/command/BaseCommand.java @@ -0,0 +1,148 @@ +package github.xCykrix.dynamicLights.command; + +import github.xCykrix.DevkitPlugin; +import github.xCykrix.dynamicLights.DynamicLights; +import github.xCykrix.extendable.DevkitSimpleState; +import github.xCykrix.plugin.CommandPlugin; +import github.xCykrix.shade.dev.jorel.commandapi.CommandAPICommand; +import github.xCykrix.shade.org.apache.commons.lang3.exception.ExceptionUtils; +import java.io.IOException; +import java.util.Objects; + +public class BaseCommand extends DevkitSimpleState { + + public static BaseCommand core; + + public static BaseCommand getOrCreate(DevkitPlugin plugin) { + if (core == null) { + core = new BaseCommand(plugin); + } + return core; + } + + public BaseCommand(DevkitPlugin plugin) { + super(plugin); + } + + public void generate(CommandPlugin commandPlugin) { + new CommandAPICommand("dynamiclights") + .withAliases("dynamiclight", "dl") + .withSubcommand( + new CommandAPICommand("toggle") + .withPermission("dynamiclights.toggle") + .executesPlayer(info -> { + String uuid = info.sender().getUniqueId().toString(); + boolean current = DynamicLights.manager.toggles.getOrDefault(uuid, DynamicLights.manager.toggle); + if (!current) { + DynamicLights.adventure.get().player(info.sender()).sendMessage( + DynamicLights.language.getComponentFromID("toggle-on", true) + ); + DynamicLights.manager.toggles.put(uuid, true); + } else { + DynamicLights.adventure.get().player(info.sender()).sendMessage( + DynamicLights.language.getComponentFromID("toggle-off", true) + ); + DynamicLights.manager.toggles.put(uuid, false); + } + }) + ) + .withSubcommand( + new CommandAPICommand("lock") + .withPermission("dynamiclights.lock") + .executesPlayer(info -> { + String uuid = info.sender().getUniqueId().toString(); + boolean current = DynamicLights.manager.locks.getOrDefault(uuid, true); + if (!current) { + DynamicLights.adventure.get().player(info.sender()).sendMessage( + DynamicLights.language.getComponentFromID("enable-lock", true) + ); + DynamicLights.manager.locks.put(uuid, true); + } else { + DynamicLights.adventure.get().player(info.sender()).sendMessage( + DynamicLights.language.getComponentFromID("disable-lock", true) + ); + DynamicLights.manager.locks.put(uuid, false); + } + }) + ) + .withSubcommand( + new CommandAPICommand("reload") + .withPermission("dynamiclights.reload") + .executes(info -> { + try { + Objects.requireNonNull(DynamicLights.configuration.getYAMLFile("lights.yml")).reload(); + DynamicLights.source.initialize(); + DynamicLights.adventure.get().sender(info.sender()).sendMessage( + DynamicLights.language.getComponentFromID("reload", true) + ); + } catch (IOException | NullPointerException ex) { + DynamicLights.adventure.get().sender(info.sender()).sendMessage( + DynamicLights.language.getComponentFromID("reload-error", true) + ); + this.plugin.getLogger().severe("Failed to reload lights.yml."); + this.plugin.getLogger().severe(ExceptionUtils.getStackTrace(ex)); + } + }) + ).register(this.plugin); + } +} + + +// commandPlugin.register( +// commandPlugin.create("dynamiclights") +// .withAliases("dynamiclight", "dl") +// .withSubcommand( +// commandPlugin.create("toggle") +// .withPermission("dynamiclights.toggle") +// .executesPlayer(info -> { +// String uuid = info.sender().getUniqueId().toString(); +// boolean current = DynamicLights.manager.toggles.getOrDefault(uuid, DynamicLights.manager.toggle); +// if (!current) { +// DynamicLights.adventure.get().player(info.sender()).sendMessage( +// DynamicLights.language.getComponentFromID("toggle-on", true) +// ); +// DynamicLights.manager.toggles.put(uuid, true); +// } else { +// DynamicLights.adventure.get().player(info.sender()).sendMessage( +// DynamicLights.language.getComponentFromID("toggle-off", true) +// ); +// DynamicLights.manager.toggles.put(uuid, false); +// } +// }) +// ) +// .withSubcommand( +// commandPlugin.create("lock") +// .withPermission("dynamiclights.lock") +// .executesPlayer(info -> { +// String uuid = info.sender().getUniqueId().toString(); +// boolean current = DynamicLights.manager.locks.getOrDefault(uuid, true); +// if (!current) { +// DynamicLights.adventure.get().player(info.sender()).sendMessage( +// DynamicLights.language.getComponentFromID("enable-lock", true) +// ); +// DynamicLights.manager.locks.put(uuid, true); +// } else { +// DynamicLights.adventure.get().player(info.sender()).sendMessage( +// DynamicLights.language.getComponentFromID("disable-lock", true) +// ); +// DynamicLights.manager.locks.put(uuid, false); +// } +// }) +// ) +// .withSubcommand( +// commandPlugin.create("update_lights") +// .withPermission("dynamiclights.reload") +// .executesPlayer(info -> { +// try { +// Objects.requireNonNull(DynamicLights.configuration.getYAMLFile("lights.yml")).reload(); +// DynamicLights.source.initialize(); +// } catch (IOException | NullPointerException ex) { +// DynamicLights.adventure.get().sender(info.sender()).sendMessage( +// DynamicLights.language.getComponentFromID("reload-error", true) +// ); +// this.plugin.getLogger().severe("Failed to reload lights.yml."); +// this.plugin.getLogger().severe(ExceptionUtils.getStackTrace(ex)); +// } +// }) +// ) +// ); \ No newline at end of file diff --git a/src/main/java/github/xCykrix/dynamicLights/event/PlayerHandler.java b/src/main/java/github/xCykrix/dynamicLights/event/PlayerHandler.java new file mode 100644 index 0000000..8b91d0c --- /dev/null +++ b/src/main/java/github/xCykrix/dynamicLights/event/PlayerHandler.java @@ -0,0 +1,45 @@ +package github.xCykrix.dynamicLights.event; + +import github.xCykrix.DevkitPlugin; +import github.xCykrix.dynamicLights.DynamicLights; +import github.xCykrix.extendable.DevkitSimpleState; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.EquipmentSlot; + +public class PlayerHandler extends DevkitSimpleState implements Listener { + public PlayerHandler(DevkitPlugin plugin) { + super(plugin); + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void playerBlockPlaceEvent(BlockPlaceEvent event) { + if (event.getPlayer().isSneaking()) { + return; + } + + if (event.getHand() == EquipmentSlot.OFF_HAND) { + if (!DynamicLights.source.isProtectedLight(event.getItemInHand().getType())) { + return; + } + if (DynamicLights.manager.locks.getOrDefault(event.getPlayer().getUniqueId().toString(), DynamicLights.manager.toggle)) { + DynamicLights.adventure.get().player(event.getPlayer()).sendMessage(DynamicLights.language.getComponentFromID("prevent-block-place", true)); + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onPlayerJoinEvent(PlayerJoinEvent event) { + DynamicLights.manager.addPlayer(event.getPlayer()); + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onPlayerQuitEvent(PlayerQuitEvent event) { + DynamicLights.manager.removePlayer(event.getPlayer().getUniqueId()); + } +} diff --git a/src/main/java/github/xCykrix/dynamicLights/util/LightManager.java b/src/main/java/github/xCykrix/dynamicLights/util/LightManager.java new file mode 100644 index 0000000..c313b24 --- /dev/null +++ b/src/main/java/github/xCykrix/dynamicLights/util/LightManager.java @@ -0,0 +1,190 @@ +package github.xCykrix.dynamicLights.util; + +import github.xCykrix.DevkitPlugin; +import github.xCykrix.dynamicLights.DynamicLights; +import github.xCykrix.extendable.DevkitFullState; +import github.xCykrix.shade.dev.dejvokep.boostedyaml.YamlDocument; +import github.xCykrix.shade.org.h2.mvstore.MVMap; +import java.util.HashMap; +import java.util.UUID; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.data.Waterlogged; +import org.bukkit.block.data.type.Light; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitTask; + +public class LightManager extends DevkitFullState { + private final LightSource source; + private final HashMap tasks = new HashMap<>(); + private final HashMap lastLightLocation = new HashMap<>(); + + public final MVMap toggles; + public final MVMap locks; + private final long refresh; + private final int distance; + public final boolean toggle; + + public LightManager(DevkitPlugin plugin) { + super(plugin); + YamlDocument config = DynamicLights.configuration.getYAMLFile("config.yml"); + if (config == null) { + throw new RuntimeException("config.yml is corrupted or contains invalid formatting. Failed to load plugin."); + } + + this.source = DynamicLights.source; + this.toggles = DynamicLights.h2.get().openMap("lightToggleStatus"); + this.locks = DynamicLights.h2.get().openMap("lightLockStatus"); + this.refresh = config.getLong("update-rate"); + this.distance = config.getInt("light-culling-distance"); + this.toggle = config.getBoolean("default-toggle-state"); + } + + @Override + public void initialize() { + } + + @Override + public void shutdown() { + synchronized (this.tasks) { + for (UUID uuid : this.tasks.keySet()) { + this.tasks.get(uuid).cancel(); + } + this.tasks.clear(); + } + } + + public void addPlayer(Player player) { + synchronized (this.tasks) { + if (this.tasks.containsKey(player.getUniqueId())) { + return; + } + this.tasks.put(player.getUniqueId(), this.plugin.getServer().getScheduler().runTaskTimerAsynchronously(this.plugin, () -> { + ItemStack mainHand = player.getInventory().getItemInMainHand(); + ItemStack offHand = player.getInventory().getItemInOffHand(); + boolean valid = this.valid(player, mainHand, offHand); + int lightLevel = 0; + if (valid) { + lightLevel = source.getLightLevel(offHand.getType(), mainHand.getType()); + } + for (Player targetPlayer : Bukkit.getOnlinePlayers()) { + String locationId = player.getUniqueId() + "/" + targetPlayer.getUniqueId(); + Location lastLocation = this.getLastLocation(locationId); + if (!valid) { + if (lastLocation != null) { + this.removeLight(targetPlayer, lastLocation); + this.removeLastLocation(locationId); + } + continue; + } + Location nextLocation = player.getEyeLocation(); + if (this.toggles.getOrDefault(targetPlayer.getUniqueId().toString(), this.toggle)) { + if (lightLevel > 0 && differentLocations(lastLocation, nextLocation)) { + if (player.getWorld().getName().equals(targetPlayer.getWorld().getName())) { + if (player.getLocation().distance(targetPlayer.getLocation()) <= this.distance) { + this.addLight(targetPlayer, nextLocation, lightLevel); + this.setLastLocation(locationId, nextLocation); + } + } + } + } + if (lastLocation != null && differentLocations(lastLocation, nextLocation)) { + this.removeLight(targetPlayer, lastLocation); + } + } + }, 50L, refresh)); + } + } + + public void removePlayer(UUID uid) { + synchronized (this.tasks) { + if (this.tasks.containsKey(uid)) { + this.tasks.get(uid).cancel(); + this.tasks.remove(uid); + } + } + } + + public void addLight(Player player, Location location, int lightLevel) { + if (lightLevel == 0) { + return; + } + Light light = (Light) Material.LIGHT.createBlockData(); + if (location.getWorld() == null) { + location.setWorld(player.getWorld()); + } + World world = location.getWorld(); + switch (world.getBlockAt(location).getType()) { + case AIR, CAVE_AIR -> { + light.setWaterlogged(false); + light.setLevel(lightLevel); + } + case WATER -> { + light.setWaterlogged(true); + light.setLevel(lightLevel - 2); + } + default -> { + } + } + player.sendBlockChange(location, light); + } + + public void removeLight(Player player, Location location) { + if (location.getWorld() == null) { + location.setWorld(player.getWorld()); + } + player.sendBlockChange(location, location.getWorld().getBlockAt(location).getBlockData()); + } + + public boolean valid(Player player, ItemStack mainHand, ItemStack offHand) { + Material main = mainHand.getType(); + Material off = offHand.getType(); + boolean hasLightLevel = source.hasLightLevel(off); + if (!hasLightLevel) { + hasLightLevel = source.hasLightLevel(main); + } + if (!hasLightLevel) { + return false; + } + Block currentLocation = player.getEyeLocation().getBlock(); + if (currentLocation.getType() == Material.AIR || currentLocation.getType() == Material.CAVE_AIR) { + return true; + } + if (currentLocation instanceof Waterlogged && ((Waterlogged) currentLocation).isWaterlogged()) { + return false; + } + if (currentLocation.getType() == Material.WATER) { + return source.isSubmersible(off, main); + } + return false; + } + + public Location getLastLocation(String uuid) { + return lastLightLocation.getOrDefault(uuid, null); + } + + public void setLastLocation(String uuid, Location location) { + lastLightLocation.put(uuid, location); + } + + public void removeLastLocation(String uuid) { + lastLightLocation.remove(uuid); + } + + private boolean differentLocations(Location l1, Location l2) { + if (l1 == null || l2 == null) { + return true; + } + if (l1.getWorld() == null || l2.getWorld() == null) { + return true; + } + if (!l1.getWorld().getName().equals(l2.getWorld().getName())) { + return true; + } + return l1.getBlockX() != l2.getBlockX() || l1.getBlockY() != l2.getBlockY() || l1.getBlockZ() != l2.getBlockZ(); + } +} diff --git a/src/main/java/github/xCykrix/dynamicLights/util/LightSource.java b/src/main/java/github/xCykrix/dynamicLights/util/LightSource.java new file mode 100644 index 0000000..62eee30 --- /dev/null +++ b/src/main/java/github/xCykrix/dynamicLights/util/LightSource.java @@ -0,0 +1,90 @@ +package github.xCykrix.dynamicLights.util; + +import github.xCykrix.DevkitPlugin; +import github.xCykrix.dynamicLights.DynamicLights; +import github.xCykrix.extendable.DevkitFullState; +import github.xCykrix.shade.dev.dejvokep.boostedyaml.YamlDocument; +import github.xCykrix.shade.dev.dejvokep.boostedyaml.block.Block; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import org.bukkit.Material; + +public class LightSource extends DevkitFullState { + private final HashMap levelOfLights = new HashMap<>(); + private final HashSet submersibleLights = new HashSet<>(); + private final HashSet lockedLights = new HashSet<>(); + + public LightSource(DevkitPlugin plugin) { + super(plugin); + } + + @Override + public void initialize() { + YamlDocument lights = DynamicLights.configuration.getYAMLFile("lights.yml"); + if (lights == null) { + throw new RuntimeException("lights.yml is corrupted or contains invalid formatting. Failed to load plugin."); + } + + // Register Light Levels + this.levelOfLights.clear(); + Map> levels = lights.getSection("levels").getStoredValue(); + for (Object material : levels.keySet()) { + try { + int level = Integer.parseInt(levels.get(material).getStoredValue().toString()); + this.levelOfLights.put(Material.valueOf((String) material), level); + } catch (Exception exception) { + this.plugin.getLogger().warning("Unable to register level for '" + material + "'. " + exception.getMessage()); + } + } + this.plugin.getLogger().info("Registered " + this.levelOfLights.size() + " items for Dynamic Lights."); + + // Register Submersible Lights + this.submersibleLights.clear(); + List submersibles = lights.getStringList("submersibles"); + for (String material : submersibles) { + try { + this.submersibleLights.add(Material.valueOf(material)); + } catch (Exception exception) { + this.plugin.getLogger().warning("Unable to register submersible for '" + material + "'. " + exception.getMessage()); + } + } + this.plugin.getLogger().info("Registered " + this.submersibleLights.size() + " items for Dynamic Submersible Lights."); + + // Register Lockable Lights + this.lockedLights.clear(); + List lockables = lights.getStringList("lockables"); + for (String material : lockables) { + try { + this.lockedLights.add(Material.valueOf(material)); + } catch (Exception exception) { + this.plugin.getLogger().warning("Unable to register lockable for '" + material + "'. " + exception.getMessage()); + } + } + this.plugin.getLogger().info("Registered " + this.lockedLights.size() + " items for Dynamic Locked Lights."); + } + + @Override + public void shutdown() { + this.lockedLights.clear(); + this.submersibleLights.clear(); + this.levelOfLights.clear(); + } + + public boolean hasLightLevel(Material material) { + return levelOfLights.containsKey(material); + } + + public Integer getLightLevel(Material material, Material fallback) { + return levelOfLights.getOrDefault(material, levelOfLights.getOrDefault(fallback, 0)); + } + + public boolean isSubmersible(Material offHand, Material mainHand) { + return submersibleLights.contains(offHand) || submersibleLights.contains(mainHand); + } + + public boolean isProtectedLight(Material offHand) { + return lockedLights.contains(offHand); + } +} \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index dcbd3a8..8f606d5 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -12,4 +12,4 @@ default-lock-state: true # DO NOT EDIT THE VERSION. Manual edits may corrupt or reset configuration files. # -version: 3 +version: 3 \ No newline at end of file diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml index f89151c..cfdaa60 100644 --- a/src/main/resources/language.yml +++ b/src/main/resources/language.yml @@ -16,14 +16,14 @@ chat-prefix: "[DynamicLights] Light locking mode is currently enabled. You must sneak to place light sources from your Off Hand. This can be toggled with \"/dl lock\"." - enable-lock: " Enabled light lock mode." - disable-lock: " Disabled light lock mode." - toggle-on: " Light rendering enabled for client." - toggle-off: " Light rendering disabled for client." - reload: " Reloaded lights.yml configuration." - reload-error: " Failed to reload lights.yml configuration. Check Console.." + prevent-block-place: " Light locking mode is currently enabled. You must sneak to place light sources from your Off Hand. This can be toggled with \"/dl lock\"." + enable-lock: " Enabled light lock mode." + disable-lock: " Disabled light lock mode." + toggle-on: " Light rendering enabled for client." + toggle-off: " Light rendering disabled for client." + reload: " Reloaded lights.yml configuration." + reload-error: " Failed to reload lights.yml configuration. Check Console.." # DO NOT EDIT THE VERSION. Manual edits may corrupt or reset configuration files. # -version: 2 +version: 2 \ No newline at end of file diff --git a/src/main/resources/lights.yml b/src/main/resources/lights.yml index 21f3fca..641916e 100644 --- a/src/main/resources/lights.yml +++ b/src/main/resources/lights.yml @@ -4,34 +4,34 @@ # Map List of Light Levels levels: - LANTERN: 13 - SOUL_LANTERN: 13 - TORCH: 11 - SOUL_TORCH: 11 - REDSTONE_TORCH: 7 - GLOWSTONE: 15 - SHROOMLIGHT: 15 - SEA_LANTERN: 15 - OCHRE_FROGLIGHT: 15 - PEARLESCENT_FROGLIGHT: 15 - VERDANT_FROGLIGHT: 15 + LANTERN: 13 + SOUL_LANTERN: 13 + TORCH: 11 + SOUL_TORCH: 11 + REDSTONE_TORCH: 7 + GLOWSTONE: 15 + SHROOMLIGHT: 15 + SEA_LANTERN: 15 + OCHRE_FROGLIGHT: 15 + PEARLESCENT_FROGLIGHT: 15 + VERDANT_FROGLIGHT: 15 # String List of Submersible Materials submersibles: - - "GLOWSTONE" - - "SHROOMLIGHT" - - "SEA_LANTERN" - - "OCHRE_FROGLIGHT" - - "PEARLESCENT_FROGLIGHT" - - "VERDANT_FROGLIGHT" + - "GLOWSTONE" + - "SHROOMLIGHT" + - "SEA_LANTERN" + - "OCHRE_FROGLIGHT" + - "PEARLESCENT_FROGLIGHT" + - "VERDANT_FROGLIGHT" # String List of Lockable Materials lockables: - - "TORCH" - - "SOUL_TORCH" - - "LANTERN" - - "SOUL_LANTERN" + - "TORCH" + - "SOUL_TORCH" + - "LANTERN" + - "SOUL_LANTERN" # DO NOT EDIT THE VERSION. Manual edits may corrupt or reset configuration files. # -version: 1 +version: 1 \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 711ded0..a577130 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,22 +2,22 @@ name: 'DynamicLights' description: 'Emit Light from Held Items using the 1.17 Light Blocks.' website: 'https://www.spigotmc.org/resources/dynamiclights.110707/' author: 'xCykrix' -version: '${project.version}' +version: '1.0-SNAPSHOT' -main: com.github.xcykrix.dynamiclights.DynamicLights -api-version: '1.18' +main: github.xCykrix.dynamicLights.DynamicLights +api-version: '1.17' load: 'POSTWORLD' depend: - - 'ProtocolLib' + - 'ProtocolLib' permissions: - dynamiclights.lock: - description: "Toggle placing light sources from your off hand." - default: true - dynamiclights.toggle: - description: "Toggle rendering of light sources for your client." - default: true - dynamiclights.reload: - description: "Reload the lights.yml configuration file." - default: false + dynamiclights.lock: + description: "Toggle placing light sources from your off hand." + default: true + dynamiclights.toggle: + description: "Toggle rendering of light sources for your client." + default: true + dynamiclights.reload: + description: "Reload the lights.yml configuration file." + default: op \ No newline at end of file