mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2026-11-28 08:44:07 +00:00
Compare commits
376
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8210536dad | ||
|
|
04309fba14 | ||
|
|
97ee43e434 | ||
|
|
6992e3a41a | ||
|
|
b69d4aa787 | ||
|
|
c7a1a4e069 | ||
|
|
1d4389188f | ||
|
|
ab9911605c | ||
|
|
6eca1c5c73 | ||
|
|
621f3a6876 | ||
|
|
bd45e4cb87 | ||
|
|
b878c992f9 | ||
|
|
aeeffc9e1b | ||
|
|
09ce7e79d2 | ||
|
|
e017aa83c6 | ||
|
|
ff79654444 | ||
|
|
c2a45e8b7b | ||
|
|
9f0801fda4 | ||
|
|
66fe5b9001 | ||
|
|
4697f06163 | ||
|
|
15fc3eba67 | ||
|
|
86b2e3508b | ||
|
|
1f16f943e8 | ||
|
|
3cf85f2ce6 | ||
|
|
a5400d18e5 | ||
|
|
f494297607 | ||
|
|
6e1bb098c9 | ||
|
|
ebd0bedb2d | ||
|
|
4c2dbae45a | ||
|
|
12125d258f | ||
|
|
35d5fac459 | ||
|
|
9f181605f1 | ||
|
|
9c21792669 | ||
|
|
c721cd7837 | ||
|
|
d18bd94b3a | ||
|
|
077c55723d | ||
|
|
2971c1a407 | ||
|
|
e6ccb3be55 | ||
|
|
9ab1648bfb | ||
|
|
9fbba3a149 | ||
|
|
f2b039b962 | ||
|
|
0afea8b3d5 | ||
|
|
37e4bb196f | ||
|
|
22179be62f | ||
|
|
d1822e6e2b | ||
|
|
ea8231e4e0 | ||
|
|
dbde32d48d | ||
|
|
57b4c0078c | ||
|
|
f634264a3f | ||
|
|
1b7d347f36 | ||
|
|
6cc8eb7d4c | ||
|
|
7923c3b223 | ||
|
|
4cc5fd0afc | ||
|
|
196c1a8d99 | ||
|
|
d79c4c4c90 | ||
|
|
a7d76704e0 | ||
|
|
d056634891 | ||
|
|
418ef2a717 | ||
|
|
2350b6aca2 | ||
|
|
b4dae7de00 | ||
|
|
044054d594 | ||
|
|
9042fbf6d1 | ||
|
|
c3602ee5e1 | ||
|
|
5678934b0e | ||
|
|
8dc2b721e7 | ||
|
|
c8d076c2af | ||
|
|
7fd8b6d172 | ||
|
|
8d88d78f17 | ||
|
|
57a3c3603c | ||
|
|
59f9283fef | ||
|
|
64525691a8 | ||
|
|
c2710459c8 | ||
|
|
ee87464451 | ||
|
|
1e3e57236f | ||
|
|
2b4367b058 | ||
|
|
0203c28e52 | ||
|
|
919e458477 | ||
|
|
f7e6665c42 | ||
|
|
82b2225f0e | ||
|
|
de09261461 | ||
|
|
1126518121 | ||
|
|
3b34dd7d90 | ||
|
|
54731925bd | ||
|
|
2fc17760ef | ||
|
|
de27b4e54d | ||
|
|
b6cfe1e1c4 | ||
|
|
ea8f998c83 | ||
|
|
faf6961267 | ||
|
|
954d1fab29 | ||
|
|
3870eed1b0 | ||
|
|
72c2248934 | ||
|
|
69bfc79790 | ||
|
|
671d422683 | ||
|
|
1e903e447b | ||
|
|
d454c21734 | ||
|
|
cfaa584a7d | ||
|
|
2fcc102ed4 | ||
|
|
8c4fb96cd3 | ||
|
|
47e5ebbdf5 | ||
|
|
011c9e96a0 | ||
|
|
b5e7154386 | ||
|
|
e5e511d8c3 | ||
|
|
7c666ca114 | ||
|
|
79c54203d3 | ||
|
|
c6ba480e04 | ||
|
|
07e10ae241 | ||
|
|
f7a65e21f1 | ||
|
|
df320eb0ce | ||
|
|
bcaca3cae6 | ||
|
|
a1c266ffca | ||
|
|
7332e7c237 | ||
|
|
4712ab6479 | ||
|
|
b933e7bd77 | ||
|
|
033eaeecdc | ||
|
|
5aad2125d3 | ||
|
|
f3a1dba7f5 | ||
|
|
afb45d23cb | ||
|
|
bc184d366e | ||
|
|
4483f35d0f | ||
|
|
fd6002526d | ||
|
|
32bc0d6e36 | ||
|
|
f47c8cee10 | ||
|
|
3dc0eea406 | ||
|
|
a1f480ca28 | ||
|
|
a94b7d3ce8 | ||
|
|
9c56ec17ea | ||
|
|
06453db90c | ||
|
|
c96691325b | ||
|
|
2b882d93c7 | ||
|
|
1c62a331f1 | ||
|
|
bfcfe4985a | ||
|
|
3f3cbcfddf | ||
|
|
f7e889bac3 | ||
|
|
1afde080aa | ||
|
|
0e2ec972b9 | ||
|
|
e20126a034 | ||
|
|
50fcfb598d | ||
|
|
c9d5644a8e | ||
|
|
34f616bd99 | ||
|
|
7f52c5a481 | ||
|
|
96c0999ba7 | ||
|
|
b8e9452ea6 | ||
|
|
3cb691a765 | ||
|
|
8e2002d294 | ||
|
|
593d8c80f3 | ||
|
|
96639b8d22 | ||
|
|
33a25bccab | ||
|
|
865a6cead9 | ||
|
|
ba5c0a4717 | ||
|
|
e22924be1f | ||
|
|
d3d36e393e | ||
|
|
4551c61b68 | ||
|
|
0463422a13 | ||
|
|
55eae3814e | ||
|
|
d5a0a73991 | ||
|
|
64161b7b72 | ||
|
|
69f38d524d | ||
|
|
2f1ea6556b | ||
|
|
831f5d29da | ||
|
|
d3a9da2f76 | ||
|
|
84b8d0f5fe | ||
|
|
f0786c123a | ||
|
|
a0d4b2bdd9 | ||
|
|
abb41c54df | ||
|
|
8976e2b0c9 | ||
|
|
d6dac94e9a | ||
|
|
7ddfb2c2c3 | ||
|
|
8a0b8f60ae | ||
|
|
cc73a9320c | ||
|
|
ab43f7aaac | ||
|
|
55182607bd | ||
|
|
61d7e335d9 | ||
|
|
d460a6a510 | ||
|
|
7b15fe386a | ||
|
|
e1ac5206c5 | ||
|
|
83cc8e4124 | ||
|
|
23343a01d0 | ||
|
|
2993b595db | ||
|
|
277765e5eb | ||
|
|
f0cfab4610 | ||
|
|
e0643a4359 | ||
|
|
1ddd053cbd | ||
|
|
133b27ed06 | ||
|
|
901ca13501 | ||
|
|
7513010ec5 | ||
|
|
7c6f3a05d7 | ||
|
|
637aecb100 | ||
|
|
6381bf5108 | ||
|
|
5ebee9590b | ||
|
|
201f645c43 | ||
|
|
db0d64e404 | ||
|
|
7f6afdfd7a | ||
|
|
4d4f6b2d86 | ||
|
|
e1c7f32945 | ||
|
|
3fe5c25e7b | ||
|
|
d8129df29b | ||
|
|
c04e8c0e7d | ||
|
|
6673e279fc | ||
|
|
852d25a619 | ||
|
|
ed4b0ea492 | ||
|
|
098925d61a | ||
|
|
158b89cb20 | ||
|
|
db52a21b7f | ||
|
|
6700e0bb3f | ||
|
|
c91226266d | ||
|
|
8fc4824190 | ||
|
|
91ef3ff3c8 | ||
|
|
7c46c8c31f | ||
|
|
92b244e9d1 | ||
|
|
300f97b522 | ||
|
|
a218104e56 | ||
|
|
b56696cb1b | ||
|
|
934b246615 | ||
|
|
303fba912d | ||
|
|
870b60b245 | ||
|
|
bd07536c0c | ||
|
|
bdece2c552 | ||
|
|
c5d4997cf4 | ||
|
|
f819bd782e | ||
|
|
45601b4a34 | ||
|
|
cbae1a2619 | ||
|
|
90592d0894 | ||
|
|
f77a8c4d7b | ||
|
|
64644bea3b | ||
|
|
91720236b1 | ||
|
|
3aad8a408b | ||
|
|
529b7a4dbe | ||
|
|
d9c3f32051 | ||
|
|
1ef7fe8959 | ||
|
|
22eff44288 | ||
|
|
ba99c7957b | ||
|
|
1ec31563d8 | ||
|
|
66701c490f | ||
|
|
23cca0311c | ||
|
|
39cbe97e0e | ||
|
|
9c27e30c10 | ||
|
|
f0c219c52e | ||
|
|
9576a25af2 | ||
|
|
8daabe9b93 | ||
|
|
80d7070f65 | ||
|
|
3160442991 | ||
|
|
f1bf706a35 | ||
|
|
fdfe7639ee | ||
|
|
d3bb025068 | ||
|
|
7f388e6c6b | ||
|
|
141e857ed8 | ||
|
|
86bf26535e | ||
|
|
9499d36482 | ||
|
|
bba7e70e8c | ||
|
|
1c61ac9d60 | ||
|
|
3cb9f28fdc | ||
|
|
e6d5802bba | ||
|
|
db14e688b9 | ||
|
|
3bacb95f09 | ||
|
|
cd0d6c733d | ||
|
|
33fd6270c1 | ||
|
|
3c564a501f | ||
|
|
df3b326031 | ||
|
|
5f43375755 | ||
|
|
18febd2da1 | ||
|
|
a923d63d34 | ||
|
|
3a4ddf6818 | ||
|
|
2739fb633c | ||
|
|
e7cf494107 | ||
|
|
646441ab75 | ||
|
|
b6e42c1277 | ||
|
|
e31194c5b3 | ||
|
|
b1ab2021a3 | ||
|
|
c0886fd04e | ||
|
|
b2d937835a | ||
|
|
bec400943a | ||
|
|
4ea6869abb | ||
|
|
ed0d5f589b | ||
|
|
6d8abaf420 | ||
|
|
a6c88e1c00 | ||
|
|
5b5d18f2fe | ||
|
|
7ecf1cd1a9 | ||
|
|
f52adfddbf | ||
|
|
2da1210578 | ||
|
|
123569adbb | ||
|
|
d3d9867d9f | ||
|
|
e53ed64614 | ||
|
|
310116f360 | ||
|
|
0c78e3df6f | ||
|
|
18c0190209 | ||
|
|
587c27dc5f | ||
|
|
d7a3bf8e49 | ||
|
|
993480df38 | ||
|
|
c0846e5413 | ||
|
|
563baee57e | ||
|
|
a18c71f27b | ||
|
|
538bfa95ce | ||
|
|
253fa73100 | ||
|
|
536218ebe1 | ||
|
|
2f218707a5 | ||
|
|
17a574866b | ||
|
|
49d6e4876f | ||
|
|
cce9608a59 | ||
|
|
bc30bf1085 | ||
|
|
ea84c94282 | ||
|
|
67c93efe91 | ||
|
|
d8bd216294 | ||
|
|
c03682b06d | ||
|
|
3a357379bf | ||
|
|
9e0afd5849 | ||
|
|
d5f5f5409c | ||
|
|
49578176fe | ||
|
|
713ce65db6 | ||
|
|
231ab44da4 | ||
|
|
9b3d16faab | ||
|
|
406d6b1316 | ||
|
|
5ce3a43d87 | ||
|
|
462b2fa6be | ||
|
|
212b000a35 | ||
|
|
605ad66f2d | ||
|
|
27fc53e780 | ||
|
|
9dc7605d40 | ||
|
|
628dd55b43 | ||
|
|
4682c50080 | ||
|
|
37c411b2b0 | ||
|
|
60607b11b3 | ||
|
|
90c02ed1fd | ||
|
|
7d018b748f | ||
|
|
67cca730c4 | ||
|
|
be3c7cadb8 | ||
|
|
08607beef4 | ||
|
|
b7b408e3d8 | ||
|
|
bd826e2898 | ||
|
|
d92ee9bcff | ||
|
|
54982cd850 | ||
|
|
9ef95e5d78 | ||
|
|
dbdf7d6a60 | ||
|
|
c41b3bd2c0 | ||
|
|
3d4ce28947 | ||
|
|
36dbe9d49d | ||
|
|
4e62c743cb | ||
|
|
e6e32c7621 | ||
|
|
54482d897f | ||
|
|
169b3940e4 | ||
|
|
ea1fa435dd | ||
|
|
7b2871f17d | ||
|
|
5f43ba5590 | ||
|
|
b7d389db01 | ||
|
|
34d4a22f19 | ||
|
|
581510e187 | ||
|
|
3f06fec1a8 | ||
|
|
e8ba929b04 | ||
|
|
ffd5d3e921 | ||
|
|
2fc9c7e94a | ||
|
|
1f2a4b5b01 | ||
|
|
c5d7705d54 | ||
|
|
c8a00751fa | ||
|
|
82cba7cef6 | ||
|
|
afcb76bfd7 | ||
|
|
60458c35f9 | ||
|
|
18f4ebb40e | ||
|
|
020fa52898 | ||
|
|
f9ab7da980 | ||
|
|
14c276cefb | ||
|
|
211d3609d4 | ||
|
|
77a94812d5 | ||
|
|
a1cc310c74 | ||
|
|
34d3b656a1 | ||
|
|
d2c9b14d75 | ||
|
|
e720f5e600 | ||
|
|
fd1c7c5c14 | ||
|
|
3b8b7b0b38 | ||
|
|
951887913c | ||
|
|
b8c6933dad | ||
|
|
88e6c1f85b | ||
|
|
3bea7167a7 | ||
|
|
375ade83b3 | ||
|
|
5a497dfc9e | ||
|
|
fe12cb802b | ||
|
|
2ffe2b5cb3 | ||
|
|
b394f37f93 |
No files matched your search
@@ -0,0 +1,54 @@
|
|||||||
|
#name: Create Release
|
||||||
|
#
|
||||||
|
#on:
|
||||||
|
# push:
|
||||||
|
# tags:
|
||||||
|
# - '[0-9]+.[0-9]+.[0-9]+*'
|
||||||
|
#
|
||||||
|
#jobs:
|
||||||
|
# build-and-release:
|
||||||
|
# runs-on: ubuntu-latest
|
||||||
|
#
|
||||||
|
# steps:
|
||||||
|
# - name: Checkout code
|
||||||
|
# uses: actions/checkout@v2
|
||||||
|
#
|
||||||
|
# - name: Set up JDK
|
||||||
|
# uses: actions/setup-java@v2
|
||||||
|
# with:
|
||||||
|
# distribution: 'adopt'
|
||||||
|
# java-version: '11'
|
||||||
|
#
|
||||||
|
# - name: Extract artifact ID and version from pom.xml
|
||||||
|
# run: |
|
||||||
|
# ARTIFACT_ID=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.artifactId}' --non-recursive exec:exec)
|
||||||
|
# VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
|
||||||
|
# echo "ARTIFACT_ID=$ARTIFACT_ID" >> $GITHUB_ENV
|
||||||
|
# echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||||
|
#
|
||||||
|
# - name: Build with Maven
|
||||||
|
# run: mvn clean install --settings settings.xml --batch-mode -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true
|
||||||
|
#
|
||||||
|
# - name: Create GitHub Release
|
||||||
|
# id: create_release
|
||||||
|
# uses: actions/create-release@v1
|
||||||
|
# env:
|
||||||
|
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
# with:
|
||||||
|
# tag_name: ${{ github.ref }}
|
||||||
|
# release_name: Release ${{ github.ref }}
|
||||||
|
# body: |
|
||||||
|
# Changes in this Release
|
||||||
|
# - Add a summary of changes or refer to the changelog.
|
||||||
|
# draft: false
|
||||||
|
# prerelease: false
|
||||||
|
#
|
||||||
|
# - name: Upload JAR Artifact to Release
|
||||||
|
# uses: actions/upload-release-asset@v1
|
||||||
|
# env:
|
||||||
|
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
# with:
|
||||||
|
# upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
# asset_path: ./target/${{ env.ARTIFACT_ID }}-${{ env.VERSION }}.jar
|
||||||
|
# asset_name: ${{ env.ARTIFACT_ID }}-${{ env.VERSION }}.jar
|
||||||
|
# asset_content_type: application/java-archive
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
name: Publish editor schema
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
if: '!github.event.release.prerelease'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.release.tag_name }}
|
||||||
|
persist-credentials: false
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '22'
|
||||||
|
- name: Prepare plugin-owned schemas
|
||||||
|
env:
|
||||||
|
SCHEMA_PATHS: BetterRTP-Core/src/main/resources/META-INF/editor-schema.json BetterRTPAddons/src/main/resources/META-INF/editor-schema.json
|
||||||
|
run: |
|
||||||
|
node --input-type=module <<'JS'
|
||||||
|
import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
||||||
|
mkdirSync('editor-schemas');
|
||||||
|
for (const path of process.env.SCHEMA_PATHS.split(' ')) {
|
||||||
|
const bytes = readFileSync(path), meta = JSON.parse(bytes)['x-bettersync'];
|
||||||
|
if (meta?.format !== 1 || !/^[a-z0-9-]+$/.test(meta.plugin) || !/^[A-Za-z0-9._-]+$/.test(meta.schemaVersion)) throw new Error('Invalid schema identity');
|
||||||
|
writeFileSync(`editor-schemas/${meta.plugin}-${meta.schemaVersion}.schema.json`, bytes);
|
||||||
|
}
|
||||||
|
JS
|
||||||
|
- name: Attach schemas to this plugin release
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
GH_REPO: ${{ github.repository }}
|
||||||
|
RELEASE_TAG: ${{ github.event.release.tag_name }}
|
||||||
|
run: gh release upload "$RELEASE_TAG" editor-schemas/*.schema.json
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
name: Release BetterRTP Maven version
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [online-editor]
|
||||||
|
workflow_dispatch:
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
concurrency:
|
||||||
|
group: release-maven-version
|
||||||
|
cancel-in-progress: false
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
if: github.ref == 'refs/heads/online-editor'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
persist-credentials: false
|
||||||
|
- uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: temurin
|
||||||
|
java-version: '17'
|
||||||
|
cache: maven
|
||||||
|
- name: Read BetterRTP Maven version
|
||||||
|
id: version
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mvn -B -q -f BetterRTP-Core/pom.xml help:evaluate -Dexpression=project.version -Doutput="$RUNNER_TEMP/version-0"
|
||||||
|
version0=$(cat "$RUNNER_TEMP/version-0")
|
||||||
|
[[ "$version0" =~ ^[0-9][A-Za-z0-9._-]*$ ]] || { echo "Invalid Maven version"; exit 1; }
|
||||||
|
[[ "$version0" != *SNAPSHOT* ]] || { echo "Snapshot versions are not released"; exit 1; }
|
||||||
|
echo "version0=$version0" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "tag=v$version0" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "title=BetterRTP $version0" >> "$GITHUB_OUTPUT"
|
||||||
|
- name: Check for an existing release
|
||||||
|
id: existing
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
GH_REPO: ${{ github.repository }}
|
||||||
|
RELEASE_TAG: ${{ steps.version.outputs.tag }}
|
||||||
|
run: |
|
||||||
|
# Listing errors fail the workflow; they are not mistaken for an absent release.
|
||||||
|
releases=$(gh api --paginate "repos/$GH_REPO/releases?per_page=100" --jq '.[].tag_name')
|
||||||
|
if printf '%s\n' "$releases" | grep -Fxq "$RELEASE_TAG"; then
|
||||||
|
echo "exists=true" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "Release $RELEASE_TAG already exists; bump the Maven version for another release."
|
||||||
|
fi
|
||||||
|
- name: Build and test
|
||||||
|
if: steps.existing.outputs.exists != 'true'
|
||||||
|
run: |
|
||||||
|
mvn -B -pl :BetterRTP clean verify
|
||||||
|
mvn -B -f tests/editor/pom.xml verify
|
||||||
|
- name: Prepare BetterRTP JAR and editor schemas
|
||||||
|
if: steps.existing.outputs.exists != 'true'
|
||||||
|
env:
|
||||||
|
# The website still needs Addons field metadata; this does not build its JAR.
|
||||||
|
SCHEMA_PATHS: BetterRTP-Core/src/main/resources/META-INF/editor-schema.json BetterRTPAddons/src/main/resources/META-INF/editor-schema.json
|
||||||
|
run: |
|
||||||
|
mkdir release-assets
|
||||||
|
cp "dist/BetterRTP-${{ steps.version.outputs.version0 }}.jar" release-assets/
|
||||||
|
python3 - <<'PYTHON'
|
||||||
|
import json, os, pathlib, re
|
||||||
|
for path in os.environ['SCHEMA_PATHS'].split():
|
||||||
|
data = pathlib.Path(path).read_bytes()
|
||||||
|
meta = json.loads(data)['x-bettersync']
|
||||||
|
if meta['format'] != 1 or not re.fullmatch(r'[a-z0-9-]+', meta['plugin']) or not re.fullmatch(r'[A-Za-z0-9._-]+', meta['schemaVersion']):
|
||||||
|
raise ValueError('Invalid schema identity')
|
||||||
|
pathlib.Path('release-assets', f"{meta['plugin']}-{meta['schemaVersion']}.schema.json").write_bytes(data)
|
||||||
|
PYTHON
|
||||||
|
- name: Publish versioned release
|
||||||
|
if: steps.existing.outputs.exists != 'true'
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
GH_REPO: ${{ github.repository }}
|
||||||
|
RELEASE_TAG: ${{ steps.version.outputs.tag }}
|
||||||
|
RELEASE_TITLE: ${{ steps.version.outputs.title }}
|
||||||
|
run: |
|
||||||
|
gh release create "$RELEASE_TAG" release-assets/* \
|
||||||
|
--target "$GITHUB_SHA" --title "$RELEASE_TITLE" --generate-notes --latest
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
name: Maven Tests
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up JDK 17
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 17
|
||||||
|
|
||||||
|
- name: Configure Maven settings
|
||||||
|
run: cp settings.xml $HOME/.m2/settings.xml
|
||||||
|
|
||||||
|
- name: Build and test with Maven
|
||||||
|
run: mvn -B -pl :BetterRTP test
|
||||||
@@ -8,3 +8,7 @@ target
|
|||||||
*.iml
|
*.iml
|
||||||
BetterRTP.wiki/
|
BetterRTP.wiki/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.vscode/
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
/dist/
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true
|
||||||
@@ -0,0 +1,434 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
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>me.SuperRonanCraft</groupId>
|
||||||
|
<artifactId>BetterRTP</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<version>3.6.14</version>
|
||||||
|
|
||||||
|
<!-- Upload patches to https://repo.ronanplugins.com/#/ -->
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<bettersync.version>2.0.0</bettersync.version>
|
||||||
|
<maven.compiler.release>8</maven.compiler.release>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<editor.website>https://www.minecentral.net</editor.website>
|
||||||
|
<editor.buildSuffix></editor.buildSuffix>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>dev</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<!-- Local Server Building -->
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>3.4.2</version>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.basedir}/../../../Java/plugins</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
<finalName>${project.artifactId}-${project.version}${editor.buildSuffix}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>3.4.2</version>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.basedir}/../dist</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-install-plugin</artifactId>
|
||||||
|
<version>3.1.4</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<!-- Shade PaperLib into project -->
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.6.0</version>
|
||||||
|
<configuration>
|
||||||
|
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml
|
||||||
|
</dependencyReducedPomLocation>
|
||||||
|
<relocations>
|
||||||
|
<relocation><pattern>com.ronanplugins.bettersync</pattern><shadedPattern>me.SuperRonanCraft.BetterRTP.lib.bettersync</shadedPattern></relocation>
|
||||||
|
|
||||||
|
<relocation>
|
||||||
|
<pattern>io.papermc.lib</pattern>
|
||||||
|
<shadedPattern>me.SuperRonanCraft.BetterRTP.lib.paperlib</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>com.tcoded.folialib</pattern>
|
||||||
|
<shadedPattern>me.SuperRonanCraft.BetterRTP.lib.folialib</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
</relocations>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.14.0</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<!-- Remove only Shade's unbundled backup, after the final JAR is ready. -->
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-clean-plugin</artifactId>
|
||||||
|
<version>3.5.0</version>
|
||||||
|
<configuration>
|
||||||
|
<filesets>
|
||||||
|
<fileset>
|
||||||
|
<directory>${project.basedir}/../dist</directory>
|
||||||
|
<includes>
|
||||||
|
<include>${project.artifactId}-*.jar</include>
|
||||||
|
<include>original-${project.artifactId}-*.jar</include>
|
||||||
|
</includes>
|
||||||
|
<followSymlinks>false</followSymlinks>
|
||||||
|
</fileset>
|
||||||
|
</filesets>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>remove-unshaded-backup</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals><goal>clean</goal></goals>
|
||||||
|
<configuration>
|
||||||
|
<excludeDefaultDirectories>true</excludeDefaultDirectories>
|
||||||
|
<filesets combine.self="override">
|
||||||
|
<fileset>
|
||||||
|
<directory>${project.basedir}/../dist</directory>
|
||||||
|
<includes><include>original-${project.build.finalName}.jar</include></includes>
|
||||||
|
<followSymlinks>false</followSymlinks>
|
||||||
|
</fileset>
|
||||||
|
</filesets>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<!-- CAN BE UNCOMMENTED IF YOU HAVE ACCESS TO THE REPO -->
|
||||||
|
<!--<repository>
|
||||||
|
<id>ronanplugins-private</id>
|
||||||
|
<name>RonanPlugins Repository</name>
|
||||||
|
<url>https://repo.ronanplugins.com/private</url>
|
||||||
|
</repository>-->
|
||||||
|
<!-- GitHub based Repos -->
|
||||||
|
<repository>
|
||||||
|
<id>jitpack.io</id>
|
||||||
|
<url>https://jitpack.io</url>
|
||||||
|
</repository>
|
||||||
|
<!-- FoliaLib Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>tcoded-releases</id>
|
||||||
|
<url>https://repo.tcoded.com/releases</url>
|
||||||
|
</repository>
|
||||||
|
<!-- Spigot Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>spigot-repo</id>
|
||||||
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
|
</repository>
|
||||||
|
<!-- PaperMC Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>papermc</id>
|
||||||
|
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
|
<!-- Vault Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>vault-repo</id>
|
||||||
|
<url>https://nexus.hc.to/content/repositories/pub_releases</url>
|
||||||
|
</repository>
|
||||||
|
<!-- WorldGuard Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>sk89q-repo</id>
|
||||||
|
<url>https://maven.enginehub.org/repo/</url>
|
||||||
|
</repository>
|
||||||
|
<!-- ProjectRed Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>redprotect-repo</id>
|
||||||
|
<url>https://raw.githubusercontent.com/FabioZumbi12/RedProtect/mvn-repo/</url>
|
||||||
|
</repository>
|
||||||
|
<!-- FactionsUUID Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>factions-uuid</id>
|
||||||
|
<url>https://ci.ender.zone/plugin/repository/everything/</url>
|
||||||
|
</repository>
|
||||||
|
<!-- ProtocolLib Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>dmulloy2-repo</id>
|
||||||
|
<url>https://repo.dmulloy2.net/nexus/repository/public/</url>
|
||||||
|
</repository>
|
||||||
|
<!-- EssentialsX Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>essentials-releases</id>
|
||||||
|
<url>https://repo.essentialsx.net/releases/</url>
|
||||||
|
</repository>
|
||||||
|
<!-- PlaceholderAPI Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>placeholderapi</id>
|
||||||
|
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||||
|
</repository>
|
||||||
|
<!-- MinePlots Repo -->
|
||||||
|
<repository>
|
||||||
|
<id>minecodes-repository-releases</id>
|
||||||
|
<name>mineCodes Organization Repository</name>
|
||||||
|
<url>https://repository.minecodes.pl/releases</url>
|
||||||
|
</repository>
|
||||||
|
<!-- Used by Husk plugins -->
|
||||||
|
<repository>
|
||||||
|
<id>william278-releases</id>
|
||||||
|
<url>https://repo.william278.net/releases</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId><artifactId>junit</artifactId><version>4.13.2</version><scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Download the tagged GitHub library through JitPack; bundled by Shade. -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.RonanPlugins</groupId>
|
||||||
|
<artifactId>BetterSync</artifactId>
|
||||||
|
<version>${bettersync.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!--Spigot API-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>1.8.8-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Spigot Stuff -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot</artifactId>
|
||||||
|
<version>1.8.8-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Vault -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.milkbowl.vault</groupId>
|
||||||
|
<artifactId>VaultAPI</artifactId>
|
||||||
|
<version>1.7</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Paper Library for Async Chunk/Teleport -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.papermc</groupId>
|
||||||
|
<artifactId>paperlib</artifactId>
|
||||||
|
<version>1.0.8</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- WorldGuard (https://dev.bukkit.org/projects/worldguard) -->
|
||||||
|
<dependency> <!-- Saber Factions screws up if updated -->
|
||||||
|
<groupId>com.sk89q.worldguard</groupId>
|
||||||
|
<artifactId>worldguard-bukkit</artifactId>
|
||||||
|
<version>7.0.3</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- RedProtect (https://www.spigotmc.org/resources/redprotect.15841/) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>br.net.fabiozumbi12.RedProtect</groupId>
|
||||||
|
<artifactId>RedProtect-Core</artifactId>
|
||||||
|
<version>7.7.3</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>br.net.fabiozumbi12.RedProtect</groupId>
|
||||||
|
<artifactId>RedProtect-Spigot-1.13</artifactId>
|
||||||
|
<version>7.7.3</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- FactionsUUID (https://www.spigotmc.org/resources/factionsuuid.1035/) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.massivecraft</groupId>
|
||||||
|
<artifactId>Factions</artifactId>
|
||||||
|
<version>1.6.9.5-U0.6.8</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Lands (https://www.spigotmc.org/resources/lands.53313/) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.angeschossen</groupId>
|
||||||
|
<artifactId>LandsAPI</artifactId>
|
||||||
|
<version>6.28.11</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- ProtocolLib -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.comphenix.protocol</groupId>
|
||||||
|
<artifactId>ProtocolLib</artifactId>
|
||||||
|
<version>5.3.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Towny (https://www.spigotmc.org/resources/towny.72694/) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.TownyAdvanced</groupId>
|
||||||
|
<artifactId>Towny</artifactId>
|
||||||
|
<version>0.98.6.6</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- GriefPrevention (https://www.spigotmc.org/resources/griefprevention.1884/) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.TechFortress</groupId>
|
||||||
|
<artifactId>GriefPrevention</artifactId>
|
||||||
|
<version>17.0.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- KingdomsX (https://www.spigotmc.org/resources/kingdomsx.77670/) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.cryptomorin</groupId>
|
||||||
|
<artifactId>kingdoms</artifactId>
|
||||||
|
<version>1.16.8.1.1</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>*</groupId>
|
||||||
|
<artifactId>*</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<!-- GriefDefender (https://www.spigotmc.org/resources/griefdefender.68900/) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.bloodmc</groupId>
|
||||||
|
<artifactId>GriefDefenderApi</artifactId>
|
||||||
|
<version>920a610</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Peublos (https://www.spigotmc.org/resources/pueblos.91255/) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.SuperRonanCraft</groupId>
|
||||||
|
<artifactId>Pueblos</artifactId>
|
||||||
|
<version>97b96c9</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Particles Library
|
||||||
|
https://github.com/ByteZ1337/ParticleLib
|
||||||
|
(https://github.com/ByteZ1337/ParticleLib/blob/master/src/main/java/xyz/xenondevs/particle/ParticleEffect.java) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>xyz.xenondevs</groupId>
|
||||||
|
<artifactId>particle</artifactId>
|
||||||
|
<version>1.8.4</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Lombok Support (@Getter & @Setter)-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.38</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- EssentialsX -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.essentialsx</groupId>
|
||||||
|
<artifactId>EssentialsX</artifactId>
|
||||||
|
<version>2.21.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.bstats</groupId>
|
||||||
|
<artifactId>bstats-bukkit</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<!-- Saber Factions (https://www.spigotmc.org/resources/saberfactions.69771/) (Added in 3.4.5)-->
|
||||||
|
<dependency> <!-- WorldGuard screws up if updated -->
|
||||||
|
<groupId>com.github.SaberLLC</groupId>
|
||||||
|
<artifactId>Saber-Factions</artifactId>
|
||||||
|
<version>2.4.0-RC</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.sk89q.worldguard</groupId>
|
||||||
|
<artifactId>worldguard-bukkit</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<!-- PlaceholderAPI Support (Added in 3.4.5)-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.clip</groupId>
|
||||||
|
<artifactId>placeholderapi</artifactId>
|
||||||
|
<version>2.11.6</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- HuskClaims (https://www.spigotmc.org/resources/huskclaims.114467/) (Added in 3.6.13)-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.william278.huskclaims</groupId>
|
||||||
|
<artifactId>huskclaims-bukkit</artifactId>
|
||||||
|
<version>1.5.10</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Husktown (https://www.spigotmc.org/resources/husktowns.92672/) (Added in 3.4.5)-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.william278.husktowns</groupId>
|
||||||
|
<artifactId>husktowns-bukkit</artifactId>
|
||||||
|
<version>3.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- MinePlots (https://builtbybit.com/resources/mineplots.21646/) (Added in 3.6.6 ) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>pl.minecodes.plots</groupId>
|
||||||
|
<artifactId>plugin-api</artifactId>
|
||||||
|
<version>3.4.5</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- FoliaLib -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.tcoded</groupId>
|
||||||
|
<artifactId>FoliaLib</artifactId>
|
||||||
|
<version>0.5.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- FactionsBridge -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.dansplugins.factionsystem</groupId>
|
||||||
|
<artifactId>FactionsBridge</artifactId>
|
||||||
|
<version>1.3.8</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${project.basedir}/../lib/FactionsBridge-1.3.8.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.WhipDevelopment</groupId>
|
||||||
|
<artifactId>CrashClaim</artifactId>
|
||||||
|
<version>c697d3e9ef</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.bekvon.bukkit.residence</groupId>
|
||||||
|
<artifactId>Residence</artifactId>
|
||||||
|
<version>5.1.4.1</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
<systemPath>${project.basedir}/../lib/Residence5.1.4.1.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP;
|
||||||
|
|
||||||
|
import com.ronanplugins.bettersync.editor.EditorClient;
|
||||||
|
import com.ronanplugins.bettersync.editor.EditorSchema;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.PlayerInfo;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.Commands;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.events.EventListener;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.Permissions;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.RTPLogger;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.WarningHandler;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.database.DatabaseHandler;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.depends.DepEconomy;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.depends.DepPlaceholderAPI;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.file.Files;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.RTPInventories;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.Message_RTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesCore;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.player.playerdata.PlayerDataManager;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.CooldownHandler;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.QueueHandler;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.settings.Settings;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.web.Metrics;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.web.Updater;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.versions.FoliaHandler;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class BetterRTP extends JavaPlugin {
|
||||||
|
@Getter private final Permissions perms = new Permissions();
|
||||||
|
@Getter private final DepEconomy eco = new DepEconomy();
|
||||||
|
@Getter private final Commands cmd = new Commands(this);
|
||||||
|
@Getter private final RTP RTP = new RTP();
|
||||||
|
private final EventListener listener = new EventListener();
|
||||||
|
@Getter private static BetterRTP instance;
|
||||||
|
@Getter private final Files files = new Files();
|
||||||
|
@Getter private final RTPInventories invs = new RTPInventories();
|
||||||
|
@Getter private final PlayerInfo pInfo = new PlayerInfo();
|
||||||
|
@Getter private final PlayerDataManager playerDataManager = new PlayerDataManager();
|
||||||
|
@Getter private final Settings settings = new Settings();
|
||||||
|
@Getter private final CooldownHandler cooldowns = new CooldownHandler();
|
||||||
|
@Getter private final QueueHandler queue = new QueueHandler();
|
||||||
|
@Getter private final DatabaseHandler databaseHandler = new DatabaseHandler();
|
||||||
|
@Getter private final WarningHandler warningHandler = new WarningHandler();
|
||||||
|
@Getter private boolean PlaceholderAPI;
|
||||||
|
@Getter private final RTPLogger rtpLogger = new RTPLogger();
|
||||||
|
@Getter private final FoliaHandler foliaHandler = new FoliaHandler();
|
||||||
|
@Getter private EditorClient editorBridge;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
instance = this;
|
||||||
|
registerDependencies();
|
||||||
|
loadAll();
|
||||||
|
editorBridge = new EditorClient(
|
||||||
|
this, EditorSchema.load(this, "META-INF/editor-schema.json"),
|
||||||
|
EditorClient.website(this, "META-INF/betterrtp-editor.properties"),
|
||||||
|
me.SuperRonanCraft.BetterRTP.versions.AsyncHandler::sync, this::reload,
|
||||||
|
me.SuperRonanCraft.BetterRTP.references.PermissionNode.EDITOR::check,
|
||||||
|
() -> me.SuperRonanCraft.BetterRTP.references.file.FileOther.FILETYPE.CONFIG.getConfig().saveToString());
|
||||||
|
new Updater(this);
|
||||||
|
new Metrics(this);
|
||||||
|
listener.registerEvents(this);
|
||||||
|
queue.registerEvents(this);
|
||||||
|
try {
|
||||||
|
new DepPlaceholderAPI().register();
|
||||||
|
} catch (NoClassDefFoundError e) {
|
||||||
|
//No placeholder api :(
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
playerDataManager.clear();
|
||||||
|
if (editorBridge != null) editorBridge.close();
|
||||||
|
invs.closeAll();
|
||||||
|
queue.unload();
|
||||||
|
rtpLogger.unload();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerDependencies() {
|
||||||
|
PlaceholderAPI = Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sendi, Command cmd, String label, String[] args) {
|
||||||
|
try {
|
||||||
|
this.cmd.commandExecuted(sendi, label, args);
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Message_RTP.sms(sendi, "&cERROR &7Seems like your Administrator did not update their language file!");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
|
return this.cmd.onTabComplete(sender, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reload(CommandSender sendi) {
|
||||||
|
invs.closeAll();
|
||||||
|
loadAll();
|
||||||
|
MessagesCore.RELOAD.send(sendi);
|
||||||
|
}
|
||||||
|
|
||||||
|
//(Re)Load all plugin systems/files/cache
|
||||||
|
private void loadAll() {
|
||||||
|
foliaHandler.load();
|
||||||
|
playerDataManager.clear();
|
||||||
|
for (org.bukkit.entity.Player player : Bukkit.getOnlinePlayers())
|
||||||
|
playerDataManager.startSession(player);
|
||||||
|
files.loadAll();
|
||||||
|
settings.load();
|
||||||
|
cooldowns.load();
|
||||||
|
databaseHandler.load();
|
||||||
|
rtpLogger.setup(this);
|
||||||
|
invs.load();
|
||||||
|
RTP.load();
|
||||||
|
cmd.load();
|
||||||
|
listener.load();
|
||||||
|
eco.load();
|
||||||
|
perms.register();
|
||||||
|
queue.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void debug(String str) {
|
||||||
|
getInstance().getLogger().info(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.RTP_INV_SETTINGS;
|
||||||
|
|
||||||
|
public class PlayerInfo {
|
||||||
|
|
||||||
|
private final HashMap<Player, Inventory> invs = new HashMap<>();
|
||||||
|
//private final HashMap<Player, RTP_INV_SETTINGS> invType = new HashMap<>();
|
||||||
|
@Getter private final HashMap<Player, World> invWorld = new HashMap<>();
|
||||||
|
@Getter private final HashMap<Player, RTP_INV_SETTINGS> invNextInv = new HashMap<>();
|
||||||
|
//private final HashMap<Player, CooldownData> cooldown = new HashMap<>();
|
||||||
|
@Getter private final HashMap<Player, Boolean> rtping = new HashMap<>();
|
||||||
|
//private final HashMap<Player, List<Location>> previousLocations = new HashMap<>();
|
||||||
|
//private final HashMap<Player, RTP_TYPE> rtpType = new HashMap<>();
|
||||||
|
|
||||||
|
/*private void setInv(Player p, Inventory inv) {
|
||||||
|
invs.put(p, inv);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/*private void setInvType(Player p, RTP_INV_SETTINGS type) {
|
||||||
|
invType.put(p, type);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public void setInvWorld(Player p, World type) {
|
||||||
|
invWorld.put(p, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNextInv(Player p, RTP_INV_SETTINGS type) {
|
||||||
|
invNextInv.put(p, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
//--Logic--
|
||||||
|
|
||||||
|
public Boolean playerExists(Player p) {
|
||||||
|
return invs.containsKey(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void unloadAll() {
|
||||||
|
invs.clear();
|
||||||
|
//invType.clear();
|
||||||
|
invWorld.clear();
|
||||||
|
invNextInv.clear();
|
||||||
|
//cooldown.clear();
|
||||||
|
rtping.clear();
|
||||||
|
//previousLocations.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void unload(Player p) {
|
||||||
|
clearInvs(p);
|
||||||
|
//cooldown.remove(p);
|
||||||
|
rtping.remove(p);
|
||||||
|
//previousLocations.remove(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearInvs(Player p) {
|
||||||
|
invs.remove(p);
|
||||||
|
//invType.remove(p);
|
||||||
|
invWorld.remove(p);
|
||||||
|
invNextInv.remove(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
+89
@@ -0,0 +1,89 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.types.CmdTeleport;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_CommandEvent;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_CommandEvent_After;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesCore;
|
||||||
|
|
||||||
|
public class Commands {
|
||||||
|
|
||||||
|
private final BetterRTP pl;
|
||||||
|
public List<RTPCommand> commands = new ArrayList<>();
|
||||||
|
|
||||||
|
public Commands(BetterRTP pl) {
|
||||||
|
this.pl = pl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void load() {
|
||||||
|
commands.clear();
|
||||||
|
for (RTPCommandType cmd : RTPCommandType.values())
|
||||||
|
registerCommand(cmd.getCmd(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerCommand(RTPCommand cmd, boolean forced) {
|
||||||
|
if (!cmd.isDebugOnly() || pl.getSettings().isDebug() || forced) //If debug only, can it be enabled?
|
||||||
|
commands.add(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void commandExecuted(CommandSender sendi, String label, String[] args) {
|
||||||
|
if (PermissionNode.USE.check(sendi)) {
|
||||||
|
if (args != null && args.length > 0) {
|
||||||
|
for (RTPCommand cmd : commands) {
|
||||||
|
if (cmd.getName().equalsIgnoreCase(args[0])) {
|
||||||
|
if (cmd.permission().check(sendi)) {
|
||||||
|
RTP_CommandEvent event = new RTP_CommandEvent(sendi, cmd);
|
||||||
|
//Command Event
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled()) {
|
||||||
|
boolean editorSync = args[0].equalsIgnoreCase("editorsync") ||
|
||||||
|
(args[0].equalsIgnoreCase("addons") && args.length > 1 && args[1].equalsIgnoreCase("editorsync"));
|
||||||
|
BetterRTP.debug(sendi.getName() + " executed: /" + label + " " +
|
||||||
|
(editorSync ? (args[0].equalsIgnoreCase("addons") ? "addons editorsync [redacted]" : "editorsync [redacted]") : String.join(" ", args)));
|
||||||
|
cmd.execute(sendi, label, args);
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(new RTP_CommandEvent_After(sendi, cmd));
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
MessagesCore.NOPERMISSION.send(sendi, cmd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MessagesCore.INVALID.send(sendi, label);
|
||||||
|
} else {
|
||||||
|
RTP_CommandEvent event = new RTP_CommandEvent(sendi, new CmdTeleport());
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled())
|
||||||
|
event.getCmd().execute(sendi, label, args);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
MessagesCore.NOPERMISSION.send(sendi, PermissionNode.USE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> onTabComplete(CommandSender sendi, String[] args) {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
if (args.length == 1) {
|
||||||
|
for (RTPCommand cmd : commands) {
|
||||||
|
if (cmd.getName().toLowerCase().startsWith(args[0].toLowerCase()))
|
||||||
|
if (cmd.permission().check(sendi))
|
||||||
|
list.add(cmd.getName().toLowerCase());
|
||||||
|
}
|
||||||
|
} else if (args.length > 1) {
|
||||||
|
for (RTPCommand cmd : commands) {
|
||||||
|
if (cmd.getName().equalsIgnoreCase(args[0]))
|
||||||
|
if (cmd.permission().check(sendi)) {
|
||||||
|
List<String> _cmdlist = cmd.tabComplete(sendi, args);
|
||||||
|
if (_cmdlist != null)
|
||||||
|
list.addAll(_cmdlist);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionCheck;
|
||||||
|
|
||||||
|
public interface RTPCommand {
|
||||||
|
|
||||||
|
void execute(CommandSender sendi, String label, String[] args);
|
||||||
|
|
||||||
|
List<String> tabComplete(CommandSender sendi, String[] args);
|
||||||
|
|
||||||
|
@NotNull PermissionCheck permission();
|
||||||
|
|
||||||
|
String getName();
|
||||||
|
|
||||||
|
default boolean isDebugOnly() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
default boolean enabled() {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands;
|
||||||
|
|
||||||
|
public interface RTPCommandHelpable {
|
||||||
|
|
||||||
|
String getHelp();
|
||||||
|
}
|
||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.types.*;
|
||||||
|
|
||||||
|
public enum RTPCommandType {
|
||||||
|
BIOME(new CmdBiome()),
|
||||||
|
EDIT(new CmdEdit()),
|
||||||
|
EDITOR(new CmdEditor()),
|
||||||
|
EDITOR_SYNC(new CmdEditorSync()),
|
||||||
|
HELP(new CmdHelp()),
|
||||||
|
INFO(new CmdInfo()),
|
||||||
|
LOCATION(new CmdLocation()),
|
||||||
|
PLAYER(new CmdPlayer()),
|
||||||
|
PLAYERSUDO(new CmdPlayerSudo()),
|
||||||
|
QUEUE(new CmdQueue(), true),
|
||||||
|
RELOAD(new CmdReload()),
|
||||||
|
//SETTINGS(new CmdSettings(), true),
|
||||||
|
TEST(new CmdTest(), true),
|
||||||
|
VERSION(new CmdVersion()),
|
||||||
|
WORLD(new CmdWorld()),
|
||||||
|
DEV(new CmdDeveloper(), true),
|
||||||
|
LOGGER(new CmdLogger(), true),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final RTPCommand cmd;
|
||||||
|
private boolean debugOnly = false;
|
||||||
|
|
||||||
|
RTPCommandType(RTPCommand cmd) {
|
||||||
|
this.cmd = cmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
RTPCommandType(RTPCommand cmd, boolean debugOnly) {
|
||||||
|
this.cmd = cmd;
|
||||||
|
this.debugOnly = debugOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDebugOnly() {
|
||||||
|
return debugOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RTPCommand getCmd() {
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
}
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands;
|
||||||
|
|
||||||
|
public enum RTP_SETUP_TYPE {
|
||||||
|
DEFAULT,
|
||||||
|
CUSTOM_WORLD,
|
||||||
|
LOCATION,
|
||||||
|
PERMISSIONGROUP
|
||||||
|
}
|
||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandHelpable;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP_Info;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesHelp;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesUsage;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CmdBiome implements RTPCommand, RTPCommandHelpable {
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "biome";
|
||||||
|
}
|
||||||
|
|
||||||
|
//rtp biome <biome1, biome2...>
|
||||||
|
public void execute(CommandSender sendi, String label, String[] args) {
|
||||||
|
if (args.length >= 2)
|
||||||
|
CmdTeleport.teleport(sendi, label, null, HelperRTP_Info.getBiomes(args, 1, sendi));
|
||||||
|
else
|
||||||
|
usage(sendi, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
if (args.length >= 2)
|
||||||
|
HelperRTP_Info.addBiomes(list, args);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull public PermissionNode permission() {
|
||||||
|
return PermissionNode.BIOME;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void usage(CommandSender sendi, String label) {
|
||||||
|
MessagesUsage.BIOME.send(sendi, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelp() {
|
||||||
|
return MessagesHelp.BIOME.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.RandomLocation;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CmdDeveloper implements RTPCommand {
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "dev";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void execute(CommandSender sendi, String label, String[] args) {
|
||||||
|
RandomLocation.runChunkTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull public PermissionNode permission() {
|
||||||
|
return PermissionNode.DEVELOPER;
|
||||||
|
//sendi.getName().equalsIgnoreCase("SuperRonanCraft") || sendi.getName().equalsIgnoreCase("RonanCrafts");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void usage(CommandSender sendi, String label) {
|
||||||
|
sendi.sendMessage("This is for Developement use only!");
|
||||||
|
}
|
||||||
|
}
|
||||||
+364
@@ -0,0 +1,364 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandHelpable;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_SHAPE;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP_EditWorlds;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesCore;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesHelp;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesUsage;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.RTPWorld;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WORLD_TYPE;
|
||||||
|
|
||||||
|
public class CmdEdit implements RTPCommand, RTPCommandHelpable { //Edit a worlds properties
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "edit";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sendi, String label, String[] args) {
|
||||||
|
if (args.length >= 4) {
|
||||||
|
for (RTP_CMD_EDIT cmd : RTP_CMD_EDIT.values()) {
|
||||||
|
if (!cmd.name().equalsIgnoreCase(args[1])) continue;
|
||||||
|
switch (cmd) {
|
||||||
|
case CUSTOMWORLD:
|
||||||
|
if (args.length >= 5) {
|
||||||
|
for (World world : Bukkit.getWorlds()) {
|
||||||
|
if (world.getName().equals(args[2])) {
|
||||||
|
for (RTP_CMD_EDIT_SUB sub_cmd : RTP_CMD_EDIT_SUB.values())
|
||||||
|
if (sub_cmd.name().equalsIgnoreCase(args[3])) {
|
||||||
|
HelperRTP_EditWorlds.editCustomWorld(sendi, sub_cmd, world.getName(), args[4]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
usage(sendi, label, cmd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MessagesCore.NOTEXIST.send(sendi, args[2]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
usage(sendi, label, cmd);
|
||||||
|
return;
|
||||||
|
case LOCATION:
|
||||||
|
if (args.length >= 5) {
|
||||||
|
for (Map.Entry<String, RTPWorld> location : BetterRTP.getInstance().getRTP().getRTPworldLocations().entrySet()) {
|
||||||
|
if (location.getKey().equals(args[2])) {
|
||||||
|
for (RTP_CMD_EDIT_SUB sub_cmd : RTP_CMD_EDIT_SUB.values())
|
||||||
|
if (sub_cmd.name().equalsIgnoreCase(args[3])) {
|
||||||
|
HelperRTP_EditWorlds.editLocation(sendi, sub_cmd, location.getKey(), args[4]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
usage(sendi, label, cmd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
usage(sendi, label, cmd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
usage(sendi, label, cmd);
|
||||||
|
return;
|
||||||
|
case PERMISSION_GROUP:
|
||||||
|
if (BetterRTP.getInstance().getSettings().isPermissionGroupEnabled() && args.length >= 6) {
|
||||||
|
for (String group : BetterRTP.getInstance().getRTP().getPermissionGroups().keySet()) {
|
||||||
|
if (group.equals(args[2])) {
|
||||||
|
for (World world : Bukkit.getWorlds()) {
|
||||||
|
if (world.getName().equals(args[3])) {
|
||||||
|
for (RTP_CMD_EDIT_SUB sub_cmd : RTP_CMD_EDIT_SUB.values())
|
||||||
|
if (sub_cmd.name().toLowerCase().startsWith(args[4].toLowerCase())) {
|
||||||
|
HelperRTP_EditWorlds.editPermissionGroup(sendi, sub_cmd, group, world.getName(), args[5]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
usage(sendi, label, cmd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MessagesCore.NOTEXIST.send(sendi, args[3]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
usage(sendi, label, cmd);
|
||||||
|
return;
|
||||||
|
case DEFAULT:
|
||||||
|
for (RTP_CMD_EDIT_SUB sub_cmd : RTP_CMD_EDIT_SUB.values())
|
||||||
|
if (sub_cmd.name().equalsIgnoreCase(args[2].toLowerCase())) {
|
||||||
|
HelperRTP_EditWorlds.editDefault(sendi, sub_cmd, args[3]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
usage(sendi, label, cmd);
|
||||||
|
return;
|
||||||
|
case WORLD_TYPE:
|
||||||
|
for (World world : Bukkit.getWorlds()) {
|
||||||
|
if (world.getName().equals(args[2])) {
|
||||||
|
HelperRTP_EditWorlds.editWorldtype(sendi, args[2], args[3]);
|
||||||
|
//usage(sendi, label, cmd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MessagesCore.NOTEXIST.send(sendi, args[2]);
|
||||||
|
return;
|
||||||
|
case OVERRIDE:
|
||||||
|
for (World world : Bukkit.getWorlds()) {
|
||||||
|
if (world.getName().equals(args[2])) {
|
||||||
|
HelperRTP_EditWorlds.editOverride(sendi, args[2], args[3]);
|
||||||
|
//usage(sendi, label, cmd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MessagesCore.NOTEXIST.send(sendi, args[2]);
|
||||||
|
return;
|
||||||
|
case BLACKLISTEDBLOCKS:
|
||||||
|
if (args[2].equalsIgnoreCase("add")) {
|
||||||
|
HelperRTP_EditWorlds.editBlacklisted(sendi, args[3], true);
|
||||||
|
} else if (args[2].equalsIgnoreCase("remove")) {
|
||||||
|
HelperRTP_EditWorlds.editBlacklisted(sendi, args[3], false);
|
||||||
|
} else
|
||||||
|
usage(sendi, label, cmd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (args.length >= 2) {
|
||||||
|
for (RTP_CMD_EDIT cmd : RTP_CMD_EDIT.values())
|
||||||
|
if (cmd.name().toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||||
|
usage(sendi, label, cmd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
usage(sendi, label, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
//rtp edit default <max/min/center/useworldborder> <value>
|
||||||
|
//rtp edit world [<world>] <max/min/center/useworldborder> <value>
|
||||||
|
//rtp edit worldtype <world> <value>
|
||||||
|
@Override
|
||||||
|
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
if (args.length == 2) {
|
||||||
|
for (RTP_CMD_EDIT cmd : RTP_CMD_EDIT.values())
|
||||||
|
if (cmd.name().toLowerCase().startsWith(args[1].toLowerCase()))
|
||||||
|
list.add(cmd.name().toLowerCase());
|
||||||
|
} else if (args.length == 3) { //rtp edit <sub_cmd> <type>
|
||||||
|
for (RTP_CMD_EDIT cmd : RTP_CMD_EDIT.values())
|
||||||
|
if (cmd.name().equalsIgnoreCase(args[1])) {
|
||||||
|
switch (cmd) {
|
||||||
|
case WORLD_TYPE:
|
||||||
|
case OVERRIDE:
|
||||||
|
case CUSTOMWORLD: //List all worlds
|
||||||
|
for (World world : Bukkit.getWorlds())
|
||||||
|
if (world.getName().toLowerCase().startsWith(args[2].toLowerCase()))
|
||||||
|
list.add(world.getName());
|
||||||
|
break;
|
||||||
|
case PERMISSION_GROUP:
|
||||||
|
for (String group : BetterRTP.getInstance().getRTP().getPermissionGroups().keySet())
|
||||||
|
if (group.toLowerCase().startsWith(args[2].toLowerCase()))
|
||||||
|
list.add(group);
|
||||||
|
break;
|
||||||
|
case LOCATION:
|
||||||
|
for (String location : BetterRTP.getInstance().getRTP().getRTPworldLocations().keySet())
|
||||||
|
if (location.toLowerCase().startsWith(args[2].toLowerCase()))
|
||||||
|
list.add(location);
|
||||||
|
break;
|
||||||
|
case DEFAULT:
|
||||||
|
list.addAll(tabCompleteSub(args, cmd));
|
||||||
|
break;
|
||||||
|
case BLACKLISTEDBLOCKS:
|
||||||
|
list.add("add");
|
||||||
|
list.add("remove");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (args.length == 4) {
|
||||||
|
for (RTP_CMD_EDIT cmd : RTP_CMD_EDIT.values())
|
||||||
|
if (cmd.name().equalsIgnoreCase(args[1]))
|
||||||
|
switch (cmd) {
|
||||||
|
case CUSTOMWORLD:
|
||||||
|
case LOCATION:
|
||||||
|
list.addAll(tabCompleteSub(args, cmd)); break;
|
||||||
|
case PERMISSION_GROUP:
|
||||||
|
for (World world : Bukkit.getWorlds())
|
||||||
|
if (world.getName().toLowerCase().startsWith(args[3].toLowerCase()))
|
||||||
|
list.add(world.getName());
|
||||||
|
break;
|
||||||
|
case DEFAULT:
|
||||||
|
if (args[2].equalsIgnoreCase(RTP_CMD_EDIT_SUB.CENTER_X.name()))
|
||||||
|
list.add(String.valueOf(((Player) sendi).getLocation().getBlockX()));
|
||||||
|
else if (args[2].equalsIgnoreCase(RTP_CMD_EDIT_SUB.CENTER_Z.name()))
|
||||||
|
list.add(String.valueOf(((Player) sendi).getLocation().getBlockZ()));
|
||||||
|
break;
|
||||||
|
case WORLD_TYPE:
|
||||||
|
for (WORLD_TYPE _type : WORLD_TYPE.values())
|
||||||
|
list.add(_type.name());
|
||||||
|
break;
|
||||||
|
case OVERRIDE:
|
||||||
|
for (World world : Bukkit.getWorlds())
|
||||||
|
if (world.getName().toLowerCase().startsWith(args[2].toLowerCase()))
|
||||||
|
list.add(world.getName());
|
||||||
|
list.add("REMOVE_OVERRIDE");
|
||||||
|
break;
|
||||||
|
case BLACKLISTEDBLOCKS:
|
||||||
|
if (args[2].equalsIgnoreCase("add")) {
|
||||||
|
for (Material block : Material.values()) {
|
||||||
|
if (list.size() > 20)
|
||||||
|
break;
|
||||||
|
if (block.name().startsWith(args[3].toUpperCase()))
|
||||||
|
list.add(block.name());
|
||||||
|
}
|
||||||
|
} else if (args[2].equalsIgnoreCase("remove")) {
|
||||||
|
for (String block : BetterRTP.getInstance().getRTP().getBlockList()) {
|
||||||
|
if (block.startsWith(args[3]))
|
||||||
|
list.add(block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (args.length == 5) {
|
||||||
|
for (RTP_CMD_EDIT cmd : RTP_CMD_EDIT.values())
|
||||||
|
if (cmd.name().equalsIgnoreCase(args[1]))
|
||||||
|
switch (cmd) {
|
||||||
|
case CUSTOMWORLD:
|
||||||
|
case LOCATION:
|
||||||
|
if (args[3].equalsIgnoreCase(RTP_CMD_EDIT_SUB.CENTER_X.name()))
|
||||||
|
list.add(String.valueOf(((Player) sendi).getLocation().getBlockX()));
|
||||||
|
else if (args[3].equalsIgnoreCase(RTP_CMD_EDIT_SUB.CENTER_Z.name()))
|
||||||
|
list.add(String.valueOf(((Player) sendi).getLocation().getBlockZ()));
|
||||||
|
else if (args[3].equalsIgnoreCase(RTP_CMD_EDIT_SUB.SHAPE.name()))
|
||||||
|
for (RTP_SHAPE shape : RTP_SHAPE.values())
|
||||||
|
list.add(shape.name().toLowerCase());
|
||||||
|
/*else if (args[3].equalsIgnoreCase(RTP_CMD_EDIT_SUB.BIOME_ADD.name()))
|
||||||
|
for (Biome biome : Biome.values()) {
|
||||||
|
if (biome.name().toLowerCase().startsWith(args[4].toLowerCase()) && list.size() < 20)
|
||||||
|
list.add(biome.name());
|
||||||
|
}*/
|
||||||
|
break;
|
||||||
|
case PERMISSION_GROUP:
|
||||||
|
list.addAll(tabCompleteSub(args, cmd)); break;
|
||||||
|
}
|
||||||
|
} else if (args.length == 6) {
|
||||||
|
for (RTP_CMD_EDIT cmd : RTP_CMD_EDIT.values())
|
||||||
|
if (cmd.name().equalsIgnoreCase(args[1]))
|
||||||
|
switch (cmd) {
|
||||||
|
case PERMISSION_GROUP:
|
||||||
|
if (args[4].equalsIgnoreCase(RTP_CMD_EDIT_SUB.CENTER_X.name()))
|
||||||
|
list.add(String.valueOf(((Player) sendi).getLocation().getBlockX()));
|
||||||
|
else if (args[4].equalsIgnoreCase(RTP_CMD_EDIT_SUB.CENTER_Z.name()))
|
||||||
|
list.add(String.valueOf(((Player) sendi).getLocation().getBlockZ()));
|
||||||
|
else if (args[4].equalsIgnoreCase(RTP_CMD_EDIT_SUB.SHAPE.name()))
|
||||||
|
for (RTP_SHAPE shape : RTP_SHAPE.values())
|
||||||
|
list.add(shape.name().toLowerCase());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> tabCompleteSub(String[] args, RTP_CMD_EDIT cmd) {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
for (RTP_CMD_EDIT_SUB sub_cmd : RTP_CMD_EDIT_SUB.values()) {
|
||||||
|
|
||||||
|
if (sub_cmd.name().toLowerCase().startsWith(args[args.length - 1].toLowerCase()))
|
||||||
|
list.add(sub_cmd.name().toLowerCase());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull @Override
|
||||||
|
public PermissionNode permission() {
|
||||||
|
return PermissionNode.EDIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void usage(CommandSender sendi, String label, RTP_CMD_EDIT type) {
|
||||||
|
if (type != null)
|
||||||
|
switch (type) {
|
||||||
|
case DEFAULT:
|
||||||
|
MessagesUsage.EDIT_DEFAULT.send(sendi, label); break;
|
||||||
|
case CUSTOMWORLD:
|
||||||
|
MessagesUsage.EDIT_WORLD.send(sendi, label); break;
|
||||||
|
case WORLD_TYPE:
|
||||||
|
MessagesUsage.EDIT_WORLDTYPE.send(sendi, label); break;
|
||||||
|
case OVERRIDE:
|
||||||
|
MessagesUsage.EDIT_OVERRIDE.send(sendi, label); break;
|
||||||
|
case BLACKLISTEDBLOCKS:
|
||||||
|
MessagesUsage.EDIT_BLACKLISTEDBLLOCKS.send(sendi, label); break;
|
||||||
|
case PERMISSION_GROUP:
|
||||||
|
MessagesUsage.EDIT_PERMISSIONGROUP.send(sendi, label); break;
|
||||||
|
case LOCATION:
|
||||||
|
MessagesUsage.EDIT_LOCATION.send(sendi, label); break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
MessagesUsage.EDIT_BASE.send(sendi, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelp() {
|
||||||
|
return MessagesHelp.EDIT.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum RTP_CMD_EDIT {
|
||||||
|
//Mapped
|
||||||
|
CUSTOMWORLD,
|
||||||
|
PERMISSION_GROUP,
|
||||||
|
LOCATION,
|
||||||
|
//Custom Coded
|
||||||
|
DEFAULT,
|
||||||
|
WORLD_TYPE,
|
||||||
|
OVERRIDE,
|
||||||
|
BLACKLISTEDBLOCKS
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum RTP_CMD_EDIT_SUB { //Only for World and Default
|
||||||
|
CENTER_X("CenterX", "INT"),
|
||||||
|
CENTER_Z("CenterZ", "INT"),
|
||||||
|
MAXRAD("MaxRadius", "INT"),
|
||||||
|
MINRAD("MinRadius", "INT"),
|
||||||
|
MAXY("MaxY", "INT"),
|
||||||
|
MINY("MinY", "INT"),
|
||||||
|
PRICE("Price", "INT"),
|
||||||
|
SHAPE("Shape", "SHAPE"),
|
||||||
|
//BIOME_ADD("Biomes", "STR"),
|
||||||
|
USEWORLDBORDER("UseWorldBorder", "BOL");
|
||||||
|
|
||||||
|
private final String type;
|
||||||
|
private final String str;
|
||||||
|
|
||||||
|
RTP_CMD_EDIT_SUB(String str, String type) {
|
||||||
|
this.str = str;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String get() {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getResult(String input) {
|
||||||
|
if (this.type.equalsIgnoreCase("INT"))
|
||||||
|
return Integer.parseInt(input);
|
||||||
|
else if (this.type.equalsIgnoreCase("BOL"))
|
||||||
|
return Boolean.valueOf(input);
|
||||||
|
else if (this.type.equalsIgnoreCase("STR"))
|
||||||
|
return Collections.singletonList(input);
|
||||||
|
else if (this.type.equalsIgnoreCase("SHAPE")) {
|
||||||
|
try {
|
||||||
|
return RTP_SHAPE.valueOf(input.toUpperCase()).name();
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandHelpable;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesHelp;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CmdEditor implements RTPCommand, RTPCommandHelpable {
|
||||||
|
public String getName() { return "editor"; }
|
||||||
|
public PermissionNode permission() { return PermissionNode.EDITOR; }
|
||||||
|
public List<String> tabComplete(CommandSender sender, String[] args) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
public void execute(CommandSender sender, String label, String[] args) {
|
||||||
|
if (args.length == 1) BetterRTP.getInstance().getEditorBridge().upload(sender);
|
||||||
|
else sender.sendMessage("Usage: /" + label + " editor");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelp() {
|
||||||
|
return MessagesHelp.EDITOR.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandHelpable;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesHelp;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CmdEditorSync implements RTPCommand, RTPCommandHelpable {
|
||||||
|
public String getName() { return "editorsync"; }
|
||||||
|
public PermissionNode permission() { return PermissionNode.EDITOR; }
|
||||||
|
public List<String> tabComplete(CommandSender sender, String[] args) { return Collections.emptyList(); }
|
||||||
|
public void execute(CommandSender sender, String label, String[] args) {
|
||||||
|
if (args.length == 2) BetterRTP.getInstance().getEditorBridge().redeem(sender, args[1]);
|
||||||
|
else sender.sendMessage("Usage: /" + label + " editorsync <token>");
|
||||||
|
}
|
||||||
|
public String getHelp() { return MessagesHelp.EDITOR_SYNC.get(); }
|
||||||
|
}
|
||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandHelpable;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.Message_RTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesHelp;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CmdHelp implements RTPCommand, RTPCommandHelpable {
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "help";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void execute(CommandSender sendi, String label, String[] args) {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
list.add(MessagesHelp.PREFIX.get());
|
||||||
|
list.add(MessagesHelp.MAIN.get());
|
||||||
|
for (RTPCommand cmd : BetterRTP.getInstance().getCmd().commands)
|
||||||
|
if (cmd.permission().check(sendi))
|
||||||
|
if (cmd instanceof RTPCommandHelpable) {
|
||||||
|
String help = ((RTPCommandHelpable) cmd).getHelp();
|
||||||
|
list.add(help);
|
||||||
|
}
|
||||||
|
Message_RTP.sms(sendi, list, Collections.singletonList(label));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@NotNull public PermissionNode permission() {
|
||||||
|
return PermissionNode.USE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelp() {
|
||||||
|
return MessagesHelp.HELP.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
+286
@@ -0,0 +1,286 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandHelpable;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTP_SETUP_TYPE;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.RTPSetupInformation;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.effects.RTPEffect_Particles;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionCheck;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.Message;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.Message_RTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesCore;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesHelp;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.QueueHandler;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldDefault;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldPlayer;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.web.LogUploader;
|
||||||
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
|
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||||
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import xyz.xenondevs.particle.ParticleEffect;
|
||||||
|
|
||||||
|
public class CmdInfo implements RTPCommand, RTPCommandHelpable {
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "info";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void execute(CommandSender sendi, String label, String[] args) {
|
||||||
|
if (args.length > 1) {
|
||||||
|
if (args[1].equalsIgnoreCase(CmdInfoSub.PARTICLES.name()))
|
||||||
|
infoParticles(sendi);
|
||||||
|
else if (args[1].equalsIgnoreCase(CmdInfoSub.SHAPES.name()))
|
||||||
|
infoShapes(sendi);
|
||||||
|
else if (args[1].equalsIgnoreCase(CmdInfoSub.POTION_EFFECTS.name()))
|
||||||
|
infoEffects(sendi);
|
||||||
|
else if (args[1].equalsIgnoreCase(CmdInfoSub.WORLD.name())) {
|
||||||
|
World world = null;
|
||||||
|
Player player = null;
|
||||||
|
if (args.length > 2) {
|
||||||
|
world = Bukkit.getWorld(args[2]);
|
||||||
|
if (world == null) {
|
||||||
|
MessagesCore.DISABLED_WORLD.send(sendi, args[2]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
MessagesCore.DISABLED_WORLD.send(sendi, "NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (args.length > 3) {
|
||||||
|
player = Bukkit.getPlayer(args[3]);
|
||||||
|
if (player == null) {
|
||||||
|
MessagesCore.NOTONLINE.send(sendi, args[2]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sendInfoWorld(sendi, infoGetWorld(sendi, world, player, null), label, args);
|
||||||
|
} else if (args[1].equalsIgnoreCase(CmdInfoSub.PLAYER.name())) {
|
||||||
|
World world = null;
|
||||||
|
Player player = null;
|
||||||
|
if (args.length > 2) {
|
||||||
|
player = Bukkit.getPlayer(args[2]);
|
||||||
|
if (player != null)
|
||||||
|
world = player.getWorld();
|
||||||
|
}
|
||||||
|
if (player == null) {
|
||||||
|
MessagesCore.NOTONLINE.send(sendi, args.length > 2 ? args[2] : "NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (world == null)
|
||||||
|
world = player.getWorld();
|
||||||
|
sendInfoWorld(sendi, infoGetWorld(sendi, world, player, null), label, args);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
infoWorld(sendi, label, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelp() {
|
||||||
|
return MessagesHelp.INFO.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
enum CmdInfoSub { //Sub commands, future expansions
|
||||||
|
PARTICLES, SHAPES, POTION_EFFECTS, WORLD, PLAYER
|
||||||
|
}
|
||||||
|
|
||||||
|
//Particles
|
||||||
|
private void infoParticles(CommandSender sendi) {
|
||||||
|
List<String> info = new ArrayList<>();
|
||||||
|
// BetterRTP pl = BetterRTP.getInstance();
|
||||||
|
|
||||||
|
for (ParticleEffect eff : ParticleEffect.VALUES) {
|
||||||
|
if (info.isEmpty() || info.size() % 2 == 0) {
|
||||||
|
info.add("&7" + eff.name() + "&r");
|
||||||
|
} else
|
||||||
|
info.add("&f" + eff.name() + "&r");
|
||||||
|
}
|
||||||
|
|
||||||
|
info.forEach(str ->
|
||||||
|
info.set(info.indexOf(str), Message.color(str)));
|
||||||
|
sendi.sendMessage(info.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
//Shapes
|
||||||
|
private void infoShapes(CommandSender sendi) {
|
||||||
|
List<String> info = new ArrayList<>();
|
||||||
|
|
||||||
|
for (String shape : RTPEffect_Particles.shapeTypes) {
|
||||||
|
if (info.isEmpty() || info.size() % 2 == 0) {
|
||||||
|
info.add("&7" + shape + "&r");
|
||||||
|
} else
|
||||||
|
info.add("&f" + shape + "&r");
|
||||||
|
}
|
||||||
|
|
||||||
|
info.forEach(str ->
|
||||||
|
info.set(info.indexOf(str), Message.color(str)));
|
||||||
|
sendi.sendMessage(info.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
//World
|
||||||
|
public static void sendInfoWorld(CommandSender sendi, List<String> list, String label, String[] args) { //Send info
|
||||||
|
boolean upload = Arrays.asList(args).contains("_UPLOAD_");
|
||||||
|
list.add(0, "&e&m-----&6 BetterRTP &8| Info &e&m-----");
|
||||||
|
list.forEach(str -> list.set(list.indexOf(str), Message.color(str)));
|
||||||
|
|
||||||
|
String cmd = "/" + label + " " + String.join(" ", args);
|
||||||
|
if (!upload) {
|
||||||
|
sendi.sendMessage(list.toArray(new String[0]));
|
||||||
|
if (sendi instanceof Player) {
|
||||||
|
TextComponent component = new TextComponent(Message.color("&7- &7Click to upload command log to &fmclo.gs"));
|
||||||
|
component.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, cmd + " _UPLOAD_"));
|
||||||
|
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Message.color("&6Suggested command&f: &7" + "/betterrtp " + String.join(" ", args) + " _UPLOAD_")).create()));
|
||||||
|
((Player) sendi).spigot().sendMessage(component);
|
||||||
|
} else {
|
||||||
|
sendi.sendMessage("Execute `" + cmd + " _UPLOAD_`" + " to upload command log to https://mclo.gs");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
list.add(0, "Command: " + cmd);
|
||||||
|
list.forEach(str -> list.set(list.indexOf(str), ChatColor.stripColor(str)));
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
|
String url = LogUploader.post(list);
|
||||||
|
if (url == null) {
|
||||||
|
Message.sms(sendi, new ArrayList<>(Collections.singletonList("&cCould not upload the log. Check your connection and ensure the log is under 5 MiB, then try again.")), null);
|
||||||
|
} else {
|
||||||
|
Message.sms(sendi, Arrays.asList(" ", Message.getPrefix(Message_RTP.msg) + "&aLog uploaded! &fView&7: &6" + url), null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void infoWorld(CommandSender sendi, String label, String[] args) { //All worlds
|
||||||
|
List<String> info = new ArrayList<>();
|
||||||
|
for (World w : Bukkit.getWorlds())
|
||||||
|
info.addAll(infoGetWorld(sendi, w, null, null));
|
||||||
|
sendInfoWorld(sendi, info, label, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> infoGetWorld(CommandSender sendi, World world, Player player, WorldPlayer _rtpworld) { //Specific world
|
||||||
|
List<String> info = new ArrayList<>();
|
||||||
|
BetterRTP pl = BetterRTP.getInstance();
|
||||||
|
String _true = "&aTrue", _false = "&bFalse";
|
||||||
|
info.add("&bRTP info for &7" + world.getName() + (player != null ? " &d(personalized)" : ""));
|
||||||
|
info.add("&7- &eViewing as: &b" + (player != null ? player.getName() : "ADMIN"));
|
||||||
|
info.add("&7- &6Allowed: " + (player != null ? PermissionCheck.getAWorld(player, world.getName()) ? _true : _false : "&cN/A"));
|
||||||
|
if (pl.getRTP().getDisabledWorlds().contains(world.getName()) && !pl.getRTP().overriden.containsKey(world.getName())) //World disabled
|
||||||
|
info.add("&7- &eDisabled: " + _true);
|
||||||
|
else {
|
||||||
|
info.add("&7- &eDisabled: " + _false);
|
||||||
|
if (pl.getRTP().overriden.containsKey(world.getName())) { //World Overriden
|
||||||
|
world = Bukkit.getWorld(pl.getRTP().overriden.get(world.getName()));
|
||||||
|
info.add("&7- &6Overriden: " + _true + " &7- target `" + world.getName() + "`");
|
||||||
|
} else
|
||||||
|
info.add("&7- &6Overriden&7: " + _false);
|
||||||
|
if (_rtpworld == null)
|
||||||
|
_rtpworld = HelperRTP.getPlayerWorld(new RTPSetupInformation(world, player != null ? player : sendi, player, player != null));
|
||||||
|
WorldDefault worldDefault = BetterRTP.getInstance().getRTP().getRTPdefaultWorld();
|
||||||
|
info.add("&7- &eSetup Type&7: " + _rtpworld.setup_type.name() + getInfo(_rtpworld, worldDefault, "setup"));
|
||||||
|
info.add("&7- &6Use World Border&7: " + (_rtpworld.getUseWorldborder() ? _true : _false));
|
||||||
|
info.add("&7- &eWorld Type&7: &f" + _rtpworld.getWorldtype().name());
|
||||||
|
info.add("&7- &6Center X&7: &f" + _rtpworld.getCenterX() + getInfo(_rtpworld, worldDefault, "centerx"));
|
||||||
|
info.add("&7- &eCenter Z&7: &f" + _rtpworld.getCenterZ() + getInfo(_rtpworld, worldDefault, "centerz"));
|
||||||
|
info.add("&7- &6Max Radius&7: &f" + _rtpworld.getMaxRadius() + getInfo(_rtpworld, worldDefault, "maxrad"));
|
||||||
|
info.add("&7- &eMin Radius&7: &f" + _rtpworld.getMinRadius() + getInfo(_rtpworld, worldDefault, "minrad"));
|
||||||
|
info.add("&7- &6Min Y&7: &f" + _rtpworld.getMinY());
|
||||||
|
info.add("&7- &eMax Y&7: &f" + _rtpworld.getMaxY());
|
||||||
|
info.add("&7- &6Price&7: &f" + _rtpworld.getPrice() + getInfo(_rtpworld, worldDefault, "price"));
|
||||||
|
info.add("&7- &eCooldown&7: &f" + _rtpworld.getCooldown() + getInfo(_rtpworld, worldDefault, "cooldown"));
|
||||||
|
info.add("&7- &6Biomes&7: &f" + _rtpworld.getBiomes().toString());
|
||||||
|
info.add("&7- &eShape&7: &f" + _rtpworld.getShape().toString() + getInfo(_rtpworld, worldDefault, "shape"));
|
||||||
|
info.add("&7- &6Permission Group&7: " + (_rtpworld.getConfig() != null ? "&a" + _rtpworld.getConfig().getGroupName() : "&cN/A"));
|
||||||
|
info.add("&7- &eQueue Available&7: " + (QueueHandler.isEnabled() ? QueueHandler.getApplicableAsync(_rtpworld).size() : "&cDisabled"));
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Janky, but it works
|
||||||
|
private static String getInfo(WorldPlayer worldPlayer, WorldDefault worldDefault, String type) {
|
||||||
|
switch (type) {
|
||||||
|
case "centerx":
|
||||||
|
return worldPlayer.getUseWorldborder() || worldPlayer.getCenterX() == worldDefault.getCenterX() ? worldPlayer.getUseWorldborder() ? " &8(worldborder)" : " &8(default)" : "";
|
||||||
|
case "centerz":
|
||||||
|
return worldPlayer.getUseWorldborder() || worldPlayer.getCenterZ() == worldDefault.getCenterZ() ? worldPlayer.getUseWorldborder() ? " &8(worldborder)" : " &8(default)" : "";
|
||||||
|
case "maxrad":
|
||||||
|
return worldPlayer.getUseWorldborder() || worldPlayer.getMaxRadius() == worldDefault.getMaxRadius() ?
|
||||||
|
worldPlayer.getUseWorldborder() ?
|
||||||
|
worldPlayer.getMaxRadius() >= worldPlayer.getWorld().getWorldBorder().getSize() ?
|
||||||
|
" &8(worldborder)" : " &8(custom)" : " &8(default)" : "";
|
||||||
|
case "minrad":
|
||||||
|
return worldPlayer.getMinRadius() == worldDefault.getMinRadius() ? " &8(default)" : "";
|
||||||
|
case "price":
|
||||||
|
return worldPlayer.getPrice() == worldDefault.getPrice() ? " &8(default)" : "";
|
||||||
|
case "shape":
|
||||||
|
return worldPlayer.getShape() == worldDefault.getShape() ? " &8(default)" : "";
|
||||||
|
case "setup":
|
||||||
|
return worldPlayer.setup_type == RTP_SETUP_TYPE.LOCATION ? " &7(" + worldPlayer.setup_name + ")" : "";
|
||||||
|
case "cooldown":
|
||||||
|
return worldPlayer.getPlayer() != null ? PermissionNode.BYPASS_COOLDOWN.check(worldPlayer.getPlayer()) ? " &8(bypassing)" : "" : " &cN/A";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
//Effects
|
||||||
|
private void infoEffects(CommandSender sendi) {
|
||||||
|
List<String> info = new ArrayList<>();
|
||||||
|
|
||||||
|
for (PotionEffectType effect : PotionEffectType.values()) {
|
||||||
|
if (info.isEmpty() || info.size() % 2 == 0) {
|
||||||
|
info.add("&7" + effect.getName() + "&r");
|
||||||
|
} else
|
||||||
|
info.add("&f" + effect.getName() + "&r");
|
||||||
|
}
|
||||||
|
|
||||||
|
info.forEach(str ->
|
||||||
|
info.set(info.indexOf(str), Message.color(str)));
|
||||||
|
sendi.sendMessage(info.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||||
|
List<String> info = new ArrayList<>();
|
||||||
|
if (args.length == 2) {
|
||||||
|
for (CmdInfoSub cmd : CmdInfoSub.values())
|
||||||
|
if (cmd.name().toLowerCase().startsWith(args[1].toLowerCase()))
|
||||||
|
info.add(cmd.name().toLowerCase());
|
||||||
|
} else if (args.length == 3) {
|
||||||
|
if (CmdInfoSub.WORLD.name().toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||||
|
for (World world : Bukkit.getWorlds())
|
||||||
|
if (world.getName().toLowerCase().startsWith(args[2].toLowerCase()))
|
||||||
|
info.add(world.getName());
|
||||||
|
} else if (CmdInfoSub.PLAYER.name().toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (p.getName().toLowerCase().startsWith(args[2].toLowerCase()))
|
||||||
|
info.add(p.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (args.length == 4) {
|
||||||
|
if (CmdInfoSub.WORLD.name().toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (p.getName().toLowerCase().startsWith(args[3].toLowerCase()))
|
||||||
|
info.add(p.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull public PermissionNode permission() {
|
||||||
|
return PermissionNode.INFO;
|
||||||
|
}
|
||||||
|
}
|
||||||
+114
@@ -0,0 +1,114 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandHelpable;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_TYPE;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionCheck;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesCore;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesHelp;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesUsage;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.RTPWorld;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldLocation;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class CmdLocation implements RTPCommand, RTPCommandHelpable {
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "location";
|
||||||
|
}
|
||||||
|
|
||||||
|
//rtp location <location name> [player]
|
||||||
|
public void execute(CommandSender sendi, String label, String[] args) {
|
||||||
|
if (args.length == 2) {
|
||||||
|
if (sendi instanceof Player) {
|
||||||
|
Player p = (Player) sendi;
|
||||||
|
for (Map.Entry<String, RTPWorld> location : getLocations(sendi, p.getWorld()).entrySet())
|
||||||
|
if (location.getKey().equalsIgnoreCase(args[1].toLowerCase())) {
|
||||||
|
HelperRTP.tp(p, sendi, null, null, RTP_TYPE.COMMAND, false, false, (WorldLocation) location.getValue());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
usage(sendi, label);
|
||||||
|
} else
|
||||||
|
sendi.sendMessage("Console is not able to execute this command! Try '/rtp help'");
|
||||||
|
} else if (args.length == 3 && PermissionNode.RTP_OTHER.check(sendi)) {
|
||||||
|
Player p = Bukkit.getPlayer(args[2]);
|
||||||
|
if (p != null && p.isOnline()) {
|
||||||
|
for (Map.Entry<String, RTPWorld> location : getLocations(sendi, null).entrySet()) {
|
||||||
|
if (location.getKey().equalsIgnoreCase(args[1].toLowerCase())) {
|
||||||
|
HelperRTP.tp(p, sendi, null, null, RTP_TYPE.COMMAND, false, false, (WorldLocation) location.getValue());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
usage(sendi, label);
|
||||||
|
} else if (p != null)
|
||||||
|
MessagesCore.NOTONLINE.send(sendi, args[1]);
|
||||||
|
else
|
||||||
|
usage(sendi, label);
|
||||||
|
} else
|
||||||
|
usage(sendi, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
if (args.length == 2) {
|
||||||
|
Player p = (Player) sendi;
|
||||||
|
for (String location_name : getLocations(sendi, p.getWorld()).keySet())
|
||||||
|
if (location_name.toLowerCase().startsWith(args[1].toLowerCase()))
|
||||||
|
list.add(location_name);
|
||||||
|
} else if (args.length == 3 && PermissionNode.RTP_OTHER.check(sendi)) {
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
|
if (p.getName().toLowerCase().startsWith(args[2].toLowerCase()))
|
||||||
|
list.add(p.getName());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull public PermissionNode permission() {
|
||||||
|
return PermissionNode.LOCATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void usage(CommandSender sendi, String label) {
|
||||||
|
MessagesUsage.LOCATION.send(sendi, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get locations a player has access to
|
||||||
|
public static HashMap<String, RTPWorld> getLocations(CommandSender sendi, @Nullable World world) {
|
||||||
|
HashMap<String, RTPWorld> locations = new HashMap<>();
|
||||||
|
boolean needPermission = BetterRTP.getInstance().getSettings().isLocationNeedPermission();
|
||||||
|
boolean needSameWorld = BetterRTP.getInstance().getSettings().isUseLocationsInSameWorld();
|
||||||
|
if (needSameWorld)
|
||||||
|
needSameWorld = !PermissionNode.BYPASS_LOCATION.check(sendi);
|
||||||
|
for (Map.Entry<String, RTPWorld> location : BetterRTP.getInstance().getRTP().getRTPworldLocations().entrySet()) {
|
||||||
|
boolean add = true;
|
||||||
|
if (needPermission) //Do we need permission to go to this location?
|
||||||
|
add = PermissionCheck.getLocation(sendi, location.getKey());
|
||||||
|
if (add && needSameWorld) //Can be added and needs same world (if not same world, we don't check)
|
||||||
|
add = world == null || location.getValue().getWorld().equals(world);
|
||||||
|
if (add) //Location can be added to list
|
||||||
|
locations.put(location.getKey(), location.getValue());
|
||||||
|
}
|
||||||
|
return locations;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelp() {
|
||||||
|
return MessagesHelp.LOCATION.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean enabled() {
|
||||||
|
return BetterRTP.getInstance().getSettings().isLocationEnabled();
|
||||||
|
}
|
||||||
|
}
|
||||||
+65
@@ -0,0 +1,65 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.Message;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.Message_RTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.web.LogUploader;
|
||||||
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
|
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||||
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
public class CmdLogger implements RTPCommand {
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "logger";
|
||||||
|
}
|
||||||
|
public void execute(CommandSender sendi, String label, String[] args) {
|
||||||
|
get(sendi, label, args, args.length >= 2 && args[args.length - 1].equalsIgnoreCase("_UPLOAD_"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void get(CommandSender sendi, String label, String[] args, boolean upload) {
|
||||||
|
String cmd = "/" + label + " " + String.join(" ", args);
|
||||||
|
if (!upload) {
|
||||||
|
if (sendi instanceof Player) {
|
||||||
|
TextComponent component = new TextComponent(Message.color("&7- &7Click to upload log to &fmclo.gs"));
|
||||||
|
component.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, cmd + " _UPLOAD_"));
|
||||||
|
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Message.color("&6Suggested command&f: &7" + "/betterrtp " + String.join(" ", args) + " _UPLOAD_")).create()));
|
||||||
|
((Player) sendi).spigot().sendMessage(component);
|
||||||
|
} else {
|
||||||
|
sendi.sendMessage("Execute `" + cmd + " _UPLOAD_`" + " to upload log to https://mclo.gs");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
|
String url = LogUploader.post(BetterRTP.getInstance().getRtpLogger().getFile());
|
||||||
|
if (url == null) {
|
||||||
|
Message.sms(sendi, new ArrayList<>(Collections.singletonList("&cCould not upload the log. Check your connection and ensure the log is under 5 MiB, then try again.")), null);
|
||||||
|
} else {
|
||||||
|
Message.sms(sendi, Arrays.asList(" ", Message.getPrefix(Message_RTP.msg) + "&aLog uploaded! &fView&7: &6" + url), null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull public PermissionNode permission() {
|
||||||
|
return PermissionNode.ADMIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void usage(CommandSender sendi, String label) {
|
||||||
|
}
|
||||||
|
}
|
||||||
+122
@@ -0,0 +1,122 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandHelpable;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_PlayerInfo;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_TYPE;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesCore;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesHelp;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesUsage;
|
||||||
|
|
||||||
|
public class CmdPlayer implements RTPCommand, RTPCommandHelpable {
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "player";
|
||||||
|
}
|
||||||
|
|
||||||
|
//rtp player <player> <world> <RTP_PlayerInfo.RTP_PLAYERINFO_FLAG...>
|
||||||
|
public void execute(CommandSender sendi, String label, String[] args) {
|
||||||
|
if (args.length == 2)
|
||||||
|
if (Bukkit.getPlayer(args[1]) != null && Bukkit.getPlayer(args[1]).isOnline()) {
|
||||||
|
HelperRTP.tp(Bukkit.getPlayer(args[1]),
|
||||||
|
sendi,
|
||||||
|
Bukkit.getPlayer(args[1]).getWorld(),
|
||||||
|
null,
|
||||||
|
RTP_TYPE.FORCED,
|
||||||
|
null,
|
||||||
|
new RTP_PlayerInfo());
|
||||||
|
} else if (Bukkit.getPlayer(args[1]) != null)
|
||||||
|
MessagesCore.NOTONLINE.send(sendi, args[1]);
|
||||||
|
else
|
||||||
|
usage(sendi, label);
|
||||||
|
else if (args.length >= 3)
|
||||||
|
if (Bukkit.getPlayer(args[1]) != null && Bukkit.getPlayer(args[1]).isOnline()) {
|
||||||
|
World world = Bukkit.getWorld(args[2]);
|
||||||
|
if (world != null) {
|
||||||
|
HelperRTP.tp(Bukkit.getPlayer(args[1]),
|
||||||
|
sendi,
|
||||||
|
world,
|
||||||
|
null,
|
||||||
|
RTP_TYPE.FORCED,
|
||||||
|
null,
|
||||||
|
getFlags(args));
|
||||||
|
} else
|
||||||
|
MessagesCore.NOTEXIST.send(sendi, args[2]);
|
||||||
|
} else if (Bukkit.getPlayer(args[1]) != null)
|
||||||
|
MessagesCore.NOTONLINE.send(sendi, args[1]);
|
||||||
|
else
|
||||||
|
usage(sendi, label);
|
||||||
|
else
|
||||||
|
usage(sendi, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
private RTP_PlayerInfo getFlags(String[] args) {
|
||||||
|
boolean applyDelay = true;
|
||||||
|
boolean applyCooldown = true;
|
||||||
|
boolean checkCooldown = true;
|
||||||
|
boolean takeMoney = true;
|
||||||
|
boolean takeHunger = true;
|
||||||
|
|
||||||
|
if (args.length > 3) {
|
||||||
|
for (int i = 3; i < args.length; i++) {
|
||||||
|
for (RTP_PlayerInfo.RTP_PLAYERINFO_FLAG flag : RTP_PlayerInfo.RTP_PLAYERINFO_FLAG.values()) {
|
||||||
|
if (flag.name().equalsIgnoreCase(args[i])) {
|
||||||
|
switch (flag) {
|
||||||
|
case NODELAY: applyDelay = false; break;
|
||||||
|
case NOCOOLDOWN: applyCooldown = false; break;
|
||||||
|
case IGNORECOOLDOWN: checkCooldown = false; break;
|
||||||
|
case IGNOREMONEY: takeMoney = false; break;
|
||||||
|
case IGNOREHUNGER: takeHunger = false; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new RTP_PlayerInfo(applyDelay, applyCooldown, checkCooldown, takeMoney, takeHunger);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
if (args.length == 2) {
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
|
if (p.getDisplayName().toLowerCase().startsWith(args[1].toLowerCase()))
|
||||||
|
list.add(p.getName());
|
||||||
|
} else if (args.length == 3) {
|
||||||
|
for (World w : Bukkit.getWorlds())
|
||||||
|
if (w.getName().startsWith(args[2]) && !BetterRTP.getInstance().getRTP().getDisabledWorlds().contains(w.getName()))
|
||||||
|
list.add(w.getName());
|
||||||
|
} else if (args.length > 3) {
|
||||||
|
for (RTP_PlayerInfo.RTP_PLAYERINFO_FLAG flag : RTP_PlayerInfo.RTP_PLAYERINFO_FLAG.values()) {
|
||||||
|
if (flag.name().toLowerCase().startsWith(args[args.length - 1].toLowerCase())) {
|
||||||
|
list.add(flag.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull public PermissionNode permission() {
|
||||||
|
return PermissionNode.RTP_OTHER;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void usage(CommandSender sendi, String label) {
|
||||||
|
MessagesUsage.RTP_OTHER.send(sendi, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelp() {
|
||||||
|
return MessagesHelp.PLAYER.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
+84
@@ -0,0 +1,84 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_PlayerInfo;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_TYPE;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesCore;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesUsage;
|
||||||
|
|
||||||
|
public class CmdPlayerSudo implements RTPCommand {
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "player_sudo";
|
||||||
|
}
|
||||||
|
|
||||||
|
//rtp sudoplayer <player> <world> <RTP_PlayerInfo.RTP_PLAYERINFO_FLAG...>
|
||||||
|
public void execute(CommandSender sendi, String label, String[] args) {
|
||||||
|
if (args.length == 2)
|
||||||
|
if (Bukkit.getPlayer(args[1]) != null && Bukkit.getPlayer(args[1]).isOnline()) {
|
||||||
|
HelperRTP.tp(Bukkit.getPlayer(args[1]),
|
||||||
|
sendi,
|
||||||
|
Bukkit.getPlayer(args[1]).getWorld(),
|
||||||
|
null,
|
||||||
|
RTP_TYPE.FORCED,
|
||||||
|
null,
|
||||||
|
new RTP_PlayerInfo(false, true, false, false, false));
|
||||||
|
} else if (Bukkit.getPlayer(args[1]) != null)
|
||||||
|
MessagesCore.NOTONLINE.send(sendi, args[1]);
|
||||||
|
else
|
||||||
|
usage(sendi, label);
|
||||||
|
else if (args.length >= 3)
|
||||||
|
if (Bukkit.getPlayer(args[1]) != null && Bukkit.getPlayer(args[1]).isOnline()) {
|
||||||
|
World world = Bukkit.getWorld(args[2]);
|
||||||
|
if (world != null) {
|
||||||
|
HelperRTP.tp(Bukkit.getPlayer(args[1]),
|
||||||
|
sendi,
|
||||||
|
world,
|
||||||
|
null,
|
||||||
|
RTP_TYPE.FORCED,
|
||||||
|
null,
|
||||||
|
new RTP_PlayerInfo(false, true, false, false, false));
|
||||||
|
} else
|
||||||
|
MessagesCore.NOTEXIST.send(sendi, args[2]);
|
||||||
|
} else if (Bukkit.getPlayer(args[1]) != null)
|
||||||
|
MessagesCore.NOTONLINE.send(sendi, args[1]);
|
||||||
|
else
|
||||||
|
usage(sendi, label);
|
||||||
|
else
|
||||||
|
usage(sendi, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
if (args.length == 2) {
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
|
if (p.getDisplayName().toLowerCase().startsWith(args[1].toLowerCase()))
|
||||||
|
list.add(p.getName());
|
||||||
|
} else if (args.length == 3) {
|
||||||
|
for (World w : Bukkit.getWorlds())
|
||||||
|
if (w.getName().startsWith(args[2]) && !BetterRTP.getInstance().getRTP().getDisabledWorlds().contains(w.getName()))
|
||||||
|
list.add(w.getName());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull public PermissionNode permission() {
|
||||||
|
return PermissionNode.RTP_OTHER;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void usage(CommandSender sendi, String label) {
|
||||||
|
MessagesUsage.RTP_OTHER.send(sendi, label);
|
||||||
|
}
|
||||||
|
}
|
||||||
+119
@@ -0,0 +1,119 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.RTPSetupInformation;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.Message;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.Message_RTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.QueueData;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.QueueHandler;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldPlayer;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.web.LogUploader;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.versions.AsyncHandler;
|
||||||
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
|
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||||
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
public class CmdQueue implements RTPCommand {
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "queue";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void execute(CommandSender sendi, String label, String[] args) {
|
||||||
|
Player p = (Player) sendi;
|
||||||
|
//sendi.sendMessage("Loading...");
|
||||||
|
World world = args.length > 1 ? Bukkit.getWorld(args[1]) : null;
|
||||||
|
AsyncHandler.async(() -> {
|
||||||
|
if (world != null) {
|
||||||
|
sendInfo(sendi, queueGetWorld(p, world), label, args);
|
||||||
|
} else
|
||||||
|
queueWorlds(p, label, args);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//World
|
||||||
|
public static void sendInfo(CommandSender sendi, List<String> list, String label, String[] args) { //Send info
|
||||||
|
boolean upload = Arrays.asList(args).contains("_UPLOAD_");
|
||||||
|
list.add(0, "&e&m-----&6 BetterRTP &8| Queue &e&m-----");
|
||||||
|
list.forEach(str -> list.set(list.indexOf(str), Message.color(str)));
|
||||||
|
String cmd = "/" + label + " " + String.join(" ", args);
|
||||||
|
if (!upload) {
|
||||||
|
sendi.sendMessage(list.toArray(new String[0]));
|
||||||
|
if (sendi instanceof Player) {
|
||||||
|
TextComponent component = new TextComponent(Message.color("&7- &7Click to upload command log to &fmclo.gs"));
|
||||||
|
component.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, cmd + " _UPLOAD_"));
|
||||||
|
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Message.color("&6Suggested command&f: &7" + "/betterrtp " + String.join(" ", args) + " _UPLOAD_")).create()));
|
||||||
|
((Player) sendi).spigot().sendMessage(component);
|
||||||
|
} else {
|
||||||
|
sendi.sendMessage("Execute `" + cmd + " _UPLOAD_`" + " to upload command log to https://mclo.gs");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
list.add(0, "Command: " + cmd);
|
||||||
|
list.forEach(str -> list.set(list.indexOf(str), ChatColor.stripColor(str)));
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
|
String url = LogUploader.post(list);
|
||||||
|
if (url == null) {
|
||||||
|
Message.sms(sendi, new ArrayList<>(Collections.singletonList("&cCould not upload the log. Check your connection and ensure the log is under 5 MiB, then try again.")), null);
|
||||||
|
} else {
|
||||||
|
Message.sms(sendi, Arrays.asList(" ", Message.getPrefix(Message_RTP.msg) + "&aLog uploaded! &fView&7: &6" + url), null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void queueWorlds(Player p, String label, String[] args) { //All worlds
|
||||||
|
List<String> info = new ArrayList<>();
|
||||||
|
int locs = 0;
|
||||||
|
for (World w : Bukkit.getWorlds()) {
|
||||||
|
List<String> list = queueGetWorld(p, w);
|
||||||
|
info.addAll(list);
|
||||||
|
locs += list.size();
|
||||||
|
}
|
||||||
|
info.add("&eTotal of &a%amount% &egenerated locations".replace("%amount%", String.valueOf(locs)));
|
||||||
|
sendInfo(p, info, label, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<String> queueGetWorld(Player player, World world) { //Specific world
|
||||||
|
List<String> info = new ArrayList<>();
|
||||||
|
info.add("&eWorld: &6" + world.getName());
|
||||||
|
RTPSetupInformation setup_info = new RTPSetupInformation(HelperRTP.getActualWorld(player, world), player, player, true);
|
||||||
|
WorldPlayer pWorld = HelperRTP.getPlayerWorld(setup_info);
|
||||||
|
for (QueueData queue : QueueHandler.getApplicableAsync(pWorld)) {
|
||||||
|
String str = "&8- &7x= &b%x, &7z= &b%z";
|
||||||
|
Location loc = queue.getLocation();
|
||||||
|
str = str.replace("%x", String.valueOf(loc.getBlockX())).replace("%z", String.valueOf(loc.getBlockZ()));
|
||||||
|
info.add(str);
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||||
|
List<String> info = new ArrayList<>();
|
||||||
|
if (args.length == 2) {
|
||||||
|
for (World world : Bukkit.getWorlds())
|
||||||
|
if (world.getName().startsWith(args[1]))
|
||||||
|
info.add(world.getName());
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull public PermissionNode permission() {
|
||||||
|
return PermissionNode.ADMIN;
|
||||||
|
}
|
||||||
|
}
|
||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandHelpable;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesHelp;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CmdReload implements RTPCommand, RTPCommandHelpable {
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "reload";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void execute(CommandSender sendi, String label, String[] args) {
|
||||||
|
BetterRTP.getInstance().reload(sendi);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull public PermissionNode permission() {
|
||||||
|
return PermissionNode.RELOAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelp() {
|
||||||
|
return MessagesHelp.RELOAD.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
+41
@@ -0,0 +1,41 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandHelpable;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.invs.RTP_INV_SETTINGS;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.Message_RTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesHelp;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CmdSettings implements RTPCommand, RTPCommandHelpable {
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "settings";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void execute(CommandSender sendi, String label, String[] args) {
|
||||||
|
if (sendi instanceof Player)
|
||||||
|
BetterRTP.getInstance().getInvs().getInv(RTP_INV_SETTINGS.MAIN).show((Player) sendi);
|
||||||
|
else
|
||||||
|
Message_RTP.sms(sendi, "Must be a player to use this command! Try '/" + label + " help'");
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull public PermissionNode permission() {
|
||||||
|
return PermissionNode.SETTINGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelp() {
|
||||||
|
return MessagesHelp.SETTINGS.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
+45
@@ -0,0 +1,45 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_TYPE;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.Message_RTP;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CmdTeleport implements RTPCommand {
|
||||||
|
|
||||||
|
//Label is the %command% placeholder in messages
|
||||||
|
public static void teleport(CommandSender sendi, String label, World world, List<String> biomes) {
|
||||||
|
if (sendi instanceof Player)
|
||||||
|
HelperRTP.tp((Player) sendi, sendi, world, biomes, RTP_TYPE.COMMAND);
|
||||||
|
else
|
||||||
|
Message_RTP.sms(sendi, "Must be a player to use this command! Try '/" + label + " help'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sendi, String label, String[] args) {
|
||||||
|
teleport(sendi, label, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull @Override
|
||||||
|
public PermissionNode permission() {
|
||||||
|
return PermissionNode.USE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+53
@@ -0,0 +1,53 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandHelpable;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.RTPSetupInformation;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_TYPE;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesHelp;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
//Meant to just test particles and effects without actually rtp'ing around the world
|
||||||
|
public class CmdTest implements RTPCommand, RTPCommandHelpable {
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "test";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sendi, String label, String[] args) {
|
||||||
|
if (sendi instanceof Player) {
|
||||||
|
Player p = (Player) sendi;
|
||||||
|
BetterRTP.getInstance().getRTP().getTeleport().afterTeleport(p, p.getLocation(),
|
||||||
|
HelperRTP.getPlayerWorld(new RTPSetupInformation(p.getWorld(), p, p, false)), 0, p.getLocation(), RTP_TYPE.TEST);
|
||||||
|
} else
|
||||||
|
sendi.sendMessage("Console is not able to execute this command! Try '/rtp help'");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull @Override
|
||||||
|
public PermissionNode permission() {
|
||||||
|
return PermissionNode.ADMIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelp() {
|
||||||
|
return MessagesHelp.TEST.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDebugOnly() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandHelpable;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.Message_RTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesHelp;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CmdVersion implements RTPCommand, RTPCommandHelpable {
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "version";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void execute(CommandSender sendi, String label, String[] args) {
|
||||||
|
Message_RTP.sms(sendi, "&aVersion #&e" + BetterRTP.getInstance().getDescription().getVersion());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull public PermissionNode permission() {
|
||||||
|
return PermissionNode.VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelp() {
|
||||||
|
return MessagesHelp.VERSION.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
+69
@@ -0,0 +1,69 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandHelpable;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionCheck;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP_Info;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesCore;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesHelp;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesUsage;
|
||||||
|
|
||||||
|
public class CmdWorld implements RTPCommand, RTPCommandHelpable {
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "world";
|
||||||
|
}
|
||||||
|
|
||||||
|
//rtp world <world> <biome1, biome2...>
|
||||||
|
public void execute(CommandSender sendi, String label, String[] args) {
|
||||||
|
if (args.length >= 2) {
|
||||||
|
World world = Bukkit.getWorld(args[1]);
|
||||||
|
if (world == null) //Check if world has spaces instead of underscores
|
||||||
|
world = Bukkit.getWorld(args[1].replace("_", " "));
|
||||||
|
if (world != null)
|
||||||
|
CmdTeleport.teleport(sendi, label, world, HelperRTP_Info.getBiomes(args, 2, sendi));
|
||||||
|
else
|
||||||
|
MessagesCore.NOTEXIST.send(sendi, args[1]);
|
||||||
|
} else
|
||||||
|
usage(sendi, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
if (args.length == 2) {
|
||||||
|
for (World w : Bukkit.getWorlds()) {
|
||||||
|
String _wName = w.getName().replace(" ", "_");
|
||||||
|
if (w.getName().startsWith(args[1]) && !BetterRTP.getInstance().getRTP().getDisabledWorlds().contains(_wName)
|
||||||
|
&& PermissionCheck.getAWorld(sendi, _wName))
|
||||||
|
list.add(_wName);
|
||||||
|
}
|
||||||
|
} else if (args.length >= 3) {
|
||||||
|
if (PermissionNode.BIOME.check(sendi))
|
||||||
|
HelperRTP_Info.addBiomes(list, args);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull public PermissionNode permission() {
|
||||||
|
return PermissionNode.WORLD;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void usage(CommandSender sendi, String label) {
|
||||||
|
MessagesUsage.WORLD.send(sendi, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHelp() {
|
||||||
|
return MessagesHelp.WORLD.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
+14
-11
@@ -1,33 +1,35 @@
|
|||||||
package me.SuperRonanCraft.BetterRTP.player.events;
|
package me.SuperRonanCraft.BetterRTP.player.events;
|
||||||
|
|
||||||
import me.SuperRonanCraft.BetterRTP.references.invs.RTPInventories;
|
import me.SuperRonanCraft.BetterRTP.references.invs.RTPInventories;
|
||||||
import me.SuperRonanCraft.BetterRTP.Main;
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
import me.SuperRonanCraft.BetterRTP.player.PlayerInfo;
|
import me.SuperRonanCraft.BetterRTP.references.player.HelperPlayer;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.player.playerdata.PlayerData;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
|
||||||
public class Click {
|
public class Click {
|
||||||
|
|
||||||
public void click(InventoryClickEvent e) {
|
static void click(InventoryClickEvent e) {
|
||||||
if (!validClick(e))
|
if (!validClick(e))
|
||||||
return;
|
return;
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
handler(e);
|
handler(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handler(InventoryClickEvent e) {
|
static private void handler(InventoryClickEvent e) {
|
||||||
try {
|
try {
|
||||||
PlayerInfo pInfo = Main.getInstance().getpInfo();
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
Player p = (Player) e.getWhoClicked();
|
||||||
RTPInventories menu = Main.getInstance().getInvs();
|
PlayerData data = HelperPlayer.getData(p);
|
||||||
menu.getInv(pInfo.getInvType(p)).clickEvent(e);
|
if (data == null) return;
|
||||||
|
RTPInventories menu = BetterRTP.getInstance().getInvs();
|
||||||
|
menu.getInv(data.getMenu().getInvType()).clickEvent(e);
|
||||||
} catch (NullPointerException ex) {
|
} catch (NullPointerException ex) {
|
||||||
//ex.printStackTrace();
|
//ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean validClick(InventoryClickEvent e) {
|
static private boolean validClick(InventoryClickEvent e) {
|
||||||
//Not a player, or Not our inventory
|
//Not a player, or Not our inventory
|
||||||
if (!(e.getWhoClicked() instanceof Player) || e.isCancelled())
|
if (!(e.getWhoClicked() instanceof Player) || e.isCancelled())
|
||||||
return false;
|
return false;
|
||||||
@@ -36,11 +38,12 @@ public class Click {
|
|||||||
return false;
|
return false;
|
||||||
else if (e.getWhoClicked() instanceof Player) {
|
else if (e.getWhoClicked() instanceof Player) {
|
||||||
// Clicks the inventory
|
// Clicks the inventory
|
||||||
if (!e.getInventory().equals(Main.getInstance().getpInfo().getInv((Player) e.getWhoClicked())))
|
PlayerData data = HelperPlayer.getData((Player) e.getWhoClicked());
|
||||||
|
if (data == null) return false;
|
||||||
|
if (!e.getInventory().equals(data.getMenu().getInv()))
|
||||||
return false;
|
return false;
|
||||||
// Clicks their own inventory
|
// Clicks their own inventory
|
||||||
else if (!e.getClickedInventory().equals(Main.getInstance().getpInfo().getInv((Player) e
|
else if (!e.getClickedInventory().equals(data.getMenu().getInv())) {
|
||||||
.getWhoClicked()))) {
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.events;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_TeleportPostEvent;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.depends.DepEssentials;
|
||||||
|
|
||||||
|
public class Custom {
|
||||||
|
|
||||||
|
static void postRTP(RTP_TeleportPostEvent e) {
|
||||||
|
DepEssentials.setBackLocation(e.getPlayer(), e.getOldLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.events;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.player.HelperPlayer;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.player.playerdata.PlayerData;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
|
||||||
|
public class Damage {
|
||||||
|
static boolean canCancel(EntityDamageEvent.DamageCause damageCause) {
|
||||||
|
return true; // TODO: Allow for filtering damage causes
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean isInInvincibleMode(Player player) {
|
||||||
|
PlayerData data = HelperPlayer.getData(player);
|
||||||
|
return data != null && data.getInvincibleEndTime() > System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onEntityDamage(EntityDamageEvent event) {
|
||||||
|
Entity entity = event.getEntity();
|
||||||
|
if (!(entity instanceof Player)) return;
|
||||||
|
Player player = (Player) entity;
|
||||||
|
|
||||||
|
if (!canCancel(event.getCause())) return;
|
||||||
|
if (!isInInvincibleMode(player)) return;
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.events;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.RTPSetupInformation;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_TYPE;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
|
|
||||||
|
public class Death {
|
||||||
|
|
||||||
|
static void respawnEvent(PlayerRespawnEvent e) {
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
WorldPlayer worldPlayer = HelperRTP.getPlayerWorld(new RTPSetupInformation(
|
||||||
|
p.getWorld(),
|
||||||
|
p, p, false
|
||||||
|
));
|
||||||
|
if (worldPlayer.getRTPOnDeath()) {
|
||||||
|
HelperRTP.tp(p, p, p.getWorld(), null, RTP_TYPE.FORCED, true, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+76
@@ -0,0 +1,76 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.events;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_TeleportPostEvent;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.SignChangeEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.player.*;
|
||||||
|
import org.bukkit.event.world.WorldLoadEvent;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
|
public class EventListener implements Listener {
|
||||||
|
private final Interact interact = new Interact();
|
||||||
|
private final WorldLoad worldLoad = new WorldLoad();
|
||||||
|
|
||||||
|
public void registerEvents(BetterRTP pl) {
|
||||||
|
PluginManager pm = pl.getServer().getPluginManager();
|
||||||
|
pm.registerEvents(this, pl);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void load() {
|
||||||
|
interact.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
private void onLeave(PlayerQuitEvent e) {
|
||||||
|
Leave.event(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
private void onJoin(PlayerJoinEvent e) {
|
||||||
|
Join.event(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
private void onInteract(PlayerInteractEvent e) {
|
||||||
|
interact.event(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
private void interact(SignChangeEvent e) {
|
||||||
|
interact.createSign(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
private void click(InventoryClickEvent e) {
|
||||||
|
Click.click(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
private void teleport(PlayerTeleportEvent e) {
|
||||||
|
Teleport.tpEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
private void rtpPost(RTP_TeleportPostEvent e) {
|
||||||
|
Custom.postRTP(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
private void worldLoad(WorldLoadEvent e) {
|
||||||
|
worldLoad.load(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
private void onRespawn(PlayerRespawnEvent e) {
|
||||||
|
Death.respawnEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
private void onDamage(EntityDamageEvent e) {
|
||||||
|
Damage.onEntityDamage(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
+17
-13
@@ -1,8 +1,12 @@
|
|||||||
package me.SuperRonanCraft.BetterRTP.player.events;
|
package me.SuperRonanCraft.BetterRTP.player.events;
|
||||||
|
|
||||||
import me.SuperRonanCraft.BetterRTP.player.commands.CommandTypes;
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandType;
|
||||||
import me.SuperRonanCraft.BetterRTP.Main;
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.Message;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.Message_RTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesCore;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -19,10 +23,10 @@ class Interact {
|
|||||||
|
|
||||||
void load() {
|
void load() {
|
||||||
String pre = "Settings.";
|
String pre = "Settings.";
|
||||||
FileBasics.FILETYPE file = Main.getInstance().getFiles().getType(FileBasics.FILETYPE.SIGNS);
|
FileOther.FILETYPE file = BetterRTP.getInstance().getFiles().getType(FileOther.FILETYPE.SIGNS);
|
||||||
enabled = file.getBoolean(pre + "Enabled");
|
enabled = file.getBoolean(pre + "Enabled");
|
||||||
title = file.getString(pre + "Title");
|
title = file.getString(pre + "Title");
|
||||||
coloredTitle = Main.getInstance().getText().color(title);
|
coloredTitle = Message.color(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void event(PlayerInteractEvent e) {
|
void event(PlayerInteractEvent e) {
|
||||||
@@ -34,33 +38,33 @@ class Interact {
|
|||||||
action(e.getPlayer(), null);
|
action(e.getPlayer(), null);
|
||||||
return;
|
return;
|
||||||
} else
|
} else
|
||||||
for (CommandTypes cmd : CommandTypes.values())
|
for (RTPCommandType cmd : RTPCommandType.values())
|
||||||
if (command.equalsIgnoreCase(cmd.name())) {
|
if (command.equalsIgnoreCase(cmd.name())) {
|
||||||
action(e.getPlayer(), cmd(sign.getLines()).split(" "));
|
action(e.getPlayer(), cmd(sign.getLines()).split(" "));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
e.getPlayer().sendMessage(Main.getInstance().getText().colorPre("&cError! &7Command &a"
|
Message_RTP.sms(e.getPlayer(), "&cError! &7Command &a"
|
||||||
+ Arrays.toString(cmd(sign.getLines()).split(" ")) + "&7 does not exist! Defaulting command to /rtp!"));
|
+ Arrays.toString(cmd(sign.getLines()).split(" ")) + "&7 does not exist! Defaulting command to /rtp!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void createSign(SignChangeEvent e) {
|
void createSign(SignChangeEvent e) {
|
||||||
if (enabled && Main.getInstance().getPerms().getSignCreate(e.getPlayer())) {
|
if (enabled && PermissionNode.SIGN_CREATE.check(e.getPlayer())) {
|
||||||
String line = e.getLine(0);
|
String line = e.getLine(0);
|
||||||
if (line != null && (line.equalsIgnoreCase(title) ||
|
if (line != null && (line.equalsIgnoreCase(title) ||
|
||||||
line.equalsIgnoreCase("[RTP]"))) {
|
line.equalsIgnoreCase("[RTP]"))) {
|
||||||
e.setLine(0, coloredTitle != null ? coloredTitle : "[RTP]");
|
e.setLine(0, coloredTitle != null ? coloredTitle : "[RTP]");
|
||||||
Main.getInstance().getText().getSignCreated(e.getPlayer(), cmd(e.getLines()));
|
MessagesCore.SIGN.send(e.getPlayer(), cmd(e.getLines()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void action(Player p, String[] line) {
|
private void action(Player p, String[] line) {
|
||||||
Main.getInstance().getCmd().commandExecuted(p, "rtp", line);
|
BetterRTP.getInstance().getCmd().commandExecuted(p, "rtp", line);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String cmd(String[] signArray) {
|
private static String cmd(String[] signArray) {
|
||||||
String actions = "";
|
String actions = "";
|
||||||
for (int i = 1; i < signArray.length; i++) {
|
for (int i = 1; i < signArray.length; i++) {
|
||||||
String line = signArray[i];
|
String line = signArray[i];
|
||||||
@@ -73,7 +77,7 @@ class Interact {
|
|||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSign(Block block) {
|
private static boolean isSign(Block block) {
|
||||||
return block.getState() instanceof Sign;
|
return block.getState() instanceof Sign;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.events;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_TYPE;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.Message_RTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesCore;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.web.Updater;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class Join {
|
||||||
|
|
||||||
|
static void event(PlayerJoinEvent e) {
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
getPl().getPlayerDataManager().startSession(p);
|
||||||
|
updater(p);
|
||||||
|
getPl().getCooldowns().loadPlayer(p);
|
||||||
|
rtpOnFirstJoin(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Updater
|
||||||
|
private static void updater(Player p) {
|
||||||
|
if (!getPl().getFiles().getType(FileOther.FILETYPE.CONFIG).getBoolean("Settings.DisableUpdater") && PermissionNode.UPDATER.check(p)) {
|
||||||
|
if (!getPl().getDescription().getVersion().equals(Updater.updatedVersion)) {
|
||||||
|
String currentVersion = getPl().getDescription().getVersion();
|
||||||
|
String newVersion = Updater.updatedVersion;
|
||||||
|
|
||||||
|
MessagesCore.UPDATE.send(p, Arrays.asList(currentVersion, newVersion));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//RTP on first join
|
||||||
|
private static void rtpOnFirstJoin(Player p) {
|
||||||
|
if (getPl().getSettings().isRtpOnFirstJoin_Enabled() && !p.hasPlayedBefore())
|
||||||
|
HelperRTP.tp(p, Bukkit.getConsoleSender(), Bukkit.getWorld(getPl().getSettings().getRtpOnFirstJoin_World()), null, RTP_TYPE.JOIN, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BetterRTP getPl() {
|
||||||
|
return BetterRTP.getInstance();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.events;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.player.HelperPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
|
class Leave {
|
||||||
|
|
||||||
|
static void event(PlayerQuitEvent e) {
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
HelperPlayer.unload(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.events;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.player.HelperPlayer;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.player.playerdata.PlayerData;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
|
|
||||||
|
public class Teleport {
|
||||||
|
|
||||||
|
static void tpEvent(PlayerTeleportEvent e) {
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
PlayerData data = HelperPlayer.getData(p);
|
||||||
|
//Add data to database
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.events;
|
||||||
|
|
||||||
|
import com.tcoded.folialib.wrapper.task.WrappedTask;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.versions.AsyncHandler;
|
||||||
|
import org.bukkit.event.world.WorldLoadEvent;
|
||||||
|
|
||||||
|
public class WorldLoad {
|
||||||
|
|
||||||
|
WrappedTask loader;
|
||||||
|
|
||||||
|
void load(WorldLoadEvent e) {
|
||||||
|
//BetterRTP.getInstance().getLogger().info("NEW WORLD!");
|
||||||
|
if (loader != null)
|
||||||
|
loader.cancel();
|
||||||
|
loader = AsyncHandler.syncLater(() -> {
|
||||||
|
BetterRTP.debug("New world `" + e.getWorld().getName() + "` detected! Reloaded Databases!");
|
||||||
|
BetterRTP.getInstance().getDatabaseHandler().load();
|
||||||
|
}, 20L * 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_SettingUpEvent;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP_Check;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.PermissionGroup;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.RTPWorld;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WORLD_TYPE;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldDefault;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldPlayer;
|
||||||
|
|
||||||
|
public class RTP {
|
||||||
|
|
||||||
|
@Getter final RTPTeleport teleport = new RTPTeleport();
|
||||||
|
//Cache
|
||||||
|
public final HashMap<String, String> overriden = new HashMap<>();
|
||||||
|
@Getter List<String> disabledWorlds, blockList;
|
||||||
|
int maxAttempts, delayTime;
|
||||||
|
boolean cancelOnMove, cancelOnDamage;
|
||||||
|
public final HashMap<String, WORLD_TYPE> world_type = new HashMap<>();
|
||||||
|
//Worlds
|
||||||
|
@Getter private final WorldDefault RTPdefaultWorld = new WorldDefault();
|
||||||
|
@Getter private final HashMap<String, RTPWorld> RTPcustomWorld = new HashMap<>();
|
||||||
|
@Getter private final HashMap<String, RTPWorld> RTPworldLocations = new HashMap<>();
|
||||||
|
@Getter private final HashMap<String, PermissionGroup> permissionGroups = new HashMap<>();
|
||||||
|
|
||||||
|
public void load() {
|
||||||
|
FileOther.FILETYPE config = FileOther.FILETYPE.CONFIG;
|
||||||
|
disabledWorlds = config.getStringList("DisabledWorlds");
|
||||||
|
maxAttempts = config.getInt("Settings.MaxAttempts");
|
||||||
|
delayTime = config.getInt("Settings.Delay.Time");
|
||||||
|
cancelOnMove = config.getBoolean("Settings.Delay.CancelOnMove");
|
||||||
|
cancelOnDamage = config.getBoolean("Settings.Delay.CancelOnDamage");
|
||||||
|
blockList = config.getStringList("BlacklistedBlocks");
|
||||||
|
//Overrides
|
||||||
|
RTPLoader.loadOverrides(overriden);
|
||||||
|
//WorldType
|
||||||
|
RTPLoader.loadWorldTypes(world_type);
|
||||||
|
//Worlds & CustomWorlds
|
||||||
|
loadWorlds();
|
||||||
|
//Locations
|
||||||
|
loadLocations();
|
||||||
|
//Permissions
|
||||||
|
loadPermissionGroups();
|
||||||
|
teleport.load(); //Load teleporting stuff
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadWorlds() { //Keeping this here because of the edit command
|
||||||
|
RTPLoader.loadWorlds(RTPdefaultWorld, RTPcustomWorld);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadLocations() { //Keeping this here because of the edit command
|
||||||
|
RTPLoader.loadLocations(RTPworldLocations);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadPermissionGroups() { //Keeping this here because of the edit command
|
||||||
|
RTPLoader.loadPermissionGroups(permissionGroups);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start(RTPSetupInformation setup_info) {
|
||||||
|
start(HelperRTP.getPlayerWorld(setup_info));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start(WorldPlayer pWorld) {
|
||||||
|
RTP_SettingUpEvent setup = new RTP_SettingUpEvent(pWorld.getPlayer());
|
||||||
|
Bukkit.getPluginManager().callEvent(setup);
|
||||||
|
if (setup.isCancelled())
|
||||||
|
return;
|
||||||
|
rtp(pWorld.getSendi(), pWorld, pWorld.getRtp_type());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rtp(CommandSender sendi, WorldPlayer pWorld, RTP_TYPE type) {
|
||||||
|
//Cooldown
|
||||||
|
Player p = pWorld.getPlayer();
|
||||||
|
getPl().getPInfo().getRtping().put(p, true); //Cache player so they cant run '/rtp' again while rtp'ing
|
||||||
|
//Setup player rtp methods
|
||||||
|
RTPPlayer rtpPlayer = new RTPPlayer(p, this, pWorld, type);
|
||||||
|
// Delaying? Else, just go
|
||||||
|
if (pWorld.getPlayerInfo().applyDelay && HelperRTP_Check.applyDelay(pWorld.getPlayer())) {
|
||||||
|
new RTPDelay(sendi, rtpPlayer, delayTime, cancelOnMove, cancelOnDamage);
|
||||||
|
} else {
|
||||||
|
if (!teleport.beforeTeleportInstant(sendi, p))
|
||||||
|
rtpPlayer.randomlyTeleport(sendi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private BetterRTP getPl() {
|
||||||
|
return BetterRTP.getInstance();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||||
|
|
||||||
|
import com.tcoded.folialib.wrapper.task.WrappedTask;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_CancelledEvent;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.versions.AsyncHandler;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
|
class RTPDelay implements Listener {
|
||||||
|
private WrappedTask task;
|
||||||
|
private final boolean cancelOnMove, cancelOnDamage;
|
||||||
|
private final RTPPlayer rtp;
|
||||||
|
|
||||||
|
RTPDelay(CommandSender sendi, RTPPlayer rtp, int delay, boolean cancelOnMove, boolean cancelOnDamage) {
|
||||||
|
this.cancelOnMove = cancelOnMove;
|
||||||
|
this.cancelOnDamage = cancelOnDamage;
|
||||||
|
this.rtp = rtp;
|
||||||
|
delay(sendi, delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void delay(CommandSender sendi, int delay) {
|
||||||
|
if (!getPl().getRTP().getTeleport().beforeTeleportDelay(rtp.getPlayer(), delay)) {
|
||||||
|
task = AsyncHandler.syncLater(run(sendi, this), delay * 20L);
|
||||||
|
if (cancelOnMove || cancelOnDamage)
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, BetterRTP.getInstance());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private void event(PlayerMoveEvent e) {
|
||||||
|
if (cancelOnMove)
|
||||||
|
if (e.getPlayer().equals(rtp.getPlayer()) &&
|
||||||
|
(e.getTo() != null &&
|
||||||
|
(e.getTo().getBlockX() != e.getFrom().getBlockX() ||
|
||||||
|
e.getTo().getBlockY() != e.getFrom().getBlockY() ||
|
||||||
|
e.getTo().getBlockZ() != e.getFrom().getBlockZ()))
|
||||||
|
) {
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private void event(EntityDamageEvent e) {
|
||||||
|
if (cancelOnDamage)
|
||||||
|
if (e.getEntity() instanceof Player){
|
||||||
|
if (e.getEntity().equals(rtp.getPlayer()))
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancel() {
|
||||||
|
if (task != null)
|
||||||
|
task.cancel();
|
||||||
|
HandlerList.unregisterAll(this);
|
||||||
|
getPl().getRTP().getTeleport().cancelledTeleport(rtp.getPlayer());
|
||||||
|
//getPl().getEco().unCharge(rtp.getPlayer(), rtp.pWorld);
|
||||||
|
getPl().getCooldowns().removeCooldown(rtp.getPlayer(), rtp.worldPlayer.getWorld());
|
||||||
|
getPl().getPInfo().getRtping().remove(rtp.getPlayer());
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(new RTP_CancelledEvent(rtp.getPlayer()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Runnable run(final CommandSender sendi, final RTPDelay cls) {
|
||||||
|
return () -> {
|
||||||
|
HandlerList.unregisterAll(cls);
|
||||||
|
if (getPl().getPInfo().getRtping().containsKey(rtp.getPlayer()))
|
||||||
|
rtp.randomlyTeleport(sendi);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private BetterRTP getPl() {
|
||||||
|
return BetterRTP.getInstance();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.PermissionGroup;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.RTPWorld;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WORLD_TYPE;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldCustom;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldDefault;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldLocation;
|
||||||
|
|
||||||
|
public class RTPLoader {
|
||||||
|
|
||||||
|
static void loadWorlds(@NotNull WorldDefault defaultWorld, @NotNull HashMap<String, RTPWorld> customWorlds) {
|
||||||
|
defaultWorld.load();
|
||||||
|
customWorlds.clear();
|
||||||
|
BetterRTP.debug("Loading Custom Worlds...");
|
||||||
|
try {
|
||||||
|
FileOther.FILETYPE config = FileOther.FILETYPE.CONFIG;
|
||||||
|
List<Map<?, ?>> map = config.getMapList("CustomWorlds");
|
||||||
|
for (Map<?, ?> m : map)
|
||||||
|
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
||||||
|
String world = entry.getKey().toString();
|
||||||
|
AtomicBoolean exists = new AtomicBoolean(false);
|
||||||
|
Bukkit.getWorlds().forEach(w -> {
|
||||||
|
if (w.getName().equals(world))
|
||||||
|
exists.set(true);
|
||||||
|
});
|
||||||
|
if (exists.get()) {
|
||||||
|
BetterRTP.debug("Custom World '" + world + "' registered:");
|
||||||
|
customWorlds.put(world, new WorldCustom(Bukkit.getWorld(world)));
|
||||||
|
} else
|
||||||
|
BetterRTP.debug("[WARN] - Custom World '" + world + "' was not registered because world does NOT exist");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
//No Custom Worlds
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void loadOverrides(@NotNull HashMap<String, String> overriden) {
|
||||||
|
BetterRTP.debug("Loading Overrides...");
|
||||||
|
overriden.clear();
|
||||||
|
try {
|
||||||
|
FileOther.FILETYPE config = FileOther.FILETYPE.CONFIG;
|
||||||
|
List<Map<?, ?>> override_map = config.getMapList("Overrides");
|
||||||
|
for (Map<?, ?> m : override_map)
|
||||||
|
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
||||||
|
overriden.put(entry.getKey().toString(), entry.getValue().toString());
|
||||||
|
if (getPl().getSettings().isDebug())
|
||||||
|
getPl().getLogger().info("- Override '" + entry.getKey() + "' -> '" + entry.getValue() + "' added");
|
||||||
|
if (Bukkit.getWorld(entry.getValue().toString()) == null)
|
||||||
|
getPl().getLogger().warning("The world `" + entry.getValue() + "` doesn't seem to exist! Please update `" + entry.getKey() + "'s` override! Maybe there are capital letters?");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
//No Overrides
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void loadWorldTypes(@NotNull HashMap<String, WORLD_TYPE> world_type) {
|
||||||
|
BetterRTP.debug("Loading World Types...");
|
||||||
|
world_type.clear();
|
||||||
|
try {
|
||||||
|
FileOther.FILETYPE config = FileOther.FILETYPE.CONFIG;
|
||||||
|
//for (World world : Bukkit.getWorlds())
|
||||||
|
// world_type.put(world.getName(), WORLD_TYPE.NORMAL);
|
||||||
|
List<Map<?, ?>> world_map = config.getMapList("WorldType");
|
||||||
|
for (Map<?, ?> m : world_map)
|
||||||
|
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
||||||
|
//if (world_type.containsKey(entry.getKey())) {
|
||||||
|
try {
|
||||||
|
String world = entry.getKey().toString();
|
||||||
|
WORLD_TYPE type = WORLD_TYPE.valueOf(entry.getValue().toString().toUpperCase());
|
||||||
|
world_type.put(world, type);
|
||||||
|
BetterRTP.debug("- World Type for '" + world + "' set to '" + type + "'");
|
||||||
|
} catch(IllegalArgumentException e) {
|
||||||
|
StringBuilder valids = new StringBuilder();
|
||||||
|
for (WORLD_TYPE type : WORLD_TYPE.values())
|
||||||
|
valids.append(type.name()).append(", ");
|
||||||
|
valids.replace(valids.length() - 2, valids.length(), "");
|
||||||
|
getPl().getLogger().severe("World Type for '" + entry.getKey() + "' is INVALID '" + entry.getValue() +
|
||||||
|
"'. Valid ID's are: " + valids);
|
||||||
|
//Wrong rtp world type
|
||||||
|
}
|
||||||
|
//}/* else {
|
||||||
|
// if (getPl().getSettings().debug)
|
||||||
|
// getPl().getLogger().info("- World Type failed for '" + entry.getKey() + "' is it loaded?");
|
||||||
|
//}*/
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
//No World Types
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void loadLocations(@NotNull HashMap<String, RTPWorld> worlds) {
|
||||||
|
worlds.clear();
|
||||||
|
FileOther.FILETYPE config = FileOther.FILETYPE.LOCATIONS;
|
||||||
|
if (!BetterRTP.getInstance().getSettings().isLocationEnabled())
|
||||||
|
return;
|
||||||
|
BetterRTP.debug("Loading Locations...");
|
||||||
|
List<Map<?, ?>> map = config.getMapList("Locations");
|
||||||
|
for (Map<?, ?> m : map)
|
||||||
|
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
||||||
|
WorldLocation location = new WorldLocation(entry.getKey().toString());
|
||||||
|
if (location.isValid()) {
|
||||||
|
worlds.put(entry.getKey().toString(), location);
|
||||||
|
BetterRTP.debug("- Location '" + entry.getKey() + "' registered");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void loadPermissionGroups(@NotNull HashMap<String, PermissionGroup> permissionGroup) {
|
||||||
|
permissionGroup.clear();
|
||||||
|
FileOther.FILETYPE config = FileOther.FILETYPE.CONFIG;
|
||||||
|
if (!getPl().getSettings().isPermissionGroupEnabled())
|
||||||
|
return;
|
||||||
|
BetterRTP.debug("Loading Permission Groups...");
|
||||||
|
try {
|
||||||
|
List<Map<?, ?>> map = config.getMapList("PermissionGroup.Groups");
|
||||||
|
for (Map<?, ?> m : map)
|
||||||
|
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
||||||
|
String group = entry.getKey().toString();
|
||||||
|
permissionGroup.put(group, new PermissionGroup(entry));
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
//No Permission Groups
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BetterRTP getPl() {
|
||||||
|
return BetterRTP.getInstance();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_FailedEvent;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_FindLocationEvent;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP_Check;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.QueueData;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.QueueHandler;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.RandomLocation;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldPlayer;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.versions.AsyncHandler;
|
||||||
|
|
||||||
|
public class RTPPlayer {
|
||||||
|
|
||||||
|
@Getter private final Player player;
|
||||||
|
private final RTP settings;
|
||||||
|
@Getter WorldPlayer worldPlayer;
|
||||||
|
@Getter RTP_TYPE type;
|
||||||
|
@Getter int attempts;
|
||||||
|
//List<Location> attemptedLocations = new ArrayList<>();
|
||||||
|
|
||||||
|
RTPPlayer(Player player, RTP settings, WorldPlayer worldPlayer, RTP_TYPE type) {
|
||||||
|
this.player = player;
|
||||||
|
this.settings = settings;
|
||||||
|
this.worldPlayer = worldPlayer;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
void randomlyTeleport(CommandSender sendi) {
|
||||||
|
if (attempts >= settings.maxAttempts) //Cancel out, too many tries
|
||||||
|
metMax(sendi, player);
|
||||||
|
else { //Try again to find a safe location
|
||||||
|
//Find a location from another Plugin
|
||||||
|
RTP_FindLocationEvent event = new RTP_FindLocationEvent(this); //Find an external plugin location
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
|
//Async Location finder
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
randomlyTeleport(sendi);
|
||||||
|
attempts++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AsyncHandler.async(() -> {
|
||||||
|
Location loc;
|
||||||
|
if (event.getLocation() != null) // && WorldPlayer.checkIsValid(event.getLocation(), pWorld))
|
||||||
|
loc = event.getLocation();
|
||||||
|
else {
|
||||||
|
QueueData queueData = QueueHandler.getRandomAsync(worldPlayer);
|
||||||
|
//BetterRTP.getInstance().getLogger().warning("Center x " + worldPlayer.getCenterX());
|
||||||
|
if (queueData != null)
|
||||||
|
loc = queueData.getLocation();
|
||||||
|
else
|
||||||
|
loc = RandomLocation.generateLocation(worldPlayer);
|
||||||
|
}
|
||||||
|
attempts++; //Add an attempt
|
||||||
|
//Load chunk and find out if safe location (asynchronously)
|
||||||
|
AsyncHandler.sync(() -> {
|
||||||
|
try { //Prior to 1.12 this async chunk will NOT work
|
||||||
|
CompletableFuture<Chunk> chunk = PaperLib.getChunkAtAsync(loc);
|
||||||
|
chunk.thenAccept(result -> {
|
||||||
|
//BetterRTP.debug("Checking location for " + p.getName());
|
||||||
|
attempt(sendi, loc);
|
||||||
|
});
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
//Legacy non-async support
|
||||||
|
attempt(sendi, loc);
|
||||||
|
} catch (Throwable ignored) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void attempt(CommandSender sendi, Location loc) {
|
||||||
|
Location tpLoc;
|
||||||
|
tpLoc = RandomLocation.getSafeLocation(worldPlayer.getWorldtype(), worldPlayer.getWorld(), loc, worldPlayer.getMinY(), worldPlayer.getMaxY(), worldPlayer.getBiomes());
|
||||||
|
//attemptedLocations.add(loc);
|
||||||
|
//Valid location?
|
||||||
|
if (tpLoc != null && checkDepends(tpLoc)) {
|
||||||
|
tpLoc.add(0.5, 0, 0.5); //Center location
|
||||||
|
if (getPl().getEco().charge(player, worldPlayer)) {
|
||||||
|
//Successfully found a safe location, set cooldown and teleport player.
|
||||||
|
if (worldPlayer.getPlayerInfo().isApplyCooldown() && HelperRTP_Check.applyCooldown(player))
|
||||||
|
getPl().getCooldowns().add(player, worldPlayer.getWorld());
|
||||||
|
tpLoc.setYaw(player.getLocation().getYaw());
|
||||||
|
tpLoc.setPitch(player.getLocation().getPitch());
|
||||||
|
AsyncHandler.sync(() -> settings.teleport.sendPlayer(sendi, player, tpLoc, worldPlayer, attempts, type));
|
||||||
|
} else {
|
||||||
|
if (worldPlayer.getPlayerInfo().applyCooldown)
|
||||||
|
getPl().getCooldowns().removeCooldown(player, worldPlayer.getWorld());
|
||||||
|
getPl().getPInfo().getRtping().remove(player);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
randomlyTeleport(sendi);
|
||||||
|
QueueHandler.remove(loc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compressed code for MaxAttempts being met
|
||||||
|
private void metMax(CommandSender sendi, Player p) {
|
||||||
|
settings.teleport.failedTeleport(p, sendi);
|
||||||
|
getPl().getCooldowns().removeCooldown(p, worldPlayer.getWorld());
|
||||||
|
getPl().getPInfo().getRtping().remove(p);
|
||||||
|
//RTP Failed Event
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(new RTP_FailedEvent(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param loc Location to check
|
||||||
|
* @return True if the location is valid
|
||||||
|
*/
|
||||||
|
public static boolean checkDepends(Location loc) {
|
||||||
|
return RTPPluginValidation.checkLocation(loc);
|
||||||
|
}
|
||||||
|
|
||||||
|
private BetterRTP getPl() {
|
||||||
|
return BetterRTP.getInstance();
|
||||||
|
}
|
||||||
|
}
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.depends.regionPlugins.REGIONPLUGINS;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
public class RTPPluginValidation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param loc Location to check
|
||||||
|
* @return True if valid location
|
||||||
|
*/
|
||||||
|
public static boolean checkLocation(Location loc) {
|
||||||
|
for (REGIONPLUGINS validators : REGIONPLUGINS.values())
|
||||||
|
if (!validators.getValidator().check(loc))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
+76
@@ -0,0 +1,76 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NonNull;
|
||||||
|
import lombok.Setter;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldLocation;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class RTPSetupInformation {
|
||||||
|
//Will provide information to setup an RTP attempt
|
||||||
|
@Getter @Setter private World world;
|
||||||
|
@Getter @NonNull private final CommandSender sender;
|
||||||
|
@Getter @Nullable private final Player player;
|
||||||
|
@Getter private final boolean personalized;
|
||||||
|
@Getter @Setter @Nullable private List<String> biomes;
|
||||||
|
@Getter @Setter @Nullable private WorldLocation location;
|
||||||
|
@Getter @Nullable private final RTP_TYPE rtp_type;
|
||||||
|
@Getter private final RTP_PlayerInfo playerInfo;
|
||||||
|
|
||||||
|
public RTPSetupInformation(@Nullable World world,
|
||||||
|
@NonNull CommandSender sender,
|
||||||
|
@Nullable Player player,
|
||||||
|
boolean personalized) {
|
||||||
|
this(world, sender, player, personalized, null, false, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RTPSetupInformation(@Nullable World world,
|
||||||
|
@NonNull CommandSender sender,
|
||||||
|
@Nullable Player player,
|
||||||
|
boolean personalized,
|
||||||
|
@Nullable List<String> biomes,
|
||||||
|
boolean delay,
|
||||||
|
@Nullable RTP_TYPE rtp_type,
|
||||||
|
@Nullable WorldLocation location) {
|
||||||
|
this(world, sender, player, personalized, biomes, delay, rtp_type, location, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RTPSetupInformation(@Nullable World world,
|
||||||
|
@NonNull CommandSender sender,
|
||||||
|
@Nullable Player player,
|
||||||
|
boolean personalized,
|
||||||
|
@Nullable List<String> biomes,
|
||||||
|
boolean delay,
|
||||||
|
@Nullable RTP_TYPE rtp_type,
|
||||||
|
@Nullable WorldLocation location,
|
||||||
|
boolean cooldown) {
|
||||||
|
this(world, sender, player, personalized, biomes, rtp_type, location, new RTP_PlayerInfo(delay, cooldown));
|
||||||
|
}
|
||||||
|
|
||||||
|
public RTPSetupInformation(@Nullable World world,
|
||||||
|
@NonNull CommandSender sender,
|
||||||
|
@Nullable Player player,
|
||||||
|
boolean personalized,
|
||||||
|
@Nullable List<String> biomes,
|
||||||
|
@Nullable RTP_TYPE rtp_type,
|
||||||
|
@Nullable WorldLocation location,
|
||||||
|
RTP_PlayerInfo playerInfo) {
|
||||||
|
this.world = world;
|
||||||
|
this.sender = sender;
|
||||||
|
this.player = player;
|
||||||
|
this.personalized = personalized;
|
||||||
|
this.biomes = biomes;
|
||||||
|
this.rtp_type = rtp_type;
|
||||||
|
this.location = location;
|
||||||
|
if (this.world == null) {
|
||||||
|
if (player != null)
|
||||||
|
this.world = player.getWorld();
|
||||||
|
}
|
||||||
|
this.playerInfo = playerInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
+168
@@ -0,0 +1,168 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.effects.RTPEffect_Titles;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.effects.RTPEffects;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_TeleportEvent;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_TeleportPostEvent;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.customEvents.RTP_TeleportPreEvent;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesCore;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldPlayer;
|
||||||
|
|
||||||
|
//---
|
||||||
|
//Credit to @PaperMC for PaperLib - https://github.com/PaperMC/PaperLib
|
||||||
|
//
|
||||||
|
//Use of asyncronous chunk loading and teleporting
|
||||||
|
//---
|
||||||
|
|
||||||
|
public class RTPTeleport {
|
||||||
|
|
||||||
|
private final RTPEffects effects = new RTPEffects();
|
||||||
|
|
||||||
|
void load() {
|
||||||
|
effects.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
// void cancel(Player p) { //Cancel loading chunks/teleporting
|
||||||
|
// if (!playerLoads.containsKey(p)) return;
|
||||||
|
// List<CompletableFuture<Chunk>> asyncChunks = playerLoads.get(p);
|
||||||
|
// CompletableFuture.allOf(asyncChunks.toArray(new CompletableFuture[] {})).cancel(true);
|
||||||
|
// }
|
||||||
|
|
||||||
|
void sendPlayer(final CommandSender sendi, final Player p, final Location location, final WorldPlayer wPlayer,
|
||||||
|
final int attempts, RTP_TYPE type) throws NullPointerException {
|
||||||
|
Location oldLoc = p.getLocation();
|
||||||
|
loadingTeleport(p, sendi); //Send loading message to player who requested
|
||||||
|
//List<CompletableFuture<Chunk>> asyncChunks = getChunks(location); //Get a list of chunks
|
||||||
|
//playerLoads.put(p, asyncChunks);
|
||||||
|
/*CompletableFuture.allOf(asyncChunks.toArray(new CompletableFuture[] {})).thenRun(() -> { //Async chunk load
|
||||||
|
new BukkitRunnable() { //Run synchronously
|
||||||
|
@Override
|
||||||
|
public void run() {*/
|
||||||
|
try {
|
||||||
|
RTP_TeleportEvent event = new RTP_TeleportEvent(p, location, wPlayer.getWorldtype());
|
||||||
|
getPl().getServer().getPluginManager().callEvent(event);
|
||||||
|
Location loc = event.getLocation();
|
||||||
|
PaperLib.teleportAsync(p, loc).thenRun(new BukkitRunnable() { //Async teleport
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
afterTeleport(p, loc, wPlayer, attempts, oldLoc, type);
|
||||||
|
if (sendi != p) //Tell player who requested that the player rtp'd
|
||||||
|
sendSuccessMsg(sendi, p.getName(), loc, wPlayer, false, attempts);
|
||||||
|
getPl().getPInfo().getRtping().remove(p); //No longer rtp'ing
|
||||||
|
//Save respawn location if first join
|
||||||
|
if (type == RTP_TYPE.JOIN) //RTP Type was Join
|
||||||
|
if (BetterRTP.getInstance().getSettings().isRtpOnFirstJoin_SetAsRespawn()) //Save as respawn is enabled
|
||||||
|
p.setBedSpawnLocation(loc, true); //True means to force a respawn even without a valid bed
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
getPl().getPInfo().getRtping().remove(p); //No longer rtp'ing (errored)
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Effects
|
||||||
|
|
||||||
|
public void afterTeleport(Player p, Location loc, WorldPlayer wPlayer, int attempts, Location oldLoc, RTP_TYPE type) {
|
||||||
|
//Only a successful rtp should run this OR '/rtp test'
|
||||||
|
effects.getSounds().playTeleport(p);
|
||||||
|
effects.getParticles().display(p);
|
||||||
|
effects.getPotions().giveEffects(p);
|
||||||
|
effects.getTitles().showTitle(RTPEffect_Titles.RTP_TITLE_TYPE.TELEPORT, p, loc, attempts, 0);
|
||||||
|
if (effects.getTitles().sendMsg(RTPEffect_Titles.RTP_TITLE_TYPE.TELEPORT))
|
||||||
|
sendSuccessMsg(p, p.getName(), loc, wPlayer, true, attempts);
|
||||||
|
getPl().getServer().getPluginManager().callEvent(new RTP_TeleportPostEvent(p, loc, oldLoc, wPlayer, type));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean beforeTeleportInstant(CommandSender sendi, Player p) {
|
||||||
|
RTP_TeleportPreEvent event = new RTP_TeleportPreEvent(p);
|
||||||
|
getPl().getServer().getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled()) {
|
||||||
|
effects.getSounds().playDelay(p);
|
||||||
|
effects.getTitles().showTitle(RTPEffect_Titles.RTP_TITLE_TYPE.NODELAY, p, p.getLocation(), 0, 0);
|
||||||
|
if (effects.getTitles().sendMsg(RTPEffect_Titles.RTP_TITLE_TYPE.NODELAY))
|
||||||
|
MessagesCore.SUCCESS_TELEPORT.send(sendi);
|
||||||
|
}
|
||||||
|
return event.isCancelled();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean beforeTeleportDelay(Player p, int delay) { //Only Delays should call this
|
||||||
|
RTP_TeleportPreEvent event = new RTP_TeleportPreEvent(p);
|
||||||
|
getPl().getServer().getPluginManager().callEvent(event);
|
||||||
|
if (!event.isCancelled()) {
|
||||||
|
effects.getSounds().playDelay(p);
|
||||||
|
effects.getTitles().showTitle(RTPEffect_Titles.RTP_TITLE_TYPE.DELAY, p, p.getLocation(), 0, delay);
|
||||||
|
if (effects.getTitles().sendMsg(RTPEffect_Titles.RTP_TITLE_TYPE.DELAY))
|
||||||
|
MessagesCore.DELAY.send(p, delay);
|
||||||
|
}
|
||||||
|
return event.isCancelled();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelledTeleport(Player p) { //Only Delays should call this
|
||||||
|
effects.getTitles().showTitle(RTPEffect_Titles.RTP_TITLE_TYPE.CANCEL, p, p.getLocation(), 0, 0);
|
||||||
|
if (effects.getTitles().sendMsg(RTPEffect_Titles.RTP_TITLE_TYPE.CANCEL))
|
||||||
|
MessagesCore.MOVED.send(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadingTeleport(Player p, CommandSender sendi) {
|
||||||
|
effects.getTitles().showTitle(RTPEffect_Titles.RTP_TITLE_TYPE.LOADING, p, p.getLocation(), 0, 0);
|
||||||
|
if (effects.getTitles().sendMsg(RTPEffect_Titles.RTP_TITLE_TYPE.LOADING) && sendStatusMessage()) { //Show msg if enabled or if not same player
|
||||||
|
if (p == sendi)
|
||||||
|
MessagesCore.SUCCESS_LOADING.send(sendi);
|
||||||
|
MessagesCore.SUCCESS_LOADING.send(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void failedTeleport(Player p, CommandSender sendi) {
|
||||||
|
effects.getTitles().showTitle(RTPEffect_Titles.RTP_TITLE_TYPE.FAILED, p, p.getLocation(), 0, 0);
|
||||||
|
if (effects.getTitles().sendMsg(RTPEffect_Titles.RTP_TITLE_TYPE.FAILED))
|
||||||
|
if (p == sendi)
|
||||||
|
MessagesCore.FAILED_NOTSAFE.send(p, BetterRTP.getInstance().getRTP().maxAttempts);
|
||||||
|
else
|
||||||
|
MessagesCore.OTHER_NOTSAFE.send(sendi, Arrays.asList(
|
||||||
|
BetterRTP.getInstance().getRTP().maxAttempts,
|
||||||
|
p.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Processing
|
||||||
|
|
||||||
|
/*private List<CompletableFuture<Chunk>> getChunks(Location loc) { //List all chunks in range to load
|
||||||
|
List<CompletableFuture<Chunk>> asyncChunks = new ArrayList<>();
|
||||||
|
int range = Math.round(Math.max(0, Math.min(16, getPl().getSettings().getPreloadRadius())));
|
||||||
|
for (int x = -range; x <= range; x++)
|
||||||
|
for (int z = -range; z <= range; z++) {
|
||||||
|
Location locLoad = new Location(loc.getWorld(), loc.getX() + (x * 16), loc.getY(), loc.getZ() + (z * 16));
|
||||||
|
CompletableFuture<Chunk> chunk = PaperLib.getChunkAtAsync(locLoad, true);
|
||||||
|
asyncChunks.add(chunk);
|
||||||
|
}
|
||||||
|
return asyncChunks;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
private void sendSuccessMsg(CommandSender sendi, String player, Location loc, WorldPlayer wPlayer, boolean sameAsPlayer, int attempts) {
|
||||||
|
if (sameAsPlayer) {
|
||||||
|
if (wPlayer.getPrice() == 0 || PermissionNode.BYPASS_ECONOMY.check(sendi))
|
||||||
|
MessagesCore.SUCCESS_BYPASS.send(sendi, Arrays.asList(loc, attempts));
|
||||||
|
else
|
||||||
|
MessagesCore.SUCCESS_PAID.send(sendi, Arrays.asList(loc, wPlayer, attempts));
|
||||||
|
} else
|
||||||
|
MessagesCore.OTHER_SUCCESS.send(sendi, Arrays.asList(loc, player, attempts));
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean sendStatusMessage() {
|
||||||
|
return getPl().getSettings().isStatusMessages();
|
||||||
|
}
|
||||||
|
|
||||||
|
private BetterRTP getPl() {
|
||||||
|
return BetterRTP.getInstance();
|
||||||
|
}
|
||||||
|
}
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesCore;
|
||||||
|
|
||||||
|
public enum RTP_ERROR_REQUEST_REASON {
|
||||||
|
IS_RTPING(MessagesCore.ALREADY),
|
||||||
|
NO_PERMISSION(MessagesCore.NOPERMISSION_WORLD),
|
||||||
|
WORLD_DISABLED(MessagesCore.DISABLED_WORLD),
|
||||||
|
COOLDOWN(MessagesCore.COOLDOWN),
|
||||||
|
PRICE_ECONOMY(MessagesCore.FAILED_PRICE),
|
||||||
|
PRICE_HUNGER(MessagesCore.FAILED_HUNGER);
|
||||||
|
|
||||||
|
@Getter private final MessagesCore msg;
|
||||||
|
|
||||||
|
RTP_ERROR_REQUEST_REASON(MessagesCore msg) {
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
+43
@@ -0,0 +1,43 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
public class RTP_PlayerInfo {
|
||||||
|
|
||||||
|
@Getter @Setter boolean
|
||||||
|
applyDelay,
|
||||||
|
applyCooldown,
|
||||||
|
checkCooldown,
|
||||||
|
takeMoney,
|
||||||
|
takeHunger;
|
||||||
|
|
||||||
|
public RTP_PlayerInfo() {
|
||||||
|
this(true, true, true, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RTP_PlayerInfo(boolean applyDelay, boolean applyCooldown) {
|
||||||
|
this(applyDelay, applyCooldown, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RTP_PlayerInfo(boolean applyDelay, boolean applyCooldown, boolean checkCooldown) {
|
||||||
|
this(applyDelay, applyCooldown, checkCooldown, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RTP_PlayerInfo(boolean applyDelay,
|
||||||
|
boolean applyCooldown,
|
||||||
|
boolean checkCooldown,
|
||||||
|
boolean takeMoney,
|
||||||
|
boolean takeHunger) {
|
||||||
|
this.applyDelay = applyDelay;
|
||||||
|
this.applyCooldown = applyCooldown;
|
||||||
|
this.checkCooldown = checkCooldown;
|
||||||
|
this.takeMoney = takeMoney;
|
||||||
|
this.takeHunger = takeHunger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum RTP_PLAYERINFO_FLAG {
|
||||||
|
NODELAY, NOCOOLDOWN, IGNORECOOLDOWN, IGNOREMONEY, IGNOREHUNGER;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||||
|
|
||||||
|
public enum RTP_SHAPE {
|
||||||
|
SQUARE, //Square shaped location finder
|
||||||
|
CIRCLE //Circled area location finder
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||||
|
|
||||||
|
public enum RTP_TYPE {
|
||||||
|
COMMAND, //Player executed command
|
||||||
|
FORCED, //Player was forced to rtp (/rtp player <player>)
|
||||||
|
RESPAWN, //Player respawned and world has RTPOnDeath enabled
|
||||||
|
JOIN, //Player joined and was rtp'd automatically
|
||||||
|
TEST, //Player was just testing out effects
|
||||||
|
ADDON, //Player RTP'd from the external addons plugin
|
||||||
|
ADDON_PORTAL, //Player RTP'd from the external addons (Portals)
|
||||||
|
ADDON_MAGICSTICK, //Player RTP'd from the external addons (MagicStick)
|
||||||
|
}
|
||||||
+140
@@ -0,0 +1,140 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.rtp.effects;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.versions.AsyncHandler;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
import xyz.xenondevs.particle.ParticleEffect;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
//---
|
||||||
|
//Credit to @ByteZ1337 for ParticleLib - https://github.com/ByteZ1337/ParticleLib
|
||||||
|
//
|
||||||
|
//Use of particle creation
|
||||||
|
//---
|
||||||
|
|
||||||
|
public class RTPEffect_Particles {
|
||||||
|
|
||||||
|
private boolean enabled;
|
||||||
|
private final List<ParticleEffect> effects = new ArrayList<>();
|
||||||
|
private String shape;
|
||||||
|
private final int precision = 16;
|
||||||
|
|
||||||
|
//Some particles act very differently and might not care how they are shaped before animating, ex: EXPLOSION_NORMAL
|
||||||
|
public static String[] shapeTypes = {
|
||||||
|
"SCAN", //Body scan
|
||||||
|
"EXPLODE", //Make an explosive entrance
|
||||||
|
"TELEPORT" //Startrek type of portal
|
||||||
|
};
|
||||||
|
|
||||||
|
void load() {
|
||||||
|
FileOther.FILETYPE config = getPl().getFiles().getType(FileOther.FILETYPE.EFFECTS);
|
||||||
|
enabled = config.getBoolean("Particles.Enabled");
|
||||||
|
if (!enabled) return;
|
||||||
|
//Enabled? Load all this junk
|
||||||
|
List<String> types;
|
||||||
|
if (config.isList("Particles.Type"))
|
||||||
|
types = config.getStringList("Particles.Type");
|
||||||
|
else {
|
||||||
|
types = new ArrayList<>();
|
||||||
|
types.add(config.getString("Particles.Type"));
|
||||||
|
}
|
||||||
|
String typeTrying = null;
|
||||||
|
try {
|
||||||
|
for (String type : types) {
|
||||||
|
typeTrying = type;
|
||||||
|
effects.add(ParticleEffect.valueOf(type.toUpperCase()));
|
||||||
|
}
|
||||||
|
} catch (IllegalArgumentException | NullPointerException e) {
|
||||||
|
effects.clear();
|
||||||
|
effects.add(ParticleEffect.ASH);
|
||||||
|
getPl().getLogger().severe("The particle '" + typeTrying + "' doesn't exist! Default particle enabled... " +
|
||||||
|
"Try using '/rtp info particles' to get a list of available particles");
|
||||||
|
} catch (ExceptionInInitializerError | NoClassDefFoundError e2) {
|
||||||
|
effects.clear();
|
||||||
|
getPl().getLogger().severe("The particle '" + typeTrying + "' created a fatal error when loading particles! Your MC version isn't supported!");
|
||||||
|
enabled = false;
|
||||||
|
}
|
||||||
|
shape = config.getString("Particles.Shape").toUpperCase();
|
||||||
|
if (!Arrays.asList(shapeTypes).contains(shape)) {
|
||||||
|
getPl().getLogger().severe("The particle shape '" + shape + "' doesn't exist! Default particle shape enabled...");
|
||||||
|
getPl().getLogger().severe("Try using '/rtp info shapes' to get a list of shapes, or: " + Arrays.asList(shapeTypes));
|
||||||
|
shape = shapeTypes[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void display(Player p) {
|
||||||
|
if (!enabled) return;
|
||||||
|
AsyncHandler.async(() -> {
|
||||||
|
try { //Incase the library errors out
|
||||||
|
switch (shape) {
|
||||||
|
case "TELEPORT":
|
||||||
|
partTeleport(p);
|
||||||
|
break;
|
||||||
|
case "EXPLODE":
|
||||||
|
partExplosion(p);
|
||||||
|
break;
|
||||||
|
default: //Super redundant, but... just future proofing
|
||||||
|
case "SCAN":
|
||||||
|
partScan(p);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void partScan(Player p) { //Particles with negative velocity
|
||||||
|
Location loc = p.getLocation().add(new Vector(0, 1.75, 0));
|
||||||
|
for (int index = 1; index < precision; index++) {
|
||||||
|
Vector vec = getVecCircle(index);
|
||||||
|
for (ParticleEffect effect : effects) {
|
||||||
|
effect.display(loc.clone().add(vec), new Vector(0, -0.125, 0), .15f, 0, null, p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void partTeleport(Player p) { //Static particles in a shape
|
||||||
|
Location loc = p.getLocation();
|
||||||
|
for (float y = 2.5f; y > 0; y -= .25f)
|
||||||
|
for (int index = 1; index < precision; index++) {
|
||||||
|
//double yran = ran.nextGaussian() * pHeight;
|
||||||
|
Vector vec = getVecCircle(index).add(new Vector(0, y, 0));
|
||||||
|
for (ParticleEffect effect : effects) {
|
||||||
|
effect.display(loc.clone().add(vec), p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void partExplosion(Player p) { //Particles with a shape and forward velocity
|
||||||
|
Location loc = p.getLocation().add(new Vector(0, 1, 0));
|
||||||
|
for (int index = 1; index < precision; index++) {
|
||||||
|
Vector vec = getVecCircle(index);
|
||||||
|
for (ParticleEffect effect : effects) {
|
||||||
|
effect.display(loc.clone().add(vec), vec, 1.5f, 0, null, p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector getVecCircle(int index) {
|
||||||
|
double p1 = (index * Math.PI) / (precision / 2);
|
||||||
|
double p2 = (index - 1) * Math.PI / (precision / 2);
|
||||||
|
//Positions
|
||||||
|
int radius = 3;
|
||||||
|
double x1 = Math.cos(p1) * radius;
|
||||||
|
double x2 = Math.cos(p2) * radius;
|
||||||
|
double z1 = Math.sin(p1) * radius;
|
||||||
|
double z2 = Math.sin(p2) * radius;
|
||||||
|
return new Vector(x2 - x1, 0, z2 - z1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private BetterRTP getPl() {
|
||||||
|
return BetterRTP.getInstance();
|
||||||
|
}
|
||||||
|
}
|
||||||
+73
@@ -0,0 +1,73 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.rtp.effects;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.player.HelperPlayer;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.player.playerdata.PlayerData;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.versions.AsyncHandler;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class RTPEffect_Potions { //Potions AND Invincibility
|
||||||
|
|
||||||
|
private boolean potionEnabled;
|
||||||
|
private final HashMap<PotionEffectType, Integer[]> potionEffects = new HashMap<>();
|
||||||
|
private boolean invincibleEnabled;
|
||||||
|
private int invincibleTime;
|
||||||
|
|
||||||
|
void load() {
|
||||||
|
potionEffects.clear();
|
||||||
|
FileOther.FILETYPE config = FileOther.FILETYPE.EFFECTS;
|
||||||
|
//Invincible
|
||||||
|
invincibleEnabled = config.getBoolean("Invincible.Enabled");
|
||||||
|
if (invincibleEnabled)
|
||||||
|
invincibleTime = config.getInt("Invincible.Seconds");
|
||||||
|
|
||||||
|
//Potions
|
||||||
|
potionEnabled = config.getBoolean("Potions.Enabled");
|
||||||
|
if (potionEnabled) {
|
||||||
|
List<String> list = config.getStringList("Potions.Types");
|
||||||
|
for (String p : list) {
|
||||||
|
String[] ary = p.replaceAll(" ", "").split(":");
|
||||||
|
String type = ary[0].trim();
|
||||||
|
PotionEffectType effect = PotionEffectType.getByName(type);
|
||||||
|
if (effect != null) {
|
||||||
|
try {
|
||||||
|
int duration = ary.length >= 2 ? Integer.parseInt(ary[1]) : 60;
|
||||||
|
int amplifier = ary.length >= 3 ? Integer.parseInt(ary[2]) : 1;
|
||||||
|
potionEffects.put(effect, new Integer[] {duration, amplifier});
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
BetterRTP.getInstance().getLogger().info("The potion duration or amplifier `" + ary[1] + "` is not an integer. Effect was removed!");
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
BetterRTP.getInstance().getLogger().info("The potion effect `" + type + "` does not exist! " +
|
||||||
|
"Please fix or remove this potion effect! Try '/rtp info potion_effects' to get a list of valid effects!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void giveEffects(Player p) {
|
||||||
|
AsyncHandler.syncAtEntity(p, () -> {
|
||||||
|
PlayerData data = HelperPlayer.getData(p);
|
||||||
|
if (data == null) return;
|
||||||
|
if (invincibleEnabled)
|
||||||
|
data.setInvincibleEndTime(System.currentTimeMillis() + (invincibleTime * 1000L));
|
||||||
|
if (potionEnabled) {
|
||||||
|
List<PotionEffect> effects = new ArrayList<>();
|
||||||
|
for (PotionEffectType e : potionEffects.keySet()) {
|
||||||
|
Integer[] mods = potionEffects.get(e);
|
||||||
|
int duration = mods[0];
|
||||||
|
int amplifier = mods[1];
|
||||||
|
effects.add(new PotionEffect(e, duration, amplifier, false, false));
|
||||||
|
}
|
||||||
|
p.addPotionEffects(effects);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+70
@@ -0,0 +1,70 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.rtp.effects;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
|
import com.comphenix.protocol.ProtocolManager;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.packets.WrapperPlayServerNamedSoundEffect;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class RTPEffect_Sounds {
|
||||||
|
|
||||||
|
private boolean enabled;
|
||||||
|
private String soundTeleport, soundDelay;
|
||||||
|
|
||||||
|
void load() {
|
||||||
|
FileOther.FILETYPE config = FileOther.FILETYPE.EFFECTS;
|
||||||
|
enabled = config.getBoolean("Sounds.Enabled");
|
||||||
|
if (enabled) {
|
||||||
|
soundTeleport = config.getString("Sounds.Success");
|
||||||
|
soundDelay = config.getString("Sounds.Delay");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playTeleport(Player p) {
|
||||||
|
if (!enabled)
|
||||||
|
return;
|
||||||
|
if (soundTeleport != null) {
|
||||||
|
playSound(p.getLocation(), p, soundTeleport);
|
||||||
|
//p.playSound(p.getLocation(), soundTeleport, 1F, 1F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playDelay(Player p) {
|
||||||
|
if (!enabled) return;
|
||||||
|
if (soundDelay != null) {
|
||||||
|
playSound(p.getLocation(), p, soundDelay);
|
||||||
|
//p.playSound(p.getLocation(), soundDelay, 1F, 1F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void playSound(Location loc, Player p, String sound) {
|
||||||
|
if (BetterRTP.getInstance().getSettings().isProtocolLibSounds()) {
|
||||||
|
try {
|
||||||
|
ProtocolManager pm = ProtocolLibrary.getProtocolManager();
|
||||||
|
WrapperPlayServerNamedSoundEffect packet = new WrapperPlayServerNamedSoundEffect(pm.createPacket(PacketType.Play.Server.NAMED_SOUND_EFFECT));
|
||||||
|
packet.setSoundName(sound);
|
||||||
|
packet.setEffectPositionX(loc.getBlockX());
|
||||||
|
packet.setEffectPositionY(loc.getBlockY());
|
||||||
|
packet.setEffectPositionZ(loc.getBlockZ());
|
||||||
|
packet.sendPacket(p);
|
||||||
|
} catch (NoClassDefFoundError | Exception e) {
|
||||||
|
BetterRTP.getInstance().getLogger().severe("ProtocolLib Sounds is enabled in the effects.yml file, but no ProtocolLib plugin was found!");
|
||||||
|
p.playSound(p.getLocation(), getSound(sound), 1F, 1F);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
p.playSound(p.getLocation(), getSound(sound), 1F, 1F);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Sound getSound(String sound) {
|
||||||
|
try {
|
||||||
|
return Sound.valueOf(sound.toUpperCase());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
BetterRTP.getInstance().getLogger().info("The sound '" + sound + "' is invalid!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+76
@@ -0,0 +1,76 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.rtp.effects;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.Message;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class RTPEffect_Titles {
|
||||||
|
|
||||||
|
boolean enabled = false;
|
||||||
|
private final HashMap<RTP_TITLE_TYPE, RTP_TITLE> titles = new HashMap<>();
|
||||||
|
|
||||||
|
void load() {
|
||||||
|
titles.clear();
|
||||||
|
FileOther.FILETYPE config = FileOther.FILETYPE.EFFECTS;
|
||||||
|
enabled = config.getBoolean("Titles.Enabled");
|
||||||
|
if (enabled)
|
||||||
|
for (RTP_TITLE_TYPE type : RTP_TITLE_TYPE.values())
|
||||||
|
titles.put(type, new RTP_TITLE(type.path));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showTitle(RTP_TITLE_TYPE type, Player p, Location loc, int attempts, int delay) {
|
||||||
|
if (titles.containsKey(type)) {
|
||||||
|
String title = getPlaceholders(titles.get(type).title, p, loc, attempts, delay);
|
||||||
|
String sub = getPlaceholders(titles.get(type).subTitle, p, loc, attempts, delay);
|
||||||
|
show(p, title, sub);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean sendMsg(RTP_TITLE_TYPE type) {
|
||||||
|
return titles.containsKey(type) && titles.get(type).send_message || !enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getPlaceholders(String str, Player p, Location loc, int attempts, int delay) {
|
||||||
|
return str.replace("%player%", p.getName())
|
||||||
|
.replace("%x%", String.valueOf(loc.getBlockX()))
|
||||||
|
.replace("%y%", String.valueOf(loc.getBlockY()))
|
||||||
|
.replace("%z%", String.valueOf(loc.getBlockZ()))
|
||||||
|
.replace("%attempts%", String.valueOf(attempts))
|
||||||
|
.replace("%time%", String.valueOf(delay));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void show(Player p, String title, String sub) {
|
||||||
|
// int fadeIn = getPl().text.getFadeIn();
|
||||||
|
// int stay = text.getStay();
|
||||||
|
// int fadeOut = text.getFadeOut();
|
||||||
|
title = Message.color(title);
|
||||||
|
sub = Message.color(sub);
|
||||||
|
//Message.smsTitle(p, Arrays.asList(title, sub));
|
||||||
|
p.sendTitle(title, sub);
|
||||||
|
// player.sendTitle(title, subTitle, fadeIn, stay, fadeOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum RTP_TITLE_TYPE {
|
||||||
|
NODELAY("NoDelay"), TELEPORT("Teleport"), DELAY("Delay"), CANCEL("Cancelled"), LOADING("Loading"), FAILED("Failed");
|
||||||
|
final String path;
|
||||||
|
RTP_TITLE_TYPE(String path) {
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class RTP_TITLE {
|
||||||
|
String title, subTitle;
|
||||||
|
boolean send_message;
|
||||||
|
|
||||||
|
RTP_TITLE(String path) {
|
||||||
|
FileOther.FILETYPE config = FileOther.FILETYPE.EFFECTS;
|
||||||
|
title = config.getString("Titles." + path + ".Title");
|
||||||
|
subTitle = config.getString("Titles." + path + ".Subtitle");
|
||||||
|
send_message = config.getBoolean("Titles." + path + ".SendMessage");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.rtp.effects;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
public class RTPEffects {
|
||||||
|
|
||||||
|
@Getter final RTPEffect_Particles particles = new RTPEffect_Particles();
|
||||||
|
@Getter final RTPEffect_Potions potions = new RTPEffect_Potions();
|
||||||
|
@Getter final RTPEffect_Sounds sounds = new RTPEffect_Sounds();
|
||||||
|
@Getter final RTPEffect_Titles titles = new RTPEffect_Titles();
|
||||||
|
|
||||||
|
//public HashMap<Player, List<CompletableFuture<Chunk>>> playerLoads = new HashMap<>();
|
||||||
|
|
||||||
|
public void load() {
|
||||||
|
particles.load();
|
||||||
|
potions.load();
|
||||||
|
sounds.load();
|
||||||
|
titles.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+87
@@ -0,0 +1,87 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.rtp.packets;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public abstract class AbstractPacket {
|
||||||
|
// The packet we will be modifying
|
||||||
|
protected PacketContainer handle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new strongly typed wrapper for the given packet.
|
||||||
|
*
|
||||||
|
* @param handle - handle to the raw packet data.
|
||||||
|
* @param type - the packet type.
|
||||||
|
*/
|
||||||
|
protected AbstractPacket(PacketContainer handle, PacketType type) {
|
||||||
|
// Make sure we're given a valid packet
|
||||||
|
if (handle == null)
|
||||||
|
throw new IllegalArgumentException("Packet handle cannot be NULL.");
|
||||||
|
if (!Objects.equal(handle.getType(), type))
|
||||||
|
throw new IllegalArgumentException(handle.getHandle()
|
||||||
|
+ " is not a packet of type " + type);
|
||||||
|
|
||||||
|
this.handle = handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a handle to the raw packet data.
|
||||||
|
*
|
||||||
|
* @return Raw packet data.
|
||||||
|
*/
|
||||||
|
public PacketContainer getHandle() {
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the current packet to the given receiver.
|
||||||
|
*
|
||||||
|
* @param receiver - the receiver.
|
||||||
|
*/
|
||||||
|
public void sendPacket(Player receiver) {
|
||||||
|
ProtocolLibrary.getProtocolManager().sendServerPacket(receiver, getHandle());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the current packet to all online players.
|
||||||
|
*/
|
||||||
|
public void broadcastPacket() {
|
||||||
|
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getHandle());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simulate receiving the current packet from the given sender.
|
||||||
|
*
|
||||||
|
* @param sender - the sender.
|
||||||
|
* @throws RuntimeException If the packet cannot be received.
|
||||||
|
* @deprecated Misspelled. recieve to receive
|
||||||
|
* @see #receivePacket(Player)
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public void recievePacket(Player sender) {
|
||||||
|
try {
|
||||||
|
ProtocolLibrary.getProtocolManager().receiveClientPacket(sender,
|
||||||
|
getHandle());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Cannot recieve packet.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simulate receiving the current packet from the given sender.
|
||||||
|
*
|
||||||
|
* @param sender - the sender.
|
||||||
|
* @throws RuntimeException if the packet cannot be received.
|
||||||
|
*/
|
||||||
|
public void receivePacket(Player sender) {
|
||||||
|
try {
|
||||||
|
ProtocolLibrary.getProtocolManager().receiveClientPacket(sender,
|
||||||
|
getHandle());
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Cannot receive packet.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+350
@@ -0,0 +1,350 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player.rtp.packets;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
public class WrapperPlayServerNamedSoundEffect extends AbstractPacket {
|
||||||
|
public static final PacketType TYPE = PacketType.Play.Server.NAMED_SOUND_EFFECT;
|
||||||
|
|
||||||
|
public WrapperPlayServerNamedSoundEffect() {
|
||||||
|
super(new PacketContainer(TYPE), TYPE);
|
||||||
|
handle.getModifier().writeDefaults();
|
||||||
|
}
|
||||||
|
|
||||||
|
public WrapperPlayServerNamedSoundEffect(PacketContainer packet) {
|
||||||
|
super(packet, TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of all the named sound effects in Minecraft.
|
||||||
|
* @author Kristian
|
||||||
|
*/
|
||||||
|
public static class NamedSoundEffects {
|
||||||
|
public static final String AMBIENT_WEATHER_RAIN = "ambient.weather.rain";
|
||||||
|
public static final String AMBIENT_WEATHER_THUNDER = "ambient.weather.thunder";
|
||||||
|
public static final String DAMAGE_FALL_BIG = "damage.fallbig";
|
||||||
|
public static final String DAMAGE_FALL_SMALL = "damage.fallsmall";
|
||||||
|
public static final String FIRE_ACTIVE = "fire.fire";
|
||||||
|
public static final String FIRE_IGNITE = "fire.ignite";
|
||||||
|
public static final String LIQUID_LAVA = "liquid.lava";
|
||||||
|
public static final String LIQUID_LAVA_POP = "liquid.lavapop";
|
||||||
|
public static final String LIQUID_SPLASH = "liquid.splash";
|
||||||
|
public static final String LIQUID_WATER = "liquid.water";
|
||||||
|
public static final String MOB_BLAZE_BREATHE = "mob.blaze.breathe";
|
||||||
|
public static final String MOB_BLAZE_DEATH = "mob.blaze.death";
|
||||||
|
public static final String MOB_BLAZE_HIT = "mob.blaze.hit";
|
||||||
|
public static final String MOB_CAT_HISS = "mob.cat.hiss";
|
||||||
|
public static final String MOB_CAT_HITT = "mob.cat.hitt";
|
||||||
|
public static final String MOB_CAT_MEOW = "mob.cat.meow";
|
||||||
|
public static final String MOB_CAT_PURR = "mob.cat.purr";
|
||||||
|
public static final String MOB_CAT_PURREOW = "mob.cat.purreow";
|
||||||
|
public static final String MOB_CHICKEN_HURT = "mob.chicken.hurt";
|
||||||
|
public static final String MOB_CHICKEN_PLOP = "mob.chicken.plop";
|
||||||
|
public static final String MOB_COW_HURT = "mob.cow.hurt";
|
||||||
|
public static final String MOB_CREEPER = "mob.creeper";
|
||||||
|
public static final String MOB_CREEPER_DEATH = "mob.creeperdeath";
|
||||||
|
public static final String MOB_ENDERMEN_DEATH = "mob.endermen.death";
|
||||||
|
public static final String MOB_ENDERMEN_HIT = "mob.endermen.hit";
|
||||||
|
public static final String MOB_ENDERMEN_IDLE = "mob.endermen.idle";
|
||||||
|
public static final String MOB_ENDERMEN_PORTAL = "mob.endermen.portal";
|
||||||
|
public static final String MOB_ENDERMEN_SCREAM = "mob.endermen.scream";
|
||||||
|
public static final String MOB_ENDERMEN_STARE = "mob.endermen.stare";
|
||||||
|
public static final String MOB_GHAST_AFFECTIONATE_SCREAM = "mob.ghast.affectionate scream";
|
||||||
|
public static final String MOB_GHAST_CHARGE = "mob.ghast.charge";
|
||||||
|
public static final String MOB_GHAST_DEATH = "mob.ghast.death";
|
||||||
|
public static final String MOB_GHAST_FIREBALL = "mob.ghast.fireball";
|
||||||
|
public static final String MOB_GHAST_MOAN = "mob.ghast.moan";
|
||||||
|
public static final String MOB_GHAST_SCREAM = "mob.ghast.scream";
|
||||||
|
public static final String MOB_IRONGOLEM_DEATH = "mob.irongolem.death";
|
||||||
|
public static final String MOB_IRONGOLEM_HIT = "mob.irongolem.hit";
|
||||||
|
public static final String MOB_IRONGOLEM_THROW = "mob.irongolem.throw";
|
||||||
|
public static final String MOB_IRONGOLEM_WALK = "mob.irongolem.walk";
|
||||||
|
public static final String MOB_MAGMACUBE_BIG = "mob.magmacube.big";
|
||||||
|
public static final String MOB_MAGMACUBE_JUMP = "mob.magmacube.jump";
|
||||||
|
public static final String MOB_MAGMACUBE_SMALL = "mob.magmacube.small";
|
||||||
|
public static final String MOB_PIGDEATH = "mob.pig.death";
|
||||||
|
public static final String MOB_SILVERFISH_HIT = "mob.silverfish.hit";
|
||||||
|
public static final String MOB_SILVERFISH_KILL = "mob.silverfish.kill";
|
||||||
|
public static final String MOB_SILVERFISH_SAY = "mob.silverfish.say";
|
||||||
|
public static final String MOB_SILVERFISH_STEP = "mob.silverfish.step";
|
||||||
|
public static final String MOB_SKELETON_DEATH = "mob.skeleton.death";
|
||||||
|
public static final String MOB_SKELETON_HURT = "mob.skeleton.hurt";
|
||||||
|
public static final String MOB_SLIMEATTACK = "mob.slime.attack";
|
||||||
|
public static final String MOB_SPIDER_DEATH = "mob.spider.death";
|
||||||
|
public static final String MOB_WOLF_BARK = "mob.wolf.bark";
|
||||||
|
public static final String MOB_WOLF_DEATH = "mob.wolf.death";
|
||||||
|
public static final String MOB_WOLF_GROWL = "mob.wolf.growl";
|
||||||
|
public static final String MOB_WOLF_HOWL = "mob.wolf.howl";
|
||||||
|
public static final String MOB_WOLF_HURT = "mob.wolf.hurt";
|
||||||
|
public static final String MOB_WOLF_PANTING = "mob.wolf.panting";
|
||||||
|
public static final String MOB_WOLF_SHAKE = "mob.wolf.shake";
|
||||||
|
public static final String MOB_WOLF_WHINE = "mob.wolf.whine";
|
||||||
|
public static final String MOB_ZOMBIE_METAL = "mob.zombie.metal";
|
||||||
|
public static final String MOB_ZOMBIE_WOOD = "mob.zombie.wood";
|
||||||
|
public static final String MOB_ZOMBIE_WOODBREAK = "mob.zombie.woodbreak";
|
||||||
|
public static final String MOB_ZOMBIE = "mob.zombie";
|
||||||
|
public static final String MOB_ZOMBIEDEATH = "mob.zombie.death";
|
||||||
|
public static final String MOB_ZOMBIEHURT = "mob.zombie.hurt";
|
||||||
|
public static final String MOB_ZOMBIEPIG_ZPIG = "mob.zombiepig.zpig";
|
||||||
|
public static final String MOB_ZOMBIEPIG_ZPIGANGRY = "mob.zombiepig.zpigangry";
|
||||||
|
public static final String MOB_ZOMBIEPIG_ZPIGDEATH = "mob.zombiepig.zpigdeath";
|
||||||
|
public static final String MOB_ZOMBIEPIG_ZPIGHURT = "mob.zombiepig.zpighurt";
|
||||||
|
public static final String NOTE_BASS = "note.bass";
|
||||||
|
public static final String NOTE_BASS_ATTACK = "note.bassattack";
|
||||||
|
public static final String NOTE_BD = "note.bd";
|
||||||
|
public static final String NOTE_HARP = "note.harp";
|
||||||
|
public static final String NOTE_HAT = "note.hat";
|
||||||
|
public static final String NOTE_PLING = "note.pling";
|
||||||
|
public static final String NOTE_SNARE = "note.snare";
|
||||||
|
public static final String PORTAL_NEAR = "portal.portal";
|
||||||
|
public static final String PORTAL_TRAVEL = "portal.travel";
|
||||||
|
public static final String PORTAL_TRIGGER = "portal.trigger";
|
||||||
|
public static final String RANDOM_BOW = "random.bow";
|
||||||
|
public static final String RANDOM_BOWHIT = "random.bowhit";
|
||||||
|
public static final String RANDOM_BREAK = "random.break";
|
||||||
|
public static final String RANDOM_BREATH = "random.breath";
|
||||||
|
public static final String RANDOM_BURP = "random.burp";
|
||||||
|
public static final String RANDOM_CHESTCLOSED = "random.chestclosed";
|
||||||
|
public static final String RANDOM_CHESTOPEN = "random.chestopen";
|
||||||
|
public static final String RANDOM_CLICK = "random.click";
|
||||||
|
public static final String RANDOM_DOOR_CLOSE = "random.door_close";
|
||||||
|
public static final String RANDOM_DOOR_OPEN = "random.door_open";
|
||||||
|
public static final String RANDOM_DRINK = "random.drink";
|
||||||
|
public static final String RANDOM_EAT = "random.eat";
|
||||||
|
public static final String RANDOM_EXPLODE = "random.explode";
|
||||||
|
public static final String RANDOM_FIZZ = "random.fizz";
|
||||||
|
public static final String RANDOM_FUSE = "random.fuse";
|
||||||
|
public static final String RANDOM_GLASS = "random.glass";
|
||||||
|
public static final String RANDOM_LEVELUP = "random.levelup";
|
||||||
|
public static final String RANDOM_OLD_EXPLODE = "random.old_explode";
|
||||||
|
public static final String RANDOM_ORB = "random.orb";
|
||||||
|
public static final String RANDOM_POP = "random.pop";
|
||||||
|
public static final String RANDOM_SPLASH = "random.splash";
|
||||||
|
public static final String RANDOM_WOOD_CLICK = "random.wood click";
|
||||||
|
public static final String STEP_CLOTH = "step.cloth";
|
||||||
|
public static final String STEP_GRASS = "step.grass";
|
||||||
|
public static final String STEP_GRAVEL = "step.gravel";
|
||||||
|
public static final String STEP_SAND = "step.sand";
|
||||||
|
public static final String STEP_SNOW = "step.snow";
|
||||||
|
public static final String STEP_STONE = "step.stone";
|
||||||
|
public static final String STEP_WOOD = "step.wood";
|
||||||
|
public static final String TILE_PISTON_IN = "tile.piston.in";
|
||||||
|
public static final String TILE_PISTON_OUT = "tile.piston.out";
|
||||||
|
public static final String DAMAGE_HIT = "damage.hit";
|
||||||
|
public static final String DIG_CLOTH = "dig.cloth";
|
||||||
|
public static final String DIG_GRASS = "dig.grass";
|
||||||
|
public static final String DIG_GRAVEL = "dig.gravel";
|
||||||
|
public static final String DIG_SAND = "dig.sand";
|
||||||
|
public static final String DIG_SNOW = "dig.snow";
|
||||||
|
public static final String DIG_STONE = "dig.stone";
|
||||||
|
public static final String DIG_WOOD = "dig.wood";
|
||||||
|
public static final String LIQUID_SWIM = "liquid.swim";
|
||||||
|
public static final String MINECART_BASE = "minecart.base";
|
||||||
|
public static final String MINECART_INSIDE = "minecart.inside";
|
||||||
|
public static final String MOB_CHICKEN_SAY = "mob.chicken.say";
|
||||||
|
public static final String MOB_CHICKEN_STEP = "mob.chicken.step";
|
||||||
|
public static final String MOB_COW_SAY = "mob.cow.say";
|
||||||
|
public static final String MOB_COW_STEP = "mob.cow.step";
|
||||||
|
public static final String MOB_CREEPER_SAY = "mob.creeper.say";
|
||||||
|
public static final String MOB_PIG_DEATH = "mob.pig.death";
|
||||||
|
public static final String MOB_PIG_SAY = "mob.pig.say";
|
||||||
|
public static final String MOB_PIG_STEP = "mob.pig.step";
|
||||||
|
public static final String MOB_SHEEP_SAY = "mob.sheep.say";
|
||||||
|
public static final String MOB_SHEEP_SHEAR = "mob.sheep.shear";
|
||||||
|
public static final String MOB_SHEEP_STEP = "mob.sheep.step";
|
||||||
|
public static final String MOB_SKELETON_SAY = "mob.skeleton.say";
|
||||||
|
public static final String MOB_SKELETON_STEP = "mob.skeleton.step";
|
||||||
|
public static final String MOB_SLIME_ATTACK = "mob.slime.attack";
|
||||||
|
public static final String MOB_SLIME_BIG = "mob.slime.big";
|
||||||
|
public static final String MOB_SLIME_SMALL = "mob.slime.small";
|
||||||
|
public static final String MOB_SPIDER_SAY = "mob.spider.say";
|
||||||
|
public static final String MOB_SPIDER_STEP = "mob.spider.step";
|
||||||
|
public static final String MOB_WOLF_STEP = "mob.wolf.step";
|
||||||
|
public static final String MOB_ZOMBIE_DEATH = "mob.zombie.death";
|
||||||
|
public static final String MOB_ZOMBIE_HURT = "mob.zombie.hurt";
|
||||||
|
public static final String MOB_ZOMBIE_SAY = "mob.zombie.say";
|
||||||
|
public static final String MOB_ZOMBIE_STEP = "mob.zombie.step";
|
||||||
|
public static final String RANDOM_CLASSIC_HURT = "random.classic_hurt";
|
||||||
|
public static final String STEP_LADDER = "step.ladder";
|
||||||
|
public static final String MOB_BAT_DEATH = "mob.bat.death";
|
||||||
|
public static final String MOB_BAT_HURT = "mob.bat.hurt";
|
||||||
|
public static final String MOB_BAT_IDLE = "mob.bat.idle";
|
||||||
|
public static final String MOB_BAT_TAKEOFF = "mob.bat.takeoff";
|
||||||
|
public static final String MOB_ENDERDRAGON_END = "mob.enderdragon.end";
|
||||||
|
public static final String MOB_ENDERDRAGON_GROWL = "mob.enderdragon.growl";
|
||||||
|
public static final String MOB_ENDERDRAGON_HIT = "mob.enderdragon.hit";
|
||||||
|
public static final String MOB_ENDERDRAGON_WINGS = "mob.enderdragon.wings";
|
||||||
|
public static final String MOB_WITHER_DEATH = "mob.wither.death";
|
||||||
|
public static final String MOB_WITHER_HURT = "mob.wither.hurt";
|
||||||
|
public static final String MOB_WITHER_IDLE = "mob.wither.idle";
|
||||||
|
public static final String MOB_WITHER_SHOOT = "mob.wither.shoot";
|
||||||
|
public static final String MOB_WITHER_SPAWN = "mob.wither.spawn";
|
||||||
|
public static final String MOB_ZOMBIE_INFECT = "mob.zombie.infect";
|
||||||
|
public static final String MOB_ZOMBIE_REMEDY = "mob.zombie.remedy";
|
||||||
|
public static final String MOB_ZOMBIE_UNFECT = "mob.zombie.unfect";
|
||||||
|
public static final String RANDOM_ANVIL_BREAK = "random.anvil_break";
|
||||||
|
public static final String RANDOM_ANVIL_LAND = "random.anvil_land";
|
||||||
|
public static final String RANDOM_ANVIL_USE = "random.anvil_use";
|
||||||
|
|
||||||
|
private static String[] values;
|
||||||
|
|
||||||
|
public static String[] values() {
|
||||||
|
if (values == null) {
|
||||||
|
List<String> result = Lists.newArrayList();
|
||||||
|
|
||||||
|
// Get all public fields
|
||||||
|
for (Field field : NamedSoundEffects.class.getFields()) {
|
||||||
|
try {
|
||||||
|
result.add((String) field.get(null));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Cannot read field.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
values = result.toArray(new String[0]);
|
||||||
|
}
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the sound name.
|
||||||
|
* @see {@link NamedSoundEffects}.
|
||||||
|
* @return The current Sound name
|
||||||
|
*/
|
||||||
|
public String getSoundName() {
|
||||||
|
return handle.getStrings().read(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the sound name.
|
||||||
|
* @see {@link NamedSoundEffects}.
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setSoundName(String value) {
|
||||||
|
handle.getStrings().write(0, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the location of the effect.
|
||||||
|
* @param event - the current event.
|
||||||
|
* @return The effect location.
|
||||||
|
*/
|
||||||
|
public Location getEffectPosition(PacketEvent event) {
|
||||||
|
return getEffectPosition(event.getPlayer().getWorld());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the location of the effect.
|
||||||
|
* @param world - the current world.
|
||||||
|
* @return The effect location.
|
||||||
|
*/
|
||||||
|
public Location getEffectPosition(World world) {
|
||||||
|
return new Location(world, getEffectPositionX(), getEffectPositionY(), getEffectPositionZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the x coordinate of the effect.
|
||||||
|
* @return The current effect position X
|
||||||
|
*/
|
||||||
|
public double getEffectPositionX() {
|
||||||
|
return handle.getIntegers().read(0) / 8.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the x coordinate of the effect.
|
||||||
|
* <p>
|
||||||
|
* Note that the value is rounded of to the nearest 1/8.
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setEffectPositionX(double value) {
|
||||||
|
handle.getIntegers().write(0, (int) (value * 8.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the y coordinate of the effect.
|
||||||
|
* <p>
|
||||||
|
* Note that the value is rounded of to the nearest 1/8.
|
||||||
|
* @return The current effect position Y
|
||||||
|
*/
|
||||||
|
public double getEffectPositionY() {
|
||||||
|
return handle.getIntegers().read(1) / 8.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the y coordinate of the effect.
|
||||||
|
* <p>
|
||||||
|
* Note that the value is rounded of to the nearest 1/8.
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setEffectPositionY(double value) {
|
||||||
|
handle.getIntegers().write(1, (int) (value * 8.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the z coordinate of the effect.
|
||||||
|
* <p>
|
||||||
|
* Note that the value is rounded of to the nearest 1/8.
|
||||||
|
* @return The current effect position z
|
||||||
|
*/
|
||||||
|
public double getEffectPositionZ() {
|
||||||
|
return handle.getIntegers().read(2) / 8.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the z coordinate of the effect.
|
||||||
|
* <p>
|
||||||
|
* Note that the value is rounded of to the nearest 1/8.
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setEffectPositionZ(double value) {
|
||||||
|
handle.getIntegers().write(2, (int) (value * 8.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the volumne.
|
||||||
|
* <p>
|
||||||
|
* One (1) is 100%, can be more.
|
||||||
|
* @return The current Volume
|
||||||
|
*/
|
||||||
|
public float getVolume() {
|
||||||
|
return handle.getFloat().read(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the volume.
|
||||||
|
* <p>
|
||||||
|
* One (1) is 100%, can be more.
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setVolume(float value) {
|
||||||
|
handle.getFloat().write(0, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the pitch.
|
||||||
|
* <p>
|
||||||
|
* One (1) is 100%, can be up to 3.9.
|
||||||
|
* @return The current Pitch
|
||||||
|
*/
|
||||||
|
public float getPitch() {
|
||||||
|
return handle.getIntegers().read(3) / 63.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the pitch.
|
||||||
|
* <p>
|
||||||
|
* One (1) is 100%, can be up to 3.9.
|
||||||
|
* @param value - new value.
|
||||||
|
*/
|
||||||
|
public void setPitch(float value) {
|
||||||
|
handle.getIntegers().write(3, (int) (value * 63.0F));
|
||||||
|
}
|
||||||
|
}
|
||||||
+61
@@ -0,0 +1,61 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public interface PermissionCheck {
|
||||||
|
|
||||||
|
static String getPrefix() {
|
||||||
|
return "betterrtp.";
|
||||||
|
}
|
||||||
|
|
||||||
|
default boolean check(CommandSender sendi) {
|
||||||
|
if (isDev())
|
||||||
|
return sendi.getName().equalsIgnoreCase("SuperRonanCraft") || sendi.getName().equalsIgnoreCase("RonanCrafts");
|
||||||
|
return BetterRTP.getInstance().getPerms().checkPerm(getNode(), sendi);
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean check(CommandSender sendi, String check) {
|
||||||
|
return BetterRTP.getInstance().getPerms().checkPerm(check, sendi);
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean getAWorld(CommandSender sendi, String world) {
|
||||||
|
return getAWorldText(sendi, world).passed;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PermissionResult getAWorldText(CommandSender sendi, @NotNull String world) {
|
||||||
|
String perm = getPrefix() + "world.*";
|
||||||
|
if (check(sendi, perm)) {
|
||||||
|
return new PermissionResult(perm, true);
|
||||||
|
} else {
|
||||||
|
perm = getPrefix() + "world." + world;
|
||||||
|
if (check(sendi, perm))
|
||||||
|
return new PermissionResult(perm, true);
|
||||||
|
}
|
||||||
|
return new PermissionResult(perm, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean getLocation(CommandSender sendi, String location) {
|
||||||
|
return check(sendi, getPrefix() + "location." + location);
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean getPermissionGroup(CommandSender sendi, String group) {
|
||||||
|
return check(sendi, getPrefix() + "group." + group);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isDev();
|
||||||
|
|
||||||
|
String getNode();
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
class PermissionResult {
|
||||||
|
private final boolean passed;
|
||||||
|
private final String string;
|
||||||
|
PermissionResult(String string, boolean passed) {
|
||||||
|
this.passed = passed;
|
||||||
|
this.string = string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum PermissionNode implements PermissionCheck {
|
||||||
|
|
||||||
|
ADMIN("admin"),
|
||||||
|
USE("use"),
|
||||||
|
BYPASS_ECONOMY("bypass.economy"),
|
||||||
|
BYPASS_HUNGER("bypass.hunger"),
|
||||||
|
BYPASS_COOLDOWN("bypass.cooldown"),
|
||||||
|
BYPASS_DELAY("bypass.delay"),
|
||||||
|
BYPASS_LOCATION("bypass.location"), //Ability to bypass `UseLocationsInSameWorld` if enabled in location.yml
|
||||||
|
RELOAD("reload"),
|
||||||
|
SETTINGS("settings"),
|
||||||
|
INFO("info"),
|
||||||
|
UPDATER("updater"),
|
||||||
|
RTP_OTHER("player"),
|
||||||
|
BIOME("biome"),
|
||||||
|
WORLD("world"),
|
||||||
|
SIGN_CREATE("sign"),
|
||||||
|
VERSION("version"),
|
||||||
|
EDIT("edit"),
|
||||||
|
EDITOR("editor"),
|
||||||
|
LOCATION("location"),
|
||||||
|
DEVELOPER("DEVELOPER_PERM"),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final String node;
|
||||||
|
|
||||||
|
PermissionNode(String node) {
|
||||||
|
this.node = PermissionCheck.getPrefix() + node;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean isDev() {
|
||||||
|
return this == DEVELOPER;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.depends.DepPerms;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
public class Permissions {
|
||||||
|
|
||||||
|
private final DepPerms depPerms = new DepPerms();
|
||||||
|
|
||||||
|
public void register() {
|
||||||
|
depPerms.register();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkPerm(String str, CommandSender sendi) {
|
||||||
|
return depPerms.hasPerm(str, sendi);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.logging.*;
|
||||||
|
|
||||||
|
public class RTPLogger {
|
||||||
|
|
||||||
|
@Getter private String format;
|
||||||
|
@Getter private File file;
|
||||||
|
private FileHandler handler;
|
||||||
|
//private ConsoleHandler consoleHandler_rtp, consoleHandler_logger;
|
||||||
|
|
||||||
|
public void setup(BetterRTP plugin) {
|
||||||
|
FileOther.FILETYPE config = plugin.getFiles().getType(FileOther.FILETYPE.CONFIG);
|
||||||
|
boolean enabled = config.getBoolean("Settings.Logger.Enabled");
|
||||||
|
Logger logger = plugin.getLogger();
|
||||||
|
logger.setUseParentHandlers(true);
|
||||||
|
if (handler != null) {
|
||||||
|
logger.removeHandler(handler);
|
||||||
|
handler.close();
|
||||||
|
}
|
||||||
|
if (!enabled) return;
|
||||||
|
this.format = config.getString("Settings.Logger.Format");
|
||||||
|
boolean toConsole = config.getBoolean("Settings.Logger.LogToConsole");
|
||||||
|
try {
|
||||||
|
this.file = new File(plugin.getDataFolder() + File.separator + "log.txt");
|
||||||
|
Files.deleteIfExists(file.toPath());
|
||||||
|
this.handler = new FileHandler(file.getPath(), true);
|
||||||
|
handler.setFormatter(new MyFormatter());
|
||||||
|
logger.setUseParentHandlers(toConsole); //Disable logging to console
|
||||||
|
logger.addHandler(handler);
|
||||||
|
//Log copying
|
||||||
|
//consoleHandler_logger = new MyConsole(this.logger, plugin.getName());
|
||||||
|
//plugin.getLogger().addHandler(consoleHandler_logger);
|
||||||
|
//consoleHandler_rtp = new MyConsole(this.logger, plugin.getName());
|
||||||
|
//plugin.getLogger().addHandler(consoleHandler_rtp);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getDate() {
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat(BetterRTP.getInstance().getRtpLogger().getFormat());
|
||||||
|
return format.format(new Date());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unload() {
|
||||||
|
if (handler != null)
|
||||||
|
handler.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
static class MyFormatter extends Formatter {
|
||||||
|
@Override
|
||||||
|
public String format(LogRecord record) {
|
||||||
|
return getDate() + " [" + record.getLevel().getName() + "]: " + record.getMessage() + '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class WarningHandler {
|
||||||
|
|
||||||
|
HashMap<WARNING, Long> lastWarning = new HashMap<>();
|
||||||
|
|
||||||
|
public static void warn(WARNING type, String str) {
|
||||||
|
warn(type, str, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void warn(WARNING type, String str, boolean auto_ignore) {
|
||||||
|
WarningHandler handler = BetterRTP.getInstance().getWarningHandler();
|
||||||
|
if (auto_ignore) { //Ignored automatically every 30 minutes
|
||||||
|
Long lastTime = handler.lastWarning.getOrDefault(type, 0L);
|
||||||
|
if (lastTime <= System.currentTimeMillis()) {
|
||||||
|
BetterRTP.getInstance().getLogger().info(str);
|
||||||
|
lastTime += System.currentTimeMillis() + (1000 * 1800);
|
||||||
|
}
|
||||||
|
handler.lastWarning.put(type, lastTime);
|
||||||
|
} else
|
||||||
|
BetterRTP.getInstance().getLogger().warning(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum WARNING {
|
||||||
|
USELOCATION_ENABLED_NO_LOCATION_AVAILABLE,
|
||||||
|
NO_WORLD_TYPE_DECLARED
|
||||||
|
}
|
||||||
|
}
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.customEvents;
|
||||||
|
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
public class RTPEvent extends Event {
|
||||||
|
|
||||||
|
private static final HandlerList handler = new HandlerList();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handler;
|
||||||
|
}
|
||||||
|
}
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.customEvents;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
public class RTP_CancelledEvent extends RTPEvent { //Called when a delayed rtp is cancelled cause player moved
|
||||||
|
|
||||||
|
Player p;
|
||||||
|
private static final HandlerList handler = new HandlerList();
|
||||||
|
|
||||||
|
public RTP_CancelledEvent(Player p) {
|
||||||
|
this.p = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer() {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
}
|
||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.customEvents;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
public class RTP_CommandEvent extends RTPEvent implements Cancellable {
|
||||||
|
|
||||||
|
boolean cancelled;
|
||||||
|
CommandSender sendi;
|
||||||
|
RTPCommand cmd;
|
||||||
|
private static final HandlerList handler = new HandlerList();
|
||||||
|
|
||||||
|
//Called before a command is executed
|
||||||
|
public RTP_CommandEvent(CommandSender sendi, RTPCommand cmd) {
|
||||||
|
this.sendi = sendi;
|
||||||
|
this.cmd = cmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandSender getSendi() {
|
||||||
|
return sendi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RTPCommand getCmd() {
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean b) {
|
||||||
|
cancelled = b;
|
||||||
|
}
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.customEvents;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
|
|
||||||
|
public class RTP_CommandEvent_After extends RTP_CommandEvent {
|
||||||
|
|
||||||
|
//Executed after a command was executed
|
||||||
|
public RTP_CommandEvent_After(CommandSender sendi, RTPCommand cmd) {
|
||||||
|
super(sendi, cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.customEvents;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.RTPPlayer;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.RTPWorld;
|
||||||
|
|
||||||
|
//Called when an rtp is finding a valid location
|
||||||
|
@Getter public class RTP_FailedEvent extends RTPEvent {
|
||||||
|
|
||||||
|
Player p;
|
||||||
|
RTPWorld world;
|
||||||
|
int attempts;
|
||||||
|
|
||||||
|
public RTP_FailedEvent(RTPPlayer rtpPlayer) {
|
||||||
|
this.p = rtpPlayer.getPlayer();
|
||||||
|
this.world = rtpPlayer.getWorldPlayer();
|
||||||
|
this.attempts = rtpPlayer.getAttempts();
|
||||||
|
}
|
||||||
|
}
|
||||||
+53
@@ -0,0 +1,53 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.customEvents;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.RTPPlayer;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.RTPWorld;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
//Called when an rtp is finding a valid location
|
||||||
|
public class RTP_FindLocationEvent extends RTPEvent implements Cancellable {
|
||||||
|
|
||||||
|
Player p;
|
||||||
|
RTPWorld world;
|
||||||
|
Location loc; //Used to force a location into find event
|
||||||
|
int attempts;
|
||||||
|
boolean cancelled;
|
||||||
|
|
||||||
|
public RTP_FindLocationEvent(RTPPlayer rtpPlayer) {
|
||||||
|
this.p = rtpPlayer.getPlayer();
|
||||||
|
this.world = rtpPlayer.getWorldPlayer();
|
||||||
|
this.attempts = rtpPlayer.getAttempts();
|
||||||
|
}
|
||||||
|
|
||||||
|
//A location can be pushed in if a developer wants to inject a custom location
|
||||||
|
//Safe block code will still be run!
|
||||||
|
public void setLocation(Location loc) {
|
||||||
|
this.loc = loc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Location getLocation() {
|
||||||
|
return loc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RTPWorld getWorld() {
|
||||||
|
return world;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer() {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean b) {
|
||||||
|
cancelled = b;
|
||||||
|
}
|
||||||
|
}
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.customEvents;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
|
public class RTP_SettingUpEvent extends RTPEvent implements Cancellable {
|
||||||
|
|
||||||
|
Player p;
|
||||||
|
boolean cancelled = false;
|
||||||
|
|
||||||
|
public RTP_SettingUpEvent(Player p) {
|
||||||
|
this.p = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer() {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean b) {
|
||||||
|
cancelled = b;
|
||||||
|
}
|
||||||
|
}
|
||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.customEvents;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WORLD_TYPE;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class RTP_TeleportEvent extends RTPEvent {
|
||||||
|
|
||||||
|
Player p;
|
||||||
|
Location loc;
|
||||||
|
WORLD_TYPE worldType;
|
||||||
|
|
||||||
|
public RTP_TeleportEvent(Player p, Location loc, WORLD_TYPE worldType) {
|
||||||
|
this.p = p;
|
||||||
|
this.loc = loc;
|
||||||
|
this.worldType = worldType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer() {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getLocation() {
|
||||||
|
return loc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void changeLocation(Location loc) {
|
||||||
|
this.loc = loc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WORLD_TYPE getWorldType() {
|
||||||
|
return worldType;
|
||||||
|
}
|
||||||
|
}
|
||||||
+43
@@ -0,0 +1,43 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.customEvents;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_TYPE;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldPlayer;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class RTP_TeleportPostEvent extends RTPEvent {
|
||||||
|
|
||||||
|
Player p;
|
||||||
|
Location loc;
|
||||||
|
Location oldLoc;
|
||||||
|
RTP_TYPE type;
|
||||||
|
WorldPlayer wPlayer;
|
||||||
|
|
||||||
|
public RTP_TeleportPostEvent(Player p, Location loc, Location oldLoc, WorldPlayer wPlayer, RTP_TYPE type) {
|
||||||
|
this.p = p;
|
||||||
|
this.loc = loc;
|
||||||
|
this.oldLoc = oldLoc;
|
||||||
|
this.type = type;
|
||||||
|
this.wPlayer = wPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer() {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getLocation() {
|
||||||
|
return loc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getOldLocation() {
|
||||||
|
return oldLoc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RTP_TYPE getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorldPlayer getWorldPlayer() {
|
||||||
|
return wPlayer;
|
||||||
|
}
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.customEvents;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
|
public class RTP_TeleportPreEvent extends RTPEvent implements Cancellable { //Called upon every rtp call, does not mean player will be teleported
|
||||||
|
|
||||||
|
@Getter Player p;
|
||||||
|
boolean cancelled;
|
||||||
|
|
||||||
|
public RTP_TeleportPreEvent(Player p) {
|
||||||
|
this.p = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean b) {
|
||||||
|
cancelled = b;
|
||||||
|
}
|
||||||
|
}
|
||||||
+64
@@ -0,0 +1,64 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.database;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.versions.AsyncHandler;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class DatabaseChunkData extends SQLite {
|
||||||
|
|
||||||
|
public DatabaseChunkData() {
|
||||||
|
super(DATABASE_TYPE.CHUNK_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getTables() {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
list.add("ChunkData");
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum COLUMNS {
|
||||||
|
ID("id", "integer PRIMARY KEY AUTOINCREMENT"),
|
||||||
|
//Chunk Data
|
||||||
|
WORLD("world", "varchar(32)"),
|
||||||
|
X("x", "long"),
|
||||||
|
Z("z", "long"),
|
||||||
|
BIOME("biome", "string"),
|
||||||
|
MAX_Y("max_y", "integer"),
|
||||||
|
;
|
||||||
|
|
||||||
|
public final String name;
|
||||||
|
public final String type;
|
||||||
|
|
||||||
|
COLUMNS(String name, String type) {
|
||||||
|
this.name = name;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void addChunk(Chunk chunk, int maxy, Biome biome) {
|
||||||
|
AsyncHandler.async(() -> {
|
||||||
|
String pre = "INSERT OR REPLACE INTO ";
|
||||||
|
String sql = pre + tables.get(0) + " ("
|
||||||
|
+ COLUMNS.WORLD.name + ", "
|
||||||
|
+ COLUMNS.X.name + ", "
|
||||||
|
+ COLUMNS.Z.name + ", "
|
||||||
|
+ COLUMNS.BIOME.name + ", "
|
||||||
|
+ COLUMNS.MAX_Y.name + " "
|
||||||
|
+ ") VALUES(?, ?, ?, ?, ?)";
|
||||||
|
List<Object> params = new ArrayList<Object>() {{
|
||||||
|
add(chunk.getWorld().getName());
|
||||||
|
add(chunk.getX());
|
||||||
|
add(chunk.getZ());
|
||||||
|
add(biome.name());
|
||||||
|
add(maxy);
|
||||||
|
}};
|
||||||
|
sqlUpdate(sql, params);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+139
@@ -0,0 +1,139 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.database;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.CooldownData;
|
||||||
|
|
||||||
|
public class DatabaseCooldowns extends SQLite {
|
||||||
|
|
||||||
|
public DatabaseCooldowns() {
|
||||||
|
super(DATABASE_TYPE.COOLDOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getTables() {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
|
||||||
|
// Ignore loaded world names if cooldowns are disabled
|
||||||
|
if (!BetterRTP.getInstance().getCooldowns().isEnabled())
|
||||||
|
return list;
|
||||||
|
|
||||||
|
// Get list of disabled worlds and ensure list isn't null
|
||||||
|
List<String> disabledWorlds = BetterRTP.getInstance().getRTP().getDisabledWorlds();
|
||||||
|
if (disabledWorlds == null) disabledWorlds = new ArrayList<>();
|
||||||
|
|
||||||
|
// If there are disabled worlds, iterate through the loaded worlds on the server and
|
||||||
|
// add the world name to the list of table names if they aren't marked as disabled
|
||||||
|
List<World> worlds = Bukkit.getWorlds();
|
||||||
|
if (!disabledWorlds.isEmpty()) {
|
||||||
|
for (World world : worlds) {
|
||||||
|
if (!disabledWorlds.contains(world.getName()))
|
||||||
|
list.add(world.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum COLUMNS {
|
||||||
|
UUID("uuid", "varchar(32) PRIMARY KEY"),
|
||||||
|
//COOLDOWN DATA
|
||||||
|
COOLDOWN_DATE("date", "long"),
|
||||||
|
//USES("uses", "integer"),
|
||||||
|
;
|
||||||
|
|
||||||
|
public final String name;
|
||||||
|
public final String type;
|
||||||
|
|
||||||
|
COLUMNS(String name, String type) {
|
||||||
|
this.name = name;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePlayer(UUID uuid, World world) {
|
||||||
|
// Create SQL query string with backtick-ed table name to allow for special characters
|
||||||
|
String sql = String.format(
|
||||||
|
"DELETE FROM `%s` WHERE %s = ?",
|
||||||
|
world.getName(),
|
||||||
|
COLUMNS.UUID.name
|
||||||
|
);
|
||||||
|
List<Object> params = new ArrayList<Object>() {{
|
||||||
|
add(uuid.toString());
|
||||||
|
}};
|
||||||
|
sqlUpdate(sql, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CooldownData getCooldown(UUID uuid, World world) {
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
try {
|
||||||
|
conn = getSQLConnection();
|
||||||
|
// Create prepared statement with backtick-ed table name to allow for special characters
|
||||||
|
ps = conn.prepareStatement(String.format(
|
||||||
|
"SELECT * FROM `%s` WHERE %s = ?",
|
||||||
|
world.getName(),
|
||||||
|
COLUMNS.UUID.name
|
||||||
|
));
|
||||||
|
ps.setString(1, uuid.toString());
|
||||||
|
|
||||||
|
rs = ps.executeQuery();
|
||||||
|
if (rs.next()) {
|
||||||
|
Long time = rs.getLong(COLUMNS.COOLDOWN_DATE.name);
|
||||||
|
//int uses = rs.getInt(COLUMNS.USES.name);
|
||||||
|
return new CooldownData(uuid, time);
|
||||||
|
}
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
BetterRTP.getInstance().getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||||
|
} finally {
|
||||||
|
close(ps, rs, conn);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Set a player Cooldown
|
||||||
|
public void setCooldown(World world, CooldownData data) {
|
||||||
|
String pre = "INSERT OR REPLACE INTO ";
|
||||||
|
String sql = pre + world.getName() + " ("
|
||||||
|
+ COLUMNS.UUID.name + ", "
|
||||||
|
+ COLUMNS.COOLDOWN_DATE.name + " "
|
||||||
|
//+ COLUMNS.USES.name + " "
|
||||||
|
+ ") VALUES(?, ?)";
|
||||||
|
List<Object> params = new ArrayList<Object>() {{
|
||||||
|
add(data.getUuid().toString());
|
||||||
|
add(data.getTime());
|
||||||
|
//add(data.getUses());
|
||||||
|
}};
|
||||||
|
sqlUpdate(sql, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Update multiple players cooldowns
|
||||||
|
/*public void setCooldown(List<CooldownData> cooldownData) {
|
||||||
|
String pre = "INSERT OR REPLACE INTO ";
|
||||||
|
String sql = pre + table + " ("
|
||||||
|
+ COLUMNS.UUID.name + ", "
|
||||||
|
+ COLUMNS.COOLDOWN_DATE.name + ", "
|
||||||
|
+ COLUMNS.USES.name + " "
|
||||||
|
+ ") VALUES(?, ?, ?)";
|
||||||
|
for (CooldownData data : cooldownData) {
|
||||||
|
List<Object> param = new ArrayList<Object>() {{
|
||||||
|
add(data.getUuid().toString());
|
||||||
|
add(data.getTime());
|
||||||
|
add(data.getUses());
|
||||||
|
}};
|
||||||
|
sqlUpdate(sql, param);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
}
|
||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.database;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.versions.AsyncHandler;
|
||||||
|
|
||||||
|
public class DatabaseHandler {
|
||||||
|
|
||||||
|
@Getter private final DatabasePlayers databasePlayers = new DatabasePlayers();
|
||||||
|
@Getter private final DatabaseCooldowns databaseCooldowns = new DatabaseCooldowns();
|
||||||
|
@Getter private final DatabaseQueue databaseQueue = new DatabaseQueue();
|
||||||
|
@Getter private final DatabaseChunkData databaseChunks = new DatabaseChunkData();
|
||||||
|
|
||||||
|
public void load() {
|
||||||
|
AsyncHandler.async(() -> {
|
||||||
|
databasePlayers.load();
|
||||||
|
databaseCooldowns.load();
|
||||||
|
databaseQueue.load();
|
||||||
|
databaseChunks.load();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DatabasePlayers getPlayers() {
|
||||||
|
return BetterRTP.getInstance().getDatabaseHandler().getDatabasePlayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DatabaseCooldowns getCooldowns() {
|
||||||
|
return BetterRTP.getInstance().getDatabaseHandler().getDatabaseCooldowns();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DatabaseQueue getQueue() {
|
||||||
|
return BetterRTP.getInstance().getDatabaseHandler().getDatabaseQueue();
|
||||||
|
}
|
||||||
|
|
||||||
|
//public static DatabaseChunkData getChunks() {
|
||||||
|
// return BetterRTP.getInstance().getDatabaseHandler().getDatabaseChunks();
|
||||||
|
//}
|
||||||
|
|
||||||
|
}
|
||||||
+108
@@ -0,0 +1,108 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.database;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.player.playerdata.PlayerData;
|
||||||
|
|
||||||
|
public class DatabasePlayers extends SQLite {
|
||||||
|
|
||||||
|
public DatabasePlayers() {
|
||||||
|
super(DATABASE_TYPE.PLAYERS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getTables() {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
list.add("Players");
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum COLUMNS {
|
||||||
|
UUID("uuid", "varchar(32) PRIMARY KEY"),
|
||||||
|
//COOLDOWN DATA
|
||||||
|
COUNT("count", "long"),
|
||||||
|
LAST_COOLDOWN_DATE("last_rtp_date", "long"),
|
||||||
|
;
|
||||||
|
|
||||||
|
public final String name;
|
||||||
|
public final String type;
|
||||||
|
|
||||||
|
COLUMNS(String name, String type) {
|
||||||
|
this.name = name;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Immutable persistence values; never retains a Bukkit player/session. */
|
||||||
|
public static final class Snapshot {
|
||||||
|
public final UUID uuid;
|
||||||
|
public final int count;
|
||||||
|
public final long cooldown;
|
||||||
|
|
||||||
|
public Snapshot(UUID uuid, int count, long cooldown) {
|
||||||
|
this.uuid = uuid;
|
||||||
|
this.count = count;
|
||||||
|
this.cooldown = cooldown;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Snapshot capture(PlayerData data) {
|
||||||
|
return new Snapshot(data.player.getUniqueId(), data.getRtpCount(), data.getGlobalCooldown());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Existing API: load into this session only while it is still current. */
|
||||||
|
public void setupData(PlayerData data) {
|
||||||
|
if (data == null) return;
|
||||||
|
Snapshot stored = loadData(data.player.getUniqueId());
|
||||||
|
if (stored != null)
|
||||||
|
BetterRTP.getInstance().getPlayerDataManager().applyIfCurrent(data, current -> {
|
||||||
|
current.setRtpCount(stored.count);
|
||||||
|
current.setGlobalCooldown(stored.cooldown);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public Snapshot loadData(UUID uuid) {
|
||||||
|
try {
|
||||||
|
return SQLiteExecutor.EXECUTOR.submit(() -> {
|
||||||
|
try (Connection conn = getSQLConnection();
|
||||||
|
PreparedStatement ps = conn.prepareStatement("SELECT * FROM " + tables.get(0) + " WHERE " + COLUMNS.UUID.name + " = ?")) {
|
||||||
|
ps.setString(1, uuid.toString());
|
||||||
|
try (ResultSet rs = ps.executeQuery()) {
|
||||||
|
if (rs.next())
|
||||||
|
return new Snapshot(uuid, Math.toIntExact(rs.getLong(COLUMNS.COUNT.name)),
|
||||||
|
rs.getLong(COLUMNS.LAST_COOLDOWN_DATE.name));
|
||||||
|
}
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
BetterRTP.getInstance().getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}).get();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Compatibility entry point: capture before deferring database work. */
|
||||||
|
public void setData(PlayerData data) {
|
||||||
|
if (data != null) setData(Snapshot.capture(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(Snapshot data) {
|
||||||
|
SQLiteExecutor.EXECUTOR.submit(() -> {
|
||||||
|
String sql = "INSERT OR REPLACE INTO " + tables.get(0) + " ("
|
||||||
|
+ COLUMNS.UUID.name + ", " + COLUMNS.COUNT.name + ", "
|
||||||
|
+ COLUMNS.LAST_COOLDOWN_DATE.name + ") VALUES(?, ?, ?)";
|
||||||
|
List<Object> params = java.util.Arrays.asList(data.uuid.toString(), data.count, data.cooldown);
|
||||||
|
sqlUpdate(sql, params);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
+184
@@ -0,0 +1,184 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.database;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NonNull;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.QueueData;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.QueueGenerator;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.QueueHandler;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.RTPWorld;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class DatabaseQueue extends SQLite {
|
||||||
|
|
||||||
|
public DatabaseQueue() {
|
||||||
|
super(DATABASE_TYPE.QUEUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getTables() {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
list.add("Queue");
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum COLUMNS {
|
||||||
|
ID("id", "integer PRIMARY KEY AUTOINCREMENT"),
|
||||||
|
//Location Data
|
||||||
|
X("x", "long"),
|
||||||
|
Z("z", "long"),
|
||||||
|
WORLD("world", "varchar(32)"),
|
||||||
|
GENERATED("generated", "long")
|
||||||
|
;
|
||||||
|
|
||||||
|
public final String name;
|
||||||
|
public final String type;
|
||||||
|
|
||||||
|
COLUMNS(String name, String type) {
|
||||||
|
this.name = name;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void load() {
|
||||||
|
if (QueueHandler.isEnabled())
|
||||||
|
super.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<QueueData> getInRange(QueueRangeData range) {
|
||||||
|
final List<QueueData> queueDataList = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
SQLiteExecutor.EXECUTOR.submit(() -> {
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
try {
|
||||||
|
conn = getSQLConnection();
|
||||||
|
ps = conn.prepareStatement("SELECT * FROM " + tables.get(0) + " WHERE "
|
||||||
|
+ COLUMNS.WORLD.name + " = '" + range.getWorld().getName() + "' AND "
|
||||||
|
+ COLUMNS.X.name + " BETWEEN " + range.getXLow() + " AND " + range.getXHigh()
|
||||||
|
+ " AND " + COLUMNS.Z.name + " BETWEEN " + range.getZLow() + " AND " + range.getZHigh()
|
||||||
|
+ " ORDER BY RANDOM() LIMIT " + (QueueGenerator.queueMax + 1)
|
||||||
|
);
|
||||||
|
rs = ps.executeQuery();
|
||||||
|
while (rs.next()) {
|
||||||
|
long x = rs.getLong(COLUMNS.X.name);
|
||||||
|
long z = rs.getLong(COLUMNS.Z.name);
|
||||||
|
String worldName = rs.getString(COLUMNS.WORLD.name);
|
||||||
|
int id = rs.getInt(COLUMNS.ID.name);
|
||||||
|
long generated = rs.getLong(COLUMNS.GENERATED.name);
|
||||||
|
World world = Bukkit.getWorld(worldName);
|
||||||
|
if (world != null) {
|
||||||
|
queueDataList.add(new QueueData(new Location(world, x, 69, z), generated, id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
BetterRTP.getInstance().getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||||
|
} finally {
|
||||||
|
close(ps, rs, conn);
|
||||||
|
}
|
||||||
|
}).get();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
return queueDataList;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Set a queue to save
|
||||||
|
public QueueData addQueue(Location loc) {
|
||||||
|
try {
|
||||||
|
return SQLiteExecutor.EXECUTOR.submit(() -> {
|
||||||
|
String sql = "INSERT INTO " + tables.get(0) + " ("
|
||||||
|
+ COLUMNS.X.name + ", "
|
||||||
|
+ COLUMNS.Z.name + ", "
|
||||||
|
+ COLUMNS.WORLD.name + ", "
|
||||||
|
+ COLUMNS.GENERATED.name + ") VALUES(?, ?, ?, ?)";
|
||||||
|
List<Object> params = new ArrayList<Object>() {{
|
||||||
|
add(loc.getBlockX());
|
||||||
|
add(loc.getBlockZ());
|
||||||
|
add(loc.getWorld().getName());
|
||||||
|
add(System.currentTimeMillis());
|
||||||
|
}};
|
||||||
|
int database_id = createQueue(sql, params);
|
||||||
|
return database_id >= 0 ? new QueueData(loc, System.currentTimeMillis(), database_id) : null;
|
||||||
|
}).get();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int createQueue(String statement, @NonNull List<Object> params) {
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
int id = -1;
|
||||||
|
try {
|
||||||
|
conn = getSQLConnection();
|
||||||
|
ps = conn.prepareStatement(statement, Statement.RETURN_GENERATED_KEYS);
|
||||||
|
Iterator<Object> it = params.iterator();
|
||||||
|
int paramIndex = 1;
|
||||||
|
while (it.hasNext()) {
|
||||||
|
ps.setObject(paramIndex, it.next());
|
||||||
|
paramIndex++;
|
||||||
|
}
|
||||||
|
ps.executeUpdate();
|
||||||
|
ResultSet rs = ps.getGeneratedKeys();
|
||||||
|
if (rs.next()) {
|
||||||
|
id = rs.getInt(1);
|
||||||
|
}
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
BetterRTP.getInstance().getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||||
|
} finally {
|
||||||
|
close(ps, null, conn);
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean removeLocation(Location loc) {
|
||||||
|
try {
|
||||||
|
return SQLiteExecutor.EXECUTOR.submit(() -> {
|
||||||
|
String sql = "DELETE FROM " + tables.get(0) + " WHERE "
|
||||||
|
+ COLUMNS.X.name + " = ? AND "
|
||||||
|
+ COLUMNS.Z.name + " = ? AND "
|
||||||
|
+ COLUMNS.WORLD.name + " = ?";
|
||||||
|
List<Object> params = new ArrayList<Object>() {{
|
||||||
|
add(loc.getBlockX());
|
||||||
|
add(loc.getBlockZ());
|
||||||
|
add(loc.getWorld().getName());
|
||||||
|
}};
|
||||||
|
return sqlUpdate(sql, params);
|
||||||
|
}).get();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public static class QueueRangeData {
|
||||||
|
|
||||||
|
int xLow, xHigh;
|
||||||
|
int zLow, zHigh;
|
||||||
|
World world;
|
||||||
|
|
||||||
|
public QueueRangeData(RTPWorld rtpWorld) {
|
||||||
|
this.xLow = rtpWorld.getCenterX() - rtpWorld.getMaxRadius();
|
||||||
|
this.xHigh = rtpWorld.getCenterX() + rtpWorld.getMaxRadius();
|
||||||
|
this.zLow = rtpWorld.getCenterZ() - rtpWorld.getMaxRadius();
|
||||||
|
this.zHigh = rtpWorld.getCenterZ() + rtpWorld.getMaxRadius();
|
||||||
|
this.world = rtpWorld.getWorld();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.database;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class Error {
|
||||||
|
public static void execute(BetterRTP plugin, Exception ex){
|
||||||
|
plugin.getLogger().log(Level.SEVERE, "Couldn't execute MySQL statement: ", ex);
|
||||||
|
}
|
||||||
|
public static void close(BetterRTP plugin, Exception ex){
|
||||||
|
plugin.getLogger().log(Level.SEVERE, "Failed to close MySQL connection: ", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.database;
|
||||||
|
|
||||||
|
public class Errors {
|
||||||
|
public static String sqlConnectionExecute(){
|
||||||
|
return "Couldn't execute MySQL statement: ";
|
||||||
|
}
|
||||||
|
public static String sqlConnectionClose(){
|
||||||
|
return "Failed to close MySQL connection: ";
|
||||||
|
}
|
||||||
|
public static String noSQLConnection(){
|
||||||
|
return "Unable to retreive MYSQL connection: ";
|
||||||
|
}
|
||||||
|
public static String noTableFound(){
|
||||||
|
return "Database Error: No Table Found";
|
||||||
|
}
|
||||||
|
}
|
||||||
+244
@@ -0,0 +1,244 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.database;
|
||||||
|
|
||||||
|
import lombok.NonNull;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.versions.AsyncHandler;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public abstract class SQLite {
|
||||||
|
|
||||||
|
private static final String db_file_name = "database";
|
||||||
|
List<String> tables;
|
||||||
|
private boolean loaded;
|
||||||
|
|
||||||
|
public String addMissingColumns = "ALTER TABLE %table% ADD COLUMN %column% %type%";
|
||||||
|
|
||||||
|
private final DATABASE_TYPE type;
|
||||||
|
|
||||||
|
public SQLite(DATABASE_TYPE type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract List<String> getTables();
|
||||||
|
|
||||||
|
// SQL creation stuff
|
||||||
|
public Connection getSQLConnection() {
|
||||||
|
return getLocal();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Connection getLocal() {
|
||||||
|
File dataFolder = new File(BetterRTP.getInstance().getDataFolder().getPath() + File.separator + "data", db_file_name + ".db");
|
||||||
|
if (!dataFolder.exists()){
|
||||||
|
try {
|
||||||
|
dataFolder.getParentFile().mkdir();
|
||||||
|
dataFolder.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
BetterRTP.getInstance().getLogger().log(Level.SEVERE, "File write error: " + dataFolder.getPath());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Class.forName("org.sqlite.JDBC");
|
||||||
|
return DriverManager.getConnection("jdbc:sqlite:" + dataFolder);
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
BetterRTP.getInstance().getLogger().log(Level.SEVERE, "SQLite exception on initialize", ex);
|
||||||
|
} catch (ClassNotFoundException ex) {
|
||||||
|
BetterRTP.getInstance().getLogger().log(Level.SEVERE, "You need the SQLite JBDC library. Google it Ronan...");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void load() {
|
||||||
|
loaded = false;
|
||||||
|
tables = getTables();
|
||||||
|
|
||||||
|
// Don't do anything is no columns to generate
|
||||||
|
if (tables.isEmpty()) {
|
||||||
|
loaded = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AsyncHandler.async(() -> {
|
||||||
|
Connection connection = getSQLConnection();
|
||||||
|
try {
|
||||||
|
Statement s = connection.createStatement();
|
||||||
|
for (String table : tables) {
|
||||||
|
s.executeUpdate(getCreateTable(table));
|
||||||
|
//s.executeUpdate(createTable_bank);
|
||||||
|
for (Enum<?> c : getColumns(type)) { //Add missing columns dynamically
|
||||||
|
try {
|
||||||
|
String _name = getColumnName(type, c);
|
||||||
|
String _type = getColumnType(type, c);
|
||||||
|
//System.out.println("Adding " + _name);
|
||||||
|
s.executeUpdate(addMissingColumns.replace("%table%", table).replace("%column%", _name).replace("%type%", _type));
|
||||||
|
} catch (SQLException e) {
|
||||||
|
//e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BetterRTP.debug("Database " + type.name() + ":" + table + " configured and loaded!");
|
||||||
|
}
|
||||||
|
s.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
if (connection != null) {
|
||||||
|
try {
|
||||||
|
connection.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
initialize();
|
||||||
|
loaded = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getCreateTable(String table) {
|
||||||
|
String str = "CREATE TABLE IF NOT EXISTS `" + table + "` (";
|
||||||
|
Enum<?>[] columns = getColumns(type);
|
||||||
|
for (Enum<?> c : columns) {
|
||||||
|
String _name = getColumnName(type, c);
|
||||||
|
String _type = getColumnType(type, c);
|
||||||
|
str = str.concat("`" + _name + "` " + _type);
|
||||||
|
if (c.equals(columns[columns.length - 1]))
|
||||||
|
str = str.concat(")");
|
||||||
|
else
|
||||||
|
str = str.concat(", ");
|
||||||
|
}
|
||||||
|
//System.out.println("MySQL column string: `" + str + "`");
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Enum<?>[] getColumns(DATABASE_TYPE type) {
|
||||||
|
switch (type) {
|
||||||
|
case CHUNK_DATA: return DatabaseChunkData.COLUMNS.values();
|
||||||
|
case PLAYERS: return DatabasePlayers.COLUMNS.values();
|
||||||
|
case QUEUE: return DatabaseQueue.COLUMNS.values();
|
||||||
|
case COOLDOWN:
|
||||||
|
default: return DatabaseCooldowns.COLUMNS.values();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getColumnName(DATABASE_TYPE type, Enum<?> column) {
|
||||||
|
switch (type) {
|
||||||
|
case CHUNK_DATA: return ((DatabaseChunkData.COLUMNS) column).name;
|
||||||
|
case PLAYERS: return ((DatabasePlayers.COLUMNS) column).name;
|
||||||
|
case QUEUE: return ((DatabaseQueue.COLUMNS) column).name;
|
||||||
|
case COOLDOWN:
|
||||||
|
default: return ((DatabaseCooldowns.COLUMNS) column).name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getColumnType(DATABASE_TYPE type, Enum<?> column) {
|
||||||
|
switch (type) {
|
||||||
|
case CHUNK_DATA: return ((DatabaseChunkData.COLUMNS) column).type;
|
||||||
|
case PLAYERS: return ((DatabasePlayers.COLUMNS) column).type;
|
||||||
|
case QUEUE: return ((DatabaseQueue.COLUMNS) column).type;
|
||||||
|
case COOLDOWN:
|
||||||
|
default: return ((DatabaseCooldowns.COLUMNS) column).type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Processing
|
||||||
|
protected boolean sqlUpdate(String statement, @NonNull List<Object> params) {
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
boolean success = true;
|
||||||
|
try {
|
||||||
|
conn = getSQLConnection();
|
||||||
|
ps = conn.prepareStatement(statement);
|
||||||
|
Iterator<Object> it = params.iterator();
|
||||||
|
int paramIndex = 1;
|
||||||
|
while (it.hasNext()) {
|
||||||
|
ps.setObject(paramIndex, it.next());
|
||||||
|
paramIndex++;
|
||||||
|
}
|
||||||
|
ps.executeUpdate();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
BetterRTP.getInstance().getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||||
|
success = false;
|
||||||
|
} finally {
|
||||||
|
close(ps, null, conn);
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean sqlUpdate(List<String> statement1, List<List<Object>> params1) {
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
boolean success = true;
|
||||||
|
try {
|
||||||
|
conn = getSQLConnection();
|
||||||
|
for (int i = 0; i < statement1.size(); i++) {
|
||||||
|
String statement = statement1.get(i);
|
||||||
|
List<Object> params = params1.get(i);
|
||||||
|
if (ps == null)
|
||||||
|
ps = conn.prepareStatement(statement);
|
||||||
|
else
|
||||||
|
ps.addBatch(statement);
|
||||||
|
if (params != null) {
|
||||||
|
Iterator<Object> it = params.iterator();
|
||||||
|
int paramIndex = 1;
|
||||||
|
while (it.hasNext()) {
|
||||||
|
ps.setObject(paramIndex, it.next());
|
||||||
|
paramIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert ps != null;
|
||||||
|
ps.executeUpdate();
|
||||||
|
ps.close();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
BetterRTP.getInstance().getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||||
|
success = false;
|
||||||
|
ex.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
close(ps, null, conn);
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initialize() { //Let in console know if its all setup or not
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement ps = null;
|
||||||
|
ResultSet rs = null;
|
||||||
|
try {
|
||||||
|
conn = getSQLConnection();
|
||||||
|
ps = conn.prepareStatement("SELECT * FROM " + tables.get(0) + " WHERE " + getColumnName(type, getColumns(type)[0]) + " = 0");
|
||||||
|
|
||||||
|
rs = ps.executeQuery();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
BetterRTP.getInstance().getLogger().log(Level.SEVERE, "Unable to retrieve connection", ex);
|
||||||
|
} finally {
|
||||||
|
close(ps, rs, conn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void close(PreparedStatement ps, ResultSet rs, Connection conn) {
|
||||||
|
try {
|
||||||
|
if (ps != null) ps.close();
|
||||||
|
if (conn != null) conn.close();
|
||||||
|
if (rs != null) rs.close();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
Error.close(BetterRTP.getInstance(), ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLoaded() {
|
||||||
|
return loaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum DATABASE_TYPE {
|
||||||
|
PLAYERS,
|
||||||
|
COOLDOWN,
|
||||||
|
QUEUE,
|
||||||
|
CHUNK_DATA,
|
||||||
|
}
|
||||||
|
}
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.database;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
public class SQLiteExecutor {
|
||||||
|
public static final ExecutorService EXECUTOR = Executors.newSingleThreadExecutor();
|
||||||
|
}
|
||||||
+119
@@ -0,0 +1,119 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.depends;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesCore;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldPlayer;
|
||||||
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
import net.milkbowl.vault.economy.EconomyResponse;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
|
||||||
|
public class DepEconomy {
|
||||||
|
private Economy e;
|
||||||
|
private int hunger = 0;
|
||||||
|
private boolean checked = false;
|
||||||
|
|
||||||
|
public boolean charge(CommandSender sendi, WorldPlayer pWorld) {
|
||||||
|
check(false);
|
||||||
|
Player player = pWorld.getPlayer();
|
||||||
|
//Hunger Stuff
|
||||||
|
boolean took_food = false;
|
||||||
|
if (hunger != 0
|
||||||
|
&& pWorld.getPlayerInfo().isTakeHunger()
|
||||||
|
&& !PermissionNode.BYPASS_HUNGER.check(player)
|
||||||
|
&& (player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE)) {
|
||||||
|
boolean has_hunger = player.getFoodLevel() >= hunger;
|
||||||
|
if (!has_hunger) {
|
||||||
|
MessagesCore.FAILED_HUNGER.send(sendi);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
player.setFoodLevel(player.getFoodLevel() - hunger);
|
||||||
|
took_food = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Economy Stuff
|
||||||
|
if (e != null
|
||||||
|
&& pWorld.getPrice() != 0
|
||||||
|
&& pWorld.getPlayerInfo().isTakeMoney()
|
||||||
|
&& !PermissionNode.BYPASS_ECONOMY.check(player)) {
|
||||||
|
try {
|
||||||
|
EconomyResponse r = e.withdrawPlayer(player, pWorld.getPrice());
|
||||||
|
boolean passed_economy = r.transactionSuccess();
|
||||||
|
if (!passed_economy) {
|
||||||
|
MessagesCore.FAILED_PRICE.send(sendi, pWorld.getPrice());
|
||||||
|
if (took_food)
|
||||||
|
player.setFoodLevel(player.getFoodLevel() + hunger);
|
||||||
|
} //else
|
||||||
|
//pWorld.eco_money_taken = true;
|
||||||
|
return passed_economy;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Default value
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasBalance(WorldPlayer pWorld) {
|
||||||
|
check(false);
|
||||||
|
//Economy Stuff
|
||||||
|
int price = pWorld.getPrice();
|
||||||
|
if (e != null && price != 0 && !PermissionNode.BYPASS_ECONOMY.check(pWorld.getPlayer())) {
|
||||||
|
try {
|
||||||
|
return e.getBalance(pWorld.getPlayer()) >= price;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Default value
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasHunger(WorldPlayer pWorld) {
|
||||||
|
check(false);
|
||||||
|
Player player = pWorld.getPlayer();
|
||||||
|
//Hunger Stuff
|
||||||
|
if (hunger != 0
|
||||||
|
&& !PermissionNode.BYPASS_HUNGER.check(player)
|
||||||
|
&& (player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE)) {
|
||||||
|
return player.getFoodLevel() >= hunger;
|
||||||
|
}
|
||||||
|
//Default value
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public void unCharge(Player p, WorldPlayer pWorld) {
|
||||||
|
if (e != null && pWorld.getPrice() != 0 && pWorld.eco_money_taken)
|
||||||
|
e.depositPlayer(p, pWorld.getPrice());
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public void load() {
|
||||||
|
check(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void check(boolean force) {
|
||||||
|
if (!checked || force)
|
||||||
|
registerEconomy();
|
||||||
|
if (BetterRTP.getInstance().getFiles().getType(FileOther.FILETYPE.ECO).getBoolean("Hunger.Enabled"))
|
||||||
|
hunger = BetterRTP.getInstance().getFiles().getType(FileOther.FILETYPE.ECO).getInt("Hunger.Honches");
|
||||||
|
else
|
||||||
|
hunger = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerEconomy() {
|
||||||
|
try {
|
||||||
|
if (BetterRTP.getInstance().getFiles().getType(FileOther.FILETYPE.ECO).getBoolean("Economy.Enabled"))
|
||||||
|
if (BetterRTP.getInstance().getServer().getPluginManager().isPluginEnabled("Vault")) {
|
||||||
|
RegisteredServiceProvider<Economy> rsp = BetterRTP.getInstance().getServer().getServicesManager().getRegistration(Economy.class);
|
||||||
|
e = rsp.getProvider();
|
||||||
|
}
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
checked = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.depends;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.Essentials;
|
||||||
|
import com.earth2me.essentials.User;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class DepEssentials {
|
||||||
|
|
||||||
|
public static void setBackLocation(Player player, Location location) {
|
||||||
|
try {
|
||||||
|
Essentials ess = (Essentials) Bukkit.getServer().getPluginManager().getPlugin("Essentials");
|
||||||
|
if (ess == null)
|
||||||
|
return;
|
||||||
|
User user = ess.getUser(player.getUniqueId());
|
||||||
|
if (user == null)
|
||||||
|
return;
|
||||||
|
user.setLastLocation(location);
|
||||||
|
} catch (ClassCastException e) {
|
||||||
|
//Something wrong happened, idk why this would break...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
package me.SuperRonanCraft.BetterRTP.references.depends;
|
package me.SuperRonanCraft.BetterRTP.references.depends;
|
||||||
|
|
||||||
import me.SuperRonanCraft.BetterRTP.Main;
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
@@ -17,8 +17,8 @@ public class DepPerms {
|
|||||||
|
|
||||||
public void register() {
|
public void register() {
|
||||||
try {
|
try {
|
||||||
if (Main.getInstance().getServer().getPluginManager().isPluginEnabled("Vault")) {
|
if (BetterRTP.getInstance().getServer().getPluginManager().isPluginEnabled("Vault")) {
|
||||||
RegisteredServiceProvider<Permission> permissionProvider = Main.getInstance().getServer()
|
RegisteredServiceProvider<Permission> permissionProvider = BetterRTP.getInstance().getServer()
|
||||||
.getServicesManager().getRegistration(Permission.class);
|
.getServicesManager().getRegistration(Permission.class);
|
||||||
p = permissionProvider.getProvider();
|
p = permissionProvider.getProvider();
|
||||||
} else
|
} else
|
||||||
+183
@@ -0,0 +1,183 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.depends;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.RTPSetupInformation;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.PermissionCheck;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperDate;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP_Check;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.player.HelperPlayer;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.player.playerdata.PlayerData;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldPlayer;
|
||||||
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
|
|
||||||
|
public class DepPlaceholderAPI extends PlaceholderExpansion {
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public String getIdentifier() {
|
||||||
|
return BetterRTP.getInstance().getDescription().getName().toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public String getAuthor() {
|
||||||
|
return BetterRTP.getInstance().getDescription().getAuthors().get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public String getVersion() {
|
||||||
|
return BetterRTP.getInstance().getDescription().getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String onPlaceholderRequest(Player player, String request) {
|
||||||
|
PlayerData data = HelperPlayer.getData(player);
|
||||||
|
if (data == null) return null;
|
||||||
|
if (request.equalsIgnoreCase("count")) {
|
||||||
|
return String.valueOf(data.getRtpCount());
|
||||||
|
} else if (request.startsWith("cooldown")) {
|
||||||
|
if (request.equalsIgnoreCase("cooldown")) {
|
||||||
|
return cooldown(data, player.getWorld());
|
||||||
|
} else if (request.startsWith("cooldown_")) {
|
||||||
|
return cooldown(data, getWorld(request.replace("cooldown_", "")));
|
||||||
|
} else if (request.equalsIgnoreCase("cooldowntime")) {
|
||||||
|
return cooldownTime(data, player.getWorld());
|
||||||
|
} else if (request.startsWith("cooldowntime_")) {
|
||||||
|
return cooldownTime(data, getWorld(request.replace("cooldowntime_", "")));
|
||||||
|
}
|
||||||
|
} else if (request.startsWith("canrtp")) {
|
||||||
|
if (request.equalsIgnoreCase("canrtp")) {
|
||||||
|
return canRTPALL(player, player.getWorld());
|
||||||
|
} else if (request.startsWith("canrtp_")) {
|
||||||
|
return canRTPALL(player, getWorld(request.replace("canrtp_", "")));
|
||||||
|
} else if (request.startsWith("canrtpcooldown")) {
|
||||||
|
if (request.equalsIgnoreCase("canrtpcooldown")) {
|
||||||
|
return canRTP_cooldown(player, player.getWorld());
|
||||||
|
} else if (request.startsWith("canrtpcooldown_")) {
|
||||||
|
return canRTP_cooldown(player, getWorld(request.replace("canrtpcooldown_", "")));
|
||||||
|
}
|
||||||
|
} else if (request.startsWith("canrtpprice")) {
|
||||||
|
if (request.equalsIgnoreCase("canrtpprice")) {
|
||||||
|
return canRTP_price(player, player.getWorld());
|
||||||
|
} else if (request.startsWith("canrtpprice_")) {
|
||||||
|
return canRTP_price(player, getWorld(request.replace("canrtpprice_", "")));
|
||||||
|
}
|
||||||
|
} else if (request.startsWith("canrtphunger")) {
|
||||||
|
if (request.equalsIgnoreCase("canrtphunger")) {
|
||||||
|
return canRTP_hunger(player, player.getWorld());
|
||||||
|
} else if (request.startsWith("canrtphunger_")) {
|
||||||
|
return canRTP_hunger(player, getWorld(request.replace("canrtphunger_", "")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (request.startsWith("price")) {
|
||||||
|
if (request.equalsIgnoreCase("price")) {
|
||||||
|
return price(player, player.getWorld());
|
||||||
|
} else if (request.startsWith("price_")) {
|
||||||
|
return price(player, getWorld(request.replace("price_", "")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String cooldown(PlayerData data, World world) {
|
||||||
|
if (world == null) return "Invalid World";
|
||||||
|
long lng = BetterRTP.getInstance().getCooldowns().locked(data.player) ? -1L :
|
||||||
|
HelperRTP_Check.getCooldown(data.player, HelperRTP.getPlayerWorld(new RTPSetupInformation(world, data.player, data.player, true)));
|
||||||
|
return HelperDate.total(lng);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String cooldownTime(PlayerData data, World world) {
|
||||||
|
if (world == null) return "Invalid World";
|
||||||
|
RTPSetupInformation setup_info = new RTPSetupInformation(HelperRTP.getActualWorld(data.player, world), data.player, data.player, true);
|
||||||
|
WorldPlayer pWorld = HelperRTP.getPlayerWorld(setup_info);
|
||||||
|
Long cooldownTime = BetterRTP.getInstance().getCooldowns().locked(data.player) ? -1L :
|
||||||
|
(HelperRTP_Check.applyCooldown(data.player) ? pWorld.getCooldown() * 1000L : 0L);
|
||||||
|
return HelperDate.total(cooldownTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String canRTPALL(Player player, World world) {
|
||||||
|
if (world == null) return "Invalid World";
|
||||||
|
world = HelperRTP.getActualWorld(player, world);
|
||||||
|
//Permission
|
||||||
|
if (!PermissionCheck.getAWorld(player, world.getName()))
|
||||||
|
return BetterRTP.getInstance().getSettings().getPlaceholder_nopermission();
|
||||||
|
RTPSetupInformation setupInformation = new RTPSetupInformation(world, player, player, true);
|
||||||
|
WorldPlayer pWorld = HelperRTP.getPlayerWorld(setupInformation);
|
||||||
|
//Cooldown
|
||||||
|
if (HelperRTP_Check.isCoolingDown(player, pWorld))
|
||||||
|
return BetterRTP.getInstance().getSettings().getPlaceholder_cooldown();
|
||||||
|
//Price
|
||||||
|
if (!BetterRTP.getInstance().getEco().hasBalance(pWorld))
|
||||||
|
return BetterRTP.getInstance().getSettings().getPlaceholder_balance();
|
||||||
|
//Hunger
|
||||||
|
if (!BetterRTP.getInstance().getEco().hasHunger(pWorld))
|
||||||
|
return BetterRTP.getInstance().getSettings().getPlaceholder_hunger();
|
||||||
|
//True
|
||||||
|
return BetterRTP.getInstance().getSettings().getPlaceholder_true();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String canRTP_cooldown(Player player, World world) {
|
||||||
|
if (world == null) return "Invalid World";
|
||||||
|
world = HelperRTP.getActualWorld(player, world);
|
||||||
|
|
||||||
|
RTPSetupInformation setupInformation = new RTPSetupInformation(world, player, player, true);
|
||||||
|
WorldPlayer pWorld = HelperRTP.getPlayerWorld(setupInformation);
|
||||||
|
//Cooldown
|
||||||
|
if (HelperRTP_Check.isCoolingDown(player, pWorld))
|
||||||
|
return BetterRTP.getInstance().getSettings().getPlaceholder_cooldown();
|
||||||
|
//True
|
||||||
|
return BetterRTP.getInstance().getSettings().getPlaceholder_true();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String canRTP_price(Player player, World world) {
|
||||||
|
if (world == null) return "Invalid World";
|
||||||
|
world = HelperRTP.getActualWorld(player, world);
|
||||||
|
|
||||||
|
RTPSetupInformation setupInformation = new RTPSetupInformation(world, player, player, true);
|
||||||
|
WorldPlayer pWorld = HelperRTP.getPlayerWorld(setupInformation);
|
||||||
|
//Price
|
||||||
|
if (!BetterRTP.getInstance().getEco().hasBalance(pWorld))
|
||||||
|
return BetterRTP.getInstance().getSettings().getPlaceholder_balance();
|
||||||
|
//True
|
||||||
|
return BetterRTP.getInstance().getSettings().getPlaceholder_true();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String canRTP_hunger(Player player, World world) {
|
||||||
|
if (world == null) return "Invalid World";
|
||||||
|
world = HelperRTP.getActualWorld(player, world);
|
||||||
|
|
||||||
|
RTPSetupInformation setupInformation = new RTPSetupInformation(world, player, player, true);
|
||||||
|
WorldPlayer pWorld = HelperRTP.getPlayerWorld(setupInformation);
|
||||||
|
//Hunger
|
||||||
|
if (!BetterRTP.getInstance().getEco().hasHunger(pWorld))
|
||||||
|
return BetterRTP.getInstance().getSettings().getPlaceholder_hunger();
|
||||||
|
//True
|
||||||
|
return BetterRTP.getInstance().getSettings().getPlaceholder_true();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String price(Player player, World world) {
|
||||||
|
if (world == null) return "Invalid World";
|
||||||
|
world = HelperRTP.getActualWorld(player, world);
|
||||||
|
RTPSetupInformation setupInformation = new RTPSetupInformation(world, player, player, true);
|
||||||
|
WorldPlayer pWorld = HelperRTP.getPlayerWorld(setupInformation);
|
||||||
|
return String.valueOf(pWorld.getPrice());
|
||||||
|
}
|
||||||
|
|
||||||
|
private World getWorld(String world_name) {
|
||||||
|
World world = null;
|
||||||
|
if (world_name.length() > 0)
|
||||||
|
for (World _world : Bukkit.getWorlds())
|
||||||
|
if (world_name.equalsIgnoreCase(_world.getName())) {
|
||||||
|
world = _world;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return world;
|
||||||
|
}
|
||||||
|
}
|
||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.depends.regionPlugins;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.settings.SoftDepends;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum REGIONPLUGINS {
|
||||||
|
FACTIONSUUID("FactionsUUID", "Factions", new RTP_FactionsUUID()),
|
||||||
|
GRIEFDEFENDER("GriefDefender", new RTP_GriefDefender()),
|
||||||
|
GRIEFPREVENTION("GriefPrevention", new RTP_GriefPrevention()),
|
||||||
|
HCLAIMS("hClaims", "hClaim", new RTP_hClaims()),
|
||||||
|
HUSKCLAIMS("HuskClaims", new RTP_HuskClaims()),
|
||||||
|
HUSKTOWNS("HuskTowns", new RTP_HuskTowns()),
|
||||||
|
KINGDOMSX("KingdomsX", "Kingdoms", new RTP_KingdomsX()),
|
||||||
|
LANDS("Lands", new RTP_Lands()),
|
||||||
|
PUEBLOS("Pueblos", new RTP_Pueblos()),
|
||||||
|
REDPROTECT("RedProtect", new RTP_RedProtect()),
|
||||||
|
RESIDENCE("Residence", new RTP_Residence()),
|
||||||
|
SABERFACTIONS("SaberFactions", "Factions", new RTP_SaberFactions()),
|
||||||
|
TOWNY("Towny", new RTP_Towny()),
|
||||||
|
ULTIMATECLAIMS("UltimateClaims", new RTP_UltimateClaims()),
|
||||||
|
WORLDGUARD("WorldGuard", new RTP_WorldGuard()),
|
||||||
|
MINEPLOTS("MinePlots", new RTP_MinePlots()),
|
||||||
|
FACTIONSBRIDGE("FactionsBridge", new RTP_FactionsBridge()),
|
||||||
|
CRASH_CLAIM("CrashClaim", new RTP_CrashClaim());
|
||||||
|
|
||||||
|
private final SoftDepends.RegionPlugin plugin = new SoftDepends.RegionPlugin();
|
||||||
|
private final String setting_name, pluginyml_name;
|
||||||
|
private final RegionPluginCheck validator;
|
||||||
|
|
||||||
|
REGIONPLUGINS(String all_name, RegionPluginCheck validator) {
|
||||||
|
this(all_name, all_name, validator);
|
||||||
|
}
|
||||||
|
|
||||||
|
REGIONPLUGINS(String setting_name, String pluginyml_name, RegionPluginCheck validator) {
|
||||||
|
this.setting_name = setting_name;
|
||||||
|
this.pluginyml_name = pluginyml_name;
|
||||||
|
this.validator = validator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return plugin.isEnabled();
|
||||||
|
}
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.depends.regionPlugins;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
import net.crashcraft.crashclaim.CrashClaim;
|
||||||
|
|
||||||
|
public class RTP_CrashClaim implements RegionPluginCheck {
|
||||||
|
|
||||||
|
// NOT TESTED (3.6.9)
|
||||||
|
// CrashClaim (1.0.39)
|
||||||
|
// https://www.spigotmc.org/resources/crashclaim-claiming-plugin.94037/
|
||||||
|
public boolean check(Location loc) {
|
||||||
|
boolean result = true;
|
||||||
|
if (REGIONPLUGINS.CRASH_CLAIM.isEnabled())
|
||||||
|
try {
|
||||||
|
result = CrashClaim.getPlugin().getApi().getClaim(loc) == null; // no claim = valid
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.depends.regionPlugins;
|
||||||
|
|
||||||
|
import cc.javajobs.factionsbridge.FactionsBridge;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
public class RTP_FactionsBridge implements RegionPluginCheck {
|
||||||
|
|
||||||
|
// NOT TESTED (3.6.9)
|
||||||
|
// FactionsBridge (v1.3.8)
|
||||||
|
// https://www.spigotmc.org/resources/factionsbridge.89716/
|
||||||
|
public boolean check(Location loc) {
|
||||||
|
boolean result = true;
|
||||||
|
if (REGIONPLUGINS.FACTIONSBRIDGE.isEnabled())
|
||||||
|
try {
|
||||||
|
boolean claimed = FactionsBridge.getFactionsAPI().getClaim(loc).isClaimed();
|
||||||
|
result = !claimed;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.depends.regionPlugins;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.Board;
|
||||||
|
import com.massivecraft.factions.FLocation;
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
|
|
||||||
|
public class RTP_FactionsUUID implements RegionPluginCheck {
|
||||||
|
|
||||||
|
// NOT TESTED (2.13.2)
|
||||||
|
// FactionsUUID (v1.6.9.5-U0.5.16)
|
||||||
|
// https://www.spigotmc.org/resources/factionsuuid.1035/
|
||||||
|
public boolean check(Location loc) {
|
||||||
|
boolean result = true;
|
||||||
|
if (REGIONPLUGINS.FACTIONSUUID.isEnabled())
|
||||||
|
try {
|
||||||
|
Faction faction = Board.getInstance().getFactionAt(new FLocation(loc));
|
||||||
|
result = faction.isWilderness() || faction.isSafeZone();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.depends.regionPlugins;
|
||||||
|
|
||||||
|
import com.griefdefender.api.GriefDefender;
|
||||||
|
import com.griefdefender.api.claim.Claim;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
public class RTP_GriefDefender implements RegionPluginCheck {
|
||||||
|
|
||||||
|
// NOT TESTED (3.1.0)
|
||||||
|
// GriefDefender (v1.5.10)
|
||||||
|
// https://www.spigotmc.org/resources/griefdefender.68900/
|
||||||
|
public boolean check(Location loc) {
|
||||||
|
boolean result = true;
|
||||||
|
if (REGIONPLUGINS.GRIEFDEFENDER.isEnabled())
|
||||||
|
try {
|
||||||
|
for (Claim claim : GriefDefender.getCore().getAllClaims())
|
||||||
|
if (claim.contains(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())) {
|
||||||
|
result = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.depends.regionPlugins;
|
||||||
|
|
||||||
|
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
public class RTP_GriefPrevention implements RegionPluginCheck {
|
||||||
|
|
||||||
|
// TESTED (v2.13.0)
|
||||||
|
// GriefPrevention (v16.15.0)
|
||||||
|
// https://www.spigotmc.org/resources/griefprevention.1884/
|
||||||
|
public boolean check(Location loc) {
|
||||||
|
boolean result = true;
|
||||||
|
if (REGIONPLUGINS.GRIEFPREVENTION.isEnabled())
|
||||||
|
try {
|
||||||
|
result = GriefPrevention.instance.dataStore.getClaimAt(loc, true, null) == null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.depends.regionPlugins;
|
||||||
|
|
||||||
|
import net.william278.huskclaims.BukkitHuskClaims;
|
||||||
|
import net.william278.huskclaims.api.BukkitHuskClaimsAPI;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
public class RTP_HuskClaims implements RegionPluginCheck {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean check(Location loc) {
|
||||||
|
boolean result = true;
|
||||||
|
if (REGIONPLUGINS.HUSKCLAIMS.isEnabled()) {
|
||||||
|
try {
|
||||||
|
result = !BukkitHuskClaimsAPI.getInstance().getClaimAt(BukkitHuskClaims.Adapter.adapt(loc)).isPresent();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.depends.regionPlugins;
|
||||||
|
|
||||||
|
import net.william278.husktowns.api.BukkitHuskTownsAPI;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
public class RTP_HuskTowns implements RegionPluginCheck {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean check(Location loc) {
|
||||||
|
boolean result = true;
|
||||||
|
if (REGIONPLUGINS.HUSKTOWNS.isEnabled()) {
|
||||||
|
try {
|
||||||
|
result = !BukkitHuskTownsAPI.getInstance().getClaimAt(loc).isPresent();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.depends.regionPlugins;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
public class RTP_KingdomsX implements RegionPluginCheck {
|
||||||
|
|
||||||
|
// NOT TESTED (3.6.12)
|
||||||
|
// KingdomsX (v1.16.8.1.1)
|
||||||
|
// https://www.spigotmc.org/resources/kingdomsx.77670/
|
||||||
|
public boolean check(Location loc) {
|
||||||
|
boolean result = true;
|
||||||
|
if (REGIONPLUGINS.KINGDOMSX.isEnabled())
|
||||||
|
try {
|
||||||
|
org.kingdoms.constants.land.Land land = org.kingdoms.constants.land.Land.getLand(loc);
|
||||||
|
result = land == null || !land.isClaimed();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.depends.regionPlugins;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
|
import me.angeschossen.lands.api.LandsIntegration;
|
||||||
|
|
||||||
|
public class RTP_Lands implements RegionPluginCheck {
|
||||||
|
|
||||||
|
// Implemented (2.14.3)
|
||||||
|
// Tested (3.6.2)
|
||||||
|
// Lands (v6.28.13)
|
||||||
|
// https://www.spigotmc.org/resources/lands.53313/
|
||||||
|
public boolean check(Location loc) {
|
||||||
|
boolean result = true;
|
||||||
|
if (REGIONPLUGINS.LANDS.isEnabled())
|
||||||
|
try {
|
||||||
|
result = LandsIntegration.of(BetterRTP.getInstance()).getArea(loc) == null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.depends.regionPlugins;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
import pl.minecodes.plots.api.plot.PlotApi;
|
||||||
|
import pl.minecodes.plots.api.plot.PlotServiceApi;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class RTP_MinePlots implements RegionPluginCheck{
|
||||||
|
// NOT TESTED (3.6.6)
|
||||||
|
// MinePlots- (v4.0.1)
|
||||||
|
// https://builtbybit.com/resources/mineplots.21646/
|
||||||
|
|
||||||
|
private PlotServiceApi plotServiceApi;
|
||||||
|
|
||||||
|
public boolean check(Location loc) {
|
||||||
|
boolean result = true;
|
||||||
|
if (REGIONPLUGINS.MINEPLOTS.isEnabled())
|
||||||
|
try {
|
||||||
|
RegisteredServiceProvider<PlotServiceApi> serviceProvider = Bukkit.getServicesManager().getRegistration(PlotServiceApi.class);
|
||||||
|
Objects.requireNonNull(serviceProvider, "[MinePlots Respect] Service provider is null.");
|
||||||
|
plotServiceApi = serviceProvider.getProvider();
|
||||||
|
|
||||||
|
plotServiceApi = serviceProvider.getProvider();
|
||||||
|
PlotApi plot = plotServiceApi.getPlot(loc);
|
||||||
|
|
||||||
|
if (plot != null) {
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.references.depends.regionPlugins;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
import me.RonanCraft.Pueblos.Pueblos;
|
||||||
|
|
||||||
|
public class RTP_Pueblos implements RegionPluginCheck {
|
||||||
|
|
||||||
|
// NOT TESTED (3.1.0)
|
||||||
|
// Pueblos (v2.0.1)
|
||||||
|
// https://www.spigotmc.org/resources/pueblos.91255/
|
||||||
|
public boolean check(Location loc) {
|
||||||
|
boolean result = true;
|
||||||
|
if (REGIONPLUGINS.PUEBLOS.isEnabled())
|
||||||
|
try {
|
||||||
|
result = Pueblos.getInstance().getClaimHandler().getClaimMain(loc) == null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loaded 100 of 362 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user