Compare commits
487 Commits
0.0.6
...
spigot-1.1
Author | SHA1 | Date |
---|---|---|
renovate[bot] | 689d4a4fe9 | |
renovate[bot] | f0671fb8b8 | |
renovate[bot] | 9cf6d9e991 | |
Tad Hunt | b0a93c2c35 | |
renovate[bot] | 5229339a8c | |
renovate[bot] | 1a759dcc76 | |
renovate[bot] | 93a6aface2 | |
renovate[bot] | 0b64f47b8a | |
renovate[bot] | 617ccfd66a | |
Osiris-Team | e808668fce | |
renovate[bot] | 91d52b8c1b | |
renovate[bot] | eb71f1c1d1 | |
renovate[bot] | 15956b4844 | |
renovate[bot] | 4f60d8e319 | |
renovate[bot] | f5f06167db | |
renovate[bot] | 0f595fac7d | |
renovate[bot] | 051fc6c92e | |
renovate[bot] | 22483ac052 | |
renovate[bot] | 51aa6dac47 | |
renovate[bot] | 029f117fc1 | |
Renovate Bot | 87cd76cdeb | |
Renovate Bot | 34b0127f99 | |
Renovate Bot | 7d3597faad | |
Renovate Bot | 58e7e3ad78 | |
Renovate Bot | 6906772138 | |
Renovate Bot | 080aae4a9e | |
Renovate Bot | f6620ef2eb | |
Renovate Bot | 05359480a3 | |
Renovate Bot | a317acce3d | |
Renovate Bot | 9b7c09955e | |
Renovate Bot | 8eb3a2926b | |
Renovate Bot | 71e67f2010 | |
Sekwah | 5df74aae28 | |
Sekwah | 4904d806be | |
Sekwah | 9a64ae58c7 | |
Renovate Bot | c504909668 | |
Renovate Bot | 5b79228be7 | |
Renovate Bot | 6ab4c363ac | |
Renovate Bot | 5751879abd | |
Renovate Bot | 7d82fa3879 | |
Sekwah | 1bad72bbc2 | |
Sekwah | f8bec4c1ee | |
Sekwah | 75d2be30fe | |
Sekwah | 787c1d09b4 | |
Sekwah | 20c56219f9 | |
Sekwah | 778ad2ab31 | |
JOO200 | e3021367ab | |
JOO200 | fdb22ab8b5 | |
JOO200 | d16ccb7717 | |
Renovate Bot | 2207324598 | |
Renovate Bot | d916deb3a9 | |
Sekwah | 659fcca7ee | |
Mohammed Al-Dahleh | 3928922de3 | |
Sekwah | a9e660db65 | |
Renovate Bot | 486cff7e09 | |
Renovate Bot | d09ad72491 | |
Renovate Bot | 7d5e96f291 | |
Sekwah | 393ad01d45 | |
Renovate Bot | 71d08da9dc | |
Renovate Bot | f225363e67 | |
Renovate Bot | 162505553f | |
Renovate Bot | 812f4c78dc | |
Renovate Bot | 0ab32790eb | |
Renovate Bot | 0be605fe3a | |
Sekwah | 64f0f5113e | |
Sekwah | fb80fbb515 | |
Sekwah | 81d64ecc5a | |
Renovate Bot | aacf626635 | |
Renovate Bot | 12ab00f004 | |
Renovate Bot | 065fa22852 | |
Sekwah | 012ddf6e36 | |
Sekwah | 9b3adf7ba4 | |
Sekwah | ab9dbe027e | |
Sekwah | 62307c6bcf | |
Renovate Bot | e2b0723d24 | |
Renovate Bot | 1a57a509e6 | |
Sekwah | ee8f0ff3d0 | |
Sekwah | 05d2a51fbf | |
Sekwah | e73d84afa3 | |
Renovate Bot | d4b642ec23 | |
Sekwah | bc683183f6 | |
Sekwah | 3a5460cff3 | |
Sekwah | f364828176 | |
Renovate Bot | dfe5cfc26d | |
Sekwah | ebd94fd081 | |
Renovate Bot | ffee4fbbbe | |
Renovate Bot | dcf8456511 | |
Renovate Bot | 1ac1fe7e2e | |
Sekwah | c51a556ac7 | |
Sekwah | eafe7f1d9c | |
Sekwah | ff95908bf2 | |
Sekwah | d2e69771c5 | |
Sekwah | 17a81dede7 | |
Renovate Bot | efc9ad4715 | |
Sekwah | 7c78f414ac | |
Sekwah | bfea4b2836 | |
Sekwah | b1be39b908 | |
Sekwah | 68ba7dc76b | |
Sekwah | cd96c0d2c0 | |
Sekwah | 06722986be | |
Sekwah | 9536835785 | |
Sekwah | 7b0c1ca6ae | |
Sekwah | 100b825765 | |
Sekwah | 186ec82afc | |
Sekwah | 093da07b00 | |
Sekwah | 8acb0f535e | |
Sekwah | 8e0590b6d1 | |
Sekwah | 9d7184d86e | |
Sekwah | 6b097087a2 | |
Sekwah | 99c810e1be | |
Sekwah | f3c8f73975 | |
Sekwah | b243b4d889 | |
Sekwah | 0adb854548 | |
Sekwah | 327e7dd0cb | |
Sekwah | 2bf377e575 | |
Sekwah | 4ab2e2bd7a | |
Sekwah | a20028d9fc | |
Sekwah | d025947134 | |
Sekwah | df7bceea6e | |
Sekwah | e22b068a97 | |
Sekwah | d884db3d6c | |
Sekwah | a1121adc10 | |
Sekwah | e8cbb403c5 | |
Sekwah | ae518bea39 | |
Sekwah | 4278cd5d7a | |
Sekwah | fd6ef9ac08 | |
Sekwah | 3ac7a8c6ff | |
Sekwah | 0ad693db0c | |
Sekwah | 1aa8ce45ac | |
Sekwah | fc952e6c9e | |
Sekwah | 5c1f712765 | |
Sekwah | 7034eee7b2 | |
Sekwah | e8ecde5b4e | |
Sekwah | baca2d3316 | |
Sekwah | 2040ea08a8 | |
Sekwah | afe4e41b14 | |
Sekwah | 425093d887 | |
Sekwah | a30e44bb35 | |
Sekwah | 3ac200bbc0 | |
Sekwah | 5c2c1cf465 | |
Sekwah | 9aa53f4a28 | |
Sekwah | 4648ca31d6 | |
Sekwah | 5e1d9aeb9d | |
Sekwah | 31db696b1a | |
Sekwah | 56221ee058 | |
loonybtard | b7b148f057 | |
Sekwah | ecd11a7f34 | |
Sekwah | 5ee12d7696 | |
loonybtard | ff4fd1f3e7 | |
loonybtard | 5682b94aef | |
Sekwah | 886a8744e2 | |
Sekwah | 8c7798dec8 | |
Sekwah | 41643caff2 | |
Sekwah | f8e5cced9e | |
Sekwah | 2da18a3417 | |
Sekwah | d06f150358 | |
Sekwah | 1796945896 | |
Sekwah | 2063c8e30c | |
Sekwah | 9279be58aa | |
Sekwah | 9a2ff28ab9 | |
Sekwah | aacdd54ffe | |
Sekwah | 6dd23ddeee | |
Sekwah | d104da907f | |
Sekwah | d84ec0bd3e | |
Sekwah | f14fd9f692 | |
Sekwah | 69176c379b | |
Freddy | 7aa4114742 | |
Sekwah | 42b01ec059 | |
Sekwah | 806beea62a | |
Sekwah | 38b15acd15 | |
Daniil | d950d8eb22 | |
Sekwah | e02dd0e858 | |
Sekwah | 5718d789d9 | |
tmantti | f82de6be12 | |
tmantti | 77096a931c | |
tmantti | 1cba807351 | |
tmantti | 35845e1caa | |
tmantti | cf2ff77ccb | |
Sekwah | 17fb0c5332 | |
Sekwah | 468715a29f | |
Sekwah | f2090a917b | |
Sekwah | 1c413c82e5 | |
Sekwah | 4012e9bc01 | |
Sekwah | 6c9eeb06d0 | |
Sekwah | a4771aa86a | |
Sekwah | d2a362e5af | |
Sekwah | 859971b6ea | |
Sekwah | 79f43b9a62 | |
Sekwah | 4912984cf0 | |
Sekwah | 9528ad6049 | |
Sekwah | 1e322aa2ce | |
Sekwah | bfcb2d596e | |
silicondev | 2100e5cec9 | |
Sekwah | dc8a301ff2 | |
Sekwah | 36a75a2bd6 | |
Sekwah | d9928a60bb | |
Tomasz Piowczyk | 028482a46c | |
Tomasz Piowczyk | f61ac373a4 | |
Tomasz Piowczyk | 414835a690 | |
Tomasz Piowczyk | dafb14ffb4 | |
Sekwah | 067865f726 | |
dalbodeule | 7009129085 | |
dalbodeule | 5402a0ab4e | |
Sekwah | 2d022de19c | |
Sekwah | ffe3201a93 | |
Sekwah | a5c828e010 | |
dalbodeule | e926515175 | |
dalbodeule | cab45ff7b2 | |
dalbodeule | 0015a3bcb7 | |
dalbodeule | a6555b171c | |
Sekwah | 89c4253f82 | |
Sekwah | 0c8548b12e | |
Sekwah | fecdc32e0d | |
Sekwah | 9f4b70a0ef | |
Sekwah | 9329ab58c5 | |
Sekwah | 48c416b63f | |
Sekwah | 79693bcd8a | |
Sekwah | b33a30ad89 | |
Sekwah | f5deb96d2e | |
sekwah41 | c8efcbb801 | |
sekwah41 | 39dc937ddf | |
sekwah41 | d92fcf1244 | |
xPepijnxTechx | 4d816cbd46 | |
sekwah41 | e409f990af | |
Sekwah | 16fcc5dccc | |
Sekwah | 523fbb1c83 | |
Sekwah | 20c8f585c0 | |
sekwah41 | 28ea9d1f8d | |
Sekwah | e37ec1bef6 | |
sekwah41 | 4392d60b26 | |
sekwah41 | 4d8879a255 | |
Sekwah | 21a5bb2933 | |
jascotty2 | fa01dde5d2 | |
jascotty2 | ccd21d0e22 | |
Sekwah | 9540ad434c | |
sekwah41 | dd36947184 | |
Sekwah | 3175fd0052 | |
Sekwah | ae5557f816 | |
Sekwah | 8c5d8d689c | |
Sekwah | 17e3819b2f | |
Sekwah | 677491a33f | |
Sekwah | 232a5334f1 | |
Sekwah | 7a0b65187b | |
Sekwah | e4900a62f4 | |
Sekwah | af2ded09b5 | |
Sekwah | dbf101bb4e | |
Sekwah | 70347779c2 | |
Sekwah | 5078868fda | |
Sekwah | 56bbd8f2ca | |
Sekwah | 3134e972a5 | |
Unknown | af28e22b58 | |
Unknown | d75c5d710a | |
Sekwah | 24d0f4719d | |
Sekwah | accfda8d90 | |
Sekwah | 81e339172d | |
Sekwah | e6c2b2e960 | |
sekwah41 | d491009451 | |
sekwah41 | 545167824d | |
Sekwah | ebf936735c | |
Sekwah | 6a97eb46c8 | |
Sekwah | e37de65fd3 | |
Sekwah | ae677607a1 | |
Sekwah | 26f74c9cf6 | |
Aztec | 321d4c8764 | |
Sekwah | becd114d87 | |
Sekwah | d4776748bb | |
Sekwah | 360618cd96 | |
Sekwah | faf14757f8 | |
Sekwah | e3ff485b09 | |
Sekwah | 5de6385051 | |
Unknown | e3b660dcae | |
Sekwah | 4f516a7eb2 | |
Sekwah | c23d7a2d14 | |
sekwah | ca72d9a8df | |
Unknown | 727c768a38 | |
Unknown | 811079b901 | |
sekwah | 6d6a483275 | |
sekwah | 7a4046f3f9 | |
sekwah41 | 08d266210b | |
FabioZumbi12 | 0c691df591 | |
sekwah | d530621da0 | |
sekwah | f42f2d3aea | |
sekwah | 5c4cbaa127 | |
sekwah | a8521b3998 | |
sekwah | f03ddda6c5 | |
sekwah | 72db55a86b | |
sekwah41 | 1f3748e10e | |
Alastair | 14a453ea1a | |
sekwah41 | 2096698b52 | |
sekwah41 | efe03d29aa | |
Alastair | 5b12a9960f | |
Alastair | 726a4d7ba2 | |
Alastair | 1cd97d2bc1 | |
sekwah41 | bfc473ec85 | |
Alastair | 4dcb4dd354 | |
sekwah41 | cd5933aa08 | |
sekwah41 | 9ccb6308c2 | |
sekwah41 | 340a9917a0 | |
Alastair | 734337a5be | |
Alastair | 4b28ed98a9 | |
Xorgon | 89036c12a7 | |
sekwah | 9ec4c3b78a | |
Alastair | fbbd104881 | |
Alastair | 8f5fba9959 | |
Alastair | 43160e35d9 | |
Alastair | de987f0555 | |
Alastair | 9e371b7a97 | |
Alastair | 52712ff015 | |
Alastair | e4f38f50a0 | |
Alastair | b7463fa8b3 | |
Alastair | 9d21bc3fc0 | |
sekwah41 | a81e322be3 | |
sekwah41 | de1cbddad1 | |
Alastair | d49f2ff976 | |
Alastair | 0cd3de1af5 | |
Alastair | 112abf3d03 | |
sekwah41 | 7c2732145b | |
Alastair | 9861869ad8 | |
Alastair | fc4e94bcd3 | |
Alastair | 3551066e21 | |
Alastair | b29d7f35c5 | |
Alastair | 3366e9705a | |
Alastair | ac8d5a9725 | |
Alastair | 68bffc2c7e | |
Alastair | 801ce6a4aa | |
sekwah | 1406a86272 | |
Alastair | f73192d729 | |
Alastair | c403e59360 | |
Alastair | 3832c43148 | |
Alastair | fca3d737db | |
Alastair | 64da16507c | |
Alastair | a3ae2416c3 | |
Alastair | 8e1bd7b832 | |
Alastair | 9d906e9fff | |
Alastair | 42ac3553a2 | |
Alastair | 1af04abd37 | |
Alastair | 9099f2367b | |
Alastair | de46b0846e | |
Alastair | 60287a4526 | |
Alastair | 82cfa1a4b3 | |
Alastair | 1e8e5d9e03 | |
Alastair | 19041f05d4 | |
Alastair | 62fc4add68 | |
Alastair | 07db2f8208 | |
Alastair | eda0dd5de6 | |
Alastair | e6ebcef28a | |
Alastair | 221bee9613 | |
Alastair | 8ae2473b9a | |
Alastair | bbcd423987 | |
Alastair Hawkes | 1bf886e909 | |
Alastair Hawkes | 160d1e4cc3 | |
Alastair Hawkes | d392dfa88c | |
Alastair Hawkes | 6bcc9e6510 | |
Alastair Hawkes | e9b47db152 | |
Alastair Hawkes | 664ef41b6a | |
Alastair Hawkes | f34ffe8916 | |
Alastair | 6800134600 | |
Alastair | 6b18c0721d | |
sekwah41 | fe0df660c7 | |
CodeHat | 9efa4aac74 | |
Alastair | 9f32237dae | |
Alastair | cb5e429de0 | |
Alastair | 4cb0df024e | |
Alastair | ee10d17cbb | |
Alastair | 88a823f713 | |
Alastair | eb03573338 | |
sekwah41 | e27af038d5 | |
sekwah41 | e0e9889681 | |
Alastair | 9494120be5 | |
Alastair | 0c53ef956b | |
sekwah41 | 03653e9fed | |
Max Qian | 2952d59743 | |
Alastair | f45aeab806 | |
Alastair | b94ec07573 | |
Alastair | 9888d6ec19 | |
Alastair | 412dd428dd | |
Alastair | 0070d70c8e | |
sekwah41 | af83ea8ef6 | |
Max Qian | 161a56d281 | |
Max Qian | 50455376de | |
Alastair | 7fdb84f36b | |
Alastair | 4134b77502 | |
Alastair | 5312eab16b | |
Alastair | d4da241c2c | |
Alastair | a21c75346a | |
Alastair | 305014c31c | |
sekwah41 | 7b774d6d9e | |
Max Qian | 109cd04034 | |
Alastair | 22163ba629 | |
Alastair | 62037634bc | |
Alastair | e4d187be52 | |
Max Qian | 80fcd96ba7 | |
Max Qian | fa9c1bdf9e | |
Alastair | 6aa354c2eb | |
Max Qian | f5f7464c24 | |
Alastair | 6219f2c32b | |
Max Qian | 75d5fef5b0 | |
Max Qian | db76bc6ef2 | |
Alastair | 920e3952d7 | |
Alastair | 294a89b305 | |
sekwah41 | 0714278fbb | |
Max Qian | 0bfdb18c04 | |
Max Qian | 65f264aedc | |
Alastair | e56853f0ea | |
Alastair | 82ff025b3a | |
Alastair | 5183684f2f | |
Alastair | c93b4e92b5 | |
Alastair | ce9a679bbc | |
Alastair | 09ac2adf06 | |
Alastair | c08ca1de33 | |
Max Qian | 830c6e0879 | |
Max Qian | 4fd0275d3a | |
Max Qian | 14ccbbcd0f | |
Max Qian | 7632291df7 | |
Max Qian | 85a3abd5b2 | |
Alastair | 3e1ff45fd3 | |
Alastair | cd5a657b6f | |
Alastair | 36e24caf63 | |
Alastair | efaec1f49b | |
Alastair | 9fc3847fb5 | |
Max Qian | d5fb63f0a6 | |
Alastair | ae37afcbde | |
Alastair | 75419c00bc | |
Alastair | c3f466720d | |
Alastair | 8a528230a3 | |
Max Qian | 252187c404 | |
Max Qian | 5bf7b71b65 | |
Max Qian | ee4227b919 | |
Max Qian | 96a0fedc4d | |
Alastair | 6fa6175856 | |
Alastair Hawkes | 4f0b06b32c | |
Alastair | 06794ac4a7 | |
Alastair Hawkes | 7bcd88fd1d | |
Alastair Hawkes | eff5319a9d | |
Alastair | 808a9527f3 | |
Alastair | cae5811371 | |
Alastair | 379fd20c79 | |
Alastair | 94c02eadb2 | |
Alastair Hawkes | 67f6b39434 | |
Alastair | d8872c0fa1 | |
Alastair | 0a5130b72c | |
Alastair | 3fbdccbd40 | |
Alastair | b201c76e97 | |
Alastair | 4b24440ff3 | |
Alastair | 703919bf4a | |
Alastair | 2500ecef0c | |
Alastair | c7690bafad | |
Alastair | 4f33a22f0f | |
Alastair | 5430c27999 | |
Alastair | 08d2a58c45 | |
Alastair | 541a7f11e9 | |
Alastair | 318d35fd11 | |
Alastair | 1ccda4eab7 | |
sekwah41 | 667297263b | |
Alastair | 57bc18b994 | |
Alastair | 5d5f916750 | |
Alastair | a740de0ae9 | |
Alastair | 4617b398f3 | |
Alastair Hawkes | f7df4bff24 | |
Alastair Hawkes | 15bc1f0c44 | |
Alastair | 54a3f8215f | |
Alastair Hawkes | 9adfc2e58b | |
Alastair Hawkes | bbd9984ac1 | |
Alastair | b522b169b9 | |
Alastair | 1ff177e6eb | |
Alastair | 3d0b6a5366 | |
Alastair | 8887bbd9c3 | |
Alastair | 5e60034d6b | |
Alastair | 43e9607ec9 | |
Alastair Hawkes | 65b028c777 | |
Alastair | f29a53409a | |
Alastair | 41c2ed911e | |
Alastair | bf09540855 | |
Alastair Hawkes | 24a76e453d | |
Alastair Hawkes | 07f3e8e2f6 | |
Alastair | e12a65bf69 | |
Alastair | 1511016221 | |
Alastair Hawkes | ec9e11eb3a | |
Alastair Hawkes | 809f573a51 | |
Alastair | dc937b28ce | |
Alastair | c2b6b58940 | |
Alastair | 3ce49556aa | |
sekwah41 | eb053c5ea4 | |
Alastair | 10aa76acd1 | |
Alastair | 16811d4c38 | |
Alastair Hawkes | 619085650c | |
Alastair Hawkes | e80196062b |
|
@ -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"
|
||||
}
|
||||
}
|
|
@ -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.
|
|
@ -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
|
||||
|
|
@ -1,6 +1,18 @@
|
|||
*.class
|
||||
|
||||
/build/
|
||||
/target/
|
||||
.gradle/
|
||||
.idea/
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
node_modules/
|
||||
*.iml
|
||||
*.iws
|
||||
*.ipr
|
||||
.env
|
||||
out/
|
||||
logs/
|
||||
classes/
|
||||
run/
|
||||
|
|
|
@ -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.
|
|
@ -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/
|
|
@ -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
|
191
LICENSE
191
LICENSE
|
@ -1,191 +0,0 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, and
|
||||
distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
||||
owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all other entities
|
||||
that control, are controlled by, or are under common control with that entity.
|
||||
For the purposes of this definition, "control" means (i) the power, direct or
|
||||
indirect, to cause the direction or management of such entity, whether by
|
||||
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
||||
permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications, including
|
||||
but not limited to software source code, documentation source, and configuration
|
||||
files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical transformation or
|
||||
translation of a Source form, including but not limited to compiled object code,
|
||||
generated documentation, and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form, made
|
||||
available under the License, as indicated by a copyright notice that is included
|
||||
in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
||||
is based on (or derived from) the Work and for which the editorial revisions,
|
||||
annotations, elaborations, or other modifications represent, as a whole, an
|
||||
original work of authorship. For the purposes of this License, Derivative Works
|
||||
shall not include works that remain separable from, or merely link (or bind by
|
||||
name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including the original version
|
||||
of the Work and any modifications or additions to that Work or Derivative Works
|
||||
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
||||
by the copyright owner or by an individual or Legal Entity authorized to submit
|
||||
on behalf of the copyright owner. For the purposes of this definition,
|
||||
"submitted" means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems, and
|
||||
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
||||
the purpose of discussing and improving the Work, but excluding communication
|
||||
that is conspicuously marked or otherwise designated in writing by the copyright
|
||||
owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
||||
of whom a Contribution has been received by Licensor and subsequently
|
||||
incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License.
|
||||
|
||||
Subject to the terms and conditions of this License, each Contributor hereby
|
||||
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the Work and such
|
||||
Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License.
|
||||
|
||||
Subject to the terms and conditions of this License, each Contributor hereby
|
||||
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||
irrevocable (except as stated in this section) patent license to make, have
|
||||
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
|
||||
such license applies only to those patent claims licensable by such Contributor
|
||||
that are necessarily infringed by their Contribution(s) alone or by combination
|
||||
of their Contribution(s) with the Work to which such Contribution(s) was
|
||||
submitted. If You institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
||||
Contribution incorporated within the Work constitutes direct or contributory
|
||||
patent infringement, then any patent licenses granted to You under this License
|
||||
for that Work shall terminate as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution.
|
||||
|
||||
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
||||
in any medium, with or without modifications, and in Source or Object form,
|
||||
provided that You meet the following conditions:
|
||||
|
||||
You must give any other recipients of the Work or Derivative Works a copy of
|
||||
this License; and
|
||||
You must cause any modified files to carry prominent notices stating that You
|
||||
changed the files; and
|
||||
You must retain, in the Source form of any Derivative Works that You distribute,
|
||||
all copyright, patent, trademark, and attribution notices from the Source form
|
||||
of the Work, excluding those notices that do not pertain to any part of the
|
||||
Derivative Works; and
|
||||
If the Work includes a "NOTICE" text file as part of its distribution, then any
|
||||
Derivative Works that You distribute must include a readable copy of the
|
||||
attribution notices contained within such NOTICE file, excluding those notices
|
||||
that do not pertain to any part of the Derivative Works, in at least one of the
|
||||
following places: within a NOTICE text file distributed as part of the
|
||||
Derivative Works; within the Source form or documentation, if provided along
|
||||
with the Derivative Works; or, within a display generated by the Derivative
|
||||
Works, if and wherever such third-party notices normally appear. The contents of
|
||||
the NOTICE file are for informational purposes only and do not modify the
|
||||
License. You may add Your own attribution notices within Derivative Works that
|
||||
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
||||
provided that such additional attribution notices cannot be construed as
|
||||
modifying the License.
|
||||
You may add Your own copyright statement to Your modifications and may provide
|
||||
additional or different license terms and conditions for use, reproduction, or
|
||||
distribution of Your modifications, or for any such Derivative Works as a whole,
|
||||
provided Your use, reproduction, and distribution of the Work otherwise complies
|
||||
with the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions.
|
||||
|
||||
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
||||
for inclusion in the Work by You to the Licensor shall be under the terms and
|
||||
conditions of this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify the terms of
|
||||
any separate license agreement you may have executed with Licensor regarding
|
||||
such Contributions.
|
||||
|
||||
6. Trademarks.
|
||||
|
||||
This License does not grant permission to use the trade names, trademarks,
|
||||
service marks, or product names of the Licensor, except as required for
|
||||
reasonable and customary use in describing the origin of the Work and
|
||||
reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, Licensor provides the
|
||||
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
||||
including, without limitation, any warranties or conditions of TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
|
||||
solely responsible for determining the appropriateness of using or
|
||||
redistributing the Work and assume any risks associated with Your exercise of
|
||||
permissions under this License.
|
||||
|
||||
8. Limitation of Liability.
|
||||
|
||||
In no event and under no legal theory, whether in tort (including negligence),
|
||||
contract, or otherwise, unless required by applicable law (such as deliberate
|
||||
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special, incidental,
|
||||
or consequential damages of any character arising as a result of this License or
|
||||
out of the use or inability to use the Work (including but not limited to
|
||||
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
|
||||
any and all other commercial damages or losses), even if such Contributor has
|
||||
been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability.
|
||||
|
||||
While redistributing the Work or Derivative Works thereof, You may choose to
|
||||
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
||||
other liability obligations and/or rights consistent with this License. However,
|
||||
in accepting such obligations, You may act only on Your own behalf and on Your
|
||||
sole responsibility, not on behalf of any other Contributor, and only if You
|
||||
agree to indemnify, defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason of your
|
||||
accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work
|
||||
|
||||
To apply the Apache License to your work, attach the following boilerplate
|
||||
notice, with the fields enclosed by brackets "[]" replaced with your own
|
||||
identifying information. (Don't include the brackets!) The text should be
|
||||
enclosed in the appropriate comment syntax for the file format. We also
|
||||
recommend that a file or class name and description of purpose be included on
|
||||
the same "printed page" as the copyright notice for easier identification within
|
||||
third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
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
|
||||
|
||||
http://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.
|
|
@ -0,0 +1,63 @@
|
|||
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.
|
||||
|
||||
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.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
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.
|
||||
|
||||
“The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
|
||||
|
||||
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.
|
||||
|
||||
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”.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
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:
|
||||
|
||||
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.
|
||||
|
||||
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:
|
||||
|
||||
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.
|
||||
|
||||
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) 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.
|
||||
|
||||
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:
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
63
README.md
63
README.md
|
@ -1,7 +1,64 @@
|
|||
Advanced Portals
|
||||
================
|
||||
![Advanced Portals](https://i.imgur.com/UIF6cQR.png)
|
||||
|
||||
[![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)
|
||||
|
||||
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.
|
||||
|
||||
# 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.
|
||||
|
||||
# Help
|
||||
[Command Documentation & Guides](https://www.guilded.gg/Sekwah/groups/MDqAZyrD/channels/72ffdaa3-9273-4722-bf47-b75408b371af/docs/1807463914)
|
||||
|
||||
[List Of Commands](https://github.com/sekwah41/Advanced-Portals/wiki/Commands)
|
||||
|
||||
[Spigot Page](https://www.spigotmc.org/resources/advanced-portals.14356/)
|
||||
|
||||
[Bukkit Page](http://dev.bukkit.org/bukkit-plugins/advanced-portals/)
|
||||
|
||||
# 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)
|
||||
|
||||
<a href="https://github.com/sekwah41/Advanced-Portals/wiki/Commands">List Of Commands</a>
|
||||
|
|
|
@ -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'
|
||||
}
|
|
@ -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
|
Binary file not shown.
|
@ -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
|
|
@ -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" "$@"
|
|
@ -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
|
|
@ -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"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"extends": [
|
||||
"config:base"
|
||||
],
|
||||
"packageRules": [
|
||||
{
|
||||
"commitMessagePrefix": "chore(deps):",
|
||||
"matchUpdateTypes": ["minor", "patch"],
|
||||
"automerge": true,
|
||||
"automergeType": "branch",
|
||||
"groupName": "Deps",
|
||||
"schedule": ["every weekend"]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
# Advanced Portals Config
|
||||
|
||||
# To set this file back to its default state just delete it and reload the server or restart it!
|
||||
|
||||
|
||||
|
||||
# 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
|
||||
UseOnlyServerMadeAxe: false
|
||||
|
||||
# Preferably an item and not a block but it shouldnt matter
|
||||
AxeItemId: IRON_AXE
|
||||
|
||||
# Will be implemented so you can give yourself the portal block and build manually with it so its easier to make portals with the portal block.
|
||||
CanBuildPortalBlock: true
|
||||
|
||||
# Defines if portals protect themselves
|
||||
PortalProtection: true
|
||||
|
||||
# How many blocks around the portals will be protected from griefing or destruction
|
||||
PortalProtectionRadius: 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
|
||||
StopWaterFlow: true
|
||||
|
||||
# This must be a placeable block or it will not work and may even crash
|
||||
ShowSelectionBlockID: STAINED_GLASS
|
||||
ShowSelectionBlockData: 14
|
||||
|
||||
# WarpEffect
|
||||
# 0 = disabled(no particles)
|
||||
# 1 = Eye of ender explode efffect(loads of portal particles)
|
||||
WarpParticles: 1
|
||||
|
||||
# WarpSound generally suggested to keep the same as warpeffect but can usually be used for just the sound and no particle effects
|
||||
# 0 = disabled(no sound)
|
||||
# 1 = Enderman Warp Sound
|
||||
WarpSound: 1
|
||||
|
||||
# In case you want to show the bungee attempting warp message
|
||||
ShowBungeeWarpMessage: false
|
||||
|
||||
# This changes how long the show seletion lasts in seconds
|
||||
|
||||
ShowSelectionShowDuration: 10
|
||||
|
||||
# If a player is riding a entity, warp the entity too?(unless its a bungee 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
|
||||
|
||||
# Use plugin name in the warp messages
|
||||
UseWarpPrefix: true
|
||||
|
||||
# If this is true a custom prefix can be used, (not fully coded yet!!)
|
||||
|
||||
UseCustomPrefix: false
|
||||
|
||||
CustomPrefix: '[Test]'
|
|
@ -1,497 +0,0 @@
|
|||
package com.sekwah.advancedportals;
|
||||
|
||||
import com.sekwah.advancedportals.portals.Portal;
|
||||
import com.sekwah.advancedportals.portals.PortalArg;
|
||||
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;
|
||||
|
||||
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) {
|
||||
Player player = (Player)sender;
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
|
||||
if(sender.hasPermission("advancedportals.portal")){
|
||||
if(args.length > 0){
|
||||
if(args[0].toLowerCase().equals("wand") || args[0].toLowerCase().equals("selector")){
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
|
||||
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("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have been given a \u00A7ePortal Region Selector\u00A7a!");
|
||||
}
|
||||
else if(args[0].toLowerCase().equals("portal") || args[0].toLowerCase().equals("portalblock")){
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
|
||||
ItemStack portalBlock = new ItemStack(Material.PORTAL, 1);
|
||||
|
||||
inventory.addItem(portalBlock);
|
||||
|
||||
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have been given a \u00A7ePortal Block\u00A7a!");
|
||||
}
|
||||
else if(args[0].toLowerCase().equals("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
|
||||
boolean hasName = false;
|
||||
boolean hasTriggerBlock = false;
|
||||
boolean hasDestination = false;
|
||||
boolean isBungeePortal = false;
|
||||
boolean needsPermission = false;
|
||||
String destination = null;
|
||||
String portalName = null;
|
||||
String triggerBlock = null;
|
||||
String serverName = null;
|
||||
String permission = null;
|
||||
|
||||
ArrayList<PortalArg> extraData = new ArrayList<PortalArg>();
|
||||
|
||||
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("\u00A7c[\u00A77AdvancedPortals\u00A7c] 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));
|
||||
}
|
||||
}
|
||||
if(!hasName){
|
||||
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] 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("\u00A7a[\u00A7eAdvancedPortals\u00A7a]\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)");
|
||||
}
|
||||
|
||||
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("\u00A7c[\u00A77AdvancedPortals\u00A7c] 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("\u00A7c[\u00A77AdvancedPortals\u00A7c] 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("\u00A7c[\u00A77AdvancedPortals\u00A7c] The points you have selected need to be in the same world!");
|
||||
}
|
||||
}
|
||||
else{
|
||||
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You need to have two points selected to make a portal!");
|
||||
}
|
||||
}
|
||||
else if(args[0].toLowerCase().equals("variables")) {
|
||||
player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Currently available variables: name, triggerBlock, destination");
|
||||
player.sendMessage("");
|
||||
player.sendMessage("\u00A7aExample command: \u00A7e/portal create name:test triggerId:portal");
|
||||
}
|
||||
else if(args[0].toLowerCase().equals("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("\u00A7c[\u00A77AdvancedPortals\u00A7c] 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("\u00A7a[\u00A7eAdvancedPortals\u00A7a] 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("\u00A7c[\u00A77AdvancedPortals\u00A7c] Portal selection cancelled!");
|
||||
}
|
||||
}
|
||||
else if(args[0].toLowerCase().equals("gui")){
|
||||
if(args.length > 1){
|
||||
if(args[1].toLowerCase().equals("remove") && args.length > 2){
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] Are you sure you would like to remove the portal \u00A7e" + args[2] + "\u00A7c?");
|
||||
sender.sendMessage("");
|
||||
plugin.nmsAccess.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("");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(args[0].toLowerCase().equals("edit")) {
|
||||
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "Portals.yml");
|
||||
if(args.length > 1){
|
||||
String posX = portalConfig.getConfig().getString(args[1] + ".pos1.X");
|
||||
if(posX != null){
|
||||
portalEditMenu(sender, portalConfig, args[1]);
|
||||
}
|
||||
else{
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] 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("\u00A7c[\u00A77AdvancedPortals\u00A7c] The portal you had selected no longer seems to exist!");
|
||||
player.removeMetadata("selectedPortal", plugin);
|
||||
}
|
||||
}
|
||||
else{
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal has been defined or selected!");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(args[0].toLowerCase().equals("rename")) {
|
||||
|
||||
// not finished yet /
|
||||
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "Portals.yml");
|
||||
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("\u00A7a[\u00A7eAdvancedPortals\u00A7a] 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("\u00A7c[\u00A77AdvancedPortals\u00A7c] There is already a portal with the name \u00A7e" + args[1] + "\u00A7c!");
|
||||
}
|
||||
else{
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The portal you had selected no longer seems to exist!");
|
||||
player.removeMetadata("selectedPortal", plugin);
|
||||
}
|
||||
}
|
||||
else{
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The portal you have selected is already called that!");
|
||||
}
|
||||
}
|
||||
else{
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal has been defined or selected!");
|
||||
}
|
||||
}
|
||||
else{
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You must select a portal first and then type \u00A7e/portal rename (new name)\u00A7c!");
|
||||
}
|
||||
}
|
||||
else if(args[0].toLowerCase().equals("remove")) {
|
||||
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "Portals.yml");
|
||||
if(args.length > 1){
|
||||
String posX = portalConfig.getConfig().getString(args[1] + ".pos1.X");
|
||||
if(posX != null){
|
||||
Portal.remove(args[1]);
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The portal \u00A7e" + args[1] + "\u00A7c has been removed!");
|
||||
}
|
||||
else{
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] 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("\u00A7c[\u00A77AdvancedPortals\u00A7c] The portal \u00A77" + portalName + " has been removed!");
|
||||
}
|
||||
else{
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The portal you had selected no longer seems to exist!");
|
||||
player.removeMetadata("selectedPortal", plugin);
|
||||
}
|
||||
}
|
||||
else{
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal has been defined or selected!");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(args[0].toLowerCase().equals("bukkitpage")) {
|
||||
player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Bukkit page: (insert bitly link)!");
|
||||
}
|
||||
else if(args[0].toLowerCase().equals("helppage")) {
|
||||
player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Help page: (insert bitly link)!");
|
||||
}
|
||||
else if(args[0].toLowerCase().equals("show")){
|
||||
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "Portals.yml");
|
||||
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("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal by that name exists!");
|
||||
}
|
||||
}
|
||||
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("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Your currently selected area has been shown, it will dissapear shortly!");
|
||||
Selection.Show(player, this.plugin);
|
||||
}
|
||||
else{
|
||||
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The points you have selected need to be in the same world!");
|
||||
}
|
||||
}
|
||||
else{
|
||||
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You need to have both points selected!");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(args[0].toLowerCase().equals("help")) {
|
||||
player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Reloaded values!");
|
||||
Listeners.reloadValues(plugin);
|
||||
Portal.loadPortals();
|
||||
}
|
||||
else{
|
||||
PluginMessages.UnknownCommand(sender, command);
|
||||
}
|
||||
}
|
||||
else{
|
||||
PluginMessages.UnknownCommand(sender, command);
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
PluginMessages.NoPermission(sender, command);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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("\u00A7a[\u00A7eAdvancedPortals\u00A7a] 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");
|
||||
}
|
||||
sender.sendMessage("");
|
||||
|
||||
Player player = (Player)sender;
|
||||
|
||||
plugin.nmsAccess.sendRawMessage("{text:\"\u00A7aFunctions\u00A7e: \",extra:[{text:\"\u00A7eRemove\",hoverEvent:{action:show_text,value:\"Remove the selected portal\"},clickEvent:{action:run_command,value:\"/portal gui remove " + portalName + "\"}}"
|
||||
+ ",{text:\" \"},{text:\"\u00A7eShow\",hoverEvent:{action:show_text,value:\"Show the selected portal\"},clickEvent:{action:run_command,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:run_command,value:\"/warp " + destination + "\"}}]}", player);
|
||||
|
||||
/**IChatBaseComponent comp = ChatSerializer.a("{text:\"\u00A7aFunctions\u00A7e: \",extra:[{text:\"\u00A7eRemove\",hoverEvent:{action:show_text,value:\"Remove the selected portal\"},clickEvent:{action:run_command,value:\"/portal gui remove " + portalName + "\"}}"
|
||||
+ ",{text:\" \"},{text:\"\u00A7eShow\",hoverEvent:{action:show_text,value:\"Show the selected portal\"},clickEvent:{action:run_command,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:run_command,value:\"/warp " + destination + "\"}}]}");
|
||||
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);*/
|
||||
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", "portal", "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;
|
||||
|
||||
for(int i = 1; i < args.length; i++){
|
||||
if(args[i].toLowerCase().startsWith("name:") && args[i].length() > 5){
|
||||
hasName = true;
|
||||
}
|
||||
else if(args[i].toLowerCase().startsWith("destination:") && args[i].length() > 12){
|
||||
hasDestination = true;
|
||||
}
|
||||
else if(args[i].toLowerCase().startsWith("desti:") && args[i].length() > 6){
|
||||
hasDestination = true;
|
||||
}
|
||||
else if(args[i].toLowerCase().startsWith("triggerblock:") && args[i].length() > 13){
|
||||
hasTriggerBlock = true;
|
||||
}
|
||||
else if(args[i].toLowerCase().startsWith("bungee:") && args[i].length() > 7){
|
||||
isBungeePortal = true;
|
||||
}
|
||||
else if(args[i].toLowerCase().startsWith("permission:") && args[i].length() > 11){
|
||||
needsPermission = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!hasName){autoComplete.add("name:");}
|
||||
if(!hasTriggerBlock){autoComplete.add("triggerblock:");}
|
||||
if(!hasDestination){autoComplete.add("destination:");autoComplete.add("desti:");}
|
||||
if(!isBungeePortal){autoComplete.add("bungee:");}
|
||||
if(!isBungeePortal){autoComplete.add("permission:");}
|
||||
}
|
||||
}
|
||||
Collections.sort(autoComplete);
|
||||
for(Object result: autoComplete.toArray()){
|
||||
if(!result.toString().startsWith(args[args.length - 1])){
|
||||
autoComplete.remove(result);
|
||||
}
|
||||
}
|
||||
return autoComplete;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,105 +0,0 @@
|
|||
package com.sekwah.advancedportals;
|
||||
|
||||
import com.sekwah.advancedportals.DataCollector.DataCollector;
|
||||
import com.sekwah.advancedportals.compat.NMS;
|
||||
import com.sekwah.advancedportals.destinations.Destination;
|
||||
import com.sekwah.advancedportals.metrics.Metrics;
|
||||
import com.sekwah.advancedportals.portals.Portal;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||
|
||||
public NMS nmsAccess;
|
||||
|
||||
public void onEnable() {
|
||||
|
||||
try {
|
||||
Metrics metrics = new Metrics(this);
|
||||
metrics.start();
|
||||
} catch (IOException e) {
|
||||
// Failed to submit the stats :-(
|
||||
}
|
||||
|
||||
this.getServer().getConsoleSender().sendMessage("\u00A7aAdvanced portals have been sucsessfully enabled!");
|
||||
|
||||
String packageName = getServer().getClass().getPackage().getName();
|
||||
String[] packageSplit = packageName.split("\\.");
|
||||
String version = packageSplit[packageSplit.length - 1];
|
||||
|
||||
try {
|
||||
Class<?> nmsClass = Class.forName("com.sekwah.advancedportals.compat." + version);
|
||||
if(NMS.class.isAssignableFrom(nmsClass)){
|
||||
this.nmsAccess = (NMS) nmsClass.getConstructor().newInstance();
|
||||
}else
|
||||
{
|
||||
System.out.println("Something went wrong, please notify the author and tell them this version v:" + version);
|
||||
this.setEnabled(false);
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
System.out.println("This version of craftbukkit is not yet supported, please notify the author and give version v:" + version);
|
||||
this.setEnabled(false);
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
new Assets(this);
|
||||
|
||||
// Opens a channel that messages bungeeCord
|
||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
|
||||
// thanks to the new config accessor code the config.saveDefaultConfig(); will now
|
||||
// only copy the file if it doesnt exist!
|
||||
ConfigAccessor config = new ConfigAccessor(this, "Config.yml");
|
||||
config.saveDefaultConfig();
|
||||
|
||||
ConfigAccessor portalconfig = new ConfigAccessor(this, "Portals.yml");
|
||||
portalconfig.saveDefaultConfig();
|
||||
|
||||
ConfigAccessor destinationconfig = new ConfigAccessor(this, "Destinations.yml");
|
||||
destinationconfig.saveDefaultConfig();
|
||||
|
||||
|
||||
// Loads the portal and destination editors
|
||||
new Portal(this);
|
||||
new Destination(this);
|
||||
|
||||
new DataCollector(this);
|
||||
|
||||
// These register the commands
|
||||
new AdvancedPortalsCommand(this);
|
||||
new DestinationCommand(this);
|
||||
new WarpCommand(this);
|
||||
|
||||
|
||||
// These register the listeners
|
||||
new Listeners(this);
|
||||
|
||||
new FlowStopper(this);
|
||||
new PortalProtect(this);
|
||||
new PortalPlacer(this);
|
||||
|
||||
Selection.LoadData(this);
|
||||
|
||||
DataCollector.setupMetrics();
|
||||
}
|
||||
|
||||
|
||||
public void onDisable() {
|
||||
this.getServer().getConsoleSender().sendMessage("\u00A7cAdvanced portals are being disabled!");
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package com.sekwah.advancedportals;
|
||||
|
||||
public class Assets {
|
||||
|
||||
public static int currentWarpParticles = 0;
|
||||
|
||||
public static int currentWarpSound = 0;
|
||||
|
||||
public Assets(AdvancedPortalsPlugin plugin) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
|
||||
currentWarpParticles = config.getConfig().getInt("WarpParticles");
|
||||
currentWarpSound = config.getConfig().getInt("WarpSound");
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
|
||||
Graph TotalWarps = metrics.createGraph("Total Warps");
|
||||
|
||||
TotalWarps.addPlotter(new Metrics.Plotter("Internal Warps") {
|
||||
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1; // number of warps
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
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,176 +0,0 @@
|
|||
package com.sekwah.advancedportals;
|
||||
|
||||
import com.sekwah.advancedportals.destinations.Destination;
|
||||
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.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class DestinationCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
private final int PortalMessagesDisplay;
|
||||
|
||||
private AdvancedPortalsPlugin plugin;
|
||||
|
||||
public DestinationCommand(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
plugin.getCommand("destination").setExecutor(this);
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
|
||||
|
||||
PortalMessagesDisplay = config.getConfig().getInt("WarpMessageDisplay");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String command, String[] args) {
|
||||
if(args.length > 0){
|
||||
if(args[0].toLowerCase().equals("create")){
|
||||
if(sender.hasPermission("AdvancedPortals.create")){
|
||||
if(args.length > 1){
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
|
||||
String posX = config.getConfig().getString(args[1].toLowerCase() + ".pos.X");
|
||||
if(posX == null){
|
||||
sender.sendMessage("§a[\u00A7eAdvancedPortals\u00A7a] You have created a new destination called \u00A7e" + args[1] + "!");
|
||||
Player player = sender.getServer().getPlayer(sender.getName());
|
||||
Destination.create(player.getLocation(), args[1]);
|
||||
}
|
||||
else{
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] A destination by that name already exists!");
|
||||
}
|
||||
}
|
||||
else{
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] Please state the name of the destination you would like to create!");
|
||||
}
|
||||
}
|
||||
else{
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You do not have permission to create portals so you cannot give yourself a \u00A7ePortal Region Selector\u00A7c!");
|
||||
}
|
||||
}
|
||||
else if(args[0].toLowerCase().equals("remove")) {
|
||||
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "Destinations.yml");
|
||||
if(args.length > 1){
|
||||
String posX = portalConfig.getConfig().getString(args[1] + ".pos.X");
|
||||
if(posX != null){
|
||||
Destination.remove(args[1]);
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The destination \u00A7e" + args[1] + "\u00A7c has been removed!");
|
||||
}
|
||||
else{
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No destination by that name exists.");
|
||||
}
|
||||
}
|
||||
else{
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You need to state the name of the destination you wish to remove.");
|
||||
}
|
||||
}
|
||||
else if(args[0].toLowerCase().equals("goto") || args[0].toLowerCase().equals("warp")) {
|
||||
if(args.length > 1){
|
||||
//System.out.println(args[1]);
|
||||
ConfigAccessor configDesti = new ConfigAccessor(plugin, "Destinations.yml");
|
||||
if(configDesti.getConfig().getString(args[1] + ".world") != null){
|
||||
Destination.warp(sender, args[1]);
|
||||
if(PortalMessagesDisplay == 1){
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have been warped to \u00A7e" + args[1].replaceAll("_", " ") + "\u00A7a.");
|
||||
sender.sendMessage("");
|
||||
}
|
||||
else if(PortalMessagesDisplay == 2){
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
|
||||
plugin.nmsAccess.sendActionBarMessage("{text:\"\u00A7aYou have warped to \u00A7e" + args[1].replaceAll("_", " ") + "\u00A7a.\"}", (Player) sender);
|
||||
/**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{
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No destination by that name exists.");
|
||||
}
|
||||
}
|
||||
else{
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You need to state the name of the destination you wish to teleport to.");
|
||||
}
|
||||
}
|
||||
else if(args[0].toLowerCase().equals("list")) {
|
||||
List<String> destiList = Destination.destiList();
|
||||
if(destiList.size() >= 1){
|
||||
if(args.length > 1){
|
||||
try
|
||||
{
|
||||
int page = Integer.parseInt(args[1]);
|
||||
if(page * 5 >= destiList.size() - 5){ // add this if statement so that the user cant select a list page higher than the max
|
||||
if(destiList.size() / 5 == destiList.size()){
|
||||
|
||||
}
|
||||
}
|
||||
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Showing destinations page 1 of 1");
|
||||
for(int i = (page - 1) * 5; i < page * 5; i++){
|
||||
if(i > destiList.size()){
|
||||
break;
|
||||
}
|
||||
sender.sendMessage(" \u00A7e" + destiList.get(i));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Showing destinations page 1 of 1");
|
||||
for(int i = 0; i < 5; i++){
|
||||
if(i > destiList.size()){
|
||||
break;
|
||||
}
|
||||
sender.sendMessage(" \u00A7e" + destiList.get(i));
|
||||
}
|
||||
|
||||
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Showing destinations page 1 of 1");
|
||||
for(int i = 0; i < 5; i++){
|
||||
if(i > destiList.size()){
|
||||
break;
|
||||
}
|
||||
sender.sendMessage(" \u00A7e" + destiList.get(i));
|
||||
}
|
||||
}
|
||||
else{
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] There are currently no defined destinations.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You need to type something after /" + command + ", if you do not know what you can put or would like some help with the commands please type /" + command + " help");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@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", "goto", "redefine", "move", "rename", "remove"));
|
||||
}
|
||||
else if(args[0].toLowerCase().equals("create")){
|
||||
}
|
||||
}
|
||||
Collections.sort(autoComplete);
|
||||
for(Object result: autoComplete.toArray()){
|
||||
if(!result.toString().startsWith(args[args.length - 1])){
|
||||
autoComplete.remove(result);
|
||||
}
|
||||
}
|
||||
return autoComplete;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
package com.sekwah.advancedportals;
|
||||
|
||||
import com.sekwah.advancedportals.portals.AdvancedPortal;
|
||||
import com.sekwah.advancedportals.portals.Portal;
|
||||
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.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
|
||||
// an example is in the interact event in this if statement if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("<EFBFBD>eP...
|
||||
private boolean WaterFlow = true;
|
||||
|
||||
public FlowStopper(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
|
||||
this.WaterFlow = config.getConfig().getBoolean("StopWaterFlow");
|
||||
|
||||
if(WaterFlow){
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockFromTo(BlockFromToEvent event) {
|
||||
// when checking positions check the block and the to block
|
||||
Block blockTo = event.getToBlock();
|
||||
Block block = event.getBlock();
|
||||
|
||||
for(AdvancedPortal portal : Portal.Portals){
|
||||
if(portal.worldName.equals(block.getWorld().getName())){
|
||||
|
||||
if((portal.pos1.getX() + 3D) >= block.getX() && (portal.pos1.getY() + 3D) >= block.getY() && (portal.pos1.getZ() + 3D) >= block.getZ()){
|
||||
|
||||
if((portal.pos2.getX() - 3D) <= block.getX() && (portal.pos2.getY() - 3D) <= block.getY() && (portal.pos2.getZ() - 3D) <= block.getZ()){
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(portal.worldName.equals(blockTo.getWorld().getName())){
|
||||
|
||||
if((portal.pos1.getX() + 3D) >= blockTo.getX() && (portal.pos1.getY() + 3D) >= blockTo.getY() && (portal.pos1.getZ() + 3D) >= blockTo.getZ()){
|
||||
|
||||
if((portal.pos2.getX() - 3D) <= blockTo.getX() && (portal.pos2.getY() - 3D) <= blockTo.getY() && (portal.pos2.getZ() - 3D) <= blockTo.getZ()){
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,260 +0,0 @@
|
|||
package com.sekwah.advancedportals;
|
||||
|
||||
import com.sekwah.advancedportals.events.WarpEvent;
|
||||
import com.sekwah.advancedportals.portals.AdvancedPortal;
|
||||
import com.sekwah.advancedportals.portals.Portal;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
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;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerPortalEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
public class Listeners implements Listener {
|
||||
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
private int PortalMessagesDisplay = 2;
|
||||
|
||||
// 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 static boolean ShowBungeeMessage;
|
||||
|
||||
@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");
|
||||
|
||||
PortalMessagesDisplay = config.getConfig().getInt("WarpMessageDisplay");
|
||||
|
||||
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");
|
||||
|
||||
ShowBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage");
|
||||
|
||||
String ItemID = config.getConfig().getString("AxeItemId");
|
||||
|
||||
try
|
||||
{
|
||||
WandMaterial = Material.getMaterial(Integer.parseInt(ItemID));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
WandMaterial = Material.getMaterial(ItemID);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onMoveEvent(PlayerMoveEvent event) {
|
||||
// will check if the player is in the portal or not.
|
||||
if(Portal.portalsActive){
|
||||
Player player = event.getPlayer();
|
||||
Location fromloc = event.getFrom();
|
||||
Location loc = event.getTo();
|
||||
Location eyeloc = event.getTo();
|
||||
//System.out.println(loc.getBlock().getType()); // for debugging, remove or comment out when not needed
|
||||
eyeloc.setY(eyeloc.getY() + player.getEyeHeight());
|
||||
AdvancedPortal[] portals = Portal.Portals;
|
||||
for(AdvancedPortal portal : portals){
|
||||
if(portal.worldName.equals(loc.getWorld().getName())){
|
||||
if(portal.trigger.equals(loc.getBlock().getType())
|
||||
|| portal.trigger.equals(eyeloc.getBlock().getType())){
|
||||
if((portal.pos1.getX() + 1D) >= loc.getX() && (portal.pos1.getY() + 1D) >= loc.getY() && (portal.pos1.getZ() + 1D) >= loc.getZ()){
|
||||
if(portal.pos2.getX() <= loc.getX() && portal.pos2.getY() <= loc.getY() && portal.pos2.getZ() <= loc.getZ()){
|
||||
|
||||
|
||||
WarpEvent warpEvent = new WarpEvent(player, portal.portalName);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
boolean warped = Portal.activate(player, portal.portalName);
|
||||
if(PortalMessagesDisplay == 1 && warped){
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
||||
player.sendMessage("");
|
||||
player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have been warped to \u00A7e" + config.getConfig().getString(portal.portalName + ".destination").replaceAll("_", " ") + "\u00A7.");
|
||||
player.sendMessage("");
|
||||
}
|
||||
else if(PortalMessagesDisplay == 2 && warped){
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
||||
plugin.nmsAccess.sendActionBarMessage("{text:\"\u00A7aYou have been warped to \u00A7e" + config.getConfig().getString(portal.portalName + ".destination").replaceAll("_", " ") + "\u00A7a.\"}", player);
|
||||
/**plugin.nmsAccess.sendActionBarMessage("[{text:\"You have warped to \",color:green},{text:\"" + config.getConfig().getString(portal.portalName + ".destination").replaceAll("_", " ")
|
||||
+ "\",color:yellow},{\"text\":\".\",color:green}]", player);*/
|
||||
}
|
||||
|
||||
if(!warped){
|
||||
player.teleport(fromloc);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(portal.trigger.equals(Material.PORTAL)){
|
||||
final Player finalplayer = event.getPlayer();
|
||||
if(player.getGameMode().equals(GameMode.CREATIVE)){
|
||||
player.setMetadata("HasWarped", new FixedMetadataValue(plugin, true));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||
public void run(){
|
||||
finalplayer.removeMetadata("HasWarped", plugin);
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler
|
||||
public void onPortalEvent(PlayerPortalEvent event) {
|
||||
|
||||
if(Portal.portalsActive){
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(player.hasMetadata("HasWarped")){
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Location loc = player.getLocation();
|
||||
Object[] portals = Portal.Portals;
|
||||
for(AdvancedPortal portal : Portal.Portals){
|
||||
if(portal.worldName.equals(player.getWorld().getName())){
|
||||
|
||||
if((portal.pos1.getX() + 1D) >= loc.getX() && (portal.pos1.getY() + 1D) >= loc.getY() && (portal.pos1.getZ() + 1D) >= loc.getZ()){
|
||||
|
||||
if((portal.pos2.getX()) <= loc.getX() && (portal.pos2.getY()) <= loc.getY() && (portal.pos2.getZ()) <= loc.getZ()){
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@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)){
|
||||
Block block = event.getClickedBlock();
|
||||
for(AdvancedPortal portal : Portal.Portals){
|
||||
if(portal.worldName.equals(block.getWorld().getName())){
|
||||
|
||||
if((portal.pos1.getX() + 3D) >= block.getX() && (portal.pos1.getY() + 3D) >= block.getY() && (portal.pos1.getZ() + 3D) >= block.getZ()){
|
||||
|
||||
if((portal.pos2.getX() - 3D) <= block.getX() && (portal.pos2.getY() - 3D) <= block.getY() && (portal.pos2.getZ() - 3D) <= block.getZ()){
|
||||
player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have selected: \u00A7e" + portal.portalName);
|
||||
player.removeMetadata("selectingPortal", plugin);
|
||||
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("\u00A7c[\u00A77AdvancedPortals\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.
|
||||
if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("\u00A7ePortal Region Selector")) && event.getPlayer().getItemInHand().getTypeId() == WandMaterial.getId()) {
|
||||
|
||||
// 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)
|
||||
return;
|
||||
}
|
||||
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)
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package com.sekwah.advancedportals;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class PluginMessages {
|
||||
|
||||
// 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 void UnknownCommand(CommandSender sender, String command) {
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] 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");
|
||||
}
|
||||
|
||||
public static void NoPermission(CommandSender sender, String command) {
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You do not have permission to perform that command!");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
package com.sekwah.advancedportals;
|
||||
|
||||
import com.sekwah.advancedportals.portals.AdvancedPortal;
|
||||
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 double 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().getDouble("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)
|
||||
{
|
||||
for(AdvancedPortal portal : Portal.Portals){
|
||||
if(portal.worldName.equals(block.getWorld().getName())){
|
||||
|
||||
if((portal.pos1.getX() + PortalProtectionRadius) >= block.getX() && (portal.pos1.getY() + PortalProtectionRadius) >= block.getY() && (portal.pos1.getZ() + PortalProtectionRadius) >= block.getZ()){
|
||||
|
||||
if((portal.pos2.getX() - PortalProtectionRadius) <= block.getX() && (portal.pos2.getY() - PortalProtectionRadius) <= block.getY() && (portal.pos2.getZ() - PortalProtectionRadius) <= block.getZ()){
|
||||
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//event.getChangedType();
|
||||
//event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
package com.sekwah.advancedportals;
|
||||
|
||||
import com.sekwah.advancedportals.portals.AdvancedPortal;
|
||||
import com.sekwah.advancedportals.portals.Portal;
|
||||
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.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PortalProtect implements Listener {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
// 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 PortalProtect = true;
|
||||
|
||||
private double PortalProtectionRadius = 5D;
|
||||
|
||||
public PortalProtect(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
|
||||
this.PortalProtect = config.getConfig().getBoolean("PortalProtection");
|
||||
|
||||
this.PortalProtectionRadius = config.getConfig().getDouble("PortalProtectionRadius");
|
||||
|
||||
if(PortalProtect){
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockBreak(BlockBreakEvent event){
|
||||
|
||||
if(!event.getPlayer().hasPermission("advancedportals.build")){
|
||||
Block block = event.getBlock();
|
||||
|
||||
for(AdvancedPortal portal : Portal.Portals){
|
||||
if(portal.worldName.equals(block.getWorld().getName())){
|
||||
|
||||
if((portal.pos1.getX() + PortalProtectionRadius) >= block.getX() && (portal.pos1.getY() + PortalProtectionRadius) >= block.getY() && (portal.pos1.getZ() + PortalProtectionRadius) >= block.getZ()){
|
||||
|
||||
if((portal.pos2.getX() - PortalProtectionRadius) <= block.getX() && (portal.pos2.getY() - PortalProtectionRadius) <= block.getY() && (portal.pos2.getZ() - PortalProtectionRadius) <= block.getZ()){
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockPlace(BlockPlaceEvent event){
|
||||
|
||||
if(!event.getPlayer().hasPermission("advancedportals.build")){
|
||||
Block block = event.getBlock();
|
||||
|
||||
for(AdvancedPortal portal : Portal.Portals){
|
||||
if(portal.worldName.equals(block.getWorld().getName())){
|
||||
|
||||
if((portal.pos1.getX() + PortalProtectionRadius) >= block.getX() && (portal.pos1.getY() + PortalProtectionRadius) >= block.getY() && (portal.pos1.getZ() + PortalProtectionRadius) >= block.getZ()){
|
||||
|
||||
if((portal.pos2.getX() - PortalProtectionRadius) <= block.getX() && (portal.pos2.getY() - PortalProtectionRadius) <= block.getY() && (portal.pos2.getZ() - PortalProtectionRadius) <= block.getZ()){
|
||||
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onExplosion(EntityExplodeEvent event){
|
||||
List<Block> blockList = event.blockList();
|
||||
for (int i = 0; i < blockList.size(); i++) {
|
||||
Block block = blockList.get(i);
|
||||
Object[] portals = Portal.Portals;
|
||||
for(AdvancedPortal portal : Portal.Portals){ // change for format for(int i = 0; i < portals.length; i++){
|
||||
if(portal.worldName.equals(block.getWorld().getName())){
|
||||
|
||||
if((portal.pos1.getX() + PortalProtectionRadius) >= block.getX() && (portal.pos1.getY() + PortalProtectionRadius) >= block.getY() && (portal.pos1.getZ() + PortalProtectionRadius) >= block.getZ()){
|
||||
|
||||
if((portal.pos2.getX() - PortalProtectionRadius) <= block.getX() && (portal.pos2.getY() - PortalProtectionRadius) <= block.getY() && (portal.pos2.getZ() - PortalProtectionRadius) <= block.getZ()){
|
||||
blockList.remove(i);
|
||||
i--;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,280 +0,0 @@
|
|||
package com.sekwah.advancedportals;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Selection {
|
||||
|
||||
public static Material blockType = Material.WOOL;
|
||||
public static int timeout = 10;
|
||||
public static byte metadata = 14;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
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);
|
||||
}
|
||||
|
||||
if(blockType == null){
|
||||
blockType = Material.STAINED_GLASS;
|
||||
}
|
||||
|
||||
metadata = (byte) config.getConfig().getInt("ShowSelectionBlockData");
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void Show(final Player player, final AdvancedPortalsPlugin plugin, String portalName) {
|
||||
|
||||
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "Portals.yml");
|
||||
|
||||
int LowX = portalConfig.getConfig().getInt(portalName + ".pos2.X");
|
||||
int LowY = portalConfig.getConfig().getInt(portalName + ".pos2.Y");
|
||||
int LowZ = portalConfig.getConfig().getInt(portalName + ".pos2.Z");
|
||||
|
||||
int HighX = portalConfig.getConfig().getInt(portalName + ".pos1.X");
|
||||
int HighY = portalConfig.getConfig().getInt(portalName + ".pos1.Y");
|
||||
int HighZ = portalConfig.getConfig().getInt(portalName + ".pos1.Z");
|
||||
|
||||
final Location pos1 = new Location(player.getWorld(), LowX, LowY, LowZ);
|
||||
final Location pos2 = new Location(player.getWorld(), HighX, HighY, HighZ);
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
for(int x = LowX; x <= HighX; x++){
|
||||
Location loc = new Location(player.getWorld(), x, LowY, LowZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
for(int x = LowX; x <= HighX; x++){
|
||||
Location loc = new Location(player.getWorld(), x, LowY, HighZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
for(int z = LowZ; z <= HighZ; z++){
|
||||
Location loc = new Location(player.getWorld(), LowX, LowY, z);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
for(int z = LowZ; z <= HighZ; z++){
|
||||
Location loc = new Location(player.getWorld(), HighX, LowY, z);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
for(int y = LowY; y <= HighY; y++){
|
||||
Location loc = new Location(player.getWorld(), LowX, y, LowZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
for(int y = LowY; y <= HighY; y++){
|
||||
Location loc = new Location(player.getWorld(), LowX, y, HighZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
for(int y = LowY; y <= HighY; y++){
|
||||
Location loc = new Location(player.getWorld(), HighX, y, LowZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
for(int y = LowY; y <= HighY; y++){
|
||||
Location loc = new Location(player.getWorld(), HighX, y, HighZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
for(int x = LowX; x <= HighX; x++){
|
||||
Location loc = new Location(player.getWorld(), x, HighY, HighZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
for(int x = LowX; x <= HighX; x++){
|
||||
Location loc = new Location(player.getWorld(), x, HighY, LowZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
for(int z = LowZ; z <= HighZ; z++){
|
||||
Location loc = new Location(player.getWorld(), LowX, HighY, z);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
for(int z = LowZ; z <= HighZ; z++){
|
||||
Location loc = new Location(player.getWorld(), HighX, HighY, z);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||
public void run(){
|
||||
Selection.Hide(player, plugin, pos1, pos2);
|
||||
}
|
||||
}, timeout * 20);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void Show(final Player player, final AdvancedPortalsPlugin plugin) {
|
||||
|
||||
int LowX = 0;
|
||||
int LowY = 0;
|
||||
int LowZ = 0;
|
||||
|
||||
int HighX = 0;
|
||||
int HighY = 0;
|
||||
int HighZ = 0;
|
||||
|
||||
if(player.getMetadata("Pos1X").get(0).asInt() > player.getMetadata("Pos2X").get(0).asInt()){
|
||||
LowX = player.getMetadata("Pos2X").get(0).asInt();
|
||||
HighX = player.getMetadata("Pos1X").get(0).asInt();
|
||||
}
|
||||
else{
|
||||
LowX = player.getMetadata("Pos1X").get(0).asInt();
|
||||
HighX = player.getMetadata("Pos2X").get(0).asInt();
|
||||
}
|
||||
if(player.getMetadata("Pos1Y").get(0).asInt() > player.getMetadata("Pos2Y").get(0).asInt()){
|
||||
LowY = player.getMetadata("Pos2Y").get(0).asInt();
|
||||
HighY = player.getMetadata("Pos1Y").get(0).asInt();
|
||||
}
|
||||
else{
|
||||
LowY = player.getMetadata("Pos1Y").get(0).asInt();
|
||||
HighY = player.getMetadata("Pos2Y").get(0).asInt();
|
||||
}
|
||||
if(player.getMetadata("Pos1Z").get(0).asInt() > player.getMetadata("Pos2Z").get(0).asInt()){
|
||||
LowZ = player.getMetadata("Pos2Z").get(0).asInt();
|
||||
HighZ = player.getMetadata("Pos1Z").get(0).asInt();
|
||||
}
|
||||
else{
|
||||
LowZ = player.getMetadata("Pos1Z").get(0).asInt();
|
||||
HighZ = player.getMetadata("Pos2Z").get(0).asInt();
|
||||
}
|
||||
|
||||
final Location pos1 = new Location(player.getWorld(), LowX, LowY, LowZ);
|
||||
final Location pos2 = new Location(player.getWorld(), HighX, HighY, HighZ);
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
for(int x = LowX; x <= HighX; x++){
|
||||
Location loc = new Location(player.getWorld(), x, LowY, LowZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
for(int x = LowX; x <= HighX; x++){
|
||||
Location loc = new Location(player.getWorld(), x, LowY, HighZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
for(int z = LowZ; z <= HighZ; z++){
|
||||
Location loc = new Location(player.getWorld(), LowX, LowY, z);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
for(int z = LowZ; z <= HighZ; z++){
|
||||
Location loc = new Location(player.getWorld(), HighX, LowY, z);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
for(int y = LowY; y <= HighY; y++){
|
||||
Location loc = new Location(player.getWorld(), LowX, y, LowZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
for(int y = LowY; y <= HighY; y++){
|
||||
Location loc = new Location(player.getWorld(), LowX, y, HighZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
for(int y = LowY; y <= HighY; y++){
|
||||
Location loc = new Location(player.getWorld(), HighX, y, LowZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
for(int y = LowY; y <= HighY; y++){
|
||||
Location loc = new Location(player.getWorld(), HighX, y, HighZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
for(int x = LowX; x <= HighX; x++){
|
||||
Location loc = new Location(player.getWorld(), x, HighY, HighZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
for(int x = LowX; x <= HighX; x++){
|
||||
Location loc = new Location(player.getWorld(), x, HighY, LowZ);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
for(int z = LowZ; z <= HighZ; z++){
|
||||
Location loc = new Location(player.getWorld(), LowX, HighY, z);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
for(int z = LowZ; z <= HighZ; z++){
|
||||
Location loc = new Location(player.getWorld(), HighX, HighY, z);
|
||||
player.sendBlockChange(loc, blockType, metadata);
|
||||
}
|
||||
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||
public void run(){
|
||||
Selection.Hide(player, plugin, pos1, pos2);
|
||||
}
|
||||
}, timeout * 20);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected static void Hide(Player player, AdvancedPortalsPlugin plugin, Location pos1, Location pos2) {
|
||||
|
||||
int LowX = pos1.getBlockX();
|
||||
int LowY = pos1.getBlockY();
|
||||
int LowZ = pos1.getBlockZ();
|
||||
|
||||
int HighX = pos2.getBlockX();
|
||||
int HighY = pos2.getBlockY();
|
||||
int HighZ = pos2.getBlockZ();
|
||||
|
||||
for(int x = LowX; x <= HighX; x++){
|
||||
Location loc = new Location(player.getWorld(), x, LowY, LowZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for(int x = LowX; x <= HighX; x++){
|
||||
Location loc = new Location(player.getWorld(), x, LowY, HighZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for(int z = LowZ; z <= HighZ; z++){
|
||||
Location loc = new Location(player.getWorld(), LowX, LowY, z);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for(int z = LowZ; z <= HighZ; z++){
|
||||
Location loc = new Location(player.getWorld(), HighX, LowY, z);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for(int y = LowY; y <= HighY; y++){
|
||||
Location loc = new Location(player.getWorld(), LowX, y, LowZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for(int y = LowY; y <= HighY; y++){
|
||||
Location loc = new Location(player.getWorld(), LowX, y, HighZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for(int y = LowY; y <= HighY; y++){
|
||||
Location loc = new Location(player.getWorld(), HighX, y, LowZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for(int y = LowY; y <= HighY; y++){
|
||||
Location loc = new Location(player.getWorld(), HighX, y, HighZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for(int x = LowX; x <= HighX; x++){
|
||||
Location loc = new Location(player.getWorld(), x, HighY, HighZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for(int x = LowX; x <= HighX; x++){
|
||||
Location loc = new Location(player.getWorld(), x, HighY, LowZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for(int z = LowZ; z <= HighZ; z++){
|
||||
Location loc = new Location(player.getWorld(), LowX, HighY, z);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for(int z = LowZ; z <= HighZ; z++){
|
||||
Location loc = new Location(player.getWorld(), HighX, HighY, z);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
package com.sekwah.advancedportals;
|
||||
|
||||
import com.sekwah.advancedportals.destinations.Destination;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class WarpCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private AdvancedPortalsPlugin plugin;
|
||||
|
||||
public WarpCommand(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
plugin.getCommand("warp").setExecutor(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String command, String[] args) {
|
||||
if(args.length > 0){
|
||||
if(Destination.warp(sender, args[0], false)){
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have been warped to \u00A7e" + args[0] + "\u00A7a.");
|
||||
sender.sendMessage("");
|
||||
}
|
||||
else{
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The destination you tried to warp to does not exist!");
|
||||
sender.sendMessage("");
|
||||
}
|
||||
}
|
||||
else{
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You need to type a destination after /" + command + "!");
|
||||
sender.sendMessage("");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@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", "goto", "redefine", "move", "rename", "remove"));
|
||||
}
|
||||
else if(args[0].toLowerCase().equals("create")){
|
||||
}
|
||||
}
|
||||
Collections.sort(autoComplete);
|
||||
for(Object result: autoComplete.toArray()){
|
||||
if(!result.toString().startsWith(args[args.length - 1])){
|
||||
autoComplete.remove(result);
|
||||
}
|
||||
}*/
|
||||
return autoComplete;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
package com.sekwah.advancedportals.compat;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface NMS {
|
||||
|
||||
public void sendRawMessage(String rawMessage, Player player);
|
||||
|
||||
public void sendActionBarMessage(String rawMessage, Player player);
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package com.sekwah.advancedportals.compat;
|
||||
|
||||
import net.minecraft.server.v1_7_R1.ChatSerializer;
|
||||
import net.minecraft.server.v1_7_R1.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_7_R1.PacketPlayOutChat;
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class v1_7_R1 implements NMS {
|
||||
|
||||
@Override
|
||||
public void sendRawMessage(String rawMessage, Player player) {
|
||||
IChatBaseComponent comp = ChatSerializer.a(rawMessage);
|
||||
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionBarMessage(String rawMessage, Player player) {
|
||||
IChatBaseComponent comp = ChatSerializer.a(" " + rawMessage);
|
||||
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package com.sekwah.advancedportals.compat;
|
||||
|
||||
import net.minecraft.server.v1_7_R2.ChatSerializer;
|
||||
import net.minecraft.server.v1_7_R2.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_7_R2.PacketPlayOutChat;
|
||||
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class v1_7_R2 implements NMS {
|
||||
|
||||
@Override
|
||||
public void sendRawMessage(String rawMessage, Player player) {
|
||||
IChatBaseComponent comp = ChatSerializer.a(rawMessage);
|
||||
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionBarMessage(String rawMessage, Player player) {
|
||||
IChatBaseComponent comp = ChatSerializer.a(" " + rawMessage);
|
||||
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package com.sekwah.advancedportals.compat;
|
||||
|
||||
import net.minecraft.server.v1_7_R3.ChatSerializer;
|
||||
import net.minecraft.server.v1_7_R3.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_7_R3.PacketPlayOutChat;
|
||||
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class v1_7_R3 implements NMS {
|
||||
|
||||
@Override
|
||||
public void sendRawMessage(String rawMessage, Player player) {
|
||||
IChatBaseComponent comp = ChatSerializer.a(rawMessage);
|
||||
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionBarMessage(String rawMessage, Player player) {
|
||||
IChatBaseComponent comp = ChatSerializer.a(" " + rawMessage);
|
||||
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package com.sekwah.advancedportals.compat;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.ChatSerializer;
|
||||
import net.minecraft.server.v1_7_R4.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutChat;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class v1_7_R4 implements NMS {
|
||||
|
||||
@Override
|
||||
public void sendRawMessage(String rawMessage, Player player) {
|
||||
IChatBaseComponent comp = ChatSerializer.a(rawMessage);
|
||||
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionBarMessage(String rawMessage, Player player) {
|
||||
IChatBaseComponent comp = ChatSerializer.a(" " + rawMessage);
|
||||
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package com.sekwah.advancedportals.compat;
|
||||
|
||||
import net.minecraft.server.v1_8_R1.ChatSerializer;
|
||||
import net.minecraft.server.v1_8_R1.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_8_R1.PacketPlayOutChat;
|
||||
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class v1_8_R1 implements NMS {
|
||||
|
||||
@Override
|
||||
public void sendRawMessage(String rawMessage, Player player) {
|
||||
IChatBaseComponent comp = 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);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendActionBarMessage(String rawMessage, Player player) {
|
||||
IChatBaseComponent comp = 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) 2);
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package com.sekwah.advancedportals.compat;
|
||||
|
||||
import net.minecraft.server.v1_8_R2.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_8_R2.PacketPlayOutChat;
|
||||
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class v1_8_R2 implements NMS {
|
||||
|
||||
@Override
|
||||
public void sendRawMessage(String rawMessage, Player player) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendActionBarMessage(String rawMessage, Player player) {
|
||||
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) 2);
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
}
|
|
@ -1,201 +0,0 @@
|
|||
package com.sekwah.advancedportals.destinations;
|
||||
|
||||
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.ConfigAccessor;
|
||||
import com.sekwah.advancedportals.effects.WarpEffects;
|
||||
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 java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Destination {
|
||||
|
||||
private static AdvancedPortalsPlugin plugin;
|
||||
|
||||
public Destination(AdvancedPortalsPlugin plugin) {
|
||||
Destination.plugin = plugin;
|
||||
}
|
||||
|
||||
public static void create(Location location, String name){
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".world", location.getWorld().getName());
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.X", location.getX());
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.Y", location.getY());
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.Z", location.getZ());
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.pitch", location.getPitch());
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.yaw", location.getYaw());
|
||||
|
||||
config.saveConfig();
|
||||
}
|
||||
|
||||
public static void move(Location location, String name){
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".world", location.getWorld().getName());
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.X", location.getX());
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.Y", location.getY());
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.Z", location.getZ());
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.pitch", location.getPitch());
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.yaw", location.getYaw());
|
||||
|
||||
config.saveConfig();
|
||||
}
|
||||
|
||||
public static void rename(String oldName, String newName){
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
|
||||
|
||||
config.getConfig().set(newName.toLowerCase() + ".world", config.getConfig().getString(oldName + ".world"));
|
||||
|
||||
config.getConfig().set(newName.toLowerCase() + ".pos.X", config.getConfig().getDouble(oldName + ".pos.X"));
|
||||
config.getConfig().set(newName.toLowerCase() + ".pos.Y", config.getConfig().getDouble(oldName + ".pos.Y"));
|
||||
config.getConfig().set(newName.toLowerCase() + ".pos.Z", config.getConfig().getDouble(oldName + ".pos.Z"));
|
||||
|
||||
config.getConfig().set(newName.toLowerCase() + ".pos.pitch", config.getConfig().getDouble(oldName + ".pos.pitch"));
|
||||
config.getConfig().set(newName.toLowerCase() + ".pos.yaw", config.getConfig().getDouble(oldName + ".pos.yaw"));
|
||||
|
||||
remove(oldName);
|
||||
|
||||
config.saveConfig();
|
||||
}
|
||||
|
||||
public static void remove(String name){
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".world", null);
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.X", null);
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.Y", null);
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.Z", null);
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.pitch", null);
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.yaw", null);
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".pos", null);
|
||||
|
||||
config.getConfig().set(name.toLowerCase(), null);
|
||||
|
||||
config.saveConfig();
|
||||
}
|
||||
|
||||
public static boolean warp(Player player, String name, boolean senderror){
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
|
||||
if(config.getConfig().getString(name + ".world") != null){
|
||||
Location loc = player.getLocation();
|
||||
if(Bukkit.getWorld(config.getConfig().getString(name + ".world")) != null){
|
||||
loc.setWorld(Bukkit.getWorld(config.getConfig().getString(name + ".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.setPitch((float) config.getConfig().getDouble(name + ".pos.pitch"));
|
||||
loc.setYaw((float) config.getConfig().getDouble(name + ".pos.yaw"));
|
||||
|
||||
WarpEffects.activateParticles(player);
|
||||
WarpEffects.activateSound(player);
|
||||
Chunk c = loc.getChunk();
|
||||
Entity riding = player.getVehicle();
|
||||
if (!c.isLoaded()) c.load();
|
||||
if(player.getVehicle() != null){
|
||||
riding.eject();
|
||||
riding.teleport(loc);
|
||||
player.teleport(loc);
|
||||
riding.setPassenger(player);
|
||||
}
|
||||
else{
|
||||
player.teleport(loc);
|
||||
}
|
||||
WarpEffects.activateParticles(player);
|
||||
WarpEffects.activateSound(player);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
if(senderror){
|
||||
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\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!");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(senderror){
|
||||
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] There has been a problem warping you to the selected destination!");
|
||||
plugin.getLogger().log(Level.SEVERE, "The destination '" + name + "' has just had a warp "
|
||||
+ "attempt and either the data is corrupt or that destination doesn't exist!");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as other warp but changes sender to player for you.
|
||||
*
|
||||
* @param player
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static boolean warp(Player player, String name) {
|
||||
return warp(player, name, true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as other warp but changes sender to player for you.
|
||||
*
|
||||
* @param sender
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static boolean warp(CommandSender sender, String name, boolean senderror) {
|
||||
Player player = (Player)sender;
|
||||
return warp(player, name, senderror);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as other warp but changes sender to player for you.
|
||||
*
|
||||
* @param sender
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static boolean warp(CommandSender sender, String name) {
|
||||
Player player = (Player)sender;
|
||||
return warp(player, name, true);
|
||||
|
||||
}
|
||||
|
||||
public static List<String> destiList(){
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
|
||||
|
||||
LinkedList<String> destiList = new LinkedList<String>();
|
||||
|
||||
Set<String> destiSet = config.getConfig().getKeys(false);
|
||||
if(destiSet.size() > 0){
|
||||
for(Object desti: destiSet.toArray()){
|
||||
destiSet.add(desti.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(destiList);
|
||||
return destiList;
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package com.sekwah.advancedportals.effects;
|
||||
|
||||
import com.sekwah.advancedportals.Assets;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class WarpEffects {
|
||||
|
||||
public static void activateParticles(Player player) {
|
||||
Location loc = player.getLocation();
|
||||
World world = player.getWorld();
|
||||
switch (Assets.currentWarpParticles){
|
||||
case 1:
|
||||
for(int i = 0; i < 10; i++){
|
||||
world.playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
}
|
||||
loc.add(0D, 1D, 0D);
|
||||
for(int i = 0; i < 10; i++){
|
||||
world.playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void activateSound(Player player) {
|
||||
Location loc = player.getLocation();
|
||||
World world = player.getWorld();
|
||||
switch (Assets.currentWarpParticles){
|
||||
case 1:
|
||||
world.playSound(loc, Sound.ENDERMAN_TELEPORT, 1F, 1F);
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,748 +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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
int playersOnline = Bukkit.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,21 +0,0 @@
|
|||
package com.sekwah.advancedportals.portals;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class AdvancedPortal {
|
||||
|
||||
public Material trigger = null;
|
||||
|
||||
public String worldName = null;
|
||||
|
||||
public Location pos1 = null;
|
||||
|
||||
public Location pos2 = null;
|
||||
|
||||
public String portalName = null;
|
||||
|
||||
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
|
||||
}
|
|
@ -1,409 +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.destinations.Destination;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Portal {
|
||||
|
||||
private static AdvancedPortalsPlugin plugin;
|
||||
|
||||
public static boolean portalsActive = true;
|
||||
|
||||
public static AdvancedPortal[] Portals;
|
||||
|
||||
private static boolean ShowBungeeMessage;
|
||||
|
||||
public Portal(AdvancedPortalsPlugin plugin) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
|
||||
ShowBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage");
|
||||
|
||||
Portal.plugin = plugin;
|
||||
Portal.loadPortals();
|
||||
}
|
||||
|
||||
/**
|
||||
* This can be used to move the get keys to different sections
|
||||
*
|
||||
* ConfigurationSection section = config.getSection("sectionname");
|
||||
*
|
||||
* section.getKeys(false);
|
||||
*
|
||||
*/
|
||||
|
||||
public static void loadPortals(){
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
||||
Set<String> PortalSet = config.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()){
|
||||
|
||||
Material blockType = Material.PORTAL;
|
||||
String BlockID = config.getConfig().getString(portal.toString() + ".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;
|
||||
}
|
||||
|
||||
Portals[portalId].trigger = blockType;
|
||||
Portals[portalId].portalName = portal.toString();
|
||||
Portals[portalId].worldName = config.getConfig().getString(portal.toString() + ".world");
|
||||
World world = Bukkit.getWorld(config.getConfig().getString(portal.toString() + ".world"));
|
||||
Portals[portalId].pos1 = new Location(world, config.getConfig().getInt(portal.toString() + ".pos1.X"), config.getConfig().getInt(portal.toString() + ".pos1.Y"), config.getConfig().getInt(portal.toString() + ".pos1.Z"));
|
||||
Portals[portalId].pos2 = new Location(world, config.getConfig().getInt(portal.toString() + ".pos2.X"), config.getConfig().getInt(portal.toString() + ".pos2.Y"), config.getConfig().getInt(portal.toString() + ".pos2.Z"));
|
||||
|
||||
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!";
|
||||
}
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
||||
|
||||
config.getConfig().set(name + ".world", pos1.getWorld().getName());
|
||||
|
||||
config.getConfig().set(name + ".triggerblock", checkMaterial(triggerBlock));
|
||||
|
||||
config.getConfig().set(name + ".destination", destination);
|
||||
|
||||
config.getConfig().set(name + ".bungee", serverName);
|
||||
|
||||
config.getConfig().set(name + ".pos1.X", HighX);
|
||||
config.getConfig().set(name + ".pos1.Y", HighY);
|
||||
config.getConfig().set(name + ".pos1.Z", HighZ);
|
||||
|
||||
config.getConfig().set(name + ".pos2.X", LowX);
|
||||
config.getConfig().set(name + ".pos2.Y", LowY);
|
||||
config.getConfig().set(name + ".pos2.Z", LowZ);
|
||||
|
||||
for(PortalArg arg: portalArgs){
|
||||
config.getConfig().set(name + ".portalArgs." + arg.argName, arg.value);
|
||||
}
|
||||
|
||||
config.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();
|
||||
}
|
||||
|
||||
public static String create(Location pos1, Location pos2, String portalName, String name, String destination, PortalArg... extraData) {
|
||||
return create(pos1, pos2, name, destination,(String) null);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static String create(Location pos1, Location pos2, String name, String destination, String serverName) { // 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 config so that the application can use them
|
||||
|
||||
String result = create(pos1, pos2, name, destination, triggerBlockType, serverName);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void redefine(Location pos1, Location pos2, String name){
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
||||
|
||||
config.getConfig().set(name + ".pos1.X", pos1.getX());
|
||||
config.getConfig().set(name + ".pos1.Y", pos1.getY());
|
||||
config.getConfig().set(name + ".pos1.Z", pos1.getZ());
|
||||
|
||||
config.getConfig().set(name + ".pos2.X", pos2.getX());
|
||||
config.getConfig().set(name + ".pos2.Y", pos2.getY());
|
||||
config.getConfig().set(name + ".pos2.Z", pos2.getZ());
|
||||
|
||||
config.saveConfig();
|
||||
|
||||
loadPortals();
|
||||
|
||||
}
|
||||
|
||||
public static void remove(String name){
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
||||
|
||||
Object[] keys = config.getConfig().getKeys(true).toArray();
|
||||
for(int i = keys.length - 1; i >= 0; i--){
|
||||
String key = keys[i].toString();
|
||||
if(key.startsWith(name + ".")){
|
||||
config.getConfig().set(key, null);
|
||||
}
|
||||
}
|
||||
config.getConfig().set(name, null);
|
||||
|
||||
// TODO add code to check if people have the portal selected and notify if removed.
|
||||
|
||||
/**Set<String> keys = config.getConfig().getKeys(true);
|
||||
for(String key: keys){
|
||||
if(key.startsWith(name)){
|
||||
config.getConfig().set(key, null);
|
||||
}
|
||||
}*/
|
||||
|
||||
/**config.getConfig().set(name + ".world", null);
|
||||
config.getConfig().set(name + ".triggerblock", null);
|
||||
config.getConfig().set(name + ".destination", null);
|
||||
|
||||
config.getConfig().set(name + ".pos1.X", null);
|
||||
config.getConfig().set(name + ".pos1.Y", null);
|
||||
config.getConfig().set(name + ".pos1.Z", null);
|
||||
|
||||
config.getConfig().set(name + ".pos2.X", null);
|
||||
config.getConfig().set(name + ".pos2.Y", null);
|
||||
config.getConfig().set(name + ".pos2.Z", null);
|
||||
|
||||
config.getConfig().set(name + ".pos1", null);
|
||||
config.getConfig().set(name + ".pos2", null);
|
||||
|
||||
config.getConfig().set(name, null);*/
|
||||
|
||||
config.saveConfig();
|
||||
|
||||
loadPortals();
|
||||
}
|
||||
|
||||
public static boolean portalExists(String portalName){
|
||||
|
||||
ConfigAccessor portalconfig = new ConfigAccessor(plugin, "Portals.yml");
|
||||
String posX = portalconfig.getConfig().getString(portalName + ".pos1.X");
|
||||
|
||||
if(posX == null){
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean activate(Player player, String portalName) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
||||
|
||||
// add other variables or filter code here, or somehow have a way to register them
|
||||
|
||||
if(config.getConfig().getString(portalName + ".bungee") != null){
|
||||
if(ShowBungeeMessage){
|
||||
player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Attempting to warp to \u00A7e" + config.getConfig().getString(portalName + ".bungee") + "\u00A7a.");
|
||||
}
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF(config.getConfig().getString(portalName + ".bungee"));
|
||||
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||
return false;
|
||||
|
||||
}
|
||||
else{
|
||||
if(config.getConfig().getString(portalName + ".destination") != null){
|
||||
ConfigAccessor configDesti = new ConfigAccessor(plugin, "Destinations.yml");
|
||||
String destiName = config.getConfig().getString(portalName + ".destination");
|
||||
if(configDesti.getConfig().getString(destiName + ".world") != null){
|
||||
String permission = config.getConfig().getString(portalName + ".portalArgs.permission");
|
||||
if(permission == null || (permission != null && player.hasPermission(permission)) || player.isOp()){
|
||||
boolean warped = Destination.warp(player, destiName);
|
||||
return warped;
|
||||
}
|
||||
else{
|
||||
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You do not have permission to use this portal!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The destination you are currently attempting to warp to doesnt exist!");
|
||||
plugin.getLogger().log(Level.SEVERE, "The portal '" + portalName + "' has just had a warp "
|
||||
+ "attempt and either the data is corrupt or that destination listed doesn't exist!");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The portal you are trying to use doesn't have a destination!");
|
||||
plugin.getLogger().log(Level.SEVERE, "The portal '" + portalName + "' has just had a warp "
|
||||
+ "attempt and either the data is corrupt or portal doesn't exist!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// add code for if the portal doesnt have a destination but a teleport location
|
||||
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
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 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) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
this.useCustomPrefix = config.getConfig().getBoolean("UseCustomPrefix");
|
||||
if (useCustomPrefix) {
|
||||
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");
|
||||
}
|
||||
|
||||
public static void NoPermission(CommandSender sender, String command) {
|
||||
sender.sendMessage(customPrefixFail + " You do not have permission to perform that command!");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,206 @@
|
|||
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 {
|
||||
|
||||
private static Material blockType = Material.RED_STAINED_GLASS;
|
||||
private static int timeout = 10;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void loadData(AdvancedPortalsPlugin plugin) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
|
||||
timeout = config.getConfig().getInt("ShowSelectionShowDuration");
|
||||
|
||||
String BlockID = config.getConfig().getString("ShowSelectionBlockID");
|
||||
|
||||
blockType = Material.getMaterial(BlockID);
|
||||
|
||||
if (blockType == null) {
|
||||
plugin.getLogger().warning("Material may be from old name format");
|
||||
blockType = Material.RED_STAINED_GLASS;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void show(final Player player, final AdvancedPortalsPlugin plugin, String portalName) {
|
||||
|
||||
int LowX = 0;
|
||||
int LowY = 0;
|
||||
int LowZ = 0;
|
||||
|
||||
int HighX = 0;
|
||||
int HighY = 0;
|
||||
int HighZ = 0;
|
||||
|
||||
if (portalName != null) {
|
||||
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "portals.yml");
|
||||
|
||||
LowX = portalConfig.getConfig().getInt(portalName + ".pos2.X");
|
||||
LowY = portalConfig.getConfig().getInt(portalName + ".pos2.Y");
|
||||
LowZ = portalConfig.getConfig().getInt(portalName + ".pos2.Z");
|
||||
|
||||
HighX = portalConfig.getConfig().getInt(portalName + ".pos1.X");
|
||||
HighY = portalConfig.getConfig().getInt(portalName + ".pos1.Y");
|
||||
HighZ = portalConfig.getConfig().getInt(portalName + ".pos1.Z");
|
||||
} else {
|
||||
if (player.getMetadata("Pos1X").get(0).asInt() > player.getMetadata("Pos2X").get(0).asInt()) {
|
||||
LowX = player.getMetadata("Pos2X").get(0).asInt();
|
||||
HighX = player.getMetadata("Pos1X").get(0).asInt();
|
||||
} else {
|
||||
LowX = player.getMetadata("Pos1X").get(0).asInt();
|
||||
HighX = player.getMetadata("Pos2X").get(0).asInt();
|
||||
}
|
||||
if (player.getMetadata("Pos1Y").get(0).asInt() > player.getMetadata("Pos2Y").get(0).asInt()) {
|
||||
LowY = player.getMetadata("Pos2Y").get(0).asInt();
|
||||
HighY = player.getMetadata("Pos1Y").get(0).asInt();
|
||||
} else {
|
||||
LowY = player.getMetadata("Pos1Y").get(0).asInt();
|
||||
HighY = player.getMetadata("Pos2Y").get(0).asInt();
|
||||
}
|
||||
if (player.getMetadata("Pos1Z").get(0).asInt() > player.getMetadata("Pos2Z").get(0).asInt()) {
|
||||
LowZ = player.getMetadata("Pos2Z").get(0).asInt();
|
||||
HighZ = player.getMetadata("Pos1Z").get(0).asInt();
|
||||
} else {
|
||||
LowZ = player.getMetadata("Pos1Z").get(0).asInt();
|
||||
HighZ = player.getMetadata("Pos2Z").get(0).asInt();
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
for (int x = LowX; x <= HighX; x++) {
|
||||
Location loc = new Location(player.getWorld(), x, LowY, LowZ);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int x = LowX; x <= HighX; x++) {
|
||||
Location loc = new Location(player.getWorld(), x, LowY, HighZ);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int z = LowZ; z <= HighZ; z++) {
|
||||
Location loc = new Location(player.getWorld(), LowX, LowY, z);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int z = LowZ; z <= HighZ; z++) {
|
||||
Location loc = new Location(player.getWorld(), HighX, LowY, z);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int y = LowY; y <= HighY; y++) {
|
||||
Location loc = new Location(player.getWorld(), LowX, y, LowZ);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int y = LowY; y <= HighY; y++) {
|
||||
Location loc = new Location(player.getWorld(), LowX, y, HighZ);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int y = LowY; y <= HighY; y++) {
|
||||
Location loc = new Location(player.getWorld(), HighX, y, LowZ);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int y = LowY; y <= HighY; y++) {
|
||||
Location loc = new Location(player.getWorld(), HighX, y, HighZ);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int x = LowX; x <= HighX; x++) {
|
||||
Location loc = new Location(player.getWorld(), x, HighY, HighZ);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int x = LowX; x <= HighX; x++) {
|
||||
Location loc = new Location(player.getWorld(), x, HighY, LowZ);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int z = LowZ; z <= HighZ; z++) {
|
||||
Location loc = new Location(player.getWorld(), LowX, HighY, z);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
for (int z = LowZ; z <= HighZ; z++) {
|
||||
Location loc = new Location(player.getWorld(), HighX, HighY, z);
|
||||
player.sendBlockChange(loc, blockData);
|
||||
}
|
||||
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
Selection.hide(player, plugin, pos1, pos2);
|
||||
}
|
||||
}, timeout * 20);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected static void hide(Player player, AdvancedPortalsPlugin plugin, Location pos1, Location pos2) {
|
||||
|
||||
int LowX = pos1.getBlockX();
|
||||
int LowY = pos1.getBlockY();
|
||||
int LowZ = pos1.getBlockZ();
|
||||
|
||||
int HighX = pos2.getBlockX();
|
||||
int HighY = pos2.getBlockY();
|
||||
int HighZ = pos2.getBlockZ();
|
||||
|
||||
for (int x = LowX; x <= HighX; x++) {
|
||||
Location loc = new Location(player.getWorld(), x, LowY, LowZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for (int x = LowX; x <= HighX; x++) {
|
||||
Location loc = new Location(player.getWorld(), x, LowY, HighZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for (int z = LowZ; z <= HighZ; z++) {
|
||||
Location loc = new Location(player.getWorld(), LowX, LowY, z);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for (int z = LowZ; z <= HighZ; z++) {
|
||||
Location loc = new Location(player.getWorld(), HighX, LowY, z);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for (int y = LowY; y <= HighY; y++) {
|
||||
Location loc = new Location(player.getWorld(), LowX, y, LowZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for (int y = LowY; y <= HighY; y++) {
|
||||
Location loc = new Location(player.getWorld(), LowX, y, HighZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for (int y = LowY; y <= HighY; y++) {
|
||||
Location loc = new Location(player.getWorld(), HighX, y, LowZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for (int y = LowY; y <= HighY; y++) {
|
||||
Location loc = new Location(player.getWorld(), HighX, y, HighZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for (int x = LowX; x <= HighX; x++) {
|
||||
Location loc = new Location(player.getWorld(), x, HighY, HighZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for (int x = LowX; x <= HighX; x++) {
|
||||
Location loc = new Location(player.getWorld(), x, HighY, LowZ);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for (int z = LowZ; z <= HighZ; z++) {
|
||||
Location loc = new Location(player.getWorld(), LowX, HighY, z);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
for (int z = LowZ; z <= HighZ; z++) {
|
||||
Location loc = new Location(player.getWorld(), HighX, HighY, z);
|
||||
player.sendBlockChange(loc, loc.getBlock().getType(), loc.getBlock().getData());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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,77 +1,78 @@
|
|||
package com.sekwah.advancedportals.events;
|
||||
package com.sekwah.advancedportals.bukkit.api.events;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.portals.AdvancedPortal;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
|
||||
public final class WarpEvent extends Event implements Cancellable {
|
||||
|
||||
/**
|
||||
* Use listeners so you can add new triggers easier and also other plugins can listen for the event
|
||||
* and add their own triggers
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Use listeners so you can add new triggers easier and also other plugins can listen for the event
|
||||
* and add their own triggers
|
||||
*/
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
|
||||
private boolean cancelled = false;
|
||||
|
||||
private Player player;
|
||||
private final Player player;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private String portalName;
|
||||
private final AdvancedPortal portalData;
|
||||
|
||||
private boolean hasWarped = false;
|
||||
|
||||
public WarpEvent(Player player, String portalName) {
|
||||
this.player = player;
|
||||
this.portalName = portalName;
|
||||
private boolean hasWarped = false;
|
||||
|
||||
public WarpEvent(Player player, AdvancedPortal portalData) {
|
||||
this.player = player;
|
||||
this.portalData = portalData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the event has been cancelled
|
||||
*
|
||||
*
|
||||
* @return cancelled
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
|
||||
public void setCancelled(boolean cancel) {
|
||||
cancelled = cancel;
|
||||
}
|
||||
|
||||
|
||||
public AdvancedPortal getPortalData() {
|
||||
return portalData;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the
|
||||
*
|
||||
* This will return true if another plugin has warped the player(and set this to true)
|
||||
*
|
||||
* @return hasWarped
|
||||
*/
|
||||
public boolean getHasWarped() {
|
||||
return hasWarped;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the
|
||||
*
|
||||
* @param warped
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public void setHasWarped(boolean warped){
|
||||
this.hasWarped = warped;
|
||||
public void setHasWarped(boolean warped) {
|
||||
this.hasWarped = warped;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will return true if another plugin has warped the player(and set this to true)
|
||||
*
|
||||
* @return hasWarped
|
||||
*/
|
||||
public boolean getHasWarped(){
|
||||
return hasWarped;
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public Player getPlayer(){
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,11 @@
|
|||
package com.sekwah.advancedportals.portals;
|
||||
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*/){
|
||||
public PortalArg(String argName, String value/*, int type*/) {
|
||||
this.argName = argName;
|
||||
this.value = value;
|
||||
// may be used if values need to be 100% not string
|
|
@ -0,0 +1,35 @@
|
|||
package com.sekwah.advancedportals.bukkit.api.portaldata;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PortalTags {
|
||||
|
||||
// TODO create a list or hashmap of tags to check for.
|
||||
|
||||
public Map<String, String> tagDesc = new HashMap<String, String>();
|
||||
|
||||
public ArrayList<String> tags = new ArrayList<String>();
|
||||
|
||||
|
||||
public void registerTag(String tagName) {
|
||||
this.registerTag(tagName, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Will only be used if a /portal tags command is created. The descriptions will be used for help text
|
||||
* so please keep it short.
|
||||
*
|
||||
* @param tagName
|
||||
* @param description
|
||||
*/
|
||||
public void registerTag(String tagName, boolean multiWord, String description) {
|
||||
this.registerTag(tagName, multiWord);
|
||||
}
|
||||
|
||||
public void registerTag(String tagName, boolean multiWord) {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package com.sekwah.advancedportals.bukkit.api.registry;
|
||||
|
||||
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;
|
||||
|
||||
public class TagRegistry {
|
||||
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
private final ArrayList<String> tags = new ArrayList<String>();
|
||||
|
||||
private final Map<String, TagHandler.Activation> tagActivation = new HashMap<String, TagHandler.Activation>();
|
||||
|
||||
private final Map<String, TagHandler.Creation> tagCreation = new HashMap<String, TagHandler.Creation>();
|
||||
|
||||
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.
|
||||
|
||||
public TagRegistry(AdvancedPortalsPlugin plugin){
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return if the tag has been registered or if it already exists.
|
||||
*/
|
||||
public boolean registerTag(String tag, TagHandler tagHandler){
|
||||
|
||||
if(tag == null){
|
||||
plugin.getLogger().warning("A tag can not be null.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(tags.contains(tag)){
|
||||
return false;
|
||||
}
|
||||
|
||||
tags.add(tag);
|
||||
|
||||
if(tagHandler != null && !(tagHandler instanceof TagHandler.Activation) && !(tagHandler instanceof TagHandler.TagStatus) &&
|
||||
!(tagHandler instanceof TagHandler.Creation)){
|
||||
plugin.getLogger().warning("Error with tag: " + tag + ". A tag handler must implement one of the handlers. Not just extend.");
|
||||
if(tagHandler instanceof TagHandler.Activation){
|
||||
tagActivation.put(tag, (TagHandler.Activation) tagHandler);
|
||||
}
|
||||
if(tagHandler instanceof TagHandler.TagStatus){
|
||||
tagStatus.put(tag, (TagHandler.TagStatus) tagHandler);
|
||||
}
|
||||
if(tagHandler instanceof TagHandler.Creation){
|
||||
tagCreation.put(tag, (TagHandler.Creation) tagHandler);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.sekwah.advancedportals.bukkit.api.warphandler;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||
|
||||
public class ActivationData {
|
||||
|
||||
private boolean warpAllowed = true;
|
||||
|
||||
private WarpedStatus warpStatus = WarpedStatus.INACTIVE;
|
||||
|
||||
private final Portal activePortal;
|
||||
|
||||
public ActivationData(Portal portal){
|
||||
this.activePortal = portal;
|
||||
}
|
||||
|
||||
public WarpedStatus getWarped(){
|
||||
return this.warpStatus;
|
||||
}
|
||||
|
||||
public void setWarpStatus(WarpedStatus warped){
|
||||
if(this.warpStatus == WarpedStatus.WARPED || this.warpStatus == WarpedStatus.INACTIVE){
|
||||
return;
|
||||
}
|
||||
this.warpStatus = warped;
|
||||
}
|
||||
|
||||
/**
|
||||
* In case you need to set the status back down a step for whatever reason. However it is not recommended.
|
||||
* @param warped
|
||||
*/
|
||||
public void setWarpStatusAbsolute(WarpedStatus warped){
|
||||
this.warpStatus = warped;
|
||||
}
|
||||
|
||||
public boolean getAllowed(){
|
||||
return this.warpAllowed;
|
||||
}
|
||||
|
||||
public void setAllowed(boolean allowed){
|
||||
this.warpAllowed = allowed;
|
||||
}
|
||||
|
||||
public enum WarpedStatus{
|
||||
/**
|
||||
* Player has moved or something major has happened. (only one of these should activate)
|
||||
*/
|
||||
WARPED,
|
||||
/**
|
||||
* Shows that the portal has been activated even if a major function is not performed.
|
||||
*/
|
||||
ACTIVATED,
|
||||
/**
|
||||
* Nothing has activated on the portal.
|
||||
*/
|
||||
INACTIVE
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package com.sekwah.advancedportals.bukkit.api.warphandler;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TagHandler {
|
||||
|
||||
public interface Creation{
|
||||
|
||||
/**
|
||||
* Example if the player does not have access to use a tag on the portal.
|
||||
* @param player
|
||||
* @param activeData
|
||||
* @param argData
|
||||
* @return if the portal can be created.
|
||||
*/
|
||||
boolean portalCreated(Player player, ActivationData activeData, String argData);
|
||||
|
||||
/**
|
||||
* Example if the player does not have access to remove the portal.
|
||||
* @param player
|
||||
* @param activeData
|
||||
* @param argData
|
||||
* @return if the portal can be destroyed.
|
||||
*/
|
||||
boolean portalDestroyed(Player player, ActivationData activeData, String argData);
|
||||
|
||||
}
|
||||
|
||||
public interface Activation{
|
||||
|
||||
/**
|
||||
* Activates before the main part of portal activation.
|
||||
* @param player
|
||||
* @param activeData
|
||||
* @param argData
|
||||
*/
|
||||
void portalPreActivated(Player player, ActivationData activeData, String argData);
|
||||
|
||||
/**
|
||||
* Activates after portal activation
|
||||
* @param player
|
||||
* @param activeData
|
||||
* @param argData
|
||||
*/
|
||||
void portalPostActivated(Player player, ActivationData activeData, String argData);
|
||||
|
||||
/**
|
||||
* Activates if the portal is allowed from pre
|
||||
* @param player
|
||||
* @param activeData
|
||||
* @param argData
|
||||
*/
|
||||
void portalActivated(Player player, ActivationData activeData, String argData);
|
||||
|
||||
}
|
||||
|
||||
public interface TagStatus{
|
||||
|
||||
/**
|
||||
* If the user has access to add the tag
|
||||
* @param player
|
||||
* @param activeData
|
||||
* @param argData
|
||||
* @return if the tag will be added.
|
||||
*/
|
||||
boolean tagAdded(Player player, ActivationData activeData, String argData);
|
||||
|
||||
/**
|
||||
* If the user has access to remove the tag
|
||||
* @param player
|
||||
* @param activeData
|
||||
* @param argData
|
||||
* @return if the tag will be removed.
|
||||
*/
|
||||
boolean ragRemoved(Player player, ActivationData activeData, String argData);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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 {
|
||||
|
@ -33,11 +32,9 @@ public class ConfigAccessor {
|
|||
fileConfiguration = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
// Look for defaults in the jar
|
||||
InputStream defConfigStream = plugin.getResource(fileName);
|
||||
if (defConfigStream != null) {
|
||||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
|
||||
fileConfiguration.setDefaults(defConfig);
|
||||
}
|
||||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(new File(this.getClass()
|
||||
.getClassLoader().getResource(fileName).getPath()));
|
||||
fileConfiguration.setDefaults(defConfig);
|
||||
}
|
||||
|
||||
public FileConfiguration getConfig() {
|
||||
|
@ -81,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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,196 @@
|
|||
package com.sekwah.advancedportals.bukkit.destinations;
|
||||
|
||||
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.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Destination {
|
||||
|
||||
private static AdvancedPortalsPlugin plugin;
|
||||
|
||||
private static boolean TELEPORT_RIDING = false;
|
||||
public static int PORTAL_MESSAGE_DISPLAY = 0;
|
||||
|
||||
public static void init(AdvancedPortalsPlugin plugin) {
|
||||
Destination.plugin = plugin;
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
TELEPORT_RIDING = config.getConfig().getBoolean("WarpRiddenEntity");
|
||||
PORTAL_MESSAGE_DISPLAY = config.getConfig().getInt("WarpMessageDisplay");
|
||||
}
|
||||
|
||||
// TODO add permissions for destinations.
|
||||
|
||||
// TODO try keeping the chunks loaded and add different delays to events to make
|
||||
// the horse teleport when you have more time.(its an annoying bug caused by changed)
|
||||
// in mc
|
||||
|
||||
public static void create(Location location, String name) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".world", location.getWorld().getName());
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.X", location.getX());
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.Y", location.getY());
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.Z", location.getZ());
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.pitch", location.getPitch());
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.yaw", location.getYaw());
|
||||
|
||||
config.saveConfig();
|
||||
}
|
||||
|
||||
public static void move(Location location, String name) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".world", location.getWorld().getName());
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.X", location.getX());
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.Y", location.getY());
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.Z", location.getZ());
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.pitch", location.getPitch());
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.yaw", location.getYaw());
|
||||
|
||||
config.saveConfig();
|
||||
}
|
||||
|
||||
public static void rename(String oldName, String newName) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
|
||||
|
||||
config.getConfig().set(newName.toLowerCase() + ".world", config.getConfig().getString(oldName + ".world"));
|
||||
|
||||
config.getConfig().set(newName.toLowerCase() + ".pos.X", config.getConfig().getDouble(oldName + ".pos.X"));
|
||||
config.getConfig().set(newName.toLowerCase() + ".pos.Y", config.getConfig().getDouble(oldName + ".pos.Y"));
|
||||
config.getConfig().set(newName.toLowerCase() + ".pos.Z", config.getConfig().getDouble(oldName + ".pos.Z"));
|
||||
|
||||
config.getConfig().set(newName.toLowerCase() + ".pos.pitch", config.getConfig().getDouble(oldName + ".pos.pitch"));
|
||||
config.getConfig().set(newName.toLowerCase() + ".pos.yaw", config.getConfig().getDouble(oldName + ".pos.yaw"));
|
||||
|
||||
remove(oldName);
|
||||
|
||||
config.saveConfig();
|
||||
}
|
||||
|
||||
public static void remove(String name) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".world", null);
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.X", null);
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.Y", null);
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.Z", null);
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.pitch", null);
|
||||
config.getConfig().set(name.toLowerCase() + ".pos.yaw", null);
|
||||
|
||||
config.getConfig().set(name.toLowerCase() + ".pos", null);
|
||||
|
||||
config.getConfig().set(name.toLowerCase(), null);
|
||||
|
||||
config.saveConfig();
|
||||
}
|
||||
|
||||
public static boolean warp(Player player, String name) {
|
||||
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(dest + ".world") != null) {
|
||||
Location loc = player.getLocation();
|
||||
if (Bukkit.getWorld(config.getConfig().getString(dest + ".world")) != null) {
|
||||
loc.setWorld(Bukkit.getWorld(config.getConfig().getString(dest + ".world")));
|
||||
|
||||
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(dest + ".pos.pitch"));
|
||||
loc.setYaw((float) config.getConfig().getDouble(dest + ".pos.yaw"));
|
||||
|
||||
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 && TELEPORT_RIDING) {
|
||||
|
||||
riding.eject();
|
||||
riding.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
player.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
riding.setPassenger(player);
|
||||
|
||||
} else {
|
||||
player.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
}
|
||||
|
||||
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.customPrefix + PluginMessages.getWarpMessage(dest));
|
||||
player.sendMessage("");
|
||||
} 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 '" + 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 '" + dest + "' has just had a warp "
|
||||
+ "attempt and either the data is corrupt or that destination doesn't exist!");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
package com.sekwah.advancedportals.bukkit.destinations;
|
||||
|
||||
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.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class DestinationCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
public DestinationCommand(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
plugin.getCommand("destination").setExecutor(this);
|
||||
}
|
||||
|
||||
|
||||
@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":
|
||||
if (sender.hasPermission("advancedportals.desti")) {
|
||||
if (args.length > 1) {
|
||||
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 = (Player) sender;
|
||||
Destination.create(player.getLocation(), args[1]);
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " A destination by that name already exists!");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " Please state the name of the destination you would like to create!");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " You do not have permission to create destinations!");
|
||||
}
|
||||
break;
|
||||
case "remove":
|
||||
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "destinations.yml");
|
||||
if (sender.hasPermission("advancedportals.desti")) {
|
||||
if (args.length > 1) {
|
||||
String posX = portalConfig.getConfig().getString(args[1] + ".pos.X");
|
||||
if (posX != null) {
|
||||
Destination.remove(args[1]);
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " The destination \u00A7e" + args[1] + "\u00A7c has been removed!");
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " No destination by that name exists.");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " You need to state the name of the destination you wish to remove.");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " You do not have permission to remove destinations!");
|
||||
}
|
||||
break;
|
||||
case "list":
|
||||
String message = PluginMessages.customPrefix + " \u00A77Destinations \u00A7c:\u00A7a";
|
||||
Object[] destiObj = config.getConfig().getKeys(false).toArray();
|
||||
LinkedList<String> destis = new LinkedList<>();
|
||||
for (Object object : destiObj) {
|
||||
destis.add(object.toString());
|
||||
}
|
||||
Collections.sort(destis);
|
||||
for (Object desti : destis.toArray()) message = message + " " + desti;
|
||||
sender.sendMessage(message);
|
||||
break;
|
||||
case "help":
|
||||
sender.sendMessage(PluginMessages.customPrefix + " Destination Help Menu");
|
||||
sender.sendMessage("\u00A7e\u00A7m----------------------------");
|
||||
sender.sendMessage("\u00A76/" + command + " create \u00A7c[name] \u00A7a- create destination at your location");
|
||||
sender.sendMessage("\u00A76/" + command + " remove \u00A7c[name] \u00A7a- remove destination");
|
||||
sender.sendMessage("\u00A76/" + command + " warp \u00A7c[name] \u00A7a- teleport to destination");
|
||||
sender.sendMessage("\u00A76/" + command + " list \u00A7a- list all destinations");
|
||||
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]);
|
||||
}
|
||||
else{
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " You must specify a warp location!");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
PluginMessages.UnknownCommand(sender, command);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
PluginMessages.UnknownCommand(sender, command);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String command, String[] args) {
|
||||
LinkedList<String> autoComplete = new LinkedList<>();
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
|
||||
if(args.length > 1 && args[0].equalsIgnoreCase("warp")){
|
||||
for (String string : config.getConfig().getKeys(false)) {
|
||||
if (sender.hasPermission("advancedportals.desti.*") | sender.hasPermission("advancedportals.desti." + string))
|
||||
autoComplete.add(string);
|
||||
}
|
||||
}
|
||||
if (args.length == 1) {
|
||||
if (sender.hasPermission("advancedportals.desti") | sender.hasPermission("advancedportals.createportal")) {
|
||||
autoComplete.addAll(Arrays.asList("create", "remove", "help"));
|
||||
}
|
||||
autoComplete.add("warp");
|
||||
}
|
||||
Collections.sort(autoComplete);
|
||||
for (Object result : autoComplete.toArray()) {
|
||||
if (!result.toString().startsWith(args[args.length - 1])) {
|
||||
autoComplete.remove(result);
|
||||
}
|
||||
}
|
||||
return autoComplete;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package com.sekwah.advancedportals.bukkit.destinations;
|
||||
|
||||
public class PortalWarp {
|
||||
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
package com.sekwah.advancedportals.bukkit.effects;
|
||||
|
||||
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;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class WarpEffects {
|
||||
|
||||
private static AdvancedPortalsPlugin plugin = null;
|
||||
|
||||
public boolean oldSoundLoc = true;
|
||||
|
||||
public static Sound[] sounds = new Sound[2];
|
||||
|
||||
public static boolean soundError = false;
|
||||
|
||||
public WarpEffects(AdvancedPortalsPlugin pluginTemp) {
|
||||
|
||||
plugin = pluginTemp;
|
||||
|
||||
//sounds[0] = findSound(plugin, "ENTITY_ENDERMEN_TELEPORT", "ENDERMAN_TELEPORT");
|
||||
sounds[0] = Sound.ENTITY_ENDERMAN_TELEPORT;
|
||||
|
||||
sounds[1] = Sound.ENTITY_GENERIC_EXPLODE;
|
||||
|
||||
}
|
||||
|
||||
public static Sound findSound(AdvancedPortalsPlugin plugin, String newName, String oldName){
|
||||
Sound soundFound = null;
|
||||
try{
|
||||
soundFound = Sound.valueOf(newName);
|
||||
plugin.getLogger().info(newName + " found");
|
||||
} catch (IllegalArgumentException e) {
|
||||
try {
|
||||
soundFound = Sound.valueOf(oldName);
|
||||
plugin.getLogger().info("Using old effect name: " + oldName);
|
||||
} catch (IllegalArgumentException e2) {
|
||||
plugin.getLogger().warning("There was an error using both the old and new names for " + newName);
|
||||
soundError = true;
|
||||
}
|
||||
}
|
||||
return soundFound;
|
||||
}
|
||||
|
||||
public static void activateEffect(Player player) {
|
||||
Location loc = player.getLocation();
|
||||
World world = player.getWorld();
|
||||
switch (plugin.getSettings().getCurrentWarpParticles()){
|
||||
case 1:
|
||||
for(int i = 0; i < 10; i++){
|
||||
world.playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
}
|
||||
loc.add(0D, 1D, 0D);
|
||||
for(int i = 0; i < 10; i++){
|
||||
world.playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
}
|
||||
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) {
|
||||
if(!soundError){
|
||||
Location loc = player.getLocation();
|
||||
World world = player.getWorld();
|
||||
switch (plugin.getSettings().getCurrentWarpSound()){
|
||||
case 1:
|
||||
world.playSound(loc, sounds[0], 1F, 1F);
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package com.sekwah.advancedportals.bukkit.listeners;
|
||||
|
||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
public class BungeeListener implements PluginMessageListener {
|
||||
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
public BungeeListener(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
||||
if (!channel.equals("BungeeCord")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// some codes
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,37 @@
|
|||
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.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
|
||||
public class FlowStopper implements Listener {
|
||||
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
// 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 WaterFlow = true;
|
||||
|
||||
public FlowStopper(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
this.WaterFlow = config.getConfig().getBoolean("StopWaterFlow");
|
||||
|
||||
if (WaterFlow) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockFromTo(BlockFromToEvent event) {
|
||||
if (Portal.inPortalRegion(event.getBlock().getLocation(), 3) | Portal.inPortalRegion(event.getToBlock().getLocation(), 3))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package com.sekwah.advancedportals.bukkit.listeners;
|
||||
|
||||
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;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class PortalProtect implements Listener {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
// 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 PortalProtect = true;
|
||||
|
||||
private int PortalProtectionArea = 5;
|
||||
|
||||
public PortalProtect(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
this.PortalProtect = config.getConfig().getBoolean("PortalProtection");
|
||||
|
||||
this.PortalProtectionArea = config.getConfig().getInt("PortalProtectionArea", 5);
|
||||
|
||||
if (PortalProtect) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
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(!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(), 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());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
main: com.sekwah.advancedportals.bungee.AdvancedPortalsPlugin
|
||||
name: AdvancedPortals
|
||||
version: 0.9.2
|
||||
author: sekwah
|
|
@ -0,0 +1,107 @@
|
|||
# Advanced Portals Config
|
||||
|
||||
# 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
|
||||
UseOnlyServerMadeAxe: false
|
||||
|
||||
# Preferably an item and not a block but it shouldnt matter
|
||||
AxeItemId: IRON_AXE
|
||||
|
||||
# Will be implemented so you can give yourself the portal block and build manually with it so its easier to make portals with the portal block.
|
||||
CanBuildPortalBlock: true
|
||||
|
||||
# Defines if portals protect themselves
|
||||
PortalProtection: true
|
||||
|
||||
# How many blocks around the portals will be protected from griefing or destruction
|
||||
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
|
||||
StopWaterFlow: true
|
||||
|
||||
# This must be a placeable block or it will not work and may even crash
|
||||
ShowSelectionBlockID: RED_STAINED_GLASS
|
||||
|
||||
# WarpEffect
|
||||
# 0 = disabled(no particles)
|
||||
# 1 = Eye of ender explode effect(loads of portal particles)
|
||||
# adding more soon and may create some custom ones
|
||||
WarpParticles: 1
|
||||
|
||||
# WarpSound generally suggested to keep the same as warpeffect but can usually be used for just the sound and no particle effects
|
||||
# 0 = disabled(no sound)
|
||||
# 1 = Enderman Warp Sound
|
||||
# adding more soon
|
||||
WarpSound: 1
|
||||
|
||||
# In case you want to show the bungee attempting warp message
|
||||
ShowBungeeWarpMessage: false
|
||||
|
||||
# This changes how long the show seletion lasts in seconds
|
||||
|
||||
ShowSelectionShowDuration: 10
|
||||
|
||||
# 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
|
||||
|
||||
# Use plugin name in the warp messages
|
||||
UseWarpPrefix: true
|
||||
|
||||
# If this is true a custom prefix can be used, (not fully coded yet!!)
|
||||
|
||||
UseCustomPrefix: false
|
||||
|
||||
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
|
||||
|
||||
# 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 enable op command portals
|
||||
# p enable permission command portals
|
||||
# c enable console command portals
|
||||
# b enable bungee command portals
|
||||
#
|
||||
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
|
|
@ -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
|
|
@ -1,33 +0,0 @@
|
|||
main: com.sekwah.advancedportals.AdvancedPortalsPlugin
|
||||
name: AdvancedPortals
|
||||
version: 0.0.6
|
||||
author: SEKWAH41
|
||||
description: An advanced portals plugin for bukkit.
|
||||
commands:
|
||||
advancedportals:
|
||||
description: The main command for the advanced portals
|
||||
aliases: [portals, aportals, portal]
|
||||
usage: /<command>
|
||||
destination:
|
||||
description: Can be used to access portal destinations.
|
||||
aliases: [desti]
|
||||
usage: /<command>
|
||||
warp:
|
||||
description: Used to warp to destinations.
|
||||
usage: /<command>
|
||||
permissions:
|
||||
advancedportals.*:
|
||||
description: Gives access to all portal commands
|
||||
children:
|
||||
advancedportals.createportal: true
|
||||
advancedportals.portal: true
|
||||
advancedportals.build: true
|
||||
advancedportals.createportal:
|
||||
description: Allows you to create portals
|
||||
default: op
|
||||
advancedportals.portal:
|
||||
description: Allows use of portal commands
|
||||
default: op
|
||||
advancedportals.build:
|
||||
description: Allows you to build in the portal regions
|
||||
default: op
|
Loading…
Reference in New Issue