Updating To Gradlew and New Command Framework

This commit is contained in:
Daniel 2020-09-09 14:47:02 -04:00
parent 692b51085f
commit 66c3e60a6f
42 changed files with 7791 additions and 1181 deletions

View File

@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at darkstylerz@web.de. All
reported by contacting the project team at me@silthus.net. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.

View File

@ -1,7 +1,7 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
title: "[BUG]"
labels: ''
assignees: ''
@ -23,16 +23,10 @@ A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Server Information (please complete the following information):**
- Server version (`/bukkit:version`):
- Installed plugins (`/bukkit:plugins`):
- WorldGuard Report Pastebin Link (`/wg report -p`):
**Additional context**
Add any other context about the problem here.

6
.github/auto-merge.yml vendored Normal file
View File

@ -0,0 +1,6 @@
minApprovals:
NONE: 0
requiredLabels:
- dependencies
updateBranch: true
mergeMethod: rebase

15
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,15 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "gradle" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"

View File

@ -0,0 +1,13 @@
name: Auto approve
on:
pull_request
jobs:
auto-approve:
runs-on: ubuntu-latest
steps:
- uses: hmarr/auto-approve-action@v2.0.0
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

114
.github/workflows/gradle.yml vendored Normal file
View File

@ -0,0 +1,114 @@
name: Build
on: [push]
jobs:
build:
runs-on: ubuntu-18.04
# We want to run on external PRs, but not on our own internal PRs as they'll be run
# by the push to the branch.
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
steps:
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache Gradle
id: cache-gradle
uses: actions/cache@v1
with:
path: ~/.gradle
key: ${{ runner.os }}-gradle
- uses: actions/checkout@v1
- name: Grant execute permission to gradlew
run: chmod +x gradlew
- name: Build
run: ./gradlew build -x test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload build artifacts
uses: actions/upload-artifact@v2
with:
path: "**/build/libs"
test:
runs-on: ubuntu-18.04
steps:
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache Gradle
id: cache-gradle
uses: actions/cache@v1
with:
path: ~/.gradle
key: ${{ runner.os }}-gradle
- uses: actions/checkout@v1
- name: Grant execute permission to gradlew
run: chmod +x gradlew
- name: Test
run: ./gradlew test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload CodeCov Report
uses: codecov/codecov-action@v1
with:
file: "**/build/reports/jacoco/**/*.xml"
- name: Upload Test Report
uses: actions/upload-artifact@v2
if: always()
with:
name: build reports
path: "**/build/reports"
release:
needs: [build, test]
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-18.04
steps:
- name: Set up JDK 8
uses: actions/setup-java@v1
with:
java-version: 8
- name: Set up Node.js v12.x
uses: actions/setup-node@v1
with:
node-version: "12.x"
- name: Cache Gradle
id: cache-gradle
uses: actions/cache@v1
with:
path: ~/.gradle
key: ${{ runner.os }}-gradle
- uses: actions/checkout@v1
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Release
run: |
yarn install
yarn semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_URL: "https://api.github.com/"

223
.gitignore vendored
View File

@ -1,25 +1,208 @@
# Maven
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# IntelliJ
# Eclipse
bin/
.settings
.project
.classpath
/.idea/dictionaries/
/.idea/libraries/
/.idea/*.xml
*.iml
# Gradle
.gradle
build/
# Server
working/*
**/debug/**/*
!working/server.properties
/.idea/
src/**/plugin.yml
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
.idea/
*.iml
.idea/vcs.xml
# Misc
.DS_Store
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.pnp.*

1
.nvmrc Normal file
View File

@ -0,0 +1 @@
12

View File

@ -1,2 +0,0 @@
language: java
jdk: openjdk8

238
CHANGELOG.md Normal file
View File

