Compare commits

...

243 Commits

Author SHA1 Message Date
renovate[bot] 689d4a4fe9
chore(deps): Update dependency io.netty:netty-all to v4.1.87.Final 2023-01-14 03:18:36 +00:00
renovate[bot] f0671fb8b8
chore(deps): Update dependency com.google.code.gson:gson to v2.10.1 2023-01-07 02:41:15 +00:00
renovate[bot] 9cf6d9e991
chore(deps): Update dependency io.netty:netty-all to v4.1.86.Final 2022-12-17 01:14:35 +00:00
Tad Hunt b0a93c2c35
feat: make the portal reload command usable from the console and rcon (#338) 2022-12-15 11:40:15 +00:00
renovate[bot] 5229339a8c
chore(deps): Update dependency com.sk89q.worldedit:worldedit-bukkit to v7.2.13 2022-12-11 06:44:06 +00:00
renovate[bot] 1a759dcc76
chore(deps): Update Deps to v4.5.14 2022-12-04 13:32:31 +00:00
renovate[bot] 93a6aface2
chore(deps): Update dependency gradle to v7.6 2022-11-26 01:53:29 +00:00
renovate[bot] 0b64f47b8a
chore(deps): Update dependency io.netty:netty-all to v4.1.85.Final 2022-11-12 02:01:15 +00:00
renovate[bot] 617ccfd66a
chore(deps): Update dependency com.google.code.gson:gson to v2.10 2022-10-29 01:42:02 +00:00
Osiris-Team e808668fce
fix: updated author name, fixes #334 and #326 (#335)
* Update bungee.yml

* Update plugin.yml

* Update AdvancedPortalsPlugin.java
2022-10-24 12:11:57 +01:00
renovate[bot] 91d52b8c1b
chore(deps): Update dependency io.netty:netty-all to v4.1.84.Final 2022-10-15 00:12:25 +00:00
renovate[bot] eb71f1c1d1
chore(deps): Update Deps 2022-09-17 00:16:56 +00:00
renovate[bot] 15956b4844
chore(deps): Update dependency io.netty:netty-all to v4.1.81.Final 2022-09-10 01:14:53 +00:00
renovate[bot] 4f60d8e319
chore(deps): Update dependency io.netty:netty-all to v4.1.80.Final 2022-08-27 01:30:51 +00:00
renovate[bot] f5f06167db
chore(deps): Update dependency com.sk89q.worldedit:worldedit-bukkit to v7.2.12 2022-08-07 11:15:02 +00:00
renovate[bot] 0f595fac7d
chore(deps): Update Deps 2022-08-06 00:44:07 +00:00
renovate[bot] 051fc6c92e
chore(deps): Update dependency com.sk89q.worldedit:worldedit-bukkit to v7.2.11 2022-07-30 10:40:54 +00:00
renovate[bot] 22483ac052
chore(deps): Update Deps to v10.37.4 2022-07-30 01:35:48 +00:00
renovate[bot] 51aa6dac47
chore(deps): Update Deps 2022-07-16 00:48:28 +00:00
renovate[bot] 029f117fc1
chore(deps): Update dependency io.netty:netty-all to v4.1.78.Final 2022-06-18 00:46:05 +00:00
Renovate Bot 87cd76cdeb
chore(deps): Update Deps to v10.37.1 2022-05-28 02:31:30 +00:00
Renovate Bot 34b0127f99
chore(deps): Update Deps to v10.37.0 2022-05-21 00:59:11 +00:00
Renovate Bot 7d3597faad
chore(deps): Update dependency io.netty:netty-all to v4.1.77.Final 2022-05-07 02:28:47 +00:00
Renovate Bot 58e7e3ad78
chore(deps): Update dependency io.netty:netty-all to v4.1.76.Final 2022-04-16 00:05:08 +00:00
Renovate Bot 6906772138
chore(deps): Update dependency gradle to v7.4.2 2022-04-02 00:10:40 +00:00
Renovate Bot 080aae4a9e
chore(deps): Update Deps to v10.36.5 2022-03-26 00:40:54 +00:00
Renovate Bot f6620ef2eb
chore(deps): Update Deps 2022-03-19 02:07:09 +00:00
Renovate Bot 05359480a3
chore(deps): Update Deps 2022-03-12 00:38:13 +00:00
Renovate Bot a317acce3d
chore(deps): Update Deps to v10.34.1 2022-03-05 21:00:38 +00:00
Renovate Bot 9b7c09955e
chore(deps): Update Deps to v10.34.0 2022-03-05 08:57:24 +00:00
Renovate Bot 8eb3a2926b
chore(deps): Update Deps to v10.33.1 2022-03-05 00:51:36 +00:00
Renovate Bot 71e67f2010 chore(deps): update actions/setup-java action to v3 2022-02-25 12:56:33 +00:00
Sekwah 5df74aae28 release version: 0.9.2 [skip ci] 2022-02-24 00:31:25 +00:00
Sekwah 4904d806be Update CHANGELOG.md [skip ci] 2022-02-24 00:31:21 +00:00
Sekwah 9a64ae58c7 fix: Removes the false positive warning from McAntiMalware
Fixes #300
2022-02-24 00:30:23 +00:00
Renovate Bot c504909668
chore(deps): Update Deps 2022-02-12 01:12:00 +00:00
Renovate Bot 5b79228be7
chore(deps): Update dependency com.sk89q.worldedit:worldedit-bukkit to v7.2.9 2022-02-05 02:05:11 +00:00
Renovate Bot 6ab4c363ac chore(deps): Update Deps 2022-01-20 20:01:53 +00:00
Renovate Bot 5751879abd
chore(deps): Update dependency gradle to v7.3.3 2021-12-25 00:30:32 +00:00
Renovate Bot 7d82fa3879
chore(deps): Update Deps 2021-12-18 01:19:17 +00:00
Sekwah 1bad72bbc2 release version: 0.9.1 [skip ci] 2021-12-17 02:09:11 +00:00
Sekwah f8bec4c1ee Update CHANGELOG.md [skip ci] 2021-12-17 02:09:07 +00:00
Sekwah 75d2be30fe fix: Error in position checks for portal creation 2021-12-17 02:08:24 +00:00
Sekwah 787c1d09b4
chore(ci): Update release support flags 2021-12-15 00:29:37 +00:00
Sekwah 20c56219f9 release version: 0.9.0 [skip ci] 2021-12-15 00:14:44 +00:00
Sekwah 778ad2ab31 Update CHANGELOG.md [skip ci] 2021-12-15 00:14:40 +00:00
JOO200 e3021367ab feat: WorldEdit Integration, fix logic error 2021-12-15 00:13:30 +00:00
JOO200 fdb22ab8b5 feat: Added WorldEdit Integration
* New config option to enable WorldEdit integration
* New command "/portal we-selection <name>" to select the Portal as WorldEdit selection
* When enabled: Create portals with WorldEdit selections, disable AdvancedPortal's Wand
2021-12-15 00:13:30 +00:00
JOO200 d16ccb7717 chore(deps): Update Velocity to 3.1.0 2021-12-15 00:13:30 +00:00
Renovate Bot 2207324598
chore(deps): Update Deps 2021-12-11 00:17:25 +00:00
Renovate Bot d916deb3a9
chore(deps): Update dependency gradle to v7.3.1 2021-12-04 00:03:50 +00:00
Sekwah 659fcca7ee docs: Update changelog
I assume the merge type messed up who was responsible for the pr. Try to use rebase and not squash.
2021-11-29 12:11:33 +00:00
Mohammed Al-Dahleh 3928922de3 feat: Adds ability to configure warp message 2021-11-29 12:00:25 +00:00
Sekwah a9e660db65
chore(ci): Allow manual triggering 2021-11-29 11:55:03 +00:00
Renovate Bot 486cff7e09
chore(deps): Update Deps to v10.32.3 2021-11-27 01:42:09 +00:00
Renovate Bot d09ad72491
chore(deps): Update dependency gradle to v7.3 2021-11-13 00:07:40 +00:00
Renovate Bot 7d5e96f291
chore(deps): Update dependency io.netty:netty-all to v4.1.70.Final 2021-11-06 02:18:42 +00:00
Sekwah 393ad01d45
chore(ci): Update to list 1.17 as supported automatically 2021-10-31 01:30:59 +01:00
Renovate Bot 71d08da9dc
chore(deps): Update Deps 2021-10-30 02:03:28 +00:00
Renovate Bot f225363e67
chore(deps): Update dependency io.netty:netty-all to v4.1.69.Final 2021-10-16 01:40:06 +00:00
Renovate Bot 162505553f
chore(deps): Update Deps to v10.32.1 2021-10-02 01:33:11 +00:00
Renovate Bot 812f4c78dc
chore(deps): Update Deps to v10.32.0 2021-09-18 01:11:04 +00:00
Renovate Bot 0ab32790eb
chore(deps): Update Deps 2021-09-11 00:37:54 +00:00
Renovate Bot 0be605fe3a
chore(deps): Update dependency com.velocitypowered:velocity-api to v1.1.9 2021-09-04 01:24:55 +00:00
Sekwah 64f0f5113e release version: 0.8.0 [skip ci] 2021-09-01 16:48:06 +00:00
Sekwah fb80fbb515 Update CHANGELOG.md [skip ci] 2021-09-01 16:48:03 +00:00
Sekwah 81d64ecc5a feat: Allow the ability to disable the proxy warning message 2021-09-01 17:46:58 +01:00
Renovate Bot aacf626635
chore(deps): Update Deps 2021-08-21 00:15:54 +00:00
Renovate Bot 12ab00f004
chore(deps): Update Deps 2021-08-14 01:05:18 +00:00
Renovate Bot 065fa22852
chore(deps): Update Deps 2021-07-25 15:07:59 +00:00
Sekwah 012ddf6e36
chore(ci): Update rennovate config 2021-07-25 16:04:48 +01:00
Sekwah 9b3adf7ba4 release version: 0.7.2 [skip ci] 2021-07-14 08:35:41 +00:00
Sekwah ab9dbe027e Update CHANGELOG.md [skip ci] 2021-07-14 08:35:38 +00:00
Sekwah 62307c6bcf fix: Issue where portal events activate too early in survival
Fixes #228
2021-07-14 09:34:36 +01:00
Renovate Bot e2b0723d24 chore(deps): update dependency com.velocitypowered:velocity-api to v1.1.9 2021-07-06 23:46:12 +01:00
Renovate Bot 1a57a509e6 chore(deps): update dependency gradle to v7.1.1 2021-07-04 12:18:30 +01:00
Sekwah ee8f0ff3d0 release version: 0.7.1 [skip ci] 2021-06-30 09:23:07 +00:00
Sekwah 05d2a51fbf Update CHANGELOG.md [skip ci] 2021-06-30 09:23:04 +00:00
Sekwah e73d84afa3 fix: Access to portal warp command locked behind wrong perm
Fixes #272
2021-06-30 10:22:12 +01:00
Renovate Bot d4b642ec23 chore(deps): update dependency gradle to v7 2021-06-29 13:26:03 +01:00
Sekwah bc683183f6 release version: 0.7.0 [skip ci] 2021-06-27 20:28:53 +00:00
Sekwah 3a5460cff3 Update CHANGELOG.md [skip ci] 2021-06-27 20:28:50 +00:00
Sekwah f364828176 feat: Added missing commands from tab complete 2021-06-27 21:28:11 +01:00
Renovate Bot dfe5cfc26d chore(deps): update dependency net.md-5:bungeecord-api to v1.16-r0.4 2021-06-27 21:11:27 +01:00
Sekwah ebd94fd081
chore(ci): removed verbose mode for release 2021-06-27 21:09:41 +01:00
Renovate Bot ffee4fbbbe chore(deps): update dependency com.google.code.gson:gson to v2.8.7 2021-06-27 21:07:20 +01:00
Renovate Bot dcf8456511 chore(deps): update dependency gradle to v6.9 2021-06-27 21:07:00 +01:00
Renovate Bot 1ac1fe7e2e chore(deps): update dependency com.velocitypowered:velocity-api to v1.1.8 2021-06-27 21:06:23 +01:00
Sekwah c51a556ac7 release version: 0.6.1 [skip ci] 2021-06-27 18:20:59 +00:00
Sekwah eafe7f1d9c Update CHANGELOG.md [skip ci] 2021-06-27 18:20:53 +00:00
Sekwah ff95908bf2 chore(ci): Remove isDevBranch remains 2021-06-27 19:18:51 +01:00
Sekwah d2e69771c5 chore(ci): Fix forgotten sha in build gradle 2021-06-27 19:14:04 +01:00
Sekwah 17a81dede7 chore(ci): Update version-bumping task order 2021-06-27 19:08:46 +01:00
Renovate Bot efc9ad4715 chore(deps): pin dependencies 2021-06-27 18:56:46 +01:00
Sekwah 7c78f414ac
fix: Spigot 1.17 error message (#260)
* chore(ci): Add renovate

* fix: 1.17 launch non-critical error

Fixes #259
2021-06-27 18:53:43 +01:00
Sekwah bfea4b2836
chore(ci): Swapping build pipeline 2021-06-27 18:31:52 +01:00
Sekwah b1be39b908
ci: Fixed java version 2021-05-21 00:23:06 +01:00
Sekwah 68ba7dc76b
ci: Fix changelog reference 2021-05-21 00:03:44 +01:00
Sekwah cd96c0d2c0
ci: Updated build pipelines to newer module 2021-05-21 00:03:31 +01:00
Sekwah 06722986be
chore(release): 0.6.0 2021-05-19 20:33:41 +01:00
Sekwah 9536835785
ci: FIxed changelog location 2021-05-19 20:31:56 +01:00
Sekwah 7b0c1ca6ae
ci: add tagrelease task
Just to help really, not needed but stops having to manually type it.
2021-05-19 01:01:01 +01:00
Sekwah 100b825765
Merge pull request #250 from sekwah41/dev/spigot-1.13-1.16
Release v1.16.0
2021-05-19 01:00:53 +01:00
Sekwah 186ec82afc
Merge pull request #250 from sekwah41/dev/spigot-1.13-1.16
Release v1.16.0
2021-05-19 00:57:36 +01:00
Sekwah 093da07b00
chore(release): 0.16.0 2021-05-19 00:55:45 +01:00
Sekwah 8acb0f535e
ci: Updating uploads 2021-05-19 00:48:41 +01:00
Sekwah 8e0590b6d1
ci: Add comment for specific version 2021-05-15 02:59:07 +01:00
Sekwah 9d7184d86e
docs: Updated README.md 2021-05-14 11:44:04 +01:00
Sekwah 6b097087a2
build: Shorten updateChangelog steps 2021-05-14 11:14:53 +01:00
Sekwah 99c810e1be
feat(proxy): Added a ForceEnableProxySupport config option
This is in case other plugins may be messing with the location after swapping servers so that it is enforced after the others.
2021-05-14 03:16:43 +01:00
Sekwah f3c8f73975
feat(proxy): Modern forwarding will be automatically detected.
You will no longer need to manually set ForceEnableProxySupport
2021-05-14 03:14:24 +01:00
Sekwah b243b4d889
feat(proxy): Added Velocity support 2021-05-14 02:55:22 +01:00
Sekwah 0adb854548
ci: Further upgrades to changelog scripts 2021-05-14 02:52:59 +01:00
Sekwah 327e7dd0cb
chore(release): 0.5.13-2 2021-05-14 02:35:05 +01:00
Sekwah 2bf377e575
docs(changelog): Updating locations and other details. 2021-05-14 02:31:35 +01:00
Sekwah 4ab2e2bd7a
ci: Update changelog scripts 2021-05-14 02:06:23 +01:00
Sekwah a20028d9fc
ci: Upload to curseforge bukkit 2021-05-14 00:50:33 +01:00
Sekwah d025947134
Merge branch 'feature/244-proxy-teleport-delay' into dev/spigot-1.13-1.16 2021-05-13 01:00:55 +01:00
Sekwah df7bceea6e
docs: Fix version issue in CHANGELOG.md 2021-05-13 00:47:46 +01:00
Sekwah e22b068a97
ci: Fix changelog generator 2021-05-13 00:45:13 +01:00
Sekwah d884db3d6c
chore(release): 0.5.13-1 2021-05-13 00:44:25 +01:00
Sekwah a1121adc10
feat: Added configurable proxy teleport delay 2021-05-13 00:42:45 +01:00
Sekwah e8cbb403c5
ci: Fix issue with wrong dev mode 2021-05-12 20:06:11 +01:00
Sekwah ae518bea39
chore(release): 0.5.14-0 2021-05-12 02:47:47 +01:00
Sekwah 4278cd5d7a
ci: Fixed version bumping 2021-05-12 02:07:10 +01:00
Sekwah fd6ef9ac08
docs: Updating Readme 2021-05-12 01:22:50 +01:00
Sekwah 3ac7a8c6ff
ci: Adding changelog generation as well as changes to pipelines 2021-05-12 01:19:01 +01:00
Sekwah 0ad693db0c
Merge pull request #243 from sekwah41/dev/spigot-1.13-1.16
Add force enable features and proper velocity support
2021-05-10 10:21:53 +01:00
Sekwah 1aa8ce45ac
Updated changelog 2021-05-09 03:51:09 +01:00
Sekwah fc952e6c9e
Merge pull request #242 from sekwah41/feature/modern-forward-detect
Added modern forwarding
2021-05-09 03:47:36 +01:00
Sekwah 5c1f712765
Added auto detection at modern forwarding 2021-05-09 03:45:31 +01:00
Sekwah 7034eee7b2
Updated jar file naming to match maven standards 2021-05-05 02:14:25 +01:00
Sekwah e8ecde5b4e
Updated changelog 2021-04-22 11:56:20 +01:00
Sekwah baca2d3316
Merge branch 'feature/velocity-support' into dev/spigot-1.13-1.16 2021-04-22 11:49:21 +01:00
Sekwah 2040ea08a8
Fixed up velocity packets 2021-04-22 11:49:10 +01:00
Sekwah afe4e41b14
Updated to show dev in file name if not tagged 2021-04-05 15:07:56 +01:00
Sekwah 425093d887
Updated dev tags 2021-04-05 14:56:47 +01:00
Sekwah a30e44bb35
Altered tags to releases 2021-04-05 14:50:41 +01:00
Sekwah 3ac200bbc0
Updated build info and some other workflows 2021-04-05 14:47:34 +01:00
Sekwah 5c2c1cf465
Changed to explicitly state the master branch 2021-03-23 11:55:54 +00:00
Sekwah 9aa53f4a28
Updated readme to remove travis parts 2021-03-23 01:49:20 +00:00
Sekwah 4648ca31d6
Removed unused broken import 2021-03-23 01:38:29 +00:00
Sekwah 5e1d9aeb9d
Switched to gradle actions 2021-03-23 01:36:34 +00:00
Sekwah 31db696b1a
chmod 2021-03-23 01:35:23 +00:00
Sekwah 56221ee058
Merge pull request #232 from loonybtard/master
Command permissions for luckperms
2021-02-06 19:37:00 +00:00
loonybtard b7b148f057
Command permissions for luckperms 2021-02-05 00:00:54 +03:00
Sekwah ecd11a7f34
Clean up code a little and alter tags 2021-02-01 00:59:23 +00:00
Sekwah 5ee12d7696
Merge pull request #231 from loonybtard/master
Custom warp effects via particles
2021-01-30 18:42:49 +00:00
loonybtard ff4fd1f3e7 custom particle effect on warp 2021-01-30 02:50:36 +03:00
loonybtard 5682b94aef fix unused hideActionBar 2021-01-30 00:37:36 +03:00
Sekwah 886a8744e2
Merge parts 2021-01-25 01:05:47 +00:00
Sekwah 8c7798dec8
Remove unneeded imports 2021-01-24 03:26:35 +00:00
Sekwah 41643caff2
Cleanup 2021-01-24 03:08:14 +00:00
Sekwah f8e5cced9e
Add force override to enable proxy. 2021-01-24 03:05:58 +00:00
Sekwah 2da18a3417
Bungee cleanup (was sending unneeded packets to clients) 2020-12-30 04:04:17 +00:00
Sekwah d06f150358
Finished Velocity Support 2020-12-30 03:44:27 +00:00
Sekwah 1796945896
Adding velocity support 2020-12-30 02:49:45 +00:00
Sekwah 2063c8e30c
Fixed entity teleporting? 2020-12-03 22:45:05 +00:00
Sekwah 9279be58aa
Fixed an issue with spam re-triggering on portal events 2020-11-28 17:07:24 +00:00
Sekwah 9a2ff28ab9
Update README.md 2020-11-28 03:21:52 +00:00
Sekwah aacdd54ffe
Update README.md 2020-11-28 03:21:32 +00:00
Sekwah 6dd23ddeee
Added extra checks to in portal as well as fix spam trigger on commands 2020-10-26 03:39:32 +00:00
Sekwah d104da907f
Changed for better support for paperspigot 2020-09-23 10:06:05 +01:00
Sekwah d84ec0bd3e
Upped version 2020-09-23 02:01:36 +01:00
Sekwah f14fd9f692
Fixed for the new more reliable event 2020-09-23 02:00:49 +01:00
Sekwah 69176c379b
Merge pull request #222 from elytraa/bungee-destination
Use ServerConnectedEvent for bungee relay
2020-09-21 00:19:19 +01:00
Freddy 7aa4114742 Use ServerConnectedEvent for bungee relay 2020-09-21 01:08:27 +02:00
Sekwah 42b01ec059
Removed large warning messages 2020-07-19 14:33:02 +01:00
Sekwah 806beea62a
Removed large warning message
this was only here for a transition period
2020-07-19 14:27:10 +01:00
Sekwah 38b15acd15
Merge pull request #209 from imDaniX/patch-1
better check for bungeecord support
2020-07-19 14:21:16 +01:00
Daniil d950d8eb22
better check for bungeecord support
For some custom forks like Tuinity and such.
Also this next warning is enormous and just annoying. I think there's should be some configurable option in the config to disable it. Can make a PR for this too if needed.
2020-07-19 04:09:41 +03:00
Sekwah e02dd0e858
Updated versions to 0.5.7 2020-07-16 23:56:06 +01:00
Sekwah 5718d789d9
Merge pull request #207 from tmantti/bungee-destifix
Fix timing issues with bungeecord destination warps
2020-07-16 23:48:41 +01:00
tmantti f82de6be12
Update AdvancedPortalsPlugin.java 2020-07-16 12:58:06 +03:00
tmantti 77096a931c
Update Listeners.java 2020-07-16 12:41:28 +03:00
tmantti 1cba807351
Update PluginMessageReceiver.java 2020-07-16 12:36:25 +03:00
tmantti 35845e1caa
Update AdvancedPortalsPlugin.java 2020-07-16 12:33:59 +03:00
tmantti cf2ff77ccb
Update PluginMessageReceiver.java 2020-07-15 13:59:11 +03:00
Sekwah 17fb0c5332
Fixed security vulnerability 2020-07-02 02:39:23 +01:00
Sekwah 468715a29f Removed useless comment 2020-06-28 21:26:57 +01:00
Sekwah f2090a917b Optimised imports and removed comment 2020-06-26 02:33:38 +01:00
Sekwah 1c413c82e5 Updated to 1.16
Solves #200

Also removed the compat file so this should be far more forwards compatible
2020-06-26 00:42:39 +01:00
Sekwah 4012e9bc01 Fixed permissions surrounding /portal warp 2020-06-21 03:18:26 +01:00
Sekwah 6c9eeb06d0 Added disablegateway feature 2020-06-21 02:49:18 +01:00
Sekwah a4771aa86a Ment to set as 0.5.4 2020-06-18 03:40:10 +01:00
Sekwah d2a362e5af Fixed bungee issues and protection 2020-06-18 03:37:06 +01:00
Sekwah 859971b6ea Portals fixed? 2020-05-31 22:41:09 +01:00
Sekwah 79f43b9a62 updated version 2020-04-21 19:47:21 +01:00
Sekwah 4912984cf0 Fixed wrong user being targeted by bungee destinations 2020-04-21 19:44:12 +01:00
Sekwah 9528ad6049 Added forgotten bracket from pr
I assume this one was done in a text edior
2020-04-20 20:36:42 +01:00
Sekwah 1e322aa2ce Updated version numbers 2020-04-20 20:35:27 +01:00
Sekwah bfcb2d596e
Merge pull request #188 from silicondev/patch-1
Fixed issue where help menu appears on successful warp
2020-04-20 20:25:08 +01:00
silicondev 2100e5cec9
Fixed issue where help menu appears even if a player uses a successful portal warp command.
Added else if statement at line 80 checking for single arg instead of 2. This should now only appear if a player both has permission and has not specified a portal to warp to.
2020-04-20 19:06:28 +01:00
Sekwah dc8a301ff2 Fixed #187 as well as adds bungeecommand 2020-04-20 13:23:52 +01:00
Sekwah 36a75a2bd6 Added leavedesti 2020-04-08 17:28:26 +01:00
Sekwah d9928a60bb
Merge pull request #185 from Testerro/master
Add cooldown per portal feature
2020-04-08 16:58:18 +01:00
Tomasz Piowczyk 028482a46c Add data cleaner task 2020-04-08 15:44:53 +02:00
Tomasz Piowczyk f61ac373a4 Cooldown uses extra data, remove onLeaveEvent for cooldown persistance, add join cooldown 2020-04-06 22:36:46 +02:00
Tomasz Piowczyk 414835a690 Remove debug message and make default cooldown 0 2020-04-04 17:34:06 +02:00
Tomasz Piowczyk dafb14ffb4 Add cooldown per portal feature 2020-04-04 17:12:09 +02:00
Sekwah 067865f726
Merge pull request #177 from dalbodeule/master
[Emergency] bukkit PluginMessageReceiver add null-check/delay 20Ticks
2020-02-22 19:14:42 +00:00
dalbodeule 7009129085
delete not use package imports 2020-02-22 12:40:14 +09:00
dalbodeule 5402a0ab4e
some comment deleted, add null-check/delay 20Ticks 2020-02-06 17:19:43 +09:00
Sekwah 2d022de19c
Updated version number 2020-01-23 05:06:24 +00:00
Sekwah ffe3201a93
Changing version number and updating ignore file 2020-01-22 16:30:59 +00:00
Sekwah a5c828e010
Merge pull request #174 from dalbodeule/master
add bungeecord destination warp through subchannel
2020-01-22 15:56:08 +00:00
dalbodeule e926515175
add null check for bungee portal destination 2020-01-21 20:22:12 +09:00
dalbodeule cab45ff7b2
delete junk file 2020-01-21 20:17:04 +09:00
dalbodeule 0015a3bcb7
fix subchannel/bungee issues 2020-01-21 00:45:55 +09:00
dalbodeule a6555b171c
add bungeecord portal teleport destination 2020-01-20 19:55:18 +09:00
Sekwah 89c4253f82
fixing shit travis stuff 2019-12-30 21:54:24 +00:00
Sekwah 0c8548b12e
Cleaned up gradle files 2019-12-30 15:18:14 +00:00
Sekwah fecdc32e0d
Fixed portal protection region 2019-12-30 15:11:25 +00:00
Sekwah 9f4b70a0ef
Basic edits, though seems to work in 1.15 2019-12-30 14:52:00 +00:00
Sekwah 9329ab58c5
Update README.md 2019-09-07 23:53:50 +01:00
Sekwah 48c416b63f
Updated license 2019-09-07 23:53:17 +01:00
Sekwah 79693bcd8a
Update README.md 2019-09-07 23:39:39 +01:00
Sekwah b33a30ad89 Merge remote-tracking branch 'origin/dev' 2019-08-12 09:40:46 +01:00
Sekwah f5deb96d2e Upgraded gradle file and fixed a nullpointer 2019-08-12 09:40:06 +01:00
sekwah41 c8efcbb801
Merge pull request #161 from project-dreamstation/master
Update Portal.java and make text more clear
2019-07-03 11:12:09 +01:00
sekwah41 39dc937ddf
Merge branch 'master' into master 2019-07-03 11:11:51 +01:00
sekwah41 d92fcf1244
Added second(s) 2019-07-03 11:08:59 +01:00
xPepijnxTechx 4d816cbd46
Update Portal.java
Add ''to enter this portal'' instead of ''to teleport to (loc)"
2019-06-23 15:54:49 +02:00
sekwah41 e409f990af
Merge pull request #156 from sekwah41/master
Will do merges as pull requests more often
2019-06-03 03:54:16 +01:00
Sekwah 16fcc5dccc Merge branch 'dev' 2019-06-03 03:51:13 +01:00
Sekwah 523fbb1c83
Added developer note 2019-06-03 03:46:13 +01:00
Sekwah 20c8f585c0 Merge branch 'master' into dev 2019-06-03 03:41:24 +01:00
sekwah41 28ea9d1f8d
Merge pull request #155 from sekwah41/dev
Small tweaks to events
2019-06-03 03:15:37 +01:00
Sekwah e37ec1bef6 Removed useless comments 2019-06-03 03:11:34 +01:00
sekwah41 4392d60b26
Merge pull request #153 from jascotty2/dev
Improve event checking
2019-06-03 03:07:59 +01:00
sekwah41 4d8879a255
Merge pull request #154 from sekwah41/dev
Added message tag
2019-06-03 02:59:46 +01:00
Sekwah 21a5bb2933 Added message tag
Also updated the colour code conversion
2019-06-03 02:55:44 +01:00
jascotty2 fa01dde5d2 merge with dev 2019-06-02 17:26:21 -05:00
jascotty2 ccd21d0e22 improve event checking, cleanup imports 2019-06-02 17:25:29 -05:00
Sekwah 9540ad434c Merge branch 'dev' 2019-06-02 17:53:19 +01:00
sekwah41 dd36947184
Updated build icons to link to travis 2019-06-02 17:53:08 +01:00
Sekwah 3175fd0052 Merge branch 'master' into dev 2019-06-02 17:43:46 +01:00
Sekwah ae5557f816 Updated readme 2019-06-02 17:43:09 +01:00
Sekwah 8c5d8d689c Updated readme 2019-06-02 06:19:41 +01:00
Sekwah 17e3819b2f Updated plugin version 2019-06-02 06:01:14 +01:00
Sekwah 677491a33f Added multiple material portals and random bungee tags 2019-06-02 04:39:08 +01:00
Sekwah 232a5334f1 Added new delay command 2019-05-31 04:04:48 +01:00
Sekwah 7a0b65187b Upgraded gradle build file 2019-05-31 04:04:33 +01:00
63 changed files with 7967 additions and 3577 deletions

32
.autorc Normal file
View File

@ -0,0 +1,32 @@
{
"baseBranch": "spigot-1.13-1.16",
"plugins": [
[
"gradle",
{
"gradleCommand": "./gradlew",
"gradleOptions": [""]
}
],
[
"exec",
{
"canary": "./gradlew build discord"
}
],
["conventional-commits", { "preset": "angular" }],
"released",
["upload-assets", ["./build/libs/*.jar"]]
],
"owner": "sekwah41",
"repo": "Advanced-Portals",
"name": "Sekwah",
"email": "contact@sekwah.com",
"onlyPublishWithReleaseLabel": true,
"shipit": {
"onlyGraduateWithReleaseLabel": true
},
"canary": {
"message": "📦 Published PR to [discord](https://discord.sekwah.com/) as canary version: %v"
}
}

View File

@ -0,0 +1,8 @@
# What Changed
Whatever changed here
## Release Notes
If anything should be commented in the changelog release notes.
**NOTE:** Please remove this unless something important needs to be shared.
It's just to save time looking up what is needed in the event we need to.

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

@ -0,0 +1,47 @@
name: Release
on: [push, workflow_dispatch]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Cache Node packages
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
restore-keys: ${{ runner.os }}-node
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 8
- name: Use Node.js 12.x
uses: actions/setup-node@v2
with:
node-version: 12.x
- name: Prepare repository
run: |
git fetch --unshallow --tags
yarn install --frozen-lockfile
echo $(yarn bin) >> $GITHUB_PATH
- name: Build with Gradle
run: ./gradlew build
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CURSE_API: ${{ secrets.CURSE_API }}
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
run: |
auto shipit

8
.gitignore vendored
View File

@ -1,16 +1,18 @@
*.class
.*
/build/
/target/
.gradle/
.idea/
# Package Files #
*.war
*.ear
node_modules/
*.iml
*.iws
*.ipr
.env
out/
logs/
classes/
run/

View File

@ -1,4 +0,0 @@
language: java
cache:
directories:
- $HOME/.m2

240
CHANGELOG.md Normal file
View File

@ -0,0 +1,240 @@
# v0.9.2 (Thu Feb 24 2022)
#### 🐛 Bug Fix
- fix: Removes the false positive warning from McAntiMalware [#318](https://github.com/sekwah41/Advanced-Portals/pull/318) ([@sekwah41](https://github.com/sekwah41))
- chore(deps): Update Deps ([@renovate-bot](https://github.com/renovate-bot))
- chore(deps): Update dependency com.sk89q.worldedit:worldedit-bukkit to v7.2.9 ([@renovate-bot](https://github.com/renovate-bot))
- chore(deps): Update Deps [#316](https://github.com/sekwah41/Advanced-Portals/pull/316) ([@renovate-bot](https://github.com/renovate-bot))
- chore(deps): Update dependency gradle to v7.3.3 ([@renovate-bot](https://github.com/renovate-bot))
#### Authors: 2
- Sekwah ([@sekwah41](https://github.com/sekwah41))
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
---
# v0.9.1 (Fri Dec 17 2021)
#### 🐛 Bug Fix
- fix: Error in position checks for portal creation [#310](https://github.com/sekwah41/Advanced-Portals/pull/310) ([@sekwah41](https://github.com/sekwah41))
- chore(ci): Update release support flags ([@sekwah41](https://github.com/sekwah41))
#### Authors: 1
- Sekwah ([@sekwah41](https://github.com/sekwah41))
---
# v0.9.0 (Wed Dec 15 2021)
#### 🚀 Enhancement
- feat: WorldEdit Integration, fix logic error [#307](https://github.com/sekwah41/Advanced-Portals/pull/307) ([@JOO200](https://github.com/JOO200))
- feat: Added WorldEdit Integration [#307](https://github.com/sekwah41/Advanced-Portals/pull/307) ([@JOO200](https://github.com/JOO200))
- feat: Adds ability to configure warp message [#302](https://github.com/sekwah41/Advanced-Portals/pull/302) ([@maldahleh](https://github.com/maldahleh))
#### 🐛 Bug Fix
- chore(deps): Update Velocity to 3.1.0 [#307](https://github.com/sekwah41/Advanced-Portals/pull/307) ([@JOO200](https://github.com/JOO200))
- chore(deps): Update Deps ([@renovate-bot](https://github.com/renovate-bot))
- chore(deps): Update dependency gradle to v7.3.1 ([@renovate-bot](https://github.com/renovate-bot))
- docs: Update changelog ([@sekwah41](https://github.com/sekwah41))
- chore(ci): Allow manual triggering ([@sekwah41](https://github.com/sekwah41))
- chore(deps): Update Deps to v10.32.3 ([@renovate-bot](https://github.com/renovate-bot))
- chore(deps): Update dependency gradle to v7.3 ([@renovate-bot](https://github.com/renovate-bot))
- chore(deps): Update dependency io.netty:netty-all to v4.1.70.Final ([@renovate-bot](https://github.com/renovate-bot))
- chore(ci): Update to list 1.17 as supported automatically ([@sekwah41](https://github.com/sekwah41))
- chore(deps): Update dependency io.netty:netty-all to v4.1.69.Final ([@renovate-bot](https://github.com/renovate-bot))
- chore(deps): Update Deps to v10.32.1 ([@renovate-bot](https://github.com/renovate-bot))
- chore(deps): Update Deps to v10.32.0 ([@renovate-bot](https://github.com/renovate-bot))
- chore(deps): Update dependency com.velocitypowered:velocity-api to v1.1.9 ([@renovate-bot](https://github.com/renovate-bot))
#### Authors: 4
- [@JOO200](https://github.com/JOO200)
- Mohammed Al-Dahleh ([@maldahleh](https://github.com/maldahleh))
- Sekwah ([@sekwah41](https://github.com/sekwah41))
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
---
# v0.8.0 (Wed Sep 01 2021)
#### 🚀 Enhancement
- feat: Allow the ability to disable the proxy warning message [#292](https://github.com/sekwah41/Advanced-Portals/pull/292) ([@maldahleh](https://github.com/maldahleh))
#### 🐛 Bug Fix
- chore(deps): Update Deps ([@renovate-bot](https://github.com/renovate-bot))
- chore(ci): Update rennovate config ([@sekwah41](https://github.com/sekwah41))
#### Authors: 2
- Mohammed Al-Dahleh ([@maldahleh](https://github.com/maldahleh))
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
---
# v0.7.2 (Wed Jul 14 2021)
#### 🐛 Bug Fix
- fix: Issue where portal events activate too early in survival [#280](https://github.com/sekwah41/Advanced-Portals/pull/280) ([@sekwah41](https://github.com/sekwah41))
- chore(deps): update dependency com.velocitypowered:velocity-api to v1.1.9 [#278](https://github.com/sekwah41/Advanced-Portals/pull/278) ([@renovate-bot](https://github.com/renovate-bot))
- chore(deps): update dependency gradle to v7.1.1 [#277](https://github.com/sekwah41/Advanced-Portals/pull/277) ([@renovate-bot](https://github.com/renovate-bot))
#### Authors: 2
- Sekwah ([@sekwah41](https://github.com/sekwah41))
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
---
# v0.7.1 (Wed Jun 30 2021)
#### 🐛 Bug Fix
- fix: Access to portal warp command locked behind wrong perm [#275](https://github.com/sekwah41/Advanced-Portals/pull/275) ([@sekwah41](https://github.com/sekwah41))
- chore(deps): update dependency gradle to v7 [#271](https://github.com/sekwah41/Advanced-Portals/pull/271) ([@renovate-bot](https://github.com/renovate-bot))
#### Authors: 2
- Sekwah ([@sekwah41](https://github.com/sekwah41))
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
---
# v0.7.0 (Sun Jun 27 2021)
#### 🚀 Enhancement
- feat: Added missing commands from tab complete [#270](https://github.com/sekwah41/Advanced-Portals/pull/270) ([@sekwah41](https://github.com/sekwah41))
#### 🐛 Bug Fix
- chore(deps): update dependency net.md-5:bungeecord-api to v1.16-r0.4 [#269](https://github.com/sekwah41/Advanced-Portals/pull/269) ([@renovate-bot](https://github.com/renovate-bot))
- chore(ci): removed verbose mode for release ([@sekwah41](https://github.com/sekwah41))
- chore(deps): update dependency com.google.code.gson:gson to v2.8.7 [#262](https://github.com/sekwah41/Advanced-Portals/pull/262) ([@renovate-bot](https://github.com/renovate-bot))
- chore(deps): update dependency gradle to v6.9 [#267](https://github.com/sekwah41/Advanced-Portals/pull/267) ([@renovate-bot](https://github.com/renovate-bot))
- chore(deps): update dependency com.velocitypowered:velocity-api to v1.1.8 [#266](https://github.com/sekwah41/Advanced-Portals/pull/266) ([@renovate-bot](https://github.com/renovate-bot))
#### Authors: 2
- Sekwah ([@sekwah41](https://github.com/sekwah41))
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
---
# v0.6.1 (Sun Jun 27 2021)
#### 🐛 Bug Fix
- chore(ci): Remove isDevBranch remains [#265](https://github.com/sekwah41/Advanced-Portals/pull/265) ([@sekwah41](https://github.com/sekwah41))
- chore(ci): Fix forgotten sha in build gradle [#264](https://github.com/sekwah41/Advanced-Portals/pull/264) ([@sekwah41](https://github.com/sekwah41))
- chore(ci): Update version-bumping task order [#263](https://github.com/sekwah41/Advanced-Portals/pull/263) ([@sekwah41](https://github.com/sekwah41))
- chore(deps): pin dependencies [#261](https://github.com/sekwah41/Advanced-Portals/pull/261) ([@renovate-bot](https://github.com/renovate-bot))
- fix: Spigot 1.17 error message [#260](https://github.com/sekwah41/Advanced-Portals/pull/260) ([@sekwah41](https://github.com/sekwah41))
- chore(ci): Swapping build pipeline ([@sekwah41](https://github.com/sekwah41))
- ci: Fixed java version ([@sekwah41](https://github.com/sekwah41))
- ci: Fix changelog reference ([@sekwah41](https://github.com/sekwah41))
- ci: Updated build pipelines to newer module ([@sekwah41](https://github.com/sekwah41))
#### Authors: 2
- Sekwah ([@sekwah41](https://github.com/sekwah41))
- WhiteSource Renovate ([@renovate-bot](https://github.com/renovate-bot))
---
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
For the release changelogs see [CHANGELOG.md](CHANGELOG.md)
For the snapshot changelogs see [SNAPSHOT_CHANGELOG.md](SNAPSHOT_CHANGELOG.md)
## 0.6.0 (2021-05-19)
### Features
* **proxy:** Added a ForceEnableProxySupport config option ([99c810e](https://github.com/sekwah41/Advanced-Portals/commit/99c810e1beeee743734ec451ffe5df312eec8726))
* **proxy:** Added Velocity support ([b243b4d](https://github.com/sekwah41/Advanced-Portals/commit/b243b4d889b8039cb800d981d44d85da06ff62d5))
* **proxy:** Modern forwarding will be automatically detected. ([f3c8f73](https://github.com/sekwah41/Advanced-Portals/commit/f3c8f73975857a4e5d31a6a21111eee8b7888bdd))
* Added configurable proxy teleport delay ([a1121ad](https://github.com/sekwah41/Advanced-Portals/commit/a1121adc10addfcce515d1358d1274232109fdfd))
### 0.5.12
* Added support for Velocity.
* Also fixed some issues with entity teleporting.
### 0.5.11
* Missing changelogs
### 0.5.10
* Missing changelogs
### 0.5.10
* Added fix for command portals spam triggering if they didn't teleport you out.
* Made portals not activate if you were teleported into them by another portal (to allow linking zones like a star trek warp pad)
### 0.5.9
* Missing changelogs
### 0.5.8
* Missing changelogs
### 0.5.7
* Extra checks added by @tmantti to fix slow connections to new servers from activating the destination location too quick.
### 0.5.6
* Fixed packet exploit affecting destinations (only effecting versions 0.5.0 to 0.5.5).
### 0.5.5
* Added support for 1.16
* Reworked chat menus to better use Spigot API
* Changed edit menu to have Activate instead of Teleport to destination
* Compat code changed. You must now use Spigot rather than CraftBukkit.
### 0.5.4
* Added bungee backup methods to ensure bungee and desti work correctly together
* Fixed protection region issue
* Reworked the warp command and fixed the surrounding permissions
* Disabling gateway beams is now enabled for placing the blocks as well as by a few other means
### 0.5.3
* Fixed destination bug.
### 0.5.2
* Fixed issue with bungee destinations.
### 0.5.1
* Fixed warp permission info
### 0.5.0
* Added command:
* Fix for bungee warps
### 0.4.0
* Individual portal cooldown added
* Bungee improvements
### Earlier
* See github releases and spigot pages for more info.

View File

@ -4,4 +4,4 @@ REM Use this file for testing cases for different versions, just drag the versio
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.
PAUSE

View File

@ -1,674 +1,63 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Preamble
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
0. Additional Definitions.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
“The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
1. Exception to Section 3 of the GNU GPL.
The precise terms and conditions for copying, distribution and
modification follow.
You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
TERMS AND CONDITIONS
2. Conveying Modified Versions.
0. Definitions.
If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
"This License" refers to version 3 of the GNU General Public License.
a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license document.
4. Combined Works.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
A "covered work" means either the unmodified Program or a work based
on the Program.
a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
5. Combined Libraries.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
1. Source Code.
Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Advanced lightweight portal plugin for minecraft.
Copyright (C) 2016 sekwah41
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Advanced-Portals Copyright (C) 2016 sekwah41
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.

View File

@ -1,31 +1,64 @@
Advanced Portals ![Build Status](https://travis-ci.org/Plugineers/Advanced-Portals.svg?branch=portals-old)
================
<h2>Build Instructions</h2>
<p>(This part is mostly aimed for beginners in case they haven't seen a maven project)
<p>You must have maven installed then run "gradle build". Once the build is complete you will have a useable jar file in the folder named "build/lib" listed as Advanced-Portals-x.x.x-snapshot.jar</p>
![Advanced Portals](https://i.imgur.com/UIF6cQR.png)
<h2>Plugin Info</h2>
<p><b>NOTE:</b> This is the old version of Advanced Portals, look in the appropriate branch for the newer versions.</p>
[![Discord](https://img.shields.io/discord/168282484037910528.svg?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/fAJ3xJg)
[![](https://img.shields.io/github/contributors/sekwah41/Advanced-Portals.svg?style=for-the-badge&logo=github)](https://github.com/sekwah41/Advanced-Portals/graphs/contributors)
[![](https://img.shields.io/github/issues/sekwah41/Advanced-Portals.svg?style=for-the-badge&logo=github)](https://github.com/sekwah41/Advanced-Portals/issues)
[![](https://img.shields.io/github/issues-pr/sekwah41/Advanced-Portals.svg?style=for-the-badge&logo=github)](https://github.com/sekwah41/Advanced-Portals/pulls)
[![](https://img.shields.io/github/forks/sekwah41/Advanced-Portals.svg?style=for-the-badge&logo=github)](https://github.com/sekwah41/Advanced-Portals/network/members)
[![](https://img.shields.io/github/stars/sekwah41/Advanced-Portals.svg?style=for-the-badge&logo=github)](https://github.com/sekwah41/Advanced-Portals/stargazers)
[![](https://img.shields.io/github/license/sekwah41/Advanced-Portals.svg?logo=github&style=for-the-badge)](https://github.com/sekwah41/Advanced-Portals/blob/master/LICENSE.md)
<p>An advanced portals plugin for bukkit made by sekwah41 designed to have a wide range of features which are easy to use. It adds a bunch of commands to create and edit portals and destinations. This plugin not only enable normal teleportation but also cross server teleportation for networks using bungee.</p>
Advanced Portals ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/sekwah41/Advanced-Portals/Build%20Project/master)
==============
An advanced portals plugin for bukkit made by sekwah41 designed to have a wide range of features which are easy to use. It adds a bunch of commands to create and edit portals and destinations. This plugin not only enable normal teleportation but also cross server teleportation for networks using bungee.
<a href="https://github.com/Plugineers/Advanced-Portals/wiki/Commands">List Of Commands</a>
# Recode
We are currently slowly working on a complete re-code of the plugin with a full API.
For now maintaining the current 1.13+ spigot versions is our main priority.
<a href="https://www.spigotmc.org/resources/advanced-portals.14356/">Spigot Page</a>
# Help
[Command Documentation & Guides](https://www.guilded.gg/Sekwah/groups/MDqAZyrD/channels/72ffdaa3-9273-4722-bf47-b75408b371af/docs/1807463914)
<a href="http://dev.bukkit.org/bukkit-plugins/advanced-portals/">Bukkit Page</a>
<br>
<br>
<p>Usage Data</p>
[List Of Commands](https://github.com/sekwah41/Advanced-Portals/wiki/Commands)
<img src="http://i.mcstats.org/AdvancedPortals/Global+Statistics.borderless.png" alt="Global Plugin Stats" title="Global Plugin Stats">
[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.
<p>To get the needed bukkit versions download the spigot buildtools and run the appropriate commands for the versions listed in the pom file.</p>
<p>e.g. "java -jar BuildTools.jar --rev 1.10.2" (Enter this into git bash)</p>
# Contributing
<p>Use the versions to test code before you turn it into reflection or suggest it to be turned into reflection.</p>
Don't worry about updating the file numbers in `bungee.yml`, `plugin.yml` and `AdvancedPortalsPlugin.java`.
They will be updated automatically before builds.
Please ensure that your commits are in the following style for PR's
https://www.conventionalcommits.org/en/v1.0.0/
Accepted tags mostly follow the Angular style and are meant to only loosely be followed.
When commits close an issue refer in the commit description in the following style (Refs #1, #2, #3)
## Types available
* **build**: Changes that affect the build system or external dependencies
* **ci**: Changes to our CI configuration files and scripts
* **docs**: Documentation only changes
* **feat**: A new feature
* **fix**: A bug fix
* **perf**: A code change that improves performance
* **refactor**: A code change that neither fixes a bug nor adds a feature
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
<!---
We don't currently do tests. But in case.
* **test**: Adding missing tests or correcting existing tests
-->
## Scopes available
Scopes are only needed if relating to specific features just to make them easier to find.
_I'll expand the list as I work more on the project._
* **proxy** (Proxy specific features and issues)
<p>You should never use direct craftbukkit references in public builds as it would only work in one spigot version</p>

View File

@ -1,10 +1,50 @@
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: 'maven'
apply plugin: 'idea'
apply plugin: 'eclipse'
def branch = System.getenv("GITHUB_REF");
if (branch != null) {
branch = branch.replace('refs/heads/', '')
}
def isCanary = version.toString().contains('canary')
group = 'com.sekwah.advancedportals'
version = '0.0.50-snapshot'
description = ""
@ -15,27 +55,271 @@ 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 "http://repo.maven.apache.org/maven2" }
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 {
compile "org.bukkit:bukkit:1.14.1-R0.1-SNAPSHOT"
compile "io.netty:netty-all:4.0.4.Final"
//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"
@ -43,4 +327,79 @@ task runJar() {
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'
}

View File

@ -1,3 +1,7 @@
# https://docs.gradle.org/current/userguide/build_environment.html
# Disable with --no-build-cache
org.gradle.caching=true
org.gradle.caching=true
github=https://github.com/sekwah41/Advanced-Portals
curse_project_id=86001
version=0.9.2

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

Binary file not shown.

View File

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

244
gradlew vendored Executable file
View File

@ -0,0 +1,244 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

92
gradlew.bat vendored Normal file
View File

@ -0,0 +1,92 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

12
package.json Normal file
View File

@ -0,0 +1,12 @@
{
"devDependencies": {
"conventional-changelog-angular": "5.0.13",
"@auto-it/conventional-commits": "10.37.6",
"@auto-it/exec": "10.37.6",
"@auto-it/first-time-contributor": "10.37.6",
"@auto-it/gradle": "10.37.6",
"@auto-it/released": "10.37.6",
"@auto-it/upload-assets": "10.37.6",
"auto": "10.37.6"
}
}

15
renovate.json Normal file
View File

@ -0,0 +1,15 @@
{
"extends": [
"config:base"
],
"packageRules": [
{
"commitMessagePrefix": "chore(deps):",
"matchUpdateTypes": ["minor", "patch"],
"automerge": true,
"automergeType": "branch",
"groupName": "Deps",
"schedule": ["every weekend"]
}
]
}

View File

@ -1,758 +0,0 @@
package com.sekwah.advancedportals;
import com.sekwah.advancedportals.api.events.WarpEvent;
import com.sekwah.advancedportals.api.portaldata.PortalArg;
import com.sekwah.advancedportals.listeners.Listeners;
import com.sekwah.advancedportals.portals.AdvancedPortal;
import com.sekwah.advancedportals.portals.Portal;
import org.bukkit.*;
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.material.Wool;
import org.bukkit.metadata.FixedMetadataValue;
import java.util.*;
public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
private final ArrayList<String> blockMaterialList = new ArrayList<>();
private AdvancedPortalsPlugin plugin;
private int portalArgsStringLength = 0;
// TODO recode the portal args to be put into a hashmap and use a string array
// to store all possible portal arguments. Makes code shorter and possibly more efficient.
//private HashMap<String, String> portalArgs = new HashMap<>();
public AdvancedPortalsCommand(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
for(Material material : Material.values()) {
this.blockMaterialList.add("triggerblock:" + material.name());
}
plugin.getCommand("advancedportals").setExecutor(this);
}
@SuppressWarnings("deprecation")
@Override
public boolean onCommand(CommandSender sender, Command cmd, String command, String[] args) {
//System.out.printf("%s %s %s %s%n", sender, cmd, command, args );
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "portals.yml");
if(!(sender instanceof Player)) {
sender.sendMessage(PluginMessages.customPrefixFail + " You cannot use commands with the console.");
return true;
}
Player player = (Player) sender;
PlayerInventory inventory = player.getInventory();
if (sender.hasPermission("advancedportals.portal")) {
if (args.length > 0) { switch (args[0].toLowerCase()) {
case "warp":
if (args.length == 2 && player.hasPermission("advancedportals.portal.warp")){
for (AdvancedPortal portal: Portal.portals){
if (args[1].equalsIgnoreCase(portal.getName())){
if (portal.inPortal.contains(player.getUniqueId())) return true;
WarpEvent warpEvent = new WarpEvent(player, portal);
plugin.getServer().getPluginManager().callEvent(warpEvent);
if (!warpEvent.isCancelled()) Portal.activate(player, portal);
break;
}
}
}
sendMenu(player, "Help Menu: Warp", "\u00A76/" + command + " warp <name> \u00A7a- teleport to warp name");
break;
case "wand":
case "selector":
String ItemID = config.getConfig().getString("AxeItemId");
Material WandMaterial = Material.getMaterial(ItemID);
if (WandMaterial == null) {
WandMaterial = Material.IRON_AXE;
}
ItemStack regionselector = new ItemStack(WandMaterial);
ItemMeta selectorname = regionselector.getItemMeta();
selectorname.setDisplayName("\u00A7ePortal Region Selector");
selectorname.setLore(Arrays.asList("\u00A7rThis wand with has the power to help"
, "\u00A7r create portals bistowed upon it!"));
regionselector.setItemMeta(selectorname);
inventory.addItem(regionselector);
sender.sendMessage(PluginMessages.customPrefix + " You have been given a \u00A7ePortal Region Selector\u00A7a!");
break;
case "portalblock":
// TODO change this to a purple wool block and give it a name with a color. Then listen to when its placed.
// Also do this for other blocks such as gateways and end portals just in case they want it.
ItemStack portalBlock = new Wool(DyeColor.PURPLE).toItemStack(1);
ItemMeta blockName = portalBlock.getItemMeta();
blockName.setDisplayName("\u00A75Portal Block Placer");
blockName.setLore(Arrays.asList("\u00A7rThis wool is made of a magical substance",
"\u00A7rRight Click: Place portal block",
"\u00A7rLeft Click: Rotate portal block"));
portalBlock.setItemMeta(blockName);
inventory.addItem(portalBlock);
sender.sendMessage(PluginMessages.customPrefix + " You have been given a \u00A7ePortal Block\u00A7a!");
break;
case "endportalblock":
// TODO change this to a purple wool block and give it a name with a color. Then listen to when its placed.
// Also do this for other blocks such as gateways and end portals just in case they want it.
portalBlock = new Wool(DyeColor.BLACK).toItemStack(1);
blockName = portalBlock.getItemMeta();
blockName.setDisplayName("\u00A78End Portal Block Placer");
blockName.setLore(Arrays.asList("\u00A7rThis wool is made of a magical substance",
"\u00A7rRight Click: Place portal block"));
portalBlock.setItemMeta(blockName);
inventory.addItem(portalBlock);
sender.sendMessage(PluginMessages.customPrefix + " You have been given a \u00A7ePortal Block\u00A7a!");
break;
case "gatewayblock":
// TODO change this to a purple wool block and give it a name with a color. Then listen to when its placed.
// Also do this for other blocks such as gateways and end portals just in case they want it.
portalBlock = new Wool(DyeColor.BLACK).toItemStack(1);
blockName = portalBlock.getItemMeta();
blockName.setDisplayName("\u00A78Gateway Block Placer");
blockName.setLore(Arrays.asList("\u00A7rThis wool is made of a magical substance",
"\u00A7rRight Click: Place portal block"));
portalBlock.setItemMeta(blockName);
inventory.addItem(portalBlock);
sender.sendMessage(PluginMessages.customPrefix + " You have been given a \u00A7ePortal Block\u00A7a!");
break;
case "create":
if (player.hasMetadata("Pos1World") && player.hasMetadata("Pos2World")) {
if (player.getMetadata("Pos1World").get(0).asString().equals(player.getMetadata("Pos2World").get(0).asString())
&& player.getMetadata("Pos1World").get(0).asString().equals(player.getLocation().getWorld().getName())) {
if (args.length >= 2) { // may make this next piece of code more efficient, maybe check against a list of available variables or something
// TODO change system to use arrays and hashmaps
boolean hasName = false;
boolean hasTriggerBlock = false;
boolean hasDestination = false;
boolean isBungeePortal = false;
boolean needsPermission = false;
boolean executesCommand = false;
String destination = null;
String portalName = null;
String triggerBlock = null;
String serverName = null;
String permission = null;
String portalCommand = null;
ArrayList<PortalArg> extraData = new ArrayList<>();
for (int i = 1; i < args.length; i++) {
if (args[i].toLowerCase().startsWith("name:") && args[i].length() > 5) {
hasName = true;
portalName = args[i].replaceFirst("name:", "");
} else if (args[i].toLowerCase().startsWith("name:")) {
player.sendMessage(PluginMessages.customPrefixFail + " You must include a name for the portal that isnt nothing!");
return true;
} else if (args[i].toLowerCase().startsWith("destination:") && args[i].length() > 12) {
hasDestination = true;
destination = args[i].toLowerCase().replaceFirst("destination:", "");
} else if (args[i].toLowerCase().startsWith("desti:") && args[i].length() > 6) {
hasDestination = true;
destination = args[i].toLowerCase().replaceFirst("desti:", "");
} else if (args[i].toLowerCase().startsWith("triggerblock:") && args[i].length() > 13) {
hasTriggerBlock = true;
triggerBlock = args[i].toLowerCase().replaceFirst("triggerblock:", "");
} else if (args[i].toLowerCase().startsWith("triggerblock:") && args[i].length() > 13) {
hasTriggerBlock = true;
triggerBlock = args[i].toLowerCase().replaceFirst("triggerblock:", "");
} else if (this.startsWithPortalArg("bungee:", args[i])) {
isBungeePortal = true;
serverName = args[i].substring("bungee:".length());
} else if (args[i].toLowerCase().startsWith("permission:") && args[i].length() > 11) {
needsPermission = true;
permission = args[i].toLowerCase().replaceFirst("permission:", "");
extraData.add(new PortalArg("permission", permission));
} else if (args[i].toLowerCase().startsWith("command:") && args[i].length() > 8) {
executesCommand = true;
portalCommand = parseArgVariable(args, i, "command:");
i += this.portalArgsStringLength - 1;
if(portalCommand.startsWith("#") && !(this.plugin.getSettings().hasCommandLevel("c")
&& (sender.hasPermission("advancedportals.createportal.commandlevel.console"))
|| (this.plugin.getSettings().hasCommandLevel("k") && sender.isOp()))) {
player.sendMessage(PluginMessages.customPrefixFail + " You need permission to make a console command portal!");
return true;
}
else if(portalCommand.startsWith("!") && !(this.plugin.getSettings().hasCommandLevel("o")
&& (sender.hasPermission("advancedportals.createportal.commandlevel.op"))
|| (this.plugin.getSettings().hasCommandLevel("p") && sender.isOp()))) {
player.sendMessage(PluginMessages.customPrefixFail + " You need permission to make a op command portal!");
return true;
}
else if(portalCommand.startsWith("^") && !(this.plugin.getSettings().hasCommandLevel("p")
&& (sender.hasPermission("advancedportals.createportal.commandlevel.perms"))
|| (this.plugin.getSettings().hasCommandLevel("e") && sender.isOp()))) {
player.sendMessage(PluginMessages.customPrefixFail + " You need permission to make a all perms command portal!");
return true;
}
extraData.add(new PortalArg("command.1", portalCommand));
}
}
if (!hasName) {
player.sendMessage(PluginMessages.customPrefixFail + " You must include a name for the portal that you are creating in the variables!");
return true;
}
World world = org.bukkit.Bukkit.getWorld(player.getMetadata("Pos1World").get(0).asString());
Location pos1 = new Location(world, player.getMetadata("Pos1X").get(0).asInt(), player.getMetadata("Pos1Y").get(0).asInt(), player.getMetadata("Pos1Z").get(0).asInt());
Location pos2 = new Location(world, player.getMetadata("Pos2X").get(0).asInt(), player.getMetadata("Pos2Y").get(0).asInt(), player.getMetadata("Pos2Z").get(0).asInt());
ConfigAccessor desticonfig = new ConfigAccessor(plugin, "destinations.yml");
String destiPosX = desticonfig.getConfig().getString(destination + ".pos.X");
if (!Portal.portalExists(portalName)) {
player.sendMessage("");
player.sendMessage(PluginMessages.customPrefix + "\u00A7e You have created a new portal with the following details:");
player.sendMessage("\u00A7aname: \u00A7e" + portalName);
if (hasDestination) {
if (destiPosX == null) {
player.sendMessage("\u00A7cdestination: \u00A7e" + destination + " (destination does not exist)");
return true;
}
else{
player.sendMessage("\u00A7adestination: \u00A7e" + destination);
}
} else {
player.sendMessage("\u00A7cdestination: \u00A7eN/A (will not teleport to a location)");
}
if (isBungeePortal) {
player.sendMessage("\u00A7abungee: \u00A7e" + serverName);
}
if (needsPermission) {
player.sendMessage("\u00A7apermission: \u00A7e" + permission);
} else {
player.sendMessage("\u00A7apermission: \u00A7e(none needed)");
}
if (executesCommand) {
player.sendMessage("\u00A7acommand: \u00A7e" + portalCommand);
}
Material triggerBlockMat;
if (hasTriggerBlock) {
triggerBlockMat = Material.getMaterial(triggerBlock.toUpperCase());
if (triggerBlockMat != null) {
player.sendMessage("\u00A7atriggerBlock: \u00A7e" + triggerBlock.toUpperCase());
PortalArg[] portalArgs = new PortalArg[extraData.size()];
portalArgs = extraData.toArray(portalArgs);
player.sendMessage(Portal.create(pos1, pos2, portalName, destination, triggerBlockMat, serverName, portalArgs));
} else {
hasTriggerBlock = false;
ConfigAccessor Config = new ConfigAccessor(plugin, "config.yml");
player.sendMessage("\u00A7ctriggerBlock: \u00A7edefault(" + Config.getConfig().getString("DefaultPortalTriggerBlock") + ")");
player.sendMessage("\u00A7cThe block " + triggerBlock.toUpperCase() + " is not a valid block name in minecraft so the trigger block has been set to the default!");
PortalArg[] portalArgs = new PortalArg[extraData.size()];
portalArgs = extraData.toArray(portalArgs);
player.sendMessage(Portal.create(pos1, pos2, portalName, destination, serverName, portalArgs));
}
} else {
ConfigAccessor Config = new ConfigAccessor(plugin, "config.yml");
player.sendMessage("\u00A7atriggerBlock: \u00A7edefault(" + Config.getConfig().getString("DefaultPortalTriggerBlock") + ")");
PortalArg[] portalArgs = new PortalArg[extraData.size()];
portalArgs = extraData.toArray(portalArgs);
player.sendMessage(Portal.create(pos1, pos2, portalName, destination, serverName, portalArgs));
}
} else {
sender.sendMessage(PluginMessages.customPrefixFail + " A portal by that name already exists!");
}
// add code to save the portal to the portal config and reload the portals
player.sendMessage("");
} else {
player.sendMessage(PluginMessages.customPrefixFail + " You need to at least add the name of the portal as a variable, \u00A7cType \u00A7e/portal variables\u00A7c"
+ " for a full list of currently available variables and an example command!");
}
} else {
player.sendMessage(PluginMessages.customPrefixFail + " The points you have selected need to be in the same world!");
}
} else {
player.sendMessage(PluginMessages.customPrefixFail + " You need to have two points selected to make a portal!");
}
break;
case "variables" :
sender.sendMessage(PluginMessages.customPrefix + " \u00A77Variables \u00A7c: \u00A7aname, triggerBlock, desti, destination, bungee, permission, command");
sender.sendMessage("");
sender.sendMessage("\u00A7aExample command: \u00A7e/portal create name:test triggerId:portal");
break;
case "select":
// TODO finish the select command and the hit block to replace!
if (!player.hasMetadata("selectingPortal")) {
if (args.length > 1) {
if (Portal.portalExists(args[1])) {
player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, args[1]));
player.sendMessage(PluginMessages.customPrefix + " You have selected\u00A7e " + args[1] + "\u00A7a.");
} else {
player.sendMessage(PluginMessages.customPrefixFail + " No portal by the name \u00A7e" + args[1] + "\u00A7c exists (maybe you got the caps wrong)\n Try typing \u00A7e/portal select\u00A7c and hit inside the apropriate portals area!");
}
} else {
player.sendMessage(PluginMessages.customPrefix + " Hit a block inside the portal region to select the portal!");
player.setMetadata("selectingPortal", new FixedMetadataValue(plugin, true));
}
} else {
player.removeMetadata("selectingPortal", plugin);
player.sendMessage(PluginMessages.customPrefixFail + " Portal selection cancelled!");
}
break;
case "unselect":
if(player.getMetadata("selectedPortal").size() != 0){
player.sendMessage(PluginMessages.customPrefix + " You have unselected\u00A7e" + player.getMetadata("selectedPortal").get(0).asString()
+ "\u00A7a.");
}
else{
player.sendMessage(PluginMessages.customPrefixFail + " You had no portal selected!");
}
case "gui" :
if (args.length > 1) {
if (args[1].toLowerCase().equals("remove") && args.length > 2) {
sender.sendMessage("");
sender.sendMessage(PluginMessages.customPrefixFail + " Are you sure you would like to remove the portal \u00A7e" + args[2] + "\u00A7c?");
sender.sendMessage("");
plugin.compat.sendRawMessage("{\"text\":\" \",\"extra\":[{\"text\":\"\u00A7e[Yes]\",\"hoverEvent\":{\"action\":\"show_text\"," +
"\"value\":\"Confirm removing this portal\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal remove " + args[2] + "\"}}, " +
"{\"text\":\" \"},{\"text\":\"\u00A7e[No]\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Cancel removing this portal\"}" +
",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal edit " + args[2] + "\"}}]}", player);
sender.sendMessage("");
}
}
break;
case "edit":
if (args.length > 1) {
if (Portal.portalExists(args[1])) {
player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, args[1]));
portalEditMenu(sender, portalConfig, args[1]);
} else {
sender.sendMessage(PluginMessages.customPrefixFail + " No portal by the name \u00A7e" + args[1] + "\u00A7c exists!");
}
} else {
if (player.getMetadata("selectedPortal").size() != 0) {
String portalName = player.getMetadata("selectedPortal").get(0).asString();
String posX = portalConfig.getConfig().getString(portalName + ".pos1.X");
if (posX != null) {
portalEditMenu(sender, portalConfig, portalName);
} else {
sender.sendMessage(PluginMessages.customPrefixFail + " The portal you had selected no longer seems to exist!");
player.removeMetadata("selectedPortal", plugin);
}
} else {
sender.sendMessage(PluginMessages.customPrefixFail + " No portal has been defined or selected!");
}
}
break;
case "rename":
// not finished yet /
if (args.length > 1) {
if (player.getMetadata("selectedPortal").size() != 0) {
String portalName = player.getMetadata("selectedPortal").get(0).asString();
if (portalName.toLowerCase() != args[1].toLowerCase()) {
String posX = portalConfig.getConfig().getString(portalName + ".pos1.X");
String newPortalPosX = portalConfig.getConfig().getString(args[1] + ".pos1.X");
if (posX != null && newPortalPosX == null) {
Portal.rename(portalName, args[1]);
sender.sendMessage(PluginMessages.customPrefix + " The portal \u00A7e" + portalName + "\u00A7a has been renamed to \u00A7e" + args[1] + "\u00A7a.");
player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, args[1]));
} else if (newPortalPosX != null) {
sender.sendMessage(PluginMessages.customPrefixFail + " There is already a portal with the name \u00A7e" + args[1] + "\u00A7c!");
} else {
sender.sendMessage(PluginMessages.customPrefixFail + " The portal you had selected no longer seems to exist!");
player.removeMetadata("selectedPortal", plugin);
}
} else {
sender.sendMessage(PluginMessages.customPrefixFail + " The portal you have selected is already called that!");
}
} else {
sender.sendMessage(PluginMessages.customPrefixFail + " No portal has been defined or selected!");
}
} else {
sender.sendMessage(PluginMessages.customPrefixFail + " You must select a portal first and then type \u00A7e/portal rename (new name)\u00A7c!");
}
break;
case "command":
if (player.getMetadata("selectedPortal").size() != 0) {
String portalName = player.getMetadata("selectedPortal").get(0).asString();
if (args.length > 1) {
// TODO add the command autocompletes, add, remove and show
if (args[1].toLowerCase().equals("add")) {
if (args.length > 2) {
String portalCommand = args[2];
for (int i = 3; i < args.length; i++) {
portalCommand += args[i];
}
if (Portal.addCommand(portalName, portalCommand)) {
sender.sendMessage(PluginMessages.customPrefixFail + " Command added to portal!");
} else {
sender.sendMessage(PluginMessages.customPrefixFail + " Failed to add command to portal!");
}
} else {
sender.sendMessage(PluginMessages.customPrefixFail + " You must actually specify a command to execute!");
}
} else if (args[1].toLowerCase().equals("remove")) {
// Specify what line to remove
} else if (args[1].toLowerCase().equals("show")) {
} else {
sender.sendMessage(PluginMessages.customPrefixFail + " You must specify to \u00A7eadd\u00A7c or \u00A7eremove a command!");
}
} else {
sender.sendMessage(PluginMessages.customPrefixFail + " You must specify to \u00A7eadd\u00A7c or \u00A7eremove\u00A7c a command!");
}
} else {
}
break;
case "remove":
if (args.length > 1) {
String posX = portalConfig.getConfig().getString(args[1] + ".pos1.X");
if (posX != null) {
Portal.remove(args[1]);
sender.sendMessage(PluginMessages.customPrefixFail + " The portal \u00A7e" + args[1] + "\u00A7c has been removed!");
} else {
sender.sendMessage(PluginMessages.customPrefixFail + " No portal by that name exists!");
}
} else {
if (player.getMetadata("selectedPortal").size() != 0) {
String portalName = player.getMetadata("selectedPortal").get(0).asString();
String posX = portalConfig.getConfig().getString(portalName + ".pos1.X");
if (posX != null) {
Portal.remove(portalName);
sender.sendMessage(PluginMessages.customPrefixFail + " The portal \u00A77" + portalName + "\u00A7c has been removed!");
} else {
sender.sendMessage(PluginMessages.customPrefixFail + " The portal you had selected no longer seems to exist!");
player.removeMetadata("selectedPortal", plugin);
}
} else {
sender.sendMessage(PluginMessages.customPrefixFail + " No portal has been defined or selected!");
}
}
break;
case "help":
helpCommand(sender, command, args);
break;
case "show":
if (args.length > 1) {
String posX = portalConfig.getConfig().getString(args[1] + ".pos1.X");
if (posX != null) {
Selection.show(player, this.plugin, args[1]);
} else {
sender.sendMessage(PluginMessages.customPrefixFail + " No portal by that name exists!");
}
} else {
if (player.getMetadata("selectedPortal").size() != 0) {
player.sendMessage(PluginMessages.customPrefix + " Your currently selected portal has been shown, it will dissapear shortly!");
Selection.show(player, this.plugin, player.getMetadata("selectedPortal").get(0).asString());
} else if (player.hasMetadata("Pos1World") && player.hasMetadata("Pos2World")) {
if (player.getMetadata("Pos1World").get(0).asString().equals(player.getMetadata("Pos2World").get(0).asString())
&& player.getMetadata("Pos1World").get(0).asString().equals(player.getLocation().getWorld().getName())) {
player.sendMessage(PluginMessages.customPrefix + " Your currently selected area has been shown, it will dissapear shortly!");
Selection.show(player, this.plugin, null);
}
} else {
player.sendMessage(PluginMessages.customPrefixFail + " No regions selected!");
}
}
break;
case "reload":
sender.sendMessage(PluginMessages.customPrefix + " Reloaded values!");
Listeners.reloadValues(plugin);
Portal.loadPortals();
break;
case "list" :
String message = PluginMessages.customPrefix + " \u00A77Portals \u00A7c:\u00A7a";
LinkedList<String> portals = new LinkedList<>();
for (AdvancedPortal portal : Portal.portals) {
portals.add(portal.getName());
}
Collections.sort(portals);
for (Object portalName : portals.toArray()) {
message = message + " " + portalName;
}
player.sendMessage(message);
break;
default:
PluginMessages.UnknownCommand(sender, command);
}
} else {
PluginMessages.UnknownCommand(sender, command);
}
} else {
PluginMessages.NoPermission(sender, command);
}
return true;
}
private boolean startsWithPortalArg(String portalArg, String arg) {
return arg.toLowerCase().startsWith(portalArg) && arg.length() > portalArg.length();
}
private void helpCommand(CommandSender sender, String command, String[] args) {
// Add pages if there starts to become too many
if(args.length == 1) {
sendMenu(sender, "Help Menu",
"\u00A76/" + command + " selector \u00A7a- gives you a region selector",
"\u00A76/" + command + " create \u00A7c[tags] \u00A7a- creates a portal with a selection ",
"\u00A76/" + command + " portalblock \u00A7a- gives you a portal block",
"\u00A76/" + command + " endportalblock \u00A7a- gives you an end portal block",
"\u00A76/" + command + " gatewayblock \u00A7a- gives you a gateway block",
"\u00A76/" + command + " select \u00A7a- selects an existing portal",
"\u00A76/" + command + " unselect \u00A7a- unselects the current portal",
"\u00A76/" + command + " command \u00A7a- adds or removes commands from the selected portal",
"\u00A76/" + command + " help \u00A7a- shows this help section",
"\u00A76/" + command + " help <arg> \u00A7a- shows help for the specified arg",
"\u00A76/" + command + " remove \u00A7a- removes a portal",
"\u00A76/" + command + " list \u00A7a- lists all the current portals",
"\u00A76/" + command + " warp <name> \u00A7a- teleport to warp name",
"\u00A76/" + command + " variables \u00A7a- lists all available tags");
}
else if(args.length > 1){
if(args[1].toLowerCase().equals("help")) {
sendMenu(sender, "Help Command",
"Shows the help section. You can also use a single argument after it to show the " +
"help section for the corresponding command.");
}
else if(args[1].toLowerCase().equals("portalblock")) {
sendMenu(sender, "Help Command",
"Gives you a special wool block to place portal blocks.",
"",
"\u00A7eLeft Click: \u00A76Rotates the hit portal block",
"\u00A7eRight Click: \u00A76Placed a portal block");
}
else if(args[1].toLowerCase().equals("endportalblock")) {
sendMenu(sender, "Help Command",
"Gives you a special wool block to place end portal blocks.",
"",
"\u00A7eRight Click: \u00A76Placed a end portal block");
}
else if(args[1].toLowerCase().equals("gatewayblock")) {
sendMenu(sender, "Help Command",
"Gives you a special wool block to place gateway blocks.",
"",
"\u00A7eRight Click: \u00A76Placed a gateway block");
}
else{
sender.sendMessage(PluginMessages.customPrefix + " Either \u00A7e" + args[1] + "\u00A7a is not a command or a help page has not been added yet.");
}
}
}
private void sendMenu(CommandSender sender, String title, String... lines) {
sender.sendMessage(PluginMessages.customPrefix + " " + title);
sender.sendMessage("\u00A7e\u00A7m-----------------------------------");
for(String line : lines){
sender.sendMessage("\u00A7a" + line);
}
sender.sendMessage("\u00A7e\u00A7m-----------------------------------");
}
private String parseArgVariable(String[] args, int currentArg, String argStarter) {
String variableString = args[currentArg].replaceFirst(argStarter, "");
this.portalArgsStringLength = 1;
if (variableString.charAt(0) == '"') {
variableString = variableString.substring(1, variableString.length());
if (variableString.charAt(variableString.length() - 1) != '"') {
currentArg++;
for (; currentArg < args.length; currentArg++) {
variableString += " " + args[currentArg];
this.portalArgsStringLength += 1;
if (variableString.charAt(variableString.length() - 1) == '"') {
variableString = variableString.substring(0, variableString.length() - 1);
break;
}
}
} else {
variableString = variableString.substring(0, variableString.length() - 1);
}
}
return variableString;
}
private void portalEditMenu(CommandSender sender, ConfigAccessor portalConfig, String portalName) {
// make the text gui with the json message for a list of edit commands to be clicked or hovered
// put \" for a " in the json messages
// sadly there is no newline code so these three lines will have to be copied and pasted for each line
// use the usual messages for normal lines but anything that needs special features make sure you use the
// chat steriliser
sender.sendMessage("");
sender.sendMessage(PluginMessages.customPrefix + " Editing: \u00A7e" + portalName);
sender.sendMessage(" \u00A7apos1\u00A7e: " + portalConfig.getConfig().getString(portalName + ".pos1.X")
+ ", " + portalConfig.getConfig().getString(portalName + ".pos1.Y") + ", " + portalConfig.getConfig().getString(portalName + ".pos1.Z"));
sender.sendMessage(" \u00A7apos2\u00A7e: " + portalConfig.getConfig().getString(portalName + ".pos2.X")
+ ", " + portalConfig.getConfig().getString(portalName + ".pos2.Y") + ", " + portalConfig.getConfig().getString(portalName + ".pos2.Z"));
String destination = portalConfig.getConfig().getString(portalName + ".destination");
if (destination != null) {
sender.sendMessage(" \u00A7adestination\u00A7e: " + destination);
} else {
sender.sendMessage(" \u00A7cdestination\u00A7e: null");
}
String trigger = portalConfig.getConfig().getString(portalName + ".triggerblock");
if (trigger != null) {
sender.sendMessage(" \u00A7atriggerBlock\u00A7e: " + trigger);
} else {
sender.sendMessage(" \u00A7ctriggerBlock\u00A7e: null");
}
if (portalConfig.getConfig().getString(portalName + ".portalArgs.command.1") != null) {
int commands = 0;
String command = portalConfig.getConfig().getString(portalName + ".portalArgs.command.1");
// TODO possibly change code so it counds number of subvalues rather than a loop.
while (command != null) {
command = portalConfig.getConfig().getString(portalName + ".portalArgs.command." + ++commands);
}
if (--commands > 1) {
sender.sendMessage(" \u00A7acommands\u00A7e: " + commands + " commands");
} else {
sender.sendMessage(" \u00A7acommands\u00A7e: " + commands + " command");
}
} else {
sender.sendMessage(" \u00A7ccommands\u00A7e: none");
}
sender.sendMessage("");
Player player = (Player) sender;
plugin.compat.sendRawMessage("{\"text\":\"\u00A7aFunctions\u00A7e: \"," +
"\"extra\":[{\"text\":\"\u00A7eRemove\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Remove the selected portal\"},\"clickEvent\":{\"action\":\"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\":\"\u00A7eTeleport\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Teleport to the set destination\n(If there is one)\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/desti warp " + destination + "\"}}]}", player);
sender.sendMessage("");
}
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String command, String[] args) {
LinkedList<String> autoComplete = new LinkedList<String>();
if (sender.hasPermission("advancedportals.createportal")) {
if (args.length == 1 || (args.length == 2 && args[0].toLowerCase().equals("help"))) {
autoComplete.addAll(Arrays.asList("create", "list", "portalblock", "select", "unselect", "command", "selector"
, "show", "gatewayblock", "endportalblock", "variables", "wand", "remove", "rename", "help", "bukkitpage", "helppage", "warp"));
} else if (args[0].toLowerCase().equals("create")) {
boolean hasName = false;
boolean hasTriggerBlock = false;
boolean hasDestination = false;
boolean isBungeePortal = false;
boolean needsPermission = false;
boolean hasCommand = false;
// TODO change auto complete when quotes are opened and closed. Such as autocomplete @Player and stuff when specifying commands
for (int i = 1; i < args.length; i++) {
String argTag = getTag(args[i].toLowerCase());
if (argTag.length() + 1 < args[i].length()) {
switch (argTag) {
case "name":
hasName = true;
break;
case "destination":
hasDestination = true;
break;
case "desti":
hasDestination = true;
break;
case "triggerblock":
hasTriggerBlock = true;
break;
case "bungee":
isBungeePortal = true;
break;
case "permission":
needsPermission = true;
break;
case "command":
hasCommand = true;
break;
}
}
}
if (!hasName) {
autoComplete.add("name:");
}
if (!hasTriggerBlock) {
autoComplete.add("triggerblock:");
}
if (!hasDestination) {
autoComplete.add("destination:");
autoComplete.add("desti:");
}
if (!isBungeePortal) {
autoComplete.add("bungee:");
}
if (!needsPermission) {
autoComplete.add("permission:");
}
if (!hasCommand) {
autoComplete.add("command:");
}
}
}
if (args.length == 2 && args[0].equalsIgnoreCase("warp")){
for (AdvancedPortal portal :Portal.portals){
String perm = portal.getArg("permission");
if (perm == null || sender.hasPermission(perm)){
autoComplete.add(portal.getName());
}
}
}
if(args[args.length-1].startsWith("triggerblock:")) {
autoComplete.addAll(this.blockMaterialList);
}
if(args[args.length-1].startsWith("desti:") || args[args.length-1].startsWith("destination:")) {
String tagStart = args[args.length-1].startsWith("desti:") ? "desti:" : "destination:";
ConfigAccessor destiConfig = new ConfigAccessor(plugin, "destinations.yml");
List<Object> destiObj = Arrays.asList(destiConfig.getConfig().getKeys(false).toArray());
for (Object object : destiObj) {
autoComplete.add(tagStart + object.toString());
}
}
Collections.sort(autoComplete);
for (Object result : autoComplete.toArray()) {
if (!result.toString().startsWith(args[args.length - 1])) {
autoComplete.remove(result);
}
}
return autoComplete;
}
private String getTag(String arg) {
int indexOfSplitter = arg.indexOf(':');
if (indexOfSplitter > 0) {
return arg.substring(0, indexOfSplitter);
}
return "";
}
}

View File

@ -1,122 +0,0 @@
package com.sekwah.advancedportals;
import com.sekwah.advancedportals.compat.CraftBukkit;
import com.sekwah.advancedportals.destinations.Destination;
import com.sekwah.advancedportals.destinations.DestinationCommand;
import com.sekwah.advancedportals.effects.WarpEffects;
import com.sekwah.advancedportals.injector.PacketInjector;
import com.sekwah.advancedportals.listeners.*;
import com.sekwah.advancedportals.metrics.Metrics;
import com.sekwah.advancedportals.portals.Portal;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.*;
public class AdvancedPortalsPlugin extends JavaPlugin {
public CraftBukkit compat = null;
private Settings settings;
public void onEnable() {
String packageName = getServer().getClass().getPackage().getName();
String[] packageSplit = packageName.split("\\.");
String version = packageSplit[packageSplit.length - 1];
saveDefaultConfig();
try {
Metrics metrics = new Metrics(this);
metrics.start();
} catch (IOException e) {
// Failed to submit the stats :-(
}
try {
this.compat = new CraftBukkit(this, version);
ConfigAccessor config = new ConfigAccessor(this, "config.yml");
// TODO reenable and finish but probably focus on the recode first
/*if(config.getConfig().getBoolean("DisableGatewayBeam", true)) {
new PacketInjector(this, version);
}*/
ConfigAccessor portalConfig = new ConfigAccessor(this, "portals.yml");
portalConfig.saveDefaultConfig();
ConfigAccessor destinationConfig = new ConfigAccessor(this, "destinations.yml");
destinationConfig.saveDefaultConfig();
this.settings = new Settings(this);
// Loads the portal and destination editors
new Portal(this);
new Destination(this);
this.registerCommands();
new WarpEffects(this);
this.addListeners();
this.setupDataCollector();
this.setupBungee();
this.getServer().getConsoleSender().sendMessage("\u00A7aAdvanced portals have been successfully enabled!");
} catch (ClassNotFoundException e) {
e.printStackTrace();
this.getLogger().warning("This version of craftbukkit is not yet supported, please notify sekwah and tell him about this version v:" + version);
this.getLogger().warning("Along with the above stacktrace");
this.setEnabled(false);
} catch (IllegalArgumentException |
NoSuchFieldException | SecurityException | NoSuchMethodException e) {
e.printStackTrace();
this.getLogger().warning("Something went wrong, please notify sekwah and tell him about this version v:" + version);
this.getLogger().warning("Along with the above stacktrace");
this.setEnabled(false);
}
// 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() {
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeListener(this));
}
public void onDisable() {
this.getServer().getConsoleSender().sendMessage("\u00A7cAdvanced portals are being disabled!");
}
public Settings getSettings() {
return settings;
}
}

View File

@ -1,40 +0,0 @@
package com.sekwah.advancedportals;
/**
* This contains generally used settings mostly
*/
public class Settings {
private int currentWarpParticles = 0;
private int currentWarpSound = 0;
private String commandLevels = "n";
public Settings(AdvancedPortalsPlugin plugin) {
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
currentWarpParticles = config.getConfig().getInt("WarpParticles");
currentWarpSound = config.getConfig().getInt("WarpSound");
commandLevels = config.getConfig().getString("CommandLevels", "opchek");
if(commandLevels.contains("n") || commandLevels.equals("")) {
commandLevels = "n";
}
}
public String getCommandLevels(){
return this.commandLevels;
}
public boolean hasCommandLevel(String level){
return this.commandLevels.contains(level);
}
public int getCurrentWarpSound() {
return currentWarpSound;
}
public int getCurrentWarpParticles() {
return currentWarpParticles;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -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;
}
}

View File

@ -1,26 +1,34 @@
package com.sekwah.advancedportals;
package com.sekwah.advancedportals.bukkit;
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
public class PluginMessages {
private AdvancedPortalsPlugin plugin;
private static String WARP_MESSAGE;
public boolean useCustomPrefix = false;
public static String customPrefix = "\u00A7a[\u00A7eAdvancedPortals\u00A7a]";
public static String customPrefixFail = "\u00A7c[\u00A77AdvancedPortals\u00A7c]";
public PluginMessages (AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
ConfigAccessor config = new ConfigAccessor(this.plugin, "config.yml");
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
this.useCustomPrefix = config.getConfig().getBoolean("UseCustomPrefix");
if (useCustomPrefix) {
PluginMessages.customPrefix = config.getConfig().getString("CustomPrefix").replaceAll("&", "\u00A7");
PluginMessages.customPrefixFail = config.getConfig().getString("CustomPrefixFail").replaceAll("&", "\u00A7");
PluginMessages.customPrefix = config.getConfig().getString("CustomPrefix").replaceAll("&(?=[0-9a-fk-or])", "\u00A7");
PluginMessages.customPrefixFail = config.getConfig().getString("CustomPrefixFail").replaceAll("&(?=[0-9a-fk-or])", "\u00A7");
}
WARP_MESSAGE = ChatColor.translateAlternateColorCodes('&', config.getConfig().getString("WarpMessage", "&aYou have warped to &e<warp>&a"));
}
// This class is so then the common messages in commands or just messages over the commands are the same and can be
// easily changed.
public static String getWarpMessage(String warp) {
String cleanedWarp = warp.replace("_", " ");
return WARP_MESSAGE.replace("<warp>", cleanedWarp);
}
public static void UnknownCommand(CommandSender sender, String command) {
sender.sendMessage(customPrefixFail + " You need to type something after /" + command + "\n");
sender.sendMessage("\u00A7cIf you do not know what you can put or would like some help with the commands please type \u00A7e" + '"' + "\u00A7e/" + command + " help" + '"' + "\u00A7c\n");

View File

@ -1,5 +1,6 @@
package com.sekwah.advancedportals;
package com.sekwah.advancedportals.bukkit;
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;

View File

@ -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;
}
}

View File

@ -1,6 +1,6 @@
package com.sekwah.advancedportals.api.events;
package com.sekwah.advancedportals.bukkit.api.events;
import com.sekwah.advancedportals.portals.AdvancedPortal;
import com.sekwah.advancedportals.bukkit.portals.AdvancedPortal;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
@ -16,10 +16,10 @@ public final class WarpEvent extends Event implements Cancellable {
private boolean cancelled = false;
private Player player;
private final Player player;
@SuppressWarnings("unused")
private AdvancedPortal portalData;
private final AdvancedPortal portalData;
private boolean hasWarped = false;
@ -75,4 +75,4 @@ public final class WarpEvent extends Event implements Cancellable {
public HandlerList getHandlers() {
return handlers;
}
}
}

View File

@ -1,4 +1,4 @@
package com.sekwah.advancedportals.api.portaldata;
package com.sekwah.advancedportals.bukkit.api.portaldata;
public class PortalArg {

View File

@ -1,16 +1,9 @@
package com.sekwah.advancedportals.api.portaldata;
package com.sekwah.advancedportals.bukkit.api.portaldata;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
/**
* Created by on 29/03/2016.
* <p>
* TODO add all the normal tags then add the extradata tags
*
* @author sekwah41
*/
public class PortalTags {
// TODO create a list or hashmap of tags to check for.

View File

@ -1,28 +1,23 @@
package com.sekwah.advancedportals.api.registry;
package com.sekwah.advancedportals.bukkit.api.registry;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.api.warphandler.TagHandler;
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.bukkit.api.warphandler.TagHandler;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
/**
* Created by on 25/07/2016.
*
* @author sekwah41
*/
public class TagRegistry {
private final AdvancedPortalsPlugin plugin;
private ArrayList<String> tags = new ArrayList<String>();
private final ArrayList<String> tags = new ArrayList<String>();
private Map<String, TagHandler.Activation> tagActivation = new HashMap<String, TagHandler.Activation>();
private final Map<String, TagHandler.Activation> tagActivation = new HashMap<String, TagHandler.Activation>();
private Map<String, TagHandler.Creation> tagCreation = new HashMap<String, TagHandler.Creation>();
private final Map<String, TagHandler.Creation> tagCreation = new HashMap<String, TagHandler.Creation>();
private Map<String, TagHandler.TagStatus> tagStatus = new HashMap<String, TagHandler.TagStatus>();
private final Map<String, TagHandler.TagStatus> tagStatus = new HashMap<String, TagHandler.TagStatus>();
// TODO the event can be used for general data detection and management, but use a TagHandler to make it so they can register
// the individual class to handle.

View File

@ -1,19 +1,14 @@
package com.sekwah.advancedportals.api.warphandler;
package com.sekwah.advancedportals.bukkit.api.warphandler;
import com.sekwah.advancedportals.portals.Portal;
import com.sekwah.advancedportals.bukkit.portals.Portal;
/**
* Created by on 30/07/2016.
*
* @author sekwah41
*/
public class ActivationData {
private boolean warpAllowed = true;
private WarpedStatus warpStatus = WarpedStatus.INACTIVE;
private Portal activePortal;
private final Portal activePortal;
public ActivationData(Portal portal){
this.activePortal = portal;
@ -24,10 +19,7 @@ public class ActivationData {
}
public void setWarpStatus(WarpedStatus warped){
if(this.warpStatus == WarpedStatus.WARPED){
return;
}
else if(this.warpStatus == WarpedStatus.INACTIVE){
if(this.warpStatus == WarpedStatus.WARPED || this.warpStatus == WarpedStatus.INACTIVE){
return;
}
this.warpStatus = warped;
@ -61,7 +53,7 @@ public class ActivationData {
/**
* Nothing has activated on the portal.
*/
INACTIVE;
INACTIVE
}
}

View File

@ -1,12 +1,7 @@
package com.sekwah.advancedportals.api.warphandler;
package com.sekwah.advancedportals.bukkit.api.warphandler;
import org.bukkit.entity.Player;
/**
* Created by on 30/07/2016.
*
* @author sekwah41
*/
public class TagHandler {
public interface Creation{

View File

@ -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;
@ -78,4 +78,4 @@ public class ConfigAccessor {
}
}
}
}

View File

@ -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);
}
}
}

View File

@ -1,9 +1,13 @@
package com.sekwah.advancedportals.destinations;
package com.sekwah.advancedportals.bukkit.destinations;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.PluginMessages;
import com.sekwah.advancedportals.effects.WarpEffects;
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.bukkit.PluginMessages;
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
import com.sekwah.advancedportals.bukkit.effects.WarpEffects;
import com.sekwah.advancedportals.bukkit.portals.AdvancedPortal;
import com.sekwah.advancedportals.bukkit.portals.Portal;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
@ -11,6 +15,7 @@ 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 {
@ -20,7 +25,7 @@ public class Destination {
private static boolean TELEPORT_RIDING = false;
public static int PORTAL_MESSAGE_DISPLAY = 0;
public Destination(AdvancedPortalsPlugin plugin) {
public static void init(AdvancedPortalsPlugin plugin) {
Destination.plugin = plugin;
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
@ -101,21 +106,39 @@ public class Destination {
}
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(name + ".world") != null) {
if (config.getConfig().getString(dest + ".world") != null) {
Location loc = player.getLocation();
if (Bukkit.getWorld(config.getConfig().getString(name + ".world")) != null) {
loc.setWorld(Bukkit.getWorld(config.getConfig().getString(name + ".world")));
if (Bukkit.getWorld(config.getConfig().getString(dest + ".world")) != null) {
loc.setWorld(Bukkit.getWorld(config.getConfig().getString(dest + ".world")));
loc.setX(config.getConfig().getDouble(name + ".pos.X"));
loc.setY(config.getConfig().getDouble(name + ".pos.Y"));
loc.setZ(config.getConfig().getDouble(name + ".pos.Z"));
loc.setX(config.getConfig().getDouble(dest + ".pos.X"));
loc.setY(config.getConfig().getDouble(dest + ".pos.Y"));
loc.setZ(config.getConfig().getDouble(dest + ".pos.Z"));
loc.setPitch((float) config.getConfig().getDouble(name + ".pos.pitch"));
loc.setYaw((float) config.getConfig().getDouble(name + ".pos.yaw"));
loc.setPitch((float) config.getConfig().getDouble(dest + ".pos.pitch"));
loc.setYaw((float) config.getConfig().getDouble(dest + ".pos.yaw"));
WarpEffects.activateParticles(player);
WarpEffects.activateSound(player);
if (disp != null && disp.getArg("particlein") != null) {
WarpEffects.activateParticle(player, disp.getArg("particlein"));
}
if(!noEffects) {
WarpEffects.activateEffect(player);
WarpEffects.activateSound(player);
}
Chunk c = loc.getChunk();
Entity riding = player.getVehicle();
if (!c.isLoaded()) c.load();
@ -130,28 +153,42 @@ public class Destination {
} else {
player.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
}
WarpEffects.activateParticles(player);
WarpEffects.activateSound(player);
if (disp != null && disp.getArg("particleout") != null) {
WarpEffects.activateParticle(player, disp.getArg("particleout"));
}
if(!noEffects) {
WarpEffects.activateEffect(player);
WarpEffects.activateSound(player);
}
if (PORTAL_MESSAGE_DISPLAY == 1) {
player.sendMessage("");
player.sendMessage(PluginMessages.customPrefixFail + "\u00A7a You have been warped to \u00A7e" + name.replaceAll("_", " ") + "\u00A7a.");
player.sendMessage(PluginMessages.customPrefix + PluginMessages.getWarpMessage(dest));
player.sendMessage("");
} else if (PORTAL_MESSAGE_DISPLAY == 2) {
plugin.compat.sendActionBarMessage("\u00A7aYou have warped to \u00A7e" + name.replaceAll("_", " ") + "\u00A7a.", player);
/**plugin.nmsAccess.sendActionBarMessage("[{text:\"You have warped to \",color:green},{text:\"" + config.getConfig().getString(Portal.portals[portalId].portalName + ".destination").replaceAll("_", " ")
+ "\",color:yellow},{\"text\":\".\",color:green}]", player);*/
} else if (PORTAL_MESSAGE_DISPLAY == 2 && !hideActionbar) {
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(PluginMessages.getWarpMessage(dest)));
}
Location newLoc = player.getLocation();
Location newEyeLoc = player.getEyeLocation();
UUID uuid = player.getUniqueId();
for (AdvancedPortal portal : Portal.portals) {
if (!portal.inPortal.contains(uuid) && !portal.isDelayed()
&& (Portal.locationInPortalTrigger(portal, newLoc) || Portal.locationInPortalTrigger(portal, newEyeLoc))) {
portal.inPortal.add(uuid);
}
}
return true;
} else {
player.sendMessage(PluginMessages.customPrefixFail + "\u00A7c The destination you are trying to warp to seems to be linked to a world that doesn't exist!");
plugin.getLogger().log(Level.SEVERE, "The destination '" + name + "' is linked to the world "
+ config.getConfig().getString(name + ".world") + " which doesnt seem to exist any more!");
plugin.getLogger().log(Level.SEVERE, "The destination '" + dest + "' is linked to the world "
+ config.getConfig().getString(dest + ".world") + " which doesnt seem to exist any more!");
}
} else {
player.sendMessage(PluginMessages.customPrefix + "\u00A7c The destination you are currently attempting to warp to doesnt exist!");
plugin.getLogger().log(Level.SEVERE, "The destination '" + name + "' has just had a warp "
plugin.getLogger().log(Level.SEVERE, "The destination '" + dest + "' has just had a warp "
+ "attempt and either the data is corrupt or that destination doesn't exist!");
}
return false;

View File

@ -1,8 +1,8 @@
package com.sekwah.advancedportals.destinations;
package com.sekwah.advancedportals.bukkit.destinations;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.PluginMessages;
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.bukkit.PluginMessages;
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -16,7 +16,7 @@ import java.util.List;
public class DestinationCommand implements CommandExecutor, TabCompleter {
private AdvancedPortalsPlugin plugin;
private final AdvancedPortalsPlugin plugin;
public DestinationCommand(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
@ -71,7 +71,7 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
break;
case "list":
String message = PluginMessages.customPrefix + " \u00A77Destinations \u00A7c:\u00A7a";
List<Object> destiObj = Arrays.asList(config.getConfig().getKeys(false).toArray());
Object[] destiObj = config.getConfig().getKeys(false).toArray();
LinkedList<String> destis = new LinkedList<>();
for (Object object : destiObj) {
destis.add(object.toString());

View File

@ -0,0 +1,5 @@
package com.sekwah.advancedportals.bukkit.destinations;
public class PortalWarp {
}

View File

@ -1,7 +1,9 @@
package com.sekwah.advancedportals.effects;
package com.sekwah.advancedportals.bukkit.effects;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.bukkit.portals.Portal;
import org.bukkit.Effect;
import org.bukkit.Particle;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.World;
@ -45,7 +47,7 @@ public class WarpEffects {
return soundFound;
}
public static void activateParticles(Player player) {
public static void activateEffect(Player player) {
Location loc = player.getLocation();
World world = player.getWorld();
switch (plugin.getSettings().getCurrentWarpParticles()){
@ -62,6 +64,21 @@ public class WarpEffects {
}
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();

View File

@ -1,7 +1,7 @@
package com.sekwah.advancedportals.injector;
package com.sekwah.advancedportals.bukkit.injector;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.reflection.ReflectionHelper;
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.bukkit.reflection.ReflectionHelper;
import io.netty.channel.Channel;
import java.lang.reflect.Field;

View File

@ -1,19 +1,12 @@
package com.sekwah.advancedportals.listeners;
package com.sekwah.advancedportals.bukkit.listeners;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteStreams;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
/**
* Created by on 29/03/2016.
*
* @author sekwah41
*/
public class BungeeListener implements PluginMessageListener {
private AdvancedPortalsPlugin plugin;
private final AdvancedPortalsPlugin plugin;
public BungeeListener(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
@ -24,12 +17,8 @@ public class BungeeListener implements PluginMessageListener {
if (!channel.equals("BungeeCord")) {
return;
}
ByteArrayDataInput in = ByteStreams.newDataInput(message);
String subchannel = in.readUTF();
if (subchannel.equals("AdvancedPortals")) {
// Any data after this is read like the packets used in the naruto mod
// (same order as sent)
}
// some codes
}
/**

View File

@ -1,8 +1,8 @@
package com.sekwah.advancedportals.listeners;
package com.sekwah.advancedportals.bukkit.listeners;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.portals.Portal;
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;

View File

@ -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();
}
}

View File

@ -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());
*
*/
}

View File

@ -1,23 +1,24 @@
package com.sekwah.advancedportals.listeners;
package com.sekwah.advancedportals.bukkit.listeners;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.portals.Portal;
import org.bukkit.Bukkit;
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;
private final boolean DISABLE_GATEWAY_BEAM;
public PortalPlacer(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
@ -25,7 +26,7 @@ public class PortalPlacer implements Listener {
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
boolean portalPlace = config.getConfig().getBoolean("CanBuildPortalBlock");
//this.DISABLE_GATEWAY_BEAM = config.getConfig().getBoolean("DisableGatewayBeam", true);
this.DISABLE_GATEWAY_BEAM = config.getConfig().getBoolean("DisableGatewayBeam", true);
if (portalPlace) {
@ -42,27 +43,46 @@ public class PortalPlacer implements Listener {
if(name == null) return;
if (name.equals("\u00A75Portal Block Placer")){
event.getBlockPlaced().setType(Material.NETHER_PORTAL);
}
else if (name.equals("\u00A78End Portal 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")){
event.getBlockPlaced().setType(Material.END_GATEWAY);
/*if(this.DISABLE_GATEWAY_BEAM) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
this.plugin.compat.setGatewayAgeHigh(event.getBlock());
}, 1);
}*/
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);

View File

@ -1,10 +1,9 @@
package com.sekwah.advancedportals.listeners;
package com.sekwah.advancedportals.bukkit.listeners;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.PluginMessages;
import com.sekwah.advancedportals.portals.Portal;
import org.bukkit.ChatColor;
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;
@ -26,7 +25,7 @@ public class PortalProtect implements Listener {
// an example is in the interact event in this if statement if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("<EFBFBD>eP...
private boolean PortalProtect = true;
private int PortalProtectionRadius = 5;
private int PortalProtectionArea = 5;
public PortalProtect(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
@ -34,6 +33,8 @@ public class PortalProtect implements Listener {
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);
}
@ -41,9 +42,11 @@ public class PortalProtect implements Listener {
@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(), PortalProtectionRadius)) {
&& Portal.inPortalRegion(event.getBlock().getLocation(), PortalProtectionArea)) {
event.setCancelled(true);
player.sendMessage(PluginMessages.customPrefixFail + " You don't have permission to build here!");
}
@ -51,9 +54,11 @@ public class PortalProtect implements Listener {
@EventHandler(priority = EventPriority.HIGH)
public void onBlockPlace(BlockPlaceEvent event) {
if(!this.PortalProtect) return;
Player player = event.getPlayer();
if (!player.hasPermission("advancedportals.build")
&& Portal.inPortalRegion(event.getBlock().getLocation(), PortalProtectionRadius)) {
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!");
}
@ -61,11 +66,12 @@ public class PortalProtect implements Listener {
@EventHandler(priority = EventPriority.HIGH)
public void onExplosion(EntityExplodeEvent event) {
if(!this.PortalProtect) return;
List<Block> blockList = event.blockList();
for (int i = 0; i < blockList.size(); i++) {
Block block = blockList.get(i);
if (Portal.inPortalRegion(block.getLocation(), PortalProtectionRadius)) {
if (Portal.inPortalRegion(block.getLocation(), PortalProtectionArea)) {
blockList.remove(i);
i--;
}

View File

@ -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;
}
}
}

View File

@ -1,16 +1,17 @@
package com.sekwah.advancedportals.portals;
package com.sekwah.advancedportals.bukkit.portals;
import com.sekwah.advancedportals.api.portaldata.PortalArg;
import com.sekwah.advancedportals.bukkit.api.portaldata.PortalArg;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
public class AdvancedPortal {
private Material trigger = null;
private Set<Material> triggers = null;
private String worldName = null;
@ -47,8 +48,12 @@ public class AdvancedPortal {
}
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.trigger = trigger;
this.triggers = triggers;
this.pos1 = pos1;
this.pos2 = pos2;
this.worldName = worldName;
@ -72,8 +77,8 @@ public class AdvancedPortal {
return this.getArg(arg) != null;
}
public Material getTrigger() {
return this.trigger;
public Set<Material> getTriggers() {
return this.triggers;
}
public String getWorldName() {
@ -107,4 +112,8 @@ public class AdvancedPortal {
public void setBungee(String bungee) {
this.bungee = bungee;
}
public boolean isDelayed() {
return this.hasArg("delayed") && this.getArg("delayed").equalsIgnoreCase("true");
}
}

View File

@ -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);
}
}

View File

@ -1,4 +1,4 @@
package com.sekwah.advancedportals.reflection;
package com.sekwah.advancedportals.bukkit.reflection;
import java.lang.reflect.Field;

View File

@ -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);
}
}

View File

@ -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!");
}
}

View File

@ -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";
}

View File

@ -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());
}
}
}
}

View File

@ -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);
}
}

View File

@ -1,121 +0,0 @@
package com.sekwah.advancedportals.compat;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.reflection.ReflectionHelper;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
* Created by on 02/08/2016.
*
* I don't think there will be any others supported other than bukkit but if there are its not just the compat that will
* need to change unless it has a different package for the minecraft server parts
*
* @author sekwah41 maxqia
*/
public class CraftBukkit {
private final AdvancedPortalsPlugin plugin;
// Data for chat bar and json message
private Method chatMessageTypeMethod;
private Method serializeMessage;
private Constructor<?> chatPacketConstructor;
private Method playerGetHandle;
private Field playerConnection;
private Method sendPacket;
public CraftBukkit(AdvancedPortalsPlugin plugin, String bukkitImpl) throws ClassNotFoundException, NoSuchFieldException, NoSuchMethodException {
this.plugin = plugin;
try {
String craftBukkitPackage = "org.bukkit.craftbukkit." + bukkitImpl + ".";
String minecraftPackage = "net.minecraft.server." + bukkitImpl + ".";
this.plugin.getLogger().info("Bukkit version detected " + bukkitImpl);
Class<?> chatBaseComponent = Class.forName(minecraftPackage + "IChatBaseComponent"); // string to packet methods
Class<?> chatSerialClass = ReflectionHelper.findClass(chatBaseComponent, "ChatSerializer");
Class<?> chatMessageTypeClass = Class.forName(minecraftPackage + "ChatMessageType");
this.chatMessageTypeMethod = chatMessageTypeClass.getMethod("a", byte.class);
this.chatPacketConstructor = Class.forName(minecraftPackage + "PacketPlayOutChat").getConstructor(chatBaseComponent, chatMessageTypeClass);
this.serializeMessage = chatSerialClass.getMethod("a", String.class);
this.playerGetHandle = Class.forName(craftBukkitPackage + "entity.CraftPlayer").getMethod("getHandle");
this.playerConnection = Class.forName(minecraftPackage + "EntityPlayer").getField("playerConnection"); // get player connection
Class<?> packet = Class.forName(minecraftPackage + "Packet");
this.sendPacket = playerConnection.getType().getMethod("sendPacket", packet);
} catch (Exception e) {
e.printStackTrace();
plugin.getLogger().warning("Attempting to use backup porekit locations");
// Fall back on your Porekit
Class<?> textBaseComponent = Class.forName("net.minecraft.util.text.ITextComponent"); // string to packet methods
this.serializeMessage = ReflectionHelper.findClass(textBaseComponent, "Serializer").getMethod("func_150699_a", String.class); // md: jsonToComponent
this.chatPacketConstructor = Class.forName("net.minecraft.network.play.server.SPacketChat").getConstructor(textBaseComponent, byte.class);
this.playerGetHandle = Class.forName("blue.lapis.pore.impl.entity.PorePlayer").getMethod("getHandle");
this.playerConnection = Class.forName("net.minecraft.entity.player.EntityPlayerMP").getField("field_71135_a"); // get player connection fd: connection
Class<?> packet = Class.forName("net.minecraft.network.Packet");
this.sendPacket = playerConnection.getType().getMethod("func_147359_a", packet); //md: sendPacket
}
}
public void sendRawMessage(String rawMessage, Player player) {
this.sendMessage(rawMessage,player, (byte) 1);
}
public void sendActionBarMessage(String rawMessage, Player player) {
this.sendMessage("{\"text\":\"" + rawMessage + "\"}",player, (byte) 2);
}
public void sendMessage(String rawMessage, Player player, byte msgType) {
try {
Object comp = this.serializeMessage.invoke(null, rawMessage);
Object packet = this.chatPacketConstructor.newInstance(comp, this.chatMessageTypeMethod.invoke(null,msgType)); // convert bytes into packet
Object handle = this.playerGetHandle.invoke(player);
Object playerConnection = this.playerConnection.get(handle); // get players connection
sendPacket.invoke(playerConnection, packet); // send packet
} catch (IllegalAccessException | InvocationTargetException | InstantiationException e) {
this.plugin.getLogger().warning("Error creating raw message, something must be wrong with reflection");
e.printStackTrace();
}
}
/**
* Blocks the beacon from showing
* @param block
*/
/*public void setGatewayAgeHigh(Block block) {
if(block.getWorld().getEnvironment() != World.Environment.THE_END &&
this.endGatewayClass.isAssignableFrom(block.getState().getClass())) {
try {
Object tileEntity = this.getTileEntityMethod.invoke(this.getWorldHandleMethod.invoke(block.getWorld()),
this.blockPositionConstructor.newInstance(block.getX(), block.getY(), block.getZ()));
if(this.tileEntityEndGatewayClass.isAssignableFrom(tileEntity.getClass())) {
getEntityTimeoutField.set(tileEntity, Integer.MAX_VALUE);
}
} catch (IllegalAccessException| InvocationTargetException | InstantiationException e) {
this.plugin.getLogger().warning("Error setting gateway time");
e.printStackTrace();
}
}
}*/
}

View File

@ -1,12 +0,0 @@
package com.sekwah.advancedportals.destinations;
/**
* Created by on 04/08/2016.
*
* TODO load the destinations into memory rather than constantly reading from the yml.
*
* @author sekwah41
*/
public class PortalWarp {
}

View File

@ -1,284 +0,0 @@
package com.sekwah.advancedportals.listeners;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.PluginMessages;
import com.sekwah.advancedportals.api.events.WarpEvent;
import com.sekwah.advancedportals.portals.AdvancedPortal;
import com.sekwah.advancedportals.portals.Portal;
import org.bukkit.*;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Directional;
import org.bukkit.block.data.Orientable;
import org.bukkit.block.data.Rotatable;
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.player.*;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import java.util.UUID;
public class Listeners implements Listener {
// The needed config values will be stored so they are easier to access later
// an example is in the interact event in this if statement if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("\u00A7eP...
private static boolean UseOnlyServerAxe = false;
private static Material WandMaterial;
private final AdvancedPortalsPlugin plugin;
@SuppressWarnings("deprecation")
public Listeners(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
UseOnlyServerAxe = config.getConfig().getBoolean("UseOnlyServerMadeAxe");
String ItemID = config.getConfig().getString("AxeItemId");
if(ItemID == null){
WandMaterial = Material.IRON_AXE;
}
else{
WandMaterial = Material.getMaterial(ItemID);
}
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@SuppressWarnings("deprecation")
public static void reloadValues(AdvancedPortalsPlugin plugin) {
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
UseOnlyServerAxe = config.getConfig().getBoolean("UseOnlyServerMadeAxe");
String ItemID = config.getConfig().getString("AxeItemId");
WandMaterial = Material.getMaterial(ItemID);
}
@EventHandler
public void onJoinEvent(PlayerJoinEvent event) {
Portal.cooldown.put(event.getPlayer().getName(), System.currentTimeMillis());
}
@EventHandler
public void onWorldChangeEvent(PlayerChangedWorldEvent event) {
Portal.cooldown.put(event.getPlayer().getName(), System.currentTimeMillis());
}
@EventHandler
public void onTeleportEvent(PlayerTeleportEvent event) {
Portal.cooldown.put(event.getPlayer().getName(), System.currentTimeMillis());
}
@EventHandler
public void spawnMobEvent(CreatureSpawnEvent event) {
if(event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.NETHER_PORTAL && Portal.inPortalRegion(event.getLocation(), Portal.getPortalProtectionRadius())) {
event.setCancelled(true);
}
}
@EventHandler
public void onLeaveEvent(PlayerQuitEvent event) {
Portal.cooldown.remove(event.getPlayer().getName());
UUID uuid = event.getPlayer().getUniqueId();
for (AdvancedPortal portal : Portal.portals) {
portal.inPortal.remove(uuid);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
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();
//Location fromloc = event.getFrom();
Location loc = event.getTo();
Location eyeLoc = new Location(loc.getWorld(), loc.getX(), loc.getY() + player.getEyeHeight(), loc.getZ());
for (AdvancedPortal portal : Portal.portals) {
if (Portal.locationInPortalTrigger(portal, loc) || Portal.locationInPortalTrigger(portal, eyeLoc)) {
if (portal.getTrigger().equals(Material.NETHER_PORTAL)) {
if (player.getGameMode().equals(GameMode.CREATIVE)) {
player.setMetadata("hasWarped", new FixedMetadataValue(plugin, true));
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new RemoveWarpData(player), 10);
}
} else if (portal.getTrigger().equals(Material.LAVA)) {
player.setMetadata("lavaWarped", 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);
portal.inPortal.add(player.getUniqueId());
} else portal.inPortal.remove(player.getUniqueId());
}
}
// These are here because java 7 can only take finals straight into a runnable
class RemoveLavaData implements Runnable{
private Player player;
public RemoveLavaData(Player player){
this.player = player;
}
@Override
public void run() {
player.removeMetadata("lavaWarped", plugin);
player.setFireTicks(0);
}
};
class RemoveWarpData implements Runnable{
private Player player;
public RemoveWarpData(Player player){
this.player = player;
}
@Override
public void run() {
if (player != null && player.isOnline()) {
player.removeMetadata("hasWarped", plugin);
}
}
};
@EventHandler
public void onCombustEntityEvent(EntityCombustEvent event) {
if (Portal.inPortalTriggerRegion(event.getEntity().getLocation()))
event.setCancelled(true);
}
@EventHandler
public void onDamEvent(EntityDamageEvent event) {
if (event.getCause() == EntityDamageEvent.DamageCause.LAVA || event.getCause() == EntityDamageEvent.DamageCause.FIRE || event.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK) {
if (event.getEntity().hasMetadata("lavaWarped") | Portal.inPortalTriggerRegion(event.getEntity().getLocation()))
event.setCancelled(true);
}
}
@EventHandler
public void onPortalEvent(PlayerPortalEvent event) {
Player player = event.getPlayer();
if (player.hasMetadata("hasWarped") | Portal.inPortalRegion(event.getFrom(),1))
event.setCancelled(true);
}
@EventHandler
public void onItemInteract(PlayerInteractEvent event) {
// will detect if the player is using an axe so the points of a portal can be set
// also any other detections such as sign interaction or basic block protection
Player player = event.getPlayer();
if (player.hasMetadata("selectingPortal") && (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
for (AdvancedPortal portal : Portal.portals) {
if (Portal.locationInPortal(portal, event.getClickedBlock().getLocation(), 0)) {
player.sendMessage(PluginMessages.customPrefix + "\u00A7a You have selected: \u00A7e" + portal.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")) {
// UseOnlyServerMadeAxe being set to true makes is so only the axe generated by the server can be used so other iron axes can be used normally,
// by default its false but it is a nice feature in case the user wants to use the axe normally too, such as a admin playing survival or it being used
// as a weapon.
// Null pointer exeption detected here on some servers(try decompiling the jar file to double check)
/*try {
// Use this to surround the code if needed
}
catch(NullPointerException e){
}*/
if (event.getItem() != null && event.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();
}
}

View File

@ -1,773 +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.Server;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.scheduler.BukkitTask;
import java.io.*;
import java.lang.reflect.Method;
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");
}
/**
* Gets the online player (backwards compatibility)
*
* @return online player amount
*/
private int getOnlinePlayers() {
try {
Method onlinePlayerMethod = Server.class.getMethod("getOnlinePlayers");
if(onlinePlayerMethod.getReturnType().equals(Collection.class)) {
return ((Collection<?>)onlinePlayerMethod.invoke(Bukkit.getServer())).size();
} else {
return ((Player[])onlinePlayerMethod.invoke(Bukkit.getServer())).length;
}
} catch (Exception ex) {
if (debug) {
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
}
}
return 0;
}
/**
* 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 = this.getOnlinePlayers();
// 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();
}
}
}

View File

@ -1,567 +0,0 @@
package com.sekwah.advancedportals.portals;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.PluginMessages;
import com.sekwah.advancedportals.api.portaldata.PortalArg;
import com.sekwah.advancedportals.destinations.Destination;
import com.sekwah.advancedportals.effects.WarpEffects;
import org.bukkit.*;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;
import java.util.Set;
import java.util.logging.Level;
public class Portal {
public static HashMap<String, Long> cooldown = new 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 int cooldelay;
private static double throwback;
private static Sound portalSound;
private static int portalProtectionRadius;
private static boolean blockSpectatorMode;
public Portal(AdvancedPortalsPlugin plugin) {
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
this.showBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage", false);
this.cooldelay = config.getConfig().getInt("PortalCooldown", 5);
this.portalProtectionRadius = config.getConfig().getInt("PortalProtectionRadius");
this.throwback = config.getConfig().getDouble("ThrowbackAmount", 0.7);
this.portalSound = WarpEffects.findSound(plugin, "BLOCK_PORTAL_TRAVEL", "PORTAL_TRAVEL");
this.blockSpectatorMode = config.getConfig().getBoolean("BlockSpectatorMode", false);
Portal.plugin = plugin;
Portal.loadPortals();
}
/**
* This can be used to move the get keys to different sections
* <p>
* ConfigurationSection section = portalData.getSection("sectionname");
* <p>
* section.getKeys(false);
*/
public static void loadPortals() {
portalData = new ConfigAccessor(plugin, "portals.yml");
Set<String> PortalSet = portalData.getConfig().getKeys(false);
if (PortalSet.size() > 0) {
portals = new AdvancedPortal[PortalSet.toArray().length];
/*for(int i = 0; i <= PortalSet.toArray().length - 1; i++){
portals[i] = new AdvancedPortal();
}*/
int portalId = 0;
for (Object portal : PortalSet.toArray()) {
ConfigurationSection portalConfigSection = portalData.getConfig().getConfigurationSection(portal.toString());
Material blockType = Material.NETHER_PORTAL;
String BlockID = portalConfigSection.getString("triggerblock");
try {
Integer.parseInt(BlockID);
plugin.getLogger().info("Block names must be given not IDs");
} catch (NumberFormatException e) {
blockType = Material.getMaterial(BlockID);
}
if (blockType == null) {
blockType = 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(), blockType, 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 String create(Location pos1, Location pos2, String name, String destination, Material triggerBlock, PortalArg... extraData) {
return create(pos1, pos2, name, destination, triggerBlock, null, extraData);
}
public static String create(Location pos1, Location pos2, String name, String destination, Material triggerBlock, String serverName, PortalArg... portalArgs) {
if (!pos1.getWorld().equals(pos2.getWorld())) {
plugin.getLogger().log(Level.WARNING, "pos1 and pos2 must be in the same world!");
return "\u00A7cPortal creation error, pos1 and pos2 must be in the same world!";
}
int LowX = 0;
int LowY = 0;
int LowZ = 0;
int HighX = 0;
int HighY = 0;
int HighZ = 0;
if (pos1.getX() > pos2.getX()) {
LowX = (int) pos2.getX();
HighX = (int) pos1.getX();
} else {
LowX = (int) pos1.getX();
HighX = (int) pos2.getX();
}
if (pos1.getY() > pos2.getY()) {
LowY = (int) pos2.getY();
HighY = (int) pos1.getY();
} else {
LowY = (int) pos1.getY();
HighY = (int) pos2.getY();
}
if (pos1.getZ() > pos2.getZ()) {
LowZ = (int) pos2.getZ();
HighZ = (int) pos1.getZ();
} else {
LowZ = (int) pos1.getZ();
HighZ = (int) pos2.getZ();
}
Location checkpos1 = new Location(pos1.getWorld(), HighX, HighY, HighZ);
Location checkpos2 = new Location(pos2.getWorld(), LowX, LowY, LowZ);
/*if (checkPortalOverlap(checkpos1, checkpos2)) {
plugin.getLogger().log(Level.WARNING, "portals must not overlap!");
return "\u00A7cPortal creation error, portals must not overlap!";
}*/
portalData.getConfig().set(name + ".world", pos1.getWorld().getName());
portalData.getConfig().set(name + ".triggerblock", triggerBlock.toString());
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) {
if ((pos2.getX()) <= posX && pos2.getY() <= posY && pos2.getZ() <= posZ) {
return true;
}
}
return false;
}
@SuppressWarnings("deprecation")
public static String create(Location pos1, Location pos2, String name, String destination, String serverName, PortalArg... extraData) { // add stuff for destination names or coordinates
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
Material triggerBlockType;
String BlockID = config.getConfig().getString("DefaultPortalTriggerBlock");
triggerBlockType = Material.getMaterial(BlockID);
if (triggerBlockType == null) {
triggerBlockType = Material.NETHER_PORTAL;
}
return create(pos1, pos2, name, destination, 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 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) {
// add other variables or filter code here, or somehow have a way to register them
// TODO on load and unload recode the permissions to try to register themselves
// https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/plugin/PluginManager.html#addPermission(org.bukkit.permissions.Permission)
// check they havent been registered before too and store a list of ones made by this plugin to remove when portals are unloaded.
// When a portal is added or removed it reloads all portals(i think) so add code for unloading too.
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");
/*if((permission == null || (permission != null && player.hasPermission(permission)) || player.isOp())){*/
// 3 checks, 1st is if it doesnt need perms. 2nd is if it does do they have it. And third is are they op.
if (!(permission == null || (permission != null && player.hasPermission(permission)) || player.isOp())) {
player.sendMessage(PluginMessages.customPrefixFail + "\u00A7c You do not have permission to use this portal!");
failSound(player, portal);
throwPlayerBack(player);
return false;
}
if (cooldown.get(player.getName()) != null) {
int diff = (int) ((System.currentTimeMillis() - cooldown.get(player.getName())) / 1000);
if (diff < cooldelay) {
player.sendMessage(ChatColor.RED + "Please wait " + ChatColor.YELLOW + (cooldelay - diff) + ChatColor.RED + " seconds until attempting to teleport again.");
failSound(player, portal);
throwPlayerBack(player);
return false;
}
}
cooldown.put(player.getName(), System.currentTimeMillis());
boolean showFailMessage = !portal.hasArg("command.1");
//plugin.getLogger().info(portal.getName() + ":" + portal.getDestiation());
boolean warped = false;
if (portal.getBungee() != null) {
if (showBungeeMessage) {
player.sendMessage(PluginMessages.customPrefix + "\u00A7a Attempting to warp to \u00A7e" + portal.getBungee() + "\u00A7a.");
}
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Connect");
out.writeUTF(portal.getBungee());
player.sendPluginMessage(plugin, "BungeeCord", out.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());
if(!warped){
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!");
throwPlayerBack(player);
failSound(player, portal);
}
}
if (portal.hasArg("command.1")) {
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());
plugin.getLogger().log(Level.INFO, "Portal command: " + command);
if (command.startsWith("#") && plugin.getSettings().hasCommandLevel("c")) {
command = command.substring(1);
plugin.getLogger().log(Level.INFO, "Portal command: " + command);
try{
plugin.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
}
catch(Exception e){
plugin.getLogger().warning("Error while executing: " + command);
}
} else if (command.startsWith("!") && plugin.getSettings().hasCommandLevel("o")) {
command = command.substring(1);
boolean wasOp = player.isOp();
try {
player.setOp(true);
player.chat("/" + command);
//player.performCommand(command);
} finally {
player.setOp(wasOp);
}
} else if (command.startsWith("^")) {
command = command.substring(1);
PermissionAttachment permissionAttachment = null;
try {
permissionAttachment = player.addAttachment(plugin, "*", true);
player.chat("/" + command);
//player.performCommand(command);
} finally {
player.removeAttachment(permissionAttachment);
}
} else {
player.chat("/" + command);
//player.performCommand(command);
}
command = portal.getArg("command." + ++commandLine);
} while (command != null);
}
return warped;
}
private static void failSound(Player player, AdvancedPortal portal) {
if(!(portal.getTrigger() == 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) {
return portal.getTrigger().equals(loc.getBlock().getType()) && locationInPortal(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, 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())
if (portal.getPos2().getX() - additionalArea <= loc.getX() && portal.getPos2().getY() - additionalArea <= loc.getY() && portal.getPos2().getZ() - additionalArea <= loc.getZ())
return true;
return false;
}
public static void throwPlayerBack(Player player){
// Not ensured to remove them out of the portal but it makes it feel nicer for the player.
if (throwback > 0) {
Vector velocity = player.getLocation().getDirection();
player.setVelocity(velocity.setY(0).normalize().multiply(-1).setY(throwback));
}
}
public static int getPortalProtectionRadius() {
return portalProtectionRadius;
}
}

View File

@ -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());
}
});
}
}
}

View File

@ -0,0 +1,4 @@
main: com.sekwah.advancedportals.bungee.AdvancedPortalsPlugin
name: AdvancedPortals
version: 0.9.2
author: sekwah

View File

@ -2,7 +2,8 @@
# To set this file back to its default state just delete it and reload the server or restart it!
# Will update whenever there is a config update from an older version so may not be the latest plugin version
ConfigVersion: 0.5.13
# Set to true if you want the normal axes to work normally but the ones gived with /portals selector or wand will still work though
# It can be usefull if people with permission want to use an iron axe on a survival server
@ -18,13 +19,13 @@ CanBuildPortalBlock: true
PortalProtection: true
# How many blocks around the portals will be protected from griefing or destruction
PortalProtectionRadius: 5
PortalProtectionArea: 5
# What the default trigger block is for portals if nothing is defined.
DefaultPortalTriggerBlock: PORTAL
# This stops all water flowing inside a portal area(can be disabled if something like world edit is handelling the water flow or you dont want it active)
# you want to
# you want to
StopWaterFlow: true
# This must be a placeable block or it will not work and may even crash
@ -64,27 +65,43 @@ CustomPrefix: '&a[&eAdvancedPortals&a]'
CustomPrefixFail: '&c[&7AdvancedPortals&c]'
# Message sent to player in chat/action bar on warp
WarpMessage: '&aYou have warped to &e<warp>&a.'
BlockSpectatorMode: false
PortalCooldown: 5 # How long after trying to enter a portal until the player can try to enter another. 0 or lower to deactivate.
ThrowbackAmount: 0.7 # How fast to throw them back, 0 or lower to disable throwback
# Experimental, works but not all the time (Entities don't seem to be provided in the event sometimes or something is wrong)
# We have no plans to further this but if anyone has any tips feel free to contact us here https://discord.gg/25QZVVn
DisableGatewayBeam: false
# 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
# Letters are flags. Include them to activate. n always disables everything, remove if you want it to work.
# Lettering may not make too much sense but meh its useful. Examples are "ocpk" or "cop" (doesnt matter order)
#
# Remember enabling this means potentially admins could leave a portal lying around which could let them reop themselves.
# If you think this may be an issue use a permission plugin and specifically give the users you trust permissions.
# Enable or disable special command portals
#
# n Disabled none, best just put this to really make sure the fact none are here is specified. It disables any others too
# o Admin Heighten Enabled Permission advancedportals.createportal.commandlevel.op
# p Perm Heighten Enabled Permission advancedportals.createportal.commandlevel.perms
# c Console Heighten Enabled Permission advancedportals.createportal.commandlevel.console
# h Ops can create admin commands without special perms
# e Ops can create all perm commands without special perms
# k Ops can create console commands without special perms
# o enable op command portals
# p enable permission command portals
# c enable console command portals
# b enable bungee command portals
#
CommandLevels: opchek
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

View File

@ -1,55 +1,71 @@
main: com.sekwah.advancedportals.AdvancedPortalsPlugin
main: com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin
name: AdvancedPortals
version: 0.0.50
author: sekwah41
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>
destination:
description: Can be used to access portal destinations.
aliases: [desti]
usage: /<command>
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.perms: true
advancedportals.createportal.commandlevel.console: true
advancedportals.createportal.commandlevel.op:
description: Allows you to increase the users level temporaily to op
default: false
advancedportals.createportal.commandlevel.perms:
description: Allows you to increase the users level temporaily to have all perms
default: false
advancedportals.createportal.commandlevel.console:
description: Executes command in the console
default: false
advancedportals.portal:
description: Allows use of portal commands
default: op
advancedportals.build:
description: Allows you to build in the portal regions
default: op
advancedportals.desti:
description: Gives access to all desti commands
default: op
advancedportals.warp.*:
description: Access to all warps (not really used tbh)
default: op
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

2789
yarn.lock Normal file

File diff suppressed because it is too large Load Diff