mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-09-27 22:57:39 +02:00
Compare commits
341 Commits
0.0.28
...
spigot-1.1
Author | SHA1 | Date | |
---|---|---|---|
|
689d4a4fe9 | ||
|
f0671fb8b8 | ||
|
9cf6d9e991 | ||
|
b0a93c2c35 | ||
|
5229339a8c | ||
|
1a759dcc76 | ||
|
93a6aface2 | ||
|
0b64f47b8a | ||
|
617ccfd66a | ||
|
e808668fce | ||
|
91d52b8c1b | ||
|
eb71f1c1d1 | ||
|
15956b4844 | ||
|
4f60d8e319 | ||
|
f5f06167db | ||
|
0f595fac7d | ||
|
051fc6c92e | ||
|
22483ac052 | ||
|
51aa6dac47 | ||
|
029f117fc1 | ||
|
87cd76cdeb | ||
|
34b0127f99 | ||
|
7d3597faad | ||
|
58e7e3ad78 | ||
|
6906772138 | ||
|
080aae4a9e | ||
|
f6620ef2eb | ||
|
05359480a3 | ||
|
a317acce3d | ||
|
9b7c09955e | ||
|
8eb3a2926b | ||
|
71e67f2010 | ||
|
5df74aae28 | ||
|
4904d806be | ||
|
9a64ae58c7 | ||
|
c504909668 | ||
|
5b79228be7 | ||
|
6ab4c363ac | ||
|
5751879abd | ||
|
7d82fa3879 | ||
|
1bad72bbc2 | ||
|
f8bec4c1ee | ||
|
75d2be30fe | ||
|
787c1d09b4 | ||
|
20c56219f9 | ||
|
778ad2ab31 | ||
|
e3021367ab | ||
|
fdb22ab8b5 | ||
|
d16ccb7717 | ||
|
2207324598 | ||
|
d916deb3a9 | ||
|
659fcca7ee | ||
|
3928922de3 | ||
|
a9e660db65 | ||
|
486cff7e09 | ||
|
d09ad72491 | ||
|
7d5e96f291 | ||
|
393ad01d45 | ||
|
71d08da9dc | ||
|
f225363e67 | ||
|
162505553f | ||
|
812f4c78dc | ||
|
0ab32790eb | ||
|
0be605fe3a | ||
|
64f0f5113e | ||
|
fb80fbb515 | ||
|
81d64ecc5a | ||
|
aacf626635 | ||
|
12ab00f004 | ||
|
065fa22852 | ||
|
012ddf6e36 | ||
|
9b3adf7ba4 | ||
|
ab9dbe027e | ||
|
62307c6bcf | ||
|
e2b0723d24 | ||
|
1a57a509e6 | ||
|
ee8f0ff3d0 | ||
|
05d2a51fbf | ||
|
e73d84afa3 | ||
|
d4b642ec23 | ||
|
bc683183f6 | ||
|
3a5460cff3 | ||
|
f364828176 | ||
|
dfe5cfc26d | ||
|
ebd94fd081 | ||
|
ffee4fbbbe | ||
|
dcf8456511 | ||
|
1ac1fe7e2e | ||
|
c51a556ac7 | ||
|
eafe7f1d9c | ||
|
ff95908bf2 | ||
|
d2e69771c5 | ||
|
17a81dede7 | ||
|
efc9ad4715 | ||
|
7c78f414ac | ||
|
bfea4b2836 | ||
|
b1be39b908 | ||
|
68ba7dc76b | ||
|
cd96c0d2c0 | ||
|
06722986be | ||
|
9536835785 | ||
|
7b0c1ca6ae | ||
|
100b825765 | ||
|
186ec82afc | ||
|
093da07b00 | ||
|
8acb0f535e | ||
|
8e0590b6d1 | ||
|
9d7184d86e | ||
|
6b097087a2 | ||
|
99c810e1be | ||
|
f3c8f73975 | ||
|
b243b4d889 | ||
|
0adb854548 | ||
|
327e7dd0cb | ||
|
2bf377e575 | ||
|
4ab2e2bd7a | ||
|
a20028d9fc | ||
|
d025947134 | ||
|
df7bceea6e | ||
|
e22b068a97 | ||
|
d884db3d6c | ||
|
a1121adc10 | ||
|
e8cbb403c5 | ||
|
ae518bea39 | ||
|
4278cd5d7a | ||
|
fd6ef9ac08 | ||
|
3ac7a8c6ff | ||
|
0ad693db0c | ||
|
1aa8ce45ac | ||
|
fc952e6c9e | ||
|
5c1f712765 | ||
|
7034eee7b2 | ||
|
e8ecde5b4e | ||
|
baca2d3316 | ||
|
2040ea08a8 | ||
|
afe4e41b14 | ||
|
425093d887 | ||
|
a30e44bb35 | ||
|
3ac200bbc0 | ||
|
5c2c1cf465 | ||
|
9aa53f4a28 | ||
|
4648ca31d6 | ||
|
5e1d9aeb9d | ||
|
31db696b1a | ||
|
56221ee058 | ||
|
b7b148f057 | ||
|
ecd11a7f34 | ||
|
5ee12d7696 | ||
|
ff4fd1f3e7 | ||
|
5682b94aef | ||
|
886a8744e2 | ||
|
8c7798dec8 | ||
|
41643caff2 | ||
|
f8e5cced9e | ||
|
2da18a3417 | ||
|
d06f150358 | ||
|
1796945896 | ||
|
2063c8e30c | ||
|
9279be58aa | ||
|
9a2ff28ab9 | ||
|
aacdd54ffe | ||
|
6dd23ddeee | ||
|
d104da907f | ||
|
d84ec0bd3e | ||
|
f14fd9f692 | ||
|
69176c379b | ||
|
7aa4114742 | ||
|
42b01ec059 | ||
|
806beea62a | ||
|
38b15acd15 | ||
|
d950d8eb22 | ||
|
e02dd0e858 | ||
|
5718d789d9 | ||
|
f82de6be12 | ||
|
77096a931c | ||
|
1cba807351 | ||
|
35845e1caa | ||
|
cf2ff77ccb | ||
|
17fb0c5332 | ||
|
468715a29f | ||
|
f2090a917b | ||
|
1c413c82e5 | ||
|
4012e9bc01 | ||
|
6c9eeb06d0 | ||
|
a4771aa86a | ||
|
d2a362e5af | ||
|
859971b6ea | ||
|
79f43b9a62 | ||
|
4912984cf0 | ||
|
9528ad6049 | ||
|
1e322aa2ce | ||
|
bfcb2d596e | ||
|
2100e5cec9 | ||
|
dc8a301ff2 | ||
|
36a75a2bd6 | ||
|
d9928a60bb | ||
|
028482a46c | ||
|
f61ac373a4 | ||
|
414835a690 | ||
|
dafb14ffb4 | ||
|
067865f726 | ||
|
7009129085 | ||
|
5402a0ab4e | ||
|
2d022de19c | ||
|
ffe3201a93 | ||
|
a5c828e010 | ||
|
e926515175 | ||
|
cab45ff7b2 | ||
|
0015a3bcb7 | ||
|
a6555b171c | ||
|
89c4253f82 | ||
|
0c8548b12e | ||
|
fecdc32e0d | ||
|
9f4b70a0ef | ||
|
9329ab58c5 | ||
|
48c416b63f | ||
|
79693bcd8a | ||
|
b33a30ad89 | ||
|
f5deb96d2e | ||
|
c8efcbb801 | ||
|
39dc937ddf | ||
|
d92fcf1244 | ||
|
4d816cbd46 | ||
|
e409f990af | ||
|
16fcc5dccc | ||
|
523fbb1c83 | ||
|
20c8f585c0 | ||
|
28ea9d1f8d | ||
|
e37ec1bef6 | ||
|
4392d60b26 | ||
|
4d8879a255 | ||
|
21a5bb2933 | ||
|
fa01dde5d2 | ||
|
ccd21d0e22 | ||
|
9540ad434c | ||
|
dd36947184 | ||
|
3175fd0052 | ||
|
ae5557f816 | ||
|
8c5d8d689c | ||
|
17e3819b2f | ||
|
677491a33f | ||
|
232a5334f1 | ||
|
7a0b65187b | ||
|
e4900a62f4 | ||
|
af2ded09b5 | ||
|
dbf101bb4e | ||
|
70347779c2 | ||
|
5078868fda | ||
|
56bbd8f2ca | ||
|
3134e972a5 | ||
|
af28e22b58 | ||
|
d75c5d710a | ||
|
24d0f4719d | ||
|
accfda8d90 | ||
|
81e339172d | ||
|
e6c2b2e960 | ||
|
d491009451 | ||
|
545167824d | ||
|
ebf936735c | ||
|
6a97eb46c8 | ||
|
e37de65fd3 | ||
|
ae677607a1 | ||
|
26f74c9cf6 | ||
|
321d4c8764 | ||
|
becd114d87 | ||
|
d4776748bb | ||
|
360618cd96 | ||
|
faf14757f8 | ||
|
e3ff485b09 | ||
|
5de6385051 | ||
|
e3b660dcae | ||
|
4f516a7eb2 | ||
|
c23d7a2d14 | ||
|
ca72d9a8df | ||
|
727c768a38 | ||
|
811079b901 | ||
|
6d6a483275 | ||
|
7a4046f3f9 | ||
|
08d266210b | ||
|
0c691df591 | ||
|
d530621da0 | ||
|
f42f2d3aea | ||
|
5c4cbaa127 | ||
|
a8521b3998 | ||
|
f03ddda6c5 | ||
|
72db55a86b | ||
|
1f3748e10e | ||
|
14a453ea1a | ||
|
2096698b52 | ||
|
efe03d29aa | ||
|
5b12a9960f | ||
|
726a4d7ba2 | ||
|
1cd97d2bc1 | ||
|
bfc473ec85 | ||
|
4dcb4dd354 | ||
|
cd5933aa08 | ||
|
9ccb6308c2 | ||
|
340a9917a0 | ||
|
734337a5be | ||
|
4b28ed98a9 | ||
|
89036c12a7 | ||
|
9ec4c3b78a | ||
|
fbbd104881 | ||
|
8f5fba9959 | ||
|
43160e35d9 | ||
|
de987f0555 | ||
|
9e371b7a97 | ||
|
52712ff015 | ||
|
e4f38f50a0 | ||
|
b7463fa8b3 | ||
|
9d21bc3fc0 | ||
|
a81e322be3 | ||
|
de1cbddad1 | ||
|
d49f2ff976 | ||
|
0cd3de1af5 | ||
|
112abf3d03 | ||
|
7c2732145b | ||
|
9861869ad8 | ||
|
fc4e94bcd3 | ||
|
3551066e21 | ||
|
b29d7f35c5 | ||
|
3366e9705a | ||
|
ac8d5a9725 | ||
|
68bffc2c7e | ||
|
801ce6a4aa | ||
|
1406a86272 | ||
|
f73192d729 | ||
|
c403e59360 | ||
|
3832c43148 | ||
|
fca3d737db | ||
|
64da16507c | ||
|
a3ae2416c3 | ||
|
8e1bd7b832 | ||
|
9d906e9fff | ||
|
42ac3553a2 | ||
|
1af04abd37 | ||
|
9099f2367b | ||
|
de46b0846e | ||
|
60287a4526 | ||
|
82cfa1a4b3 | ||
|
1e8e5d9e03 |
32
.autorc
Normal file
32
.autorc
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"baseBranch": "spigot-1.13-1.16",
|
||||
"plugins": [
|
||||
[
|
||||
"gradle",
|
||||
{
|
||||
"gradleCommand": "./gradlew",
|
||||
"gradleOptions": [""]
|
||||
}
|
||||
],
|
||||
[
|
||||
"exec",
|
||||
{
|
||||
"canary": "./gradlew build discord"
|
||||
}
|
||||
],
|
||||
["conventional-commits", { "preset": "angular" }],
|
||||
"released",
|
||||
["upload-assets", ["./build/libs/*.jar"]]
|
||||
],
|
||||
"owner": "sekwah41",
|
||||
"repo": "Advanced-Portals",
|
||||
"name": "Sekwah",
|
||||
"email": "contact@sekwah.com",
|
||||
"onlyPublishWithReleaseLabel": true,
|
||||
"shipit": {
|
||||
"onlyGraduateWithReleaseLabel": true
|
||||
},
|
||||
"canary": {
|
||||
"message": "📦 Published PR to [discord](https://discord.sekwah.com/) as canary version: %v"
|
||||
}
|
||||
}
|
8
.github/PULL_REQUEST_TEMPLATE/pr_changelog_release_notes.md
vendored
Normal file
8
.github/PULL_REQUEST_TEMPLATE/pr_changelog_release_notes.md
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# What Changed
|
||||
Whatever changed here
|
||||
|
||||
## Release Notes
|
||||
If anything should be commented in the changelog release notes.
|
||||
|
||||
**NOTE:** Please remove this unless something important needs to be shared.
|
||||
It's just to save time looking up what is needed in the event we need to.
|
47
.github/workflows/gradle.yml
vendored
Normal file
47
.github/workflows/gradle.yml
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
name: Release
|
||||
|
||||
on: [push, workflow_dispatch]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Cache Gradle packages
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.gradle/caches
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
|
||||
restore-keys: ${{ runner.os }}-gradle
|
||||
- name: Cache Node packages
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: node_modules
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
|
||||
restore-keys: ${{ runner.os }}-node
|
||||
- name: Set up JDK 8
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: 8
|
||||
- name: Use Node.js 12.x
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 12.x
|
||||
- name: Prepare repository
|
||||
run: |
|
||||
git fetch --unshallow --tags
|
||||
yarn install --frozen-lockfile
|
||||
echo $(yarn bin) >> $GITHUB_PATH
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
- name: Create Release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
CURSE_API: ${{ secrets.CURSE_API }}
|
||||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
||||
run: |
|
||||
auto shipit
|
||||
|
16
.gitignore
vendored
16
.gitignore
vendored
@ -1,8 +1,18 @@
|
||||
*.class
|
||||
.*
|
||||
/build/
|
||||
/target/
|
||||
|
||||
.gradle/
|
||||
.idea/
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
node_modules/
|
||||
*.iml
|
||||
*.iws
|
||||
*.ipr
|
||||
.env
|
||||
out/
|
||||
logs/
|
||||
classes/
|
||||
run/
|
||||
|
240
CHANGELOG.md
Normal file
240
CHANGELOG.md
Normal file
@ -0,0 +1,240 @@
|
||||
# v0.9.2 (Thu Feb 24 2022)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- fix: Removes the false positive warning from McAntiMalware [#318](https://github.com/sekwah41/Advanced-Portals/pull/318) ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(deps): Update Deps ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update dependency com.sk89q.worldedit:worldedit-bukkit to v7.2.9 ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update Deps [#316](https://github.com/sekwah41/Advanced-Portals/pull/316) ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update dependency gradle to v7.3.3 ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
#### Authors: 2
|
||||
|
||||
- Sekwah ([@sekwah41](https://github.com/sekwah41))
|
||||
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
---
|
||||
|
||||
# v0.9.1 (Fri Dec 17 2021)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- fix: Error in position checks for portal creation [#310](https://github.com/sekwah41/Advanced-Portals/pull/310) ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(ci): Update release support flags ([@sekwah41](https://github.com/sekwah41))
|
||||
|
||||
#### Authors: 1
|
||||
|
||||
- Sekwah ([@sekwah41](https://github.com/sekwah41))
|
||||
|
||||
---
|
||||
|
||||
# v0.9.0 (Wed Dec 15 2021)
|
||||
|
||||
#### 🚀 Enhancement
|
||||
|
||||
- feat: WorldEdit Integration, fix logic error [#307](https://github.com/sekwah41/Advanced-Portals/pull/307) ([@JOO200](https://github.com/JOO200))
|
||||
- feat: Added WorldEdit Integration [#307](https://github.com/sekwah41/Advanced-Portals/pull/307) ([@JOO200](https://github.com/JOO200))
|
||||
- feat: Adds ability to configure warp message [#302](https://github.com/sekwah41/Advanced-Portals/pull/302) ([@maldahleh](https://github.com/maldahleh))
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- chore(deps): Update Velocity to 3.1.0 [#307](https://github.com/sekwah41/Advanced-Portals/pull/307) ([@JOO200](https://github.com/JOO200))
|
||||
- chore(deps): Update Deps ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update dependency gradle to v7.3.1 ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- docs: Update changelog ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(ci): Allow manual triggering ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(deps): Update Deps to v10.32.3 ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update dependency gradle to v7.3 ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update dependency io.netty:netty-all to v4.1.70.Final ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(ci): Update to list 1.17 as supported automatically ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(deps): Update dependency io.netty:netty-all to v4.1.69.Final ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update Deps to v10.32.1 ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update Deps to v10.32.0 ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): Update dependency com.velocitypowered:velocity-api to v1.1.9 ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
#### Authors: 4
|
||||
|
||||
- [@JOO200](https://github.com/JOO200)
|
||||
- Mohammed Al-Dahleh ([@maldahleh](https://github.com/maldahleh))
|
||||
- Sekwah ([@sekwah41](https://github.com/sekwah41))
|
||||
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
---
|
||||
|
||||
# v0.8.0 (Wed Sep 01 2021)
|
||||
|
||||
#### 🚀 Enhancement
|
||||
|
||||
- feat: Allow the ability to disable the proxy warning message [#292](https://github.com/sekwah41/Advanced-Portals/pull/292) ([@maldahleh](https://github.com/maldahleh))
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- chore(deps): Update Deps ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(ci): Update rennovate config ([@sekwah41](https://github.com/sekwah41))
|
||||
|
||||
#### Authors: 2
|
||||
|
||||
- Mohammed Al-Dahleh ([@maldahleh](https://github.com/maldahleh))
|
||||
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
---
|
||||
|
||||
# v0.7.2 (Wed Jul 14 2021)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- fix: Issue where portal events activate too early in survival [#280](https://github.com/sekwah41/Advanced-Portals/pull/280) ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(deps): update dependency com.velocitypowered:velocity-api to v1.1.9 [#278](https://github.com/sekwah41/Advanced-Portals/pull/278) ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): update dependency gradle to v7.1.1 [#277](https://github.com/sekwah41/Advanced-Portals/pull/277) ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
#### Authors: 2
|
||||
|
||||
- Sekwah ([@sekwah41](https://github.com/sekwah41))
|
||||
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
---
|
||||
|
||||
# v0.7.1 (Wed Jun 30 2021)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- fix: Access to portal warp command locked behind wrong perm [#275](https://github.com/sekwah41/Advanced-Portals/pull/275) ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(deps): update dependency gradle to v7 [#271](https://github.com/sekwah41/Advanced-Portals/pull/271) ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
#### Authors: 2
|
||||
|
||||
- Sekwah ([@sekwah41](https://github.com/sekwah41))
|
||||
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
---
|
||||
|
||||
# v0.7.0 (Sun Jun 27 2021)
|
||||
|
||||
#### 🚀 Enhancement
|
||||
|
||||
- feat: Added missing commands from tab complete [#270](https://github.com/sekwah41/Advanced-Portals/pull/270) ([@sekwah41](https://github.com/sekwah41))
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- chore(deps): update dependency net.md-5:bungeecord-api to v1.16-r0.4 [#269](https://github.com/sekwah41/Advanced-Portals/pull/269) ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(ci): removed verbose mode for release ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(deps): update dependency com.google.code.gson:gson to v2.8.7 [#262](https://github.com/sekwah41/Advanced-Portals/pull/262) ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): update dependency gradle to v6.9 [#267](https://github.com/sekwah41/Advanced-Portals/pull/267) ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- chore(deps): update dependency com.velocitypowered:velocity-api to v1.1.8 [#266](https://github.com/sekwah41/Advanced-Portals/pull/266) ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
#### Authors: 2
|
||||
|
||||
- Sekwah ([@sekwah41](https://github.com/sekwah41))
|
||||
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
---
|
||||
|
||||
# v0.6.1 (Sun Jun 27 2021)
|
||||
|
||||
#### 🐛 Bug Fix
|
||||
|
||||
- chore(ci): Remove isDevBranch remains [#265](https://github.com/sekwah41/Advanced-Portals/pull/265) ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(ci): Fix forgotten sha in build gradle [#264](https://github.com/sekwah41/Advanced-Portals/pull/264) ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(ci): Update version-bumping task order [#263](https://github.com/sekwah41/Advanced-Portals/pull/263) ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(deps): pin dependencies [#261](https://github.com/sekwah41/Advanced-Portals/pull/261) ([@renovate-bot](https://github.com/renovate-bot))
|
||||
- fix: Spigot 1.17 error message [#260](https://github.com/sekwah41/Advanced-Portals/pull/260) ([@sekwah41](https://github.com/sekwah41))
|
||||
- chore(ci): Swapping build pipeline ([@sekwah41](https://github.com/sekwah41))
|
||||
- ci: Fixed java version ([@sekwah41](https://github.com/sekwah41))
|
||||
- ci: Fix changelog reference ([@sekwah41](https://github.com/sekwah41))
|
||||
- ci: Updated build pipelines to newer module ([@sekwah41](https://github.com/sekwah41))
|
||||
|
||||
#### Authors: 2
|
||||
|
||||
- Sekwah ([@sekwah41](https://github.com/sekwah41))
|
||||
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
|
||||
|
||||
---
|
||||
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
For the release changelogs see [CHANGELOG.md](CHANGELOG.md)
|
||||
For the snapshot changelogs see [SNAPSHOT_CHANGELOG.md](SNAPSHOT_CHANGELOG.md)
|
||||
|
||||
## 0.6.0 (2021-05-19)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **proxy:** Added a ForceEnableProxySupport config option ([99c810e](https://github.com/sekwah41/Advanced-Portals/commit/99c810e1beeee743734ec451ffe5df312eec8726))
|
||||
* **proxy:** Added Velocity support ([b243b4d](https://github.com/sekwah41/Advanced-Portals/commit/b243b4d889b8039cb800d981d44d85da06ff62d5))
|
||||
* **proxy:** Modern forwarding will be automatically detected. ([f3c8f73](https://github.com/sekwah41/Advanced-Portals/commit/f3c8f73975857a4e5d31a6a21111eee8b7888bdd))
|
||||
* Added configurable proxy teleport delay ([a1121ad](https://github.com/sekwah41/Advanced-Portals/commit/a1121adc10addfcce515d1358d1274232109fdfd))
|
||||
|
||||
### 0.5.12
|
||||
|
||||
* Added support for Velocity.
|
||||
* Also fixed some issues with entity teleporting.
|
||||
|
||||
### 0.5.11
|
||||
|
||||
* Missing changelogs
|
||||
|
||||
### 0.5.10
|
||||
|
||||
* Missing changelogs
|
||||
|
||||
### 0.5.10
|
||||
|
||||
* Added fix for command portals spam triggering if they didn't teleport you out.
|
||||
* Made portals not activate if you were teleported into them by another portal (to allow linking zones like a star trek warp pad)
|
||||
|
||||
### 0.5.9
|
||||
|
||||
* Missing changelogs
|
||||
|
||||
### 0.5.8
|
||||
|
||||
* Missing changelogs
|
||||
|
||||
### 0.5.7
|
||||
|
||||
|
||||
* Extra checks added by @tmantti to fix slow connections to new servers from activating the destination location too quick.
|
||||
|
||||
### 0.5.6
|
||||
* Fixed packet exploit affecting destinations (only effecting versions 0.5.0 to 0.5.5).
|
||||
|
||||
### 0.5.5
|
||||
* Added support for 1.16
|
||||
* Reworked chat menus to better use Spigot API
|
||||
* Changed edit menu to have Activate instead of Teleport to destination
|
||||
* Compat code changed. You must now use Spigot rather than CraftBukkit.
|
||||
|
||||
### 0.5.4
|
||||
* Added bungee backup methods to ensure bungee and desti work correctly together
|
||||
* Fixed protection region issue
|
||||
* Reworked the warp command and fixed the surrounding permissions
|
||||
* Disabling gateway beams is now enabled for placing the blocks as well as by a few other means
|
||||
|
||||
### 0.5.3
|
||||
|
||||
* Fixed destination bug.
|
||||
|
||||
### 0.5.2
|
||||
|
||||
* Fixed issue with bungee destinations.
|
||||
|
||||
### 0.5.1
|
||||
|
||||
* Fixed warp permission info
|
||||
|
||||
### 0.5.0
|
||||
|
||||
* Added command:
|
||||
* Fix for bungee warps
|
||||
|
||||
### 0.4.0
|
||||
|
||||
* Individual portal cooldown added
|
||||
* Bungee improvements
|
||||
|
||||
### Earlier
|
||||
|
||||
* See github releases and spigot pages for more info.
|
46
CODE_OF_CONDUCT.md
Normal file
46
CODE_OF_CONDUCT.md
Normal file
@ -0,0 +1,46 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at sekwah41@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
7
DragAndDropStarter.bat
Normal file
7
DragAndDropStarter.bat
Normal file
@ -0,0 +1,7 @@
|
||||
REM Use this file for testing cases for different versions, just drag the version you want to test the plugin in and it will start.
|
||||
@ECHO OFF
|
||||
:A
|
||||
java -Xmx4096M -DIReallyKnowWhatIAmDoingISwear=true -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -jar %1
|
||||
REM Could add a 32 bit test part but noone uses 32 bit anymore
|
||||
GOTO A
|
||||
PAUSE
|
689
LICENSE.md
689
LICENSE.md
@ -1,674 +1,63 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
|
||||
Preamble
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
0. Additional Definitions.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
“The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
0. Definitions.
|
||||
If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
|
||||
b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license document.
|
||||
4. Combined Works.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
|
||||
c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
|
||||
d) Do one of the following:
|
||||
0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
|
||||
1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
|
||||
e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
|
||||
5. Combined Libraries.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
|
||||
b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
|
||||
1. Source Code.
|
||||
Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
Advanced lightweight portal plugin for minecraft.
|
||||
Copyright (C) 2016 sekwah41
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
Advanced-Portals Copyright (C) 2016 sekwah41
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
|
||||
|
69
README.md
69
README.md
@ -1,23 +1,64 @@
|
||||
Advanced Portals
|
||||
================
|
||||
![Advanced Portals](https://i.imgur.com/UIF6cQR.png)
|
||||
|
||||
<p>An advanced portals plugin for bukkit made by sekwah41 designed to have a wide range of features which are easy to use. It adds a bunch of commands to create and edit portals and destinations. This plugin not only enable normal teleportation but also cross server teleportation for networks using bungee.</p>
|
||||
[![Discord](https://img.shields.io/discord/168282484037910528.svg?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/fAJ3xJg)
|
||||
[![](https://img.shields.io/github/contributors/sekwah41/Advanced-Portals.svg?style=for-the-badge&logo=github)](https://github.com/sekwah41/Advanced-Portals/graphs/contributors)
|
||||
[![](https://img.shields.io/github/issues/sekwah41/Advanced-Portals.svg?style=for-the-badge&logo=github)](https://github.com/sekwah41/Advanced-Portals/issues)
|
||||
[![](https://img.shields.io/github/issues-pr/sekwah41/Advanced-Portals.svg?style=for-the-badge&logo=github)](https://github.com/sekwah41/Advanced-Portals/pulls)
|
||||
[![](https://img.shields.io/github/forks/sekwah41/Advanced-Portals.svg?style=for-the-badge&logo=github)](https://github.com/sekwah41/Advanced-Portals/network/members)
|
||||
[![](https://img.shields.io/github/stars/sekwah41/Advanced-Portals.svg?style=for-the-badge&logo=github)](https://github.com/sekwah41/Advanced-Portals/stargazers)
|
||||
[![](https://img.shields.io/github/license/sekwah41/Advanced-Portals.svg?logo=github&style=for-the-badge)](https://github.com/sekwah41/Advanced-Portals/blob/master/LICENSE.md)
|
||||
|
||||
<a href="https://github.com/sekwah41/Advanced-Portals/wiki/Commands">List Of Commands</a>
|
||||
Advanced Portals ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/sekwah41/Advanced-Portals/Build%20Project/master)
|
||||
==============
|
||||
An advanced portals plugin for bukkit made by sekwah41 designed to have a wide range of features which are easy to use. It adds a bunch of commands to create and edit portals and destinations. This plugin not only enable normal teleportation but also cross server teleportation for networks using bungee.
|
||||
|
||||
<a href="https://www.spigotmc.org/resources/advanced-portals.14356/">Spigot Page</a>
|
||||
# Recode
|
||||
We are currently slowly working on a complete re-code of the plugin with a full API.
|
||||
For now maintaining the current 1.13+ spigot versions is our main priority.
|
||||
|
||||
<a href="http://dev.bukkit.org/bukkit-plugins/advanced-portals/">Bukkit Page</a>
|
||||
<br>
|
||||
<br>
|
||||
<p>Usage Data</p>
|
||||
# Help
|
||||
[Command Documentation & Guides](https://www.guilded.gg/Sekwah/groups/MDqAZyrD/channels/72ffdaa3-9273-4722-bf47-b75408b371af/docs/1807463914)
|
||||
|
||||
<img src="http://i.mcstats.org/AdvancedPortals/Global+Statistics.borderless.png" alt="Global Plugin Stats" title="Global Plugin Stats">
|
||||
[List Of Commands](https://github.com/sekwah41/Advanced-Portals/wiki/Commands)
|
||||
|
||||
[Spigot Page](https://www.spigotmc.org/resources/advanced-portals.14356/)
|
||||
|
||||
<p>To get the needed bukkit versions download the spigot buildtools and run the appropriate commands for the versions listed in the pom file.</p>
|
||||
<p>e.g. "java -jar BuildTools.jar --rev 1.10.2" (Enter this into git bash)</p>
|
||||
[Bukkit Page](http://dev.bukkit.org/bukkit-plugins/advanced-portals/)
|
||||
|
||||
<p>Use the versions to test code before you turn it into reflection or suggest it to be turned into reflection.</p>
|
||||
# Usage Data
|
||||
Usage stats can be found here https://bstats.org/plugin/bukkit/AdvancedPortals
|
||||
|
||||
# API
|
||||
|
||||
The api isn't implemented in this version, sorry for any inconvenience. Check the recode tree for possibly a working recode at some point.
|
||||
|
||||
# Contributing
|
||||
|
||||
Don't worry about updating the file numbers in `bungee.yml`, `plugin.yml` and `AdvancedPortalsPlugin.java`.
|
||||
They will be updated automatically before builds.
|
||||
|
||||
Please ensure that your commits are in the following style for PR's
|
||||
|
||||
https://www.conventionalcommits.org/en/v1.0.0/
|
||||
|
||||
Accepted tags mostly follow the Angular style and are meant to only loosely be followed.
|
||||
When commits close an issue refer in the commit description in the following style (Refs #1, #2, #3)
|
||||
## Types available
|
||||
* **build**: Changes that affect the build system or external dependencies
|
||||
* **ci**: Changes to our CI configuration files and scripts
|
||||
* **docs**: Documentation only changes
|
||||
* **feat**: A new feature
|
||||
* **fix**: A bug fix
|
||||
* **perf**: A code change that improves performance
|
||||
* **refactor**: A code change that neither fixes a bug nor adds a feature
|
||||
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
|
||||
<!---
|
||||
We don't currently do tests. But in case.
|
||||
* **test**: Adding missing tests or correcting existing tests
|
||||
-->
|
||||
|
||||
## Scopes available
|
||||
Scopes are only needed if relating to specific features just to make them easier to find.
|
||||
_I'll expand the list as I work more on the project._
|
||||
* **proxy** (Proxy specific features and issues)
|
||||
|
||||
<p>You should never use direct craftbukkit references in public builds as it would only work in one spigot version</p>
|
||||
|
@ -1,54 +0,0 @@
|
||||
main: com.sekwah.advancedportals.AdvancedPortalsPlugin
|
||||
name: AdvancedPortals
|
||||
version: 0.0.28
|
||||
author: sekwah41
|
||||
description: An advanced portals plugin for bukkit.
|
||||
commands:
|
||||
advancedportals:
|
||||
description: The main command for the advanced portals
|
||||
aliases: [portals, aportals, portal, ap]
|
||||
usage: /<command>
|
||||
destination:
|
||||
description: Can be used to access portal destinations.
|
||||
aliases: [desti]
|
||||
usage: /<command>
|
||||
permissions:
|
||||
advancedportals.*:
|
||||
description: Gives access to all commands
|
||||
default: op
|
||||
children:
|
||||
advancedportals.createportal: true
|
||||
advancedportals.portal: true
|
||||
advancedportals.build: true
|
||||
advancedportals.desti: true
|
||||
advancedportals.createportal:
|
||||
description: Allows you to create portals
|
||||
default: op
|
||||
advancedportals.createportal.commandlevel.*:
|
||||
description: Gives access to all level raisers
|
||||
default: false
|
||||
children:
|
||||
advancedportals.createportal.commandlevel.op: true
|
||||
advancedportals.createportal.commandlevel.perms: true
|
||||
advancedportals.createportal.commandlevel.console: true
|
||||
advancedportals.createportal.commandlevel.op:
|
||||
description: Allows you to increase the users level temporaily to op
|
||||
default: false
|
||||
advancedportals.createportal.commandlevel.perms:
|
||||
description: Allows you to increase the users level temporaily to have all perms
|
||||
default: false
|
||||
advancedportals.createportal.commandlevel.console:
|
||||
description: Executes command in the console
|
||||
default: false
|
||||
advancedportals.portal:
|
||||
description: Allows use of portal commands
|
||||
default: op
|
||||
advancedportals.build:
|
||||
description: Allows you to build in the portal regions
|
||||
default: op
|
||||
advancedportals.desti:
|
||||
description: Gives access to all desti commands
|
||||
default: op
|
||||
advancedportals.warp.*:
|
||||
description: Access to all warps (not really used tbh)
|
||||
default: true
|
405
build.gradle
Normal file
405
build.gradle
Normal file
@ -0,0 +1,405 @@
|
||||
import com.google.gson.Gson
|
||||
import org.apache.commons.codec.Charsets
|
||||
import org.apache.http.HttpEntity
|
||||
import org.apache.http.HttpResponse
|
||||
import org.apache.http.client.HttpClient
|
||||
import org.apache.http.client.config.CookieSpecs
|
||||
import org.apache.http.client.config.RequestConfig
|
||||
import org.apache.http.client.methods.CloseableHttpResponse
|
||||
import org.apache.http.client.methods.HttpGet
|
||||
import org.apache.http.client.methods.HttpPost
|
||||
import org.apache.http.entity.ContentType
|
||||
import org.apache.http.entity.mime.MultipartEntityBuilder
|
||||
import org.apache.http.impl.client.CloseableHttpClient
|
||||
import org.apache.http.impl.client.HttpClientBuilder
|
||||
import org.apache.http.impl.client.HttpClients
|
||||
|
||||
import java.util.regex.Matcher
|
||||
import java.util.regex.Pattern
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
maven { url "https://plugins.gradle.org/m2/" }
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.apache.httpcomponents:httpmime:4.5.14"
|
||||
classpath "com.google.code.gson:gson:2.10.1"
|
||||
classpath "org.apache.httpcomponents:httpclient:4.5.14"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'net.researchgate.release' version '2.8.1'
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'idea'
|
||||
|
||||
def branch = System.getenv("GITHUB_REF");
|
||||
if (branch != null) {
|
||||
branch = branch.replace('refs/heads/', '')
|
||||
}
|
||||
def isCanary = version.toString().contains('canary')
|
||||
|
||||
group = 'com.sekwah.advancedportals'
|
||||
|
||||
description = ""
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
|
||||
String getPluginData(String tag) {
|
||||
File file = file("src/main/resources/plugin.yml")
|
||||
String version = "notfound"
|
||||
file.readLines("UTF-8").each { String line ->
|
||||
line = line.trim()
|
||||
if (line.startsWith(tag)) {
|
||||
version = line.substring(tag.length() + 2, line.length())
|
||||
}
|
||||
}
|
||||
println "Advanced Portals v" + version
|
||||
return version
|
||||
}
|
||||
|
||||
configurations {
|
||||
// configuration that holds jars to copy into lib
|
||||
includeLibs
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url "https://repo.maven.apache.org/maven2" }
|
||||
maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" }
|
||||
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
||||
maven { url "https://nexus.velocitypowered.com/repository/maven-public/" }
|
||||
maven { url 'https://papermc.io/repo/repository/maven-public/' }
|
||||
maven { url 'https://maven.enginehub.org/repo/' } // WorldEdit
|
||||
}
|
||||
|
||||
// includeLibs just says to include the library in the final jar
|
||||
dependencies {
|
||||
|
||||
//implementation "org.bukkit:bukkit:1.16.1-R0.1-SNAPSHOT"
|
||||
implementation "org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT"
|
||||
implementation "net.md-5:bungeecord-api:1.16-R0.4"
|
||||
|
||||
implementation "com.velocitypowered:velocity-api:3.1.1"
|
||||
annotationProcessor "com.velocitypowered:velocity-api:3.1.1"
|
||||
|
||||
implementation "io.netty:netty-all:4.1.87.Final"
|
||||
compileOnly 'com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT'
|
||||
|
||||
implementation "com.sk89q.worldedit:worldedit-bukkit:7.2.13"
|
||||
//compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
}
|
||||
|
||||
/** For pre-releases and testers to be able to try the latest commits if they want.
|
||||
* If the builds start exceeding 8MB then we may want to upload to s3 instead and periodically clear.
|
||||
* TODO possibly add a task that announces when builds are made?
|
||||
* Though add a note that it may take a while for Curse to approve the files.
|
||||
*/
|
||||
task discordupload {
|
||||
dependsOn(jar)
|
||||
doLast {
|
||||
String discordWebhook = System.getenv("DISCORD_WEBHOOK")
|
||||
|
||||
if (discordWebhook != null) {
|
||||
println("Logging Into Discord")
|
||||
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault()
|
||||
HttpPost uploadFile = new HttpPost(discordWebhook)
|
||||
|
||||
MultipartEntityBuilder builder = MultipartEntityBuilder.create()
|
||||
|
||||
if (isCanary) {
|
||||
builder.addTextBody("content", "New canary Build")
|
||||
} else {
|
||||
builder.addTextBody("content", "New release build\n\n" +
|
||||
"Current Features: <${project.github}/blob/${branch}/CHANGELOG.md>")
|
||||
}
|
||||
|
||||
builder.addBinaryBody("file", file(jar.archiveFile).newInputStream(), ContentType.APPLICATION_OCTET_STREAM, jar.archiveName)
|
||||
|
||||
HttpEntity multipart = builder.build()
|
||||
|
||||
uploadFile.setEntity(multipart)
|
||||
CloseableHttpResponse response = httpClient.execute(uploadFile)
|
||||
response.getEntity()
|
||||
|
||||
println("Posted build")
|
||||
|
||||
} else {
|
||||
println("Discord webhook unspecified")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String getValueFromCurseAPI(apiKey, endpoint) {
|
||||
String API_BASE_URL = 'https://minecraft.curseforge.com'
|
||||
|
||||
Gson gson = new Gson()
|
||||
|
||||
HttpClient client = HttpClientBuilder.create()
|
||||
.setDefaultRequestConfig(RequestConfig.custom()
|
||||
.setCookieSpec(CookieSpecs.IGNORE_COOKIES).build()).build()
|
||||
|
||||
HttpGet get = new HttpGet(API_BASE_URL + endpoint)
|
||||
get.setHeader('X-Api-Token', apiKey)
|
||||
|
||||
HttpResponse response = client.execute(get)
|
||||
|
||||
int statusCode = response.statusLine.statusCode
|
||||
|
||||
if (statusCode == 200) {
|
||||
byte[] data = response.entity.content.bytes
|
||||
return new String(data, Charsets.UTF_8)
|
||||
} else {
|
||||
if (response.getFirstHeader('content-type').value.contains('json')) {
|
||||
InputStreamReader reader = new InputStreamReader(response.entity.content)
|
||||
reader.close()
|
||||
throw new RuntimeException("[CurseForge] Error")
|
||||
} else {
|
||||
throw new RuntimeException("[CurseForge] HTTP Error Code $response.statusLine.statusCode: $response.statusLine.reasonPhrase")
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload a single file (in case you also want to upload the other files like source n stuff)
|
||||
* @param json
|
||||
* @param file
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
UploadResponse uploadFile(Metadata metadata, File file, String apiKey, Gson gson) throws IOException, URISyntaxException {
|
||||
String API_BASE_URL = 'https://minecraft.curseforge.com'
|
||||
String UPLOAD_URL = "/api/projects/%s/upload-file"
|
||||
// Upload
|
||||
// Important info
|
||||
String uploadUrl = String.format(API_BASE_URL + UPLOAD_URL, project.curse_project_id)
|
||||
|
||||
HttpClient client = HttpClientBuilder.create()
|
||||
.setDefaultRequestConfig(RequestConfig.custom()
|
||||
.setCookieSpec(CookieSpecs.IGNORE_COOKIES).build()).build()
|
||||
|
||||
HttpPost post = new HttpPost(uploadUrl)
|
||||
post.setHeader('X-Api-Token', apiKey)
|
||||
|
||||
|
||||
// https://support.curseforge.com/en/support/solutions/articles/9000197321-curseforge-api
|
||||
post.setEntity(MultipartEntityBuilder.create()
|
||||
.addTextBody('metadata', gson.toJson(metadata), ContentType.APPLICATION_JSON)
|
||||
.addBinaryBody('file', file)
|
||||
.build())
|
||||
|
||||
HttpResponse response = client.execute(post)
|
||||
InputStreamReader reader = new InputStreamReader(response.entity.content)
|
||||
UploadResponse uploadResponse = gson.fromJson(reader, UploadResponse)
|
||||
reader.close()
|
||||
return uploadResponse
|
||||
}
|
||||
|
||||
class GameVersion {
|
||||
int id
|
||||
int gameVersionTypeID
|
||||
String name
|
||||
String slug
|
||||
}
|
||||
|
||||
/**
|
||||
* As described here https://support.curseforge.com/en/support/solutions/articles/9000197321-curseforge-api
|
||||
*/
|
||||
class Metadata {
|
||||
String changelog
|
||||
String changelogType
|
||||
int[] gameVersions
|
||||
String releaseType
|
||||
}
|
||||
|
||||
class UploadResponse {
|
||||
int id;
|
||||
}
|
||||
|
||||
|
||||
// Based on https://github.com/matthewprenger/CurseGradle as it didnt support Bukkit uploads at the time.
|
||||
task curseforge {
|
||||
dependsOn(jar)
|
||||
doLast {
|
||||
String apiKey = null
|
||||
|
||||
if (System.getenv("CURSE_API") != null) {
|
||||
apiKey = System.getenv("CURSE_API")
|
||||
}
|
||||
|
||||
if (apiKey != null) {
|
||||
|
||||
Gson gson = new Gson()
|
||||
|
||||
//String VERSION_TYPES_URL = "/api/game/version-types"
|
||||
int gameVersionTypeID = 1
|
||||
String VERSION_URL = "/api/game/versions"
|
||||
println("Uploading to CurseForge")
|
||||
|
||||
// Get game versions
|
||||
String gameVersionsString = getValueFromCurseAPI(apiKey, VERSION_URL)
|
||||
GameVersion[] gameVersions = gson.fromJson(gameVersionsString, GameVersion[].class)
|
||||
def versions = gameVersions.findAll { it.gameVersionTypeID == gameVersionTypeID }
|
||||
|
||||
String[] supportedVersions = [
|
||||
"1.18",
|
||||
"1.17",
|
||||
"1.16",
|
||||
"1.15",
|
||||
"1.14",
|
||||
"1.13"
|
||||
]
|
||||
|
||||
def supportedGameVersions = versions.findAll { supportedVersions.contains(it.name) }
|
||||
int[] supportedGameVersionIds = supportedGameVersions.collect { it.id }.toArray()
|
||||
|
||||
println("Supported Version Id's ${supportedGameVersionIds}")
|
||||
|
||||
Metadata uploadMetadata = new Metadata();
|
||||
|
||||
uploadMetadata.changelog = "${project.github}/blob/${branch}/CHANGELOG.md"
|
||||
uploadMetadata.changelogType = "markdown"
|
||||
uploadMetadata.releaseType = "release"
|
||||
uploadMetadata.gameVersions = supportedGameVersionIds
|
||||
|
||||
def uploadId = uploadFile(uploadMetadata, file(jar.archiveFile), apiKey, gson)
|
||||
|
||||
println("Uploaded with ID: ${uploadId.id}")
|
||||
|
||||
println("Published build")
|
||||
|
||||
} else {
|
||||
println("Discord webhook unspecified")
|
||||
}
|
||||
}
|
||||
// id = project.curse_project_id
|
||||
// // TODO add code to reference this but also cut the latest change logs in for the files
|
||||
// changelogType = 'markdown'
|
||||
// releaseType = 'release'
|
||||
}
|
||||
|
||||
task copyPlugin {
|
||||
doLast {
|
||||
copy {
|
||||
if (System.env.MC_SERVER_LOC == null) {
|
||||
throw new Exception('You must set the server location and jar to use')
|
||||
}
|
||||
println "$buildDir/libs/Advanced-Portals-${version}.jar"
|
||||
println "${System.env.MC_SERVER_LOC}/plugins/Advanced-Portals-${version}.jar"
|
||||
try {
|
||||
delete fileTree("${System.env.MC_SERVER_LOC}/plugins/") {
|
||||
include "*.jar"
|
||||
}
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
println e.getLocalizedMessage()
|
||||
}
|
||||
from file("$buildDir/libs/Advanced-Portals-${version}.jar")
|
||||
into file("${System.env.MC_SERVER_LOC}/plugins/")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set SPIGOT_LOC to the location of your server and SPIGOT_JAR as the name of the jar file in the server you want to run
|
||||
// DIReallyKnowWhatIAmDoingISwear is to remove the stupid pause spigot has at the start
|
||||
task runJar() {
|
||||
doLast {
|
||||
if (System.env.MC_SERVER_LOC == null || System.env.MC_SERVER_JAR == null) {
|
||||
throw new Exception('You must set the server location and jar to use MC_SERVER_LOC and MC_SERVER_JAR')
|
||||
}
|
||||
javaexec {
|
||||
main "-jar"
|
||||
args "${System.env.MC_SERVER_LOC}\\${System.env.MC_SERVER_JAR}.jar"
|
||||
jvmArgs = ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", "-DIReallyKnowWhatIAmDoingISwear=true"]
|
||||
workingDir "${System.env.MC_SERVER_LOC}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task publish {
|
||||
doLast {
|
||||
println "This is a dummy task to run others for version: ${version}"
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/researchgate/gradle-release
|
||||
// Only other plugin I can find using auto & gradle https://github.com/intuit/hooks
|
||||
release {
|
||||
failOnPublishNeeded = false
|
||||
failOnSnapshotDependencies = false
|
||||
git {
|
||||
requireBranch = ''
|
||||
}
|
||||
|
||||
|
||||
// Disable tasks because something we have is causing -x to be ignored
|
||||
createReleaseTag.enabled = false
|
||||
preTagCommit.enabled = false
|
||||
commitNewVersion.enabled = false
|
||||
}
|
||||
|
||||
task cleanbuildfolder {
|
||||
doFirst {
|
||||
println "Cleaning up previous builds (to stop publishing old ones by mistake)"
|
||||
project.delete(files("${buildDir}/libs"))
|
||||
}
|
||||
}
|
||||
|
||||
void updateFileVersion(String fileLoc, Pattern pattern, Closure<String> stringClosure) {
|
||||
File file = new File(projectDir, fileLoc)
|
||||
Matcher m = pattern.matcher(file.text)
|
||||
if (m.find()) {
|
||||
def newVersion = stringClosure.call(m)
|
||||
println "Replacing ${pattern.toString()} in ${fileLoc} with '${newVersion}'"
|
||||
file.text = file.text.replaceAll(pattern, newVersion)
|
||||
}
|
||||
}
|
||||
|
||||
// Just to keep all numbers the same (as they are dotted all over the place)
|
||||
task updateVersionNumbers {
|
||||
doFirst {
|
||||
def versionRegex = ~/(\nversion:\s)([0-9.-]+)/
|
||||
def velocityVersionRegex = ~/(\sversion\s=\s")([0-9.-]+)("\))/
|
||||
|
||||
updateFileVersion("src/main/resources/bungee.yml", versionRegex,
|
||||
{ Matcher m ->
|
||||
return "${m.group(1)}${getVersion()}"
|
||||
})
|
||||
|
||||
updateFileVersion("src/main/resources/plugin.yml", versionRegex,
|
||||
{ Matcher m ->
|
||||
return "${m.group(1)}${getVersion()}"
|
||||
})
|
||||
|
||||
updateFileVersion("src/main/java/com/sekwah/advancedportals/velocity/AdvancedPortalsPlugin.java",
|
||||
velocityVersionRegex,
|
||||
{ Matcher m ->
|
||||
return "${m.group(1)}${getVersion()}${m.group(3)}"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
updateVersion.finalizedBy 'updateVersionNumbers'
|
||||
|
||||
compileJava.dependsOn 'cleanbuildfolder'
|
||||
|
||||
// Publish rules
|
||||
// Current behavior seems to be canary or release. Though pre-releases may break this pattern.
|
||||
publish.dependsOn 'build'
|
||||
publish.finalizedBy 'discordupload'
|
||||
if (!isCanary) {
|
||||
publish.finalizedBy 'curseforge'
|
||||
}
|
7
gradle.properties
Normal file
7
gradle.properties
Normal file
@ -0,0 +1,7 @@
|
||||
# https://docs.gradle.org/current/userguide/build_environment.html
|
||||
# Disable with --no-build-cache
|
||||
org.gradle.caching=true
|
||||
|
||||
github=https://github.com/sekwah41/Advanced-Portals
|
||||
curse_project_id=86001
|
||||
version=0.9.2
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
244
gradlew
vendored
Executable file
244
gradlew
vendored
Executable file
@ -0,0 +1,244 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
92
gradlew.bat
vendored
Normal file
92
gradlew.bat
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
12
package.json
Normal file
12
package.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"devDependencies": {
|
||||
"conventional-changelog-angular": "5.0.13",
|
||||
"@auto-it/conventional-commits": "10.37.6",
|
||||
"@auto-it/exec": "10.37.6",
|
||||
"@auto-it/first-time-contributor": "10.37.6",
|
||||
"@auto-it/gradle": "10.37.6",
|
||||
"@auto-it/released": "10.37.6",
|
||||
"@auto-it/upload-assets": "10.37.6",
|
||||
"auto": "10.37.6"
|
||||
}
|
||||
}
|
42
pom.xml
42
pom.xml
@ -1,42 +0,0 @@
|
||||
<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>com.sekwah.advancedportals</groupId>
|
||||
<artifactId>Advanced-Portals</artifactId>
|
||||
<build>
|
||||
<sourceDirectory>${basedir}/src/</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${basedir}/Resources</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<version>0.0.28-snapshot</version>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- spigot's buildtools automatically places it in maven's repository after building it -->
|
||||
<!-- Craftbukkit contains the bukkit code. But as the majority uses it uses bukkit
|
||||
it stops the need to build to edit at least -->
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.12-pre2-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.10.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>-->
|
||||
</dependencies>
|
||||
</project>
|
15
renovate.json
Normal file
15
renovate.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"extends": [
|
||||
"config:base"
|
||||
],
|
||||
"packageRules": [
|
||||
{
|
||||
"commitMessagePrefix": "chore(deps):",
|
||||
"matchUpdateTypes": ["minor", "patch"],
|
||||
"automerge": true,
|
||||
"automergeType": "branch",
|
||||
"groupName": "Deps",
|
||||
"schedule": ["every weekend"]
|
||||
}
|
||||
]
|
||||
}
|
@ -1,619 +0,0 @@
|
||||
package com.sekwah.advancedportals;
|
||||
|
||||
import com.sekwah.advancedportals.api.portaldata.PortalArg;
|
||||
import com.sekwah.advancedportals.listeners.Listeners;
|
||||
import com.sekwah.advancedportals.portals.AdvancedPortal;
|
||||
import com.sekwah.advancedportals.portals.Portal;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
private AdvancedPortalsPlugin plugin;
|
||||
|
||||
private int portalArgsStringLength = 0;
|
||||
|
||||
// TODO recode the portal args to be put into a hashmap and use a string array
|
||||
// to store all possible portal arguments. Makes code shorter and possibly more efficient.
|
||||
//private HashMap<String, String> portalArgs = new HashMap<>();
|
||||
|
||||
public AdvancedPortalsCommand(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
plugin.getCommand("advancedportals").setExecutor(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String command, String[] args) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "portals.yml");
|
||||
Player player = (Player) sender;
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
if (sender.hasPermission("advancedportals.portal")) {
|
||||
if (args.length > 0) { switch (args[0].toLowerCase()) {
|
||||
case "wand":
|
||||
case "selector":
|
||||
String ItemID = config.getConfig().getString("AxeItemId");
|
||||
|
||||
|
||||
Material WandMaterial = Material.getMaterial(ItemID);
|
||||
|
||||
if (WandMaterial == null) {
|
||||
WandMaterial = Material.IRON_AXE;
|
||||
}
|
||||
|
||||
ItemStack regionselector = new ItemStack(WandMaterial);
|
||||
ItemMeta selectorname = regionselector.getItemMeta();
|
||||
selectorname.setDisplayName("\u00A7ePortal Region Selector");
|
||||
selectorname.setLore(Arrays.asList("\u00A7rThis wand with has the power to help"
|
||||
, "\u00A7r create portals bistowed upon it!"));
|
||||
regionselector.setItemMeta(selectorname);
|
||||
|
||||
inventory.addItem(regionselector);
|
||||
sender.sendMessage(PluginMessages.customPrefix + " You have been given a \u00A7ePortal Region Selector\u00A7a!");
|
||||
break;
|
||||
case "portalblock":
|
||||
// TODO change this to a purple wool block and give it a name with a color. Then listen to when its placed.
|
||||
// Also do this for other blocks such as gateways and end portals just in case they want it.
|
||||
ItemStack portalBlock = new ItemStack(Material.PORTAL, 1);
|
||||
|
||||
inventory.addItem(portalBlock);
|
||||
|
||||
sender.sendMessage(PluginMessages.customPrefix + " You have been given a \u00A7ePortal Block\u00A7a!");
|
||||
break;
|
||||
case "create":
|
||||
if (player.hasMetadata("Pos1World") && player.hasMetadata("Pos2World")) {
|
||||
if (player.getMetadata("Pos1World").get(0).asString().equals(player.getMetadata("Pos2World").get(0).asString())
|
||||
&& player.getMetadata("Pos1World").get(0).asString().equals(player.getLocation().getWorld().getName())) {
|
||||
if (args.length >= 2) { // may make this next piece of code more efficient, maybe check against a list of available variables or something
|
||||
// TODO change system to use arrays and hashmaps
|
||||
boolean hasName = false;
|
||||
boolean hasTriggerBlock = false;
|
||||
boolean hasDestination = false;
|
||||
boolean isBungeePortal = false;
|
||||
boolean needsPermission = false;
|
||||
boolean executesCommand = false;
|
||||
String destination = null;
|
||||
String portalName = null;
|
||||
String triggerBlock = null;
|
||||
String serverName = null;
|
||||
String permission = null;
|
||||
String portalCommand = null;
|
||||
|
||||
ArrayList<PortalArg> extraData = new ArrayList<>();
|
||||
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
if (args[i].toLowerCase().startsWith("name:") && args[i].length() > 5) {
|
||||
hasName = true;
|
||||
portalName = args[i].replaceFirst("name:", "");
|
||||
} else if (args[i].toLowerCase().startsWith("name:")) {
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " You must include a name for the portal that isnt nothing!");
|
||||
return true;
|
||||
} else if (args[i].toLowerCase().startsWith("destination:") && args[i].length() > 12) {
|
||||
hasDestination = true;
|
||||
destination = args[i].toLowerCase().replaceFirst("destination:", "");
|
||||
} else if (args[i].toLowerCase().startsWith("desti:") && args[i].length() > 6) {
|
||||
hasDestination = true;
|
||||
destination = args[i].toLowerCase().replaceFirst("desti:", "");
|
||||
} else if (args[i].toLowerCase().startsWith("triggerblock:") && args[i].length() > 13) {
|
||||
hasTriggerBlock = true;
|
||||
triggerBlock = args[i].toLowerCase().replaceFirst("triggerblock:", "");
|
||||
} else if (args[i].toLowerCase().startsWith("triggerblock:") && args[i].length() > 13) {
|
||||
hasTriggerBlock = true;
|
||||
triggerBlock = args[i].toLowerCase().replaceFirst("triggerblock:", "");
|
||||
} else if (args[i].toLowerCase().startsWith("bungee:") && args[i].length() > 7) { // not completely implemented
|
||||
isBungeePortal = true;
|
||||
serverName = args[i].toLowerCase().replaceFirst("bungee:", "");
|
||||
//extraData.add(new PortalArgs("bungee", serverName));
|
||||
} else if (args[i].toLowerCase().startsWith("permission:") && args[i].length() > 11) { // not completely implemented
|
||||
needsPermission = true;
|
||||
permission = args[i].toLowerCase().replaceFirst("permission:", "");
|
||||
extraData.add(new PortalArg("permission", permission));
|
||||
} else if (args[i].toLowerCase().startsWith("command:") && args[i].length() > 8) { // not completely implemented
|
||||
executesCommand = true;
|
||||
portalCommand = parseArgVariable(args, i, "command:");
|
||||
i += this.portalArgsStringLength - 1;
|
||||
if(portalCommand.startsWith("#")
|
||||
&& !(this.plugin.getSettings().hasCommandLevel("c")
|
||||
&& (sender.hasPermission("advancedportals.createportal.commandlevel.console")
|
||||
|| (this.plugin.getSettings().hasCommandLevel("k") && sender.isOp()) ) )){
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " You need permission to make a console command portal!");
|
||||
return true;
|
||||
}
|
||||
else if(portalCommand.startsWith("!")
|
||||
&& !(this.plugin.getSettings().hasCommandLevel("o")
|
||||
&& (sender.hasPermission("advancedportals.createportal.commandlevel.op")
|
||||
|| (this.plugin.getSettings().hasCommandLevel("h") && sender.isOp()) ) )){
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " You need permission to make a op command portal!");
|
||||
return true;
|
||||
}
|
||||
else if(portalCommand.startsWith("^")
|
||||
&& !(this.plugin.getSettings().hasCommandLevel("p")
|
||||
&& (sender.hasPermission("advancedportals.createportal.commandlevel.perms")
|
||||
|| (this.plugin.getSettings().hasCommandLevel("e") && sender.isOp()) ) )){
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " You need permission to make a all perms command portal!");
|
||||
return true;
|
||||
}
|
||||
extraData.add(new PortalArg("command.1", portalCommand));
|
||||
}
|
||||
}
|
||||
if (!hasName) {
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " You must include a name for the portal that you are creating in the variables!");
|
||||
return true;
|
||||
}
|
||||
|
||||
World world = org.bukkit.Bukkit.getWorld(player.getMetadata("Pos1World").get(0).asString());
|
||||
Location pos1 = new Location(world, player.getMetadata("Pos1X").get(0).asInt(), player.getMetadata("Pos1Y").get(0).asInt(), player.getMetadata("Pos1Z").get(0).asInt());
|
||||
Location pos2 = new Location(world, player.getMetadata("Pos2X").get(0).asInt(), player.getMetadata("Pos2Y").get(0).asInt(), player.getMetadata("Pos2Z").get(0).asInt());
|
||||
|
||||
ConfigAccessor desticonfig = new ConfigAccessor(plugin, "destinations.yml");
|
||||
String destiPosX = desticonfig.getConfig().getString(destination + ".pos1.X");
|
||||
|
||||
if (!Portal.portalExists(portalName)) {
|
||||
|
||||
player.sendMessage("");
|
||||
player.sendMessage(PluginMessages.customPrefix + "\u00A7e You have created a new portal with the following details:");
|
||||
player.sendMessage("\u00A7aname: \u00A7e" + portalName);
|
||||
if (hasDestination) {
|
||||
player.sendMessage("\u00A7adestination: \u00A7e" + destination);
|
||||
} else if (destiPosX == null) {
|
||||
player.sendMessage("\u00A7cdestination: \u00A7e" + destination + " (destination does not exist)");
|
||||
} else {
|
||||
player.sendMessage("\u00A7cdestination: \u00A7eN/A (will not work)");
|
||||
}
|
||||
|
||||
if (isBungeePortal) {
|
||||
player.sendMessage("\u00A7abungee: \u00A7e" + serverName);
|
||||
}
|
||||
|
||||
if (needsPermission) {
|
||||
player.sendMessage("\u00A7apermission: \u00A7e" + permission);
|
||||
} else {
|
||||
player.sendMessage("\u00A7apermission: \u00A7e(none needed)");
|
||||
}
|
||||
|
||||
if (executesCommand) {
|
||||
player.sendMessage("\u00A7acommand: \u00A7e" + portalCommand);
|
||||
}
|
||||
|
||||
Material triggerBlockMat = Material.getMaterial(0);
|
||||
if (hasTriggerBlock) {
|
||||
triggerBlockMat = Material.getMaterial(triggerBlock.toUpperCase());
|
||||
if (triggerBlockMat != null) {
|
||||
player.sendMessage("\u00A7atriggerBlock: \u00A7e" + triggerBlock.toUpperCase());
|
||||
PortalArg[] portalArgs = new PortalArg[extraData.size()];
|
||||
portalArgs = extraData.toArray(portalArgs);
|
||||
player.sendMessage(Portal.create(pos1, pos2, portalName, destination, triggerBlockMat, serverName, portalArgs));
|
||||
} else {
|
||||
hasTriggerBlock = false;
|
||||
ConfigAccessor Config = new ConfigAccessor(plugin, "config.yml");
|
||||
player.sendMessage("\u00A7ctriggerBlock: \u00A7edefault(" + Config.getConfig().getString("DefaultPortalTriggerBlock") + ")");
|
||||
|
||||
player.sendMessage("\u00A7cThe block " + triggerBlock.toUpperCase() + " is not a valid block name in minecraft so the trigger block has been set to the default!");
|
||||
PortalArg[] portalArgs = new PortalArg[extraData.size()];
|
||||
portalArgs = extraData.toArray(portalArgs);
|
||||
player.sendMessage(Portal.create(pos1, pos2, portalName, destination, serverName, portalArgs));
|
||||
}
|
||||
} else {
|
||||
ConfigAccessor Config = new ConfigAccessor(plugin, "config.yml");
|
||||
player.sendMessage("\u00A7atriggerBlock: \u00A7edefault(" + Config.getConfig().getString("DefaultPortalTriggerBlock") + ")");
|
||||
PortalArg[] portalArgs = new PortalArg[extraData.size()];
|
||||
portalArgs = extraData.toArray(portalArgs);
|
||||
player.sendMessage(Portal.create(pos1, pos2, portalName, destination, serverName, portalArgs));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " A portal by that name already exists!");
|
||||
}
|
||||
|
||||
// add code to save the portal to the portal config and reload the portals
|
||||
|
||||
player.sendMessage("");
|
||||
} else {
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " You need to at least add the name of the portal as a variable, \u00A7cType \u00A7e/portal variables\u00A7c"
|
||||
+ " for a full list of currently available variables and an example command!");
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " The points you have selected need to be in the same world!");
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " You need to have two points selected to make a portal!");
|
||||
}
|
||||
break;
|
||||
case "variables" :
|
||||
sender.sendMessage(PluginMessages.customPrefix + " \u00A77Variables \u00A7c: \u00A7aname, triggerBlock, destination");
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage("\u00A7aExample command: \u00A7e/portal create name:test triggerId:portal");
|
||||
break;
|
||||
case "select":
|
||||
// TODO finish the select command and the hit block to replace!
|
||||
if (!player.hasMetadata("selectingPortal")) {
|
||||
if (args.length > 1) {
|
||||
if (Portal.portalExists(args[1])) {
|
||||
player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, args[1]));
|
||||
} else {
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " No portal by the name \u00A7e" + args[1] + "\u00A7c exists (maybe you got the caps wrong)\n Try typing \u00A7e/portal select\u00A7c and hit inside the apropriate portals area!");
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(PluginMessages.customPrefix + " Hit a block inside the portal region to select the portal!");
|
||||
player.setMetadata("selectingPortal", new FixedMetadataValue(plugin, true));
|
||||
}
|
||||
|
||||
} else {
|
||||
player.removeMetadata("selectingPortal", plugin);
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " Portal selection cancelled!");
|
||||
}
|
||||
break;
|
||||
case "gui" :
|
||||
if (args.length > 1) {
|
||||
if (args[1].toLowerCase().equals("remove") && args.length > 2) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " Are you sure you would like to remove the portal \u00A7e" + args[2] + "\u00A7c?");
|
||||
sender.sendMessage("");
|
||||
plugin.compat.sendRawMessage("{\"text\":\" \",\"extra\":[{\"text\":\"\u00A7e[Yes]\",\"hoverEvent\":{\"action\":\"show_text\"," +
|
||||
"\"value\":\"Confirm removing this portal\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal remove " + args[2] + "\"}}, " +
|
||||
"{\"text\":\" \"},{\"text\":\"\u00A7e[No]\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Cancel removing this portal\"}" +
|
||||
",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal edit " + args[2] + "\"}}]}", player);
|
||||
sender.sendMessage("");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "edit":
|
||||
if (args.length > 1) {
|
||||
if (Portal.portalExists(args[1])) {
|
||||
player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, args[1]));
|
||||
portalEditMenu(sender, portalConfig, args[1]);
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " No portal by the name \u00A7e" + args[1] + "\u00A7c exists!");
|
||||
}
|
||||
} else {
|
||||
if (player.hasMetadata("selectedPortal")) {
|
||||
String portalName = player.getMetadata("selectedPortal").get(0).asString();
|
||||
String posX = portalConfig.getConfig().getString(portalName + ".pos1.X");
|
||||
if (posX != null) {
|
||||
portalEditMenu(sender, portalConfig, portalName);
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " The portal you had selected no longer seems to exist!");
|
||||
player.removeMetadata("selectedPortal", plugin);
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " No portal has been defined or selected!");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "rename":
|
||||
|
||||
// not finished yet /
|
||||
if (args.length > 1) {
|
||||
if (player.hasMetadata("selectedPortal")) {
|
||||
String portalName = player.getMetadata("selectedPortal").get(0).asString();
|
||||
if (portalName.toLowerCase() != args[1].toLowerCase()) {
|
||||
String posX = portalConfig.getConfig().getString(portalName + ".pos1.X");
|
||||
|
||||
String newPortalPosX = portalConfig.getConfig().getString(args[1] + ".pos1.X");
|
||||
if (posX != null && newPortalPosX == null) {
|
||||
Portal.rename(portalName, args[1]);
|
||||
sender.sendMessage(PluginMessages.customPrefix + " The portal \u00A7e" + portalName + "\u00A7a has been renamed to \u00A7e" + args[1] + "\u00A7a.");
|
||||
player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, args[1]));
|
||||
} else if (newPortalPosX != null) {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " There is already a portal with the name \u00A7e" + args[1] + "\u00A7c!");
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " The portal you had selected no longer seems to exist!");
|
||||
player.removeMetadata("selectedPortal", plugin);
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " The portal you have selected is already called that!");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " No portal has been defined or selected!");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " You must select a portal first and then type \u00A7e/portal rename (new name)\u00A7c!");
|
||||
}
|
||||
break;
|
||||
case "command":
|
||||
if (player.hasMetadata("selectedPortal")) {
|
||||
String portalName = player.getMetadata("selectedPortal").get(0).asString();
|
||||
if (args.length > 1) {
|
||||
// TODO add the command autocompletes, add, remove and show
|
||||
if (args[1].toLowerCase().equals("add")) {
|
||||
if (args.length > 2) {
|
||||
String portalCommand = args[2];
|
||||
for (int i = 3; i < args.length; i++) {
|
||||
portalCommand += args[i];
|
||||
}
|
||||
if (Portal.addCommand(portalName, portalCommand)) {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " Command added to portal!");
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " Failed to add command to portal!");
|
||||
}
|
||||
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " You must actually specify a command to execute!");
|
||||
}
|
||||
|
||||
} else if (args[1].toLowerCase().equals("remove")) {
|
||||
// Specify what line to remove
|
||||
} else if (args[1].toLowerCase().equals("show")) {
|
||||
// Show all the commands the portal executes
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " You must specify to \u00A7eadd\u00A7c or \u00A7eremove a command!");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " You must specify to \u00A7eadd\u00A7c or \u00A7eremove\u00A7c a command!");
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
break;
|
||||
case "remove":
|
||||
if (args.length > 1) {
|
||||
String posX = portalConfig.getConfig().getString(args[1] + ".pos1.X");
|
||||
if (posX != null) {
|
||||
Portal.remove(args[1]);
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " The portal \u00A7e" + args[1] + "\u00A7c has been removed!");
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " No portal by that name exists!");
|
||||
}
|
||||
} else {
|
||||
if (player.hasMetadata("selectedPortal")) {
|
||||
String portalName = player.getMetadata("selectedPortal").get(0).asString();
|
||||
String posX = portalConfig.getConfig().getString(portalName + ".pos1.X");
|
||||
if (posX != null) {
|
||||
Portal.remove(portalName);
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " The portal \u00A77" + portalName + "\u00A7c has been removed!");
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " The portal you had selected no longer seems to exist!");
|
||||
player.removeMetadata("selectedPortal", plugin);
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " No portal has been defined or selected!");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "help":
|
||||
sender.sendMessage(PluginMessages.customPrefix + " Help Menu");
|
||||
sender.sendMessage("\u00A7e\u00A7m-----------------------------------");
|
||||
sender.sendMessage("\u00A76/" + command + " selector \u00A7a- gives you a region selector");
|
||||
sender.sendMessage("\u00A76/" + command + " create \u00A7c[tags] \u00A7a- creates a portal with a selection ");
|
||||
sender.sendMessage("\u00A76/" + command + " portalblock \u00A7a- gives you a portal block");
|
||||
sender.sendMessage("\u00A76/" + command + " select \u00A7a- selects an existing portal");
|
||||
sender.sendMessage("\u00A76/" + command + " remove \u00A7a- removes a portal");
|
||||
sender.sendMessage("\u00A76/" + command + " list \u00A7a- lists all the current portals");
|
||||
sender.sendMessage("\u00A76/" + command + " variables \u00A7a- lists all available tags");
|
||||
sender.sendMessage("\u00A7e\u00A7m-----------------------------------");
|
||||
break;
|
||||
case "show":
|
||||
if (args.length > 1) {
|
||||
String posX = portalConfig.getConfig().getString(args[1] + ".pos1.X");
|
||||
if (posX != null) {
|
||||
Selection.Show(player, this.plugin, args[1]);
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " No portal by that name exists!");
|
||||
}
|
||||
} else {
|
||||
if (player.hasMetadata("selectedPortal")) {
|
||||
player.sendMessage(PluginMessages.customPrefix + " Your currently selected portal has been shown, it will dissapear shortly!");
|
||||
Selection.Show(player, this.plugin, player.getMetadata("selectedPortal").get(0).asString());
|
||||
} else if (player.hasMetadata("Pos1World") && player.hasMetadata("Pos2World")) {
|
||||
if (player.getMetadata("Pos1World").get(0).asString().equals(player.getMetadata("Pos2World").get(0).asString())
|
||||
&& player.getMetadata("Pos1World").get(0).asString().equals(player.getLocation().getWorld().getName())) {
|
||||
player.sendMessage(PluginMessages.customPrefix + " Your currently selected area has been shown, it will dissapear shortly!");
|
||||
Selection.Show(player, this.plugin, null);
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " No regions selected!");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "reload":
|
||||
sender.sendMessage(PluginMessages.customPrefix + " Reloaded values!");
|
||||
Listeners.reloadValues(plugin);
|
||||
Portal.loadPortals();
|
||||
break;
|
||||
case "list" :
|
||||
String message = PluginMessages.customPrefix + " \u00A77Portals \u00A7c:\u00A7a";
|
||||
LinkedList<String> portals = new LinkedList<>();
|
||||
for (AdvancedPortal portal : Portal.portals) {
|
||||
portals.add(portal.portalName);
|
||||
}
|
||||
Collections.sort(portals);
|
||||
for (Object portalName : portals.toArray()) {
|
||||
message = message + " " + portalName;
|
||||
}
|
||||
player.sendMessage(message);
|
||||
break;
|
||||
default:
|
||||
PluginMessages.UnknownCommand(sender, command);
|
||||
}
|
||||
} else {
|
||||
PluginMessages.UnknownCommand(sender, command);
|
||||
}
|
||||
} else {
|
||||
PluginMessages.NoPermission(sender, command);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private String parseArgVariable(String[] args, int currentArg, String argStarter) {
|
||||
String variableString = args[currentArg].replaceFirst(argStarter, "");
|
||||
this.portalArgsStringLength = 1;
|
||||
if (variableString.charAt(0) == '"') {
|
||||
variableString = variableString.substring(1, variableString.length());
|
||||
if (variableString.charAt(variableString.length() - 1) != '"') {
|
||||
currentArg++;
|
||||
for (; currentArg < args.length; currentArg++) {
|
||||
variableString += " " + args[currentArg];
|
||||
this.portalArgsStringLength += 1;
|
||||
if (variableString.charAt(variableString.length() - 1) == '"') {
|
||||
variableString = variableString.substring(0, variableString.length() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
variableString = variableString.substring(0, variableString.length() - 1);
|
||||
}
|
||||
|
||||
}
|
||||
return variableString;
|
||||
}
|
||||
|
||||
private void portalEditMenu(CommandSender sender, ConfigAccessor portalConfig, String portalName) {
|
||||
// make the text gui with the json message for a list of edit commands to be clicked or hovered
|
||||
// put \" for a " in the json messages
|
||||
// sadly there is no newline code so these three lines will have to be copied and pasted for each line
|
||||
|
||||
// use the usual messages for normal lines but anything that needs special features make sure you use the
|
||||
// chat steriliser
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(PluginMessages.customPrefix + " Editing: \u00A7e" + portalName);
|
||||
|
||||
sender.sendMessage(" \u00A7apos1\u00A7e: " + portalConfig.getConfig().getString(portalName + ".pos1.X")
|
||||
+ ", " + portalConfig.getConfig().getString(portalName + ".pos1.Y") + ", " + portalConfig.getConfig().getString(portalName + ".pos1.Z"));
|
||||
sender.sendMessage(" \u00A7apos2\u00A7e: " + portalConfig.getConfig().getString(portalName + ".pos2.X")
|
||||
+ ", " + portalConfig.getConfig().getString(portalName + ".pos2.Y") + ", " + portalConfig.getConfig().getString(portalName + ".pos2.Z"));
|
||||
|
||||
String destination = portalConfig.getConfig().getString(portalName + ".destination");
|
||||
if (destination != null) {
|
||||
sender.sendMessage(" \u00A7adestination\u00A7e: " + destination);
|
||||
} else {
|
||||
sender.sendMessage(" \u00A7cdestination\u00A7e: null");
|
||||
}
|
||||
|
||||
String trigger = portalConfig.getConfig().getString(portalName + ".triggerblock");
|
||||
if (trigger != null) {
|
||||
sender.sendMessage(" \u00A7atriggerBlock\u00A7e: " + trigger);
|
||||
} else {
|
||||
sender.sendMessage(" \u00A7ctriggerBlock\u00A7e: null");
|
||||
}
|
||||
|
||||
if (portalConfig.getConfig().getString(portalName + ".portalArgs.command.1") != null) {
|
||||
int commands = 0;
|
||||
String command = portalConfig.getConfig().getString(portalName + ".portalArgs.command.1");
|
||||
// TODO possibly change code so it counds number of subvalues rather than a loop.
|
||||
while (command != null) {
|
||||
command = portalConfig.getConfig().getString(portalName + ".portalArgs.command." + ++commands);
|
||||
}
|
||||
if (--commands > 1) {
|
||||
sender.sendMessage(" \u00A7acommands\u00A7e: " + commands + " commands");
|
||||
} else {
|
||||
sender.sendMessage(" \u00A7acommands\u00A7e: " + commands + " command");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(" \u00A7ccommands\u00A7e: none");
|
||||
}
|
||||
sender.sendMessage("");
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
plugin.compat.sendRawMessage("{\"text\":\"\u00A7aFunctions\u00A7e: \"," +
|
||||
"\"extra\":[{\"text\":\"\u00A7eRemove\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Remove the selected portal\"},\"clickEvent\":{\"action\":\"clickEvent\",\"value\":\"/portal gui remove " + portalName + "\"}}"
|
||||
+ ",{\"text\":\" \"},{\"text\":\"\u00A7eShow\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Show the selected portal\"},\"clickEvent\":{\"action\":\"clickEvent\",\"value\":\"/portal show " + portalName + "\"}}"
|
||||
+ ",{\"text\":\" \"},{\"text\":\"\u00A7eRename\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Change the name of the portal\"},\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/portal rename \"}}"
|
||||
+ ",{\"text\":\" \"},{\"text\":\"\u00A7eActivate\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Teleport to the set destination\n(same as entering the portal)\"},\"clickEvent\":{\"action\":\"clickEvent\",\"value\":\"/warp " + destination + "\"}}]}", player);
|
||||
|
||||
sender.sendMessage("");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String command, String[] args) {
|
||||
LinkedList<String> autoComplete = new LinkedList<String>();
|
||||
if (sender.hasPermission("AdvancedPortals.CreatePortal")) {
|
||||
if (args.length == 1) {
|
||||
autoComplete.addAll(Arrays.asList("create", "list", "portalblock", "select", "selector"
|
||||
, "show", "variables", "wand", "remove", "rename", "help", "bukkitpage", "helppage"));
|
||||
} else if (args[0].toLowerCase().equals("create")) {
|
||||
|
||||
boolean hasName = false;
|
||||
boolean hasTriggerBlock = false;
|
||||
boolean hasDestination = false;
|
||||
boolean isBungeePortal = false;
|
||||
boolean needsPermission = false;
|
||||
boolean hasCommand = false;
|
||||
|
||||
|
||||
// TODO change auto complete when quotes are opened and closed. Such as autocomplete @Player and stuff when specifying commands
|
||||
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
String argTag = getTag(args[i].toLowerCase());
|
||||
if (argTag.length() + 1 < args[i].length()) {
|
||||
switch (argTag) {
|
||||
case "name":
|
||||
hasName = true;
|
||||
break;
|
||||
case "destination":
|
||||
hasDestination = true;
|
||||
break;
|
||||
case "desti":
|
||||
hasDestination = true;
|
||||
break;
|
||||
case "triggerblock":
|
||||
hasTriggerBlock = true;
|
||||
break;
|
||||
case "bungee":
|
||||
isBungeePortal = true;
|
||||
break;
|
||||
case "permission":
|
||||
needsPermission = true;
|
||||
break;
|
||||
case "command":
|
||||
hasCommand = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!hasName) {
|
||||
autoComplete.add("name:");
|
||||
}
|
||||
if (!hasTriggerBlock) {
|
||||
autoComplete.add("triggerblock:");
|
||||
}
|
||||
if (!hasDestination) {
|
||||
autoComplete.add("destination:");
|
||||
autoComplete.add("desti:");
|
||||
}
|
||||
if (!isBungeePortal) {
|
||||
autoComplete.add("bungee:");
|
||||
}
|
||||
if (!needsPermission) {
|
||||
autoComplete.add("permission:");
|
||||
}
|
||||
if (!hasCommand) {
|
||||
autoComplete.add("command:");
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(autoComplete);
|
||||
for (Object result : autoComplete.toArray()) {
|
||||
if (!result.toString().startsWith(args[args.length - 1])) {
|
||||
autoComplete.remove(result);
|
||||
}
|
||||
}
|
||||
return autoComplete;
|
||||
}
|
||||
|
||||
private String getTag(String arg) {
|
||||
int indexOfSplitter = arg.indexOf(':');
|
||||
if (indexOfSplitter > 0) {
|
||||
return arg.substring(0, indexOfSplitter);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
package com.sekwah.advancedportals;
|
||||
|
||||
import com.sekwah.advancedportals.DataCollector.DataCollector;
|
||||
import com.sekwah.advancedportals.compat.CraftBukkit;
|
||||
import com.sekwah.advancedportals.destinations.*;
|
||||
import com.sekwah.advancedportals.effects.WarpEffects;
|
||||
import com.sekwah.advancedportals.listeners.*;
|
||||
import com.sekwah.advancedportals.metrics.Metrics;
|
||||
import com.sekwah.advancedportals.portals.Portal;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||
|
||||
public CraftBukkit compat = null;
|
||||
private Settings settings;
|
||||
|
||||
public void onEnable() {
|
||||
|
||||
try {
|
||||
Metrics metrics = new Metrics(this);
|
||||
metrics.start();
|
||||
} catch (IOException e) {
|
||||
// Failed to submit the stats :-(
|
||||
}
|
||||
|
||||
String packageName = getServer().getClass().getPackage().getName();
|
||||
String[] packageSplit = packageName.split("\\.");
|
||||
String version = packageSplit[packageSplit.length - 1];
|
||||
|
||||
try {
|
||||
|
||||
this.compat = new CraftBukkit(this, version);
|
||||
|
||||
ConfigAccessor portalConfig = new ConfigAccessor(this, "portals.yml");
|
||||
portalConfig.saveDefaultConfig();
|
||||
|
||||
ConfigAccessor destinationConfig = new ConfigAccessor(this, "destinations.yml");
|
||||
destinationConfig.saveDefaultConfig();
|
||||
|
||||
this.settings = new Settings(this);
|
||||
|
||||
// Loads the portal and destination editors
|
||||
new Portal(this);
|
||||
new Destination(this);
|
||||
|
||||
new DataCollector(this);
|
||||
|
||||
|
||||
this.registerCommands();
|
||||
|
||||
new WarpEffects(this);
|
||||
|
||||
this.addListeners();
|
||||
this.setupDataCollector();
|
||||
|
||||
this.setupBungee();
|
||||
|
||||
this.getServer().getConsoleSender().sendMessage("\u00A7aAdvanced portals have been successfully enabled!");
|
||||
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
this.getLogger().warning("This version of craftbukkit is not yet supported, please notify sekwah and tell him about this version v:" + version);
|
||||
this.getLogger().warning("Along with the above stacktrace");
|
||||
this.setEnabled(false);
|
||||
} catch (IllegalArgumentException |
|
||||
NoSuchFieldException | SecurityException | NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
this.getLogger().warning("Something went wrong, please notify sekwah and tell him about this version v:" + version);
|
||||
this.getLogger().warning("Along with the above stacktrace");
|
||||
this.setEnabled(false);
|
||||
}
|
||||
|
||||
saveDefaultConfig();
|
||||
|
||||
// thanks to the new config accessor code the config.saveDefaultConfig(); will now
|
||||
// only copy the file if it doesnt exist!
|
||||
}
|
||||
|
||||
private void registerCommands() {
|
||||
new PluginMessages(this);
|
||||
new AdvancedPortalsCommand(this);
|
||||
new DestinationCommand(this);
|
||||
}
|
||||
|
||||
private void addListeners() {
|
||||
new Listeners(this);
|
||||
|
||||
new FlowStopper(this);
|
||||
new PortalProtect(this);
|
||||
new PortalPlacer(this);
|
||||
}
|
||||
|
||||
private void setupDataCollector() {
|
||||
Selection.LoadData(this);
|
||||
|
||||
DataCollector.setupMetrics();
|
||||
}
|
||||
|
||||
private void setupBungee() {
|
||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeListener(this));
|
||||
}
|
||||
|
||||
|
||||
public void onDisable() {
|
||||
this.getServer().getConsoleSender().sendMessage("\u00A7cAdvanced portals are being disabled!");
|
||||
}
|
||||
|
||||
|
||||
public Settings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
package com.sekwah.advancedportals.DataCollector;
|
||||
|
||||
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.metrics.Metrics;
|
||||
import com.sekwah.advancedportals.metrics.Metrics.Graph;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class DataCollector {
|
||||
|
||||
private static AdvancedPortalsPlugin plugin;
|
||||
|
||||
public DataCollector(AdvancedPortalsPlugin plugin) {
|
||||
DataCollector.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* This is currently being tested as it doesn't fully work at the moment.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* public static void playerWarped() {
|
||||
* try {
|
||||
* Metrics metrics = new Metrics(plugin);
|
||||
* <p>
|
||||
* Graph TotalWarps = metrics.createGraph("Total Warps");
|
||||
* <p>
|
||||
* TotalWarps.addPlotter(new Metrics.Plotter("Internal Warps") {
|
||||
*
|
||||
* @Override public int getValue() {
|
||||
* return 1; // number of warps
|
||||
* }
|
||||
* <p>
|
||||
* });
|
||||
* <p>
|
||||
* metrics.start();
|
||||
* } catch (IOException e) {
|
||||
* plugin.getLogger().log(Level.SEVERE, "Could not submit data", e);
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
|
||||
public static void setupMetrics() {
|
||||
|
||||
try {
|
||||
Metrics metrics = new Metrics(plugin);
|
||||
Graph TotalWarps = metrics.createGraph("Portal Trigger Blocks");
|
||||
|
||||
/**List<Material> MaterialList = new ArrayList<Material>();
|
||||
for(AdvancedPortal portal : Portal.portals){
|
||||
MaterialList.add(portal.trigger);
|
||||
}*/
|
||||
|
||||
/**TotalWarps.addPlotter(new Metrics.Plotter(triggerName) {
|
||||
|
||||
@Override public int getValue() {
|
||||
return 1; // number of portals created
|
||||
}
|
||||
|
||||
});*/
|
||||
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Could not submit data", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package com.sekwah.advancedportals;
|
||||
|
||||
/**
|
||||
* This contains generally used settings mostly
|
||||
*/
|
||||
public class Settings {
|
||||
|
||||
private int currentWarpParticles = 0;
|
||||
|
||||
private int currentWarpSound = 0;
|
||||
|
||||
private String commandLevels = "n";
|
||||
|
||||
public Settings(AdvancedPortalsPlugin plugin) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
currentWarpParticles = config.getConfig().getInt("WarpParticles");
|
||||
currentWarpSound = config.getConfig().getInt("WarpSound");
|
||||
|
||||
commandLevels = config.getConfig().getString("CommandLevels", "n");
|
||||
if(commandLevels.contains("n") || commandLevels.equals("")) {
|
||||
commandLevels = "n";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCommandLevels(){
|
||||
return this.commandLevels;
|
||||
}
|
||||
|
||||
public boolean hasCommandLevel(String level){
|
||||
return this.commandLevels.contains(level);
|
||||
}
|
||||
|
||||
public int getCurrentWarpSound() {
|
||||
return currentWarpSound;
|
||||
}
|
||||
|
||||
public int getCurrentWarpParticles() {
|
||||
return currentWarpParticles;
|
||||
}
|
||||
}
|
@ -1,135 +0,0 @@
|
||||
package com.sekwah.advancedportals.compat;
|
||||
|
||||
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Created by on 02/08/2016.
|
||||
*
|
||||
* I don't think there will be any others supported other than bukkit but if there are its not just the compat that will
|
||||
* need to change unless it has a different package for the minecraft server parts
|
||||
*
|
||||
* @author sekwah41 maxqia
|
||||
*/
|
||||
public class CraftBukkit {
|
||||
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
private Method chatMessageTypeMethod;
|
||||
|
||||
private Method serializeMessage;
|
||||
private Constructor<?> chatPacketConstructor;
|
||||
|
||||
private Method playerGetHandle;
|
||||
private Field playerConnection;
|
||||
private Method sendPacket;
|
||||
|
||||
private boolean useEnumType = false;
|
||||
|
||||
|
||||
// Classes so it doesnt keep fetching them.
|
||||
|
||||
public CraftBukkit(AdvancedPortalsPlugin plugin, String bukkitImpl) throws ClassNotFoundException, NoSuchFieldException, NoSuchMethodException {
|
||||
|
||||
this.plugin = plugin;
|
||||
|
||||
try {
|
||||
// CraftBukkit Ahoy!
|
||||
String craftBukkitPackage = "org.bukkit.craftbukkit." + bukkitImpl + ".";
|
||||
String minecraftPackage = "net.minecraft.server." + bukkitImpl + ".";
|
||||
|
||||
Class<?> chatBaseComponent = Class.forName(minecraftPackage + "IChatBaseComponent"); // string to packet methods
|
||||
Class<?> chatSerialClass = this.findClass(chatBaseComponent, "ChatSerializer");
|
||||
|
||||
try{
|
||||
Class<?> chatMessageTypeClass = Class.forName(minecraftPackage + "ChatMessageType");
|
||||
|
||||
this.chatMessageTypeMethod = chatMessageTypeClass.getMethod("a", byte.class);
|
||||
|
||||
this.chatPacketConstructor = Class.forName(minecraftPackage + "PacketPlayOutChat").getConstructor(chatBaseComponent, chatMessageTypeClass);
|
||||
|
||||
useEnumType = true;
|
||||
}
|
||||
catch(ClassNotFoundException e) {
|
||||
plugin.getLogger().info("Old version detected, changing chat method");
|
||||
this.chatPacketConstructor = Class.forName(minecraftPackage + "PacketPlayOutChat").getConstructor(chatBaseComponent, byte.class);
|
||||
}
|
||||
|
||||
if(chatSerialClass != null){
|
||||
this.serializeMessage = chatSerialClass.getMethod("a", String.class);
|
||||
}
|
||||
else{
|
||||
plugin.getLogger().info("Even older version detected, changing chat method");
|
||||
this.serializeMessage = chatBaseComponent.getMethod("a", String.class);
|
||||
}
|
||||
|
||||
this.playerGetHandle = Class.forName(craftBukkitPackage + "entity.CraftPlayer").getMethod("getHandle");
|
||||
this.playerConnection = Class.forName(minecraftPackage + "EntityPlayer").getField("playerConnection"); // get player connection
|
||||
Class<?> packet = Class.forName(minecraftPackage + "Packet");
|
||||
this.sendPacket = playerConnection.getType().getMethod("sendPacket", packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
plugin.getLogger().warning("Attempting to use backup porekit locations");
|
||||
// Fall back on your Porekit
|
||||
Class<?> textBaseComponent = Class.forName("net.minecraft.util.text.ITextComponent"); // string to packet methods
|
||||
this.serializeMessage = this.findClass(textBaseComponent, "Serializer").getMethod("func_150699_a", String.class); // md: jsonToComponent
|
||||
this.chatPacketConstructor = Class.forName("net.minecraft.network.play.server.SPacketChat").getConstructor(textBaseComponent, byte.class);
|
||||
|
||||
this.playerGetHandle = Class.forName("blue.lapis.pore.impl.entity.PorePlayer").getMethod("getHandle");
|
||||
this.playerConnection = Class.forName("net.minecraft.entity.player.EntityPlayerMP").getField("field_71135_a"); // get player connection fd: connection
|
||||
Class<?> packet = Class.forName("net.minecraft.network.Packet");
|
||||
this.sendPacket = playerConnection.getType().getMethod("func_147359_a", packet); //md: sendPacket
|
||||
}
|
||||
}
|
||||
|
||||
public void sendRawMessage(String rawMessage, Player player) {
|
||||
this.sendMessage(rawMessage,player, (byte) 1);
|
||||
}
|
||||
|
||||
public void sendActionBarMessage(String rawMessage, Player player) {
|
||||
this.sendMessage(rawMessage,player, (byte) 2);
|
||||
}
|
||||
|
||||
public void sendMessage(String rawMessage, Player player, byte msgType) {
|
||||
try {
|
||||
Object comp = this.serializeMessage.invoke(null,rawMessage); // convert string into bytes
|
||||
Object packet;
|
||||
if(useEnumType){
|
||||
packet = this.chatPacketConstructor.newInstance(comp, this.chatMessageTypeMethod.invoke(null,msgType)); // convert bytes into packet
|
||||
}
|
||||
else{
|
||||
packet = this.chatPacketConstructor.newInstance(comp, msgType); // convert bytes into packet
|
||||
}
|
||||
|
||||
Object handle = this.playerGetHandle.invoke(player);
|
||||
Object playerConnection = this.playerConnection.get(handle); // get players connection
|
||||
sendPacket.invoke(playerConnection, packet); // send packet
|
||||
} catch (IllegalAccessException | InvocationTargetException | InstantiationException e) {
|
||||
this.plugin.getLogger().warning("Error creating raw message, something must be wrong with reflection");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
/*IChatBaseComponent comp = IChatBaseComponent.ChatSerializer.a(rawMessage);
|
||||
// "json message", position(0: chat (chat box), 1: system message (chat box), 2: above action bar)
|
||||
PacketPlayOutChat packet = new PacketPlayOutChat(comp, (byte) 1);
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);*/
|
||||
}
|
||||
|
||||
|
||||
public Class<?> findClass(Class<?> classObj, String className){
|
||||
for(Class<?> classes : classObj.getDeclaredClasses()){
|
||||
if(classes.getSimpleName().equals(className)){
|
||||
return classes;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package com.sekwah.advancedportals.destinations;
|
||||
|
||||
/**
|
||||
* Created by on 04/08/2016.
|
||||
*
|
||||
* TODO load the destinations into memory rather than constantly reading from the yml.
|
||||
*
|
||||
* @author sekwah41
|
||||
*/
|
||||
public class PortalWarp {
|
||||
|
||||
}
|
@ -1,232 +0,0 @@
|
||||
package com.sekwah.advancedportals.listeners;
|
||||
|
||||
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.PluginMessages;
|
||||
import com.sekwah.advancedportals.api.events.WarpEvent;
|
||||
import com.sekwah.advancedportals.portals.AdvancedPortal;
|
||||
import com.sekwah.advancedportals.portals.Portal;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerPortalEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
public class Listeners implements Listener {
|
||||
// The needed config values will be stored so they are easier to access later
|
||||
// an example is in the interact event in this if statement if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("\u00A7eP...
|
||||
private static boolean UseOnlyServerAxe = false;
|
||||
private static Material WandMaterial;
|
||||
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public Listeners(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
UseOnlyServerAxe = config.getConfig().getBoolean("UseOnlyServerMadeAxe");
|
||||
|
||||
String ItemID = config.getConfig().getString("AxeItemId");
|
||||
|
||||
try {
|
||||
WandMaterial = Material.getMaterial(Integer.parseInt(ItemID));
|
||||
} catch (Exception e) {
|
||||
WandMaterial = Material.getMaterial(ItemID);
|
||||
}
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void reloadValues(AdvancedPortalsPlugin plugin) {
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
UseOnlyServerAxe = config.getConfig().getBoolean("UseOnlyServerMadeAxe");
|
||||
|
||||
String ItemID = config.getConfig().getString("AxeItemId");
|
||||
|
||||
try {
|
||||
WandMaterial = Material.getMaterial(Integer.parseInt(ItemID));
|
||||
} catch (Exception e) {
|
||||
WandMaterial = Material.getMaterial(ItemID);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoinEvent(PlayerJoinEvent event) {
|
||||
Portal.cooldown.put(event.getPlayer(), System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onMoveEvent(PlayerMoveEvent event) {
|
||||
// will check if the player is in the portal or not.
|
||||
if (!Portal.portalsActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
//Location fromloc = event.getFrom();
|
||||
Location loc = event.getTo();
|
||||
Location eyeLoc = new Location(loc.getWorld(), loc.getX(), loc.getY() + player.getEyeHeight(), loc.getZ());
|
||||
for (AdvancedPortal portal : Portal.portals) {
|
||||
if (Portal.locationInPortalTrigger(portal, loc) || Portal.locationInPortalTrigger(portal, eyeLoc)) {
|
||||
if (portal.trigger.equals(Material.PORTAL)) {
|
||||
if (player.getGameMode().equals(GameMode.CREATIVE)) {
|
||||
player.setMetadata("hasWarped", new FixedMetadataValue(plugin, true));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new RemoveWarpData(player), 10);
|
||||
}
|
||||
} else if (portal.trigger.equals(Material.LAVA)) {
|
||||
player.setMetadata("lavaWarped", new FixedMetadataValue(plugin, true));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new RemoveLavaData(player), 10);
|
||||
}
|
||||
if (portal.inPortal.contains(player)) return;
|
||||
WarpEvent warpEvent = new WarpEvent(player, portal);
|
||||
plugin.getServer().getPluginManager().callEvent(warpEvent);
|
||||
if (!event.isCancelled()) Portal.activate(player, portal);
|
||||
portal.inPortal.add(player);
|
||||
} else portal.inPortal.remove(player);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// These are here because java 7 can only take finals straight into a runnable
|
||||
class RemoveLavaData implements Runnable{
|
||||
|
||||
|
||||
private Player player;
|
||||
|
||||
public RemoveLavaData(Player player){
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
player.removeMetadata("lavaWarped", plugin);
|
||||
player.setFireTicks(0);
|
||||
}
|
||||
};
|
||||
|
||||
class RemoveWarpData implements Runnable{
|
||||
|
||||
|
||||
private Player player;
|
||||
|
||||
public RemoveWarpData(Player player){
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (player != null && player.isOnline()) {
|
||||
player.removeMetadata("hasWarped", plugin);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@EventHandler
|
||||
public void onCombustEntityEvent(EntityCombustEvent event) {
|
||||
if (Portal.inPortalTriggerRegion(event.getEntity().getLocation()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onDamEvent(EntityDamageEvent event) {
|
||||
if (event.getCause() == EntityDamageEvent.DamageCause.LAVA || event.getCause() == EntityDamageEvent.DamageCause.FIRE || event.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK) {
|
||||
if (event.getEntity().hasMetadata("lavaWarped") | Portal.inPortalTriggerRegion(event.getEntity().getLocation()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
// https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/PlayerTeleportEvent.TeleportCause.html
|
||||
// Also listen to this possibly.
|
||||
@EventHandler
|
||||
public void onPortalEvent(PlayerPortalEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player.hasMetadata("hasWarped") | Portal.inPortalTriggerRegion(player.getLocation()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemInteract(PlayerInteractEvent event) {
|
||||
|
||||
// will detect if the player is using an axe so the points of a portal can be set
|
||||
// also any other detections such as sign interaction or basic block protection
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (player.hasMetadata("selectingPortal") && (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
|
||||
for (AdvancedPortal portal : Portal.portals) {
|
||||
if (Portal.locationInPortal(portal, event.getClickedBlock().getLocation(), 0)) {
|
||||
player.sendMessage(PluginMessages.customPrefix + "\u00A7a You have selected: \u00A7e" + portal.portalName);
|
||||
player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, portal.portalName)); // adds the name to the metadata of the character
|
||||
event.setCancelled(true);
|
||||
player.removeMetadata("selectingPortal", plugin);
|
||||
return;
|
||||
}
|
||||
}
|
||||
player.sendMessage(PluginMessages.customPrefixFail + "\u00A7c No portal was selected. If you would like to stop selecting please type \u00A7e/portal select \u00A7cagain!");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.hasPermission("AdvancedPortals.CreatePortal")) {
|
||||
|
||||
// UseOnlyServerMadeAxe being set to true makes is so only the axe generated by the server can be used so other iron axes can be used normally,
|
||||
// by default its false but it is a nice feature in case the user wants to use the axe normally too, such as a admin playing survival or it being used
|
||||
// as a weapon.
|
||||
// Null pointer exeption detected here on some servers(try decompiling the jar file to double check)
|
||||
/*try {
|
||||
// Use this to surround the code if needed
|
||||
}
|
||||
catch(NullPointerException e){
|
||||
|
||||
}*/
|
||||
if (event.getItem() != null && event.getPlayer().getItemInHand().getType() == WandMaterial // was type id
|
||||
&& (!UseOnlyServerAxe || (event.getItem().getItemMeta().getDisplayName() != null && event.getItem().getItemMeta().getDisplayName().equals("\u00A7ePortal Region Selector")))) {
|
||||
|
||||
// This checks if the action was a left or right click and if it was directly effecting a block.
|
||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
Location blockloc = event.getClickedBlock().getLocation();
|
||||
// stores the selection as metadata on the character so then it isn't saved anywhere, if the player logs out it will
|
||||
// have to be selected again if the player joins, also it does not affect any other players.
|
||||
player.setMetadata("Pos1X", new FixedMetadataValue(plugin, blockloc.getBlockX()));
|
||||
player.setMetadata("Pos1Y", new FixedMetadataValue(plugin, blockloc.getBlockY()));
|
||||
player.setMetadata("Pos1Z", new FixedMetadataValue(plugin, blockloc.getBlockZ()));
|
||||
player.setMetadata("Pos1World", new FixedMetadataValue(plugin, blockloc.getWorld().getName()));
|
||||
player.sendMessage("\u00A7eYou have selected pos1! X:" + blockloc.getBlockX() + " Y:" + blockloc.getBlockY() + " Z:" + blockloc.getBlockZ() + " World: " + blockloc.getWorld().getName());
|
||||
|
||||
// Stops the event so the block is not damaged
|
||||
event.setCancelled(true);
|
||||
|
||||
// Returns the event so no more code is executed(stops unnecessary code being executed)
|
||||
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
Location blockloc = event.getClickedBlock().getLocation();
|
||||
player.setMetadata("Pos2X", new FixedMetadataValue(plugin, blockloc.getBlockX()));
|
||||
player.setMetadata("Pos2Y", new FixedMetadataValue(plugin, blockloc.getBlockY()));
|
||||
player.setMetadata("Pos2Z", new FixedMetadataValue(plugin, blockloc.getBlockZ()));
|
||||
player.setMetadata("Pos2World", new FixedMetadataValue(plugin, blockloc.getWorld().getName()));
|
||||
player.sendMessage("\u00A7eYou have selected pos2! X:" + blockloc.getBlockX() + " Y:" + blockloc.getBlockY() + " Z:" + blockloc.getBlockZ() + " World: " + blockloc.getWorld().getName());
|
||||
|
||||
// Stops the event so the block is not interacted with
|
||||
event.setCancelled(true);
|
||||
|
||||
// Returns the event so no more code is executed(stops unnecessary code being executed)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package com.sekwah.advancedportals.listeners;
|
||||
|
||||
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.portals.Portal;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
|
||||
public class PortalPlacer implements Listener {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
private final int PortalProtectionRadius;
|
||||
|
||||
// The needed config values will be stored so they are easier to access later
|
||||
// an example is in the interact event in this if statement if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("<EFBFBD>eP...
|
||||
private boolean PortalPlace = true;
|
||||
|
||||
public PortalPlacer(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
this.PortalPlace = config.getConfig().getBoolean("CanBuildPortalBlock");
|
||||
|
||||
this.PortalProtectionRadius = config.getConfig().getInt("PortalProtectionRadius");
|
||||
|
||||
if (PortalPlace) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||
Block block = event.getBlock();
|
||||
Material material = block.getType();
|
||||
if (material == Material.PORTAL && Portal.inPortalRegion(block.getLocation(), PortalProtectionRadius))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
@ -1,750 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2013 Tyler Blair. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and contributors and should not be interpreted as representing official policies,
|
||||
* either expressed or implied, of anybody else.
|
||||
*/
|
||||
package com.sekwah.advancedportals.metrics;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.Proxy;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
public class Metrics {
|
||||
|
||||
/**
|
||||
* The current revision number
|
||||
*/
|
||||
private final static int REVISION = 7;
|
||||
|
||||
/**
|
||||
* The base url of the metrics domain
|
||||
*/
|
||||
private static final String BASE_URL = "http://report.mcstats.org";
|
||||
|
||||
/**
|
||||
* The url used to report a server's status
|
||||
*/
|
||||
private static final String REPORT_URL = "/plugin/%s";
|
||||
|
||||
/**
|
||||
* Interval of time to ping (in minutes)
|
||||
*/
|
||||
private static final int PING_INTERVAL = 15;
|
||||
|
||||
/**
|
||||
* The plugin this metrics submits for
|
||||
*/
|
||||
private final Plugin plugin;
|
||||
|
||||
/**
|
||||
* All of the custom graphs to submit to metrics
|
||||
*/
|
||||
private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>());
|
||||
|
||||
/**
|
||||
* The plugin configuration file
|
||||
*/
|
||||
private final YamlConfiguration configuration;
|
||||
|
||||
/**
|
||||
* The plugin configuration file
|
||||
*/
|
||||
private final File configurationFile;
|
||||
|
||||
/**
|
||||
* Unique server id
|
||||
*/
|
||||
private final String guid;
|
||||
|
||||
/**
|
||||
* Debug mode
|
||||
*/
|
||||
private final boolean debug;
|
||||
|
||||
/**
|
||||
* Lock for synchronization
|
||||
*/
|
||||
private final Object optOutLock = new Object();
|
||||
|
||||
/**
|
||||
* The scheduled task
|
||||
*/
|
||||
private volatile BukkitTask task = null;
|
||||
|
||||
public Metrics(final Plugin plugin) throws IOException {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
}
|
||||
|
||||
this.plugin = plugin;
|
||||
|
||||
// load the config
|
||||
configurationFile = getConfigFile();
|
||||
configuration = YamlConfiguration.loadConfiguration(configurationFile);
|
||||
|
||||
// add some defaults
|
||||
configuration.addDefault("opt-out", false);
|
||||
configuration.addDefault("guid", UUID.randomUUID().toString());
|
||||
configuration.addDefault("debug", false);
|
||||
|
||||
// Do we need to create the file?
|
||||
if (configuration.get("guid", null) == null) {
|
||||
configuration.options().header("http://mcstats.org").copyDefaults(true);
|
||||
configuration.save(configurationFile);
|
||||
}
|
||||
|
||||
// Load the guid then
|
||||
guid = configuration.getString("guid");
|
||||
debug = configuration.getBoolean("debug", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* GZip compress a string of bytes
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static byte[] gzip(String input) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
GZIPOutputStream gzos = null;
|
||||
|
||||
try {
|
||||
gzos = new GZIPOutputStream(baos);
|
||||
gzos.write(input.getBytes("UTF-8"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (gzos != null) try {
|
||||
gzos.close();
|
||||
} catch (IOException ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a json encoded key/value pair to the given string builder.
|
||||
*
|
||||
* @param json
|
||||
* @param key
|
||||
* @param value
|
||||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException {
|
||||
boolean isValueNumeric = false;
|
||||
|
||||
try {
|
||||
if (value.equals("0") || !value.endsWith("0")) {
|
||||
Double.parseDouble(value);
|
||||
isValueNumeric = true;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
isValueNumeric = false;
|
||||
}
|
||||
|
||||
if (json.charAt(json.length() - 1) != '{') {
|
||||
json.append(',');
|
||||
}
|
||||
|
||||
json.append(escapeJSON(key));
|
||||
json.append(':');
|
||||
|
||||
if (isValueNumeric) {
|
||||
json.append(value);
|
||||
} else {
|
||||
json.append(escapeJSON(value));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape a string to create a valid JSON string
|
||||
*
|
||||
* @param text
|
||||
* @return
|
||||
*/
|
||||
private static String escapeJSON(String text) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append('"');
|
||||
for (int index = 0; index < text.length(); index++) {
|
||||
char chr = text.charAt(index);
|
||||
|
||||
switch (chr) {
|
||||
case '"':
|
||||
case '\\':
|
||||
builder.append('\\');
|
||||
builder.append(chr);
|
||||
break;
|
||||
case '\b':
|
||||
builder.append("\\b");
|
||||
break;
|
||||
case '\t':
|
||||
builder.append("\\t");
|
||||
break;
|
||||
case '\n':
|
||||
builder.append("\\n");
|
||||
break;
|
||||
case '\r':
|
||||
builder.append("\\r");
|
||||
break;
|
||||
default:
|
||||
if (chr < ' ') {
|
||||
String t = "000" + Integer.toHexString(chr);
|
||||
builder.append("\\u" + t.substring(t.length() - 4));
|
||||
} else {
|
||||
builder.append(chr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
builder.append('"');
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode text as UTF-8
|
||||
*
|
||||
* @param text the text to encode
|
||||
* @return the encoded text, as UTF-8
|
||||
*/
|
||||
private static String urlEncode(final String text) throws UnsupportedEncodingException {
|
||||
return URLEncoder.encode(text, "UTF-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics
|
||||
* website. Plotters can be added to the graph object returned.
|
||||
*
|
||||
* @param name The name of the graph
|
||||
* @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given
|
||||
*/
|
||||
public Graph createGraph(final String name) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("Graph name cannot be null");
|
||||
}
|
||||
|
||||
// Construct the graph object
|
||||
final Graph graph = new Graph(name);
|
||||
|
||||
// Now we can add our graph
|
||||
graphs.add(graph);
|
||||
|
||||
// and return back
|
||||
return graph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Graph object to BukkitMetrics that represents data for the plugin that should be sent to the backend
|
||||
*
|
||||
* @param graph The name of the graph
|
||||
*/
|
||||
public void addGraph(final Graph graph) {
|
||||
if (graph == null) {
|
||||
throw new IllegalArgumentException("Graph cannot be null");
|
||||
}
|
||||
|
||||
graphs.add(graph);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start measuring statistics. This will immediately create an async repeating task as the plugin and send the
|
||||
* initial data to the metrics backend, and then after that it will post in increments of PING_INTERVAL * 1200
|
||||
* ticks.
|
||||
*
|
||||
* @return True if statistics measuring is running, otherwise false.
|
||||
*/
|
||||
public boolean start() {
|
||||
synchronized (optOutLock) {
|
||||
// Did we opt out?
|
||||
if (isOptOut()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Is metrics already running?
|
||||
if (task != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Begin hitting the server with glorious data
|
||||
task = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
|
||||
|
||||
private boolean firstPost = true;
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
// This has to be synchronized or it can collide with the disable method.
|
||||
synchronized (optOutLock) {
|
||||
// Disable Task, if it is running and the server owner decided to opt-out
|
||||
if (isOptOut() && task != null) {
|
||||
task.cancel();
|
||||
task = null;
|
||||
// Tell all plotters to stop gathering information.
|
||||
for (Graph graph : graphs) {
|
||||
graph.onOptOut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We use the inverse of firstPost because if it is the first time we are posting,
|
||||
// it is not a interval ping, so it evaluates to FALSE
|
||||
// Each time thereafter it will evaluate to TRUE, i.e PING!
|
||||
postPlugin(!firstPost);
|
||||
|
||||
// After the first post we set firstPost to false
|
||||
// Each post thereafter will be a ping
|
||||
firstPost = false;
|
||||
} catch (IOException e) {
|
||||
if (debug) {
|
||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0, PING_INTERVAL * 1200);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Has the server owner denied plugin metrics?
|
||||
*
|
||||
* @return true if metrics should be opted out of it
|
||||
*/
|
||||
public boolean isOptOut() {
|
||||
synchronized (optOutLock) {
|
||||
try {
|
||||
// Reload the metrics file
|
||||
configuration.load(getConfigFile());
|
||||
} catch (IOException ex) {
|
||||
if (debug) {
|
||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
} catch (InvalidConfigurationException ex) {
|
||||
if (debug) {
|
||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return configuration.getBoolean("opt-out", false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task.
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public void enable() throws IOException {
|
||||
// This has to be synchronized or it can collide with the check in the task.
|
||||
synchronized (optOutLock) {
|
||||
// Check if the server owner has already set opt-out, if not, set it.
|
||||
if (isOptOut()) {
|
||||
configuration.set("opt-out", false);
|
||||
configuration.save(configurationFile);
|
||||
}
|
||||
|
||||
// Enable Task, if it is not running
|
||||
if (task == null) {
|
||||
start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task.
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public void disable() throws IOException {
|
||||
// This has to be synchronized or it can collide with the check in the task.
|
||||
synchronized (optOutLock) {
|
||||
// Check if the server owner has already set opt-out, if not, set it.
|
||||
if (!isOptOut()) {
|
||||
configuration.set("opt-out", true);
|
||||
configuration.save(configurationFile);
|
||||
}
|
||||
|
||||
// Disable Task, if it is running
|
||||
if (task != null) {
|
||||
task.cancel();
|
||||
task = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the File object of the config file that should be used to store data such as the GUID and opt-out status
|
||||
*
|
||||
* @return the File object for the config file
|
||||
*/
|
||||
public File getConfigFile() {
|
||||
// I believe the easiest way to get the base folder (e.g craftbukkit set via -P) for plugins to use
|
||||
// is to abuse the plugin object we already have
|
||||
// plugin.getDataFolder() => base/plugins/PluginA/
|
||||
// pluginsFolder => base/plugins/
|
||||
// The base is not necessarily relative to the startup directory.
|
||||
File pluginsFolder = plugin.getDataFolder().getParentFile();
|
||||
|
||||
// return => base/plugins/PluginMetrics/config.yml
|
||||
return new File(new File(pluginsFolder, "PluginMetrics"), "config.yml");
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic method that posts a plugin to the metrics website
|
||||
*/
|
||||
private void postPlugin(final boolean isPing) throws IOException {
|
||||
// Server software specific section
|
||||
PluginDescriptionFile description = plugin.getDescription();
|
||||
String pluginName = description.getName();
|
||||
boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enabled
|
||||
String pluginVersion = description.getVersion();
|
||||
String serverVersion = Bukkit.getVersion();
|
||||
// make sure that the older versions of CraftBukkit are added first in project imports, so it can be compiled
|
||||
// against an older version
|
||||
int playersOnline = Bukkit.getOnlinePlayers().size(); //CraftBukkit.getServer().getOnlinePlayers().length;
|
||||
|
||||
// END server software specific section -- all code below does not use any code outside of this class / Java
|
||||
|
||||
// Construct the post data
|
||||
StringBuilder json = new StringBuilder(1024);
|
||||
json.append('{');
|
||||
|
||||
// The plugin's description file containg all of the plugin data such as name, version, author, etc
|
||||
appendJSONPair(json, "guid", guid);
|
||||
appendJSONPair(json, "plugin_version", pluginVersion);
|
||||
appendJSONPair(json, "server_version", serverVersion);
|
||||
appendJSONPair(json, "players_online", Integer.toString(playersOnline));
|
||||
|
||||
// New data as of R6
|
||||
String osname = System.getProperty("os.name");
|
||||
String osarch = System.getProperty("os.arch");
|
||||
String osversion = System.getProperty("os.version");
|
||||
String java_version = System.getProperty("java.version");
|
||||
int coreCount = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
// normalize os arch .. amd64 -> x86_64
|
||||
if (osarch.equals("amd64")) {
|
||||
osarch = "x86_64";
|
||||
}
|
||||
|
||||
appendJSONPair(json, "osname", osname);
|
||||
appendJSONPair(json, "osarch", osarch);
|
||||
appendJSONPair(json, "osversion", osversion);
|
||||
appendJSONPair(json, "cores", Integer.toString(coreCount));
|
||||
appendJSONPair(json, "auth_mode", onlineMode ? "1" : "0");
|
||||
appendJSONPair(json, "java_version", java_version);
|
||||
|
||||
// If we're pinging, append it
|
||||
if (isPing) {
|
||||
appendJSONPair(json, "ping", "1");
|
||||
}
|
||||
|
||||
if (graphs.size() > 0) {
|
||||
synchronized (graphs) {
|
||||
json.append(',');
|
||||
json.append('"');
|
||||
json.append("graphs");
|
||||
json.append('"');
|
||||
json.append(':');
|
||||
json.append('{');
|
||||
|
||||
boolean firstGraph = true;
|
||||
|
||||
final Iterator<Graph> iter = graphs.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
Graph graph = iter.next();
|
||||
|
||||
StringBuilder graphJson = new StringBuilder();
|
||||
graphJson.append('{');
|
||||
|
||||
for (Plotter plotter : graph.getPlotters()) {
|
||||
appendJSONPair(graphJson, plotter.getColumnName(), Integer.toString(plotter.getValue()));
|
||||
}
|
||||
|
||||
graphJson.append('}');
|
||||
|
||||
if (!firstGraph) {
|
||||
json.append(',');
|
||||
}
|
||||
|
||||
json.append(escapeJSON(graph.getName()));
|
||||
json.append(':');
|
||||
json.append(graphJson);
|
||||
|
||||
firstGraph = false;
|
||||
}
|
||||
|
||||
json.append('}');
|
||||
}
|
||||
}
|
||||
|
||||
// close json
|
||||
json.append('}');
|
||||
|
||||
// Create the url
|
||||
URL url = new URL(BASE_URL + String.format(REPORT_URL, urlEncode(pluginName)));
|
||||
|
||||
// Connect to the website
|
||||
URLConnection connection;
|
||||
|
||||
// Mineshafter creates a socks proxy, so we can safely bypass it
|
||||
// It does not reroute POST requests so we need to go around it
|
||||
if (isMineshafterPresent()) {
|
||||
connection = url.openConnection(Proxy.NO_PROXY);
|
||||
} else {
|
||||
connection = url.openConnection();
|
||||
}
|
||||
|
||||
|
||||
byte[] uncompressed = json.toString().getBytes();
|
||||
byte[] compressed = gzip(json.toString());
|
||||
|
||||
// Headers
|
||||
connection.addRequestProperty("User-Agent", "MCStats/" + REVISION);
|
||||
connection.addRequestProperty("Content-Type", "application/json");
|
||||
connection.addRequestProperty("Content-Encoding", "gzip");
|
||||
connection.addRequestProperty("Content-Length", Integer.toString(compressed.length));
|
||||
connection.addRequestProperty("Accept", "application/json");
|
||||
connection.addRequestProperty("Connection", "close");
|
||||
|
||||
connection.setDoOutput(true);
|
||||
|
||||
if (debug) {
|
||||
System.out.println("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length);
|
||||
}
|
||||
|
||||
// Write the data
|
||||
OutputStream os = connection.getOutputStream();
|
||||
os.write(compressed);
|
||||
os.flush();
|
||||
|
||||
// Now read the response
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String response = reader.readLine();
|
||||
|
||||
// close resources
|
||||
os.close();
|
||||
reader.close();
|
||||
|
||||
if (response == null || response.startsWith("ERR") || response.startsWith("7")) {
|
||||
if (response == null) {
|
||||
response = "null";
|
||||
} else if (response.startsWith("7")) {
|
||||
response = response.substring(response.startsWith("7,") ? 2 : 1);
|
||||
}
|
||||
|
||||
throw new IOException(response);
|
||||
} else {
|
||||
// Is this the first update this hour?
|
||||
if (response.equals("1") || response.contains("This is your first update this hour")) {
|
||||
synchronized (graphs) {
|
||||
final Iterator<Graph> iter = graphs.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
final Graph graph = iter.next();
|
||||
|
||||
for (Plotter plotter : graph.getPlotters()) {
|
||||
plotter.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if mineshafter is present. If it is, we need to bypass it to send POST requests
|
||||
*
|
||||
* @return true if mineshafter is installed on the server
|
||||
*/
|
||||
private boolean isMineshafterPresent() {
|
||||
try {
|
||||
Class.forName("mineshafter.MineServer");
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom graph on the website
|
||||
*/
|
||||
public static class Graph {
|
||||
|
||||
/**
|
||||
* The graph's name, alphanumeric and spaces only :) If it does not comply to the above when submitted, it is
|
||||
* rejected
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* The set of plotters that are contained within this graph
|
||||
*/
|
||||
private final Set<Plotter> plotters = new LinkedHashSet<Plotter>();
|
||||
|
||||
private Graph(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the graph's name
|
||||
*
|
||||
* @return the Graph's name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a plotter to the graph, which will be used to plot entries
|
||||
*
|
||||
* @param plotter the plotter to add to the graph
|
||||
*/
|
||||
public void addPlotter(final Plotter plotter) {
|
||||
plotters.add(plotter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a plotter from the graph
|
||||
*
|
||||
* @param plotter the plotter to remove from the graph
|
||||
*/
|
||||
public void removePlotter(final Plotter plotter) {
|
||||
plotters.remove(plotter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an <b>unmodifiable</b> set of the plotter objects in the graph
|
||||
*
|
||||
* @return an unmodifiable {@link java.util.Set} of the plotter objects
|
||||
*/
|
||||
public Set<Plotter> getPlotters() {
|
||||
return Collections.unmodifiableSet(plotters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return name.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object object) {
|
||||
if (!(object instanceof Graph)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Graph graph = (Graph) object;
|
||||
return graph.name.equals(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the server owner decides to opt-out of BukkitMetrics while the server is running.
|
||||
*/
|
||||
protected void onOptOut() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface used to collect custom data for a plugin
|
||||
*/
|
||||
public static abstract class Plotter {
|
||||
|
||||
/**
|
||||
* The plot's name
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Construct a plotter with the default plot name
|
||||
*/
|
||||
public Plotter() {
|
||||
this("Default");
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a plotter with a specific plot name
|
||||
*
|
||||
* @param name the name of the plotter to use, which will show up on the website
|
||||
*/
|
||||
public Plotter(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current value for the plotted point. Since this function defers to an external function it may or may
|
||||
* not return immediately thus cannot be guaranteed to be thread friendly or safe. This function can be called
|
||||
* from any thread so care should be taken when accessing resources that need to be synchronized.
|
||||
*
|
||||
* @return the current value for the point to be plotted.
|
||||
*/
|
||||
public abstract int getValue();
|
||||
|
||||
/**
|
||||
* Get the column name for the plotted point
|
||||
*
|
||||
* @return the plotted point's column name
|
||||
*/
|
||||
public String getColumnName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the website graphs have been updated
|
||||
*/
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getColumnName().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object object) {
|
||||
if (!(object instanceof Plotter)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Plotter plotter = (Plotter) object;
|
||||
return plotter.name.equals(name) && plotter.getValue() == getValue();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
package com.sekwah.advancedportals.portals;
|
||||
|
||||
import com.sekwah.advancedportals.api.portaldata.PortalArg;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
public class AdvancedPortal {
|
||||
|
||||
public Material trigger = null;
|
||||
|
||||
public String worldName = null;
|
||||
|
||||
public Location pos1 = null;
|
||||
|
||||
public Location pos2 = null;
|
||||
|
||||
public String portalName = null;
|
||||
|
||||
// TODO store destinations also as variables like portals
|
||||
public String destiation = null; // Could possibly store the destination name to stop the server having to read the config file
|
||||
|
||||
public String bungee = null; // Could possibly store the bungee server name to stop the server having to read the config file
|
||||
|
||||
// Bungee will be stored inside the destination.
|
||||
|
||||
public PortalArg[] portalArgs = null;
|
||||
|
||||
public HashSet<Player> inPortal = new HashSet<Player>();
|
||||
|
||||
// TODO think of relaying out the data input to a more logical format.
|
||||
public AdvancedPortal(String portalName, Material trigger, String destination, Location pos1, Location pos2, PortalArg... portalArgs) {
|
||||
this(portalName, trigger, pos1, pos2, pos2.getWorld().getName(), portalArgs);
|
||||
this.destiation = destination;
|
||||
}
|
||||
|
||||
public AdvancedPortal(String portalName, Material trigger, Location pos1, Location pos2, PortalArg... portalArgs) {
|
||||
this(portalName, trigger, pos1, pos2, pos2.getWorld().getName(), portalArgs);
|
||||
}
|
||||
|
||||
public AdvancedPortal(String portalName, Material trigger, String destination, Location pos1, Location pos2, String worldName, PortalArg... portalArgs) {
|
||||
this(portalName, trigger, pos1, pos2, worldName, portalArgs);
|
||||
this.destiation = destination;
|
||||
}
|
||||
|
||||
public AdvancedPortal(String portalName, Material trigger, Location pos1, Location pos2, String worldName, PortalArg... portalArgs) {
|
||||
this.portalName = portalName;
|
||||
this.trigger = trigger;
|
||||
this.pos1 = pos1;
|
||||
this.pos2 = pos2;
|
||||
this.worldName = worldName;
|
||||
this.portalArgs = portalArgs;
|
||||
}
|
||||
|
||||
public String getArg(String arg) {
|
||||
for (PortalArg portalArg : portalArgs) {
|
||||
if (arg.equals(portalArg.argName)) {
|
||||
return portalArg.value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasArg(String arg) {
|
||||
return this.getArg(arg) != null;
|
||||
}
|
||||
}
|
@ -1,549 +0,0 @@
|
||||
package com.sekwah.advancedportals.portals;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.PluginMessages;
|
||||
import com.sekwah.advancedportals.api.portaldata.PortalArg;
|
||||
import com.sekwah.advancedportals.destinations.Destination;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Portal {
|
||||
|
||||
public static HashMap<Player, Long> cooldown = new HashMap<Player, Long>();
|
||||
// Config values
|
||||
public static boolean portalsActive = false;
|
||||
public static AdvancedPortal[] portals = new AdvancedPortal[0];
|
||||
private static AdvancedPortalsPlugin plugin;
|
||||
public static ConfigAccessor portalData = new ConfigAccessor(plugin, "portals.yml");
|
||||
private static boolean showBungeeMessage;
|
||||
private static int cooldelay;
|
||||
private static double throwback;
|
||||
|
||||
public Portal(AdvancedPortalsPlugin plugin) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
showBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage");
|
||||
cooldelay = config.getConfig().getInt("PortalCooldown", 5);
|
||||
throwback = config.getConfig().getDouble("ThrowbackAmount", 0.7);
|
||||
|
||||
Portal.plugin = plugin;
|
||||
Portal.loadPortals();
|
||||
}
|
||||
|
||||
/**
|
||||
* This can be used to move the get keys to different sections
|
||||
* <p>
|
||||
* ConfigurationSection section = portalData.getSection("sectionname");
|
||||
* <p>
|
||||
* section.getKeys(false);
|
||||
*/
|
||||
|
||||
public static void loadPortals() {
|
||||
portalData = new ConfigAccessor(plugin, "portals.yml");
|
||||
Set<String> PortalSet = portalData.getConfig().getKeys(false);
|
||||
if (PortalSet.size() > 0) {
|
||||
portals = new AdvancedPortal[PortalSet.toArray().length];
|
||||
|
||||
/*for(int i = 0; i <= PortalSet.toArray().length - 1; i++){
|
||||
portals[i] = new AdvancedPortal();
|
||||
}*/
|
||||
|
||||
int portalId = 0;
|
||||
for (Object portal : PortalSet.toArray()) {
|
||||
|
||||
ConfigurationSection portalConfigSection = portalData.getConfig().getConfigurationSection(portal.toString());
|
||||
|
||||
Material blockType = Material.PORTAL;
|
||||
String BlockID = portalConfigSection.getString("triggerblock");
|
||||
|
||||
try {
|
||||
Integer.parseInt(BlockID);
|
||||
System.out.println("Block names must be given not IDs");
|
||||
} catch (NumberFormatException e) {
|
||||
blockType = Material.getMaterial(BlockID);
|
||||
}
|
||||
|
||||
if (blockType == null) {
|
||||
blockType = Material.PORTAL;
|
||||
}
|
||||
|
||||
ConfigurationSection portalArgsConf = portalConfigSection.getConfigurationSection("portalArgs");
|
||||
|
||||
ArrayList<PortalArg> extraData = new ArrayList<>();
|
||||
|
||||
if (portalArgsConf != null) {
|
||||
Set<String> argsSet = portalArgsConf.getKeys(true);
|
||||
|
||||
for (Object argName : argsSet.toArray()) {
|
||||
if (portalArgsConf.isString(argName.toString())) {
|
||||
extraData.add(new PortalArg(argName.toString(), portalArgsConf.getString(argName.toString())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String worldName = portalData.getConfig().getString(portal.toString() + ".world");
|
||||
if(worldName != null) {
|
||||
World world = Bukkit.getWorld(worldName);
|
||||
Location pos1 = new Location(world, portalData.getConfig().getInt(portal.toString() + ".pos1.X"), portalData.getConfig().getInt(portal.toString() + ".pos1.Y"), portalData.getConfig().getInt(portal.toString() + ".pos1.Z"));
|
||||
Location pos2 = new Location(world, portalData.getConfig().getInt(portal.toString() + ".pos2.X"), portalData.getConfig().getInt(portal.toString() + ".pos2.Y"), portalData.getConfig().getInt(portal.toString() + ".pos2.Z"));
|
||||
|
||||
PortalArg[] portalArgs = new PortalArg[extraData.size()];
|
||||
extraData.toArray(portalArgs);
|
||||
|
||||
portals[portalId] = new AdvancedPortal(portal.toString(), blockType, pos1, pos2, worldName, portalArgs);
|
||||
|
||||
portals[portalId].bungee = portalConfigSection.getString("bungee");
|
||||
|
||||
portals[portalId].destiation = portalConfigSection.getString("destination");
|
||||
|
||||
portalId++;
|
||||
}
|
||||
else{
|
||||
AdvancedPortal[] tempPortals = portals;
|
||||
|
||||
portals = new AdvancedPortal[portals.length - 1];
|
||||
|
||||
System.arraycopy(tempPortals, 0, portals, 0, portalId);
|
||||
}
|
||||
}
|
||||
portalsActive = true;
|
||||
} else {
|
||||
portalsActive = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String create(Location pos1, Location pos2, String name, String destination, Material triggerBlock, PortalArg... extraData) {
|
||||
return create(pos1, pos2, name, destination, triggerBlock, null, extraData);
|
||||
}
|
||||
|
||||
public static String create(Location pos1, Location pos2, String name, String destination, Material triggerBlock, String serverName, PortalArg... portalArgs) {
|
||||
|
||||
if (!pos1.getWorld().equals(pos2.getWorld())) {
|
||||
plugin.getLogger().log(Level.WARNING, "pos1 and pos2 must be in the same world!");
|
||||
return "\u00A7cPortal creation error, pos1 and pos2 must be in the same world!";
|
||||
}
|
||||
|
||||
int LowX = 0;
|
||||
int LowY = 0;
|
||||
int LowZ = 0;
|
||||
|
||||
int HighX = 0;
|
||||
int HighY = 0;
|
||||
int HighZ = 0;
|
||||
|
||||
if (pos1.getX() > pos2.getX()) {
|
||||
LowX = (int) pos2.getX();
|
||||
HighX = (int) pos1.getX();
|
||||
} else {
|
||||
LowX = (int) pos1.getX();
|
||||
HighX = (int) pos2.getX();
|
||||
}
|
||||
if (pos1.getY() > pos2.getY()) {
|
||||
LowY = (int) pos2.getY();
|
||||
HighY = (int) pos1.getY();
|
||||
} else {
|
||||
LowY = (int) pos1.getY();
|
||||
HighY = (int) pos2.getY();
|
||||
}
|
||||
if (pos1.getZ() > pos2.getZ()) {
|
||||
LowZ = (int) pos2.getZ();
|
||||
HighZ = (int) pos1.getZ();
|
||||
} else {
|
||||
LowZ = (int) pos1.getZ();
|
||||
HighZ = (int) pos2.getZ();
|
||||
}
|
||||
|
||||
Location checkpos1 = new Location(pos1.getWorld(), HighX, HighY, HighZ);
|
||||
Location checkpos2 = new Location(pos2.getWorld(), LowX, LowY, LowZ);
|
||||
|
||||
if (checkPortalOverlap(checkpos1, checkpos2)) {
|
||||
plugin.getLogger().log(Level.WARNING, "portals must not overlap!");
|
||||
return "\u00A7cPortal creation error, portals must not overlap!";
|
||||
}
|
||||
|
||||
portalData.getConfig().set(name + ".world", pos1.getWorld().getName());
|
||||
|
||||
portalData.getConfig().set(name + ".triggerblock", checkMaterial(triggerBlock));
|
||||
|
||||
portalData.getConfig().set(name + ".destination", destination);
|
||||
|
||||
portalData.getConfig().set(name + ".bungee", serverName);
|
||||
|
||||
portalData.getConfig().set(name + ".pos1.X", HighX);
|
||||
portalData.getConfig().set(name + ".pos1.Y", HighY);
|
||||
portalData.getConfig().set(name + ".pos1.Z", HighZ);
|
||||
|
||||
portalData.getConfig().set(name + ".pos2.X", LowX);
|
||||
portalData.getConfig().set(name + ".pos2.Y", LowY);
|
||||
portalData.getConfig().set(name + ".pos2.Z", LowZ);
|
||||
|
||||
for (PortalArg arg : portalArgs) {
|
||||
portalData.getConfig().set(name + ".portalArgs." + arg.argName, arg.value);
|
||||
}
|
||||
|
||||
portalData.saveConfig();
|
||||
|
||||
loadPortals();
|
||||
|
||||
return "\u00A7aPortal creation successful!";
|
||||
}
|
||||
|
||||
// make this actually work!
|
||||
private static boolean checkPortalOverlap(Location pos1, Location pos2) {
|
||||
|
||||
if (portalsActive) {
|
||||
int portalId = 0;
|
||||
for (@SuppressWarnings("unused") Object portal : Portal.portals) {
|
||||
if (portals[portalId].worldName.equals(pos2.getWorld().getName())) { // checks that the cubes arnt overlapping by seeing if all 4 corners are not in side another
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].pos1.getBlockX(), portals[portalId].pos1.getBlockY(), portals[portalId].pos1.getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].pos1.getBlockX(), portals[portalId].pos1.getBlockY(), portals[portalId].pos2.getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].pos1.getBlockX(), portals[portalId].pos2.getBlockY(), portals[portalId].pos1.getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].pos2.getBlockX(), portals[portalId].pos1.getBlockY(), portals[portalId].pos1.getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].pos2.getBlockX(), portals[portalId].pos2.getBlockY(), portals[portalId].pos2.getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].pos2.getBlockX(), portals[portalId].pos1.getBlockY(), portals[portalId].pos2.getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].pos1.getBlockX(), portals[portalId].pos2.getBlockY(), portals[portalId].pos2.getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].pos2.getBlockX(), portals[portalId].pos2.getBlockY(), portals[portalId].pos1.getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
portalId++;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean checkOverLapPortal(Location pos1, Location pos2, int posX, int posY, int posZ) {
|
||||
if (pos1.getX() >= posX && pos1.getY() >= posX && pos1.getZ() >= posZ) {
|
||||
if ((pos2.getX()) <= posX && pos2.getY() <= posY && pos2.getZ() <= posZ) {
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static String checkMaterial(Material triggerBlock) {
|
||||
if (triggerBlock.equals(Material.WATER)) {
|
||||
return "STATIONARY_WATER";
|
||||
} else if (triggerBlock.equals(Material.LAVA)) {
|
||||
return "STATIONARY_LAVA";
|
||||
}
|
||||
return triggerBlock.toString();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static String create(Location pos1, Location pos2, String name, String destination, String serverName, PortalArg... extraData) { // add stuff for destination names or coordinates
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
|
||||
Material triggerBlockType;
|
||||
String BlockID = config.getConfig().getString("DefaultPortalTriggerBlock");
|
||||
try {
|
||||
triggerBlockType = Material.getMaterial(Integer.parseInt(BlockID));
|
||||
} catch (Exception e) {
|
||||
triggerBlockType = Material.getMaterial(BlockID);
|
||||
}
|
||||
|
||||
if (triggerBlockType == null) {
|
||||
triggerBlockType = Material.PORTAL;
|
||||
}
|
||||
|
||||
// TODO add a for loop which scans through the addArgs and adds them to the portalData so that the application can use them
|
||||
|
||||
String result = create(pos1, pos2, name, destination, triggerBlockType, serverName, extraData);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void redefine(Location pos1, Location pos2, String name) {
|
||||
|
||||
portalData.getConfig().set(name + ".pos1.X", pos1.getX());
|
||||
portalData.getConfig().set(name + ".pos1.Y", pos1.getY());
|
||||
portalData.getConfig().set(name + ".pos1.Z", pos1.getZ());
|
||||
|
||||
portalData.getConfig().set(name + ".pos2.X", pos2.getX());
|
||||
portalData.getConfig().set(name + ".pos2.Y", pos2.getY());
|
||||
portalData.getConfig().set(name + ".pos2.Z", pos2.getZ());
|
||||
|
||||
portalData.saveConfig();
|
||||
|
||||
loadPortals();
|
||||
|
||||
}
|
||||
|
||||
public static String getDestination(String portalName) {
|
||||
return portalData.getConfig().getString(portalName + ".destination");
|
||||
}
|
||||
|
||||
public static void remove(String name) {
|
||||
|
||||
Object[] keys = portalData.getConfig().getKeys(true).toArray();
|
||||
for (int i = keys.length - 1; i >= 0; i--) {
|
||||
String key = keys[i].toString();
|
||||
if (key.startsWith(name + ".")) {
|
||||
portalData.getConfig().set(key, null);
|
||||
}
|
||||
}
|
||||
portalData.getConfig().set(name, null);
|
||||
|
||||
// TODO add code to check if people have the portal selected and notify if removed.
|
||||
|
||||
/**Set<String> keys = portalData.getConfig().getKeys(true);
|
||||
for(String key: keys){
|
||||
if(key.startsWith(name)){
|
||||
portalData.getConfig().set(key, null);
|
||||
}
|
||||
}*/
|
||||
|
||||
/**portalData.getConfig().set(name + ".world", null);
|
||||
portalData.getConfig().set(name + ".triggerblock", null);
|
||||
portalData.getConfig().set(name + ".destination", null);
|
||||
|
||||
portalData.getConfig().set(name + ".pos1.X", null);
|
||||
portalData.getConfig().set(name + ".pos1.Y", null);
|
||||
portalData.getConfig().set(name + ".pos1.Z", null);
|
||||
|
||||
portalData.getConfig().set(name + ".pos2.X", null);
|
||||
portalData.getConfig().set(name + ".pos2.Y", null);
|
||||
portalData.getConfig().set(name + ".pos2.Z", null);
|
||||
|
||||
portalData.getConfig().set(name + ".pos1", null);
|
||||
portalData.getConfig().set(name + ".pos2", null);
|
||||
|
||||
portalData.getConfig().set(name, null);*/
|
||||
|
||||
portalData.saveConfig();
|
||||
|
||||
loadPortals();
|
||||
}
|
||||
|
||||
public static boolean portalExists(String portalName) {
|
||||
|
||||
String posX = portalData.getConfig().getString(portalName + ".pos1.X");
|
||||
|
||||
return posX != null;
|
||||
}
|
||||
|
||||
public static boolean activate(Player player, String portalName) {
|
||||
for (AdvancedPortal portal : Portal.portals) {
|
||||
if (portal.portalName.equals(portalName)) return activate(player, portal);
|
||||
}
|
||||
plugin.getLogger().log(Level.SEVERE, "Portal not found by name of: " + portalName);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean activate(Player player, AdvancedPortal portal) {
|
||||
|
||||
// add other variables or filter code here, or somehow have a way to register them
|
||||
|
||||
// TODO on load and unload recode the permissions to try to register themselves
|
||||
// https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/plugin/PluginManager.html#addPermission(org.bukkit.permissions.Permission)
|
||||
// check they havent been registered before too and store a list of ones made by this plugin to remove when portals are unloaded.
|
||||
// When a portal is added or removed it reloads all portals(i think) so add code for unloading too.
|
||||
|
||||
String permission = portal.getArg("permission");
|
||||
/*if((permission == null || (permission != null && player.hasPermission(permission)) || player.isOp())){*/
|
||||
// 3 checks, 1st is if it doesnt need perms. 2nd is if it does do they have it. And third is are they op.
|
||||
if (!(permission == null || (permission != null && player.hasPermission(permission)) || player.isOp())) {
|
||||
player.sendMessage(PluginMessages.customPrefix + "\u00A7c You do not have permission to use this portal!");
|
||||
throwPlayerBack(player);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cooldown.get(player) != null) {
|
||||
int diff = (int) ((System.currentTimeMillis() - cooldown.get(player)) / 1000);
|
||||
if (diff < cooldelay) {
|
||||
player.sendMessage(ChatColor.RED + "Please wait " + ChatColor.YELLOW + (cooldelay - diff) + ChatColor.RED + " seconds until attempting to teleport again.");
|
||||
throwPlayerBack(player);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
cooldown.put(player, System.currentTimeMillis());
|
||||
boolean showFailMessage = !portal.hasArg("command.1");
|
||||
|
||||
//plugin.getLogger().info(portal.portalName + ":" + portal.destiation);
|
||||
boolean warped = false;
|
||||
if (portal.bungee != null) {
|
||||
if (showBungeeMessage) {
|
||||
player.sendMessage(PluginMessages.customPrefix + "\u00A7a Attempting to warp to \u00A7e" + portal.bungee + "\u00A7a.");
|
||||
}
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF(portal.bungee);
|
||||
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||
// Down to bungee to sort out the teleporting but yea theoretically they should warp.
|
||||
}
|
||||
else if (portal.destiation != null) {
|
||||
ConfigAccessor configDesti = new ConfigAccessor(plugin, "destinations.yml");
|
||||
if (configDesti.getConfig().getString(portal.destiation + ".world") != null) {
|
||||
warped = Destination.warp(player, portal.destiation);
|
||||
if(!warped){
|
||||
throwPlayerBack(player);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (showFailMessage) {
|
||||
player.sendMessage(PluginMessages.customPrefix + "\u00A7c The portal you are trying to use doesn't have a destination!");
|
||||
plugin.getLogger().log(Level.SEVERE, "The portal '" + portal.portalName + "' has just had a warp "
|
||||
+ "attempt and either the data is corrupt or portal doesn't exist!");
|
||||
throwPlayerBack(player);
|
||||
}
|
||||
}
|
||||
|
||||
if (portal.hasArg("command.1")) {
|
||||
int commandLine = 1;
|
||||
String command = portal.getArg("command." + commandLine);//portalData.getConfig().getString(portal.portalName+ ".portalArgs.command." + commandLine);
|
||||
do {
|
||||
// (?i) makes the search case insensitive
|
||||
command = command.replaceAll("@player", player.getName());
|
||||
plugin.getLogger().log(Level.INFO, "Portal command: " + command);
|
||||
if (command.startsWith("#") && plugin.getSettings().hasCommandLevel("c")) {
|
||||
command = command.substring(1);
|
||||
plugin.getLogger().log(Level.INFO, "Portal command: " + command);
|
||||
try{
|
||||
plugin.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
}
|
||||
catch(Exception e){
|
||||
plugin.getLogger().warning("Error while executing: " + command);
|
||||
}
|
||||
} else if (command.startsWith("!") && plugin.getSettings().hasCommandLevel("o")) {
|
||||
command = command.substring(1);
|
||||
boolean wasOp = player.isOp();
|
||||
try {
|
||||
player.setOp(true);
|
||||
player.performCommand(command);
|
||||
} finally {
|
||||
player.setOp(wasOp);
|
||||
}
|
||||
} else if (command.startsWith("^")) {
|
||||
command = command.substring(1);
|
||||
PermissionAttachment permissionAttachment = null;
|
||||
try {
|
||||
permissionAttachment = player.addAttachment(plugin, "*", true);
|
||||
player.performCommand(command);
|
||||
} finally {
|
||||
player.removeAttachment(permissionAttachment);
|
||||
}
|
||||
} else {
|
||||
player.performCommand(command);
|
||||
}
|
||||
command = portal.getArg("command." + ++commandLine);
|
||||
} while (command != null);
|
||||
}
|
||||
|
||||
return warped;
|
||||
}
|
||||
|
||||
public static void rename(String oldName, String newName) {
|
||||
|
||||
// set it so it gets all data from one and puts it into another place
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "portals.yml");
|
||||
|
||||
Set<String> keys = config.getConfig().getKeys(true);
|
||||
for (String key : keys) {
|
||||
if (key.startsWith(oldName + ".")) {
|
||||
if (config.getConfig().getString(key) != null) {
|
||||
try {
|
||||
int intData = Integer.parseInt(config.getConfig().getString(key));
|
||||
config.getConfig().set(key.replace(oldName + ".", newName + "."), intData);
|
||||
} catch (Exception e) {
|
||||
config.getConfig().set(key.replace(oldName + ".", newName + "."), config.getConfig().getString(key));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
config.saveConfig();
|
||||
|
||||
remove(oldName);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static boolean addCommand(String portalName, String portalCommand) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "portals.yml");
|
||||
if (portalExists(portalName)) {
|
||||
int commandLine = 0;
|
||||
while (config.getConfig().getString(portalName + ".portalArgs.command." + ++commandLine) != null)
|
||||
; //Loops increasing commandLine till 1 is null
|
||||
config.getConfig().set(portalName + ".portalArgs.command." + commandLine, portalCommand);
|
||||
config.saveConfig();
|
||||
loadPortals();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean inPortalTriggerRegion(Location loc) {
|
||||
for (AdvancedPortal portal : Portal.portals)
|
||||
if (Portal.locationInPortalTrigger(portal, loc))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean locationInPortalTrigger(AdvancedPortal portal, Location loc) {
|
||||
if (portal.trigger.equals(loc.getBlock().getType()))
|
||||
return locationInPortal(portal, loc, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean inPortalRegion(Location loc, int additionalArea) {
|
||||
for (AdvancedPortal portal : Portal.portals)
|
||||
if (Portal.locationInPortal(portal, loc, additionalArea))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean locationInPortal(AdvancedPortal portal, Location loc, int additionalArea) {
|
||||
if (!portalsActive)
|
||||
return false;
|
||||
if (loc.getWorld() != null && portal.worldName.equals(loc.getWorld().getName()))
|
||||
if ((portal.pos1.getX() + 1 + additionalArea) >= loc.getX() && (portal.pos1.getY() + 1 + additionalArea) > loc.getY() && (portal.pos1.getZ() + 1 + additionalArea) >= loc.getZ())
|
||||
if (portal.pos2.getX() - additionalArea <= loc.getX() && portal.pos2.getY() - additionalArea <= loc.getY() && portal.pos2.getZ() - additionalArea <= loc.getZ())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void throwPlayerBack(Player player){
|
||||
// Not ensured to remove them out of the portal but it makes it feel nicer for the player.
|
||||
if (throwback > 0) {
|
||||
Vector velocity = player.getLocation().getDirection();
|
||||
player.setVelocity(velocity.setY(0).normalize().multiply(-1).setY(throwback));
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,186 @@
|
||||
package com.sekwah.advancedportals.bukkit;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigHelper;
|
||||
import com.sekwah.advancedportals.bukkit.destinations.Destination;
|
||||
import com.sekwah.advancedportals.bukkit.destinations.DestinationCommand;
|
||||
import com.sekwah.advancedportals.bukkit.effects.WarpEffects;
|
||||
import com.sekwah.advancedportals.bukkit.listeners.*;
|
||||
import com.sekwah.advancedportals.bukkit.metrics.Metrics;
|
||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||
import com.sekwah.advancedportals.bungee.BungeeMessages;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||
|
||||
private Settings settings;
|
||||
|
||||
protected boolean isProxyPluginEnabled = false;
|
||||
|
||||
protected boolean forceRegisterProxyChannels = false;
|
||||
protected boolean disableProxyWarning = false;
|
||||
|
||||
private boolean worldEditActive = false;
|
||||
|
||||
protected static final Map<String, String> PLAYER_DESTI_MAP = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
saveDefaultConfig();
|
||||
|
||||
/*Metrics metrics = */
|
||||
new Metrics(this);
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(this, "config.yml");
|
||||
|
||||
ConfigHelper configHelper = new ConfigHelper(config.getConfig());
|
||||
|
||||
configHelper.update();
|
||||
|
||||
config.saveConfig();
|
||||
|
||||
FileConfiguration pluginConfig = config.getConfig();
|
||||
forceRegisterProxyChannels = pluginConfig.getBoolean(ConfigHelper.FORCE_ENABLE_PROXY_SUPPORT, false);
|
||||
disableProxyWarning = pluginConfig.getBoolean(ConfigHelper.DISABLE_PROXY_WARNING, false);
|
||||
|
||||
ConfigAccessor portalConfig = new ConfigAccessor(this, "portals.yml");
|
||||
portalConfig.saveDefaultConfig();
|
||||
|
||||
|
||||
ConfigAccessor destinationConfig = new ConfigAccessor(this, "destinations.yml");
|
||||
destinationConfig.saveDefaultConfig();
|
||||
|
||||
this.settings = new Settings(this);
|
||||
|
||||
// Loads the portal and destination editors
|
||||
Portal.init(this);
|
||||
Destination.init(this);
|
||||
|
||||
|
||||
this.registerCommands();
|
||||
|
||||
new WarpEffects(this);
|
||||
|
||||
this.addListeners();
|
||||
this.setupDataCollector();
|
||||
|
||||
this.setupBungee();
|
||||
|
||||
this.getServer().getConsoleSender().sendMessage("\u00A7aAdvanced portals have been successfully enabled!");
|
||||
|
||||
for (Player player:
|
||||
this.getServer().getOnlinePlayers()) {
|
||||
player.removeMetadata(Listeners.HAS_WARPED, this);
|
||||
player.removeMetadata(Listeners.LAVA_WARPED, this);
|
||||
}
|
||||
|
||||
if (settings.enabledWorldEditIntegration() && Bukkit.getPluginManager().isPluginEnabled("WorldEdit")) {
|
||||
worldEditActive = true;
|
||||
}
|
||||
|
||||
// thanks to the new config accessor code the config.saveDefaultConfig(); will now
|
||||
// only copy the file if it doesnt exist!
|
||||
}
|
||||
|
||||
private void registerCommands() {
|
||||
new PluginMessages(this);
|
||||
new AdvancedPortalsCommand(this);
|
||||
new DestinationCommand(this);
|
||||
}
|
||||
|
||||
private void addListeners() {
|
||||
new Listeners(this);
|
||||
|
||||
new FlowStopper(this);
|
||||
new PortalProtect(this);
|
||||
new PortalPlacer(this);
|
||||
}
|
||||
|
||||
private void setupDataCollector() {
|
||||
Selection.loadData(this);
|
||||
}
|
||||
|
||||
private void setupBungee() {
|
||||
// Enables very basic bungee support if not setup right
|
||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
if(forceRegisterProxyChannels || this.checkIfBungee()) {
|
||||
this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeListener(this));
|
||||
|
||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, BungeeMessages.CHANNEL_NAME);
|
||||
this.getServer().getMessenger().registerIncomingPluginChannel(this, BungeeMessages.CHANNEL_NAME, new PluginMessageReceiver(this));
|
||||
isProxyPluginEnabled = true;
|
||||
}
|
||||
else {
|
||||
isProxyPluginEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, String> getPlayerDestiMap() {
|
||||
return PLAYER_DESTI_MAP;
|
||||
}
|
||||
|
||||
public boolean isProxyPluginEnabled() {
|
||||
return isProxyPluginEnabled;
|
||||
}
|
||||
|
||||
private boolean checkIfBungee()
|
||||
{
|
||||
// we check if the server is Spigot/Paper (because of the spigot.yml file)
|
||||
try {
|
||||
Class.forName("org.spigotmc.SpigotConfig");
|
||||
} catch (ClassNotFoundException e) {
|
||||
this.getServer().getConsoleSender().sendMessage( "\u00A7ePossibly unsupported version for bungee messages detected, channels won't be enabled." );
|
||||
getLogger().info("If you believe this shouldn't be the case please contact us on discord https://discord.sekwah.com/");
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
ConfigurationSection configSelection = getServer().spigot().getConfig().getConfigurationSection("settings");
|
||||
if (configSelection != null && configSelection.getBoolean("bungeecord") ) {
|
||||
getLogger().info( "Bungee detected. Enabling proxy features." );
|
||||
return true;
|
||||
}
|
||||
} catch(NoSuchMethodError | NullPointerException e) {
|
||||
if(!disableProxyWarning) getLogger().info("BungeeCord config not detected, ignoring settings");
|
||||
}
|
||||
|
||||
// Will be valid if paperspigot is being used. Otherwise catch.
|
||||
try {
|
||||
ConfigurationSection configSelection = getServer().spigot().getPaperConfig().getConfigurationSection("settings");
|
||||
ConfigurationSection velocity = configSelection != null ? configSelection.getConfigurationSection("velocity-support") : null;
|
||||
if (velocity != null && velocity.getBoolean("enabled") ) {
|
||||
getLogger().info( "Modern forwarding detected. Enabling proxy features." );
|
||||
return true;
|
||||
}
|
||||
} catch(NoSuchMethodError | NullPointerException e) {
|
||||
if(!disableProxyWarning) getLogger().info("Paper config not detected, ignoring paper settings");
|
||||
}
|
||||
|
||||
if(!disableProxyWarning) getLogger().warning( "Proxy features disabled for Advanced Portals as bungee isn't enabled on the server (spigot.yml) " +
|
||||
"or if you are using Paper settings.velocity-support.enabled may not be enabled (paper.yml)" );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
this.getServer().getConsoleSender().sendMessage("\u00A7cAdvanced portals are being disabled!");
|
||||
}
|
||||
|
||||
|
||||
public Settings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
public boolean isWorldEditActive() {
|
||||
return worldEditActive;
|
||||
}
|
||||
}
|
@ -1,26 +1,34 @@
|
||||
package com.sekwah.advancedportals;
|
||||
package com.sekwah.advancedportals.bukkit;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class PluginMessages {
|
||||
private AdvancedPortalsPlugin plugin;
|
||||
private static String WARP_MESSAGE;
|
||||
public boolean useCustomPrefix = false;
|
||||
public static String customPrefix = "\u00A7a[\u00A7eAdvancedPortals\u00A7a]";
|
||||
public static String customPrefixFail = "\u00A7c[\u00A77AdvancedPortals\u00A7c]";
|
||||
|
||||
public PluginMessages (AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
ConfigAccessor config = new ConfigAccessor(this.plugin, "config.yml");
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
this.useCustomPrefix = config.getConfig().getBoolean("UseCustomPrefix");
|
||||
if (useCustomPrefix) {
|
||||
PluginMessages.customPrefixFail = config.getConfig().getString("CustomPrefix").replaceAll("&", "\u00A7");
|
||||
PluginMessages.customPrefixFail = config.getConfig().getString("CustomPrefixFail").replaceAll("&", "\u00A7");
|
||||
PluginMessages.customPrefix = config.getConfig().getString("CustomPrefix").replaceAll("&(?=[0-9a-fk-or])", "\u00A7");
|
||||
PluginMessages.customPrefixFail = config.getConfig().getString("CustomPrefixFail").replaceAll("&(?=[0-9a-fk-or])", "\u00A7");
|
||||
}
|
||||
|
||||
WARP_MESSAGE = ChatColor.translateAlternateColorCodes('&', config.getConfig().getString("WarpMessage", "&aYou have warped to &e<warp>&a"));
|
||||
}
|
||||
|
||||
// This class is so then the common messages in commands or just messages over the commands are the same and can be
|
||||
// easily changed.
|
||||
|
||||
public static String getWarpMessage(String warp) {
|
||||
String cleanedWarp = warp.replace("_", " ");
|
||||
return WARP_MESSAGE.replace("<warp>", cleanedWarp);
|
||||
}
|
||||
|
||||
public static void UnknownCommand(CommandSender sender, String command) {
|
||||
sender.sendMessage(customPrefixFail + " You need to type something after /" + command + "\n");
|
||||
sender.sendMessage("\u00A7cIf you do not know what you can put or would like some help with the commands please type \u00A7e" + '"' + "\u00A7e/" + command + " help" + '"' + "\u00A7c\n");
|
@ -1,38 +1,35 @@
|
||||
package com.sekwah.advancedportals;
|
||||
package com.sekwah.advancedportals.bukkit;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Selection {
|
||||
|
||||
public static Material blockType = Material.STAINED_GLASS;
|
||||
public static int timeout = 10;
|
||||
public static byte metadata = 14;
|
||||
private static Material blockType = Material.RED_STAINED_GLASS;
|
||||
private static int timeout = 10;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void LoadData(AdvancedPortalsPlugin plugin) {
|
||||
public static void loadData(AdvancedPortalsPlugin plugin) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
|
||||
timeout = config.getConfig().getInt("ShowSelectionShowDuration");
|
||||
|
||||
String BlockID = config.getConfig().getString("ShowSelectionBlockID");
|
||||
try {
|
||||
blockType = Material.getMaterial(Integer.parseInt(BlockID));
|
||||
} catch (Exception e) {
|
||||
blockType = Material.getMaterial(BlockID);
|
||||
}
|
||||
|
||||
blockType = Material.getMaterial(BlockID);
|
||||
|
||||
if (blockType == null) {
|
||||
blockType = Material.STAINED_GLASS;
|
||||
plugin.getLogger().warning("Material may be from old name format");
|
||||
blockType = Material.RED_STAINED_GLASS;
|
||||
}
|
||||
|
||||
metadata = (byte) config.getConfig().getInt("ShowSelectionBlockData");
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void Show(final Player player, final AdvancedPortalsPlugin plugin, String portalName) {
|
||||
public static void show(final Player player, final AdvancedPortalsPlugin plugin, String portalName) {
|
||||
|
||||
int LowX = 0;
|
||||
int LowY = 0;
|
||||
@ -79,6 +76,8 @@ public class Selection {
|
||||
final Location pos1 = new Location(player.getWorld(), LowX, LowY, LowZ);
|
||||
final Location pos2 = new Location(player.getWorld(), HighX, HighY, HighZ);
|
||||
|
||||
BlockData blockData = blockType.createBlockData();
|
||||
|
||||
/*
|
||||
* There are alot of for loops at the moment, when i find an easier way to do these other that a load of if statements
|
||||
* then i will change it, but for now its the best way i can think of for doing this.
|
||||
@ -86,64 +85,64 @@ public class Selection {
|
||||
|
||||
for (int x = LowX; x <= HighX; x++) {
|
||||
Location loc = new Location(player.getWorld(), x, LowY, LowZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int x = LowX; x <= HighX; x++) {
|
||||
Location loc = new Location(player.getWorld(), x, LowY, HighZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int z = LowZ; z <= HighZ; z++) {
|
||||
Location loc = new Location(player.getWorld(), LowX, LowY, z);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int z = LowZ; z <= HighZ; z++) {
|
||||
Location loc = new Location(player.getWorld(), HighX, LowY, z);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int y = LowY; y <= HighY; y++) {
|
||||
Location loc = new Location(player.getWorld(), LowX, y, LowZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int y = LowY; y <= HighY; y++) {
|
||||
Location loc = new Location(player.getWorld(), LowX, y, HighZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int y = LowY; y <= HighY; y++) {
|
||||
Location loc = new Location(player.getWorld(), HighX, y, LowZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int y = LowY; y <= HighY; y++) {
|
||||
Location loc = new Location(player.getWorld(), HighX, y, HighZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int x = LowX; x <= HighX; x++) {
|
||||
Location loc = new Location(player.getWorld(), x, HighY, HighZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int x = LowX; x <= HighX; x++) {
|
||||
Location loc = new Location(player.getWorld(), x, HighY, LowZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int z = LowZ; z <= HighZ; z++) {
|
||||
Location loc = new Location(player.getWorld(), LowX, HighY, z);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int z = LowZ; z <= HighZ; z++) {
|
||||
Location loc = new Location(player.getWorld(), HighX, HighY, z);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
Selection.Hide(player, plugin, pos1, pos2);
|
||||
Selection.hide(player, plugin, pos1, pos2);
|
||||
}
|
||||
}, timeout * 20);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected static void Hide(Player player, AdvancedPortalsPlugin plugin, Location pos1, Location pos2) {
|
||||
protected static void hide(Player player, AdvancedPortalsPlugin plugin, Location pos1, Location pos2) {
|
||||
|
||||
int LowX = pos1.getBlockX();
|
||||
int LowY = pos1.getBlockY();
|
@ -0,0 +1,75 @@
|
||||
package com.sekwah.advancedportals.bukkit;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
|
||||
import static com.sekwah.advancedportals.bukkit.Settings.PortalConfigOption.*;
|
||||
|
||||
/**
|
||||
* This contains generally used settings mostly
|
||||
*/
|
||||
public class Settings {
|
||||
|
||||
private int currentWarpParticles = 0;
|
||||
|
||||
private int currentWarpSound = 0;
|
||||
|
||||
private String commandLevels = "n";
|
||||
|
||||
private boolean worldEditEnabled = false;
|
||||
|
||||
public enum PortalConfigOption {
|
||||
COMMAND_LEVELS("CommandLevels"),
|
||||
WARP_PARTICLES("WarpParticles"),
|
||||
WARP_SOUND("WarpSound"),
|
||||
WORLDEDIT_INTEGRATION("WorldEditIntegration");
|
||||
|
||||
private final String target;
|
||||
|
||||
PortalConfigOption(String target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
return this.target;
|
||||
}
|
||||
}
|
||||
|
||||
public Settings(AdvancedPortalsPlugin plugin) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
currentWarpParticles = config.getConfig().getInt(WARP_PARTICLES.value());
|
||||
currentWarpSound = config.getConfig().getInt(WARP_SOUND.value());
|
||||
|
||||
commandLevels = config.getConfig().getString(COMMAND_LEVELS.value(), "opcb");
|
||||
|
||||
worldEditEnabled = config.getConfig().getBoolean(WORLDEDIT_INTEGRATION.value(), false);
|
||||
|
||||
assert commandLevels != null;
|
||||
if(commandLevels.equals("opchek")) {
|
||||
commandLevels = "opcb";
|
||||
config.getConfig().set(COMMAND_LEVELS.value(), "opcb");
|
||||
}
|
||||
if(commandLevels.contains("n") || commandLevels.equals("")) {
|
||||
commandLevels = "n";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCommandLevels(){
|
||||
return this.commandLevels;
|
||||
}
|
||||
|
||||
public boolean enabledCommandLevel(String level){
|
||||
return this.commandLevels.contains(level);
|
||||
}
|
||||
|
||||
public int getCurrentWarpSound() {
|
||||
return currentWarpSound;
|
||||
}
|
||||
|
||||
public int getCurrentWarpParticles() {
|
||||
return currentWarpParticles;
|
||||
}
|
||||
|
||||
public boolean enabledWorldEditIntegration() {
|
||||
return worldEditEnabled;
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.sekwah.advancedportals.api.events;
|
||||
package com.sekwah.advancedportals.bukkit.api.events;
|
||||
|
||||
import com.sekwah.advancedportals.portals.AdvancedPortal;
|
||||
import com.sekwah.advancedportals.bukkit.portals.AdvancedPortal;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
@ -16,10 +16,10 @@ public final class WarpEvent extends Event implements Cancellable {
|
||||
|
||||
private boolean cancelled = false;
|
||||
|
||||
private Player player;
|
||||
private final Player player;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private AdvancedPortal portalData;
|
||||
private final AdvancedPortal portalData;
|
||||
|
||||
private boolean hasWarped = false;
|
||||
|
||||
@ -75,4 +75,4 @@ public final class WarpEvent extends Event implements Cancellable {
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +1,9 @@
|
||||
package com.sekwah.advancedportals.api.portaldata;
|
||||
package com.sekwah.advancedportals.bukkit.api.portaldata;
|
||||
|
||||
public class PortalArg {
|
||||
|
||||
public final String argName;
|
||||
public final String value;
|
||||
//public final int type;
|
||||
|
||||
public PortalArg(String argName, String value/*, int type*/) {
|
||||
this.argName = argName;
|
@ -1,16 +1,9 @@
|
||||
package com.sekwah.advancedportals.api.portaldata;
|
||||
package com.sekwah.advancedportals.bukkit.api.portaldata;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by on 29/03/2016.
|
||||
* <p>
|
||||
* TODO add all the normal tags then add the extradata tags
|
||||
*
|
||||
* @author sekwah41
|
||||
*/
|
||||
public class PortalTags {
|
||||
|
||||
// TODO create a list or hashmap of tags to check for.
|
@ -1,28 +1,23 @@
|
||||
package com.sekwah.advancedportals.api.registry;
|
||||
package com.sekwah.advancedportals.bukkit.api.registry;
|
||||
|
||||
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.api.warphandler.TagHandler;
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.api.warphandler.TagHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by on 25/07/2016.
|
||||
*
|
||||
* @author sekwah41
|
||||
*/
|
||||
public class TagRegistry {
|
||||
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
private ArrayList<String> tags = new ArrayList<String>();
|
||||
private final ArrayList<String> tags = new ArrayList<String>();
|
||||
|
||||
private Map<String, TagHandler.Activation> tagActivation = new HashMap<String, TagHandler.Activation>();
|
||||
private final Map<String, TagHandler.Activation> tagActivation = new HashMap<String, TagHandler.Activation>();
|
||||
|
||||
private Map<String, TagHandler.Creation> tagCreation = new HashMap<String, TagHandler.Creation>();
|
||||
private final Map<String, TagHandler.Creation> tagCreation = new HashMap<String, TagHandler.Creation>();
|
||||
|
||||
private Map<String, TagHandler.TagStatus> tagStatus = new HashMap<String, TagHandler.TagStatus>();
|
||||
private final Map<String, TagHandler.TagStatus> tagStatus = new HashMap<String, TagHandler.TagStatus>();
|
||||
|
||||
// TODO the event can be used for general data detection and management, but use a TagHandler to make it so they can register
|
||||
// the individual class to handle.
|
@ -1,19 +1,14 @@
|
||||
package com.sekwah.advancedportals.api.warphandler;
|
||||
package com.sekwah.advancedportals.bukkit.api.warphandler;
|
||||
|
||||
import com.sekwah.advancedportals.portals.Portal;
|
||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||
|
||||
/**
|
||||
* Created by on 30/07/2016.
|
||||
*
|
||||
* @author sekwah41
|
||||
*/
|
||||
public class ActivationData {
|
||||
|
||||
private boolean warpAllowed = true;
|
||||
|
||||
private WarpedStatus warpStatus = WarpedStatus.INACTIVE;
|
||||
|
||||
private Portal activePortal;
|
||||
private final Portal activePortal;
|
||||
|
||||
public ActivationData(Portal portal){
|
||||
this.activePortal = portal;
|
||||
@ -24,10 +19,7 @@ public class ActivationData {
|
||||
}
|
||||
|
||||
public void setWarpStatus(WarpedStatus warped){
|
||||
if(this.warpStatus == WarpedStatus.WARPED){
|
||||
return;
|
||||
}
|
||||
else if(this.warpStatus == WarpedStatus.INACTIVE){
|
||||
if(this.warpStatus == WarpedStatus.WARPED || this.warpStatus == WarpedStatus.INACTIVE){
|
||||
return;
|
||||
}
|
||||
this.warpStatus = warped;
|
||||
@ -61,7 +53,7 @@ public class ActivationData {
|
||||
/**
|
||||
* Nothing has activated on the portal.
|
||||
*/
|
||||
INACTIVE;
|
||||
INACTIVE
|
||||
}
|
||||
|
||||
}
|
@ -1,13 +1,7 @@
|
||||
package com.sekwah.advancedportals.api.warphandler;
|
||||
package com.sekwah.advancedportals.bukkit.api.warphandler;
|
||||
|
||||
import com.sekwah.advancedportals.portals.Portal;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by on 30/07/2016.
|
||||
*
|
||||
* @author sekwah41
|
||||
*/
|
||||
public class TagHandler {
|
||||
|
||||
public interface Creation{
|
@ -1,4 +1,4 @@
|
||||
package com.sekwah.advancedportals;
|
||||
package com.sekwah.advancedportals.bukkit.config;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@ -6,7 +6,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ConfigAccessor {
|
||||
@ -79,4 +78,4 @@ public class ConfigAccessor {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.sekwah.advancedportals.bukkit.config;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
public class ConfigHelper {
|
||||
|
||||
public static final String CONFIG_VERSION = "ConfigVersion";
|
||||
|
||||
public static final String COMMAND_LOGS = "CommandLogs";
|
||||
|
||||
public static final String FORCE_ENABLE_PROXY_SUPPORT = "ForceEnableProxySupport";
|
||||
public static final String DISABLE_PROXY_WARNING = "DisableProxyWarning";
|
||||
|
||||
public static final String PROXY_TELEPORT_DELAY = "ProxyTeleportDelay";
|
||||
|
||||
public static final String DISABLE_GATEWAY_BEAM = "DisableGatewayBeam";
|
||||
|
||||
private final FileConfiguration config;
|
||||
|
||||
public ConfigHelper(FileConfiguration config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively for each time there is a future update
|
||||
*/
|
||||
public void update() {
|
||||
String configVersion = config.getString(CONFIG_VERSION);
|
||||
// Added in 0.5.4
|
||||
if(configVersion == null || configVersion.equals("true") || configVersion.equals("0.5.3")) {
|
||||
config.set(ConfigHelper.CONFIG_VERSION, "0.5.4");
|
||||
|
||||
config.set(ConfigHelper.DISABLE_GATEWAY_BEAM, true);
|
||||
update();
|
||||
} else if(configVersion.equals("0.5.4")) {
|
||||
config.set(ConfigHelper.CONFIG_VERSION, "0.5.11");
|
||||
config.set(ConfigHelper.COMMAND_LOGS, true);
|
||||
update();
|
||||
} else if(configVersion.equals("0.5.10") || configVersion.equals("0.5.11")) {
|
||||
config.set(ConfigHelper.CONFIG_VERSION, "0.5.13");
|
||||
config.set(ConfigHelper.FORCE_ENABLE_PROXY_SUPPORT, false);
|
||||
config.set(ConfigHelper.PROXY_TELEPORT_DELAY, 0);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,38 +1,36 @@
|
||||
package com.sekwah.advancedportals.destinations;
|
||||
package com.sekwah.advancedportals.bukkit.destinations;
|
||||
|
||||
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.PluginMessages;
|
||||
import com.sekwah.advancedportals.effects.WarpEffects;
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.PluginMessages;
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.bukkit.effects.WarpEffects;
|
||||
import com.sekwah.advancedportals.bukkit.portals.AdvancedPortal;
|
||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Destination {
|
||||
|
||||
private static AdvancedPortalsPlugin plugin;
|
||||
|
||||
private static boolean TeleportRiding = false;
|
||||
public static int PortalMessagesDisplay = 0;
|
||||
private static boolean TELEPORT_RIDING = false;
|
||||
public static int PORTAL_MESSAGE_DISPLAY = 0;
|
||||
|
||||
public Destination(AdvancedPortalsPlugin plugin) {
|
||||
public static void init(AdvancedPortalsPlugin plugin) {
|
||||
Destination.plugin = plugin;
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
TeleportRiding = config.getConfig().getBoolean("WarpRiddenEntity");
|
||||
PortalMessagesDisplay = config.getConfig().getInt("WarpMessageDisplay");
|
||||
TELEPORT_RIDING = config.getConfig().getBoolean("WarpRiddenEntity");
|
||||
PORTAL_MESSAGE_DISPLAY = config.getConfig().getInt("WarpMessageDisplay");
|
||||
}
|
||||
|
||||
// TODO add permissions for destinations.
|
||||
@ -108,30 +106,44 @@ public class Destination {
|
||||
}
|
||||
|
||||
public static boolean warp(Player player, String name) {
|
||||
if (!(player.hasPermission("advancedportals.warp.*") || player.hasPermission("advancedportals.warp." + name))) {
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " You don't have permission to warp to " + name + "!");
|
||||
return false;
|
||||
}
|
||||
return warp(player, name, false);
|
||||
}
|
||||
|
||||
public static boolean warp(Player player, String name, boolean hideActionBar) {
|
||||
return warp(player, name, null, hideActionBar, false);
|
||||
}
|
||||
|
||||
public static boolean warp(Player player, String name, boolean hideActionBar, boolean noEffects) {
|
||||
return warp(player, name, null, hideActionBar, noEffects);
|
||||
}
|
||||
|
||||
public static boolean warp(Player player, String dest, AdvancedPortal disp, boolean hideActionbar, boolean noEffects) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
|
||||
if (config.getConfig().getString(name + ".world") != null) {
|
||||
if (config.getConfig().getString(dest + ".world") != null) {
|
||||
Location loc = player.getLocation();
|
||||
if (Bukkit.getWorld(config.getConfig().getString(name + ".world")) != null) {
|
||||
loc.setWorld(Bukkit.getWorld(config.getConfig().getString(name + ".world")));
|
||||
if (Bukkit.getWorld(config.getConfig().getString(dest + ".world")) != null) {
|
||||
loc.setWorld(Bukkit.getWorld(config.getConfig().getString(dest + ".world")));
|
||||
|
||||
loc.setX(config.getConfig().getDouble(name + ".pos.X"));
|
||||
loc.setY(config.getConfig().getDouble(name + ".pos.Y"));
|
||||
loc.setZ(config.getConfig().getDouble(name + ".pos.Z"));
|
||||
loc.setX(config.getConfig().getDouble(dest + ".pos.X"));
|
||||
loc.setY(config.getConfig().getDouble(dest + ".pos.Y"));
|
||||
loc.setZ(config.getConfig().getDouble(dest + ".pos.Z"));
|
||||
|
||||
loc.setPitch((float) config.getConfig().getDouble(name + ".pos.pitch"));
|
||||
loc.setYaw((float) config.getConfig().getDouble(name + ".pos.yaw"));
|
||||
loc.setPitch((float) config.getConfig().getDouble(dest + ".pos.pitch"));
|
||||
loc.setYaw((float) config.getConfig().getDouble(dest + ".pos.yaw"));
|
||||
|
||||
WarpEffects.activateParticles(player);
|
||||
WarpEffects.activateSound(player);
|
||||
if (disp != null && disp.getArg("particlein") != null) {
|
||||
WarpEffects.activateParticle(player, disp.getArg("particlein"));
|
||||
}
|
||||
|
||||
if(!noEffects) {
|
||||
WarpEffects.activateEffect(player);
|
||||
WarpEffects.activateSound(player);
|
||||
}
|
||||
Chunk c = loc.getChunk();
|
||||
Entity riding = player.getVehicle();
|
||||
if (!c.isLoaded()) c.load();
|
||||
|
||||
if (player.getVehicle() != null && TeleportRiding) {
|
||||
if (player.getVehicle() != null && TELEPORT_RIDING) {
|
||||
|
||||
riding.eject();
|
||||
riding.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
@ -141,28 +153,42 @@ public class Destination {
|
||||
} else {
|
||||
player.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
}
|
||||
WarpEffects.activateParticles(player);
|
||||
WarpEffects.activateSound(player);
|
||||
|
||||
if (PortalMessagesDisplay == 1) {
|
||||
if (disp != null && disp.getArg("particleout") != null) {
|
||||
WarpEffects.activateParticle(player, disp.getArg("particleout"));
|
||||
}
|
||||
if(!noEffects) {
|
||||
WarpEffects.activateEffect(player);
|
||||
WarpEffects.activateSound(player);
|
||||
}
|
||||
|
||||
if (PORTAL_MESSAGE_DISPLAY == 1) {
|
||||
player.sendMessage("");
|
||||
player.sendMessage(PluginMessages.customPrefixFail + "\u00A7a You have been warped to \u00A7e" + name.replaceAll("_", " ") + "\u00A7a.");
|
||||
player.sendMessage(PluginMessages.customPrefix + PluginMessages.getWarpMessage(dest));
|
||||
player.sendMessage("");
|
||||
} else if (PortalMessagesDisplay == 2) {
|
||||
plugin.compat.sendActionBarMessage("{\"text\":\"\u00A7aYou have warped to \u00A7e" + name.replaceAll("_", " ") + "\u00A7a.\"}", player);
|
||||
/**plugin.nmsAccess.sendActionBarMessage("[{text:\"You have warped to \",color:green},{text:\"" + config.getConfig().getString(Portal.portals[portalId].portalName + ".destination").replaceAll("_", " ")
|
||||
+ "\",color:yellow},{\"text\":\".\",color:green}]", player);*/
|
||||
} else if (PORTAL_MESSAGE_DISPLAY == 2 && !hideActionbar) {
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(PluginMessages.getWarpMessage(dest)));
|
||||
}
|
||||
|
||||
Location newLoc = player.getLocation();
|
||||
Location newEyeLoc = player.getEyeLocation();
|
||||
UUID uuid = player.getUniqueId();
|
||||
for (AdvancedPortal portal : Portal.portals) {
|
||||
if (!portal.inPortal.contains(uuid) && !portal.isDelayed()
|
||||
&& (Portal.locationInPortalTrigger(portal, newLoc) || Portal.locationInPortalTrigger(portal, newEyeLoc))) {
|
||||
portal.inPortal.add(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
player.sendMessage(PluginMessages.customPrefixFail + "\u00A7c The destination you are trying to warp to seems to be linked to a world that doesn't exist!");
|
||||
plugin.getLogger().log(Level.SEVERE, "The destination '" + name + "' is linked to the world "
|
||||
+ config.getConfig().getString(name + ".world") + " which doesnt seem to exist any more!");
|
||||
plugin.getLogger().log(Level.SEVERE, "The destination '" + dest + "' is linked to the world "
|
||||
+ config.getConfig().getString(dest + ".world") + " which doesnt seem to exist any more!");
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(PluginMessages.customPrefix + "\u00A7c The destination you are currently attempting to warp to doesnt exist!");
|
||||
plugin.getLogger().log(Level.SEVERE, "The destination '" + name + "' has just had a warp "
|
||||
plugin.getLogger().log(Level.SEVERE, "The destination '" + dest + "' has just had a warp "
|
||||
+ "attempt and either the data is corrupt or that destination doesn't exist!");
|
||||
}
|
||||
return false;
|
@ -1,19 +1,22 @@
|
||||
package com.sekwah.advancedportals.destinations;
|
||||
package com.sekwah.advancedportals.bukkit.destinations;
|
||||
|
||||
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.PluginMessages;
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.PluginMessages;
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class DestinationCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
private AdvancedPortalsPlugin plugin;
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
public DestinationCommand(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -24,6 +27,10 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String command, String[] args) {
|
||||
if(!(sender instanceof Player)) {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " You cannot use commands with the console.");
|
||||
return true;
|
||||
}
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
|
||||
if (args.length > 0) { switch (args[0].toLowerCase()) {
|
||||
case "create":
|
||||
@ -32,7 +39,7 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
|
||||
String posX = config.getConfig().getString(args[1].toLowerCase() + ".pos.X");
|
||||
if (posX == null) {
|
||||
sender.sendMessage(PluginMessages.customPrefix + " You have created a new destination called \u00A7e" + args[1] + "!");
|
||||
Player player = sender.getServer().getPlayer(sender.getName());
|
||||
Player player = (Player) sender;
|
||||
Destination.create(player.getLocation(), args[1]);
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " A destination by that name already exists!");
|
||||
@ -64,9 +71,9 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
|
||||
break;
|
||||
case "list":
|
||||
String message = PluginMessages.customPrefix + " \u00A77Destinations \u00A7c:\u00A7a";
|
||||
List<Object> destiObj = Arrays.asList(config.getConfig().getKeys(false).toArray());
|
||||
Object[] destiObj = config.getConfig().getKeys(false).toArray();
|
||||
LinkedList<String> destis = new LinkedList<>();
|
||||
for (Object object : destiObj.toArray()) {
|
||||
for (Object object : destiObj) {
|
||||
destis.add(object.toString());
|
||||
}
|
||||
Collections.sort(destis);
|
||||
@ -83,6 +90,10 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
|
||||
sender.sendMessage("\u00A7e\u00A7m----------------------------");
|
||||
break;
|
||||
case "warp":
|
||||
if (!(sender.hasPermission("advancedportals.warp.*") || sender.hasPermission("advancedportals.warp." + args[1]))) {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " You don't have permission to warp to " + args[1] + "!");
|
||||
return true;
|
||||
}
|
||||
if(args.length >= 2){
|
||||
Destination.warp((Player) sender, args[1]);
|
||||
}
|
||||
@ -111,13 +122,12 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
|
||||
autoComplete.add(string);
|
||||
}
|
||||
}
|
||||
if (sender.hasPermission("advancedportals.desti") | sender.hasPermission("AdvancedPortals.CreatePortal")) {
|
||||
if (args.length == 1) {
|
||||
if (args.length == 1) {
|
||||
if (sender.hasPermission("advancedportals.desti") | sender.hasPermission("advancedportals.createportal")) {
|
||||
autoComplete.addAll(Arrays.asList("create", "remove", "help"));
|
||||
} else if (args[0].toLowerCase().equals("create")) {
|
||||
}
|
||||
autoComplete.add("warp");
|
||||
}
|
||||
autoComplete.add("warp");
|
||||
Collections.sort(autoComplete);
|
||||
for (Object result : autoComplete.toArray()) {
|
||||
if (!result.toString().startsWith(args[args.length - 1])) {
|
@ -0,0 +1,5 @@
|
||||
package com.sekwah.advancedportals.bukkit.destinations;
|
||||
|
||||
public class PortalWarp {
|
||||
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
package com.sekwah.advancedportals.effects;
|
||||
package com.sekwah.advancedportals.bukkit.effects;
|
||||
|
||||
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
@ -21,14 +23,14 @@ public class WarpEffects {
|
||||
|
||||
plugin = pluginTemp;
|
||||
|
||||
sounds[0] = findSound(plugin, "ENTITY_ENDERMEN_TELEPORT", "ENDERMAN_TELEPORT");
|
||||
//sounds[0] = findSound(plugin, "ENTITY_ENDERMEN_TELEPORT", "ENDERMAN_TELEPORT");
|
||||
sounds[0] = Sound.ENTITY_ENDERMAN_TELEPORT;
|
||||
|
||||
// SPIGOT STOP CHANGING THE BLOODY NAMES! we already knew what an explosion was...
|
||||
sounds[1] = findSound(plugin, "ENTITY_GENERIC_EXPLODE", "EXPLODE");
|
||||
sounds[1] = Sound.ENTITY_GENERIC_EXPLODE;
|
||||
|
||||
}
|
||||
|
||||
public Sound findSound(AdvancedPortalsPlugin plugin, String newName, String oldName){
|
||||
public static Sound findSound(AdvancedPortalsPlugin plugin, String newName, String oldName){
|
||||
Sound soundFound = null;
|
||||
try{
|
||||
soundFound = Sound.valueOf(newName);
|
||||
@ -45,11 +47,11 @@ public class WarpEffects {
|
||||
return soundFound;
|
||||
}
|
||||
|
||||
public static void activateParticles(Player player) {
|
||||
public static void activateEffect(Player player) {
|
||||
Location loc = player.getLocation();
|
||||
World world = player.getWorld();
|
||||
switch (plugin.getSettings().getCurrentWarpParticles()){
|
||||
case 1:
|
||||
case 1:
|
||||
for(int i = 0; i < 10; i++){
|
||||
world.playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
}
|
||||
@ -59,7 +61,22 @@ public class WarpEffects {
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void activateParticle(Player player, String particle_name) {
|
||||
Particle particle = Portal.getParticle(particle_name);
|
||||
if(particle == null) {
|
||||
plugin.getLogger().warning("wrong particle name: " + particle_name);
|
||||
return;
|
||||
}
|
||||
|
||||
Location loc_from = player.getLocation();
|
||||
|
||||
World world = player.getWorld();
|
||||
|
||||
world.spawnParticle(particle, loc_from, 100, 1, 1, 1);
|
||||
|
||||
}
|
||||
|
||||
public static void activateSound(Player player) {
|
@ -0,0 +1,32 @@
|
||||
package com.sekwah.advancedportals.bukkit.injector;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.reflection.ReflectionHelper;
|
||||
import io.netty.channel.Channel;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class PacketInjector {
|
||||
|
||||
private Method getPlayerHandle;
|
||||
private Field playerConnection;
|
||||
private Field networkManager;
|
||||
private Field networkChannel;
|
||||
|
||||
public PacketInjector(AdvancedPortalsPlugin plugin, String bukkitImpl) {
|
||||
String craftBukkitPackage = "org.bukkit.craftbukkit." + bukkitImpl + ".";
|
||||
String minecraftPackage = "net.minecraft.server." + bukkitImpl + ".";
|
||||
|
||||
try {
|
||||
getPlayerHandle = Class.forName(craftBukkitPackage + "entity.CraftPlayer").getMethod("getHandle");
|
||||
playerConnection = Class.forName(minecraftPackage + "EntityPlayer").getField("playerConnection");
|
||||
networkManager = Class.forName(minecraftPackage + "PlayerConnection").getField("networkManager");
|
||||
networkChannel = ReflectionHelper.getFieldByType(Class.forName(minecraftPackage + "NetworkManager"), Channel.class, true);
|
||||
|
||||
} catch (NoSuchMethodException | ClassNotFoundException | NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,19 +1,12 @@
|
||||
package com.sekwah.advancedportals.listeners;
|
||||
package com.sekwah.advancedportals.bukkit.listeners;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
/**
|
||||
* Created by on 29/03/2016.
|
||||
*
|
||||
* @author sekwah41
|
||||
*/
|
||||
public class BungeeListener implements PluginMessageListener {
|
||||
|
||||
private AdvancedPortalsPlugin plugin;
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
public BungeeListener(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -24,12 +17,8 @@ public class BungeeListener implements PluginMessageListener {
|
||||
if (!channel.equals("BungeeCord")) {
|
||||
return;
|
||||
}
|
||||
ByteArrayDataInput in = ByteStreams.newDataInput(message);
|
||||
String subchannel = in.readUTF();
|
||||
if (subchannel.equals("AdvancedPortals")) {
|
||||
// Any data after this is read like the packets used in the naruto mod
|
||||
// (same order as sent)
|
||||
}
|
||||
|
||||
// some codes
|
||||
}
|
||||
|
||||
/**
|
@ -1,10 +1,8 @@
|
||||
package com.sekwah.advancedportals.listeners;
|
||||
package com.sekwah.advancedportals.bukkit.listeners;
|
||||
|
||||
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.portals.AdvancedPortal;
|
||||
import com.sekwah.advancedportals.portals.Portal;
|
||||
import org.bukkit.block.Block;
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -12,7 +10,6 @@ import org.bukkit.event.block.BlockFromToEvent;
|
||||
|
||||
public class FlowStopper implements Listener {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
// The needed config values will be stored so they are easier to access later
|
@ -0,0 +1,399 @@
|
||||
package com.sekwah.advancedportals.bukkit.listeners;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.PluginMessages;
|
||||
import com.sekwah.advancedportals.bukkit.api.events.WarpEvent;
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.bukkit.destinations.Destination;
|
||||
import com.sekwah.advancedportals.bukkit.portals.AdvancedPortal;
|
||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Orientable;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityPortalEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Listeners implements Listener {
|
||||
|
||||
private static boolean UseOnlyServerAxe = false;
|
||||
private static Material WandMaterial;
|
||||
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
public static String HAS_WARPED = "hasWarped";
|
||||
public static String LAVA_WARPED = "lavaWarped";
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public Listeners(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
UseOnlyServerAxe = config.getConfig().getBoolean("UseOnlyServerMadeAxe");
|
||||
|
||||
String ItemID = config.getConfig().getString("AxeItemId");
|
||||
|
||||
if (ItemID == null) {
|
||||
WandMaterial = Material.IRON_AXE;
|
||||
} else {
|
||||
WandMaterial = Material.getMaterial(ItemID);
|
||||
}
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
|
||||
int cleanPeriod = config.getConfig().getInt("CleanUpPeriod", 120);
|
||||
int period = 20 * 60 * cleanPeriod;
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new CooldownDataRemovalTask(), period, period);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void reloadValues(AdvancedPortalsPlugin plugin) {
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
UseOnlyServerAxe = config.getConfig().getBoolean("UseOnlyServerMadeAxe");
|
||||
|
||||
String ItemID = config.getConfig().getString("AxeItemId");
|
||||
|
||||
WandMaterial = Material.getMaterial(ItemID);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void spawnMobEvent(CreatureSpawnEvent event) {
|
||||
if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.NETHER_PORTAL
|
||||
&& Portal.inPortalRegion(event.getLocation(), Portal.getPortalProtectionRadius())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldChangeEvent(PlayerChangedWorldEvent event) {
|
||||
Portal.joinCooldown.put(event.getPlayer().getName(), System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLeaveEvent(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player.hasMetadata("leaveDesti")) {
|
||||
Destination.warp(player, player.getMetadata("leaveDesti").get(0).asString(),
|
||||
false, true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoinEvent(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
Portal.joinCooldown.put(player.getName(), System.currentTimeMillis());
|
||||
|
||||
Location loc = player.getLocation();
|
||||
Location eyeLoc = player.getEyeLocation();
|
||||
UUID uuid = player.getUniqueId();
|
||||
for (AdvancedPortal portal : Portal.portals) {
|
||||
if (!portal.inPortal.contains(uuid)
|
||||
&& (Portal.locationInPortalTrigger(portal, loc) || Portal.locationInPortalTrigger(portal, eyeLoc))) {
|
||||
portal.inPortal.add(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, String> playerMap = plugin.getPlayerDestiMap();
|
||||
|
||||
if (playerMap.containsKey(uuid.toString())) {
|
||||
Destination.warp(player, playerMap.get(uuid.toString()), false, true);
|
||||
playerMap.remove(uuid.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onMoveEvent(PlayerMoveEvent event) {
|
||||
// will check if the player is in the portal or not.
|
||||
if (!Portal.portalsActive || event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
checkTriggerLocations(player, false, event.getTo(), player.getEyeLocation());
|
||||
|
||||
}
|
||||
|
||||
public void checkTriggerLocations(Player player, boolean useDelayed, Location... locations) {
|
||||
for (AdvancedPortal portal : Portal.portals) {
|
||||
boolean delayed = portal.isDelayed();
|
||||
if (delayed == useDelayed) {
|
||||
for (Location loc : locations) {
|
||||
if (delayed ? Portal.locationInPortal(portal, loc, 1)
|
||||
: Portal.locationInPortalTrigger(portal, loc)) {
|
||||
|
||||
player.setMetadata(HAS_WARPED, new FixedMetadataValue(plugin, true));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new RemoveWarpData(player), 10);
|
||||
if (portal.getTriggers().contains(Material.LAVA)) {
|
||||
player.setMetadata(LAVA_WARPED, new FixedMetadataValue(plugin, true));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new RemoveLavaData(player), 10);
|
||||
}
|
||||
if (portal.inPortal.contains(player.getUniqueId()))
|
||||
return;
|
||||
WarpEvent warpEvent = new WarpEvent(player, portal);
|
||||
plugin.getServer().getPluginManager().callEvent(warpEvent);
|
||||
|
||||
if (!warpEvent.isCancelled())
|
||||
Portal.activate(player, portal);
|
||||
|
||||
if (!delayed)
|
||||
portal.inPortal.add(player.getUniqueId());
|
||||
return;
|
||||
}
|
||||
}
|
||||
portal.inPortal.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CooldownDataRemovalTask implements Runnable {
|
||||
|
||||
private int removed;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
boolean canRemove = true;
|
||||
while (canRemove) {
|
||||
canRemove = Portal.cooldown.entrySet().removeIf(e -> {
|
||||
HashMap<String, Long> cds = e.getValue();
|
||||
if (cds == null) {
|
||||
removed++;
|
||||
return true;
|
||||
} else {
|
||||
cds.entrySet().removeIf(entry -> shouldRemovePortalCooldown(entry));
|
||||
if (cds.isEmpty()) {
|
||||
removed++;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
// Make sure maps are never too big than they need to be
|
||||
if (removed > 16) {
|
||||
resizeMaps();
|
||||
removed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldRemovePortalCooldown(Map.Entry<String, Long> entry) {
|
||||
String portalName = entry.getKey();
|
||||
AdvancedPortal portal = Portal.getPortal(portalName);
|
||||
if (portal != null) {
|
||||
long portalCD = entry.getValue();
|
||||
int diff = (int) ((System.currentTimeMillis() - portalCD) / 1000);
|
||||
int portalCooldown = -1;
|
||||
try {
|
||||
portalCooldown = Integer.parseInt(portal.getArg("cooldowndelay"));
|
||||
return diff >= portalCooldown; // cooldown expired
|
||||
} catch (Exception exc) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void resizeMaps() {
|
||||
HashMap<String, HashMap<String, Long>> newCooldowns = new HashMap<String, HashMap<String, Long>>(Math.max(Portal.cooldown.size() * 2, 10));
|
||||
newCooldowns.putAll(Portal.cooldown);
|
||||
Portal.cooldown = newCooldowns;
|
||||
|
||||
HashMap<String, Long> newJoinCooldowns = new HashMap<String, Long>(Math.max(Portal.joinCooldown.size() * 2, 10));
|
||||
newJoinCooldowns.putAll(Portal.joinCooldown);
|
||||
Portal.joinCooldown = newJoinCooldowns;
|
||||
}
|
||||
}
|
||||
|
||||
// These are here because java 7 can only take finals straight into a runnable
|
||||
class RemoveLavaData implements Runnable {
|
||||
|
||||
private final Player player;
|
||||
|
||||
public RemoveLavaData(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
player.removeMetadata(LAVA_WARPED, plugin);
|
||||
player.setFireTicks(0);
|
||||
}
|
||||
}
|
||||
|
||||
class RemoveWarpData implements Runnable {
|
||||
|
||||
private final Player player;
|
||||
|
||||
public RemoveWarpData(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (player != null && player.isOnline()) {
|
||||
player.removeMetadata(HAS_WARPED, plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onCombustEntityEvent(EntityCombustEvent event) {
|
||||
if (event.getEntity() instanceof Player && Portal.inPortalTriggerRegion(event.getEntity().getLocation()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onDamEvent(EntityDamageEvent event) {
|
||||
if (event.getEntity() instanceof Player && (event.getCause() == EntityDamageEvent.DamageCause.LAVA
|
||||
|| event.getCause() == EntityDamageEvent.DamageCause.FIRE
|
||||
|| event.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK)) {
|
||||
if (event.getEntity().hasMetadata(LAVA_WARPED)
|
||||
| Portal.inPortalTriggerRegion(event.getEntity().getLocation()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPortalEvent(PlayerPortalEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!player.hasMetadata(HAS_WARPED)) {
|
||||
Location loc = event.getFrom();
|
||||
Location eyeLoc = new Location(loc.getWorld(), loc.getX(), loc.getY() + player.getEyeHeight(), loc.getZ());
|
||||
|
||||
checkTriggerLocations(player, true, loc, eyeLoc);
|
||||
}
|
||||
|
||||
if (player.hasMetadata(HAS_WARPED) | Portal.inPortalRegion(event.getFrom(), 1))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onEntityPortalEvent(EntityPortalEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
if(Portal.locationInPortal(event.getFrom(), 2)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onItemInteract(PlayerInteractEvent event) {
|
||||
|
||||
// will detect if the player is using an axe so the points of a portal can be
|
||||
// set
|
||||
// also any other detections such as sign interaction or basic block protection
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (player.hasMetadata("selectingPortal")
|
||||
&& (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
|
||||
for (AdvancedPortal portal : Portal.portals) {
|
||||
if (Portal.locationInPortal(portal, event.getClickedBlock().getLocation(), 0)) {
|
||||
player.sendMessage(
|
||||
PluginMessages.customPrefix + "\u00A7a You have selected: \u00A7e" + portal.getName());
|
||||
player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, portal.getName())); // adds the
|
||||
// name to
|
||||
// the
|
||||
// metadata
|
||||
// of the
|
||||
// character
|
||||
event.setCancelled(true);
|
||||
player.removeMetadata("selectingPortal", plugin);
|
||||
return;
|
||||
}
|
||||
}
|
||||
player.sendMessage(PluginMessages.customPrefixFail
|
||||
+ "\u00A7c No portal was selected. If you would like to stop selecting please type \u00A7e/portal select \u00A7cagain!");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.hasPermission("advancedportals.createportal")) {
|
||||
if (!plugin.getSettings().enabledWorldEditIntegration()
|
||||
&& event.getItem() != null && event.getItem().getType() == WandMaterial // was type id
|
||||
&& (!UseOnlyServerAxe || (checkItemForName(event.getItem()) && event.getItem().getItemMeta()
|
||||
.getDisplayName().equals("\u00A7ePortal Region Selector")))) {
|
||||
|
||||
// This checks if the action was a left or right click and if it was directly
|
||||
// effecting a block.
|
||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
Location blockloc = event.getClickedBlock().getLocation();
|
||||
// stores the selection as metadata on the character so then it isn't saved
|
||||
// anywhere, if the player logs out it will
|
||||
// have to be selected again if the player joins, also it does not affect any
|
||||
// other players.
|
||||
player.setMetadata("Pos1X", new FixedMetadataValue(plugin, blockloc.getBlockX()));
|
||||
player.setMetadata("Pos1Y", new FixedMetadataValue(plugin, blockloc.getBlockY()));
|
||||
player.setMetadata("Pos1Z", new FixedMetadataValue(plugin, blockloc.getBlockZ()));
|
||||
player.setMetadata("Pos1World", new FixedMetadataValue(plugin, blockloc.getWorld().getName()));
|
||||
player.sendMessage(
|
||||
"\u00A7eYou have selected pos1! X:" + blockloc.getBlockX() + " Y:" + blockloc.getBlockY()
|
||||
+ " Z:" + blockloc.getBlockZ() + " World: " + blockloc.getWorld().getName());
|
||||
|
||||
// Stops the event so the block is not damaged
|
||||
event.setCancelled(true);
|
||||
|
||||
// Returns the event so no more code is executed(stops unnecessary code being
|
||||
// executed)
|
||||
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
Location blockloc = event.getClickedBlock().getLocation();
|
||||
player.setMetadata("Pos2X", new FixedMetadataValue(plugin, blockloc.getBlockX()));
|
||||
player.setMetadata("Pos2Y", new FixedMetadataValue(plugin, blockloc.getBlockY()));
|
||||
player.setMetadata("Pos2Z", new FixedMetadataValue(plugin, blockloc.getBlockZ()));
|
||||
player.setMetadata("Pos2World", new FixedMetadataValue(plugin, blockloc.getWorld().getName()));
|
||||
player.sendMessage(
|
||||
"\u00A7eYou have selected pos2! X:" + blockloc.getBlockX() + " Y:" + blockloc.getBlockY()
|
||||
+ " Z:" + blockloc.getBlockZ() + " World: " + blockloc.getWorld().getName());
|
||||
|
||||
// Stops the event so the block is not interacted with
|
||||
event.setCancelled(true);
|
||||
|
||||
// Returns the event so no more code is executed(stops unnecessary code being
|
||||
// executed)
|
||||
}
|
||||
} else if (checkItemForName(event.getItem())
|
||||
&& event.getItem().getItemMeta().getDisplayName().equals("\u00A75Portal Block Placer")
|
||||
&& event.getAction() == Action.LEFT_CLICK_BLOCK
|
||||
&& event.getClickedBlock().getType() == Material.NETHER_PORTAL) {
|
||||
BlockData block = event.getClickedBlock().getBlockData();
|
||||
|
||||
if (block instanceof Orientable) {
|
||||
Orientable rotatable = (Orientable) block;
|
||||
if (rotatable.getAxis() == Axis.X) {
|
||||
rotatable.setAxis(Axis.Z);
|
||||
} else {
|
||||
rotatable.setAxis(Axis.X);
|
||||
}
|
||||
event.getClickedBlock().setBlockData(rotatable);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean checkItemForName(ItemStack item) {
|
||||
return item != null && item.hasItemMeta() && item.getItemMeta().hasDisplayName();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package com.sekwah.advancedportals.bukkit.listeners;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigHelper;
|
||||
import com.sekwah.advancedportals.bukkit.destinations.Destination;
|
||||
import com.sekwah.advancedportals.bungee.BungeeMessages;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PluginMessageReceiver implements PluginMessageListener {
|
||||
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
private final int teleportDelay;
|
||||
|
||||
public PluginMessageReceiver(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
teleportDelay = config.getConfig().getInt(ConfigHelper.PROXY_TELEPORT_DELAY, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
||||
|
||||
if (!channel.equals(BungeeMessages.CHANNEL_NAME)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ByteArrayDataInput in = ByteStreams.newDataInput(message);
|
||||
String subchannel = in.readUTF();
|
||||
|
||||
if (subchannel.equals(BungeeMessages.SERVER_DESTI)) {
|
||||
String targetDestination = in.readUTF();
|
||||
String bungeeUUID = in.readUTF();
|
||||
|
||||
Player targetPlayer = this.plugin.getServer().getPlayer(UUID.fromString(bungeeUUID));
|
||||
|
||||
if(teleportDelay <= 0) {
|
||||
teleportPlayerToDesti(targetPlayer, targetDestination, bungeeUUID);
|
||||
} else {
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () ->
|
||||
teleportPlayerToDesti(targetPlayer, targetDestination, bungeeUUID),
|
||||
20L * teleportDelay
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void teleportPlayerToDesti(Player player, String desti, String bungeeUUID) {
|
||||
if (player != null) {
|
||||
Destination.warp(player, desti, false, true);
|
||||
|
||||
}
|
||||
else {
|
||||
plugin.getPlayerDestiMap().put(bungeeUUID, desti);
|
||||
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () ->
|
||||
plugin.getPlayerDestiMap().remove(bungeeUUID),
|
||||
20L * 10
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Example forward packet.
|
||||
*
|
||||
* Construct like the forge packets.
|
||||
*
|
||||
* out.writeUTF("Forward"); // So BungeeCord knows to forward it
|
||||
out.writeUTF("ALL");
|
||||
out.writeUTF("MyChannel"); // The channel name to check if this your data
|
||||
|
||||
ByteArrayOutputStream msgbytes = new ByteArrayOutputStream();
|
||||
DataOutputStream msgout = new DataOutputStream(msgbytes);
|
||||
msgout.writeUTF("Some kind of data here"); // You can do anything you want with msgout
|
||||
msgout.writeShort(123);
|
||||
|
||||
out.writeShort(msgbytes.toByteArray().length);
|
||||
out.write(msgbytes.toByteArray());
|
||||
*
|
||||
*/
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package com.sekwah.advancedportals.bukkit.listeners;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.EndGateway;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
|
||||
public class PortalPlacer implements Listener {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
private final boolean DISABLE_GATEWAY_BEAM;
|
||||
|
||||
public PortalPlacer(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
boolean portalPlace = config.getConfig().getBoolean("CanBuildPortalBlock");
|
||||
|
||||
this.DISABLE_GATEWAY_BEAM = config.getConfig().getBoolean("DisableGatewayBeam", true);
|
||||
|
||||
|
||||
if (portalPlace) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if(event.getPlayer().hasPermission("advancedportals.build") && event.getItemInHand() != null &&
|
||||
event.getItemInHand().hasItemMeta()){
|
||||
String name = event.getItemInHand().getItemMeta().getDisplayName();
|
||||
|
||||
if(name == null) return;
|
||||
|
||||
if (name.equals("\u00A75Portal Block Placer")){
|
||||
event.getBlock().setType(Material.NETHER_PORTAL);
|
||||
} else if (name.equals("\u00A78End Portal Block Placer")){
|
||||
event.getBlockPlaced().setType(Material.END_PORTAL);
|
||||
}
|
||||
else if (name.equals("\u00A78Gateway Block Placer")){
|
||||
Block block = event.getBlockPlaced();
|
||||
|
||||
block.setType(Material.END_GATEWAY);
|
||||
if(this.DISABLE_GATEWAY_BEAM) {
|
||||
EndGateway tileState = (EndGateway) block.getState();
|
||||
tileState.setAge(Long.MIN_VALUE);
|
||||
tileState.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChunkLoad(ChunkLoadEvent event) {
|
||||
if(!this.DISABLE_GATEWAY_BEAM) {
|
||||
return;
|
||||
}
|
||||
BlockState[] tileEntities = event.getChunk().getTileEntities();
|
||||
for(BlockState block : tileEntities) {
|
||||
if(block.getType() == Material.END_GATEWAY) {
|
||||
if(Portal.inPortalRegion(block.getLocation(), 5)) {
|
||||
EndGateway tileState = (EndGateway) block;
|
||||
tileState.setAge(Long.MIN_VALUE);
|
||||
tileState.update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||
Block block = event.getBlock();
|
||||
Block newBlock = block.getWorld().getBlockAt(block.getLocation());
|
||||
Material material = block.getType();
|
||||
if (material == Material.NETHER_PORTAL && Portal.inPortalRegion(block.getLocation(), Portal.getPortalProtectionRadius()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
@ -1,10 +1,11 @@
|
||||
package com.sekwah.advancedportals.listeners;
|
||||
package com.sekwah.advancedportals.bukkit.listeners;
|
||||
|
||||
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.portals.AdvancedPortal;
|
||||
import com.sekwah.advancedportals.portals.Portal;
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.PluginMessages;
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -14,6 +15,7 @@ import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class PortalProtect implements Listener {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ -23,7 +25,7 @@ public class PortalProtect implements Listener {
|
||||
// an example is in the interact event in this if statement if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("<EFBFBD>eP...
|
||||
private boolean PortalProtect = true;
|
||||
|
||||
private int PortalProtectionRadius = 5;
|
||||
private int PortalProtectionArea = 5;
|
||||
|
||||
public PortalProtect(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -31,7 +33,7 @@ public class PortalProtect implements Listener {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
this.PortalProtect = config.getConfig().getBoolean("PortalProtection");
|
||||
|
||||
this.PortalProtectionRadius = config.getConfig().getInt("PortalProtectionRadius");
|
||||
this.PortalProtectionArea = config.getConfig().getInt("PortalProtectionArea", 5);
|
||||
|
||||
if (PortalProtect) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
@ -40,25 +42,36 @@ public class PortalProtect implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if (!event.getPlayer().hasPermission("advancedportals.build")
|
||||
&& Portal.inPortalRegion(event.getBlock().getLocation(), PortalProtectionRadius))
|
||||
if(!this.PortalProtect) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (!player.hasPermission("advancedportals.build")
|
||||
&& Portal.inPortalRegion(event.getBlock().getLocation(), PortalProtectionArea)) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " You don't have permission to build here!");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (!event.getPlayer().hasPermission("advancedportals.build")
|
||||
&& Portal.inPortalRegion(event.getBlock().getLocation(), PortalProtectionRadius))
|
||||
if(!this.PortalProtect) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (PortalProtect && !player.hasPermission("advancedportals.build")
|
||||
&& Portal.inPortalRegion(event.getBlock().getLocation(), PortalProtectionArea)) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(PluginMessages.customPrefixFail + " You don't have permission to build here!");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onExplosion(EntityExplodeEvent event) {
|
||||
if(!this.PortalProtect) return;
|
||||
|
||||
List<Block> blockList = event.blockList();
|
||||
for (int i = 0; i < blockList.size(); i++) {
|
||||
Block block = blockList.get(i);
|
||||
if (Portal.inPortalRegion(block.getLocation(), PortalProtectionRadius)) {
|
||||
if (Portal.inPortalRegion(block.getLocation(), PortalProtectionArea)) {
|
||||
blockList.remove(i);
|
||||
i--;
|
||||
}
|
@ -0,0 +1,718 @@
|
||||
package com.sekwah.advancedportals.bukkit.metrics;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
/**
|
||||
* bStats collects some data for plugin authors.
|
||||
* <p>
|
||||
* Check out https://bStats.org/ to learn more about bStats!
|
||||
*/
|
||||
@SuppressWarnings({"WeakerAccess", "unused"})
|
||||
public class Metrics {
|
||||
|
||||
static {
|
||||
// You can use the property to disable the check in your test environment
|
||||
if (System.getProperty("bstats.relocatecheck") == null || !System.getProperty("bstats.relocatecheck").equals("false")) {
|
||||
// Maven's Relocate is clever and changes strings, too. So we have to use this little "trick" ... :D
|
||||
final String defaultPackage = new String(
|
||||
new byte[]{'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's', '.', 'b', 'u', 'k', 'k', 'i', 't'});
|
||||
final String examplePackage = new String(new byte[]{'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'});
|
||||
// We want to make sure nobody just copy & pastes the example and use the wrong package names
|
||||
if (Metrics.class.getPackage().getName().equals(defaultPackage) || Metrics.class.getPackage().getName().equals(examplePackage)) {
|
||||
throw new IllegalStateException("bStats Metrics class has not been relocated correctly!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The version of this bStats class
|
||||
public static final int B_STATS_VERSION = 1;
|
||||
|
||||
// The url to which the data is sent
|
||||
private static final String URL = "https://bStats.org/submitData/bukkit";
|
||||
|
||||
// Is bStats enabled on this server?
|
||||
private final boolean enabled;
|
||||
|
||||
// Should failed requests be logged?
|
||||
private static boolean logFailedRequests;
|
||||
|
||||
// Should the sent data be logged?
|
||||
private static boolean logSentData;
|
||||
|
||||
// Should the response text be logged?
|
||||
private static boolean logResponseStatusText;
|
||||
|
||||
// The uuid of the server
|
||||
private static String serverUUID;
|
||||
|
||||
// The plugin
|
||||
private final Plugin plugin;
|
||||
|
||||
// A list with all custom charts
|
||||
private final List<CustomChart> charts = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param plugin The plugin which stats should be submitted.
|
||||
*/
|
||||
public Metrics(Plugin plugin) {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null!");
|
||||
}
|
||||
this.plugin = plugin;
|
||||
|
||||
// Get the config file
|
||||
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
|
||||
File configFile = new File(bStatsFolder, "config.yml");
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
// Check if the config file exists
|
||||
if (!config.isSet("serverUuid")) {
|
||||
|
||||
// Add default values
|
||||
config.addDefault("enabled", true);
|
||||
// Every server gets it's unique random id.
|
||||
config.addDefault("serverUuid", UUID.randomUUID().toString());
|
||||
// Should failed request be logged?
|
||||
config.addDefault("logFailedRequests", false);
|
||||
// Should the sent data be logged?
|
||||
config.addDefault("logSentData", false);
|
||||
// Should the response text be logged?
|
||||
config.addDefault("logResponseStatusText", false);
|
||||
|
||||
// Inform the server owners about bStats
|
||||
config.options().header(
|
||||
"bStats collects some data for plugin authors like how many servers are using their plugins.\n" +
|
||||
"To honor their work, you should not disable it.\n" +
|
||||
"This has nearly no effect on the server performance!\n" +
|
||||
"Check out https://bStats.org/ to learn more :)"
|
||||
).copyDefaults(true);
|
||||
try {
|
||||
config.save(configFile);
|
||||
} catch (IOException ignored) { }
|
||||
}
|
||||
|
||||
// Load the data
|
||||
enabled = config.getBoolean("enabled", true);
|
||||
serverUUID = config.getString("serverUuid");
|
||||
logFailedRequests = config.getBoolean("logFailedRequests", false);
|
||||
logSentData = config.getBoolean("logSentData", false);
|
||||
logResponseStatusText = config.getBoolean("logResponseStatusText", false);
|
||||
|
||||
if (enabled) {
|
||||
boolean found = false;
|
||||
// Search for all other bStats Metrics classes to see if we are the first one
|
||||
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
|
||||
try {
|
||||
service.getField("B_STATS_VERSION"); // Our identifier :)
|
||||
found = true; // We aren't the first
|
||||
break;
|
||||
} catch (NoSuchFieldException ignored) { }
|
||||
}
|
||||
// Register our service
|
||||
Bukkit.getServicesManager().register(Metrics.class, this, plugin, ServicePriority.Normal);
|
||||
if (!found) {
|
||||
// We are the first!
|
||||
startSubmitting();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if bStats is enabled.
|
||||
*
|
||||
* @return Whether bStats is enabled or not.
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a custom chart.
|
||||
*
|
||||
* @param chart The chart to add.
|
||||
*/
|
||||
public void addCustomChart(CustomChart chart) {
|
||||
if (chart == null) {
|
||||
throw new IllegalArgumentException("Chart cannot be null!");
|
||||
}
|
||||
charts.add(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the Scheduler which submits our data every 30 minutes.
|
||||
*/
|
||||
private void startSubmitting() {
|
||||
final Timer timer = new Timer(true); // We use a timer cause the Bukkit scheduler is affected by server lags
|
||||
timer.scheduleAtFixedRate(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!plugin.isEnabled()) { // Plugin was disabled
|
||||
timer.cancel();
|
||||
return;
|
||||
}
|
||||
// Nevertheless we want our code to run in the Bukkit main thread, so we have to use the Bukkit scheduler
|
||||
// Don't be afraid! The connection to the bStats server is still async, only the stats collection is sync ;)
|
||||
Bukkit.getScheduler().runTask(plugin, () -> submitData());
|
||||
}
|
||||
}, 1000 * 60 * 5, 1000 * 60 * 30);
|
||||
// Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough time to start
|
||||
// WARNING: Changing the frequency has no effect but your plugin WILL be blocked/deleted!
|
||||
// WARNING: Just don't do it!
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the plugin specific data.
|
||||
* This method is called using Reflection.
|
||||
*
|
||||
* @return The plugin specific data.
|
||||
*/
|
||||
public JsonObject getPluginData() {
|
||||
JsonObject data = new JsonObject();
|
||||
|
||||
String pluginName = plugin.getDescription().getName();
|
||||
String pluginVersion = plugin.getDescription().getVersion();
|
||||
|
||||
data.addProperty("pluginName", pluginName); // Append the name of the plugin
|
||||
data.addProperty("pluginVersion", pluginVersion); // Append the version of the plugin
|
||||
JsonArray customCharts = new JsonArray();
|
||||
for (CustomChart customChart : charts) {
|
||||
// Add the data of the custom charts
|
||||
JsonObject chart = customChart.getRequestJsonObject();
|
||||
if (chart == null) { // If the chart is null, we skip it
|
||||
continue;
|
||||
}
|
||||
customCharts.add(chart);
|
||||
}
|
||||
data.add("customCharts", customCharts);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the server specific data.
|
||||
*
|
||||
* @return The server specific data.
|
||||
*/
|
||||
private JsonObject getServerData() {
|
||||
// Minecraft specific data
|
||||
int playerAmount;
|
||||
try {
|
||||
// Around MC 1.8 the return type was changed to a collection from an array,
|
||||
// This fixes java.lang.NoSuchMethodError: org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection;
|
||||
Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers");
|
||||
playerAmount = onlinePlayersMethod.getReturnType().equals(Collection.class)
|
||||
? ((Collection<?>) onlinePlayersMethod.invoke(Bukkit.getServer())).size()
|
||||
: ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length;
|
||||
} catch (Exception e) {
|
||||
playerAmount = Bukkit.getOnlinePlayers().size(); // Just use the new method if the Reflection failed
|
||||
}
|
||||
int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
|
||||
String bukkitVersion = Bukkit.getVersion();
|
||||
String bukkitName = Bukkit.getName();
|
||||
|
||||
// OS/Java specific data
|
||||
String javaVersion = System.getProperty("java.version");
|
||||
String osName = System.getProperty("os.name");
|
||||
String osArch = System.getProperty("os.arch");
|
||||
String osVersion = System.getProperty("os.version");
|
||||
int coreCount = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
JsonObject data = new JsonObject();
|
||||
|
||||
data.addProperty("serverUUID", serverUUID);
|
||||
|
||||
data.addProperty("playerAmount", playerAmount);
|
||||
data.addProperty("onlineMode", onlineMode);
|
||||
data.addProperty("bukkitVersion", bukkitVersion);
|
||||
data.addProperty("bukkitName", bukkitName);
|
||||
|
||||
data.addProperty("javaVersion", javaVersion);
|
||||
data.addProperty("osName", osName);
|
||||
data.addProperty("osArch", osArch);
|
||||
data.addProperty("osVersion", osVersion);
|
||||
data.addProperty("coreCount", coreCount);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects the data and sends it afterwards.
|
||||
*/
|
||||
private void submitData() {
|
||||
final JsonObject data = getServerData();
|
||||
|
||||
JsonArray pluginData = new JsonArray();
|
||||
// Search for all other bStats Metrics classes to get their plugin data
|
||||
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
|
||||
try {
|
||||
service.getField("B_STATS_VERSION"); // Our identifier :)
|
||||
|
||||
for (RegisteredServiceProvider<?> provider : Bukkit.getServicesManager().getRegistrations(service)) {
|
||||
try {
|
||||
Object plugin = provider.getService().getMethod("getPluginData").invoke(provider.getProvider());
|
||||
if (plugin instanceof JsonObject) {
|
||||
pluginData.add((JsonObject) plugin);
|
||||
} else { // old bstats version compatibility
|
||||
try {
|
||||
Class<?> jsonObjectJsonSimple = Class.forName("org.json.simple.JSONObject");
|
||||
if (plugin.getClass().isAssignableFrom(jsonObjectJsonSimple)) {
|
||||
Method jsonStringGetter = jsonObjectJsonSimple.getDeclaredMethod("toJSONString");
|
||||
jsonStringGetter.setAccessible(true);
|
||||
String jsonString = (String) jsonStringGetter.invoke(plugin);
|
||||
JsonObject object = new JsonParser().parse(jsonString).getAsJsonObject();
|
||||
pluginData.add(object);
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
// minecraft version 1.14+
|
||||
if (logFailedRequests) {
|
||||
this.plugin.getLogger().log(Level.SEVERE, "Encountered unexpected exception", e);
|
||||
}
|
||||
continue; // continue looping since we cannot do any other thing.
|
||||
}
|
||||
}
|
||||
} catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { }
|
||||
}
|
||||
} catch (NoSuchFieldException ignored) { }
|
||||
}
|
||||
|
||||
data.add("plugins", pluginData);
|
||||
|
||||
// Create a new thread for the connection to the bStats server
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
// Send the data
|
||||
sendData(plugin, data);
|
||||
} catch (Exception e) {
|
||||
// Something went wrong! :(
|
||||
if (logFailedRequests) {
|
||||
plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the data to the bStats server.
|
||||
*
|
||||
* @param plugin Any plugin. It's just used to get a logger instance.
|
||||
* @param data The data to send.
|
||||
* @throws Exception If the request failed.
|
||||
*/
|
||||
private static void sendData(Plugin plugin, JsonObject data) throws Exception {
|
||||
if (data == null) {
|
||||
throw new IllegalArgumentException("Data cannot be null!");
|
||||
}
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
throw new IllegalAccessException("This method must not be called from the main thread!");
|
||||
}
|
||||
if (logSentData) {
|
||||
plugin.getLogger().info("Sending data to bStats: " + data.toString());
|
||||
}
|
||||
HttpsURLConnection connection = (HttpsURLConnection) new URL(URL).openConnection();
|
||||
|
||||
// Compress the data to save bandwidth
|
||||
byte[] compressedData = compress(data.toString());
|
||||
|
||||
// Add headers
|
||||
connection.setRequestMethod("POST");
|
||||
connection.addRequestProperty("Accept", "application/json");
|
||||
connection.addRequestProperty("Connection", "close");
|
||||
connection.addRequestProperty("Content-Encoding", "gzip"); // We gzip our request
|
||||
connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length));
|
||||
connection.setRequestProperty("Content-Type", "application/json"); // We send our data in JSON format
|
||||
connection.setRequestProperty("User-Agent", "MC-Server/" + B_STATS_VERSION);
|
||||
|
||||
// Send data
|
||||
connection.setDoOutput(true);
|
||||
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
|
||||
outputStream.write(compressedData);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
|
||||
InputStream inputStream = connection.getInputStream();
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
builder.append(line);
|
||||
}
|
||||
bufferedReader.close();
|
||||
if (logResponseStatusText) {
|
||||
plugin.getLogger().info("Sent data to bStats and received response: " + builder.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gzips the given String.
|
||||
*
|
||||
* @param str The string to gzip.
|
||||
* @return The gzipped String.
|
||||
* @throws IOException If the compression failed.
|
||||
*/
|
||||
private static byte[] compress(final String str) throws IOException {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
GZIPOutputStream gzip = new GZIPOutputStream(outputStream);
|
||||
gzip.write(str.getBytes(StandardCharsets.UTF_8));
|
||||
gzip.close();
|
||||
return outputStream.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom chart.
|
||||
*/
|
||||
public static abstract class CustomChart {
|
||||
|
||||
// The id of the chart
|
||||
final String chartId;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
*/
|
||||
CustomChart(String chartId) {
|
||||
if (chartId == null || chartId.isEmpty()) {
|
||||
throw new IllegalArgumentException("ChartId cannot be null or empty!");
|
||||
}
|
||||
this.chartId = chartId;
|
||||
}
|
||||
|
||||
private JsonObject getRequestJsonObject() {
|
||||
JsonObject chart = new JsonObject();
|
||||
chart.addProperty("chartId", chartId);
|
||||
try {
|
||||
JsonObject data = getChartData();
|
||||
if (data == null) {
|
||||
// If the data is null we don't send the chart.
|
||||
return null;
|
||||
}
|
||||
chart.add("data", data);
|
||||
} catch (Throwable t) {
|
||||
if (logFailedRequests) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return chart;
|
||||
}
|
||||
|
||||
protected abstract JsonObject getChartData() throws Exception;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom simple pie.
|
||||
*/
|
||||
public static class SimplePie extends CustomChart {
|
||||
|
||||
private final Callable<String> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public SimplePie(String chartId, Callable<String> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
String value = callable.call();
|
||||
if (value == null || value.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.addProperty("value", value);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom advanced pie.
|
||||
*/
|
||||
public static class AdvancedPie extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Integer>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public AdvancedPie(String chartId, Callable<Map<String, Integer>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, Integer> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
if (entry.getValue() == 0) {
|
||||
continue; // Skip this invalid
|
||||
}
|
||||
allSkipped = false;
|
||||
values.addProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom drilldown pie.
|
||||
*/
|
||||
public static class DrilldownPie extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Map<String, Integer>>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public DrilldownPie(String chartId, Callable<Map<String, Map<String, Integer>>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, Map<String, Integer>> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean reallyAllSkipped = true;
|
||||
for (Map.Entry<String, Map<String, Integer>> entryValues : map.entrySet()) {
|
||||
JsonObject value = new JsonObject();
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, Integer> valueEntry : map.get(entryValues.getKey()).entrySet()) {
|
||||
value.addProperty(valueEntry.getKey(), valueEntry.getValue());
|
||||
allSkipped = false;
|
||||
}
|
||||
if (!allSkipped) {
|
||||
reallyAllSkipped = false;
|
||||
values.add(entryValues.getKey(), value);
|
||||
}
|
||||
}
|
||||
if (reallyAllSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom single line chart.
|
||||
*/
|
||||
public static class SingleLineChart extends CustomChart {
|
||||
|
||||
private final Callable<Integer> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public SingleLineChart(String chartId, Callable<Integer> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
int value = callable.call();
|
||||
if (value == 0) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.addProperty("value", value);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom multi line chart.
|
||||
*/
|
||||
public static class MultiLineChart extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Integer>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public MultiLineChart(String chartId, Callable<Map<String, Integer>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, Integer> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
if (entry.getValue() == 0) {
|
||||
continue; // Skip this invalid
|
||||
}
|
||||
allSkipped = false;
|
||||
values.addProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom simple bar chart.
|
||||
*/
|
||||
public static class SimpleBarChart extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Integer>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public SimpleBarChart(String chartId, Callable<Map<String, Integer>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, Integer> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
JsonArray categoryValues = new JsonArray();
|
||||
categoryValues.add(entry.getValue());
|
||||
values.add(entry.getKey(), categoryValues);
|
||||
}
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom advanced bar chart.
|
||||
*/
|
||||
public static class AdvancedBarChart extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, int[]>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public AdvancedBarChart(String chartId, Callable<Map<String, int[]>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, int[]> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, int[]> entry : map.entrySet()) {
|
||||
if (entry.getValue().length == 0) {
|
||||
continue; // Skip this invalid
|
||||
}
|
||||
allSkipped = false;
|
||||
JsonArray categoryValues = new JsonArray();
|
||||
for (int categoryValue : entry.getValue()) {
|
||||
categoryValues.add(categoryValue);
|
||||
}
|
||||
values.add(entry.getKey(), categoryValues);
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
package com.sekwah.advancedportals.bukkit.portals;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.api.portaldata.PortalArg;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AdvancedPortal {
|
||||
|
||||
private Set<Material> triggers = null;
|
||||
|
||||
private String worldName = null;
|
||||
|
||||
private Location pos1 = null;
|
||||
|
||||
private Location pos2 = null;
|
||||
|
||||
private String portalName = null;
|
||||
|
||||
// TODO store destinations also as variables like portals
|
||||
private String destiation = null; // Could possibly store the destination name to stop the server having to read the config file
|
||||
|
||||
private String bungee = null; // Could possibly store the bungee server name to stop the server having to read the config file
|
||||
|
||||
// Bungee will be stored inside the destination.
|
||||
|
||||
private PortalArg[] portalArgs = null;
|
||||
|
||||
public HashSet<UUID> inPortal = new HashSet<UUID>();
|
||||
|
||||
// TODO think of relaying out the data input to a more logical format.
|
||||
public AdvancedPortal(String portalName, Material trigger, String destination, Location pos1, Location pos2, PortalArg... portalArgs) {
|
||||
this(portalName, trigger, pos1, pos2, pos2.getWorld().getName(), portalArgs);
|
||||
this.destiation = destination;
|
||||
}
|
||||
|
||||
public AdvancedPortal(String portalName, Material trigger, Location pos1, Location pos2, PortalArg... portalArgs) {
|
||||
this(portalName, trigger, pos1, pos2, pos2.getWorld().getName(), portalArgs);
|
||||
}
|
||||
|
||||
public AdvancedPortal(String portalName, Material trigger, String destination, Location pos1, Location pos2, String worldName, PortalArg... portalArgs) {
|
||||
this(portalName, trigger, pos1, pos2, worldName, portalArgs);
|
||||
this.destiation = destination;
|
||||
}
|
||||
|
||||
public AdvancedPortal(String portalName, Material trigger, Location pos1, Location pos2, String worldName, PortalArg... portalArgs) {
|
||||
this(portalName, new HashSet<>(Collections.singletonList(trigger)), pos1, pos2, worldName, portalArgs);
|
||||
}
|
||||
|
||||
public AdvancedPortal(String portalName, Set<Material> triggers, Location pos1, Location pos2, String worldName, PortalArg... portalArgs) {
|
||||
this.portalName = portalName;
|
||||
this.triggers = triggers;
|
||||
this.pos1 = pos1;
|
||||
this.pos2 = pos2;
|
||||
this.worldName = worldName;
|
||||
this.portalArgs = portalArgs;
|
||||
}
|
||||
|
||||
public String getArg(String arg) {
|
||||
for (PortalArg portalArg : this.portalArgs) {
|
||||
if (arg.equals(portalArg.argName)) {
|
||||
return portalArg.value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public PortalArg[] getArgs(){
|
||||
return this.portalArgs;
|
||||
}
|
||||
|
||||
public boolean hasArg(String arg) {
|
||||
return this.getArg(arg) != null;
|
||||
}
|
||||
|
||||
public Set<Material> getTriggers() {
|
||||
return this.triggers;
|
||||
}
|
||||
|
||||
public String getWorldName() {
|
||||
return this.worldName;
|
||||
}
|
||||
|
||||
public Location getPos1() {
|
||||
return this.pos1;
|
||||
}
|
||||
|
||||
public Location getPos2() {
|
||||
return this.pos2;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.portalName;
|
||||
}
|
||||
|
||||
public String getDestiation() {
|
||||
return this.destiation;
|
||||
}
|
||||
|
||||
public void setDestiation(String destiation) {
|
||||
this.destiation = destiation;
|
||||
}
|
||||
|
||||
public String getBungee() {
|
||||
return this.bungee;
|
||||
}
|
||||
|
||||
public void setBungee(String bungee) {
|
||||
this.bungee = bungee;
|
||||
}
|
||||
|
||||
public boolean isDelayed() {
|
||||
return this.hasArg("delayed") && this.getArg("delayed").equalsIgnoreCase("true");
|
||||
}
|
||||
}
|
@ -0,0 +1,741 @@
|
||||
package com.sekwah.advancedportals.bukkit.portals;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bukkit.PluginMessages;
|
||||
import com.sekwah.advancedportals.bukkit.api.portaldata.PortalArg;
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.bukkit.config.ConfigHelper;
|
||||
import com.sekwah.advancedportals.bukkit.destinations.Destination;
|
||||
import com.sekwah.advancedportals.bukkit.effects.WarpEffects;
|
||||
import com.sekwah.advancedportals.bungee.BungeeMessages;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Portal {
|
||||
|
||||
public static HashMap<String, Long> joinCooldown = new HashMap<String, Long>();
|
||||
public static HashMap<String, HashMap<String, Long>> cooldown = new HashMap<String, HashMap<String, Long>>();
|
||||
// Config values
|
||||
public static boolean portalsActive = false;
|
||||
public static AdvancedPortal[] portals = new AdvancedPortal[0];
|
||||
private static AdvancedPortalsPlugin plugin;
|
||||
public static ConfigAccessor portalData = new ConfigAccessor(plugin, "portals.yml");
|
||||
private static boolean showBungeeMessage;
|
||||
private static double throwback;
|
||||
private static Sound portalSound;
|
||||
private static int portalProtectionRadius;
|
||||
private static boolean blockSpectatorMode;
|
||||
private static int joinCooldownDelay;
|
||||
private static boolean commandLog;
|
||||
private static final Random random = new Random();
|
||||
|
||||
public static void init(AdvancedPortalsPlugin plugin) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
showBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage", false);
|
||||
|
||||
portalProtectionRadius = config.getConfig().getBoolean("PortalProtection") ?
|
||||
config.getConfig().getInt("PortalProtectionArea") : 0;
|
||||
|
||||
throwback = config.getConfig().getDouble("ThrowbackAmount", 0.7);
|
||||
|
||||
portalSound = WarpEffects.findSound(plugin, "BLOCK_PORTAL_TRAVEL", "PORTAL_TRAVEL");
|
||||
blockSpectatorMode = config.getConfig().getBoolean("BlockSpectatorMode", false);
|
||||
|
||||
joinCooldownDelay = config.getConfig().getInt("PortalCooldown", 5);
|
||||
|
||||
commandLog = config.getConfig().getBoolean(ConfigHelper.COMMAND_LOGS, true);
|
||||
|
||||
Portal.plugin = plugin;
|
||||
Portal.loadPortals();
|
||||
}
|
||||
|
||||
/**
|
||||
* This can be used to move the get keys to different sections
|
||||
* <p>
|
||||
* ConfigurationSection section = portalData.getSection("sectionname");
|
||||
* <p>
|
||||
* section.getKeys(false);
|
||||
*/
|
||||
|
||||
public static void loadPortals() {
|
||||
portalData = new ConfigAccessor(plugin, "portals.yml");
|
||||
Set<String> PortalSet = portalData.getConfig().getKeys(false);
|
||||
if (PortalSet.size() > 0) {
|
||||
portals = new AdvancedPortal[PortalSet.toArray().length];
|
||||
|
||||
/*
|
||||
* for(int i = 0; i <= PortalSet.toArray().length - 1; i++){ portals[i] = new
|
||||
* AdvancedPortal(); }
|
||||
*/
|
||||
|
||||
int portalId = 0;
|
||||
for (Object portal : PortalSet.toArray()) {
|
||||
|
||||
ConfigurationSection portalConfigSection = portalData.getConfig()
|
||||
.getConfigurationSection(portal.toString());
|
||||
|
||||
String blockTypesRaw = portalConfigSection.getString("triggerblock");
|
||||
|
||||
String[] blockTypesString = blockTypesRaw != null ? blockTypesRaw.split(",") : null;
|
||||
|
||||
HashSet<Material> blockTypes = getMaterialSet(blockTypesString);
|
||||
|
||||
if (blockTypes.isEmpty()) {
|
||||
blockTypes.add(Material.NETHER_PORTAL);
|
||||
}
|
||||
|
||||
ConfigurationSection portalArgsConf = portalConfigSection.getConfigurationSection("portalArgs");
|
||||
|
||||
ArrayList<PortalArg> extraData = new ArrayList<>();
|
||||
|
||||
if (portalArgsConf != null) {
|
||||
Set<String> argsSet = portalArgsConf.getKeys(true);
|
||||
|
||||
for (Object argName : argsSet.toArray()) {
|
||||
if (portalArgsConf.isString(argName.toString())) {
|
||||
extraData.add(
|
||||
new PortalArg(argName.toString(), portalArgsConf.getString(argName.toString())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String worldName = portalData.getConfig().getString(portal.toString() + ".world");
|
||||
if (worldName != null) {
|
||||
World world = Bukkit.getWorld(worldName);
|
||||
Location pos1 = new Location(world, portalData.getConfig().getInt(portal.toString() + ".pos1.X"),
|
||||
portalData.getConfig().getInt(portal.toString() + ".pos1.Y"),
|
||||
portalData.getConfig().getInt(portal.toString() + ".pos1.Z"));
|
||||
Location pos2 = new Location(world, portalData.getConfig().getInt(portal.toString() + ".pos2.X"),
|
||||
portalData.getConfig().getInt(portal.toString() + ".pos2.Y"),
|
||||
portalData.getConfig().getInt(portal.toString() + ".pos2.Z"));
|
||||
|
||||
PortalArg[] portalArgs = new PortalArg[extraData.size()];
|
||||
extraData.toArray(portalArgs);
|
||||
|
||||
portals[portalId] = new AdvancedPortal(portal.toString(), blockTypes, pos1, pos2, worldName,
|
||||
portalArgs);
|
||||
|
||||
portals[portalId].setBungee(portalConfigSection.getString("bungee"));
|
||||
|
||||
portals[portalId].setDestiation(portalConfigSection.getString("destination"));
|
||||
|
||||
portalId++;
|
||||
} else {
|
||||
AdvancedPortal[] tempPortals = portals;
|
||||
|
||||
portals = new AdvancedPortal[portals.length - 1];
|
||||
|
||||
System.arraycopy(tempPortals, 0, portals, 0, portalId);
|
||||
}
|
||||
}
|
||||
portalsActive = true;
|
||||
} else {
|
||||
portalsActive = false;
|
||||
portals = new AdvancedPortal[0];
|
||||
}
|
||||
}
|
||||
|
||||
public static HashSet<Material> getMaterialSet(String[] blockTypesString) {
|
||||
HashSet<Material> blockTypes = new HashSet<>();
|
||||
|
||||
if (blockTypesString != null) {
|
||||
for (String blockType : blockTypesString) {
|
||||
Material material = Material.getMaterial(blockType);
|
||||
if (material != null) {
|
||||
blockTypes.add(material);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return blockTypes;
|
||||
}
|
||||
|
||||
public static Particle getParticle(String name) {
|
||||
try {
|
||||
return Particle.valueOf(name.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String create(Location pos1, Location pos2, String name, String destination,
|
||||
Set<Material> triggerBlocks, PortalArg... extraData) {
|
||||
return create(pos1, pos2, name, destination, triggerBlocks, null, extraData);
|
||||
}
|
||||
|
||||
public static String create(Location pos1, Location pos2, String name, String destination,
|
||||
Set<Material> triggerBlocks, String serverName, PortalArg... portalArgs) {
|
||||
|
||||
if (!pos1.getWorld().equals(pos2.getWorld())) {
|
||||
plugin.getLogger().log(Level.WARNING, "pos1 and pos2 must be in the same world!");
|
||||
return "\u00A7cPortal creation error, pos1 and pos2 must be in the same world!";
|
||||
}
|
||||
|
||||
int LowX = 0;
|
||||
int LowY = 0;
|
||||
int LowZ = 0;
|
||||
|
||||
int HighX = 0;
|
||||
int HighY = 0;
|
||||
int HighZ = 0;
|
||||
|
||||
if (pos1.getX() > pos2.getX()) {
|
||||
LowX = (int) pos2.getX();
|
||||
HighX = (int) pos1.getX();
|
||||
} else {
|
||||
LowX = (int) pos1.getX();
|
||||
HighX = (int) pos2.getX();
|
||||
}
|
||||
if (pos1.getY() > pos2.getY()) {
|
||||
LowY = (int) pos2.getY();
|
||||
HighY = (int) pos1.getY();
|
||||
} else {
|
||||
LowY = (int) pos1.getY();
|
||||
HighY = (int) pos2.getY();
|
||||
}
|
||||
if (pos1.getZ() > pos2.getZ()) {
|
||||
LowZ = (int) pos2.getZ();
|
||||
HighZ = (int) pos1.getZ();
|
||||
} else {
|
||||
LowZ = (int) pos1.getZ();
|
||||
HighZ = (int) pos2.getZ();
|
||||
}
|
||||
|
||||
Location checkpos1 = new Location(pos1.getWorld(), HighX, HighY, HighZ);
|
||||
Location checkpos2 = new Location(pos2.getWorld(), LowX, LowY, LowZ);
|
||||
|
||||
/*
|
||||
* if (checkPortalOverlap(checkpos1, checkpos2)) {
|
||||
* plugin.getLogger().log(Level.WARNING, "portals must not overlap!"); return
|
||||
* "\u00A7cPortal creation error, portals must not overlap!"; }
|
||||
*/
|
||||
|
||||
portalData.getConfig().set(name + ".world", pos1.getWorld().getName());
|
||||
|
||||
String store = triggerBlocks.stream().map(Enum::name).collect(Collectors.joining(","));
|
||||
portalData.getConfig().set(name + ".triggerblock", store);
|
||||
|
||||
portalData.getConfig().set(name + ".destination", destination);
|
||||
|
||||
portalData.getConfig().set(name + ".bungee", serverName);
|
||||
|
||||
portalData.getConfig().set(name + ".pos1.X", HighX);
|
||||
portalData.getConfig().set(name + ".pos1.Y", HighY);
|
||||
portalData.getConfig().set(name + ".pos1.Z", HighZ);
|
||||
|
||||
portalData.getConfig().set(name + ".pos2.X", LowX);
|
||||
portalData.getConfig().set(name + ".pos2.Y", LowY);
|
||||
portalData.getConfig().set(name + ".pos2.Z", LowZ);
|
||||
|
||||
for (PortalArg arg : portalArgs) {
|
||||
portalData.getConfig().set(name + ".portalArgs." + arg.argName, arg.value);
|
||||
}
|
||||
|
||||
portalData.saveConfig();
|
||||
|
||||
loadPortals();
|
||||
|
||||
return "\u00A7aPortal creation successful!";
|
||||
}
|
||||
|
||||
private static boolean checkPortalOverlap(Location pos1, Location pos2) {
|
||||
|
||||
if (portalsActive) {
|
||||
int portalId = 0;
|
||||
for (@SuppressWarnings("unused")
|
||||
Object portal : Portal.portals) {
|
||||
if (portals[portalId].getWorldName().equals(pos2.getWorld().getName())) { // checks that the cubes arnt
|
||||
// overlapping by seeing if
|
||||
// all 4 corners are not in
|
||||
// side another
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].getPos1().getBlockX(),
|
||||
portals[portalId].getPos1().getBlockY(), portals[portalId].getPos1().getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].getPos1().getBlockX(),
|
||||
portals[portalId].getPos1().getBlockY(), portals[portalId].getPos2().getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].getPos1().getBlockX(),
|
||||
portals[portalId].getPos2().getBlockY(), portals[portalId].getPos1().getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].getPos2().getBlockX(),
|
||||
portals[portalId].getPos1().getBlockY(), portals[portalId].getPos1().getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].getPos2().getBlockX(),
|
||||
portals[portalId].getPos2().getBlockY(), portals[portalId].getPos2().getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].getPos2().getBlockX(),
|
||||
portals[portalId].getPos1().getBlockY(), portals[portalId].getPos2().getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].getPos1().getBlockX(),
|
||||
portals[portalId].getPos2().getBlockY(), portals[portalId].getPos2().getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkOverLapPortal(pos1, pos2, portals[portalId].getPos2().getBlockX(),
|
||||
portals[portalId].getPos2().getBlockY(), portals[portalId].getPos1().getBlockZ())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
portalId++;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean checkOverLapPortal(Location pos1, Location pos2, int posX, int posY, int posZ) {
|
||||
if (pos1.getX() >= posX && pos1.getY() >= posX && pos1.getZ() >= posZ) {
|
||||
return (pos2.getX()) <= posX && pos2.getY() <= posY && pos2.getZ() <= posZ;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String create(Location pos1, Location pos2, String name, String destination, String serverName,
|
||||
PortalArg... extraData) { // add stuff for destination names or coordinates
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
|
||||
Material triggerBlockType;
|
||||
String BlockID = config.getConfig().getString("DefaultPortalTriggerBlock");
|
||||
triggerBlockType = Material.getMaterial(BlockID);
|
||||
|
||||
if (triggerBlockType == null) {
|
||||
triggerBlockType = Material.NETHER_PORTAL;
|
||||
}
|
||||
|
||||
return create(pos1, pos2, name, destination, new HashSet<>(Collections.singletonList(triggerBlockType)),
|
||||
serverName, extraData);
|
||||
}
|
||||
|
||||
public static void redefine(Location pos1, Location pos2, String name) {
|
||||
|
||||
portalData.getConfig().set(name + ".pos1.X", pos1.getX());
|
||||
portalData.getConfig().set(name + ".pos1.Y", pos1.getY());
|
||||
portalData.getConfig().set(name + ".pos1.Z", pos1.getZ());
|
||||
|
||||
portalData.getConfig().set(name + ".pos2.X", pos2.getX());
|
||||
portalData.getConfig().set(name + ".pos2.Y", pos2.getY());
|
||||
portalData.getConfig().set(name + ".pos2.Z", pos2.getZ());
|
||||
|
||||
portalData.saveConfig();
|
||||
|
||||
loadPortals();
|
||||
|
||||
}
|
||||
|
||||
public static String getDestination(String portalName) {
|
||||
return portalData.getConfig().getString(portalName + ".destination");
|
||||
}
|
||||
|
||||
public static void remove(String name) {
|
||||
|
||||
Object[] keys = portalData.getConfig().getKeys(true).toArray();
|
||||
for (int i = keys.length - 1; i >= 0; i--) {
|
||||
String key = keys[i].toString();
|
||||
if (key.startsWith(name + ".")) {
|
||||
portalData.getConfig().set(key, null);
|
||||
}
|
||||
}
|
||||
portalData.getConfig().set(name, null);
|
||||
|
||||
// TODO add code to check if people have the portal selected and notify if
|
||||
// removed.
|
||||
|
||||
/**
|
||||
* Set<String> keys = portalData.getConfig().getKeys(true); for(String key:
|
||||
* keys){ if(key.startsWith(name)){ portalData.getConfig().set(key, null); } }
|
||||
*/
|
||||
|
||||
/**
|
||||
* portalData.getConfig().set(name + ".world", null);
|
||||
* portalData.getConfig().set(name + ".triggerblock", null);
|
||||
* portalData.getConfig().set(name + ".destination", null);
|
||||
*
|
||||
* portalData.getConfig().set(name + ".pos1.X", null);
|
||||
* portalData.getConfig().set(name + ".pos1.Y", null);
|
||||
* portalData.getConfig().set(name + ".pos1.Z", null);
|
||||
*
|
||||
* portalData.getConfig().set(name + ".pos2.X", null);
|
||||
* portalData.getConfig().set(name + ".pos2.Y", null);
|
||||
* portalData.getConfig().set(name + ".pos2.Z", null);
|
||||
*
|
||||
* portalData.getConfig().set(name + ".pos1", null);
|
||||
* portalData.getConfig().set(name + ".getPos2()", null);
|
||||
*
|
||||
* portalData.getConfig().set(name, null);
|
||||
*/
|
||||
|
||||
portalData.saveConfig();
|
||||
|
||||
loadPortals();
|
||||
}
|
||||
|
||||
public static AdvancedPortal getPortal(String portalName) {
|
||||
for (AdvancedPortal portalElement : Portal.portals) {
|
||||
if (portalElement.getName().equals(portalName)) {
|
||||
return portalElement;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean portalExists(String portalName) {
|
||||
|
||||
String posX = portalData.getConfig().getString(portalName + ".pos1.X");
|
||||
|
||||
return posX != null;
|
||||
}
|
||||
|
||||
public static boolean activate(Player player, String portalName) {
|
||||
for (AdvancedPortal portal : Portal.portals) {
|
||||
if (portal.getName().equals(portalName))
|
||||
return activate(player, portal);
|
||||
}
|
||||
plugin.getLogger().log(Level.SEVERE, "Portal not found by name of: " + portalName);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean activate(Player player, AdvancedPortal portal, boolean doKnockback) {
|
||||
|
||||
if (blockSpectatorMode && player.getGameMode() == GameMode.SPECTATOR) {
|
||||
player.sendMessage(
|
||||
PluginMessages.customPrefixFail + "\u00A7c You cannot enter a portal in spectator mode!");
|
||||
return false;
|
||||
}
|
||||
|
||||
String permission = portal.getArg("permission");
|
||||
|
||||
boolean invertPermission = false;
|
||||
if(permission != null) {
|
||||
invertPermission = permission.startsWith("!");
|
||||
if (invertPermission) {
|
||||
permission.substring(1);
|
||||
}
|
||||
}
|
||||
|
||||
boolean noMessage = permission != null && permission.startsWith("nomsg.");
|
||||
if(noMessage) {
|
||||
permission.substring(6);
|
||||
}
|
||||
|
||||
if (!(permission == null || ((!invertPermission && player.hasPermission(permission)) || (invertPermission && !player.hasPermission(permission))) || player.isOp())) {
|
||||
if(!noMessage) {
|
||||
player.sendMessage(
|
||||
PluginMessages.customPrefixFail + "\u00A7c You do not have permission to use this portal!");
|
||||
failSound(player, portal);
|
||||
if(doKnockback)
|
||||
throwPlayerBack(player);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Long joinCD = joinCooldown.get(player.getName());
|
||||
if (joinCD != null) {
|
||||
int diff = (int) ((System.currentTimeMillis() - joinCD) / 1000);
|
||||
if (diff < joinCooldownDelay) {
|
||||
int time = (joinCooldownDelay - diff);
|
||||
player.sendMessage(ChatColor.RED + "There is " + ChatColor.YELLOW + time + ChatColor.RED + (time == 1 ? " second" : " seconds") + " join cooldown protection left.");
|
||||
failSound(player, portal);
|
||||
if(doKnockback)
|
||||
throwPlayerBack(player);
|
||||
return false;
|
||||
}
|
||||
joinCooldown.remove(player.getName());
|
||||
}
|
||||
|
||||
HashMap<String, Long> cds = cooldown.get(player.getName());
|
||||
if (cds != null) {
|
||||
if (cds.get(portal.getName()) != null) {
|
||||
long portalCD = cds.get(portal.getName());
|
||||
int diff = (int) ((System.currentTimeMillis() - portalCD) / 1000);
|
||||
int portalCooldown = 0; // default cooldowndelay when cooldowndelay is not specified
|
||||
try {
|
||||
portalCooldown = Integer.parseInt(portal.getArg("cooldowndelay"));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
if (diff < portalCooldown) {
|
||||
int time = (portalCooldown - diff);
|
||||
player.sendMessage(ChatColor.RED + "Please wait " + ChatColor.YELLOW + time + ChatColor.RED
|
||||
+ (time == 1 ? " second" : " seconds") + " until attempting to enter this portal again.");
|
||||
failSound(player, portal);
|
||||
if(doKnockback)
|
||||
throwPlayerBack(player);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cds == null) {
|
||||
cds = new HashMap<String, Long>();
|
||||
}
|
||||
cds.put(portal.getName(), System.currentTimeMillis());
|
||||
cooldown.put(player.getName(), cds);
|
||||
|
||||
boolean showFailMessage = !portal.hasArg("command.1");
|
||||
|
||||
boolean hasMessage = portal.getArg("message") != null;
|
||||
|
||||
// plugin.getLogger().info(portal.getName() + ":" + portal.getDestiation());
|
||||
boolean warped = false;
|
||||
if (portal.getBungee() != null) {
|
||||
String[] bungeeServers = portal.getBungee().split(",");
|
||||
String bungeeServer = bungeeServers[random.nextInt(bungeeServers.length)];
|
||||
if (showBungeeMessage) {
|
||||
player.sendMessage(PluginMessages.customPrefix + "\u00A7a Attempting to warp to \u00A7e" + bungeeServer
|
||||
+ "\u00A7a.");
|
||||
}
|
||||
|
||||
if(portal.hasArg("leavedesti")) {
|
||||
player.setMetadata("leaveDesti", new FixedMetadataValue(plugin, portal.getArg("leavedesti")));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
|
||||
player.removeMetadata("leaveDesti", plugin);
|
||||
}, 20 * 10);
|
||||
}
|
||||
|
||||
if (portal.getDestiation() != null) {
|
||||
if(plugin.isProxyPluginEnabled()) {
|
||||
ByteArrayDataOutput outForList = ByteStreams.newDataOutput();
|
||||
outForList.writeUTF(BungeeMessages.ENTER_PORTAL);
|
||||
outForList.writeUTF(bungeeServer);
|
||||
outForList.writeUTF(portal.getDestiation());
|
||||
outForList.writeUTF(player.getUniqueId().toString());
|
||||
|
||||
player.sendPluginMessage(plugin, BungeeMessages.CHANNEL_NAME, outForList.toByteArray());
|
||||
}
|
||||
else {
|
||||
plugin.getLogger().log(Level.WARNING, "You do not have bungee setup correctly. Cross server destinations won't work.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ByteArrayDataOutput outForSend = ByteStreams.newDataOutput();
|
||||
outForSend.writeUTF("Connect");
|
||||
outForSend.writeUTF(bungeeServer);
|
||||
|
||||
|
||||
|
||||
portal.inPortal.add(player.getUniqueId());
|
||||
player.sendPluginMessage(plugin, "BungeeCord", outForSend.toByteArray());
|
||||
// Down to bungee to sort out the teleporting but yea theoretically they should
|
||||
// warp.
|
||||
} else if (portal.getDestiation() != null) {
|
||||
ConfigAccessor configDesti = new ConfigAccessor(plugin, "destinations.yml");
|
||||
if (configDesti.getConfig().getString(portal.getDestiation() + ".world") != null) {
|
||||
warped = Destination.warp(player, portal.getDestiation(), portal, hasMessage, false);
|
||||
if (!warped) {
|
||||
if(doKnockback)
|
||||
throwPlayerBack(player);
|
||||
}
|
||||
}
|
||||
} else if (showFailMessage) {
|
||||
player.sendMessage(PluginMessages.customPrefixFail
|
||||
+ "\u00A7c The portal you are trying to use doesn't have a destination!");
|
||||
plugin.getLogger().log(Level.SEVERE, "The portal '" + portal.getName() + "' has just had a warp "
|
||||
+ "attempt and either the data is corrupt or portal doesn't exist!");
|
||||
if(doKnockback)
|
||||
throwPlayerBack(player);
|
||||
failSound(player, portal);
|
||||
}
|
||||
|
||||
if (portal.hasArg("command.1")) {
|
||||
warped = true;
|
||||
int commandLine = 1;
|
||||
String command = portal.getArg("command." + commandLine);// portalData.getConfig().getString(portal.getName()+
|
||||
// ".portalArgs.command." + commandLine);
|
||||
do {
|
||||
// (?i) makes the search case insensitive
|
||||
command = command.replaceAll("@player", player.getName());
|
||||
if(commandLog) plugin.getLogger().log(Level.INFO, "Portal command: " + command);
|
||||
if (command.startsWith("#") && plugin.getSettings().enabledCommandLevel("c")) {
|
||||
command = command.substring(1);
|
||||
try {
|
||||
plugin.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().warning("Error while executing: " + command);
|
||||
}
|
||||
} else if (command.startsWith("!") && plugin.getSettings().enabledCommandLevel("o")) {
|
||||
command = command.substring(1);
|
||||
boolean wasOp = player.isOp();
|
||||
if(!wasOp) {
|
||||
try {
|
||||
player.setOp(true);
|
||||
player.chat("/" + command);
|
||||
} finally {
|
||||
player.setOp(false);
|
||||
}
|
||||
} else {
|
||||
player.chat("/" + command);
|
||||
}
|
||||
} else if (command.startsWith("^") && plugin.getSettings().enabledCommandLevel("p")) {
|
||||
command = command.substring(1);
|
||||
PermissionAttachment permissionAttachment = null;
|
||||
try {
|
||||
permissionAttachment = player.addAttachment(plugin, "*", true);
|
||||
player.chat("/" + command);
|
||||
// player.performCommand(command);
|
||||
} finally {
|
||||
player.removeAttachment(permissionAttachment);
|
||||
}
|
||||
} else if (command.startsWith("%") && plugin.getSettings().enabledCommandLevel("b")) {
|
||||
if(plugin.isProxyPluginEnabled()) {
|
||||
command = command.substring(1);
|
||||
ByteArrayDataOutput outForList = ByteStreams.newDataOutput();
|
||||
outForList.writeUTF(BungeeMessages.BUNGEE_COMMAND);
|
||||
outForList.writeUTF(command);
|
||||
player.sendPluginMessage(plugin, BungeeMessages.CHANNEL_NAME, outForList.toByteArray());
|
||||
}
|
||||
else {
|
||||
plugin.getLogger().log(Level.WARNING, "You do not have bungee setup correctly. For security advanced bungee features won't work.");
|
||||
}
|
||||
|
||||
} else {
|
||||
player.chat("/" + command);
|
||||
// player.performCommand(command);
|
||||
}
|
||||
command = portal.getArg("command." + ++commandLine);
|
||||
} while (command != null);
|
||||
}
|
||||
|
||||
if (warped) {
|
||||
if (hasMessage) {
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR,
|
||||
TextComponent.fromLegacyText(portal.getArg("message").replaceAll("&(?=[0-9a-fk-or])", "\u00A7")));
|
||||
}
|
||||
}
|
||||
|
||||
return warped;
|
||||
}
|
||||
|
||||
private static void failSound(Player player, AdvancedPortal portal) {
|
||||
if (!(portal.getTriggers().contains(Material.NETHER_PORTAL) && player.getGameMode() == GameMode.CREATIVE)) {
|
||||
player.playSound(player.getLocation(), portalSound, 0.2f, new Random().nextFloat() * 0.4F + 0.8F);
|
||||
}
|
||||
}
|
||||
|
||||
public static void rename(String oldName, String newName) {
|
||||
|
||||
// set it so it gets all data from one and puts it into another place
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "portals.yml");
|
||||
|
||||
Set<String> keys = config.getConfig().getKeys(true);
|
||||
for (String key : keys) {
|
||||
if (key.startsWith(oldName + ".")) {
|
||||
if (config.getConfig().getString(key) != null) {
|
||||
try {
|
||||
int intData = Integer.parseInt(config.getConfig().getString(key));
|
||||
config.getConfig().set(key.replace(oldName + ".", newName + "."), intData);
|
||||
} catch (Exception e) {
|
||||
config.getConfig().set(key.replace(oldName + ".", newName + "."),
|
||||
config.getConfig().getString(key));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
config.saveConfig();
|
||||
|
||||
remove(oldName);
|
||||
|
||||
}
|
||||
|
||||
public static boolean addCommand(String portalName, String portalCommand) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "portals.yml");
|
||||
if (portalExists(portalName)) {
|
||||
int commandLine = 0;
|
||||
while (config.getConfig().getString(portalName + ".portalArgs.command." + ++commandLine) != null)
|
||||
; // Loops increasing commandLine till 1 is null
|
||||
config.getConfig().set(portalName + ".portalArgs.command." + commandLine, portalCommand);
|
||||
config.saveConfig();
|
||||
loadPortals();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean inPortalTriggerRegion(Location loc) {
|
||||
for (AdvancedPortal portal : Portal.portals)
|
||||
if (Portal.locationInPortalTrigger(portal, loc))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean locationInPortalTrigger(AdvancedPortal portal, Location loc, int additionalArea) {
|
||||
return portal.getTriggers().contains(loc.getBlock().getType()) && locationInPortal(portal, loc, additionalArea);
|
||||
}
|
||||
|
||||
public static boolean locationInPortalTrigger(AdvancedPortal portal, Location loc) {
|
||||
return locationInPortalTrigger(portal, loc, 0);
|
||||
}
|
||||
|
||||
public static boolean inPortalRegion(Location loc, int additionalArea) {
|
||||
for (AdvancedPortal portal : Portal.portals)
|
||||
if (Portal.locationInPortal(portal, loc, additionalArea))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean locationInPortal(Location loc, int additionalArea) {
|
||||
for (AdvancedPortal portal : Portal.portals)
|
||||
if (Portal.locationInPortal(portal, loc, additionalArea))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean locationInPortal(AdvancedPortal portal, Location loc) {
|
||||
return locationInPortal(portal, loc);
|
||||
}
|
||||
|
||||
public static boolean locationInPortal(AdvancedPortal portal, Location loc, int additionalArea) {
|
||||
if (!portalsActive)
|
||||
return false;
|
||||
if (loc.getWorld() != null && portal.getWorldName().equals(loc.getWorld().getName()))
|
||||
if ((portal.getPos1().getX() + 1 + additionalArea) >= loc.getX()
|
||||
&& (portal.getPos1().getY() + 1 + additionalArea) > loc.getY()
|
||||
&& (portal.getPos1().getZ() + 1 + additionalArea) >= loc.getZ())
|
||||
return portal.getPos2().getX() - additionalArea <= loc.getX()
|
||||
&& portal.getPos2().getY() - additionalArea <= loc.getY()
|
||||
&& portal.getPos2().getZ() - additionalArea <= loc.getZ();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void throwPlayerBack(Player player) {
|
||||
// Not ensured to remove them out of the portal but it makes it feel nicer for
|
||||
// the player.
|
||||
if (throwback > 0) {
|
||||
Vector velocity = player.getLocation().getDirection();
|
||||
player.setVelocity(velocity.setY(0).normalize().multiply(-1).setY(throwback));
|
||||
}
|
||||
}
|
||||
|
||||
public static int getPortalProtectionRadius() {
|
||||
return portalProtectionRadius;
|
||||
}
|
||||
|
||||
public static boolean activate(Player player, AdvancedPortal portal) {
|
||||
return activate(player, portal, true);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.sekwah.advancedportals.bukkit.reflection;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class ReflectionHelper {
|
||||
|
||||
public static Field getFieldByType(Class<?> clazz, Class<?> findingType, boolean isAccessable) {
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
for(Field field : fields) {
|
||||
if(field.getType() == findingType && field.isAccessible() == isAccessable) {
|
||||
field.setAccessible(true);
|
||||
return field;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Class<?> findClass(Class<?> classObj, String className){
|
||||
for(Class<?> classes : classObj.getDeclaredClasses()){
|
||||
if(classes.getSimpleName().equals(className)){
|
||||
return classes;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.sekwah.advancedportals.bukkit.util;
|
||||
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class WorldEditIntegration {
|
||||
private static Region getCurrentSelection(Player player) {
|
||||
LocalSession localSession = WorldEdit.getInstance().getSessionManager().get(BukkitAdapter.adapt(player));
|
||||
try {
|
||||
return localSession.getSelection(BukkitAdapter.adapt(player.getWorld()));
|
||||
} catch (IncompleteRegionException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean validateSelection(Player player) {
|
||||
return getCurrentSelection(player) instanceof CuboidRegion;
|
||||
}
|
||||
|
||||
public static Location getPos1(Player player) {
|
||||
Region currentSelection = getCurrentSelection(player);
|
||||
if (!(currentSelection instanceof CuboidRegion)) return null;
|
||||
return BukkitAdapter.adapt(player.getWorld(), ((CuboidRegion) currentSelection).getPos1());
|
||||
}
|
||||
|
||||
public static Location getPos2(Player player) {
|
||||
Region currentSelection = getCurrentSelection(player);
|
||||
if (currentSelection == null) return null;;
|
||||
return BukkitAdapter.adapt(player.getWorld(), ((CuboidRegion) currentSelection).getPos2());
|
||||
}
|
||||
|
||||
public static void explainRegion(Player player, Location pos1, Location pos2) {
|
||||
LocalSession localSession = WorldEdit.getInstance().getSessionManager().get(BukkitAdapter.adapt(player));
|
||||
RegionSelector selector = new CuboidRegionSelector(BukkitAdapter.adapt(player.getWorld()), BukkitAdapter.asBlockVector(pos1), BukkitAdapter.asBlockVector(pos2));
|
||||
localSession.setRegionSelector(BukkitAdapter.adapt(player.getWorld()), selector);
|
||||
selector.explainRegionAdjust(BukkitAdapter.adapt(player), localSession);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.sekwah.advancedportals.bungee;
|
||||
|
||||
import com.sekwah.advancedportals.bungee.listener.EventListener;
|
||||
import com.sekwah.advancedportals.bungee.listener.PluginMessageReceiver;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class AdvancedPortalsPlugin extends Plugin {
|
||||
|
||||
public HashMap<String, String[]> PlayerDestiMap = new HashMap<>();
|
||||
// key: UUID (string)
|
||||
// value: [0] targetServer, [1] targetDestination
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getProxy().registerChannel(BungeeMessages.CHANNEL_NAME);
|
||||
|
||||
if(BungeeMessages.CHANNEL_NAME != null)
|
||||
|
||||
getProxy().getPluginManager().registerListener(this, new PluginMessageReceiver(this));
|
||||
getProxy().getPluginManager().registerListener(this, new EventListener(this));
|
||||
|
||||
getLogger().info("\u00A7aAdvanced portals have been successfully enabled!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getLogger().info("\\u00A7cAdvanced portals are being disabled!");
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.sekwah.advancedportals.bungee;
|
||||
|
||||
public class BungeeMessages {
|
||||
|
||||
/**
|
||||
* String in
|
||||
* string bungee server
|
||||
* string desti name
|
||||
* string uuid (of what the server thinks it is)
|
||||
*
|
||||
* String out (to recieving server)
|
||||
* string destination
|
||||
* string uuid
|
||||
* string offline uuid
|
||||
*
|
||||
* String out
|
||||
*/
|
||||
public static String ENTER_PORTAL = "PortalEnter";
|
||||
|
||||
public static String CHANNEL_NAME = "advancedportals:warp";
|
||||
|
||||
|
||||
public static String SERVER_DESTI = "BungeePortal";
|
||||
|
||||
/**
|
||||
* Same in and out. This is read by the bungee
|
||||
* String containing command
|
||||
*/
|
||||
public static String BUNGEE_COMMAND = "BungeeCommand";
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.sekwah.advancedportals.bungee.listener;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.sekwah.advancedportals.bungee.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bungee.BungeeMessages;
|
||||
import net.md_5.bungee.api.event.ServerConnectedEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public class EventListener implements Listener {
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
public EventListener(AdvancedPortalsPlugin plugin) { this.plugin = plugin; }
|
||||
|
||||
@EventHandler
|
||||
public void onServerConnected(ServerConnectedEvent event) {
|
||||
String uuid = event.getPlayer().getUniqueId().toString();
|
||||
|
||||
String[] val = plugin.PlayerDestiMap.get(uuid);
|
||||
|
||||
if (val != null) {
|
||||
|
||||
// key: UUID (string)
|
||||
// value: [0] targetServer, [1] targetDestination, [2] onlineUUID
|
||||
|
||||
if (event.getServer().getInfo().getName().equalsIgnoreCase(val[0])) {
|
||||
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
|
||||
out.writeUTF(BungeeMessages.SERVER_DESTI);
|
||||
out.writeUTF(val[1]);
|
||||
out.writeUTF(val[2]);
|
||||
|
||||
event.getServer().sendData(BungeeMessages.CHANNEL_NAME, out.toByteArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.sekwah.advancedportals.bungee.listener;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.sekwah.advancedportals.bungee.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.bungee.BungeeMessages;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.connection.Server;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class PluginMessageReceiver implements Listener {
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
public PluginMessageReceiver(AdvancedPortalsPlugin plugin) { this.plugin = plugin; }
|
||||
|
||||
@EventHandler
|
||||
public void onMessageReceived(PluginMessageEvent event) {
|
||||
if(!event.getTag().equalsIgnoreCase(BungeeMessages.CHANNEL_NAME) || !(event.getSender() instanceof Server)) return;
|
||||
|
||||
ByteArrayDataInput in = ByteStreams.newDataInput(event.getData());
|
||||
String subChannel = in.readUTF();
|
||||
|
||||
if (subChannel.equalsIgnoreCase(BungeeMessages.ENTER_PORTAL)) {
|
||||
String targetServer = in.readUTF();
|
||||
String targetDestination = in.readUTF();
|
||||
String targetUUID = in.readUTF();
|
||||
|
||||
plugin.PlayerDestiMap.put(targetUUID, new String[]{targetServer, targetDestination, targetUUID});
|
||||
|
||||
plugin.getProxy().getScheduler().schedule(plugin, () -> plugin.PlayerDestiMap.remove(targetUUID),
|
||||
10, TimeUnit.SECONDS);
|
||||
}
|
||||
else if (subChannel.equalsIgnoreCase(BungeeMessages.BUNGEE_COMMAND)) {
|
||||
String command = in.readUTF();
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
||||
if (player != null) {
|
||||
// To send command to server the player is currently on in a lazy way
|
||||
//player.chat("/" + command);
|
||||
plugin.getProxy().getPluginManager().dispatchCommand(player, command);
|
||||
}
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
package com.sekwah.advancedportals.velocity;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.inject.Inject;
|
||||
import com.sekwah.advancedportals.bungee.BungeeMessages;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||
import com.velocitypowered.api.event.player.ServerPostConnectEvent;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* While there may be a better way to do this for now we are keeping the behavior so it also works with Bungee's horrible API.
|
||||
*/
|
||||
@Plugin(id = "advancedportals", name = "Advanced Portals",
|
||||
url = "https://www.spigotmc.org/resources/advanced-portals.14356/",
|
||||
authors = {"sekwah"},
|
||||
version = "0.9.2")
|
||||
public class AdvancedPortalsPlugin {
|
||||
|
||||
public HashMap<String, String[]> PlayerDestiMap = new HashMap<>();
|
||||
|
||||
private final Logger logger;
|
||||
private final ProxyServer proxy;
|
||||
private LegacyChannelIdentifier AP_CHANNEL;
|
||||
|
||||
@Inject
|
||||
public AdvancedPortalsPlugin(ProxyServer proxy, Logger logger) {
|
||||
|
||||
this.proxy = proxy;
|
||||
this.logger = logger;
|
||||
|
||||
logger.info("\u00A7aAdvanced portals have been successfully enabled!");
|
||||
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onProxyInitialize(ProxyInitializeEvent event) {
|
||||
|
||||
String[] splitChannel = BungeeMessages.CHANNEL_NAME.split(":");
|
||||
AP_CHANNEL = new LegacyChannelIdentifier(BungeeMessages.CHANNEL_NAME);
|
||||
|
||||
proxy.getChannelRegistrar().register(AP_CHANNEL);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPluginMessage(PluginMessageEvent event) {
|
||||
if(event.getIdentifier().equals(AP_CHANNEL)) {
|
||||
if(event.getSource() instanceof ServerConnection) {
|
||||
|
||||
ByteArrayDataInput in = ByteStreams.newDataInput(event.getData());
|
||||
|
||||
String subChannel = in.readUTF();
|
||||
|
||||
if (subChannel.equalsIgnoreCase(BungeeMessages.ENTER_PORTAL)) {
|
||||
String targetServer = in.readUTF();
|
||||
String targetDestination = in.readUTF();
|
||||
String targetUUID = in.readUTF();
|
||||
|
||||
PlayerDestiMap.put(targetUUID, new String[]{targetServer, targetDestination, targetUUID});
|
||||
|
||||
proxy.getScheduler().buildTask(this, () -> PlayerDestiMap.remove(targetUUID))
|
||||
.delay(10, TimeUnit.SECONDS).schedule();
|
||||
}
|
||||
else if (subChannel.equalsIgnoreCase(BungeeMessages.BUNGEE_COMMAND)) {
|
||||
String command = in.readUTF();
|
||||
ServerConnection connection = (ServerConnection) event.getSource();
|
||||
if(connection.getPlayer() != null) {
|
||||
proxy.getCommandManager().executeAsync(connection.getPlayer(), command);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// So that client packets don't make it through to the servers, always trigger on this channel.
|
||||
event.setResult(PluginMessageEvent.ForwardResult.handled());
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void postJoinEvent(ServerPostConnectEvent event) {
|
||||
String uuid = event.getPlayer().getUniqueId().toString();
|
||||
|
||||
String[] val = PlayerDestiMap.get(uuid);
|
||||
|
||||
if (val != null) {
|
||||
// key: UUID (string)
|
||||
// value: [0] targetServer, [1] targetDestination, [2] onlineUUID
|
||||
|
||||
event.getPlayer().getCurrentServer().ifPresent(serverConnection -> {
|
||||
|
||||
if (serverConnection.getServerInfo().getName().equalsIgnoreCase(val[0])) {
|
||||
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
|
||||
out.writeUTF(BungeeMessages.SERVER_DESTI);
|
||||
out.writeUTF(val[1]);
|
||||
out.writeUTF(val[2]);
|
||||
|
||||
serverConnection.sendPluginMessage(AP_CHANNEL, out.toByteArray());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
4
src/main/resources/bungee.yml
Normal file
4
src/main/resources/bungee.yml
Normal file
@ -0,0 +1,4 @@
|
||||
main: com.sekwah.advancedportals.bungee.AdvancedPortalsPlugin
|
||||
name: AdvancedPortals
|
||||
version: 0.9.2
|
||||
author: sekwah
|
@ -2,7 +2,8 @@
|
||||
|
||||
# To set this file back to its default state just delete it and reload the server or restart it!
|
||||
|
||||
|
||||
# Will update whenever there is a config update from an older version so may not be the latest plugin version
|
||||
ConfigVersion: 0.5.13
|
||||
|
||||
# Set to true if you want the normal axes to work normally but the ones gived with /portals selector or wand will still work though
|
||||
# It can be usefull if people with permission want to use an iron axe on a survival server
|
||||
@ -18,18 +19,17 @@ CanBuildPortalBlock: true
|
||||
PortalProtection: true
|
||||
|
||||
# How many blocks around the portals will be protected from griefing or destruction
|
||||
PortalProtectionRadius: 5
|
||||
PortalProtectionArea: 5
|
||||
|
||||
# What the default trigger block is for portals if nothing is defined.
|
||||
DefaultPortalTriggerBlock: PORTAL
|
||||
|
||||
# This stops all water flowing inside a portal area(can be disabled if something like world edit is handelling the water flow or you dont want it active)
|
||||
# you want to
|
||||
# you want to
|
||||
StopWaterFlow: true
|
||||
|
||||
# This must be a placeable block or it will not work and may even crash
|
||||
ShowSelectionBlockID: STAINED_GLASS
|
||||
ShowSelectionBlockData: 14
|
||||
ShowSelectionBlockID: RED_STAINED_GLASS
|
||||
|
||||
# WarpEffect
|
||||
# 0 = disabled(no particles)
|
||||
@ -50,11 +50,6 @@ ShowBungeeWarpMessage: false
|
||||
|
||||
ShowSelectionShowDuration: 10
|
||||
|
||||
# If a player is riding a entity, warp the entity too?(unless its a bungee portal or any non teleporting portal)
|
||||
WarpRiddenEntity: true
|
||||
|
||||
|
||||
|
||||
# Where to display the message 0 = disabled(replaces PortalWarpMessages), 1 = in chat and 2 = action bar(1.8 and above only, anything lower will print the message that would
|
||||
# generally on the action bar in the chat without a prefix or extra chat formatting)
|
||||
WarpMessageDisplay: 2
|
||||
@ -70,21 +65,43 @@ CustomPrefix: '&a[&eAdvancedPortals&a]'
|
||||
|
||||
CustomPrefixFail: '&c[&7AdvancedPortals&c]'
|
||||
|
||||
# Message sent to player in chat/action bar on warp
|
||||
WarpMessage: '&aYou have warped to &e<warp>&a.'
|
||||
|
||||
BlockSpectatorMode: false
|
||||
|
||||
PortalCooldown: 5 # How long after trying to enter a portal until the player can try to enter another. 0 or lower to deactivate.
|
||||
ThrowbackAmount: 0.7 # How fast to throw them back, 0 or lower to disable throwback
|
||||
|
||||
# Letters are flags. Include them to activate. n always disables everything, remove if you want it to work.
|
||||
# Lettering may not make too much sense but meh its useful. Examples are "ocpk" or "cop" (doesnt matter order)
|
||||
#
|
||||
# Remember enabling this means potentially admins could leave a portal lying around which could let them reop themselves.
|
||||
# If you think this may be an issue use a permission plugin and specifically give the users you trust permissions.
|
||||
# Only disables the gateway block places with "/portal gatewayblock" for now
|
||||
# If you want to replace already made portals just use "/portal disablebeacon" and it will run through all the blocks in the area
|
||||
# Reloading the world or chunks that portals are in will also trigger the beacons to be disabled (this is for efficiency reasons)
|
||||
# However these wont trigger in the spawn chunks as they are loaded before any pluigns are.
|
||||
DisableGatewayBeam: true
|
||||
|
||||
# Enable or disable special command portals
|
||||
#
|
||||
# n Disabled none, best just put this to really make sure the fact none are here is specified. It disables any others too
|
||||
# o Admin Heighten Enabled Permission advancedportals.createportal.commandlevel.op
|
||||
# p Perm Heighten Enabled Permission advancedportals.createportal.commandlevel.perms
|
||||
# c Console Heighten Enabled Permission advancedportals.createportal.commandlevel.console
|
||||
# h Ops can create admin commands without special perms
|
||||
# e Ops can create all perm commands without special perms
|
||||
# k Ops can create console commands without special perms
|
||||
# o enable op command portals
|
||||
# p enable permission command portals
|
||||
# c enable console command portals
|
||||
# b enable bungee command portals
|
||||
#
|
||||
CommandLevels: n
|
||||
CommandLevels: opcb
|
||||
|
||||
# Should the commands being triggered log in the console? (If you have an active server it may cause a bit of spam)
|
||||
CommandLogs: true
|
||||
|
||||
# If you want to use bungee or velocity and it is not automatically detected (make sure you have advanced portals on the proxy, especially with velocity)
|
||||
ForceEnableProxySupport: false
|
||||
|
||||
# How many seconds after the proxy event fires should the player be teleported (should help with on spawn plugins and such)
|
||||
# 0 is disabled and anything higher causes a delay.
|
||||
ProxyTeleportDelay: 0
|
||||
|
||||
# Just in case you are not using the proxy and dont want the warning message
|
||||
DisableProxyWarning: false
|
||||
|
||||
# Whether the integration with worldedit should be enabled.
|
||||
# This will force AdvancedPortals to use WorldEdit selections.
|
||||
WorldEditIntegration: false
|
71
src/main/resources/plugin.yml
Normal file
71
src/main/resources/plugin.yml
Normal file
@ -0,0 +1,71 @@
|
||||
main: com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin
|
||||
name: AdvancedPortals
|
||||
version: 0.9.2
|
||||
author: sekwah
|
||||
description: An advanced portals plugin for bukkit.
|
||||
api-version: 1.13
|
||||
|
||||
softdepend:
|
||||
- WorldEdit
|
||||
|
||||
commands:
|
||||
advancedportals:
|
||||
description: The main command for the advanced portals
|
||||
aliases: [portals, aportals, portal, ap]
|
||||
usage: /<command>
|
||||
permission: advancedportals.portalcommand
|
||||
destination:
|
||||
description: Can be used to access portal destinations.
|
||||
aliases: [desti]
|
||||
usage: /<command>
|
||||
permission: advancedportals.desti
|
||||
permissions:
|
||||
advancedportals.*:
|
||||
description: Gives access to all commands
|
||||
default: op
|
||||
children:
|
||||
advancedportals.createportal: true
|
||||
advancedportals.portal: true
|
||||
advancedportals.build: true
|
||||
advancedportals.desti: true
|
||||
advancedportals.createportal:
|
||||
description: Allows you to create portals
|
||||
default: op
|
||||
advancedportals.createportal.commandlevel.*:
|
||||
description: Gives access to all level raisers
|
||||
default: false
|
||||
children:
|
||||
advancedportals.createportal.commandlevel.op: true
|
||||
advancedportals.createportal.commandlevel.bungee: true
|
||||
advancedportals.createportal.commandlevel.perms: true
|
||||
advancedportals.createportal.commandlevel.console: true
|
||||
advancedportals.createportal.commandlevel.op:
|
||||
description: Allows you to run portal commands as op
|
||||
default: false
|
||||
advancedportals.createportal.commandlevel.perms:
|
||||
description: Allows you to run portal commands with * permission
|
||||
default: false
|
||||
advancedportals.createportal.commandlevel.bungee:
|
||||
description: Allows you to run portal commands through bungee
|
||||
default: false
|
||||
advancedportals.createportal.commandlevel.console:
|
||||
description: Executes command in the console
|
||||
default: false
|
||||
advancedportals.portal:
|
||||
description: Allows use of portal commands
|
||||
default: op
|
||||
advancedportals.portalcommand:
|
||||
description: Access to the portal command. This is seperate to allow access to portal warps without the rest.
|
||||
default: true
|
||||
advancedportals.build:
|
||||
description: Allows you to build in the portal regions
|
||||
default: op
|
||||
advancedportals.desti:
|
||||
description: Gives access to all desti commands
|
||||
default: op
|
||||
advancedportals.warp:
|
||||
description: Access to the warp command
|
||||
default: op
|
||||
advancedportals.warp.*:
|
||||
description: Access to all warps
|
||||
default: op
|
Loading…
Reference in New Issue
Block a user