@ -0,0 +1,238 @@
## [2.0.1](https://github.com/Silthus/spigot-plugin-template/compare/v2.0.0...v2.0.1) (2020-07-06)
### Bug Fixes
* **debug:** exclude all content inside debug/ ([751d2b7](https://github.com/Silthus/spigot-plugin-template/commit/751d2b7057a57330851968cb9c9bafad82f09d56))
# [2.0.0](https://github.com/Silthus/spigot-plugin-template/compare/v1.7.1...v2.0.0) (2020-07-06)
### Features
* update spigradle to 2.0.0 ([df1f431](https://github.com/Silthus/spigot-plugin-template/commit/df1f431c6cb68bab085a182970c33cd0e96cddca)), closes [#19](https://github.com/Silthus/spigot-plugin-template/issues/19)
### BREAKING CHANGES
* The `@Plugin` annotation on the plugin main class for spigradle was renamed to `@PluginMain`
## [1.7.1](https://github.com/Silthus/spigot-plugin-template/compare/v1.7.0...v1.7.1) (2020-07-03)
### Bug Fixes
* target Minecraft 1.16.1 in gradle.properties ([8beb34a](https://github.com/Silthus/spigot-plugin-template/commit/8beb34a733787bd4c7cdb814a60234be2b3e981e))
# [1.7.0](https://github.com/Silthus/spigot-plugin-template/compare/v1.6.0...v1.7.0) (2020-07-02)
### Features
* use new spigradle debug task for running the server ([d7a3f25](https://github.com/Silthus/spigot-plugin-template/commit/d7a3f25a694ab92e03ebc7bf9058264b5324acf1))
# [1.6.0](https://github.com/Silthus/spigot-plugin-template/compare/v1.5.2...v1.6.0) (2020-06-25)
### Features
* **build:** split build and test into separate jobs ([38f74d4](https://github.com/Silthus/spigot-plugin-template/commit/38f74d48d258521f9414d1f050cacb7201cf6bfd))
## [1.5.2](https://github.com/Silthus/spigot-plugin-template/compare/v1.5.1...v1.5.2) (2020-06-25)
### Bug Fixes
* **build:** only run once on PR from same repo ([4df7f57](https://github.com/Silthus/spigot-plugin-template/commit/4df7f5701a2c47c46bf5394f544ca5fdf4d8bec4))
## [1.5.1](https://github.com/Silthus/spigot-plugin-template/compare/v1.5.0...v1.5.1) (2020-06-10)
### Bug Fixes
* **docs:** remove invalid whitespaces from gradle.properties ([d3fd4b5](https://github.com/Silthus/spigot-plugin-template/commit/d3fd4b53f1d7c1bd4f331f92b1651f89682b3122))
# [1.5.0](https://github.com/Silthus/spigot-plugin-template/compare/v1.4.0...v1.5.0) (2020-06-10)
### Features
* auto update dependencies with dependabot ([e28ccf4](https://github.com/Silthus/spigot-plugin-template/commit/e28ccf4cbb64ee9975b23c974b50ad1f0a4315f9))
# [1.4.0](https://github.com/Silthus/spigot-plugin-template/compare/v1.3.7...v1.4.0) (2020-06-08)
### Features
* **docs:** add spiget shields to spigot resource ([0907394](https://github.com/Silthus/spigot-plugin-template/commit/090739466d919f7b6f3fe24c3a2fade87129732d))
## [1.3.7](https://github.com/Silthus/spigot-plugin-template/compare/v1.3.6...v1.3.7) (2020-05-25)
### Bug Fixes
* **build:** copy plugin to server based on rootProject.rootDir ([1315050](https://github.com/Silthus/spigot-plugin-template/commit/1315050ac27aa8740672a773ad6fc9fa14ee180e))
* **git:** ignore automatic generated plugin.yml ([4cccd5b](https://github.com/Silthus/spigot-plugin-template/commit/4cccd5b1197311dd456bb742c2ec5cb06dcadb8f))
* **plugin:** set correct spigradle plugin name ([a7d5af5](https://github.com/Silthus/spigot-plugin-template/commit/a7d5af590f8b8b06bf5350bff8e25059cdc4f7d6))
## [1.3.6](https://github.com/Silthus/spigot-plugin-template/compare/v1.3.5...v1.3.6) (2020-05-24)
### Bug Fixes
* **release:** override GitHub API url with GH_URL ([43669f7](https://github.com/Silthus/spigot-plugin-template/commit/43669f730eee93f4c62a9bae1d0666a9513a8046))
## [1.3.5](https://github.com/Silthus/spigot-plugin-template/compare/v1.3.4...v1.3.5) (2020-05-23)
### Bug Fixes
* **build:** hash yarn.lock for cache ([307b744](https://github.com/Silthus/spigot-plugin-template/commit/307b744c7a15fe940d1d8e967e44c93a3063cc67))
### Reverts
* publish shadowJar artifact ([6e869fc](https://github.com/Silthus/spigot-plugin-template/commit/6e869fcc11de056faad831f215c80538c112435b))
## [1.3.4](https://github.com/Silthus/spigot-plugin-template/compare/v1.3.3...v1.3.4) (2020-05-23)
### Bug Fixes
* **test:** copy plugin.yml to test resources ([54893f2](https://github.com/Silthus/spigot-plugin-template/commit/54893f201d37958e2fc1b07dfb403014d09ff1c0))
## [1.3.3](https://github.com/Silthus/spigot-plugin-template/compare/v1.3.2...v1.3.3) (2020-05-23)
### Bug Fixes
* **plugin:** use pluginName property in plugin.yml ([094c57b](https://github.com/Silthus/spigot-plugin-template/commit/094c57b3730178470b60b7038950be8e1ced6c51))
* **publish:** publish shadow jar artifact ([64968ce](https://github.com/Silthus/spigot-plugin-template/commit/64968cefa69d10fea0f3a26b2d3da7abc1e627d5))
## [1.3.2](https://github.com/Silthus/spigot-plugin-template/compare/v1.3.1...v1.3.2) (2020-05-23)
### Bug Fixes
* **build:** cache node correctly ([20bb9e3](https://github.com/Silthus/spigot-plugin-template/commit/20bb9e349a16efb5712c037b1786358447bfdda1))
## [1.3.1](https://github.com/Silthus/spigot-plugin-template/compare/v1.3.0...v1.3.1) (2020-05-22)
### Bug Fixes
* **release:** update semantic-release/GitHub ([aefa8c1](https://github.com/Silthus/spigot-plugin-template/commit/aefa8c1c9e250dc4df9e1707c096bf7e91b8b79d))
# [1.3.0](https://github.com/Silthus/spigot-plugin-template/compare/v1.2.0...v1.3.0) (2020-05-20)
### Bug Fixes
* **publish:** revert publishing to project namespace ([4f2aa72](https://github.com/Silthus/spigot-plugin-template/commit/4f2aa72fd4aeb065fce5db6b8a137d9aa2e2c148))
* **tests:** output jacoco html report for intellij coverage ([7f94567](https://github.com/Silthus/spigot-plugin-template/commit/7f945670a9d63265be695d9adb21dbf0f24ead2b))
### Features
* **publish:** publish github package to user namespace ([ac38c81](https://github.com/Silthus/spigot-plugin-template/commit/ac38c811219942159901e5a177f71c9bb2e1d22e))
# [1.2.0](https://github.com/Silthus/spigot-plugin-template/compare/v1.1.1...v1.2.0) (2020-05-12)
### Bug Fixes
* **build:** include dependencies in the shadow jar ([803099b](https://github.com/Silthus/spigot-plugin-template/commit/803099bdf08c8a9a465d9d1323e3e65e1d498b7a))
### Features
* **build:** replace artifactory with github packages ([f83a08a](https://github.com/Silthus/spigot-plugin-template/commit/f83a08a3507345e234105cb46a1bcf0b9950816a))
* **build:** target JDK 1.8 ([0cc380c](https://github.com/Silthus/spigot-plugin-template/commit/0cc380cc335780ebba57f46ad035badff6cfe299))
## [1.1.1](https://github.com/Silthus/spigot-plugin-template/compare/v1.1.0...v1.1.1) (2020-05-10)
### Bug Fixes
* **build:** cache yarn.lock instead of package-lock ([c067aab](https://github.com/Silthus/spigot-plugin-template/commit/c067aab502cb076253232e20533449336e54fa15))
* **lint:** remove spotless linting ([cb2f8d1](https://github.com/Silthus/spigot-plugin-template/commit/cb2f8d1e70081e414e6fbe76479d7a2387108070))
# [1.1.0](https://github.com/Silthus/spigot-plugin-template/compare/v1.0.1...v1.1.0) (2020-05-09)
### Bug Fixes
* **build:** use ubuntu-18.04 as build host ([38669f1](https://github.com/Silthus/spigot-plugin-template/commit/38669f1523270edfc35e57f3d0278a2cb976a00c))
* **release:** add github credentials ([c6387b5](https://github.com/Silthus/spigot-plugin-template/commit/c6387b57e79260a55423c5a824353200c5ad1bbd))
### Features
* **publish:** publish artifact to github packages ([29afd59](https://github.com/Silthus/spigot-plugin-template/commit/29afd59e039142340e6ae52aa0dfd4d8891c78fc))
# [1.1.0](https://github.com/Silthus/spigot-plugin-template/compare/v1.0.1...v1.1.0) (2020-05-09)
### Bug Fixes
* **build:** use ubuntu-18.04 as build host ([38669f1](https://github.com/Silthus/spigot-plugin-template/commit/38669f1523270edfc35e57f3d0278a2cb976a00c))
* **release:** add github credentials ([c6387b5](https://github.com/Silthus/spigot-plugin-template/commit/c6387b57e79260a55423c5a824353200c5ad1bbd))
### Features
* **publish:** publish artifact to github packages ([29afd59](https://github.com/Silthus/spigot-plugin-template/commit/29afd59e039142340e6ae52aa0dfd4d8891c78fc))
# [1.1.0](https://github.com/Silthus/spigot-plugin-template/compare/v1.0.1...v1.1.0) (2020-05-09)
### Bug Fixes
* **build:** use ubuntu-18.04 as build host ([38669f1](https://github.com/Silthus/spigot-plugin-template/commit/38669f1523270edfc35e57f3d0278a2cb976a00c))
* **release:** add github credentials ([c6387b5](https://github.com/Silthus/spigot-plugin-template/commit/c6387b57e79260a55423c5a824353200c5ad1bbd))
### Features
* **publish:** publish artifact to github packages ([29afd59](https://github.com/Silthus/spigot-plugin-template/commit/29afd59e039142340e6ae52aa0dfd4d8891c78fc))
## [1.1.1](https://github.com/Silthus/spigot-plugin-template/compare/v1.1.0...v1.1.1) (2020-05-08)
### Bug Fixes
* **release:** add github credentials ([c6387b5](https://github.com/Silthus/spigot-plugin-template/commit/c6387b57e79260a55423c5a824353200c5ad1bbd))
# [1.1.0](https://github.com/mcSilthus/spigot-plugin-template/compare/v1.0.1...v1.1.0) (2020-05-08)
### Bug Fixes
* **build:** use ubuntu-18.04 as build host ([38669f1](https://github.com/mcSilthus/spigot-plugin-template/commit/38669f1523270edfc35e57f3d0278a2cb976a00c))
### Features
* **publish:** publish artifact to github packages ([29afd59](https://github.com/mcSilthus/spigot-plugin-template/commit/29afd59e039142340e6ae52aa0dfd4d8891c78fc))
## [1.0.1](https://github.com/mcSilthus/spigot-plugin-template/compare/v1.0.0...v1.0.1) (2020-05-05)
### Bug Fixes
* **release:** run gradle-release before github ([a3ef1fa](https://github.com/mcSilthus/spigot-plugin-template/commit/a3ef1fa22441879e8de6d27a8af0cd5f2ad581f9))
# 1.0.0 (2020-05-05)
### Bug Fixes
* **gradle:** publish build artifacts to maven ([a997f81](https://github.com/mcSilthus/spigot-plugin-template/commit/a997f8196d7e58f2dbeea46a94f0584ef1be6593))
* **release:** use node 12 for semantic-release ([88166a9](https://github.com/mcSilthus/spigot-plugin-template/commit/88166a91ec37f5fa86324137a45e07126a3072e0))
* **test:** directly reference plugin.yml in test ([97f7fc4](https://github.com/mcSilthus/spigot-plugin-template/commit/97f7fc4956138cf83625026c7134d9fb1eaf3794))
* plugin startup ([134f07f](https://github.com/mcSilthus/spigot-plugin-template/commit/134f07f22badfddfe8e924627a75ec68d3814978))
### Features
* **build:** add semantic versioning ([cdedcfd](https://github.com/mcSilthus/spigot-plugin-template/commit/cdedcfd8315309c030668421a4730a23f5282bec))

168
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,168 @@
# Contributing Guidelines
First off, thank you for considering contributing to this project. It's people like you that make this such a great plugin.
Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. In return, they should reciprocate that respect in addressing your issue, assessing changes, and helping you finalize your pull requests.
This is an open source project and we love to receive contributions from our community — you! There are many ways to contribute, from writing tutorials or blog posts, improving the documentation, submitting bug reports and feature requests or writing code which can be incorporated into the plugin itself.
Please, don't use the issue tracker for [requesting new plugins](https://www.spigotmc.org/threads/open-small-to-medium-plugin-development-pay-what-you-want-8-years-experience-high-quality.435578/). Read the post on the Spigot board or send me a [email](mailto://me@silthus.net).
# Ground Rules
By contributing to this project you submit to following our [code of conduct](.github/CODE_OF_CONDUCT.md).
Please read this next section carefully and check if your contribution meets all requirements in this checklist. This will save you and us a lot of time.
## Issues: Feature Requests & Bug Reports
Please make sure you checked all of the following before submitting a new issue.
* Before submitting a new issue, search the existing (including closed) issues for any duplicates.
* If you found an existing issue - use the react feature to show you have the same problem or need the same feature. Don't post comments like +1.
* Use the Bug & Feature Issue templates and provide all the required information.
* Be as detailed as possible and include screenshots wherever possible. This will help reproducing your bug or understanding your feature request.
* Use the WorldGuard `/wg report -p` command to provide detailed debug information and post the pastebin link in the issue.
## Contributing Code
Pull requests are the best way to propose changes to the codebase (we use [Github Flow](https://guides.github.com/introduction/flow/index.html)). We actively welcome your pull requests:
* **Commit using the [conventional-commit](https://www.conventionalcommits.org/en/v1.0.0/) format!**
* Create issues for any major changes and enhancements that you wish to make. Discuss things transparently and get community feedback.
* Keep feature versions as small as possible, preferably one new feature per version.
* Be welcoming to newcomers and encourage diverse new contributors from all backgrounds.
# Your First Contribution
Unsure where to begin contributing to this project? You can start by looking through these beginner and help-wanted issues:
Good first issues - issues which should only require a few lines of code, and a test or two.
Help wanted issues - issues which should be a bit more involved than beginner issues.
Working on your first Pull Request? You can learn how from this *free* series, [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github).
At this point, you're ready to make your changes! Feel free to ask for help; everyone is a beginner at first :smile_cat:
If a maintainer asks you to "rebase" your PR, they're saying that a lot of code has changed, and that you need to update your branch so it's easier to merge.
# Getting started
1. Fork the repo and create your branch from `master`.
2. If you've added code that should be tested, add tests.
3. If you've changed APIs or added new features, update the documentation.
4. Ensure the test suite passes.
5. Test your changes on a server running the latest supported Minecraft version.
6. Issue that pull request!
> You can use the `Setup Server` gradle task to quickly get your test server setup. Then use the `deploy` task to compile and copy your plugin.jar to the server.
# Code review process
The core team will look at your change as soon as possible and review it. However since this a project that is done in free time, reviewing might sometimes take some time.
# Code, commit message and labeling conventions
We have very precise rules over how our git commit messages can be formatted. This leads to **more
readable messages** that are easy to follow when looking through the **project history**.
It is important to note that we use the git commit messages to **generate** the [CHANGELOG](CHANGELOG.md) document. Improperly formatted commit messages may result in your
change not appearing in the CHANGELOG of the next release.
### <a name="commit-message-format"></a> Commit Message Format
Each commit message consists of a **header**, a **body** and a **footer**. The header has a special
format that includes a **type**, a **scope** and a **subject**:
```html
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
```
> Any line of the commit message cannot be longer 100 characters!<br/>
This allows the message to be easier to read on GitHub as well as in various Git tools.
##### Type
Must be one of the following:
* **feat**: A new feature
* **fix**: A bug fix
* **docs**: Documentation only changes
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing
semi-colons, etc)
* **refactor**: A code change that neither fixes a bug nor adds a feature
* **perf**: A code change that improves performance
* **test**: Adding missing tests
* **chore**: Changes to the build process or auxiliary tools and libraries such as documentation
generation
##### Scope
The scope could be anything that helps specifying the scope (or feature) that is changing.
Examples
- command
- event
- permission
- featureX
##### Subject
The subject contains a succinct description of the change:
* use the imperative, present tense: "change" not "changed" nor "changes"
* don't capitalize first letter
* no dot (.) at the end
##### Body
Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes"
The body should include the motivation for the change and contrast this with previous behavior.
##### Footer
The footer should contain any information about **Breaking Changes** and is also the place to
reference GitHub issues that this commit **Closes**, **Fixes**, or **Relates to**.
> Breaking Changes are intended to be highlighted in the ChangeLog as changes that will require
community users to modify their code after updating to a version that contains this commit.
##### Sample Commit messages:
```text
fix(command): allow execution of /help X from the console
when using the console /help x could not be executed
Fixes #11231
```
```text
feat(respawn): respawn player in bed after death
* add test of player respawning in bed
* add docs regarding how to set the bed respawn point
* add command to reset bed spawnpoint
Fixes #11161 Fixes #3857
```
```text
refactor(respawn): bed respawn event renamed
BREAKING CHANGE: PlayerBedRespawn renamed to PlayerRespawnInBed
Change your code from this:
```java
@EventHandler
public void onRepsawn(PlayerBedRespawn event) {
...
}
```
To this:
```java
@EventHandler
public void onRepsawn(PlayerRespawnInBed event) {
...
}
```
```
<br/>

View File

@ -1,25 +0,0 @@
# WorldSystem
A spigot plugin to give every user his own world
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/2ff2b6f5f2254dcdb4bdb5b45445465c)](https://app.codacy.com/app/Butzlabben/worldsystem?utm_source=github.com&utm_medium=referral&utm_content=Butzlabben/worldsystem&utm_campaign=Badge_Grade_Dashboard)
[![Build Status](https://travis-ci.org/Butzlabben/worldsystem.svg?branch=master)](https://travis-ci.org/Butzlabben/worldsystem) [![](https://jitpack.io/v/Butzlabben/worldsystem.svg)](https://jitpack.io/#Butzlabben/worldsystem)
## About
WorldSystem is a plugin where every player can get a world. There they can build, play and do anything they want without creating stress in a single world. The world owner can also add other players and manage their permissions on his world like is he allowed to build, teleport or changing his gamemode.
When a player creates a new world you can also set a template which will then be cloned.
## How to help making this resource better
- Contributing code
- Creating useful issues
- Donating something
- [![Build Status](https://www.paypalobjects.com/en_US/DK/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=johannes.c.naegele%40gmail.com&currency_code=EUR&source=url)
- Helping other users
- Leaving a good review
## Useful links
- Download Resource: https://www.spigotmc.org/resources/49756/
- Contact author on spigot (rather consider to create an issue here): https://www.spigotmc.org/conversations/add?to=Butzlabben
- Discord server: https://discord.gg/WYz7Qck
- Author on Discord: Butzlabben#5298

104
World System.ipr Normal file
View File

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac"/>
<resourceExtensions>
<entry name=".+\.(properties|xml|html|dtd|tld)"/>
<entry name=".+\.(gif|png|jpeg|jpg)"/>
</resourceExtensions>
<wildcardResourcePatterns>
<entry name="!?*.class"/>
<entry name="!?*.scala"/>
<entry name="!?*.groovy"/>
<entry name="!?*.java"/>
</wildcardResourcePatterns>
<annotationProcessing enabled="false" useClasspath="true"/>
<bytecodeTargetLevel target="1.8"/>
</component>
<component name="CopyrightManager" default="">
<module2copyright/>
</component>
<component name="DependencyValidationManager">
<option name="SKIP_IMPORT_STATEMENTS" value="false"/>
</component>
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false"/>
<component name="GradleUISettings">
<setting name="root"/>
</component>
<component name="GradleUISettings2">
<setting name="root"/>
</component>
<component name="IdProvider" IDEtalkID="11DA1DB66DD62DDA1ED602B7079FE97C"/>
<component name="JavadocGenerationManager">
<option name="OUTPUT_DIRECTORY"/>
<option name="OPTION_SCOPE" value="protected"/>
<option name="OPTION_HIERARCHY" value="true"/>
<option name="OPTION_NAVIGATOR" value="true"/>
<option name="OPTION_INDEX" value="true"/>
<option name="OPTION_SEPARATE_INDEX" value="true"/>
<option name="OPTION_DOCUMENT_TAG_USE" value="false"/>
<option name="OPTION_DOCUMENT_TAG_AUTHOR" value="false"/>
<option name="OPTION_DOCUMENT_TAG_VERSION" value="false"/>
<option name="OPTION_DOCUMENT_TAG_DEPRECATED" value="true"/>
<option name="OPTION_DEPRECATED_LIST" value="true"/>
<option name="OTHER_OPTIONS" value=""/>
<option name="HEAP_SIZE"/>
<option name="LOCALE"/>
<option name="OPEN_IN_BROWSER" value="true"/>
</component>
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/World System.iml" filepath="$PROJECT_DIR$/World System.iml"/>
</modules>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" assert-keyword="true" jdk-15="true" project-jdk-type="JavaSDK" assert-jdk-15="true" project-jdk-name="1.8">
<output url="file://$PROJECT_DIR$/out"/>
</component>
<component name="SvnBranchConfigurationManager">
<option name="mySupportsUserInfoFilter" value="true"/>
</component>
<component name="VcsDirectoryMappings">
<mapping directory="" vcs=""/>
</component>
<component name="masterDetails">
<states>
<state key="ArtifactsStructureConfigurable.UI">
<UIState>
<splitter-proportions>
<SplitterProportionsDataImpl/>
</splitter-proportions>
<settings/>
</UIState>
</state>
<state key="Copyright.UI">
<UIState>
<splitter-proportions>
<SplitterProportionsDataImpl/>
</splitter-proportions>
</UIState>
</state>
<state key="ProjectJDKs.UI">
<UIState>
<splitter-proportions>
<SplitterProportionsDataImpl>
<option name="proportions">
<list>
<option value="0.2"/>
</list>
</option>
</SplitterProportionsDataImpl>
</splitter-proportions>
<last-edited>1.6</last-edited>
</UIState>
</state>
<state key="ScopeChooserConfigurable.UI">
<UIState>
<splitter-proportions>
<SplitterProportionsDataImpl/>
</splitter-proportions>
<settings/>
</UIState>
</state>
</states>
</component>
</project>

209
build.gradle Normal file
View File

@ -0,0 +1,209 @@
buildscript {
repositories {
jcenter()
mavenCentral()
}
}
plugins {
id 'com.github.johnrengelman.shadow' version '6.0.0'
id 'kr.entree.spigradle' version '2.1.2'
id 'java'
id 'jacoco'
}
apply from: "$rootDir/gradle/jacoco.gradle"
//apply from: "$rootDir/gradle/publish.gradle"
sourceCompatibility = 8
targetCompatibility = 8
ext {
mcVersion = project.property("mcVersion")
}
group project.property("group")
spigot {
name = project.property("pluginName")
authors = [project.property("author")]
apiVersion = project.property("apiVersion")
//Comands
commands {
"ws" {
description = 'All WorldSystem Commands'
permissionMessage = 'You do not have permission!'
usage = '/<command> [subCommand]'
}
}
permissions {
'ws.*' {
description = 'gives all Perms'
defaults = 'op'
children = [
'ws.tp.*':true,
'ws.get':true,
'ws.sethome':true,
'ws.tp.world':true,
'ws.tp.toother':true,
'ws.tp.other':true,
'ws.build':true,
'ws.gamemode':true,
'ws.delete':true,
'ws.lag':true,
'ws.big':true,
'ws.large':true,
'ws.confirm':true
]
}
'ws.sethome' {
description = 'You can set a different worldspawn'
defaults = true
}
'ws.tp' {
description = 'You can teleport everything'
defaults = 'op'
children = ['ws.tp.toother':true,'ws.tp.other':true,'ws.tp.world':true]
}
'ws.build' {
description = 'You can build on other Worlds without WorldPermissions'
defaults = 'op'
}
'ws.get' {
description = 'You can create a world via /ws get'
defaults = true
}
'ws.delete' {
description = 'You can delete a world'
defaults = 'op'
}
'ws.gamemode' {
description = 'You can change GameMode on other worlds'
defaults = 'op'
}
'ws.tp.other' {
description = 'You can teleport other persons'
defaults = 'op'
}
'ws.tp.toother' {
description = 'You can teleport across worlds'
defaults = 'op'
}
'ws.tp.world' {
description = 'You can teleport to without rights World'
defaults = 'op'
}
'ws.lag' {
description = 'You can see lag messages'
defaults = 'op'
}
'ws.big' {
description = 'Gives you a bigger world (if set)'
defaults = 'op'
}
'ws.large' {
defaults = 'op'
children = ['ws.big':true]
}
'ws.confirm' {
description = 'You can confirm (if needed) an auto-update'
defaults = 'op'
}
}
load = STARTUP
// depends = ['']
}
compileJava {
options.encoding = 'UTF-8'
options.compilerArgs += ["-parameters"]
options.fork = true
options.forkOptions.executable = 'javac'
}
archivesBaseName = project.property("pluginName")
repositories {
jcenter()
spigot()
// bungeecord()
// paper()
// protocolLib()
// enginehub()
maven {
url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/'
}
maven {
url = 'https://jitpack.io'
}
maven {
url = 'https://libraries.minecraft.net'
}
maven {
url = 'https://repo.onarandombox.com/content/groups/public/'
}
maven {
url = 'http://ci.athion.net/job/FastAsyncWorldEdit/ws/mvn/'
}
maven {
url = 'http://maven.sk89q.com/repo/'
}
mavenCentral()
}
dependencies {
compileOnly lombok()
annotationProcessor lombok()
compileOnly spigot(mcVersion)
//Add dependencies here
//Test dependencies
testImplementation 'org.junit.jupiter:junit-jupiter:5.+'
testImplementation "org.mockito:mockito-core:3.+"
testImplementation mockBukkit()
testImplementation 'org.assertj:assertj-core:3.+'
testImplementation lombok()
testAnnotationProcessor lombok()
compileOnly 'me.clip:placeholderapi:2.10.9'
compileOnly 'com.github.MilkBowl:VaultAPI:1.7'
compileOnly 'com.mojang:authlib:1.5.25'
compileOnly 'org.projectlombok:lombok:1.18.4'
compileOnly 'com.sk89q.worldedit:worldedit-bukkit:7.0.0-SNAPSHOT'
compileOnly 'com.sk89q.worldedit:worldedit-core:7.0.0-SNAPSHOT'
compile files('C:/Users/train/Desktop/World System/lib/commons-io-2.7.jar')
compile files('C:/Users/train/Desktop/World System/lib/FastAsyncWorldEdit.jar')
}
shadowJar {
classifier = ''
// dependencies {
// include(dependency('co.aikar:acf-paper:0.5.0-SNAPSHOT'))
// }
// relocate 'co.aikar.commands', "${packageName}.acf"
// relocate 'co.aikar.locales', "${packageName}.locales"
}
tasks.build.dependsOn(shadowJar)
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
ignoreFailures = false
}
processResources {
project.properties.put("version", this.version)
expand project.properties
}
defaultTasks 'build'

36
commitlint.config.js Normal file
View File

@ -0,0 +1,36 @@
module.exports = {
parserPreset: 'conventional-changelog-conventionalcommits',
rules: {
'body-leading-blank': [1, 'always'],
'footer-leading-blank': [1, 'always'],
'header-max-length': [2, 'always', 72],
'scope-case': [2, 'always', 'lower-case'],
'subject-case': [
2,
'never',
['sentence-case', 'start-case', 'pascal-case', 'upper-case']
],
'subject-empty': [2, 'never'],
'subject-full-stop': [2, 'never', '.'],
'type-case': [2, 'always', 'lower-case'],
'type-empty': [2, 'never'],
'type-enum': [
2,
'always',
[
'build',
'chore',
'ci',
'docs',
'feat',
'fix',
'improvement',
'perf',
'refactor',
'revert',
'style',
'test'
]
]
}
};

7
gradle.properties Normal file
View File

@ -0,0 +1,7 @@
group = de.butzlabben
pluginName = WorldSystem
author = Trainerlord & Butzlabben
mcVersion = 1.16.2
apiVersion = 1.15
version = 2.4.11-SNAPSHOT-20W37b

10
gradle/jacoco.gradle Normal file
View File

@ -0,0 +1,10 @@
jacoco { toolVersion = "0.8.2" }
jacocoTestReport {
reports {
xml.enabled true
html.enabled true
}
}
tasks.check.dependsOn 'jacocoTestReport'

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

172
gradlew vendored Normal file
View File

@ -0,0 +1,172 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# 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"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# 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
;;
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"
which java >/dev/null 2>&1 || 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
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

84
gradlew.bat vendored Normal file
View File

@ -0,0 +1,84 @@
@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=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@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"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
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 init
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
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
: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 %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="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!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

BIN
lib/commons-io-2.7.jar Normal file

Binary file not shown.

BIN
lib/simple-commands.jar Normal file

Binary file not shown.

63
package.json Normal file
View File

@ -0,0 +1,63 @@
{
"devDependencies": {
"@semantic-release/changelog": "5.0.1",
"@semantic-release/commit-analyzer": "8.0.1",
"@semantic-release/git": "9.0.0",
"@semantic-release/github": "7.0.7",
"@semantic-release/release-notes-generator": "9.0.1",
"commitlint": "9.1.2",
"conventional-changelog-conventionalcommits": "4.4.0",
"gradle-semantic-release-plugin": "1.4.8",
"husky": "4.2.5",
"lint-staged": "10.2.13",
"prettier": "2.1.1",
"semantic-release": "17.1.1"
},
"scripts": {
"semantic-release": "npx semantic-release"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"lint-staged": {
"*.{md,json}": [
"prettier --write",
"git add"
],
"*.{gradle,java}": [
"git add"
]
},
"release": {
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"gradle-semantic-release-plugin",
[
"@semantic-release/github",
{
"assets": [
{
"path": "**/build/libs/*.jar"
}
]
}
],
[
"@semantic-release/git",
{
"assets": [
"gradle.properties",
"CHANGELOG.md"
]
}
]
]
},
"engines": {
"node": ">=12.14"
}
}

198
pom.xml
View File

@ -1,198 +0,0 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.butzlabben.world</groupId>
<artifactId>worldsystem</artifactId>
<version>2.4.10</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.number>-</project.build.number>
<project.build.version>${project.version}
Build:${project.build.number}
</project.build.version>
</properties>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
</plugin>
</plugins>
</reporting>
<build>
<finalName>WorldSystem</finalName>
<defaultGoal>package</defaultGoal>
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>LICENSE.txt</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>3.0.0-M3</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>fawe-repo</id>
<url>http://ci.athion.net/job/FastAsyncWorldEdit/ws/mvn/</url>
</repository>
<repository>
<id>we-repo</id>
<url>http://maven.sk89q.com/repo/</url>
</repository>
<!--Repo for CommandFramework-->
<repository>
<id>pp-public</id>
<url>https://nexus.myplayplanet.net/repository/public/</url>
</repository>
<!-- Repo for Vault support-->
<repository>
<id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
</repository>
<!-- Mojang repo for GameProfileBuilder -->
<repository>
<id>mojang</id>
<name>Mojang's Repository</name>
<url>https://libraries.minecraft.net/</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.15-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>1.5.25</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
<scope>compile</scope>
</dependency>
<!--
AsyncWorld is not in the api so I have to use a local file
Issue: https://github.com/boy0001/FastAsyncWorldedit/issues/1060
-->
<dependency>
<groupId>com.sk98q.worldedit</groupId>
<artifactId>FastAsnycWorldEdit</artifactId>
<scope>system</scope>
<version>1.0</version>
<systemPath>${pom.basedir}/lib/FastAsyncWorldEdit.jar</systemPath>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-core</artifactId>
<version>7.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>7.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.myplayplanet</groupId>
<artifactId>CommandFramework</artifactId>
<version>2.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.9.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

10
renovate.json Normal file
View File

@ -0,0 +1,10 @@
{
"extends": ["config:base"],
"node": {
"enabled": true
},
"gradle": {
"enabled": true
},
"labels": ["dependencies"]
}

1
settings.gradle Normal file
View File

@ -0,0 +1 @@
rootProject.name = 'World System'

View File

@ -1,9 +1,7 @@
package de.butzlabben.world;
import de.butzlabben.world.autoupdater.AutoUpdater;
import de.butzlabben.world.command.WSCommand;
import de.butzlabben.world.command.WorldAdministrateCommand;
import de.butzlabben.world.command.WorldSettingsCommands;
import de.butzlabben.world.command.CommandRegistry;
import de.butzlabben.world.config.DependenceConfig;
import de.butzlabben.world.config.GuiConfig;
import de.butzlabben.world.config.MessageConfig;
@ -22,7 +20,6 @@ import de.butzlabben.world.wrapper.CreatorAdapter;
import de.butzlabben.world.wrapper.SystemWorld;
import java.io.File;
import java.io.IOException;
import net.myplayplanet.commandframework.CommandFramework;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.World;
@ -37,11 +34,9 @@ import org.bukkit.plugin.java.JavaPlugin;
* @since 10.07.2017
*/
public class WorldSystem extends JavaPlugin {
private static boolean is1_13Plus = false;
final private String version = this.getDescription().getVersion();
private CreatorAdapter creator;
public static void createConfigs() {
File folder = getInstance().getDataFolder();
File dir = new File(folder + "/worldsources");
@ -104,6 +99,9 @@ public class WorldSystem extends JavaPlugin {
@Override
public void onEnable() {
//////
getCommand("ws").setExecutor(new CommandRegistry());
// Set right version
if (VersionUtil.getVersion() >= 13)
is1_13Plus = true;
@ -111,11 +109,11 @@ public class WorldSystem extends JavaPlugin {
createConfigs();
// Establish database connection
DatabaseProvider.getInstance().getUtil().connect();
DatabaseProvider.instance.util.connect();
// Fix for #34
// Check if tables exist and create them if necessary.
PlayerPositions.getInstance().checkTables();
PlayerPositions.instance.checkTables();
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new PlayerListener(), this);
@ -149,12 +147,20 @@ public class WorldSystem extends JavaPlugin {
}, 20 * 60 * 2, 20 * 60 * 2);
//COMMANDS
CommandFramework framework = new CommandFramework(this);
framework.setNoPermissionMessage(MessageConfig.getNoPermission());
System.out.println("Registered");
//this.getCommand("ws").setExecutor(new WSCommandMain());
//this.getCommand("ws").setExecutor(new CommandMain());
//this.getCommand("ws get").setExecutor(new WSGet());
//this.getCommand("ws reset").setExecutor(new WorldReset());
//this.getCommand("ws home").setExecutor(new WorldHome());
//this.getCommand("ws tnt").setExecutor(new WorldTnt());
//this.getCommand("ws fire").setExecutor(new WorldFire());
framework.registerCommands(new WSCommand());
framework.registerCommands(new WorldSettingsCommands());
framework.registerCommands(new WorldAdministrateCommand());
System.setProperty("bstats.relocatecheck", "false");
@ -203,7 +209,7 @@ public class WorldSystem extends JavaPlugin {
}
// Close database connection
DatabaseProvider.getInstance().getUtil().close();
DatabaseProvider.instance.util.close();
Bukkit.getConsoleSender()
.sendMessage(PluginConfig.getPrefix() + "Successfully disabled WorldSystem v" + version);
@ -212,4 +218,5 @@ public class WorldSystem extends JavaPlugin {
public CreatorAdapter getAdapter() {
return creator;
}
}

View File

@ -0,0 +1,93 @@
package de.butzlabben.world.command;
import de.butzlabben.world.command.commands.WSCommands;
import de.butzlabben.world.command.commands.WorldAdministrateCommand;
import de.butzlabben.world.command.commands.WorldSettingsCommands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import static de.butzlabben.world.command.commands.WSCommands.*;
import static de.butzlabben.world.command.commands.WorldAdministrateCommand.*;
import java.util.List;
public class CommandRegistry implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 0) {
WSCommands ws = new WSCommands();
return ws.mainCommand(sender, command, label, args);
} else {
WSCommands ws = new WSCommands();
WorldAdministrateCommand admin = new WorldAdministrateCommand();
WorldSettingsCommands settings = new WorldSettingsCommands();
switch (args[0]) {
//WSCommands
case "get":
if (sender.hasPermission("ws.get")) {
return ws.getCommand(sender, command, label, args);
}
else {
return false;
}
case "gui":
return ws.guiCommand(sender, command, label, args);
case "confirm":
if (sender.hasPermission("ws.confirm")) {
return ws.confirmCommand(sender, command, label, args);
} else {
return false;
}
case "home":
return ws.homeCommand(sender, command, label, args);
case "info":
return ws.infoComannd(sender, command, label, args);
case "leave":
return ws.leaveCommand(sender, command, label, args);
case "tp":
if (sender.hasPermission("ws.tp")) {
return ws.tpCommand(sender, command, label, args);
} else {
return false;
}
//Admin Command
case "delmember":
return admin.delMemberCommand(sender, command, label, args);
case "delete":
if (sender.hasPermission("ws.delete")) {
return admin.deleteCommand(sender, command, label, args);
} else {
return false;
}
case "addmember":
return admin.addMemberCommand(sender, command, label, args);
case "toggletp":
return admin.toggleTeleportCommand(sender, command, label, args);
case "togglegm":
return admin.toggleGamemodeCommand(sender, command, label, args);
case "togglewe":
return admin.toggleWorldeditCommand(sender, command, label, args);
case "togglebuild":
return admin.toggleBuildCommand(sender, command, label, args);
//World Settings Command
case "reset":
return settings.resetCommand(sender, command, label, args);
case "sethome":
if (sender.hasPermission("ws.sethome")) {
return settings.setHomeCommand(sender, command, label, args);
} else {
return false;
}
case "tnt":
return settings.tntCommand(sender, command, label, args);
case "fire":
return settings.fireCommand(sender, command, label, args);
default:
return false;
}
}
}
}

View File

@ -1,259 +0,0 @@
package de.butzlabben.world.command;
import de.butzlabben.world.WorldSystem;
import de.butzlabben.world.autoupdater.AutoUpdater;
import de.butzlabben.world.config.DependenceConfig;
import de.butzlabben.world.config.MessageConfig;
import de.butzlabben.world.config.PluginConfig;
import de.butzlabben.world.config.WorldConfig;
import de.butzlabben.world.gui.WorldChooseGUI;
import de.butzlabben.world.gui.WorldSystemGUI;
import de.butzlabben.world.util.MoneyUtil;
import de.butzlabben.world.wrapper.SystemWorld;
import de.butzlabben.world.wrapper.WorldPlayer;
import de.butzlabben.world.wrapper.WorldTemplate;
import de.butzlabben.world.wrapper.WorldTemplateProvider;
import net.myplayplanet.commandframework.CommandArgs;
import net.myplayplanet.commandframework.api.Command;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Iterator;
import java.util.List;
public class WSCommand {
@Command(name = "ws")
public void mainCommand(CommandArgs args) {
CommandSender cs = args.getSender(CommandSender.class);
String prefix = PluginConfig.getPrefix();
cs.sendMessage(
prefix + "WorldSystem by Butzlabben v" + WorldSystem.getInstance().getDescription().getVersion());
cs.sendMessage(prefix + "Contributors: Jubeki, montlikadani, jstoeckm2");
List<String> cmdHelp = MessageConfig.getCommandHelp();
cmdHelp.forEach(s -> cs.sendMessage(prefix + s));
if (cs.hasPermission("ws.delete"))
cs.sendMessage(MessageConfig.getDeleteCommandHelp());
}
@Command(name = "ws.gui", inGameOnly = true)
public void guiCommand(CommandArgs args) {
Player p = args.getSender(Player.class);
WorldPlayer wp = new WorldPlayer(p);
if (!wp.isOnSystemWorld()) {
p.sendMessage(MessageConfig.getNotOnWorld());
return;
}
if (!wp.isOwnerofWorld()) {
p.sendMessage(MessageConfig.getNoPermission());
return;
}
p.openInventory(new WorldSystemGUI().getInventory(p));
}
@Command(name = "ws.confirm", permission = "ws.confirm")
public void confirmCommand(CommandArgs args) {
CommandSender cs = args.getSender(Player.class);
if (AutoUpdater.getInstance().confirmed()) {
cs.sendMessage(PluginConfig.getPrefix() + "§cAlready confirmed or no confirm needed");
return;
}
AutoUpdater.getInstance().confirm();
cs.sendMessage(PluginConfig.getPrefix() + "§aAutoupdate confirmed, §crestart §ato apply changes");
}
@Command(name = "ws.get", inGameOnly = true)
public void getCommand(CommandArgs args) {
Player p = args.getSender(Player.class);
// Check if use can create a world
if (!p.hasPermission("ws.get")) {
p.sendMessage(MessageConfig.getNoPermission());
return;
}
// create New Entry
DependenceConfig dc = new DependenceConfig(p);
if (dc.hasWorld()) {
p.sendMessage(MessageConfig.getWorldAlreadyExists());
return;
}
if (PluginConfig.isMultiChoose()) {
if (args.length() > 0) {
String key = args.getArgument(0);
WorldTemplate template = WorldTemplateProvider.getInstance().getTemplate(key);
if (template != null) {
// Permission for this specific template
if (template.getPermission() != null && !p.hasPermission(template.getPermission())) {
p.sendMessage(MessageConfig.getNoPermission());
return;
}
// Implementation check for #15
if (template.getCost() > 0) {
if (!MoneyUtil.hasMoney(p.getUniqueId(), template.getCost())) {
p.sendMessage(MessageConfig.getNotEnoughMoney());
return;
}
MoneyUtil.removeMoney(p.getUniqueId(), template.getCost());
}
create(p, template);
return;
}
}
WorldChooseGUI.letChoose(p);
} else {
WorldTemplate template = WorldTemplateProvider.getInstance()
.getTemplate(PluginConfig.getDefaultWorldTemplate());
if (template != null)
create(p, template);
else {
p.sendMessage(PluginConfig.getPrefix() + "§cError in config at \"worldtemplates.default\"");
p.sendMessage(PluginConfig.getPrefix() + "§cPlease contact an administrator");
}
}
}
@Command(name = "ws.home", inGameOnly = true)
public void homeCommand(CommandArgs args) {
Player p = args.getSender(Player.class);
String worldname = p.getWorld().getName();
DependenceConfig dc = new DependenceConfig(p);
if (!dc.hasWorld()) {
p.sendMessage(MessageConfig.getNoWorldOwn());
return;
}
WorldPlayer wp = new WorldPlayer(p, worldname);
if (wp.isOnSystemWorld()) {
SystemWorld.tryUnloadLater(Bukkit.getWorld(worldname));
}
SystemWorld sw = SystemWorld.getSystemWorld(dc.getWorldname());
if (sw == null) {
p.sendMessage(MessageConfig.getNoWorldOwn());
return;
}
if (sw.isLoaded()) {
sw.teleportToWorldSpawn(p);
} else {
sw.load(p);
}
}
@Command(name = "ws.info", inGameOnly = true)
public void infoComannd(CommandArgs args) {
Player p = args.getSender(Player.class);
WorldPlayer wp = new WorldPlayer(p, p.getWorld().getName());
if (!wp.isOnSystemWorld()) {
p.sendMessage(MessageConfig.getNotOnWorld());
return;
}
WorldConfig wc = WorldConfig.getWorldConfig(p.getWorld().getName());
int id = wc.getId();
String owner = wc.getOwnerName();
boolean fire = wc.isFire();
boolean tnt = wc.isTnt();
p.sendMessage(MessageConfig.getInfoOwner().replaceAll("%data", owner));
p.sendMessage(MessageConfig.getInfoId().replaceAll("%data", "" + id));
p.sendMessage(MessageConfig.getInfoTnt().replaceAll("%data",
tnt ? MessageConfig.getInfoEnabled() : MessageConfig.getInfoDisabled()));
p.sendMessage(MessageConfig.getInfoFire().replaceAll("%data",
fire ? MessageConfig.getInfoEnabled() : MessageConfig.getInfoDisabled()));
StringBuilder sb = new StringBuilder();
Iterator<String> it = wc.getMembersWithNames().values().iterator();
while (it.hasNext()) {
sb.append(it.next());
if (it.hasNext())
sb.append(" ");
}
p.sendMessage(MessageConfig.getInfoMember().replaceAll("%data", sb.toString().trim()));
}
@Command(name = "ws.leave", inGameOnly = true)
public void leaveCommand(CommandArgs args) {
Player p = args.getSender(Player.class);
String worldname = p.getWorld().getName();
WorldPlayer wp = new WorldPlayer(p, worldname);
if (wp.isOnSystemWorld()) {
// Extra safety for #2
if (PluginConfig.getSpawn(null).getWorld() == null) {
Bukkit.getConsoleSender().sendMessage(PluginConfig.getPrefix() + "§cThe spawn is not properly set");
p.sendMessage(PluginConfig.getPrefix() + "§cThe spawn is not properly set");
return;
}
p.teleport(PluginConfig.getSpawn(p));
p.setGameMode(PluginConfig.getSpawnGamemode());
World w = Bukkit.getWorld(p.getWorld().getName());
SystemWorld.tryUnloadLater(w);
} else {
p.sendMessage(MessageConfig.getNotOnWorld());
}
}
@Command(name = "ws.tp", inGameOnly = true)
public void tpCommand(CommandArgs args) {
Player p = args.getSender(Player.class);
if (args.length() < 1) {
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws tp <World>"));
return;
}
if (args.getArgument(0).equalsIgnoreCase(p.getName()) || args.getArgument(0).equalsIgnoreCase(p.getUniqueId().toString())) {
p.chat("/ws home");
return;
}
DependenceConfig dc = new DependenceConfig(args.getArgument(0));
String worldname = dc.getWorldNameByOfflinePlayer();
if (!dc.hasWorld()) {
p.sendMessage(MessageConfig.getNoWorldOther());
return;
}
SystemWorld sw = SystemWorld.getSystemWorld(worldname);
WorldPlayer wp1 = new WorldPlayer(p, p.getWorld().getName());
WorldPlayer wp = new WorldPlayer(p, worldname);
if (p.getWorld().getName().equals(worldname)) {
sw.teleportToWorldSpawn(p);
return;
}
if (!p.hasPermission("ws.tp.world")) {
if (!wp.isMemberofWorld(worldname) && !wp.isOwnerofWorld()) {
p.sendMessage(MessageConfig.getNoMemberOther());
return;
}
}
if (wp1.isOnSystemWorld()) {
World w = p.getWorld();
SystemWorld.tryUnloadLater(w);
}
if (sw != null)
if (!sw.isLoaded()) {
sw.load(p);
} else {
sw.teleportToWorldSpawn(p);
}
}
private void create(Player p, WorldTemplate template) {
Bukkit.getScheduler().runTask(WorldSystem.getInstance(), () -> {
if (SystemWorld.create(p, template))
p.sendMessage(MessageConfig.getSettingUpWorld());
});
}
}

View File

@ -1,309 +0,0 @@
package de.butzlabben.world.command;
import de.butzlabben.world.WorldSystem;
import de.butzlabben.world.config.DependenceConfig;
import de.butzlabben.world.config.MessageConfig;
import de.butzlabben.world.config.PluginConfig;
import de.butzlabben.world.config.WorldConfig;
import de.butzlabben.world.event.WorldAddmemberEvent;
import de.butzlabben.world.event.WorldDeleteEvent;
import de.butzlabben.world.event.WorldRemovememberEvent;
import de.butzlabben.world.util.PlayerPositions;
import de.butzlabben.world.wrapper.SystemWorld;
import de.butzlabben.world.wrapper.WorldPlayer;
import net.myplayplanet.commandframework.CommandArgs;
import net.myplayplanet.commandframework.api.Command;
import org.apache.commons.io.FileUtils;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import java.io.File;
import java.io.IOException;
public class WorldAdministrateCommand {
@Command(name = "ws.delmember", inGameOnly = true, usage = "/ws delmember <Player>")
public void delMemberCommand(CommandArgs args) {
Player p = args.getSender(Player.class);
if (args.length() < 1) {
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws delmember <Player>"));
return;
}
DependenceConfig dc = new DependenceConfig(p);
if (!dc.hasWorld()) {
p.sendMessage(MessageConfig.getNoWorldOwn());
return;
}
@SuppressWarnings("deprecation")
OfflinePlayer a = Bukkit.getOfflinePlayer(args.getArgument(0));
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
if (a == null) {
p.sendMessage(MessageConfig.getNotRegistered().replaceAll("%player", args.getArgument(0)));
return;
} else if (!wc.isMember(a.getUniqueId())) {
p.sendMessage(MessageConfig.getNoMemberOwn());
return;
}
WorldRemovememberEvent event = new WorldRemovememberEvent(a.getUniqueId(), dc.getWorldname(), p);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
return;
if (a.isOnline()) {
Player t = (Player) a;
if (t.getWorld().getName().equals(new DependenceConfig(p).getWorldname())) {
t.teleport(PluginConfig.getSpawn(t));
t.setGameMode(PluginConfig.getSpawnGamemode());
}
}
wc.removeMember(a.getUniqueId());
try {
wc.save();
} catch (IOException e) {
p.sendMessage(MessageConfig.getUnknownError());
e.printStackTrace();
}
p.sendMessage(MessageConfig.getMemberRemoved().replaceAll("%player", a.getName()));
}
@Command(name = "ws.delete", permission = "ws.delete", usage = "/ws delete <Player>")
public void deleteCommand(CommandArgs args) {
CommandSender cs = args.getSender(CommandSender.class);
if (args.length() < 1) {
cs.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws delete <Player>"));
return;
}
DependenceConfig dc = new DependenceConfig(args.getArgument(0));
if (!dc.hasWorld()) {
cs.sendMessage(MessageConfig.getNoWorldOther());
return;
}
String worldname = dc.getWorldname();
SystemWorld sw = SystemWorld.getSystemWorld(worldname);
WorldDeleteEvent event = new WorldDeleteEvent(cs, sw);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
return;
if (sw != null && sw.isLoaded())
sw.directUnload(Bukkit.getWorld(worldname));
WorldConfig config = WorldConfig.getWorldConfig(worldname);
// Delete unnecessary positions
PlayerPositions.getInstance().deletePositions(config);
Bukkit.getScheduler().runTaskLater(WorldSystem.getInstance(), () -> {
OfflinePlayer op = dc.getOwner();
String uuid = op.getUniqueId().toString();
File dir = new File(PluginConfig.getWorlddir() + "/" + worldname);
if (!dir.exists())
dir = new File(Bukkit.getWorldContainer(), worldname);
if (dir.exists())
try {
FileUtils.deleteDirectory(dir);
} catch (Exception e) {
cs.sendMessage(MessageConfig.getUnknownError());
e.printStackTrace();
}
File dconfig = new File("plugins//WorldSystem//dependence.yml");
YamlConfiguration cfg = YamlConfiguration.loadConfiguration(dconfig);
cfg.set("Dependences." + uuid + ".ID", null);
cfg.set("Dependences." + uuid + ".ActualName", null);
cfg.set("Dependences." + uuid, null);
try {
cfg.save(dconfig);
} catch (Exception e) {
cs.sendMessage(MessageConfig.getUnknownError());
e.printStackTrace();
}
cs.sendMessage(MessageConfig.getDeleteWorldOther().replaceAll("%player", op.getName()));
if (op.isOnline()) {
Player p1 = Bukkit.getPlayer(op.getUniqueId());
p1.sendMessage(MessageConfig.getDeleteWorldOwn());
}
}, 10);
}
@Command(name = "ws.addmember", inGameOnly = true, usage = "/ws addmember <Player>")
public void addMemberCommand(CommandArgs args) {
Player p = args.getSender(Player.class);
if (args.length() < 1) {
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws addmember <Player>"));
return;
}
DependenceConfig dc = new DependenceConfig(p);
if (!dc.hasWorld()) {
p.sendMessage(MessageConfig.getNoWorldOwn());
return;
}
@SuppressWarnings("deprecation")
OfflinePlayer a = Bukkit.getOfflinePlayer(args.getArgument(0));
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
if (a == null) {
p.sendMessage(MessageConfig.getNotRegistered().replaceAll("%player", args.getArgument(0)));
return;
} else if (wc.isMember(a.getUniqueId())) {
p.sendMessage(MessageConfig.getAlreadyMember());
return;
}
WorldAddmemberEvent event = new WorldAddmemberEvent(a.getUniqueId(), dc.getWorldname(), p);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
return;
wc.addMember(a.getUniqueId());
try {
wc.save();
} catch (IOException e) {
p.sendMessage(MessageConfig.getUnknownError());
e.printStackTrace();
}
p.sendMessage(MessageConfig.getMemberAdded().replaceAll("%player", a.getName()));
}
@Command(name = "ws.toggletp", inGameOnly = true, usage = "/ws toggletp <Player>")
public void toggleTeleportCommand(CommandArgs args) {
Player p = args.getSender(Player.class);
if (args.length() < 1) {
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws toggletp <Player>"));
return;
}
DependenceConfig dc = new DependenceConfig(p);
if (!dc.hasWorld()) {
p.sendMessage(MessageConfig.getNoWorldOwn());
return;
}
@SuppressWarnings("deprecation")
OfflinePlayer a = Bukkit.getOfflinePlayer(args.getArgument(0));
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
if (!wc.isMember(a.getUniqueId())) {
p.sendMessage(MessageConfig.getNoMemberOwn());
return;
}
WorldPlayer wp = new WorldPlayer(a, dc.getWorldname());
if (wp.isOwnerofWorld()) {
p.sendMessage(PluginConfig.getPrefix() + "§cYou are the owner");
return;
}
if (wp.toggleTeleport()) {
p.sendMessage(MessageConfig.getToggleTeleportEnabled().replaceAll("%player", a.getName()));
} else {
p.sendMessage(MessageConfig.getToggleTeleportDisabled().replaceAll("%player", a.getName()));
}
}
@Command(name = "ws.togglegm", inGameOnly = true, usage = "/ws togglegm <Player>")
public void toggleGamemodeCommand(CommandArgs args) {
Player p = args.getSender(Player.class);
if (args.length() < 1) {
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws togglegm <Player>"));
return;
}
DependenceConfig dc = new DependenceConfig(p);
if (!dc.hasWorld()) {
p.sendMessage(MessageConfig.getNoWorldOwn());
return;
}
@SuppressWarnings("deprecation")
OfflinePlayer a = Bukkit.getOfflinePlayer(args.getArgument(0));
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
if (!wc.isMember(a.getUniqueId())) {
p.sendMessage(MessageConfig.getNoMemberOwn());
return;
}
WorldPlayer wp = new WorldPlayer(a, dc.getWorldname());
if (wp.isOwnerofWorld()) {
p.sendMessage(PluginConfig.getPrefix() + "§cYou are the owner");
return;
}
if (wp.toggleGamemode()) {
p.sendMessage(MessageConfig.getToggleGameModeEnabled().replaceAll("%player", a.getName()));
} else {
p.sendMessage(MessageConfig.getToggleGameModeDisabled().replaceAll("%player", a.getName()));
}
}
@Command(name = "ws.togglewe", inGameOnly = true, usage = "/ws togglewe <Player>")
public void toggleWorldeditCommand(CommandArgs args) {
Player p = args.getSender(Player.class);
if (args.length() < 1) {
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws togglewe <Player>"));
return;
}
DependenceConfig dc = new DependenceConfig(p);
if (!dc.hasWorld()) {
p.sendMessage(MessageConfig.getNoWorldOwn());
return;
}
@SuppressWarnings("deprecation")
OfflinePlayer a = Bukkit.getOfflinePlayer(args.getArgument(0));
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
if (!wc.isMember(a.getUniqueId())) {
p.sendMessage(MessageConfig.getNoMemberOwn());
return;
}
WorldPlayer wp = new WorldPlayer(a, dc.getWorldname());
if (wp.isOwnerofWorld()) {
p.sendMessage(PluginConfig.getPrefix() + "§cYou are the owner");
return;
}
if (wp.toggleWorldEdit()) {
p.sendMessage(MessageConfig.getToggleWorldeditEnabled().replaceAll("%player", a.getName()));
} else {
p.sendMessage(MessageConfig.getToggleWorldeditDisabled().replaceAll("%player", a.getName()));
}
}
@Command(name = "ws.togglebuild", inGameOnly = true, usage = "/ws togglebuild <Player>")
public void toggleBuildCommand(CommandArgs args) {
Player p = args.getSender(Player.class);
if (args.length() < 1) {
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws togglebuild <Player>"));
return;
}
DependenceConfig dc = new DependenceConfig(p);
if (!dc.hasWorld()) {
p.sendMessage(MessageConfig.getNoWorldOwn());
return;
}
@SuppressWarnings("deprecation")
OfflinePlayer a = Bukkit.getOfflinePlayer(args.getArgument(0));
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
if (!wc.isMember(a.getUniqueId())) {
p.sendMessage(MessageConfig.getNoMemberOwn());
return;
}
WorldPlayer wp = new WorldPlayer(a, dc.getWorldname());
if (wp.isOwnerofWorld()) {
p.sendMessage(PluginConfig.getPrefix() + "§cYou are the owner");
return;
}
if (wp.toggleBuild()) {
p.sendMessage(MessageConfig.getToggleBuildEnabled().replaceAll("%player", a.getName()));
} else {
p.sendMessage(MessageConfig.getToggleBuildDisabled().replaceAll("%player", a.getName()));
}
}
}

View File

@ -0,0 +1,288 @@
package de.butzlabben.world.command.commands;
import de.butzlabben.world.WorldSystem;
import de.butzlabben.world.autoupdater.AutoUpdater;
import de.butzlabben.world.config.DependenceConfig;
import de.butzlabben.world.config.MessageConfig;
import de.butzlabben.world.config.PluginConfig;
import de.butzlabben.world.config.WorldConfig;
import de.butzlabben.world.gui.WorldChooseGUI;
import de.butzlabben.world.gui.WorldSystemGUI;
import de.butzlabben.world.util.MoneyUtil;
import de.butzlabben.world.wrapper.SystemWorld;
import de.butzlabben.world.wrapper.WorldPlayer;
import de.butzlabben.world.wrapper.WorldTemplate;
import de.butzlabben.world.wrapper.WorldTemplateProvider;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Iterator;
import java.util.List;
public class WSCommands {
public boolean mainCommand(CommandSender sender, Command command, String label, String[] args) {
CommandSender cs = sender;
String prefix = PluginConfig.getPrefix();
cs.sendMessage(
prefix + "WorldSystem by Butzlabben v" + WorldSystem.getInstance().getDescription().getVersion());
cs.sendMessage(prefix + "Contributors: Jubeki, montlikadani, jstoeckm2");
List<String> cmdHelp = MessageConfig.getCommandHelp();
cmdHelp.forEach(s -> cs.sendMessage(prefix + s));
if (cs.hasPermission("ws.delete")) {
cs.sendMessage(MessageConfig.getDeleteCommandHelp());
}
return true;
}
public boolean guiCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
WorldPlayer wp = new WorldPlayer(p);
if (!wp.isOnSystemWorld()) {
p.sendMessage(MessageConfig.getNotOnWorld());
return false;
}
if (!wp.isOwnerofWorld()) {
p.sendMessage(MessageConfig.getNoPermission());
return false;
}
p.openInventory(new WorldSystemGUI().getInventory(p));
return true;
} else {
sender.sendMessage("No Console"); //TODO Get Config
return false;
}
}
public boolean confirmCommand(CommandSender sender, Command command, String label, String[] args) {
CommandSender cs = sender;
if (AutoUpdater.getInstance().confirmed()) {
cs.sendMessage(PluginConfig.getPrefix() + "§cAlready confirmed or no confirm needed");
return false;
}
AutoUpdater.getInstance().confirm();
cs.sendMessage(PluginConfig.getPrefix() + "§aAutoupdate confirmed, §crestart §ato apply changes");
return true;
}
public boolean getCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player)sender;
// Check if use can create a world
if (!p.hasPermission("ws.get")) {
p.sendMessage(MessageConfig.getNoPermission());
return false;
}
// create New Entry
DependenceConfig dc = new DependenceConfig(p);
if (dc.hasWorld()) {
p.sendMessage(MessageConfig.getWorldAlreadyExists());
return false;
}
if (PluginConfig.isMultiChoose()) {
if (args.length > 1) {
String key = args[1];
WorldTemplate template = WorldTemplateProvider.getInstance().getTemplate(key);
if (template != null) {
// Permission for this specific template
if (template.getPermission() != null && !p.hasPermission(template.getPermission())) {
p.sendMessage(MessageConfig.getNoPermission());
return false;
}
// Implementation check for #15
if (template.getCost() > 0) {
if (!MoneyUtil.hasMoney(p.getUniqueId(), template.getCost())) {
p.sendMessage(MessageConfig.getNotEnoughMoney());
return false;
}
MoneyUtil.removeMoney(p.getUniqueId(), template.getCost());
}
this.create(p, template);
return false;
}
}
WorldChooseGUI.letChoose(p);
} else {
WorldTemplate template = WorldTemplateProvider.getInstance()
.getTemplate(PluginConfig.getDefaultWorldTemplate());
if (template != null)
this.create(p, template);
else {
p.sendMessage(PluginConfig.getPrefix() + "§cError in config at \"worldtemplates.default\"");
p.sendMessage(PluginConfig.getPrefix() + "§cPlease contact an administrator");
}
}
return true;
} else {
sender.sendMessage("No Console"); //TODO Add Config
return false;
}
}
public boolean homeCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
String worldname = p.getWorld().getName();
DependenceConfig dc = new DependenceConfig(p);
if (!dc.hasWorld()) {
p.sendMessage(MessageConfig.getNoWorldOwn());
return false;
}
WorldPlayer wp = new WorldPlayer(p, worldname);
if (wp.isOnSystemWorld()) {
SystemWorld.tryUnloadLater(Bukkit.getWorld(worldname));
}
SystemWorld sw = SystemWorld.getSystemWorld(dc.getWorldname());
if (sw == null) {
p.sendMessage(MessageConfig.getNoWorldOwn());
return false;
}
if (sw.isLoaded()) {
sw.teleportToWorldSpawn(p);
} else {
sw.load(p);
}
return true;
} else {
sender.sendMessage("No Console"); //TODO Add Config
return false;
}
}
public boolean infoComannd(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
WorldPlayer wp = new WorldPlayer(p, p.getWorld().getName());
if (!wp.isOnSystemWorld()) {
p.sendMessage(MessageConfig.getNotOnWorld());
return false;
}
WorldConfig wc = WorldConfig.getWorldConfig(p.getWorld().getName());
int id = wc.getId();
String owner = wc.getOwnerName();
boolean fire = wc.isFire();
boolean tnt = wc.isTnt();
p.sendMessage(MessageConfig.getInfoOwner().replaceAll("%data", owner));
p.sendMessage(MessageConfig.getInfoId().replaceAll("%data", "" + id));
p.sendMessage(MessageConfig.getInfoTnt().replaceAll("%data",
tnt ? MessageConfig.getInfoEnabled() : MessageConfig.getInfoDisabled()));
p.sendMessage(MessageConfig.getInfoFire().replaceAll("%data",
fire ? MessageConfig.getInfoEnabled() : MessageConfig.getInfoDisabled()));
StringBuilder sb = new StringBuilder();
Iterator<String> it = wc.getMembersWithNames().values().iterator();
while (it.hasNext()) {
sb.append(it.next());
if (it.hasNext())
sb.append(" ");
}
p.sendMessage(MessageConfig.getInfoMember().replaceAll("%data", sb.toString().trim()));
return true;
} else {
sender.sendMessage("No Console"); //TODO Get Config
return false;
}
}
public boolean leaveCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
String worldname = p.getWorld().getName();
WorldPlayer wp = new WorldPlayer(p, worldname);
if (wp.isOnSystemWorld()) {
// Extra safety for #2
if (PluginConfig.getSpawn(null).getWorld() == null) {
Bukkit.getConsoleSender().sendMessage(PluginConfig.getPrefix() + "§cThe spawn is not properly set");
p.sendMessage(PluginConfig.getPrefix() + "§cThe spawn is not properly set");
return false;
}
p.teleport(PluginConfig.getSpawn(p));
p.setGameMode(PluginConfig.getSpawnGamemode());
World w = Bukkit.getWorld(p.getWorld().getName());
SystemWorld.tryUnloadLater(w);
} else {
p.sendMessage(MessageConfig.getNotOnWorld());
}
return true;
} else {
sender.sendMessage("No Console"); //TODO Get Config
return false;
}
}
public boolean tpCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
if (args.length < 2) {
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws tp <World>"));
return false;
}
if (args[1].equalsIgnoreCase(p.getName()) || args[1].equalsIgnoreCase(p.getUniqueId().toString())) {
p.chat("/ws home");
return false;
}
DependenceConfig dc = new DependenceConfig(args[1]);
String worldname = dc.getWorldNameByOfflinePlayer();
if (!dc.hasWorld()) {
p.sendMessage(MessageConfig.getNoWorldOther());
return false;
}
SystemWorld sw = SystemWorld.getSystemWorld(worldname);
WorldPlayer wp1 = new WorldPlayer(p, p.getWorld().getName());
WorldPlayer wp = new WorldPlayer(p, worldname);
if (p.getWorld().getName().equals(worldname)) {
sw.teleportToWorldSpawn(p);
return false;
}
if (!p.hasPermission("ws.tp.world")) {
if (!wp.isMemberofWorld(worldname) && !wp.isOwnerofWorld()) {
p.sendMessage(MessageConfig.getNoMemberOther());
return false;
}
}
if (wp1.isOnSystemWorld()) {
World w = p.getWorld();
SystemWorld.tryUnloadLater(w);
}
if (sw != null) {
if (!sw.isLoaded()) {
sw.load(p);
} else {
sw.teleportToWorldSpawn(p);
}
}
return true;
} else {
sender.sendMessage("No Console"); //TODO Get Config
return false;
}
}
private void create(Player p, WorldTemplate template) {
Bukkit.getScheduler().runTask(WorldSystem.getInstance(), () -> {
if (SystemWorld.create(p, template))
p.sendMessage(MessageConfig.getSettingUpWorld());
});
}
}

View File

@ -0,0 +1,332 @@
package de.butzlabben.world.command.commands;
import com.boydti.fawe.configuration.file.YamlConfiguration;
import de.butzlabben.world.WorldSystem;
import de.butzlabben.world.config.DependenceConfig;
import de.butzlabben.world.config.MessageConfig;
import de.butzlabben.world.config.PluginConfig;
import de.butzlabben.world.config.WorldConfig;
import de.butzlabben.world.event.WorldAddmemberEvent;
import de.butzlabben.world.event.WorldDeleteEvent;
import de.butzlabben.world.event.WorldRemovememberEvent;
import de.butzlabben.world.util.PlayerPositions;
import de.butzlabben.world.wrapper.SystemWorld;
import de.butzlabben.world.wrapper.WorldPlayer;
import org.apache.commons.io.FileUtils;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.io.File;
import java.io.IOException;
public class WorldAdministrateCommand {
public boolean delMemberCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
if (args.length < 2) {
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws delmember <Player>"));
return false;
}
DependenceConfig dc = new DependenceConfig(p);
if (!dc.hasWorld()) {
p.sendMessage(MessageConfig.getNoWorldOwn());
return false;
}
@SuppressWarnings("deprecation")
OfflinePlayer a = Bukkit.getOfflinePlayer(args[1]);
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
if (a == null) {
p.sendMessage(MessageConfig.getNotRegistered().replaceAll("%player", args[1]));
return false;
} else if (!wc.isMember(a.getUniqueId())) {
p.sendMessage(MessageConfig.getNoMemberOwn());
return false;
}
WorldRemovememberEvent event = new WorldRemovememberEvent(a.getUniqueId(), dc.getWorldname(), p);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
return false;
if (a.isOnline()) {
Player t = (Player) a;
if (t.getWorld().getName().equals(new DependenceConfig(p).getWorldname())) {
t.teleport(PluginConfig.getSpawn(t));
t.setGameMode(PluginConfig.getSpawnGamemode());
}
}
wc.removeMember(a.getUniqueId());
try {
wc.save();
} catch (IOException e) {
p.sendMessage(MessageConfig.getUnknownError());
e.printStackTrace();
}
p.sendMessage(MessageConfig.getMemberRemoved().replaceAll("%player", a.getName()));
return true;
} else {
sender.sendMessage("No Console"); //TODO Get Config
return false;
}
}
public boolean deleteCommand(CommandSender sender, Command command, String label, String[] args) {
CommandSender cs = sender;
if (args.length < 2) {
cs.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws delete <Player>"));
return false;
}
DependenceConfig dc = new DependenceConfig(args[1]);
if (!dc.hasWorld()) {
cs.sendMessage(MessageConfig.getNoWorldOther());
return false;
}
String worldname = dc.getWorldname();
SystemWorld sw = SystemWorld.getSystemWorld(worldname);
WorldDeleteEvent event = new WorldDeleteEvent(cs, sw);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
return false;
if (sw != null && sw.isLoaded())
sw.directUnload(Bukkit.getWorld(worldname));
WorldConfig config = WorldConfig.getWorldConfig(worldname);
// Delete unnecessary positions
PlayerPositions.instance.deletePositions(config);
Bukkit.getScheduler().runTaskLater(WorldSystem.getInstance(), () -> {
OfflinePlayer op = dc.getOwner();
String uuid = op.getUniqueId().toString();
File dir = new File(PluginConfig.getWorlddir() + "/" + worldname);
if (!dir.exists())
dir = new File(Bukkit.getWorldContainer(), worldname);
if (dir.exists())
try {
FileUtils.deleteDirectory(dir);
} catch (Exception e) {
cs.sendMessage(MessageConfig.getUnknownError());
e.printStackTrace();
}
File dconfig = new File("plugins//WorldSystem//dependence.yml");
YamlConfiguration cfg = YamlConfiguration.loadConfiguration(dconfig);
cfg.set("Dependences." + uuid + ".ID", null);
cfg.set("Dependences." + uuid + ".ActualName", null);
cfg.set("Dependences." + uuid, null);
try {
cfg.save(dconfig);
} catch (Exception e) {
cs.sendMessage(MessageConfig.getUnknownError());
e.printStackTrace();
}
cs.sendMessage(MessageConfig.getDeleteWorldOther().replaceAll("%player", op.getName()));
if (op.isOnline()) {
Player p1 = Bukkit.getPlayer(op.getUniqueId());
p1.sendMessage(MessageConfig.getDeleteWorldOwn());
}
}, 10);
return true;
}
public boolean addMemberCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
if (args.length < 2) {
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws addmember <Player>"));
return false;
}
DependenceConfig dc = new DependenceConfig(p);
if (!dc.hasWorld()) {
p.sendMessage(MessageConfig.getNoWorldOwn());
return false;
}
@SuppressWarnings("deprecation")
OfflinePlayer a = Bukkit.getOfflinePlayer(args[1]);
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
if (a == null) {
p.sendMessage(MessageConfig.getNotRegistered().replaceAll("%player", args[1]));
return false;
} else if (wc.isMember(a.getUniqueId())) {
p.sendMessage(MessageConfig.getAlreadyMember());
return false;
}
WorldAddmemberEvent event = new WorldAddmemberEvent(a.getUniqueId(), dc.getWorldname(), p);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
return false;
wc.addMember(a.getUniqueId());
try {
wc.save();
} catch (IOException e) {
p.sendMessage(MessageConfig.getUnknownError());
e.printStackTrace();
}
p.sendMessage(MessageConfig.getMemberAdded().replaceAll("%player", a.getName()));
return true;
} else {
sender.sendMessage("No Console"); //TODO Get Config
return false;
}
}
public boolean toggleTeleportCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
if (args.length < 2) {
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws toggletp <Player>"));
return false;
}
DependenceConfig dc = new DependenceConfig(p);
if (!dc.hasWorld()) {
p.sendMessage(MessageConfig.getNoWorldOwn());
return false;
}
@SuppressWarnings("deprecation")
OfflinePlayer a = Bukkit.getOfflinePlayer(args[1]);
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
if (!wc.isMember(a.getUniqueId())) {
p.sendMessage(MessageConfig.getNoMemberOwn());
return false;
}
WorldPlayer wp = new WorldPlayer(a, dc.getWorldname());
if (wp.isOwnerofWorld()) {
p.sendMessage(PluginConfig.getPrefix() + "§cYou are the owner");
return false;
}
if (wp.toggleTeleport()) {
p.sendMessage(MessageConfig.getToggleTeleportEnabled().replaceAll("%player", a.getName()));
} else {
p.sendMessage(MessageConfig.getToggleTeleportDisabled().replaceAll("%player", a.getName()));
}
return true;
} else {
sender.sendMessage("No Console"); //TODO Get Config
return false;
}
}
public boolean toggleGamemodeCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
if (args.length < 2) {
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws togglegm <Player>"));
return false;
}
DependenceConfig dc = new DependenceConfig(p);
if (!dc.hasWorld()) {
p.sendMessage(MessageConfig.getNoWorldOwn());
return false;
}
@SuppressWarnings("deprecation")
OfflinePlayer a = Bukkit.getOfflinePlayer(args[1]);
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
if (!wc.isMember(a.getUniqueId())) {
p.sendMessage(MessageConfig.getNoMemberOwn());
return false;
}
WorldPlayer wp = new WorldPlayer(a, dc.getWorldname());
if (wp.isOwnerofWorld()) {
p.sendMessage(PluginConfig.getPrefix() + "§cYou are the owner");
return false;
}
if (wp.toggleGamemode()) {
p.sendMessage(MessageConfig.getToggleGameModeEnabled().replaceAll("%player", a.getName()));
} else {
p.sendMessage(MessageConfig.getToggleGameModeDisabled().replaceAll("%player", a.getName()));
}
return true;
} else {
sender.sendMessage("No Console"); //TODO Get Config
return false;
}
}
public boolean toggleWorldeditCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
if (args.length < 2) {
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws togglewe <Player>"));
return false;
}
DependenceConfig dc = new DependenceConfig(p);
if (!dc.hasWorld()) {
p.sendMessage(MessageConfig.getNoWorldOwn());
return false;
}
@SuppressWarnings("deprecation")
OfflinePlayer a = Bukkit.getOfflinePlayer(args[1]);
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
if (!wc.isMember(a.getUniqueId())) {
p.sendMessage(MessageConfig.getNoMemberOwn());
return false;
}
WorldPlayer wp = new WorldPlayer(a, dc.getWorldname());
if (wp.isOwnerofWorld()) {
p.sendMessage(PluginConfig.getPrefix() + "§cYou are the owner");
return false;
}
if (wp.toggleWorldEdit()) {
p.sendMessage(MessageConfig.getToggleWorldeditEnabled().replaceAll("%player", a.getName()));
} else {
p.sendMessage(MessageConfig.getToggleWorldeditDisabled().replaceAll("%player", a.getName()));
}
return true;
} else {
sender.sendMessage("No Console"); //TODO Get Config
return false;
}
}
public boolean toggleBuildCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
if (args.length < 2) {
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", "/ws togglebuild <Player>"));
return false;
}
DependenceConfig dc = new DependenceConfig(p);
if (!dc.hasWorld()) {
p.sendMessage(MessageConfig.getNoWorldOwn());
return false;
}
@SuppressWarnings("deprecation")
OfflinePlayer a = Bukkit.getOfflinePlayer(args[1]);
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
if (!wc.isMember(a.getUniqueId())) {
p.sendMessage(MessageConfig.getNoMemberOwn());
return false;
}
WorldPlayer wp = new WorldPlayer(a, dc.getWorldname());
if (wp.isOwnerofWorld()) {
p.sendMessage(PluginConfig.getPrefix() + "§cYou are the owner");
return false;
}
if (wp.toggleBuild()) {
p.sendMessage(MessageConfig.getToggleBuildEnabled().replaceAll("%player", a.getName()));
} else {
p.sendMessage(MessageConfig.getToggleBuildDisabled().replaceAll("%player", a.getName()));
}
return true;
} else {
sender.sendMessage("No Console"); //TODO Get Config
return false;
}
}
}

View File

@ -1,241 +1,268 @@
package de.butzlabben.world.command;
import de.butzlabben.world.WorldSystem;
import de.butzlabben.world.config.DependenceConfig;
import de.butzlabben.world.config.MessageConfig;
import de.butzlabben.world.config.PluginConfig;
import de.butzlabben.world.config.WorldConfig;
import de.butzlabben.world.event.WorldResetEvent;
import de.butzlabben.world.event.WorldToggleFireEvent;
import de.butzlabben.world.event.WorldToggleTntEvent;
import de.butzlabben.world.gui.WorldChooseGUI;
import de.butzlabben.world.util.PlayerPositions;
import de.butzlabben.world.wrapper.SystemWorld;
import de.butzlabben.world.wrapper.WorldPlayer;
import de.butzlabben.world.wrapper.WorldTemplate;
import de.butzlabben.world.wrapper.WorldTemplateProvider;
import net.myplayplanet.commandframework.CommandArgs;
import net.myplayplanet.commandframework.api.Command;
import org.apache.commons.io.FileUtils;
import org.bukkit.Bukkit;
import org.bukkit.WorldCreator;
import org.bukkit.entity.Player;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
public class WorldSettingsCommands {
private final ArrayList<Player> toConfirm = new ArrayList<>();
@Command(name = "ws.reset", inGameOnly = true, usage = "/ws reset [confirm]")
public void resetCommand(CommandArgs args) {
Player p = args.getSender(Player.class);
DependenceConfig dc = new DependenceConfig(p);
String worldname = dc.getWorldname();
SystemWorld sw = SystemWorld.getSystemWorld(worldname);
if (!dc.hasWorld()) {
p.sendMessage(MessageConfig.getNoWorldOwn());
return;
}
if (args.length() > 0) {
if (args.getArgument(0).equalsIgnoreCase("confirm")) {
if (sw.isLoaded())
sw.directUnload(Bukkit.getWorld(worldname));
if (!toConfirm.contains(p)) {
p.sendMessage(MessageConfig.getNoRequestSend());
return;
}
WorldResetEvent event = new WorldResetEvent(p, sw);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
return;
if (sw.isLoaded()) {
p.sendMessage(MessageConfig.getWorldStillLoaded());
return;
}
WorldConfig config = WorldConfig.getWorldConfig(worldname);
// Delete positions to prevent suffocating and such stuff
PlayerPositions.getInstance().deletePositions(config);
File f = new File(PluginConfig.getWorlddir() + "/" + worldname);
if (!PluginConfig.isMultiChoose()) {
WorldTemplate template = WorldTemplateProvider.getInstance()
.getTemplate(PluginConfig.getDefaultWorldTemplate());
if (template != null)
createWorld(p, worldname, f, template, sw);
else {
p.sendMessage(PluginConfig.getPrefix() + "§cError in config at \"worldtemplates.default\"");
p.sendMessage(PluginConfig.getPrefix() + "§cPlease contact an administrator");
}
} else {
WorldChooseGUI.letChoose(p, (template) -> {
if (template != null)
createWorld(p, worldname, f, template, sw);
else {
p.sendMessage(PluginConfig.getPrefix() + "§cError in config at \"worldtemplates.default\"");
p.sendMessage(PluginConfig.getPrefix() + "§cPlease contact an administrator");
}
});
}
} else {
p.sendMessage(MessageConfig.getInvalidInput().replaceAll("input", args.getArgument(0)));
}
} else {
if (sw.isLoaded())
sw.directUnload(Bukkit.getWorld(worldname));
if (toConfirm.contains(p)) {
p.sendMessage(MessageConfig.getRequestAlreadySent());
return;
}
int time = PluginConfig.getRequestExpire();
p.sendMessage(MessageConfig.getConfirmRequest().replaceAll("%command", "/ws reset confirm"));
p.sendMessage(MessageConfig.getTimeUntilExpires().replaceAll("%time", String.valueOf(time)));
toConfirm.add(p);
Bukkit.getScheduler().runTaskLater(WorldSystem.getInstance(), () -> {
if (toConfirm.contains(p)) {
p.sendMessage(MessageConfig.getRequestExpired());
toConfirm.remove(p);
}
}, time * 20L);
}
}
@Command(name = "ws.sethome", inGameOnly = true, usage = "/ws sethome")
public void setHomeCommand(CommandArgs args) {
Player p = args.getSender(Player.class);
WorldPlayer wp = new WorldPlayer(p);
if (!wp.isOnSystemWorld()) {
p.sendMessage(MessageConfig.getNotOnWorld());
return;
}
if (!wp.isOwnerofWorld()) {
p.sendMessage(MessageConfig.getNoPermission());
return;
}
if (!p.hasPermission("ws.sethome")) {
p.sendMessage(MessageConfig.getNoPermission());
return;
}
WorldConfig config = WorldConfig.getWorldConfig(p.getWorld().getName());
config.setHome(p.getLocation());
try {
config.save();
p.sendMessage(MessageConfig.getHomeSet());
} catch (IOException e) {
p.sendMessage(MessageConfig.getUnknownError() + ": " + e.getMessage());
e.printStackTrace();
}
}
@Command(name = "ws.tnt", inGameOnly = true, usage = "/ws tnt")
public void tntCommand(CommandArgs args) {
Player p = args.getSender(Player.class);
DependenceConfig dc = new DependenceConfig(p);
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
boolean tnt = wc.isTnt();
WorldToggleTntEvent event = new WorldToggleTntEvent(p, SystemWorld.getSystemWorld(dc.getWorldname()), tnt);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
return;
wc.setTnt(p.getUniqueId(), !tnt);
try {
wc.save();
} catch (IOException e) {
p.sendMessage(PluginConfig.getPrefix() + "§cSomething went wrong");
e.printStackTrace();
}
tnt = wc.isTnt();
if (tnt) {
p.sendMessage(MessageConfig.getToggleTntEnabled());
} else {
p.sendMessage(MessageConfig.getToggleTntDisabled());
}
}
@Command(name = "ws.fire", inGameOnly = true, usage = "/ws fire")
public void fireCommand(CommandArgs args) {
Player p = args.getSender(Player.class);
DependenceConfig dc = new DependenceConfig(p);
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
boolean fire = wc.isFire();
WorldToggleFireEvent event = new WorldToggleFireEvent(p, SystemWorld.getSystemWorld(dc.getWorldname()), fire);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
return;
wc.setFire(p.getUniqueId(), !fire);
try {
wc.save();
} catch (IOException e) {
p.sendMessage(PluginConfig.getPrefix() + "§cSomething went wrong");
e.printStackTrace();
}
fire = wc.isFire();
if (fire) {
p.sendMessage(MessageConfig.getToggleFireEnabled());
} else {
p.sendMessage(MessageConfig.getToggleFireDisabled());
}
}
private void createWorld(Player p, String worldname, File f, WorldTemplate template, SystemWorld sw) {
if (f != null) {
File[] files = f.listFiles();
if (files != null) {
for (File file : files) {
if (file.getName().equals("worldconfig.yml"))
continue;
FileUtils.deleteQuietly(file);
}
}
}
try {
File templateDirectory = new File(template.getPath());
if (templateDirectory.isDirectory())
FileUtils.copyDirectory(templateDirectory, f);
toConfirm.remove(p);
FileUtils.moveDirectoryToDirectory(f, Bukkit.getWorldContainer(), false);
WorldConfig config = WorldConfig.getWorldConfig(worldname);
config.setHome(null);
config.setTemplateKey(template.getName());
config.save();
p.sendMessage(MessageConfig.getWorldReseted());
// For fast worldcreating after reset
WorldCreator creator = template.getGeneratorSettings().asWorldCreator(worldname);
sw.setCreating(true);
// For #16
WorldSystem.getInstance().getAdapter().create(creator, sw, () -> {
if (p != null && p.isOnline())
p.sendMessage(MessageConfig.getWorldCreated());
});
} catch (IOException e) {
e.printStackTrace();
p.sendMessage(MessageConfig.getUnknownError());
System.err.println("Couldn't reset world of " + p.getName());
}
}
}
package de.butzlabben.world.command.commands;
import de.butzlabben.world.WorldSystem;
import de.butzlabben.world.config.DependenceConfig;
import de.butzlabben.world.config.MessageConfig;
import de.butzlabben.world.config.PluginConfig;
import de.butzlabben.world.config.WorldConfig;
import de.butzlabben.world.event.WorldResetEvent;
import de.butzlabben.world.event.WorldToggleFireEvent;
import de.butzlabben.world.event.WorldToggleTntEvent;
import de.butzlabben.world.gui.WorldChooseGUI;
import de.butzlabben.world.util.PlayerPositions;
import de.butzlabben.world.wrapper.SystemWorld;
import de.butzlabben.world.wrapper.WorldPlayer;
import de.butzlabben.world.wrapper.WorldTemplate;
import de.butzlabben.world.wrapper.WorldTemplateProvider;
import org.apache.commons.io.FileUtils;
import org.bukkit.Bukkit;
import org.bukkit.WorldCreator;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
public class WorldSettingsCommands {
private static final ArrayList<Player> toConfirm = new ArrayList<>();
public boolean resetCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
DependenceConfig dc = new DependenceConfig(p);
String worldname = dc.getWorldname();
SystemWorld sw = SystemWorld.getSystemWorld(worldname);
if (!dc.hasWorld()) {
p.sendMessage(MessageConfig.getNoWorldOwn());
return false;
}
if (args.length > 1) {
if (args[1].equalsIgnoreCase("confirm")) {
if (sw.isLoaded())
sw.directUnload(Bukkit.getWorld(worldname));
if (!toConfirm.contains(p)) {
p.sendMessage(MessageConfig.getNoRequestSend());
return false;
}
WorldResetEvent event = new WorldResetEvent(p, sw);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
return false;
if (sw.isLoaded()) {
p.sendMessage(MessageConfig.getWorldStillLoaded());
return false;
}
WorldConfig config = WorldConfig.getWorldConfig(worldname);
// Delete positions to prevent suffocating and such stuff
PlayerPositions.instance.deletePositions(config);
File f = new File(PluginConfig.getWorlddir() + "/" + worldname);
if (!PluginConfig.isMultiChoose()) {
WorldTemplate template = WorldTemplateProvider.getInstance()
.getTemplate(PluginConfig.getDefaultWorldTemplate());
if (template != null)
createWorld(p, worldname, f, template, sw);
else {
p.sendMessage(PluginConfig.getPrefix() + "§cError in config at \"worldtemplates.default\"");
p.sendMessage(PluginConfig.getPrefix() + "§cPlease contact an administrator");
}
} else {
WorldChooseGUI.letChoose(p, (template) -> {
if (template != null)
createWorld(p, worldname, f, template, sw);
else {
p.sendMessage(PluginConfig.getPrefix() + "§cError in config at \"worldtemplates.default\"");
p.sendMessage(PluginConfig.getPrefix() + "§cPlease contact an administrator");
}
});
}
} else {
p.sendMessage(MessageConfig.getInvalidInput().replaceAll("input", args[1]));
}
} else {
if (sw.isLoaded())
sw.directUnload(Bukkit.getWorld(worldname));
if (toConfirm.contains(p)) {
p.sendMessage(MessageConfig.getRequestAlreadySent());
return false;
}
int time = PluginConfig.getRequestExpire();
p.sendMessage(MessageConfig.getConfirmRequest().replaceAll("%command", "/ws reset confirm"));
p.sendMessage(MessageConfig.getTimeUntilExpires().replaceAll("%time", String.valueOf(time)));
toConfirm.add(p);
Bukkit.getScheduler().runTaskLater(WorldSystem.getInstance(), () -> {
if (toConfirm.contains(p)) {
p.sendMessage(MessageConfig.getRequestExpired());
toConfirm.remove(p);
}
}, time * 20L);
}
return true;
} else {
sender.sendMessage("No Console"); //TODO Get Config
return false;
}
}
public boolean setHomeCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
WorldPlayer wp = new WorldPlayer(p);
if (!wp.isOnSystemWorld()) {
p.sendMessage(MessageConfig.getNotOnWorld());
return false;
}
if (!wp.isOwnerofWorld()) {
p.sendMessage(MessageConfig.getNoPermission());
return false;
}
if (!p.hasPermission("ws.sethome")) {
p.sendMessage(MessageConfig.getNoPermission());
return false;
}
WorldConfig config = WorldConfig.getWorldConfig(p.getWorld().getName());
config.setHome(p.getLocation());
try {
config.save();
p.sendMessage(MessageConfig.getHomeSet());
} catch (IOException e) {
p.sendMessage(MessageConfig.getUnknownError() + ": " + e.getMessage());
e.printStackTrace();
}
return true;
} else {
sender.sendMessage("No Console"); //TODO Get Config
return false;
}
}
public boolean tntCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
DependenceConfig dc = new DependenceConfig(p);
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
boolean tnt = wc.isTnt();
WorldToggleTntEvent event = new WorldToggleTntEvent(p, SystemWorld.getSystemWorld(dc.getWorldname()), tnt);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
return false;
wc.setTnt(p.getUniqueId(), !tnt);
try {
wc.save();
} catch (IOException e) {
p.sendMessage(PluginConfig.getPrefix() + "§cSomething went wrong");
e.printStackTrace();
}
tnt = wc.isTnt();
if (tnt) {
p.sendMessage(MessageConfig.getToggleTntEnabled());
} else {
p.sendMessage(MessageConfig.getToggleTntDisabled());
}
return true;
} else {
sender.sendMessage("No Console"); //TODO Get Config
return false;
}
}
public boolean fireCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
DependenceConfig dc = new DependenceConfig(p);
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
boolean fire = wc.isFire();
WorldToggleFireEvent event = new WorldToggleFireEvent(p, SystemWorld.getSystemWorld(dc.getWorldname()), fire);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
return false;
wc.setFire(p.getUniqueId(), !fire);
try {
wc.save();
} catch (IOException e) {
p.sendMessage(PluginConfig.getPrefix() + "§cSomething went wrong");
e.printStackTrace();
}
fire = wc.isFire();
if (fire) {
p.sendMessage(MessageConfig.getToggleFireEnabled());
} else {
p.sendMessage(MessageConfig.getToggleFireDisabled());
}
return true;
} else {
sender.sendMessage("No Console"); //TODO Get Config
return false;
}
}
private void createWorld(Player p, String worldname, File f, WorldTemplate template, SystemWorld sw) {
if (f != null) {
File[] files = f.listFiles();
if (files != null) {
for (File file : files) {
if (file.getName().equals("worldconfig.yml"))
continue;
FileUtils.deleteQuietly(file);
}
}
}
try {
File templateDirectory = new File(template.getPath());
if (templateDirectory.isDirectory())
FileUtils.copyDirectory(templateDirectory, f);
toConfirm.remove(p);
FileUtils.moveDirectoryToDirectory(f, Bukkit.getWorldContainer(), false);
WorldConfig config = WorldConfig.getWorldConfig(worldname);
config.setHome(null);
config.setTemplateKey(template.getName());
config.save();
p.sendMessage(MessageConfig.getWorldReseted());
// For fast worldcreating after reset
WorldCreator creator = template.generatorSettings.asWorldCreator(worldname);
sw.setCreating(true);
// For #16
WorldSystem.getInstance().getAdapter().create(creator, sw, () -> {
if (p != null && p.isOnline())
p.sendMessage(MessageConfig.getWorldCreated());
});
} catch (IOException e) {
e.printStackTrace();
p.sendMessage(MessageConfig.getUnknownError());
System.err.println("Couldn't reset world of " + p.getName());
}
}
}

View File

@ -159,7 +159,7 @@ public class PluginConfig {
public static Location getSpawn(Player player) {
YamlConfiguration cfg = getConfig();
Location location = getLocation(cfg, "spawn.spawnpoint", Bukkit.getWorld(cfg.getString("spawn.spawnpoint.world", "world")));
return PlayerPositions.getInstance().injectPlayersLocation(player, location);
return PlayerPositions.instance.injectPlayersLocation(player, location);
}
public static int getRequestExpire() {

View File

@ -21,9 +21,9 @@ Class for implementing #23
public class PlayerPositions {
@Getter
private static PlayerPositions instance = new PlayerPositions();
public static PlayerPositions instance = new PlayerPositions();
private final DatabaseUtil util = DatabaseProvider.getInstance().getUtil();
private final DatabaseUtil util = DatabaseProvider.instance.util;
private PlayerPositions() {

View File

@ -5,10 +5,10 @@ import lombok.Getter;
public class DatabaseProvider {
@Getter
private static DatabaseProvider instance = new DatabaseProvider();
public static DatabaseProvider instance = new DatabaseProvider();
@Getter
private final DatabaseUtil util;
public final DatabaseUtil util;
private DatabaseProvider() {
String dbType = PluginConfig.getDatabaseType();
@ -20,4 +20,4 @@ public class DatabaseProvider {
throw new IllegalArgumentException("Unknown database type: " + dbType);
}
}
}
}

View File

@ -96,7 +96,7 @@ public class SystemWorld {
String worldname = "ID" + id + "-" + uuid;
Player p = Bukkit.getPlayer(uniqueID);
WorldCreator creator = template.getGeneratorSettings().asWorldCreator(worldname);
WorldCreator creator = template.generatorSettings.asWorldCreator(worldname);
WorldCreateEvent event = new WorldCreateEvent(uniqueID, creator);
Bukkit.getPluginManager().callEvent(event);
@ -200,7 +200,7 @@ public class SystemWorld {
WorldConfig config = WorldConfig.getWorldConfig(worldname);
for (Player a : w.getPlayers()) {
PlayerPositions.getInstance().saveWorldsPlayerLocation(a, config);
PlayerPositions.instance.saveWorldsPlayerLocation(a, config);
a.teleport(PluginConfig.getSpawn(a));
a.setGameMode(PluginConfig.getSpawnGamemode());
}
@ -345,7 +345,7 @@ public class SystemWorld {
template = WorldTemplateProvider.getInstance().getTemplate(PluginConfig.getDefaultWorldTemplate());
if (template != null)
creator = template.getGeneratorSettings().asWorldCreator(worldname);
creator = template.generatorSettings.asWorldCreator(worldname);
World w = Bukkit.getWorld(worldname);
@ -393,7 +393,7 @@ public class SystemWorld {
public void teleportToWorldSpawn(Player p) {
Preconditions.checkNotNull(p, "player must not be null");
Preconditions.checkArgument(p.isOnline(), "player must be online");
PlayerPositions positions = PlayerPositions.getInstance();
PlayerPositions positions = PlayerPositions.instance;
if (creating) {
p.sendMessage(MessageConfig.getWorldStillCreating());

View File

@ -11,12 +11,12 @@ import lombok.Getter;
@Getter
public class WorldTemplate {
private final String name;
private final String permission;
private final OrcItem icon;
private final int slot;
private final int cost;
private final GeneratorSettings generatorSettings;
public final String name;
public final String permission;
public final OrcItem icon;
public final int slot;
public final int cost;
public final GeneratorSettings generatorSettings;
public WorldTemplate(String name, String permission, int cost, GeneratorSettings generatorSettings) {
this.name = name;

View File

@ -1,19 +1,10 @@
##########################################################################
### __ __ __ _______ __ ###
### \ \ / / / / / / ___/ / / ###
### \ \ __ / /___ ___/ /___/ / /____ ______/ /______________ ###
### \ \ / \ / / __ \/ _/ / __ /__ / / / / __/ __/ ___/ _ _ / ###
### \ \/ /\ \/ / /_/ / // / /_/ /__/ / /_/ /_ / /_/ ___/ // // / ###
### \__/ \__/\____/_//_/\__,_/____/\__, /___/\__/\___/_//_//_/ ###
### ___/ / ###
### \___/ ###
##########################################################################
# Path where the worlds will be saved
worldfolder: 'plugins/WorldSystem/Worlds'
worldtemplates:
# Wheter players can decide on different templates
# Whether players can decide on different templates
multi_choose: false
# If multi_choose is disabled, which template should be choosen
default: 'template_default'

View File

@ -1,74 +0,0 @@
name: WorldSystem
version: ${project.version}
author: Butzlabben
main: de.butzlabben.world.WorldSystem
api-version: 1.13
loadbefore: [FastAsyncWorldEdit, WorldEdit, BuildersUtilities]
permissions:
ws.*:
default: op
description: Gives '*'-Perms to all Commands
children:
ws.tp.*: true
ws.get: true
ws.sethome: true
ws.tp.world: true
ws.tp.toother: true
ws.tp.other: true
ws.build: true
ws.gamemode: true
ws.delete: true
ws.lag: true
ws.big: true
ws.large: true
ws.confirm: true
ws.sethome:
default: true
description: 'You can set a different worldspawn'
ws.tp.*:
default: op
description: You can teleport everything
children:
ws.tp.toother: true
ws.tp.other: true
ws.tp.world: true
ws.build:
default: op
description: You can build on other Worlds without WorldPermissions
ws.get:
default: true
description: You can create a world via /ws get
ws.delete:
default: op
description: You can delete a world
ws.gamemode:
default: op
description: You can change GameMode on other worlds
ws.tp.other:
default: op
description: You can teleport other persons
ws.tp.toother:
default: op
description: You can teleport across worlds
ws.tp.world:
default: op
description: You can teleport to without rights World
ws.lag:
default: op
description: You can see lag messages
ws.big:
default: op
description: Gives you a bigger world (if set)
ws.large:
default: op
children:
ws.big: true
description: Gives you a even bigger world (if set)
ws.confirm:
default: op
description: You can confirm (if needed) an auto-update
default-permission: admin

5306
yarn.lock Normal file

File diff suppressed because it is too large Load Diff