Compare commits

..

1264 Commits

Author SHA1 Message Date
93568f9f7f Update pom 2021-06-12 12:09:40 +01:00
b01291c4ff Add note about PlayerPlotAutoEvent return null plot 2021-06-12 11:36:33 +01:00
e2700d3b28 Implement "off" to PlotWeather flag and make it default
- Players with "player weather" will no longer have their weather reset on plots that do not set the PlotWeather flag
2021-06-10 11:41:55 +01:00
df842c355e 5.13.13 2021-06-08 10:52:51 +02:00
ce287cf218 Add toggle allowing to opt out nashorn 2021-06-08 00:16:55 +02:00
a01ad5aa04 Update wiki location 2021-06-06 21:40:34 +02:00
5cdb7e76fd Update wiki and issue links 2021-04-28 20:06:19 +02:00
823beaf268 Update a few dependencies 2021-04-27 11:46:14 +02:00
3ada55989f [ci skip] Setup new issue templates (#2951)
* Setup issue templates

* Exchange issue url
2021-04-26 16:25:15 +02:00
19daf1bd52 5.13.12 2021-04-03 22:18:03 +02:00
74a9c2f6b4 Reimplement per-world-visit 2021-04-03 21:48:21 +02:00
932873ba02 Do not access nms for older versions on newer ones 2021-03-31 12:42:32 +02:00
d9b5dc5dd7 Sort plots for /plot home the same as for /plot visit, fixes PS-188 2021-02-24 08:46:16 +01:00
c7e6564667 Add new metrics pies 2021-02-22 15:22:38 +01:00
22be81b5cb Switch to vanity url 2021-02-16 23:50:53 +01:00
c42102d1c4 Don't shade without relocation 2021-02-01 15:31:25 +01:00
666938b738 Update ServerLib 2021-01-30 13:17:36 +01:00
e549235d83 Switch to ServerLib 2021-01-22 23:42:45 +01:00
bf79639d07 Update license to 2021
Happy new year 🎆
2021-01-01 00:46:30 +01:00
b648717079 5.13.11 2020-12-29 15:14:00 +01:00
ef215b1b0c fix debugpaste with multiverse 2020-12-28 12:31:51 +00:00
2b9a194244 5.13.10 2020-12-23 14:07:42 +00:00
67a928b1ae Merge branch 'v5' of github.com:IntellectualSites/PlotSquared into v5 2020-12-23 13:54:35 +00:00
67a7211b77 use correct UUID pipeline methods in purge command 2020-12-23 13:52:47 +00:00
1d4fe01db0 Rename database chart id 2020-12-22 20:54:22 +01:00
eba6043d26 Update paster 2020-12-21 15:59:12 +01:00
e4a8459798 Switch to IncendoPaster "library" 2020-12-19 16:20:44 +00:00
5147d67318 Add charts for complex plot components 2020-12-16 13:20:23 +01:00
cbc599cb20 don't double-up schematic x/z offsets 2020-12-16 12:13:39 +00:00
de3ba9a25c re-send block change for blocks with gravity if they're physicsed
fixes PS-159
2020-12-14 14:53:53 +00:00
5e88cabb4b compare UUID to UUID, not UUIDMapping
fix PS-182
2020-12-14 14:32:34 +00:00
6d71177394 Don't save corrupt schematics so that when they load, they work. 2020-12-13 21:09:05 +00:00
c85ff7ddda Update README.md 2020-12-12 17:52:24 +01:00
ee7f683b76 Bump paperlib, fix single worlds. 2020-11-26 16:54:38 +00:00
585111ca38 Cancel boat placement on interactable blocks, fixes PS-175 (#2934)
* Cancel boat placement on interactable blocks, fixes PS-175

* Keep boat protection for old game versions

Co-authored-by: NotMyFault <mc.cache@web.de>
2020-11-24 16:32:35 +01:00
ef95334fe6 Update actions worflow 2020-11-23 18:35:44 +01:00
5d4cf3b705 setowner should allow null UUIDs 2020-11-10 17:24:37 +00:00
b0d55d434d 5.13.9 2020-11-03 21:14:07 +01:00
b66e2359d1 Update to 1.16.4
- Bump WorldEdit to 7.2.0 release
2020-11-03 15:58:17 +01:00
4213957d76 Delete dependabot.yml 2020-10-12 12:21:32 +02:00
565f9e3e29 5.13.8 2020-10-11 19:27:01 +01:00
cfd432886d Correctly handle road flags 2020-10-11 19:19:17 +01:00
b55d836871 5.13.7 2020-10-07 11:59:44 +01:00
a210f523a5 Add more information to debugpaste 2020-10-04 18:19:29 +02:00
e6237d68d0 Also remove BungeePerms from the config 2020-10-04 13:26:56 +02:00
56e6922279 Remove BungeePerms UUID fetcher 2020-10-04 13:26:56 +02:00
6e2f738d86 Stop relying on maxim's repo as it's very unreliable. 2020-10-04 12:24:37 +01:00
81d0bf6f04 Prevent blocks from getting waterlogged
In some cases, the PlayerInteractEvent doesn't cancel right clicks on blocks that can be waterlogged
2020-10-03 21:54:14 +02:00
95f509d337 Stop forcing loiwercase world names 2020-10-02 15:08:14 +01:00
2f5ce67154 add back setShouldAbortSpawn 2020-09-29 15:55:08 +01:00
89318be5f4 Apply e2f9b4245b to paper listener too 2020-09-29 15:53:23 +01:00
8c4bb4140a 5.13.6 2020-09-20 19:51:54 +01:00
ff83931a3f Fix plot grant 2020-09-20 19:42:13 +01:00
8547533210 update pom 2020-09-11 15:04:09 +01:00
d843d1715d Allow /plot home [area|world] 2020-09-11 15:03:48 +01:00
648953ec1f 5.13.5 2020-09-11 12:27:23 +02:00
5463f15633 Add pigstep music disc 2020-09-11 01:16:57 +02:00
0c6113b0d1 5.13.4 2020-09-09 23:31:30 +02:00
c5906e780a Merge pull request #2912 from IntellectualSites/fix/v5/blocktypewrapper
Add default namespace when wrapping block categories by their ids
2020-09-08 18:50:08 +02:00
f2355a76d6 Add default namespace when wrapping block categories by their ids 2020-09-06 23:36:36 +02:00
0aeca40137 Take player visibility into account when sending notify-enter and notify-leave messages. Fixes PS-103. 2020-09-05 18:48:58 +02:00
5c48e4ad19 Add missing license header 2020-09-05 18:39:56 +02:00
f6d1e2b3b8 Check TileState manually on 1.13.2, fixes PS-122 2020-09-05 18:39:56 +02:00
37010d92ee Create CODEOWNERS 2020-09-05 13:42:11 +02:00
babad3ab6d Don't validate plot aliases with offline players (Fixes PS-126) 2020-09-04 14:49:02 +02:00
d19dde2f85 Add more debugs 2020-09-02 17:18:41 +02:00
7a529e156d Add deb for onBlockIgnite event 2020-09-02 17:03:56 +02:00
03c889383b Merge pull request #2908 from IntellectualSites/dependabot/gradle/v5/org.yaml-snakeyaml-1.26
Bump snakeyaml from 1.25 to 1.26
2020-09-02 16:15:26 +02:00
da54478767 Merge pull request #2907 from IntellectualSites/dependabot/gradle/v5/org.jetbrains-annotations-20.1.0
Bump annotations from 20.0.0 to 20.1.0
2020-09-02 16:14:26 +02:00
acf9c2554f Merge pull request #2904 from IntellectualSites/dependabot/gradle/v5/org.ajoberstar.grgit-4.0.2
Bump org.ajoberstar.grgit from 4.0.1 to 4.0.2
2020-09-02 16:12:56 +02:00
7c53bfc870 Bump snakeyaml from 1.25 to 1.26
Bumps [snakeyaml](https://bitbucket.org/asomov/snakeyaml) from 1.25 to 1.26.
- [Commits](https://bitbucket.org/asomov/snakeyaml/branches/compare/snakeyaml-1.26..snakeyaml-1.25)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-02 14:10:44 +00:00
32a8dcd411 Bump annotations from 20.0.0 to 20.1.0
Bumps [annotations](https://github.com/JetBrains/java-annotations) from 20.0.0 to 20.1.0.
- [Release notes](https://github.com/JetBrains/java-annotations/releases)
- [Changelog](https://github.com/JetBrains/java-annotations/blob/master/CHANGELOG.md)
- [Commits](https://github.com/JetBrains/java-annotations/compare/20.0.0...20.1.0)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-02 14:10:44 +00:00
20b4cec0ca Bump org.ajoberstar.grgit from 4.0.1 to 4.0.2
Bumps org.ajoberstar.grgit from 4.0.1 to 4.0.2.

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-02 14:10:39 +00:00
c51c938e8d Merge pull request #2903 from IntellectualSites/dependabot/add-v2-config-file
Create Dependabot config file
2020-09-02 16:10:14 +02:00
49984f2560 Create Dependabot config file 2020-09-02 13:55:15 +00:00
b3c77ef099 Merge branch 'dependabot/gradle/v5/org.jetbrains.kotlin-kotlin-stdlib-1.4.0' into v5 2020-09-02 12:57:05 +02:00
97e34844b4 Add option to opt-out MvDW Placeholder API 2020-09-02 12:13:23 +02:00
1441cc293c 5.13.3 2020-08-26 13:57:20 +02:00
c42d5390a4 Allow teleporting to merged plots with multiple owners using /p home 2020-08-24 13:37:12 +02:00
c53cffb745 Generate signs by default 2020-08-24 13:17:15 +02:00
acb0bd95f2 Bump kotlin-stdlib from 1.3.72 to 1.4.0
Bumps [kotlin-stdlib](https://github.com/JetBrains/kotlin) from 1.3.72 to 1.4.0.
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v1.4.0/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.3.72...v1.4.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-22 23:05:56 +00:00
5d73b17415 Merge pull request #2899 from IntellectualSites/dependabot/gradle/v5/org.jetbrains-annotations-20.0.0
Bump annotations from 19.0.0 to 20.0.0
2020-08-23 01:04:40 +02:00
3a8fa9f5b6 Update WorldEdit version
That doesn't appear to break stuff 👀
2020-08-22 13:18:00 +02:00
e93d7feb2c Fixes PS-114 2020-08-22 11:48:03 +02:00
5c08db2f44 Merge branch 'feature/v5/1.16.2-support' into v5 2020-08-21 19:02:23 +02:00
28fc29c3ab Merge pull request #2890 from MeFisto94/fix-1-16-worldserver-regression
Fixes an OfflinePlayerUtil breakaged caused by NMS Changes
2020-08-21 18:29:03 +02:00
b2ac67692e Merge pull request #2892 from TimonMi/v5
[Bugfix] No chat message confirmation on /p add /p trust, etc.
2020-08-21 18:28:05 +02:00
1064d777c2 Clean up unused code 2020-08-21 00:02:07 +02:00
62f675adbe Allow visiting all owners of merged plots 2020-08-21 00:01:53 +02:00
869a579655 Bump annotations from 19.0.0 to 20.0.0
Bumps [annotations](https://github.com/JetBrains/java-annotations) from 19.0.0 to 20.0.0.
- [Release notes](https://github.com/JetBrains/java-annotations/releases)
- [Changelog](https://github.com/JetBrains/java-annotations/blob/master/CHANGELOG.md)
- [Commits](https://github.com/JetBrains/java-annotations/compare/19.0.0...20.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-08-17 09:08:30 +00:00
61d1dcc231 Ignore Events if they are not caused by real players (i.e. citizens) 2020-08-16 14:09:32 +02:00
6c9b73b100 Apply patch by @SirYwell to construct the ResourceKey without consulting the DimensionManager 2020-08-16 14:02:03 +02:00
300abd868a Merge pull request #2888 from IntellectualSites/fix-conversion
Fix problem with config creation
2020-08-14 18:36:57 +02:00
78a6e72fe1 5.13.2 2020-08-14 15:26:32 +02:00
8f1b2a9d2a fix pve against animals on other plots and roads 2020-08-14 14:21:45 +01:00
808bddbfbb Apply scaling to image 2020-08-12 10:30:05 +02:00
d6dfa9a0b9 https 2020-08-11 20:12:31 +02:00
924b73f070 Merge pull request #2896 from luca-gg/patch-1
Update de-DE.yml
2020-08-11 19:33:41 +02:00
64181c6ab8 Update de-DE.yml
adjusted grammar
2020-08-11 19:29:40 +02:00
a1b10a2900 Remove dead files 2020-08-11 17:49:04 +02:00
6315b9ea52 gradle 6.6 2020-08-11 17:43:24 +02:00
7c756304b5 1.16.2 support
- Bump EssentialsX version to the latest release
2020-08-11 16:20:33 +02:00
9fd11fbe13 Merge pull request #2893 from JunTVDE/de-translation-edit
added german translation for flag-descriptions to de-DE.yml
2020-08-09 13:21:31 +02:00
7cd9a03b0f Merge pull request #2894 from TimonMi/patch-1
Update link for contributing
2020-08-09 13:20:17 +02:00
f8bd844c6c Update link for contributing 2020-08-09 13:18:35 +02:00
987d9a267c added german translation for flag-descriptions to de-DE.yml 2020-08-09 13:05:40 +02:00
98d1bb9264 Merge remote-tracking branch 'upstream/v5' into v5 2020-08-08 18:39:47 +02:00
b46a19f5ca Keep player names, so they don't have to be looked up again.
That way the lookup function MainUtil#getName won't get called which would throw an exception if called in the Bukkit Thread.
As the player enters the Name, we don't have to look it up again.

Fixes PS-96
2020-08-08 18:07:49 +02:00
dc3f45acd4 Added UseFlag check at Roads 2020-08-07 09:57:02 +01:00
48d3c2105d Fixes an OfflinePlayerUtil breakage caused by NMS Changes 2020-08-06 15:23:36 +02:00
c745b99922 Added UseFlag check at Roads 2020-08-06 12:01:43 +02:00
01d2b0024f Add more information to the debugpaste 2020-07-31 20:33:17 +02:00
01e66f8833 Readd skyblock template 2020-07-29 14:53:09 +02:00
afd9b56e71 Merge branch 'v5' of github.com:IntellectualSites/PlotSquared into v5 2020-07-28 13:58:37 +01:00
e2f9b4245b Fixes https://issues.intellectualsites.com/issue/PS-81
- Add break statements to switches to prevent bleed from normal spawning to breeding
 - Separate misc spawning from mob spawning
2020-07-28 13:56:37 +01:00
22a007b514 Revert "Update zh-CN.yml"
This reverts commit 240362a16d.
2020-07-28 12:33:04 +02:00
ab121c7eee Fixes https://github.com/IntellectualSites/PlotSquaredSuggestions/issues/133 2020-07-26 21:12:32 +02:00
240362a16d Update zh-CN.yml 2020-07-26 17:08:58 +02:00
f2dcbce490 Fix problem where servers created in v5 (not converted from v4) would fail to start properly.
This is a quite major issue and I hope this fix resolves it. Although, it should be tested with migration from v4 to v5 and then a fresh v5 server.
2020-07-25 03:16:36 +02:00
88df434404 Create CODE_OF_CONDUCT.md 2020-07-25 03:11:07 +02:00
73e3572c72 Fix the redstone flag on roads 2020-07-21 13:11:28 +02:00
87a8ff742f 5.13.1 2020-07-19 14:16:13 +02:00
57435fdf34 verbosely ensure items cannot be duplicated when keeping inventory on death
Seemingly there's duplication issues on some servers (and apparently even when only PlotSquared is installed). Likely a Spigot issue, but there's nothing to be done for Spigot on 1.13/14/15
2020-07-16 23:24:11 +01:00
01ff9a34c2 Merge branch 'features/v5/placeholders' into v5 2020-07-16 18:48:45 +02:00
ff3a94933a Bump version 2020-07-16 18:43:52 +02:00
97a356c4a0 Very attentive reviewers, can recommend 2020-07-16 18:13:02 +02:00
10ab28c1ec Add missing license headers 2020-07-16 18:08:00 +02:00
2d9cf8b759 Get placeholders working 2020-07-16 18:04:17 +02:00
32b28a4ca5 Turn all UUID messages into debug messages 2020-07-15 22:42:58 +02:00
4996d8bcd1 Remove left over debugs 2020-07-15 14:05:15 +02:00
e5963a8590 Merge pull request #2877 from IntellectualSites/features/v5/split-bukkit-listeners
Clean up bukkit listeners by splitting them up
2020-07-15 13:35:38 +02:00
e8c155763b Register placeholders 2020-07-15 12:44:07 +02:00
a52249513e Update MVdW version 2020-07-15 12:05:42 +02:00
5d2d4ac12b fix language issue 2020-07-14 20:47:15 +02:00
64f5580edd Fix code styling issue 2020-07-14 20:46:52 +02:00
b989531a60 Merge branch 'v5' into features/v5/placeholders 2020-07-14 20:41:17 +02:00
34655b8d41 Add (untested) MVdWPlaceholderAPI support 2020-07-14 20:41:08 +02:00
30327d2fa3 update bukkit pom 2020-07-14 19:11:46 +01:00
2e4c43c251 Add config option to disable placing top wall blocks 2020-07-14 19:10:53 +01:00
1908588fcb Change expansion author and version 2020-07-14 13:17:21 +02:00
af7db08036 Add new placeholder system 2020-07-14 13:14:02 +02:00
32264ae5e3 Update gradle.yml 2020-07-14 12:43:45 +02:00
e88da3cea9 Add chunk coordinator 2020-07-12 20:58:48 +02:00
14b6f84816 fix typos that were c/p over 2020-07-12 18:50:04 +01:00
ac8841447c 6cf2c0ad97 (r40542418) 2020-07-12 17:11:25 +02:00
6cf2c0ad97 Disable the paper uuid service for offline mode servers and add toggles for all third party uuid services 2020-07-12 17:04:30 +02:00
c045ef698c Add license headers and fix method change in PlotSquared.java 2020-07-12 11:42:45 +01:00
3a11ffc77a Clean up bukkit listeners by splitting them up 2020-07-11 19:03:55 +01:00
a2ec404014 Fix /plot target nearest 2020-07-11 13:40:22 +01:00
afb72aa102 Don't include eggs with spawn*_eggs* 2020-07-10 17:31:46 +01:00
2fb76e6636 Split road and plot paste-on-top settings 2020-07-09 22:39:06 +01:00
5b260ea8da update bukkit pom 2020-07-09 22:33:01 +01:00
55139eb134 Do not respect paste on top for road schematics. 2020-07-09 22:19:23 +01:00
5e44bb60c6 Merge branch 'v5' of github.com:IntellectualSites/PlotSquared into v5 2020-07-09 22:14:38 +01:00
96740fd282 Couple of fixes to road flag logic 2020-07-09 21:52:51 +01:00
fb050ac3da 5.12.5 2020-07-09 21:15:28 +02:00
b36c6427d1 Split failed UUID batches into individual requests in order to identify the invalid UUIDs 2020-07-09 20:37:14 +02:00
63c308971b Update location block vector on add and subtract 2020-07-09 20:14:06 +02:00
cfd389883b Improve piston interaction with area border 2020-07-09 20:14:06 +02:00
4576cfd961 Improve piston interaction with plot border
Fixes retracting pistons being able to modify plot borders. Prevents
piston heads from sticking outside plots.
2020-07-09 20:14:06 +02:00
89cb6450fb Fix issue where PlotPlayer#getLocation returns a mutable location 2020-07-09 20:04:00 +02:00
699eb71e2a Fix kill-road-mobs. Fixes PS-73 2020-07-09 19:46:17 +02:00
6b07f38cff Send teleportation cancellation message immediately on movement, rather than after the timer has finished. This fixes PS-33. 2020-07-09 16:45:25 +02:00
904f5485ab Merge remote-tracking branch 'origin/v5' into v5 2020-07-09 16:38:53 +02:00
e05d817482 Fix plot owner placeholder. Fixes PS-62. 2020-07-09 16:38:46 +02:00
61de18190f More dispense blocking on roads 2020-07-09 12:33:23 +02:00
1310f9470e 5.12.4 2020-07-08 19:34:08 +01:00
d652225f36 Let players teleport to their merged plots 2020-07-08 19:33:58 +02:00
2936b806f3 Allow players to interact on their own plot 2020-07-08 17:10:09 +01:00
d267d1bb98 Start expiry tasks 2020-07-08 14:35:46 +01:00
f2191cb731 Save style.yml again 2020-07-08 13:59:31 +02:00
265c10ec1c Remove commands.yml 2020-07-08 13:59:31 +02:00
5004005c5a Fixes PS-65
EssentialsX uses paperlib 1.0.4 where we compile explicitly against 1.0.2
2020-07-08 12:21:31 +02:00
67a49a2ca7 5.12.3 2020-07-07 21:03:30 +02:00
57127537f7 Add permission check for /plot home 2020-07-07 20:45:52 +02:00
3476522c00 Allow /p v <alias> 2020-07-07 20:45:52 +02:00
3d087b1bbe Fix tab completion and usage 2020-07-07 20:45:52 +02:00
c058614fcc Split visit command into home and visit 2020-07-07 20:45:52 +02:00
9e9db0f1df Merge branch 'features/v5/road-respect-flags' into v5 2020-07-07 17:49:32 +01:00
e826836c36 Merge branch 'v5' into features/v5/road-respect-flags 2020-07-07 17:48:46 +01:00
b5818bfefc Lazy fix for FancyMessage 1.16 2020-07-04 20:25:49 +02:00
429f5e55c3 Add option to disable background caching 2020-07-03 13:50:12 +02:00
0e7a6d7a62 Fix typo 2020-07-03 13:47:50 +02:00
ad1ec42b12 Add new clear pipeline to hpw and make some stuff read access as required. 2020-07-02 14:33:22 +01:00
580212d66d fix build 2020-07-01 21:49:53 +01:00
b71de856a8 allow plugins extending and replacing RegionManager to be notified of, and "accept" plot clear "requests".
.
.
.
.
.
FAWE
2020-07-01 21:49:53 +01:00
2910176b97 Add road flag container 2020-07-01 14:53:57 +01:00
c5ec8e1931 actually fix all conflicts 2020-07-01 14:21:18 +01:00
82a887fd3b Merge branch 'v5' into features/v5/road-respect-flags
# Conflicts:
#	Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java
2020-07-01 14:12:16 +01:00
eff410d1da Merge pull request #2862 from IntellectualSites/bukkit/1.16.1
Update to 1.16.1
2020-07-01 12:02:57 +02:00
cbe8875b94 Bump gradle version 2020-07-01 11:59:28 +02:00
49c35ec084 Resolve NMF's concerns 2020-06-29 22:05:32 -04:00
fa2ad8ab22 Improve plot alias command (tab complete, admin permission) fixes PS-63 2020-06-29 13:48:37 +02:00
3a2e932d17 Add missing mobs from 1.13.2+ 2020-06-28 18:45:40 -04:00
bd9bdc9e03 Separate the Vault Permission Handling from the Economy Handling 2020-06-28 14:28:11 +02:00
e139550949 Make cache expiration configurable 2020-06-27 23:07:20 +02:00
181c5b134f Update old links 2020-06-27 21:48:15 +02:00
74876f9e64 Get biome data from correct schematic for intersections (Fixes PS-50) 2020-06-27 20:44:46 +01:00
02f3c3ef50 Fix my stupid mistake of using lamdas not creating nested classes when creating schematics. "this" doesn't work like that. Cheers Java. 2020-06-27 20:38:55 +01:00
9c3d2cfb02 Move the caching and static accessors from EconHandler to PlotMain 2020-06-27 06:26:00 +02:00
9d609c2dfe Merge remote-tracking branch 'remotes/origin/v5' into bukkit/1.16.1 2020-06-26 20:40:50 -04:00
cb04c183a8 Update to 1.16.1 2020-06-26 20:38:30 -04:00
38425a1eae Update world border on Plot#claim (Fixes PS-13) 2020-06-26 13:49:17 +02:00
d1ecf9232e Merge pull request #2859 from FreebuildFR/feature/flag_placeholder
Add placeholders to get the value of a plot flag
2020-06-26 02:22:59 +02:00
e833403e3c Replace split with substring for placeholders 2020-06-25 14:08:44 +02:00
f64026af1a Only initialise EconHandler when economy is enabled and stop accessing the static instance directly. 2020-06-24 15:26:06 +02:00
efab6e92f7 Lower tab completion cache time and fix "Invalid player" message for /plot kick 2020-06-24 13:44:06 +02:00
f69cc5cc98 Merge remote-tracking branch 'origin/v5' into v5 2020-06-24 08:32:14 +02:00
f6f26c6102 Fix issue where numbers were sometimes parsed as usernames when they shouldn't be. This commit also fixes an issue where "Not a valid plot ID" was sent twice. 2020-06-24 08:31:23 +02:00
159b35c717 Fix OfflinePlayerUUIDService breaking when no worlds have been loaded. 2020-06-24 08:05:06 +02:00
7fbac4f286 Add a second placeholder to support only local flag of current plot 2020-06-24 00:51:27 +02:00
29080de860 5.12.2 2020-06-23 23:57:27 +02:00
e17222dd19 Merge remote-tracking branch 'origin/v5' into v5 2020-06-23 18:37:00 +02:00
55cf34508a Fix issue where old player objects were not cleaned up properly.
This is caused by an issue with the event order in Spigot (and Spigot derivatives), so the fix is rather hacky.
2020-06-23 18:36:53 +02:00
c52603921d Bump version 2020-06-23 13:13:01 +02:00
f4724a3c87 Fix expiration flag commands 2020-06-23 11:45:04 +02:00
2b4e2fc793 Add plot debugging and make tab completable aliases configurable 2020-06-23 11:39:45 +02:00
14baead342 Add placeholder to get the value of a plot flag 2020-06-23 01:20:17 +02:00
2d6e6ceaeb Improve documentation of BukkitMain#wrapPlayer and improve generic types 2020-06-22 15:45:57 +02:00
1dcf8d3995 Progress on the debug logging API 2020-06-21 15:50:49 +02:00
d07d32e28b Generate plot blocks on correct height when removing intersection
Fixes PS-46
2020-06-20 00:14:04 +02:00
cb969e37a6 Don't teleport players; Fixes PS-14 2020-06-19 11:36:35 +02:00
6259287dff Add tab completion for /plot <deny|kick|remove> 2020-06-13 15:54:38 +02:00
3e2e61d2be Re-introduce online mode 2020-06-13 15:53:03 +02:00
a3586791b5 Remove unused code and use less aggressive colors 2020-06-11 01:01:00 +02:00
bb298ab660 Remove leftover TODO 2020-06-11 01:01:00 +02:00
8c0f581ff0 Add missing license headers to new files 2020-06-11 01:01:00 +02:00
033b87deb5 Resolve TODOs 2020-06-11 01:01:00 +02:00
b6f1610a7e Provide no suggestions instead of player names for commands 2020-06-11 01:01:00 +02:00
e3fbb32399 Formatting and documentation 2020-06-11 01:01:00 +02:00
67b80bb8e8 Fix /plot setup back 2020-06-11 01:01:00 +02:00
ae1427b189 Remove usage of SetupObject 2020-06-11 01:01:00 +02:00
5165c439fc Add tab completion and fix minor bugs 2020-06-11 01:01:00 +02:00
b15c48e074 Implement setup steps 2020-06-11 01:01:00 +02:00
c5bfde330f First draft of redesigned setup processing 2020-06-11 01:01:00 +02:00
d12ecc8616 Softdepend on new complementary UUID services 2020-06-04 11:41:20 +02:00
950640a557 Revert "Don't send chat spy to message sender"
This reverts commit a37ab10414.
Let's not break plotchat when plotspy is enabled
2020-06-04 11:29:02 +02:00
86746e7843 Fixed https://issues.intellectualsites.com/issue/PS-26 2020-06-03 21:18:46 +02:00
2c74d2479f Exchange website url 2020-06-02 17:06:33 +02:00
f1b79a3b0d Add more documentation to the settings.yml
Apparently gradle wants to update the poms so here we go
2020-05-27 22:20:13 +02:00
6442922d86 Implement some more generic types to make the player objects easier to work with and also create wrapper objects for fake players (NPCs). Potentially fixes PS-27 2020-05-27 14:08:48 +02:00
edbacb8e47 Bump dependency version 2020-05-25 20:11:57 +02:00
71e22f41b1 Bump json from 20190722 to 20200518
Bumps [json](https://github.com/douglascrockford/JSON-java) from 20190722 to 20200518.
- [Release notes](https://github.com/douglascrockford/JSON-java/releases)
- [Commits](https://github.com/douglascrockford/JSON-java/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-25 17:29:36 +02:00
b9b0d89b5f Replace the R-tree library with PRTree. Fix SquirrelID shading issues. Bump the version to 5.12.0 2020-05-25 15:13:31 +02:00
fdf82d0d1e Merge pull request #2852 from aurorasmiles/features/v5/uuid
Add BungeePerms UUID service
2020-05-25 13:15:41 +02:00
09327b0128 Merge branch 'v5' into features/v5/uuid 2020-05-25 13:13:29 +02:00
8a3ee4cdc2 Merge pull request #2853 from darbyjack/v5
Updated PAPI & EssX dependency to ensure compatibility
2020-05-25 13:02:10 +02:00
8d1033f725 Merge branch 'v5' into v5 2020-05-25 12:58:32 +02:00
1d8bad3a80 Merge pull request #2855 from IntellectualSites/dependabot/gradle/v5/net.luckperms-api-5.1
Bump luckperms from 5.0 to 5.1
2020-05-25 12:51:01 +02:00
67fbfb0f2d Bump api from 5.0 to 5.1
Bumps [api](https://github.com/lucko/LuckPerms) from 5.0 to 5.1.
- [Release notes](https://github.com/lucko/LuckPerms/releases)
- [Commits](https://github.com/lucko/LuckPerms/compare/v5.0...v5.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-25 09:13:10 +00:00
4b0df80878 Updated PAPI & EssX dependency to ensure compatibility 2020-05-25 00:09:28 -05:00
52b90b6757 Merge pull request #2841 from IntellectualSites/features/v5/uuid 2020-05-25 01:40:35 +02:00
31b71ade69 * :D 2020-05-24 23:43:15 +01:00
0021b114de Revert "Slow down queue a bit because 1.13+ performance is bad"
This reverts commit bbde2f5e06.
2020-05-24 23:24:27 +01:00
28a7d027f6 Merge branch 'v5' into features/v5/uuid 2020-05-24 21:14:56 +02:00
e32a2e2723 Merge pull request #2847 from IntellectualSites/features/v5/single-area 2020-05-24 21:13:51 +02:00
46b68e489d Tab complete /p list 2020-05-24 21:08:11 +02:00
2436a6a402 remove debug, whoops 2020-05-24 20:54:10 +02:00
862467c0fa Tab complete /plot visit 2020-05-24 20:53:16 +02:00
69cfb431b1 Unstupidify Visit 2020-05-24 20:18:02 +02:00
172bd6f0f2 This should hopefully fix that broken merge. Maybe. Possibly. Idk. 2020-05-24 19:05:09 +02:00
a882555d1b Merge branch 'v5' into features/v5/uuid
# Conflicts:
#	Bukkit/build.gradle
#	Core/src/main/java/com/plotsquared/core/PlotSquared.java
#	Core/src/main/java/com/plotsquared/core/command/ListCmd.java
#	Core/src/main/java/com/plotsquared/core/command/Visit.java
2020-05-24 19:00:21 +02:00
0b12c4e5b2 Update issue link 2020-05-24 18:48:15 +02:00
0ac6383c2c Use PlotQuery in Visit 2020-05-24 18:35:32 +02:00
76913d4a78 immutable -> mutable 2020-05-24 18:35:32 +02:00
a0d1da3274 fix dum typo 2020-05-24 18:35:32 +02:00
1aa144e47d Deprecate old PlotFilter class 2020-05-24 18:35:32 +02:00
6b31743fb3 add missing javadoc 2020-05-24 18:35:32 +02:00
508fdce704 Add missing methods to PlotQuery and use PlotQuery in ListCmd 2020-05-24 18:35:32 +02:00
e912909aad Add plot query system 2020-05-24 18:35:32 +02:00
98322d5d11 Add BungeePerms UUID service. This should probably work. 2020-05-24 14:32:34 +02:00
7b97130af7 Add option to disable legacy cache, also add an option to return "Unknown" when a request cannot be fulfilled (old behaviour)
This should fix issues where lowercase offline mode UUIDs don't have access to their old cache.
2020-05-24 05:00:36 +02:00
cc168d5ae9 Fix SQLite table creation statement and add legacy SQLite uuids as a provider 2020-05-24 04:48:19 +02:00
d19df3b6eb Fix offline mode UUIDs 2020-05-24 04:28:29 +02:00
75dbc2db98 Fix offline mode UUIDs 2020-05-24 04:27:20 +02:00
2875b050c5 Add plugin UUID services. They probably work. 2020-05-23 19:43:32 +02:00
6c6c2b57a1 Add options to disable tab completion and extend username completion, also limit the total number of username suggestions to 200 per request 2020-05-23 17:20:09 +02:00
113da81f29 Actually save the schematic 2020-05-23 16:15:48 +02:00
4dd2613f2f Add missing caption 2020-05-23 15:02:53 +02:00
8c37cc5340 Fix minor issues 2020-05-23 15:02:31 +02:00
47c74cfa6d Set correct region height 2020-05-23 14:39:28 +02:00
32a55127f1 Fix partial area regeneration when using PlotSquared generation.
Also fix issues with region height and road width.
2020-05-23 14:32:02 +02:00
6d0458281b Merge remote-tracking branch 'origin/v5' into features/v5/single-area 2020-05-23 02:30:45 +02:00
6090c7ccac Link issues to new issue tracker for legacy reasons 2020-05-23 01:25:18 +02:00
5e6b27e21f Update README.md 2020-05-23 00:33:30 +02:00
eee04ab87d Shade guava-mini into the bukkot module 2020-05-22 22:04:46 +02:00
a833803bdf Shade rx into the bukkot module 2020-05-22 22:04:46 +02:00
d2af342a5d Shade r-tree into the bukkit module 2020-05-22 22:04:46 +02:00
93619b3988 Don't access tree until it has been created 2020-05-22 22:04:46 +02:00
dd4c5014fc Get rid of unused field 2020-05-22 22:04:46 +02:00
1e3379b00a Fix up the plot area nightmare 2020-05-22 22:04:46 +02:00
bbde2f5e06 Slow down queue a bit because 1.13+ performance is bad 2020-05-22 10:44:51 +01:00
b61dfd6f97 Single plot area progress 2020-05-22 03:20:11 +02:00
f16fa0a3ed Merge branch 'features/v5/worlds' into features/v5/single-area 2020-05-22 02:56:36 +02:00
d4bd08415a Shade guava-mini into the bukkot module 2020-05-22 02:56:23 +02:00
9ad276eeae Merge branch 'features/v5/worlds' into features/v5/single-area 2020-05-22 02:54:24 +02:00
a3179bf114 Shade rx into the bukkot module 2020-05-22 02:54:10 +02:00
0d20dad2a3 Merge branch 'features/v5/worlds' into features/v5/single-area 2020-05-22 02:52:05 +02:00
7c080770f0 Shade r-tree into the bukkit module 2020-05-22 02:51:40 +02:00
9752e5f62b Start working on single plot areas 2020-05-22 02:48:32 +02:00
3b7057ad4f do a second attempt at fetching uuid batches even if it errors 2020-05-21 21:24:55 +02:00
38a7c771be Don't access tree until it has been created 2020-05-21 20:23:36 +02:00
1c6075df2b Get rid of unused field 2020-05-21 20:06:37 +02:00
3ede0447b0 Fix up the plot area nightmare 2020-05-21 20:06:04 +02:00
f01b242e4a For sign updating to be scheduled asynchronously.
It then forces it back on the main thread, so it's fine, but this way we can safely wait for the UUID mapping to be fetched.
2020-05-20 15:26:20 +02:00
2417dace2d Add UUID caching 2020-05-20 15:12:09 +02:00
f82a111518 Merge branch 'v5' into features/v5/uuid
# Conflicts:
#	Bukkit/pom.xml
#	Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java
2020-05-20 11:27:11 +02:00
525ba648ae ignore build/ and update bukkit pom.xml apparently 2020-05-20 09:44:45 +01:00
0160c2bb55 Add setCuboids method to RegionManager
- Allow FAWE to take charge of big operations like /plot set all
2020-05-20 08:43:58 +01:00
ea41c842bc Fix a bunch of minor issues 2020-05-20 00:31:59 +02:00
8efc78e1c9 IT COMPILES! 2020-05-19 23:05:36 +02:00
973c18623f Port more commands and add more tab completion utilities 2020-05-19 19:34:33 +02:00
7aba70ea65 Make plot clears/sets less crashy.
There's still the issue of Spigot's (or paper's) terrible GC that does nothing and stores everything in PS old gen memory so the server just numpties itself though.
2020-05-19 16:54:12 +01:00
123ca8efe9 Update more commands and add proper request timeouts 2020-05-19 17:33:59 +02:00
22c26fe962 Add PlotArea#getFlag 2020-05-19 13:07:50 +01:00
761803f777 Add option for roads to respect a plot area's flags and implement to PlayerEvents 2020-05-19 12:41:51 +01:00
d5d18a60fb Fix #2836
getCompoundTag can also be in Core since we're using WorldEdit.
2020-05-19 11:53:18 +01:00
37b065a097 Progress. 2020-05-19 00:28:52 +02:00
fdfc61cf97 Update username on async pre login event 2020-05-18 20:45:51 +02:00
31c84ab18f Basic pipeline setup 2020-05-18 00:22:34 +02:00
a47527857c Fix wonky annotation placement in SQLiteUUIDService 2020-05-17 23:58:39 +02:00
12f2cb0d58 Add a cache uuid service 2020-05-17 23:57:40 +02:00
67bf90e92f Create the SQLite UUID service and cache 2020-05-17 23:41:59 +02:00
b5f92f5003 Add sync catcher to the blocking pipeline methods 2020-05-17 23:26:19 +02:00
58989c9311 Add some missing methods to the pipeline 2020-05-17 23:20:36 +02:00
736004d88b Don't fill in stacktrace for ServiceError 2020-05-17 18:03:04 +02:00
49f51f24f7 Don't loop services when all mappings have been found 2020-05-17 18:02:26 +02:00
95df62e59b Add missing consumer API methods 2020-05-17 17:48:42 +02:00
64cfe240f9 Port OfflinePlayerUUIDService to the new system 2020-05-17 17:36:12 +02:00
29f2863cf4 Progress 2020-05-17 17:26:48 +02:00
792fa1f11d Improve design 2020-05-17 12:55:07 +02:00
7591c440c2 Begin working on the new UUID service API 2020-05-17 12:40:25 +02:00
c58309b385 Add { transitive = false } to HV 2020-05-16 21:37:14 +02:00
5ae70743b1 Always set the generator 2020-05-16 21:37:14 +02:00
29e0479081 Fix preset initialization 2020-05-16 21:37:14 +02:00
441a73839e Add /plot components 2020-05-16 21:37:14 +02:00
ff8f7a0867 Actually create the world managers 2020-05-16 21:37:14 +02:00
31edffcb63 Begin working on a platform specific world management system
This should make world management a fair bit cleaner
2020-05-16 21:37:14 +02:00
5442d43918 Update bug-issue-report-for-plotsquared.md 2020-05-15 16:46:47 +02:00
25d4d23958 5.11.2 2020-05-14 23:15:08 +02:00
86edb20c15 Add a FAWE/WE chart 2020-05-14 16:33:26 +02:00
3d30885daf No PlotSquared-Core-Core 2020-05-14 15:47:25 +02:00
194c5aa27b Merge branch 'v5' of https://github.com/IntellectualSites/PlotSquared into v5 2020-05-14 14:45:33 +01:00
20c487238a PlotSquared-Core please 2020-05-14 14:45:27 +01:00
6814b4bef2 Fix Core archive name 2020-05-14 15:24:43 +02:00
e1a25907f2 Merge branch 'v5' of https://github.com/IntellectualSites/PlotSquared into v5 2020-05-14 14:19:37 +01:00
5f896dd39a Properly copy NBT data in containers 2020-05-14 14:19:33 +01:00
f4729310fa Include the core dependency in the Bukkit module 2020-05-14 14:52:43 +02:00
2f02f4392a Fix names of shaded jars 2020-05-14 14:51:23 +02:00
b7f708dcd6 Fix gradle config 2020-05-14 14:32:20 +02:00
501fd9c8e6 Merge remote-tracking branch 'origin/v5' into v5 2020-05-14 14:16:17 +02:00
7ba7df5cb2 Make the upload task work 2020-05-14 14:16:10 +02:00
9dd9201b67 Allow plot auto from non-plot areas if the server has only one plot area 2020-05-14 13:10:53 +01:00
8fb9f29ab7 Fixes #2827
If existing blocks are an instance of container, clear the inventory.
2020-05-14 12:57:26 +01:00
dd852801cc Merge pull request #2825 from IntellectualSites/tile-entity-cap
Fix chunk processing
2020-05-14 13:18:19 +02:00
1fa41e6209 Merge branch 'v5' into tile-entity-cap 2020-05-14 13:17:41 +02:00
a2db2e8268 Add return 2020-05-14 11:27:35 +01:00
617abf89e6 Split ChunkManager to Chunk and Region Managers
- Having not chunk-specific code in ChunkManager felt wrong.
- Also allow FAWE to replace setbiome code
- Also improve performance (proper usage of chunk loading) for setbiome
2020-05-14 11:27:35 +01:00
98b4ceab7d Fix style.yml 2020-05-13 16:29:10 +01:00
86a996b2ff Make the tile entity check true by default, as it only applies when the chunk processor is enabled (and it's disabled by default) 2020-05-13 15:09:00 +02:00
e6a9daf31a Make the tile entity limit in ProcessedWEExtent apply per chunk rather than per edit 2020-05-13 14:54:54 +02:00
8c0f7b207e Make the chunk listener NOT delete all tile entities in the chunk 2020-05-13 14:39:58 +02:00
ec347f8738 Add missing blocks and block tile entities from /plot set if the chunk processor is enabled 2020-05-13 14:24:04 +02:00
19fe2efb6e Fix the WE extent and add our own tile entity list 2020-05-13 14:11:17 +02:00
e6878d7804 clean up ProcessedWEExtent 2020-05-13 12:47:52 +02:00
435d877262 Make the tile entity check respect the chunk processor status 2020-05-13 12:25:48 +02:00
3deff629b0 Add paper specific listener for limiting the amount of tile entities in a chunk during build, instead of just doing it during chunk unloading 2020-05-12 23:01:14 +02:00
a038cb6d1b Merge branch 'v5' of https://github.com/IntellectualSites/PlotSquared into v5 2020-05-12 18:53:57 +01:00
637dd7d0c2 correct update messaging 2020-05-12 18:53:26 +01:00
d20fa39cf5 Add flag that prevents people from copying NBT data in the plot unless they're added as members 2020-05-12 19:25:06 +02:00
be6910d5d9 Reformated and update French translation
Some of my translations used '' to represent ' but it's not needed. Also splited some long lines and translated new backup system and keep-inventory flag.
2020-05-12 17:29:32 +02:00
2d6a5a3804 Update download link 2020-05-12 15:16:51 +02:00
630e81fbfb 5.11.1 2020-05-12 13:42:24 +02:00
6488aafd9d Version bump 2020-05-12 12:56:18 +02:00
4ad90d423d Fix timeout comment 2020-05-12 12:52:45 +02:00
d2dae45082 Add leaves to the blacklist 2020-05-12 12:49:39 +02:00
85c9bd7ceb Add all sign type to blacklist 2020-05-12 12:24:36 +02:00
d0ee579069 Move backup config section to a more appropriate place 2020-05-12 10:44:34 +01:00
10dbcbcdbd Prevent NPE in entityDamage
This is done by creating a fake (WE) entity type in the case that the entity type name is null. In these cases, WE has no equivalent.

By doing this, all entity category contains check will fail, and it will default to the PVE check at the bottom of the if-else if chain.
2020-05-12 10:05:47 +02:00
e8dd5fe903 Merge pull request #2816 from IntellectualSites/backups
Plot backup system
2020-05-12 09:40:25 +02:00
32c23e6ced Merge branch 'v5' into backups 2020-05-11 22:27:16 +02:00
81aaba328a ENGLISH > ROOT 2020-05-11 22:21:37 +02:00
3c5dd3d0d2 Merge remote-tracking branch 'origin/v5' into v5 2020-05-11 22:11:29 +02:00
2dc07d9321 Add a looooot of default disallowed blocks 2020-05-11 22:11:21 +02:00
841dd5e189 Update wiki links 2020-05-11 20:27:06 +02:00
b2bc2887d2 Fix dumdum merge 2020-05-11 20:17:41 +02:00
e20319f4e1 Merge branch 'v5' into backups
# Conflicts:
#	Core/src/main/java/com/plotsquared/core/configuration/Captions.java
2020-05-11 20:15:48 +02:00
d40160d205 Fix javadoc 2020-05-11 20:04:22 +02:00
f7167d5e83 Fix typo 2020-05-11 20:03:26 +02:00
282773a43f Replace Guava methods with stdlib equivalents 2020-05-11 20:02:33 +02:00
8944be5319 (Complex) command suggestions for /plot set 2020-05-11 19:37:25 +02:00
df01f9bea7 Add a list of blocks that cannot be used in /plot set <component> 2020-05-11 18:35:06 +02:00
3c17b76b1c Remove dum-dum line break 2020-05-11 11:21:32 +02:00
7a6909dab1 Merge branch 'v5' into backups 2020-05-11 11:19:59 +02:00
3064ae80d1 Add a keep-inventory flag 2020-05-11 11:19:36 +02:00
06bb6856a8 Fix bad getApplicablePlotArea(Location) code
- Fixes #2815 alongside 667098268f
2020-05-11 09:48:18 +01:00
702caa6feb Remove rogue line break 2020-05-10 22:09:56 +02:00
fc74c582bf Add option to disable deletion of plot backups when the plot is unclaimed 2020-05-10 21:52:57 +02:00
658361f825 Destroy backups when the plot is uncalimed 2020-05-10 21:31:16 +02:00
e0c9a802d8 Add automatic backups and implement them /plot clear and /plot set <component>. 2020-05-10 20:31:07 +02:00
c4a70c0945 Fix tab completion for the backup command 2020-05-10 19:42:42 +02:00
f7d6ac00e4 Make the backup commands work 2020-05-10 19:20:11 +02:00
8ed5a21b36 Merge branch 'v5' into backups 2020-05-10 17:03:36 +02:00
773a993ee1 Merge branch 'remove-eol-translation-strings' into v5 2020-05-10 17:02:13 +02:00
6fb63c9609 Implement backup restoration command. This might work, idk, we'll see. 2020-05-10 16:53:19 +02:00
079289eb74 Use #getTranslated on GENERIC_UNOWNED 2020-05-10 16:40:12 +02:00
59f96d4455 Translate all backup failure reasons 2020-05-10 16:39:14 +02:00
cdab52fcbe dumdum space go bye bye 2020-05-10 16:04:33 +02:00
63c9037b10 Fix typo 2020-05-10 16:00:20 +02:00
bbc86eba39 /plot debug progress 2020-05-10 15:51:27 +02:00
e0fb6f5440 /plot debug structure 2020-05-10 15:36:20 +02:00
2bd30af361 Cache both backup profiles and backup objects 2020-05-10 15:12:17 +02:00
b136f44f12 Merge branch 'v5' into remove-eol-translation-strings 2020-05-10 15:05:58 +02:00
d0dbb495b0 Add BackupProfile#restoreBackup 2020-05-10 14:58:45 +02:00
8715a27a93 No backups for merged plots 🐮 2020-05-10 14:41:02 +02:00
503fc44208 Updated according to new translations and old removed 2020-05-10 14:12:56 +02:00
d3bfaeb5a4 Ready for merging !
Removed useless space at the end of the file + precision of the date (latest edition)
2020-05-10 14:12:56 +02:00
7adecd0808 Last fix (removed unused translation + added the missing) 2020-05-10 14:12:56 +02:00
c99e081ae0 Fiexed issues reported by CodeFactor 2020-05-10 14:12:56 +02:00
285b6bf62d Updated and corrected French translation
Old translation has been reviewed and new v5 flags' translations has been added.
Some mistakes could now remain, I will fix them if needed ;)
Enjoy !
2020-05-10 14:12:56 +02:00
723e29cdd0 Continue working on the backup system 2020-05-10 14:02:25 +02:00
667098268f Almost fix slime pathing?
This almost works, there's no real way to do it gracefully because you can't set where the slime should be travelling to nicely, nor can you set rotation etc. Seems to be a fairly large part of the event capability missing from paper.
2020-05-10 12:18:55 +01:00
e6408b35a2 fix merge auto 2020-05-10 10:44:14 +01:00
3eb0de68c4 Begin working on the structure for the backup system 2020-05-09 20:05:39 +02:00
dd1b944205 Update gradle and remove license header from gradle 2020-05-09 16:47:49 +02:00
ae11f0610e Add a few more translation strings for setup wizard 2020-05-09 16:45:32 +02:00
55fc963673 5.10.6 2020-05-09 13:19:29 +01:00
198c7ca58d Remove dead translations 2020-05-09 14:04:08 +02:00
5a2f70238a Typo 2020-05-06 12:53:27 +01:00
8257b0b563 No lazy init when calling toString,equals or hashCode
That prevents premature initialization as NullBlockCategory
2020-05-06 12:53:27 +01:00
9b997d2195 Make constructor private 2020-05-06 12:53:27 +01:00
a19fa1b92c Send a debug message if category not found 2020-05-06 12:53:27 +01:00
2c060db9c0 Lazily initialize block tags 2020-05-06 12:53:27 +01:00
a8621a15ad Override setblock setting Pattern in ChunkBlockQueue
> Should stop NPE during plot analysis
> Without overriding this method, DelegateLocalBlockQueue setblock Pattern is called
> DelegateLocalBlockQueue's setblocks use parent.setBlock, but we set that to null in ChunkBlockQueue
> ChunkBlockQueue is simply just to cache the values from generation to use in analysis
> Therefore there is no need to setblocks in any other Queue implementation
2020-05-06 12:53:16 +01:00
179e9e1e74 Clean up plot grants and plot auto
- Correct maths for calculating granted plots, etc etc
- Don't check if the player has the correct number of plots AGAIN on AutoClaimFinishTask. That's dumb.
2020-05-06 11:39:34 +01:00
df5feff9ec Display the correct number of grants used in auto 2020-05-05 13:50:29 +01:00
9226aaff1f In the interest of debug should show everything, add debug when registering an unknown flag. 2020-05-05 12:57:14 +01:00
afe874a59b try-catch for NPE in purge and fail gracefully if the world is null
Plausible scenario since purge is often run to remove plots in the DB from removed worlds
Shouls fix #2806
2020-05-05 11:12:39 +01:00
4ad9f12d5d Move plot version to debugpaste top 2020-05-04 23:58:01 +02:00
228c37815a Fix merge all
Fixes #2804
2020-05-04 17:15:53 +01:00
a37ab10414 Don't send chat spy to message sender 2020-05-03 18:13:54 +02:00
d73dbf0c81 5.10.5 2020-05-02 13:34:04 +01:00
daee26681a use strings for spawn reasons to be safe 2020-05-02 12:13:00 +01:00
729469e030 Add config options for all paper events. 2020-05-02 11:58:32 +01:00
c6dc9ee189 Add some more listeners
- Also use setShouldAbortSpawn so it doesn't just try forever
 - Add config to enable or disable all paper listeners
2020-05-02 11:58:32 +01:00
85a75ad868 Yeet that PaperSPiGoT out of here 2020-05-02 11:58:32 +01:00
8ec8b8d803 Add some paper-specific listeners 2020-05-02 11:58:32 +01:00
d864792d09 Fixes #2800 Allow to wrap OfflinePlayers in 1.15.2 2020-05-02 11:28:06 +01:00
ed2e9a80ed Fix rare bug where if the plot size was less than 15 and the chunk contained an entire plot, it would generate incorrectly 2020-05-01 20:30:59 +01:00
36948ed351 Move world settings dump to a better location (where all of the fields will actually have been set) 2020-05-01 20:29:35 +01:00
e06429f3b0 Correct world types given to player 2020-05-01 19:18:11 +01:00
fd4a9a16de Execute commands when clicked for expire messages 2020-05-01 13:34:43 -04:00
acba10ac09 Fix broken url 2020-05-01 17:00:55 +02:00
d6d49e0912 Show suffix in versionString() too 2020-05-01 15:56:35 +01:00
b5de5f30ac Allow suffixes to the version
- Useful for "PlotSquared-5.10.4-SNAPSHOT" etc
2020-05-01 15:53:40 +01:00
17698065a0 Add extra SpawnReasons to spawn listener 2020-04-30 17:00:35 +01:00
135c6f2c15 Send a less obnoxious message if the flag name length exceeds the maximum allowed length 2020-04-30 13:36:03 +02:00
a263fe2f2d Apparently we need to recover from bad flags 2020-04-30 12:15:42 +01:00
cbe46539ca Pick up the rest of the reformating 2020-04-30 11:53:07 +01:00
5e842f1572 Force flag names to be 64 characters or less
- A few people seem to be on interesting SQL installs. This should fix the issues they have with 767 bytes,
2020-04-30 11:52:39 +01:00
b56d4d0fea Merge branch 'reformat' into v5 2020-04-30 11:39:02 +01:00
42106bb97a I didn't get everything first time 2020-04-30 11:33:59 +01:00
e7216d4aef Merge branch 'v5' into reformat 2020-04-30 11:33:31 +01:00
0751e9cea3 Make LiquidFlowFlag an enum 2020-04-30 11:18:28 +01:00
0091580ae0 Reformat it all. 2020-04-30 11:01:52 +01:00
4a16f9c1a7 LiquidFlow true will override BlockPhysics false 2020-04-30 10:59:43 +01:00
894d673c90 Fix tests 2020-04-30 11:32:50 +02:00
577fe3037f Update checker improvements and 5.10.4
- Add config option to disable poll once it's found an update (true by default)
 - Better PlotVersion stuff can now detect if you're using a later version than the spigot API, and not tell you about it
2020-04-30 10:17:19 +01:00
53ca62e8fc Bump version 2020-04-29 22:06:23 +02:00
670f6d9f8b Fix coral-dry flag not respecting horn coral blocks 2020-04-29 21:55:55 +02:00
8a21334e66 Merge branch 'v5' of https://github.com/IntellectualSites/PlotSquared into v5 2020-04-28 11:21:51 +01:00
a130d801d5 schem.intellectualsites.com (just forwards to athion.net but cnamed) 2020-04-28 11:21:30 +01:00
51b6f41eff Update papi hook message 2020-04-25 23:54:30 +02:00
a829799b36 Update scripting message 2020-04-25 23:53:46 +02:00
ccb43d0661 Do placeholders better.
- Still allow parsing of placeholder if no plot is required and plot is null.
- Properly check if the player is null before getting the plot, and if the plot is null
- These were still issues before my initial "fix" city
2020-04-23 14:16:06 +01:00
5bd53436df Prevent NPE for report comments 2020-04-23 13:44:34 +01:00
caa4a08b26 getOfflinePlayer once 2020-04-23 09:21:52 +01:00
0fa99d7940 Never return null in Placeholder. Also slight cleanup. 2020-04-23 09:06:37 +01:00
73dae7842d Only poll for updates every 30 mins.
- Don't do GET requests on player join (bad idea, it was sync...)
 - If there's an update it will notify the player still, it just caches the update status
2020-04-22 12:09:00 +01:00
92a18d810c Correct usage of Json.
I'm dumb and forgot toString doesn't work. Repalce with getAsString
2020-04-22 09:57:46 +01:00
591eb60a71 5.10.2
*bump version after resource update
2020-04-22 08:24:55 +01:00
9081a5aff6 Fix incorrectly formatted biomes in worlds.yml automagically 2020-04-22 08:22:14 +01:00
8ff4566905 Change misleading information 2020-04-21 23:42:31 +02:00
c8d8fb6aff Reformat premium information 2020-04-21 23:38:56 +02:00
6da4994955 Enhance premium verification 2020-04-21 23:06:11 +02:00
4780fcd534 Fixes #2782
Thanks for the contribution :)
2020-04-21 15:53:38 +02:00
5b30711470 Cant use bar chart 2020-04-21 12:39:48 +01:00
336f27f078 Only check update if premium. Add bstats bars for premium vs not. 2020-04-21 12:39:48 +01:00
92ef0d723b 5.10.1 2020-04-21 11:59:10 +01:00
ffee7a518e update default biome to match format WorldEdit accepts. 2020-04-21 09:16:02 +01:00
8d61e6f111 Fix update checker
- No more NPEs
 - Use the better spigot API
 - No obnoxious tooltip displaying the link without being clickable
2020-04-21 08:56:23 +01:00
67736bfbca git object is actually needed in Core build 2020-04-21 08:28:22 +01:00
84108b60c2 force version 2020-04-21 08:16:06 +01:00
59f8f2fdff Fix biome setting in 1.13 and 1.14 2020-04-20 23:40:04 +02:00
5c6175badb Merge remote-tracking branch 'origin/v5' into v5 2020-04-20 23:37:02 +02:00
8db8a30455 Fix biome setting 2020-04-20 23:36:56 +02:00
cbe8fda1df Fix update notification 2020-04-20 23:24:28 +02:00
558df450b5 Update spigot updater 2020-04-20 21:04:30 +02:00
f1d10c96bc Added PERMISSIONS_ADMIN_CHAT_BYPASS enum for the permission plots.admin.chat.bypass allowing users to bypass the plot chat security feature. 2020-04-20 18:55:28 +02:00
4d1b08a628 Updated to properly use the permissions system from com.plotsquared.core.util.Permissions and com.plotsquared.core.configuration.Captions 2020-04-20 18:55:28 +02:00
2eda56bc1f If all players are denied from a plot, this will allow administrators with permission to see chatspy, talk in plots they have been denied from. 2020-04-20 18:55:28 +02:00
c391fee100 Merge pull request #2779 from lenis0012/v5
Use primite int type for setBiome 1.13 workaround
2020-04-20 18:53:55 +02:00
06d255ccc2 Create FUNDING.yml 2020-04-20 18:48:22 +02:00
bb291b947f Use primite int type for setBiome 1.13 workaround 2020-04-20 17:27:46 +02:00
3c8b22688a I'm dumb. 2020-04-19 21:24:45 +02:00
cdd1fad85c Fix github link in debugpaste 2020-04-19 21:22:45 +02:00
ab6fd06657 Link to bStats 2020-04-18 23:22:05 +02:00
3bb32a5630 Add bStats stats to README 2020-04-18 23:21:01 +02:00
bf5862942a Disable prefixes for flag info headers and footers and suppress NPE in the update utility 2020-04-18 22:26:13 +02:00
cbea595fa0 Don't relocate json-simple. 2020-04-18 21:14:44 +02:00
952ea0b090 Fix setowner none (unclaim) 2020-04-18 17:59:45 +01:00
af951ac11c Update upload to debug the content if incorrect properly. 2020-04-18 17:53:45 +01:00
165614efe9 make sure never to have unclaim be an alias of delete. Even if it doesn't work. 2020-04-18 17:44:01 +01:00
95335df84d Merge branch 'v5' of https://github.com/IntellectualSites/PlotSquared into v5 2020-04-18 17:22:58 +01:00
100861484a Fix plot claim. 2020-04-18 17:22:51 +01:00
70eb588f1f Update issue template for v5/v3 support 2020-04-18 17:04:16 +02:00
c206de263b Merge remote-tracking branch 'origin/v5' into v5 2020-04-18 02:28:29 +02:00
0c12972c03 Register misc-flags. 2020-04-18 02:28:11 +02:00
546c4defb7 Add SirYwell to authors list
Thanks for all your hard work regarding v5 ❤️
2020-04-16 23:49:08 +02:00
814fca3832 Update flag description 2020-04-16 19:15:40 +02:00
3ee29297e0 Add option to force plot chat in plot areas. 2020-04-16 16:55:14 +01:00
6d9d0fff10 Add description caption for chat flag 2020-04-16 12:49:00 +01:00
714b8dad87 Implement IntellectualSites/PlotSquaredSuggestions/96
Also make Plot Chat work properly. Not sure what was going on there before...
2020-04-16 11:54:32 +01:00
a44807d47b Don't dump biome array on /ps reload. Gradle also seems to want to change the Core pom. 2020-04-16 11:43:13 +01:00
4aac3bf7e4 Merge pull request #2757 from IntellectualSites/api/v5/packages
Package Restructure
2020-04-16 10:58:13 +02:00
ee2ed8222d Merge config packages 2020-04-16 06:14:33 +02:00
edaf396894 Merge features/v5/internal-updates into api/v5/packages 2020-04-16 06:11:03 +02:00
6f052f0001 Remove extra line from HEADER 2020-04-16 05:05:58 +02:00
ba40a56c32 Add GPLv3 License headers to all source files. 2020-04-16 04:52:39 +02:00
780be3776a Addressed some comments 2020-04-15 15:26:54 -04:00
98235b3fdc Merge remote-tracking branch 'origin/dependabot/gradle/features/v5/internal-updates/org.jetbrains.kotlin-kotlin-stdlib-1.3.72' into features/v5/internal-updates 2020-04-14 20:25:22 +02:00
f5a9abfc8d Bump kotlin-stdlib from 1.3.61 to 1.3.72
Bumps [kotlin-stdlib](https://github.com/JetBrains/kotlin) from 1.3.61 to 1.3.72.
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-14 18:25:00 +00:00
a8619fe2ad Bump asm from 7.3.1 to 8.0.1
Bumps asm from 7.3.1 to 8.0.1.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-14 18:23:48 +00:00
c812bb1295 Bump annotations from 18.0.0 to 19.0.0
Bumps [annotations](https://github.com/JetBrains/java-annotations) from 18.0.0 to 19.0.0.
- [Release notes](https://github.com/JetBrains/java-annotations/releases)
- [Changelog](https://github.com/JetBrains/java-annotations/blob/master/CHANGELOG.md)
- [Commits](https://github.com/JetBrains/java-annotations/compare/18.0.0...19.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-04-14 17:50:27 +00:00
4e7bcc788b Merge pull request #2764 from IntellectualSites/features/v5/event-entity-categories
Features/v5/event entity categories
2020-04-12 23:21:47 +02:00
79bd69e599 Make the entity counting code use the new entity categories, remove usage of magic numbers and add /plot caps 2020-04-12 19:30:50 +02:00
5772af37fe Reclassify shulker as a hostile mob 2020-04-12 04:46:51 +02:00
6324bb1134 Use entity categories in events 2020-04-12 01:47:56 +02:00
658f2a3fc3 Finalize entity type categorisation 2020-04-12 01:23:13 +02:00
6e536f81ac Add more entity categories 2020-04-12 00:57:50 +02:00
dd9450d36a Add entity category loading code to WorldUtil (implemented in BukkitUtil) 2020-04-11 22:26:31 +02:00
8ef3a90ce0 Merge remote-tracking branch 'origin/features/v5/internal-updates' into features/v5/internal-updates 2020-04-11 21:49:15 +02:00
e6c76ad3f3 Entity categories implementation 2020-04-11 21:49:08 +02:00
4a249843eb Workaround to accept Slimes and EnderDragons as Monsters 2020-04-11 21:42:52 +02:00
5c1f0f51df Add a custom bStats chart tracking terrain types 2020-04-11 20:56:34 +02:00
2377ce1123 Relocate metrics properly 2020-04-11 19:52:45 +02:00
6f2b31f4a3 Add missing default flag values to GlobalFlagContainer (fixes #2748) 2020-04-11 18:49:04 +02:00
c5590440d6 Merge remote-tracking branch 'origin/features/v5/internal-updates' into features/v5/internal-updates 2020-04-11 17:58:27 +02:00
7931390ae4 Fix json relocation issue. Make plot areas dump their default flags and add progress output for flag conversion. 2020-04-11 17:58:08 +02:00
546b857b9d Fail default flag parsing gracefully 2020-04-11 17:19:43 +02:00
ce10d54a9c Don't use legacy IDs to get block types in the hybrid plot manager 2020-04-11 13:28:58 +02:00
965bbb9f3b Extract block queues from AugmentedUtils 2020-04-11 13:23:57 +02:00
e88b331155 Clean up AugmentedUtils and make the code readable by humans 2020-04-11 12:08:46 +02:00
ce177c3c46 Clean up HybridGen and make the code readable by humans
Previously it was only readable by androids, and Jesse.
2020-04-11 12:00:42 +02:00
5a6dbfda36 Fix javadoc generation issues 2020-04-11 03:23:48 +02:00
6c1caac731 Rename jar from BukkitAPI to Bukkit 2020-04-11 02:57:00 +02:00
9c3c42c3e6 Rename published maven artifacts
# Conflicts:
#	Bukkit/build.gradle
#	Core/build.gradle
2020-04-11 02:54:34 +02:00
5fc33dcc06 Rename published maven artifacts 2020-04-11 02:39:02 +02:00
c196ced0e2 Move org.json into core 2020-04-11 02:28:15 +02:00
dfa977a020 Moved more packaged based on feedback 2020-04-10 20:19:18 -04:00
5be2dfa747 Package Changes 2020-04-10 19:26:07 -04:00
f9ea99fa1d Merge pull request #2754 from IntellectualSites/features/v5/owners
Remove all direct access to Plot.owner
2020-04-10 19:52:41 +02:00
79583c011f Replace getOwnerAbs() == null with !hasOwner() 2020-04-10 19:28:10 +02:00
172bcc7677 Revert "Replace getOwnerAbs() == null with hasOwner()"
This reverts commit 79620042
2020-04-10 19:22:12 +02:00
fa51cb94a3 Merge pull request #2755 from IntellectualSites/features/v5/licenses
Add GPLv3 License headers to all source files.
2020-04-10 19:14:14 +02:00
c2060ea1a7 Remove deprecation of getOwner() 2020-04-10 19:11:53 +02:00
7962004215 Replace getOwnerAbs() == null with hasOwner() 2020-04-10 19:10:43 +02:00
45476f2867 I missed AbstractDB somehow... 2020-04-10 18:15:35 +02:00
280ced7904 Add GPLv3 License headers to all source files.
Reason: "            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."
2020-04-10 18:09:01 +02:00
474795367e Reformat Plot after the owner changes. It was a bit too messy. 2020-04-10 14:07:52 +02:00
ce756411cf Remove all direct access to Plot.owner
New methods were added for access to the absolute owner of a plot, and the documentation of the owner getters to clarify the purpose of the methods.
2020-04-10 14:05:01 +02:00
bdba2b33fb Remove Nukkit and Sponge files from v5
We don't need these because they already exist in our git history and in the legacy branch.
2020-04-09 19:38:10 -04:00
0d26111fa7 Include golems (snowmen, iron golems and shulkers) in the animal-interact flag. 2020-04-09 21:38:24 +02:00
dada7dbb86 Use relocated org.json instead of including the source files 2020-04-09 17:41:55 +02:00
cb05d34d20 Fixes #2751 2020-04-09 17:07:14 +02:00
7c25c60252 Merge pull request #2743 from IntellectualSites/features/v5/async-load
Prevent synchronous chunk loading whenever possible
2020-04-09 15:09:18 +02:00
86149224d1 Don't set walls, wall filling or outline in plots using full vanilla terrain generation 2020-04-09 13:06:45 +02:00
f717589074 Fix typo in MainUtil and switch out Consumer<Integer> to IntConsumer 2020-04-09 11:23:39 +02:00
254a0541cc Fix OfflinePlayerUtil runtime exception 2020-04-08 22:52:13 +02:00
271109a726 Fix dumdum async getLoadedChunks call, but only because Aikar broke everything. 2020-04-08 21:49:41 +02:00
38de74c4ff Make sure PlayerEvents#logout is called 2020-04-08 17:53:11 +02:00
865d11e844 Register vehicle-place and make it disabled by default 2020-04-08 17:28:16 +02:00
ebba9a2290 Fix interval flags 2020-04-08 17:22:53 +02:00
bc45b8b695 Merge branch 'features/v5/internal-updates' into features/v5/async-load 2020-04-08 17:17:17 +02:00
7ac389b698 Fix block ignition location check 2020-04-08 17:15:17 +02:00
616d22ceac Fix liquid-flow 2020-04-08 17:01:41 +02:00
f6332d2cd9 Add tab completions to flyflag 2020-04-08 16:53:39 +02:00
4ca7a81e96 Fix untrusted-visit. 2020-04-08 16:52:10 +02:00
ae2867136a Make the fly flag an enum flag instead. It now accepts: true, false and default, where default is the default value, and does not change the flight status at all. 2020-04-08 16:39:19 +02:00
ef04ed9151 Fix augmented generation 2020-04-08 04:10:22 +02:00
1522632f5a Don't replace blocks if they have identical states already 2020-04-08 02:02:20 +02:00
be6bcafccc Make sure augmented generation doesn't crash the server 2020-04-08 01:23:22 +02:00
5d332e7d58 Fix plot clearing in normal plot worlds 2020-04-08 00:01:58 +02:00
283ff945f3 Fix /plot auto performance and remove sign-guessing 2020-04-07 23:39:56 +02:00
0d4af3023d Extract TaskManager lambdas for better debugging 2020-04-07 23:18:36 +02:00
7fdb7961ce Merge branch 'features/v5/internal-updates' into features/v5/async-load 2020-04-07 22:13:42 +02:00
e161209a46 Fix plot claiming 2020-04-07 22:12:52 +02:00
5e2e4a8631 Revert testCreate change 2020-04-07 21:43:32 +02:00
e4a6bd0ca5 Don't try to remove players. Fixes #2742. 2020-04-07 20:56:43 +02:00
5547185b3f Prevent synchronous chunk loading whenever possible 2020-04-07 20:19:39 +02:00
7841ee3dcc Fix a few encapsulate merge issues 2020-04-02 13:40:11 +01:00
099a680c85 Encapsulation and Magic Values (#2711)
* Encapsulate attributes of PlotArea using lombok Getters/Setters

* Limit access to collections, don't expose implementation details

* Better naming for some boolean attributes

* Replace magic type value with PlotAreaType enum

* Replace magic terrain value with PlotAreaTerrainType enum

* Fix remaining rebase conflicts

* Reduce code duplication

Co-authored-by: Alexander Söderberg <Sauilitired@users.noreply.github.com>
2020-04-02 13:34:38 +01:00
9764d4d226 Actually add biomes to road schematics 2020-03-28 10:43:24 +00:00
37336fffe2 Merge branch 'features/v5/internal-updates' of https://github.com/IntellectualSites/PlotSquared into features/v5/internal-updates 2020-03-28 02:26:25 +01:00
a285404847 Update gradle, actions and fix typo in branch 2020-03-27 23:44:17 +01:00
2994b2c158 Use try with resource to close ClipboardReader and stop adding "atic" to schematic files or not reason 2020-03-26 20:55:27 +00:00
3a3a06631d Add coral-dry flag 2020-03-25 21:14:58 +01:00
f9bf576d2e Actually initialise the biome array in HybridPlotWorlds.
Fixes generation using schematics (and allows generation using biomes in schematics for roads and plots....)
2020-03-25 17:46:08 +00:00
f2f7fbce09 Allow trusted users to use /plot set 2020-03-25 11:01:19 +00:00
412a3ee344 Support v2 schematics properly. No 3D biomes are supported by it as yet. (#2716) 2020-03-24 09:08:56 +01:00
2f4eea118a add clear option to /ps purge (#2714) 2020-03-24 09:08:32 +01:00
7310506ed4 Add option to have road regeneration be persistent across restarts. (#2715)
* Add option to have road regeneration be persistent across restarts.

* Use int[] not Integer[]. There's the possibility of large arrays given the size of some worlds.

* Correctly close Input/Output streams with try-with-resource.
Also don't try to ObjectOutputStream if an existing file hasn't actually been deleted.
2020-03-22 19:23:35 +00:00
26b5ee7482 Merge branch 'features/v5/internal-updates' of https://github.com/IntellectualSites/PlotSquared into features/v5/internal-updates 2020-03-20 12:12:30 +00:00
58280a20a8 Log don't debug on regenallroad completion 2020-03-20 12:11:39 +00:00
3d47d7e73f Use worldedit to regenerate chunks. (#2708)
* Use worldedit to regeneration chunks. It's very slow, but it works.

* Use the AutoClose-ness of EditSession
2020-03-20 13:05:13 +01:00
d9f9d7dc34 Features/v5/event results (#2706)
* Begin events rewrite using Guava EventBus:
- moved events to within core
- removed BukkitEventUtil
- EventUtil in core is now the implementation
- Refactor any event calls

TODO:
- Test :)
- Implement changes to PlotSquared's own listeners
- Other

* Correct code style for annotations and refactor EventUtil to EventDispatcher

* Make getEventResultRaw default method and remove empty PlotEventListener file

* not raw map

* Remove PlotPlusListener

* Add listener registration to PlotAPI. Add documentation and refactor Result enum

* Add reason for the Event Result. Change how the claim event is called
TODO: better auto event somehow. Possible re-write of auto required..?

* Implement changes to events properly
Add PlayerAutoPlotEvent
Add PlotDoneEvent
Add schematic variable to Claim event and allow it to be changed
Add reason for plot unlink to unlink event
Add pattern to component set event and allow it to be changed
Allow component of component set event to be changed
Add player to plot merge event

* Fix compile

* Correct formating

* Various cleanup
 - Correct formatting in places
 - Add feedback to Desc command cancellation
 - Correct use of flag API
 - Add FlagRemove event to flagcommand where required

* Replace reason with caption

* Switch colours in Event Deny caption

Co-authored-by: dordsor21 <dordsor21@gmail.com>
2020-03-15 12:22:49 +01:00
4bcd926543 Update discord links 2020-03-09 23:50:22 +01:00
05626c2c8f Features/v5/move swap fixes + some other important commits (comments, etc) (#2699)
* Use generics instead of the raw class

* Add Gradle wrapper verification

* Fix biome setting in versions prior to 1.15

* Fixes #2654

* Document area getters in PlotAreaManager, and replace y-value with z in the area contains check.

* Remove update notifications

* Remove unused dependencies

* Do not kick plot owners on "/p deny *"

* Do not kick any added players on /p deny *

* Allow redstone to be used in server plot with `redstone.disable-offline` enabled.

Potentially fixes #2613

* Disallow swapping ,erged plots

* Fix legacy converter.

* Fix blockbucket pattern generation

* Prevent pasting schematics onto merged plots.

* Cancel claim event correctly

* Revert "Cancel claim event correctly"

This reverts commit 0f786155
Further investigation required

* Fix plot swapping messing up owners. Fixes #2282

* Fix plot move

* Prevent plot swapping form changing the database unless the swap was successful.

* Update signs after swap.

* Only send move success message if the move was successful.

Co-authored-by: Matt <4009945+MattBDev@users.noreply.github.com>
Co-authored-by: NotMyFault <mc.cache@web.de>
Co-authored-by: Daniel <admin@hywse.eu>
Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com>
2020-02-28 22:15:04 +01:00
30b83faab6 Fix plot downloading 2020-02-28 00:31:53 +01:00
9868648fcb Pull/2693 (#2694)
* Commit WIP flag work.

* More ported flag types, and additions to the flag API.

* Make PlotFlag more generic to allow generic flag creation

* Pull Captions methods into a Caption interface.

* Port MusicFlag

* Port flight flag

* Port UntrustedVisitFlag

* Port DenyExitFlag

* Remove paper suggestion

* Make ListFlag lists immutable

* Update Flag containers. Add javadocs. Add missing methods.

* Port description flag

* Port greeting and farewell flags

* Port weather flag

* Move getExample implementation to BooleanFlag

* Port reserved flags

* Port all boolean flags.

* Remove unused flag types

* Invert liquid-flow flag

* Find the real (legacy) flag name

* Change NOITFY -> NOTIFY in Captions

* Make IntegerFlag extendable

* Port integer flags

* Update Flag command to current API state

* Begin remaking flag command

* Create DoubleFlag + extract common parsing stuff

* Supply arguments in flag parse exceptions

* Implement missing flag subcommands

* Update Flag command to current API state

* Implement PriceFlag

* Port deny-teleport

* Port gamemode flags

* Port BreakFlag

* Port PlaceFlag

* Port UseFlag

* Remove old unused flag constants

* Port blocked-cmds flag

* Fix entity util

* Port TimeFlag

* Use CaptionUtility for formatting

* Port keep flag

* Fix imports

* Reformat code

* Remove unused classes

* Fix MainUtil.java

* Remove FlagCmd

* Add flag info header and footer

* Comment out flag related stuff in SchematicHandler

* Remove FlagManager

* Finalize Plot.java

* Finalize PlotArea.java

* Finalize PlotListener

* Fix API issues

* Fix a bunch of compile errors

* Fix `/plot flag remove`

* Fix initialization of GlobalFlagContainer

* Apply API changes to events

* Update SQLManager to new API

* Invert default value for DenyExitFlag

* Replace flag.getValue().toString() with flag.toString()

* Make FlagContainer instance in Plot final

* Fix various command issues

* Clean up PlotSettings

* Don't show internal flags in flag list

* Fix `/plot flag add`

* Remove the info inventory as it's 100% broken

* Add plot info entries and fix up the default format

* Fix default flag state in Captions

* 781c200 part 2

* Fix odd grammar in captions

* Fix odd grammar in captions v2

* Add create table statements for plot_flags

* Remove old flag references in SQLManager

* Use the new plot_flags table

* Add tab completion to `/plot flag`

* Improve parse error handling

* Make flag permission check recognize parse exceptions

* Initial progress towards flag conversion

* Fix minor issues

* Don't validate flags during flag conversion

* Allow unrecognized flags to be parsed

* Filter out internal flags from command sugguestions

* Use the wrong caption when there's no plot description set

* Limit command suggestions for boolean flags

* Make blocktypelistflags accept blockcategories

* Require categories to be prefixed with '#' and fix some minor display issues

* Fix plot database conversion

* Update PlotFlagEvent.java

Updated return description

* Fix command annotation wrapping

* Add FLAG_UPDATE event for FlagContainer listeners

* Make getParentContainer nullable

* Document castUnsafe in FlagContainer

* Document FlagContainer constructors

* Add missing documentation to FlagContainer

* Document FlagParseException

* Fix wording in FlagContainer javadoc

* Document InternalFlag

* Document PlotFlag

* Minor changes

* Remove revisit comments

Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com>
Co-authored-by: NotMyFault <mc.cache@web.de>
Co-authored-by: Matt <4009945+MattBDev@users.noreply.github.com>
2020-02-24 18:42:02 +01:00
b99631f1bd Fix regen. Fixes #2692 2020-02-24 14:00:45 +01:00
6be26e8047 Also consider negative locations when cancelling liquid flow 2020-02-24 12:11:22 +01:00
c7de9379ad Prevent liquids from flowing out of block walls. Fixes #2598. 2020-02-24 11:47:52 +01:00
86ea69b65e Update README.md 2020-02-21 00:53:52 +01:00
f2aa9dccd1 Revert "Remove unused code"
This reverts commit 6d779dad05.
2020-02-20 20:08:25 +01:00
464f5e09ae Allow all messages to be formatted by external formatters and add PAPI support 2020-02-20 16:03:17 +01:00
17e4bde720 Update gradle version 2020-02-20 00:41:19 +01:00
6d779dad05 Remove unused code
Or at least I made it unused lul
2020-02-20 00:39:32 +01:00
38d0cc1b29 Fix isPremium method 2020-02-20 00:05:55 +01:00
fc9a221127 Update BukkitMain.java
wiz is quick
2020-02-20 00:02:06 +01:00
95394ec54f Add Premium verification 2020-02-19 23:55:43 +01:00
a3759f93a2 Add placeholders 2020-02-16 20:33:24 +01:00
2632283431 Move recent changes into 1 branch 2020-02-16 15:17:06 +01:00
8a014e3ad5 Remove wiki generator and unnencessary comments from the settings 2020-02-16 15:08:02 +01:00
1b3427837e Rename maven artifacts
Renaming the Core module artifact matchin its module name on GitHub, like the bukkit or nukkit module does.
Given that, it's more clear which maven artifact belongs to which module.
2020-02-16 14:42:27 +01:00
b3c91d866b Lazy cherry-pick 5db1e73eae4b0d4628df8bbbc172670c42d96435 without merge conflics 2020-02-16 14:41:51 +01:00
10dd531cdb Remove paper suggestion 2020-02-16 14:38:33 +01:00
6953187cac Add current + new version to update notification
And fix a little typo alongside bumping versioning to v5
2020-02-16 14:37:07 +01:00
7b83f0146e Readd update notification permission implementation 2020-02-16 02:34:51 +01:00
4ed108b5c0 Remove legacy auto updater (v3) 2020-02-16 01:36:24 +01:00
24b6b23d25 Bind update notifications to spigot resource updates
The notification permission could be moved back into the other class, but well
2020-02-16 01:33:43 +01:00
5ea03f12fb Update issue template 2020-02-14 17:54:45 +01:00
99a53cb005 DoogiePC doesn't like trees 2020-02-12 18:57:42 -05:00
d7af409d01 Test another workaround 2020-02-12 18:21:23 -05:00
0304e98b00 Workaround for SPIGOT-5574 2020-02-12 15:42:31 -05:00
b16db904cc Removed unused class which should be unbreaking. 2020-02-11 17:09:36 -05:00
4b306d454b Fixed an error with the debug command and added @NotNull to generator methods 2020-02-11 17:06:58 -05:00
e53ea2377c Fixed #2671
Sort of fixed. I added an if statement to log and return if a certain condition is met. It is unclear if there will be more generation issues as a result.
2020-02-11 16:52:16 -05:00
f79f2ac29e Tweaks to the world generator 2020-02-11 16:16:56 -05:00
1516edbeca Update dependencies
Changed gradle to new group id and repository. Updated paper-api to 1.15.2
2020-02-11 15:25:42 -05:00
54348d824c Update authors 2020-02-10 17:36:54 +01:00
f32cb0c16e Merge remote-tracking branch 'origin/dependabot/gradle/v4/org.projectlombok-lombok-1.18.12' into v4 2020-02-10 17:18:02 +01:00
4a03cb0701 Merge remote-tracking branch 'origin/dependabot/gradle/v4/org.ow2.asm-asm-7.3.1' into v4 2020-02-10 17:17:39 +01:00
76e25953b1 Bump lombok from 1.18.10 to 1.18.12
Bumps [lombok](https://github.com/rzwitserloot/lombok) from 1.18.10 to 1.18.12.
- [Release notes](https://github.com/rzwitserloot/lombok/releases)
- [Changelog](https://github.com/rzwitserloot/lombok/blob/master/doc/changelog.markdown)
- [Commits](https://github.com/rzwitserloot/lombok/compare/v1.18.10...v1.18.12)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-10 08:03:18 +00:00
2f0bf97162 Fix displaying 1 player remove as players 2020-02-09 01:12:32 +01:00
d0b6badf09 Fix DebugClaimTest (#2667)
* Fix DebugClaimTest

* Remove code causing 3 database updates per plot + errors when using MySQL
2020-01-31 17:12:06 +00:00
30f37e1e8b Update /plot info placeholders 2020-01-27 23:39:29 +01:00
4e1c90bbcc Fixes space between names in plot info (Fixes #2675) 2020-01-27 23:06:42 +01:00
c31c855952 Update gradle version to 6.1 2020-01-24 18:47:32 +01:00
312b2ad1a8 Send the bStats ID 2020-01-24 18:10:19 +01:00
0953b5627e Add bStats plugin version
bStats 1.7 requires plugins to have an ID to submit data.
2020-01-24 16:08:48 +01:00
57af89f1d0 Merge pull request #2652 from SynergyMC/breaking
Revert teleportation behavior to pre-4.400
2020-01-22 21:23:25 -05:00
f71f481ff3 Compile against 1.15.2 2020-01-22 23:54:37 +01:00
0ba31ed56b Update dependencies fitting https pattern 2020-01-21 18:25:46 +01:00
edc81bc668 Updated branch names for gh actions testing 2020-01-21 15:52:57 +01:00
7797e33ec5 Update sponsors 2020-01-20 01:24:08 +01:00
118adb42b9 add hungarian translation 2020-01-14 12:27:23 +01:00
2efe604b9b Bump asm from 7.2 to 7.3.1
Bumps asm from 7.2 to 7.3.1.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-13 08:01:49 +00:00
cadd0cd9b4 Merge pull request #2660 from IntellectualSites/feature/v4/wildcards-player-args
Improve "everyone" args and update a few command messages
2020-01-10 19:40:01 +01:00
f3187a465c Oops 2020-01-10 19:38:38 +01:00
6fe856c002 Merge remote-tracking branch 'origin/dependabot/gradle/v4/junit-junit-4.13' into v4 2020-01-10 19:06:22 +01:00
9a626ea1de Deprecate metrics methods
Metrics are controlled via bstats config for some time now. The config option in settings.yml has already been deprecated in the past.
2020-01-10 14:18:38 +01:00
026233b7e7 Update gradlew 2020-01-10 14:07:33 +01:00
6ee9d91aef Update requriedTypes 2020-01-10 14:01:28 +01:00
808a1ed703 Add wildcards to command args 2020-01-10 13:35:59 +01:00
7142e9e0e3 deprecate metrics settings 2020-01-07 22:45:53 +01:00
66a2e5427e Bump junit from 4.12 to 4.13
Bumps [junit](https://github.com/junit-team/junit4) from 4.12 to 4.13.
- [Release notes](https://github.com/junit-team/junit4/releases)
- [Changelog](https://github.com/junit-team/junit4/blob/master/doc/ReleaseNotes4.12.md)
- [Commits](https://github.com/junit-team/junit4/compare/r4.12...r4.13)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-01-06 07:40:34 +00:00
3aa554c52b Implemented optional specification of teleport causes
This should have backwards-compatibility for any users of the API but would require an update from anything reimplementing (for whatever reason) the interfaces amended by this commit.
2020-01-02 18:29:12 -10:00
4322f4c31d Merge pull request #2649 from IntellectualSites/dependabot/gradle/v4/org.ajoberstar.grgit-4.0.1
Bump org.ajoberstar.grgit from 4.0.0 to 4.0.1
2020-01-03 01:24:18 +01:00
33f8df3afe Add teleport cooldown bypass permission to plugin.yml 2020-01-03 01:12:48 +01:00
42a83b56c3 Add clarification of tp bypass permission node to settings.yml 2020-01-03 01:10:32 +01:00
0f39df0e0b Revert teleportation behavior to pre-4.400 2019-12-31 16:05:53 -10:00
a17588199f Merge pull request #1 from IntellectualSites/v4
Merge from upstream
2019-12-31 15:24:42 -10:00
fad835c029 Bump org.ajoberstar.grgit from 4.0.0 to 4.0.1
Bumps org.ajoberstar.grgit from 4.0.0 to 4.0.1.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-30 14:32:48 +00:00
568e9537ec Bump WorldEdit version to 7.0.1 2019-12-27 17:33:52 +01:00
58bb0509f7 Bump gradle version to 6.0.1 2019-12-27 17:01:17 +01:00
0ad2682210 Add update and jvm flags to debugpaste 2019-12-27 16:53:38 +01:00
f97e52ea0b Fixes building against 1.15 2019-12-25 10:40:54 +01:00
4c90523121 use 1.15 spigot 2019-12-25 02:39:41 +00:00
519d3ee2d6 Fix 'Unable to find method createTag' on 1.15 servers (#2642)
* Fix 'Unable to find method createTag' on 1.15 servers (#2629)

Mojang apparently refactored their NBT code in 1.15, so the NBT
parsing code in NbtFactory that used Mojang's NBT code via Reflection
broke. Since PlotSquared now depends on WorldEdit, it is much easier
to use their NBT parsing library than to update the Reflection-based
code.

* Clean up NBT streams properly
2019-12-23 20:35:37 +00:00
3abb35e506 Prevent NPE when trying to set statement = null in SQLManager
If the statement is null, the `isClosed` check will lead to a NPE. As it's going to be null either way, just ignoring the NPE has no side effects.
2019-12-20 18:01:36 +01:00
c6e36fd70e Fix plot biomes.
When migrating to the WorldEdit Biome types, code was not altered to account for these changes. This lead to configuration parsing breaking, and the `/plot setbiome` command no longer functioning. This fixes #2599.
2019-12-20 17:37:48 +01:00
ccc7b0ec65 Fix #2634 no such method error 2019-12-20 06:03:23 +00:00
4d1d3a165c Merge pull request #2635 from traksag/interact-fix
Fix interact handling for sneaking players
2019-12-18 22:23:42 -05:00
e54cf24248 Fix interact handling for sneaking players 2019-12-18 19:42:57 +01:00
7103969bba Merge pull request #2634 from traksag/hanging-fix
Fix that players cannot place hanging entities
2019-12-18 12:37:47 -05:00
3bb40a8fff Fix that players cannot place hanging entities 2019-12-17 21:04:44 +01:00
f4dcc9e786 Merge remote-tracking branch 'origin/breaking' into breaking 2019-12-15 13:08:27 -05:00
9fd29b264e Some logging operations to check for tps loss. 2019-12-15 13:08:02 -05:00
478c761750 More PlayerEvent fixes. 2019-12-15 12:53:16 -05:00
dbd6feed4e Update issue template and add link to suggestion repo on issue tab 2019-12-14 18:05:15 +01:00
480c9f11b8 Add 1.15 to templates 2019-12-14 17:46:07 +01:00
ed8fa0a2a5 Revert changes to BlockPlaceEvent 2019-12-10 17:53:55 -05:00
3af05e7960 Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-12-09 14:44:16 -05:00
07b6942690 Minor code tweaks 2019-12-09 14:43:53 -05:00
7d8a5213dd Bump okio from 2.2.2 to 2.4.1
Bumps [okio](https://github.com/square/okio) from 2.2.2 to 2.4.1.
- [Release notes](https://github.com/square/okio/releases)
- [Changelog](https://github.com/square/okio/blob/master/CHANGELOG.md)
- [Commits](https://github.com/square/okio/compare/2.2.2...2.4.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-07 19:34:28 +01:00
241589fdb0 Revert "Bump retrofit from 2.4.0 to 2.6.2"
This reverts commit 1097f44feb.
2019-12-07 18:56:43 +01:00
eb09e0a633 Bump okhttp from 3.12.0 to 4.2.2
Bumps [okhttp](https://github.com/square/okhttp) from 3.12.0 to 4.2.2.
- [Release notes](https://github.com/square/okhttp/releases)
- [Changelog](https://github.com/square/okhttp/blob/master/CHANGELOG.md)
- [Commits](https://github.com/square/okhttp/compare/parent-3.12.0...parent-4.2.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-07 18:49:39 +01:00
4e2c90e399 Bump gson from 2.8.0 to 2.8.6
Bumps [gson](https://github.com/google/gson) from 2.8.0 to 2.8.6.
- [Release notes](https://github.com/google/gson/releases)
- [Changelog](https://github.com/google/gson/blob/master/CHANGELOG.md)
- [Commits](https://github.com/google/gson/compare/gson-parent-2.8.0...gson-parent-2.8.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-07 18:48:37 +01:00
1097f44feb Bump retrofit from 2.4.0 to 2.6.2
Bumps [retrofit](https://github.com/square/retrofit) from 2.4.0 to 2.6.2.
- [Release notes](https://github.com/square/retrofit/releases)
- [Changelog](https://github.com/square/retrofit/blob/master/CHANGELOG.md)
- [Commits](https://github.com/square/retrofit/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-07 18:47:38 +01:00
e5423b5e08 Bump kotlin-stdlib from 1.3.50 to 1.3.61
Bumps [kotlin-stdlib](https://github.com/JetBrains/kotlin) from 1.3.50 to 1.3.61.
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v1.3.61/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.3.50...v1.3.61)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-07 18:41:32 +01:00
4ba5b6da1d Bump annotations from 17.0.0 to 18.0.0
Bumps [annotations](https://github.com/JetBrains/java-annotations) from 17.0.0 to 18.0.0.
- [Release notes](https://github.com/JetBrains/java-annotations/releases)
- [Commits](https://github.com/JetBrains/java-annotations/compare/17.0.0...18.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-07 18:37:56 +01:00
c1a7844f4a Bump lombok from 1.18.8 to 1.18.10
Bumps [lombok](https://github.com/rzwitserloot/lombok) from 1.18.8 to 1.18.10.
- [Release notes](https://github.com/rzwitserloot/lombok/releases)
- [Changelog](https://github.com/rzwitserloot/lombok/blob/master/doc/changelog.markdown)
- [Commits](https://github.com/rzwitserloot/lombok/compare/v1.18.8...v1.18.10)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-07 18:36:45 +01:00
781a4d8d78 Bump org.ajoberstar.grgit from 3.1.1 to 4.0.0
Bumps org.ajoberstar.grgit from 3.1.1 to 4.0.0.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-12-07 18:35:23 +01:00
3ba29583fc Add all colors to style.yml
For further releases , we should aim to get a rid of the styles.yml and $ codes. I've seen a lot of people struggling with them, and if you want to use other formatting codes, you need to yamlize the non yamlized messages, otherwise it won't work properly.
2019-12-07 17:40:15 +01:00
7760631751 Remove deprecated method from Captions.java 2019-12-06 21:18:56 -05:00
05d6d557b8 Merge remote-tracking branch 'origin/breaking' into breaking 2019-12-06 21:16:19 -05:00
9925a320f5 Fix event listeners 2019-12-06 21:16:09 -05:00
dca5d84d29 Fixes #2620 2019-12-06 00:28:07 +01:00
0b470f8e01 Update links 2019-12-04 20:11:05 +01:00
7e58f4341e Minor fixes and performance improvement 2019-12-02 17:07:57 -05:00
d8933afb50 Merge remote-tracking branch 'origin/breaking' into breaking 2019-11-28 21:50:31 -05:00
4bb45fc220 Replace ByteArrayUtilities code with Guava and Replace PlotGameMode with WorldEdit equivalent. 2019-11-28 21:50:21 -05:00
09f913cba4 Enhanced Fixes #2595
Updating messages and adding new strings that fit better.
2019-11-28 19:02:58 +01:00
006d730185 Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-11-26 18:00:44 -05:00
cf558d8f62 Update DebugPaste.java 2019-11-25 22:40:50 +00:00
a65d546f3b Fix debugpaste split 2019-11-25 22:38:03 +00:00
bf02c9fe5f Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-11-25 22:37:39 +00:00
6908b9f29b Update bug-issue-report-for-plotsquared.md 2019-11-24 19:30:37 +01:00
cd06dbc915 Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-11-22 16:12:01 +00:00
977dfa807f potentially fix partial world auto 2019-11-22 16:11:48 +00:00
8b7e8ec635 Update bug-issue-report-for-plotsquared.md 2019-11-22 15:52:25 +01:00
c14e1d7add Update Settings.java 2019-11-22 12:40:27 +01:00
7377366372 Updating some debug colors 2019-11-22 12:28:34 +01:00
9c9841663a Fixes #2595 (leave error) 2019-11-19 01:39:51 +00:00
612e96201c Fixed ItemTypeListFlag issue 2019-11-18 13:43:16 -05:00
d7aa4a0e1f Revert "Fix some flag issues"
This reverts commit 8b741477
2019-11-18 13:41:46 -05:00
8b7414770f Fix some flag issues 2019-11-18 11:09:32 -05:00
a26ede4dae Typo 2019-11-14 12:54:02 -08:00
7591770c40 Update README.md 2019-11-14 12:48:41 -08:00
7623698a00 don't use legacy ids here 2019-11-12 22:31:02 +00:00
f518c47e09 Fixes #1922 Banned people can still "talk" in plot 2019-11-12 20:52:14 +00:00
c23086259d Potentially fixes rename issues
#2450
2019-11-12 20:48:33 +00:00
765a021ecd Some flag fixes
Use ItemType for the flags, since they accept items, not blocks.
Fixes #2571
2019-11-12 20:38:18 +00:00
7e21107120 Update README.md
Include information about what the project is. The previous README assumed that the reader would already be familiar with the concept, which isn't really ideal for a project description. The added text is taken from the Spigot resource page.
2019-11-12 10:20:46 +01:00
322e186c4b Ignore invalid blocks 2019-11-12 07:32:05 +00:00
59b8776814 Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-11-11 20:39:44 +00:00
5bb7069c7f Fixes #2571 2019-11-11 20:39:28 +00:00
1a2c15684e Fixed typo 2019-11-11 21:39:27 +01:00
b02565532f Update template checkbox 2019-11-11 21:38:44 +01:00
7d7414ebb9 Fix for single chance parsing 2019-11-11 19:47:26 +00:00
55d6217c32 Check if WORLDEDIT_RESTRICTIONS is enabled
Unregister if disabled.
2019-11-11 19:44:51 +00:00
10e5760ba8 Merge pull request #2564 from IntellectualSites/we
Use patterns instead of BlockBucket
2019-11-10 14:08:47 -08:00
f797141a29 Update Plot.java 2019-11-10 22:08:03 +00:00
968c23113c Fixes #2412 2019-11-10 21:51:29 +00:00
bf4d953f3c No need to convert to a BlockState here 2019-11-10 18:49:31 +00:00
d34f5cc97e Config reading/writing 2019-11-10 18:32:32 +00:00
d254633b77 Use patterns instead of BlockBucket
Still use BlockBucket for loading/saving from config
2019-11-10 17:47:37 +00:00
be93e6efdf Merge pull request #2560 from IntellectualSites/we
"Use WorldEdit classes" because actually descriptive commitmessages are dumb, right?
2019-11-10 15:56:41 +01:00
1d9ad94822 Fix plot getRegions off by 1 2019-11-10 14:01:12 +00:00
fe438fd62a swallow stacktrace 2019-11-10 13:29:58 +00:00
93894aca96 Force lowercase 2019-11-10 13:27:37 +00:00
f1b8510708 forgot to find 2019-11-10 13:24:04 +00:00
7dcecf486d Use regex for block bucket, yay 2019-11-10 13:18:15 +00:00
8c1985f9c0 Split by regex 2019-11-10 13:08:34 +00:00
34eb7d05dc Print actual value for setup? 2019-11-10 12:45:51 +00:00
729452038b Check if integer 2019-11-10 12:43:47 +00:00
3e30e9554f Add missing RunnableVal import. 2019-11-10 13:26:59 +01:00
009bcaf6d4 Merge remote-tracking branch 'origin/we' into we 2019-11-10 13:26:27 +01:00
baca8808ee Add missing Location import. 2019-11-10 13:26:15 +01:00
1a923063b5 Merge branch 'breaking' into we 2019-11-10 13:18:16 +01:00
c512189478 fix import 2019-11-10 11:31:47 +00:00
c155c65a8f Remove modifier reflection
Fixes #2484
2019-11-10 11:23:25 +00:00
a221d6fd07 Run tasks synchronously on Bukkit when the plugin is disabled.
Previously, the tasks would fail to run, as the scheduler prevents disabled plugins from running tasks. This would cause problems on server shutdown, especially when the SQLManager attempts to perform database queries.

This fixes #2446.
2019-11-10 12:10:38 +01:00
37280779b0 Make /plot setowner require an argument. Fixes #2501. 2019-11-10 12:06:33 +01:00
ed588476e0 Fix single plot areas 2019-11-08 22:31:01 +00:00
19fe39ce2e Merge branch 'we' of https://github.com/IntellectualSites/PlotSquared into we 2019-11-08 05:18:07 +00:00
07fcd53bf8 Fixes IntellectualSites/PlotSquaredSuggestions#58 2019-11-08 05:17:51 +00:00
834d786037 Fix okio 2019-11-07 17:02:34 +01:00
72c6f1165a Fix okio 2019-11-07 17:02:08 +01:00
1570c4d08a Add missing import 2019-11-06 14:20:32 -05:00
252fdefef3 bad regex replace 2019-11-06 11:39:55 +00:00
fed5169724 Get sign lines sync 2019-11-05 15:23:48 +00:00
2cb734bba2 editsession util 2019-11-04 21:55:40 +00:00
46926a4d99 Merge remote-tracking branch 'origin/breaking' into breaking 2019-11-04 16:20:03 -05:00
88732bb88c Use CuboidRegion instead of RegionWrapper 2019-11-04 21:08:33 +00:00
ba3ff08d6c Update BlockStateListFlag.java 2019-11-04 20:17:29 +00:00
8f7f6a4f40 Merge branch 'breaking' into we 2019-11-04 20:17:15 +00:00
e8bf3f0d2c Merge pull request #2558 from IntellectualSites/more-translation-strings
Add translation messages for flag errors
2019-11-04 21:12:39 +01:00
7e6dc48d69 imports 2019-11-04 19:58:24 +00:00
37f608258f Remove PlotBlock 2019-11-04 19:55:55 +00:00
a25511c849 Add custom translations for special flags 2019-11-04 19:22:54 +01:00
930dee9326 Refactor BlockVector2 2019-11-04 17:44:23 +00:00
315f26fb82 Add missing color 2019-11-04 00:46:08 +01:00
e972cb4c1a Make flag error messages translatable 2019-11-04 00:33:04 +01:00
7309e61221 AeSix' template improvements 2019-11-02 12:48:41 +01:00
17e784c283 Revert dependency upgrades 2019-11-01 21:45:06 -04:00
627ecd2b71 Merge pull request #2542 from mindw0rm/UntrustedVisit
New plot flag untrusted-visit
2019-10-31 17:02:48 -04:00
1c5bd55c96 Merge pull request #2553 from IntellectualSites/bukkit-api
Providing bukkit module on maven
2019-10-31 17:02:00 -04:00
6ec3951e4e Add Bukkit module to maven 2019-10-30 15:05:52 +01:00
d1115d62a7 Merge pull request #2548 from IntellectualSites/flag_fix
Flag fixes and others 🐮
2019-10-27 16:13:22 +01:00
e29727827d Fix missing word 2019-10-27 16:02:34 +01:00
1f89948948 Remove unused flags 2019-10-27 16:01:57 +01:00
1067e5f2c2 Remove redundant empty line 2019-10-27 15:19:49 +01:00
25ca011bfe Fixes #2550 2019-10-27 15:10:15 +01:00
3be0be1b60 Make sure DENY_EXIT checks for the admin override permission. Fixes #2411. 2019-10-27 12:11:48 +01:00
2e15934666 Fix /plot flag set allowing for invalid flag values. (Fixes #2519) 2019-10-27 12:01:04 +01:00
cb52ee8cfb Make the flag list output message configurable. 2019-10-27 11:55:15 +01:00
01eee306f1 Fixes #2462 by making flag categories translatable. This reflects (somewhat) recent changes to command categories. 2019-10-27 11:45:18 +01:00
a601739fbd Improve handling of list flags, which in turn resolves issues where add and remove would allow players to add flags with unrecognized values. 2019-10-27 11:25:33 +01:00
cb1767347b Merge branch 'breaking' into UntrustedVisit 2019-10-23 20:51:59 +02:00
32654e1f25 Merge pull request #2506 from mindw0rm/DenyTeleportBugfix
Bugfixes for deny-teleport
2019-10-23 14:37:20 -04:00
91108a5df9 Merge branch 'breaking' into UntrustedVisit 2019-10-22 17:21:24 +02:00
e5e522bc31 Merge branch 'breaking' into DenyTeleportBugfix 2019-10-22 17:20:43 +02:00
5741d5f6a0 Merge pull request #2533 from mindw0rm/PlaceFlagBugfix
Place flag bugfix (fixxes issue #2524)
2019-10-21 21:27:48 -04:00
8b30d6a7ff Merge pull request #2537 from IntellectualSites/dependabot/gradle/com.google.code.gson-gson-2.8.6
Bump gson from 2.8.0 to 2.8.6
2019-10-19 17:45:28 -04:00
108b84d8b1 Merge pull request #2527 from IntellectualSites/dependabot/gradle/com.squareup.retrofit2-retrofit-2.6.2
Bump retrofit from 2.4.0 to 2.6.2
2019-10-19 17:44:37 -04:00
469a4f25e5 Merge branch 'breaking' into dependabot/gradle/com.squareup.retrofit2-retrofit-2.6.2 2019-10-19 17:44:27 -04:00
c49369bc7e Merge pull request #2538 from IntellectualSites/dependabot/gradle/org.ow2.asm-asm-7.2
Bump asm from 7.1 to 7.2
2019-10-19 17:43:25 -04:00
46b5f01bbc Merge pull request #2536 from IntellectualSites/dependabot/gradle/com.squareup.okhttp3-okhttp-4.2.2
Bump okhttp from 3.14.0 to 4.2.2
2019-10-19 17:43:13 -04:00
d7d9b1793f Bump okhttp from 3.14.0 to 4.2.2
Bumps [okhttp](https://github.com/square/okhttp) from 3.14.0 to 4.2.2.
- [Release notes](https://github.com/square/okhttp/releases)
- [Changelog](https://github.com/square/okhttp/blob/master/CHANGELOG.md)
- [Commits](https://github.com/square/okhttp/compare/parent-3.14.0...parent-4.2.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-19 21:40:45 +00:00
e029cc3fa1 Bump retrofit from 2.4.0 to 2.6.2
Bumps [retrofit](https://github.com/square/retrofit) from 2.4.0 to 2.6.2.
- [Release notes](https://github.com/square/retrofit/releases)
- [Changelog](https://github.com/square/retrofit/blob/master/CHANGELOG.md)
- [Commits](https://github.com/square/retrofit/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-19 21:40:43 +00:00
53e80e4359 Merge pull request #2535 from IntellectualSites/dependabot/gradle/com.squareup.okio-okio-2.4.1
Bump okio from 2.2.2 to 2.4.1
2019-10-19 17:39:38 -04:00
427cf081e3 Bump okio from 2.2.2 to 2.4.1
Bumps [okio](https://github.com/square/okio) from 2.2.2 to 2.4.1.
- [Release notes](https://github.com/square/okio/releases)
- [Changelog](https://github.com/square/okio/blob/master/CHANGELOG.md)
- [Commits](https://github.com/square/okio/compare/2.2.2...2.4.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-19 21:37:55 +00:00
c103504fc8 Merge pull request #2529 from IntellectualSites/dependabot/gradle/org.jetbrains.kotlin-kotlin-stdlib-1.3.50
Bump kotlin-stdlib from 1.3.30 to 1.3.50
2019-10-19 17:36:40 -04:00
20957a75d5 use a new Location convert function to ensure that there will be no side effects 2019-10-18 08:02:44 +02:00
dd715a9c8a Revert "copy yaw and pitch when converting between Bukkit Location and PlotSquared Location"
Undo this since I can't guarantee that there aren't side effects.
2019-10-18 07:51:01 +02:00
24d82e562a merge upstream changes 2019-10-18 07:44:04 +02:00
9ad2537ca2 Merge pull request #2517 from IntellectualSites/debugpaste-update
Improve world generator diagnosis
2019-10-17 12:23:47 +02:00
4a3c015524 Bump asm from 7.1 to 7.2
Bumps asm from 7.1 to 7.2.

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-14 15:17:55 +00:00
53e94cc001 Bump gson from 2.8.0 to 2.8.6
Bumps [gson](https://github.com/google/gson) from 2.8.0 to 2.8.6.
- [Release notes](https://github.com/google/gson/releases)
- [Changelog](https://github.com/google/gson/blob/master/CHANGELOG.md)
- [Commits](https://github.com/google/gson/compare/gson-parent-2.8.0...gson-parent-2.8.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-14 15:17:37 +00:00
039b7aee9e Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into UntrustedVisit 2019-10-10 20:34:41 +02:00
0bcaaf3c0b copy yaw and pitch when converting between Bukkit Location and PlotSquared Location 2019-10-10 20:33:25 +02:00
5315e1e337 let untrusted-visit override deny-teleport 2019-10-10 20:32:48 +02:00
1f4f78a179 this can be done more elegantly 2019-10-10 01:53:27 +02:00
599ef8aa44 Bugfix for #2524 (place flag) 2019-10-10 01:36:40 +02:00
e445f96e0c Merge pull request #2528 from IntellectualSites/dependabot/gradle/org.yaml-snakeyaml-1.25
Bump snakeyaml from 1.23 to 1.25
2019-10-07 13:49:52 -04:00
9a8aa7a4e5 Merge pull request #2530 from IntellectualSites/dependabot/gradle/org.projectlombok-lombok-1.18.10
Bump lombok from 1.18.8 to 1.18.10
2019-10-07 13:47:28 -04:00
a3905c68cf Fix links 2019-10-07 19:20:48 +02:00
3d1cd46053 Update Sponsors 2019-10-07 19:09:41 +02:00
ec6c9dac49 Bump lombok from 1.18.8 to 1.18.10
Bumps [lombok](https://github.com/rzwitserloot/lombok) from 1.18.8 to 1.18.10.
- [Release notes](https://github.com/rzwitserloot/lombok/releases)
- [Changelog](https://github.com/rzwitserloot/lombok/blob/master/doc/changelog.markdown)
- [Commits](https://github.com/rzwitserloot/lombok/compare/v1.18.8...v1.18.10)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-07 15:16:57 +00:00
8068671200 Bump kotlin-stdlib from 1.3.30 to 1.3.50
Bumps [kotlin-stdlib](https://github.com/JetBrains/kotlin) from 1.3.30 to 1.3.50.
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v1.3.50/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.3.30...v1.3.50)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-07 15:16:54 +00:00
8927f50cc6 Bump snakeyaml from 1.23 to 1.25
Bumps [snakeyaml](https://bitbucket.org/asomov/snakeyaml) from 1.23 to 1.25.
- [Commits](https://bitbucket.org/asomov/snakeyaml/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-07 15:16:31 +00:00
b806a30639 Setting debug value default to false
If the user is interested in the information or needs it for debugging, they can enable them, but we don't need to spam them unnecessarily with stats about his plot worlds on each startup, /plot reload, etc.
The same information can be obtained from a debugpaste as well, so it's not a loss of information to offer assistance.
2019-10-03 01:32:19 +02:00
ae0f1d2a15 Adding "website" to plugin.yml 2019-10-03 01:26:31 +02:00
120d36e413 Add a confirmation to the debugpaste
That should prevent people from accidentally pressing buttons (whyever you would do that)
2019-10-03 01:12:08 +02:00
c8c5d777a1 Make paths... idk what to say here 2019-10-03 00:40:41 +02:00
b92d42e7cc Add clarification to what files are pasted 2019-10-01 14:46:19 +02:00
59bc6f19e5 General clarification of the config
Certain values were rather vague and caused some confusion in the past, hopefully things are more clear now.
2019-10-01 14:01:50 +02:00
ca25b7b3c8 Fix odd space 2019-10-01 13:02:32 +02:00
b074e6e198 Update auto-comment.yml
I created templates and setup Actions to ensure functionality.
2019-10-01 12:54:20 +02:00
267bebd0e8 Improve world generator diagnosis 2019-10-01 12:12:42 +02:00
58dbe96bd8 Added a plot flag 'untrusted visit', that allows /plot visit for untrusted players without the permission plot.visit.other. 2019-09-19 10:40:47 +02:00
becac84e6e Setup Actions test 2019-09-18 02:06:28 +02:00
ae1273a7f3 Bugfixes for deny-teleport 2019-09-14 12:58:22 +02:00
05ef076ef0 Remove unnecessary spaces 2019-09-12 04:01:47 +02:00
d20d95d29b Remove schematic test command 2019-09-12 03:53:29 +02:00
6e387f3321 Do not remove the schematic file extension 2019-09-12 03:44:31 +02:00
68a5166d2f Fixes the major lag source from GlobalBlockQueue 2019-09-11 19:04:29 -04:00
2bf47478b2 Merge remote-tracking branch 'origin/breaking' into breaking 2019-09-09 15:15:53 -04:00
07b88e3147 Minor changes to the block queue classes to match FAWE more closely. 2019-09-09 15:15:44 -04:00
26e851fcf1 Merge pull request #2500 from 56738/remove-everyone
Make removing * remove the Everyone node before removing all members
2019-09-09 14:34:39 -04:00
5b3426f4ac Make removing * remove the Everyone node before removing all members 2019-09-09 18:44:36 +02:00
ecfb71b08f Changes made to GlobalBlockQueue to help diagnose lag. 2019-09-08 19:36:02 -04:00
fd6fbebd69 Fixed #2496 2019-09-08 18:43:47 -04:00
758c343e52 Update bug-issue-report-for-plotsquared.md 2019-09-08 20:25:12 +02:00
04f789d404 Fix merging 2019-09-08 20:02:45 +02:00
fe730574c9 Fixes #2490 2019-09-08 01:06:27 +02:00
20b0fa31d0 Update gradle and deprecated methods 2019-09-07 22:46:13 +02:00
ec0281768d Update README.md 2019-09-07 12:50:12 +02:00
3bec76e27a Create CONTRIBUTING.md 2019-09-07 12:46:40 +02:00
462c113ce8 Fixed accidental code reversion 2019-09-06 21:20:54 -04:00
12538c7c27 Merge pull request #2461 from IntellectualSites/midnight-ideas
@N0tMyFaultOG has some random ideas sometimes
2019-09-06 21:16:30 -04:00
e01b470493 Resolve merge conflicts 2019-09-07 03:06:05 +02:00
f7b78595a9 Merge remote-tracking branch 'origin/breaking' into breaking 2019-09-06 20:40:38 -04:00
b3136b4ebe Version number fixes, fixed documentation, new caption added, and tweaks to API functionality. 2019-09-06 20:40:28 -04:00
4d0bd8a3a3 Upgrade build files 2019-09-04 03:04:51 +02:00
e1db27010c Updating command usage formats 2019-09-04 03:01:25 +02:00
40e3b7fa06 Revert "Add new switch conditions to entity listeners"
This reverts commit a0d666ae14.
It seems to break armor stand placing in some cases.
2019-09-03 23:56:08 +02:00
a7012814ab Deprecated a poorly named method 2019-09-01 19:40:16 -04:00
213fd80894 Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-09-01 16:55:49 -04:00
5e8909883d Modified internal configuration classes, Updated Mojang UUID fetcher, other various method and documentation tweaks 2019-09-01 16:54:43 -04:00
08cd39749b Create PULL_REQUEST_TEMPLATE.md 2019-08-27 14:44:56 +02:00
a0d666ae14 Add new switch conditions to entity listeners 2019-08-23 23:58:52 -04:00
fa8b18f3d5 Add new switch conditions to entity spawning 2019-08-23 15:57:57 -04:00
267dea4693 Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-08-23 17:18:43 +01:00
434d219f41 Add plots.admin.area.sudo for permission to commands of the form "/plot <area> <command...>" as well as plots.admin 2019-08-23 17:18:25 +01:00
589a69ac6d Update ISSUE_TEMPLATE.md 2019-08-20 15:36:13 -04:00
dc0126b53c Revert PaperLib from later commits too 2019-08-19 20:47:36 +01:00
0ca69d4f03 Don't use PaperLib I guess 2019-08-19 20:39:03 +01:00
ec84b91f84 added a stupid check because of a spigot issue. 2019-08-19 14:51:14 -04:00
a63f8650e5 Create CONTRIBUTING.md 2019-08-18 13:25:11 -04:00
59a1d619d3 Add sponsors 2019-08-18 14:29:37 +02:00
76dc60194d Added an invalid world name check. 2019-08-17 19:17:01 -04:00
cc9c1f63d8 When an exception is actually being used it shouldn't be named ignored 2019-08-17 18:45:07 -04:00
e5da93f359 Added a null check for the very unlikely chance that the command isn't found. 2019-08-17 18:42:31 -04:00
008237b2a4 Fixed #2469 2019-08-17 18:40:39 -04:00
920796d8ec Fixed #2468 2019-08-17 16:28:53 -04:00
c6a4206266 Fix Typo 2019-08-17 17:06:17 +02:00
1cf85ff2c6 Removed unused translation strings
And added a new alias
2019-08-17 02:19:29 +02:00
be20b2404b OCD
- Typo Fixes
- Small amendments (Spelling)
- Reformatting
2019-08-17 01:48:43 +02:00
011baba140 Update PlotSquared.java 2019-08-16 02:05:51 +02:00
b22919a278 Variable renames and fixes 2019-08-16 01:47:22 +02:00
49b7c71fbb Adding some more translation strings 2019-08-16 01:22:24 +02:00
31c81fc9fe Update command aliases format 2019-08-15 17:35:40 +02:00
8653b9b0a2 Update unfitting messages 2019-08-15 16:37:57 +02:00
b3e53e34b6 Simplify help string 2019-08-15 16:20:30 +02:00
fbaef13553 Unify player string
<> args are used in a lot of commands, PlayerName is used in only 3 commands and I don'T want to remove methods if not really necessary, so let's just change it here.
2019-08-15 15:39:37 +02:00
3473f5dc85 Fixed compatibility with FAWE and compile issue. 2019-08-14 20:47:01 -04:00
b4c33aaa18 Midnight work
Also fixes #2463
2019-08-14 14:36:20 -04:00
a910b542a0 Replace annotations with JetBrains annotations 2019-08-13 23:43:11 -04:00
705d0294b5 Merge remote-tracking branch 'origin/breaking' into breaking 2019-08-13 23:37:22 -04:00
403916748c Variable renaming 2019-08-13 23:37:15 -04:00
fd9e716ec4 Variable renaming 2019-08-13 22:42:01 -04:00
3e6b0b8394 Work on directions and merging 2019-08-13 22:01:23 -04:00
56e055c671 Second attempt at a sign fix. 2019-08-13 18:39:38 -04:00
1341100f03 Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-08-13 18:28:54 -04:00
d7c72d5f75 Variable renames 2019-08-13 18:26:55 -04:00
265f0c6615 Potential fix for #1930 2019-08-13 18:06:10 -04:00
9642777750 If NMF can have midnight work, so can I 2019-08-13 17:33:32 -04:00
41052b27a0 I have some random ideas sometimes
- Adjusting some RequiredTypes fitting their partners/default behavior
- A plot doesn't need to be claimed to get the center
- Adapting another gamemode acronym
- Fix copyFile to adapt the latest changes
- Removing HastebinUtility, we have our own paste service
2019-08-13 21:57:49 +02:00
0ac4b7728f Merge pull request #2460 from jewome62/feature/toggle-time
Add toggle for time
2019-08-13 18:44:32 +02:00
bb97fb8e19 Update Templates to sponge schematic format
Skyblock has been removed as it was simply the default island if ASkyBlock
2019-08-13 04:08:17 +02:00
b1391bd6d7 Fix template export 2019-08-13 03:13:03 +02:00
f1c190028e Fixes #2013
Tested with LuckPerms, result successful.
2019-08-12 23:59:14 +02:00
ad7bcd19d4 Added a debug command to diagnose the issues in #2411 2019-08-12 13:40:22 -04:00
ca954ccc97 Add toggle for time 2019-08-11 21:15:02 +02:00
8ab10de4ad Fix plot title toggling (fixes #2456) 2019-08-10 17:54:44 +02:00
df9d5ae2ac Merge remote-tracking branch 'origin/breaking' into breaking 2019-08-07 19:16:55 -04:00
5ddbf3def4 Update gradle 2019-08-07 19:16:44 -04:00
289f01f7a2 Import changes and variable renames 2019-08-06 21:46:38 -04:00
f3aa9c43ef Fixed a potential NPE 2019-08-06 21:44:39 -04:00
165cf26818 Fix typo 2019-08-07 03:43:49 +02:00
e6a7f4e5a7 Add null checks to validation task
Fixes #2407
2019-08-06 20:45:01 -04:00
8f685b754a Modifications to formatting and UUID Handler
Fixes #2423
2019-08-06 20:35:36 -04:00
539ad9f05c Small changes 2019-08-06 16:08:56 -04:00
5b8f6e466a Minor gradle edit 2019-08-06 15:05:04 -04:00
520be48198 Create fixborders.js 2019-08-05 14:47:19 -04:00
e4a345880e Update addsigns.js 2019-08-05 14:46:54 -04:00
392ef51a6f Revert broken async chunk change 2019-08-05 14:37:56 -04:00
f06903f1b8 Merge remote-tracking branch 'origin/paperstuff' into paperstuff
# Conflicts:
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Help.java
2019-08-05 14:07:09 -04:00
fe83ef0975 Get chunks asynchronously 2019-08-05 14:03:09 -04:00
9e8a6c702d Fix gradle script 2019-08-05 14:03:08 -04:00
3e8b8a7575 Remove old files 2019-08-05 14:03:08 -04:00
d3e37e5eab Migrate Templates to new format 2019-08-05 14:03:08 -04:00
0c8b11cedd Update DebugUUID.java 2019-08-05 14:03:07 -04:00
cd26b1647d Add kelp-grow flag
Simply as the name says, add a controlled way to let kelp grow.
2019-08-05 14:03:07 -04:00
cdc01a5bc4 Reformat debugpaste
And upgrade from IC -> IS
2019-08-05 14:03:07 -04:00
1295f7c4bf Merge with breaking 2019-08-05 14:03:06 -04:00
20dd98d3b9 Use PaperLib and make command task return completable futures 2019-08-05 14:02:30 -04:00
bd51292f4c Get chunks asynchronously 2019-08-05 13:33:27 -04:00
cc45208605 Merge remote-tracking branch 'origin/breaking' into paperstuff 2019-08-05 13:32:19 -04:00
7542dbeab8 Fix gradle script 2019-08-04 18:40:39 +02:00
01dfdbe2ef Merge with breaking 2019-08-03 23:26:16 -04:00
bb21abb110 Merge branch 'breaking' into paperstuff
# Conflicts:
#	Bukkit/build.gradle
#	Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java
#	Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/events/PlayerPlotTrustedEvent.java
#	Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/object/BukkitPlayer.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/commands/Command.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Buy.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Clear.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugExec.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Grant.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Help.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/MainCommand.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Near.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Relight.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/SubCommand.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trust.java
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Visit.java
2019-08-03 23:11:02 -04:00
59517647b5 Remove old files 2019-08-03 23:20:21 +02:00
1eba425087 Migrate Templates to new format 2019-08-03 23:18:50 +02:00
16fcb2f505 Update DebugUUID.java 2019-07-30 23:58:48 +02:00
6d0849eb66 Merge pull request #2431 from IntellectualSites/kelp-grow
Add kelp-grow flag
2019-07-27 21:55:39 +02:00
dbf5084fa1 Reformat debugpaste
And upgrade from IC -> IS
2019-07-25 20:02:39 +02:00
d6779d977a Fixes #2423 2019-07-21 20:43:36 -04:00
e8df39d3c4 Fixes #2435 2019-07-21 20:40:04 -04:00
feda094273 Add kelp-grow flag
Simply as the name says, add a controlled way to let kelp grow.
2019-07-20 01:29:30 +02:00
23b88a375d player interact ignore cancel 2019-07-12 02:18:08 +10:00
095dccd30f Revert changes to intersection generation 2019-06-28 13:59:57 +01:00
246845607f Let's first test against Material.matchMaterial for material matching (:
Also update some dependencies
2019-06-27 15:18:54 +01:00
3074e45d2c Fixed #2325
The permission node does not exist on PlotMe anymore
2019-06-25 11:43:28 +02:00
83d1f1d629 1.14 id support (#2404)
* Plausible fix for 1.14 support.
- Allow 1.14 blocks to be specified in LegacyBlocks, but only saved if the server version is 1.14.
- No snazzy config conversion, but it seems most people managed to figure it out on their own anyway

* Ignore the "severe" output because of new 1.13/14 blocks

* fix oak_wall_sign for 1.14
2019-06-24 13:37:59 +01:00
485415c551 1.14 id support (#2403)
* Plausible fix for 1.14 support.
- Allow 1.14 blocks to be specified in LegacyBlocks, but only saved if the server version is 1.14.
- No snazzy config conversion, but it seems most people managed to figure it out on their own anyway

* Ignore the "severe" output because of new 1.13/14 blocks
2019-06-23 14:17:44 +01:00
d6401d1638 Allow running the road regeneration on a single region
The plot-based road regeneration from before does not have the same behavior as the real road regeneration code. This new debug operation will regenerate the roads within the region the player is standing using the same code that regenerates all roads. This makes it much easier to tell if things are working correctly and as expected.
2019-06-16 11:57:35 -04:00
7f404e1cf5 Fix plot walls after running regenallroads
Also clears whatever was above the plot wall, such as pieces of the road.
2019-06-16 11:57:35 -04:00
a94c588a17 Check if location has PlotArea to avoid NPE 2019-06-03 16:26:20 -04:00
d106262454 Have PlotAreas create their own PlotManager
Leads to cleaner code, less need for instanceof and casting, as a PlotArea knows which kind of PlotManager it needs to make
2019-06-03 16:26:20 -04:00
c5bca66618 Remove PlotArea parameter from PlotManager method calls
As per the previous commit, all PlotManagers now have a reference to their managed PlotArea.
2019-06-03 16:26:20 -04:00
6b3960fc3f Pass the PlotArea into the PlotManager 2019-06-03 16:26:20 -04:00
908a5784a1 Cache conversions to BaseBlock and fix leaky abstraction 2019-06-03 16:24:59 -04:00
bbff898073 Extract air block into variable to reduce unnecessary function calls 2019-06-03 16:24:59 -04:00
19f8704cb4 Remove leftovers from getting rid of PlotBlocks in LocalChunk 2019-06-03 16:24:59 -04:00
b366b0d261 Set unspecified blocks from the schematic to air
If this isn't done, any blocks not specified in the schematic will remain after a clear, which is obviously undesirable.
2019-06-03 16:24:59 -04:00
941821e453 Convert all PlotBlocks to BaseBlocks in the BasicLocalBlockQueue
The `BukkitLocalQueue` only supports using one of the sets (the removed `baseBlocks` variable in `BasicLocalBlockQueue` was the deciding factor for which one won out) which led to issues with missing blocks when trying to use both types at the same time, such as in the `HybridPlotManager`s `clearPlot` method, where `PlotBlock` is used to fill in the various layers, while the`createSchemAbs` method uses `BaseBlock` for its data.
2019-06-03 16:24:59 -04:00
427523644c Removed unused imports 2019-05-31 12:04:38 -04:00
475e9b50e1 Fixes #2380 2019-05-31 12:00:44 -04:00
812d41092e Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-05-31 11:57:18 -04:00
41299e6851 Fix issue with plot border during merge
* `getExtendedTopAbs()` used wrong relative plot for calculating X position.
* Not running `finishPlotMerge()` after every merge led to broken roads during a `merge all`
2019-05-29 23:28:16 -04:00
95cb0d84f0 Fix issue with road generation during unlink
Roads should always be created with respect to `current`.
2019-05-29 23:28:16 -04:00
fb478de164 Update outdated list of files to check on failed world load (#2365) 2019-05-22 12:09:31 -04:00
1bd7c8ca5f Variable renames 2019-05-21 18:50:52 -04:00
fe471c3571 new library in gradle and another change I can't remember. 2019-05-21 18:32:26 -04:00
8ff833de36 Added Paper to Platform 2019-05-17 18:50:24 -04:00
5dd2610b5e Misc. changes and removal of title manager 2019-05-17 18:49:09 -04:00
4e3a927323 Modifications to the generator code 2019-05-17 16:21:03 -04:00
595a68ecba variable renames 2019-05-17 15:32:05 -04:00
6f5cb30734 Minor message changes and variable changes 2019-05-17 14:38:57 -04:00
427504fd7c Commented out Multiverse-Core and Bump to 1.14.1 2019-05-17 14:26:47 -04:00
b66734a472 Misc. code changes
A lot of renaming
Some formatting
Narrowed scope of variables
Added annotations
2019-05-13 21:57:41 -04:00
84911c1a8c Remove unused title classes 2019-05-13 18:22:17 -04:00
adefe2eeef Titles can be used on Spigot and Paper now 2019-05-13 18:20:58 -04:00
549a4df834 Merge remote-tracking branch 'origin/breaking' into breaking 2019-05-13 15:56:41 -04:00
4daf1c7721 Fixes #2355 2019-05-13 15:56:28 -04:00
728082723c Revert "Don't force metrics. Forcing metrics is against the precedent for all major Spigot plugins"
This reverts commit 4522d98934.
2019-05-12 12:53:25 +01:00
4522d98934 Don't force metrics. Forcing metrics is against the precedent for all major Spigot plugins 2019-05-11 14:31:13 +01:00
0d67c174aa Fix compatibility with 1.13 and 1.14 2019-05-10 23:00:11 -04:00
a841b4ea86 Titles are now exclusive to paper servers 2019-05-10 22:42:07 -04:00
f232334bcc Various formatting tweaks as well as metrics changes. 2019-05-10 21:18:28 -04:00
d8ac6115c7 I never thought it would come to this 2019-05-10 17:16:48 -04:00
885d1b9d7e Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-05-05 16:56:14 +01:00
f6e492638d Bad temporary fix for #2345 - just don't use BukkitLocalQueue#regenChunkSafe and that on 1.14 :) (: 2019-05-05 16:56:00 +01:00
46beb90112 Correcter versioning 2019-05-05 11:58:45 +01:00
0a6fad73c3 Correct versioning 2019-05-05 11:56:08 +01:00
5796db51a7 Update links 2019-05-02 20:51:52 +02:00
2998f45b27 Update JavaDoc link 2019-05-02 16:14:53 +01:00
e156d58769 Generate javadoc with aggregatedJavadocs option 2019-05-02 15:54:14 +01:00
eb9d98d289 Use https://www.athion.net/ISPaster/paste 2019-05-01 19:52:26 +01:00
2ec13e4e76 Replace code with hasFlag() where appropriate. 2019-05-01 12:31:50 -04:00
f72d39ed85 Fixes #1318 2019-05-01 12:11:35 -04:00
72291b09f2 Fix the actual issue and remove whatever junk from the previous commit 2019-04-30 15:11:43 -04:00
ac5cdfae64 Fix for ItemFrames 2019-04-30 14:44:33 -04:00
db6115eae5 Documentation and formatting changes 2019-04-29 15:20:52 -04:00
9e324762b6 Move the update utility setup to it's own method 2019-04-29 15:18:38 -04:00
299fac95fb Add a stupidity fail-safe. 2019-04-29 11:02:47 -04:00
906c1081fa Merge remote-tracking branch 'origin/breaking' into breaking 2019-04-29 10:50:10 -04:00
237b10a2a2 Tidying up the code 2019-04-29 10:49:58 -04:00
b7909cc6e5 Fix typo 2019-04-27 16:16:13 +02:00
dca8594542 Update ISSUE_TEMPLATE.md 2019-04-25 13:06:26 -04:00
0b7e63bafb Added new 1.14 blocks 2019-04-24 22:04:30 -04:00
9f792fa54b Fixes #2328
I hope this doesn't cause more issues than it solves
2019-04-24 21:23:57 -04:00
d0be0780fd Reformatting and cleaning. 2019-04-24 16:11:24 -04:00
bef3dbc6f4 Reformat code 2019-04-23 23:48:22 +01:00
d352804b5d Update gradle lombok version for core 2019-04-23 23:47:00 +01:00
9485f82ea9 Fix signs between 1.13 and 1.14 2019-04-23 23:46:10 +01:00
c7ba94f959 Fix legacy material loading error and Jenkins4J dependencies 2019-04-23 23:03:52 +01:00
5ac00c4920 downgrade Jenkins4J 2019-04-23 22:41:06 +01:00
bd1217810f Should fix the sign issue 2019-04-23 22:30:31 +01:00
1e97392244 Update to gradle 5.4 2019-04-23 22:27:32 +01:00
9b3ca4468c Temporary fix for a working 1.14 build 2019-04-23 14:41:20 -04:00
b2b2f3cd05 attempt to fix signs 2019-04-23 14:24:55 -04:00
bae3774eb6 Merge remote-tracking branch 'origin/breaking' into breaking 2019-04-23 13:45:35 -04:00
1118901ca2 Initial 1.14 Update 2019-04-23 13:45:24 -04:00
0c0a696d36 Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-04-23 12:57:46 +10:00
21a5b04b7b remove debug 2019-04-23 12:57:39 +10:00
6fa41efbf5 Merge remote-tracking branch 'origin/breaking' into breaking 2019-04-22 11:55:11 -04:00
ef8d33db41 Minor command changes
Changed RequiredType in some classes and formatting changed in others.
2019-04-22 11:55:05 -04:00
1abe444205 Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-04-23 01:53:35 +10:00
145af1e091 fix workaround 2019-04-23 01:53:24 +10:00
f5fa15080c Minor javadoc updates 2019-04-22 11:45:23 -04:00
0c0d0104d7 Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-04-23 01:06:52 +10:00
406dd22703 Workaround for effective permission check 2019-04-23 01:06:41 +10:00
bb44c2ea92 parsable build number 2019-04-20 16:26:31 +01:00
ea26ec628d Use Settings.Teleport.ON_LOGIN 2019-04-19 13:02:50 +10:00
815e513093 Fix teleportOnLogin error 2019-04-19 12:53:48 +10:00
8ac23b92d8 Use UUID, not just name 2019-04-17 22:18:03 +10:00
d31dbc7c7c Fix debugimportworlds 1.13
because someone changed PlotId.fromString to throw an exception without updating things that call it
2019-04-17 22:07:33 +10:00
000e3de35d Don't allow importing using base directory 2019-04-17 14:36:31 +10:00
7e63ffe745 Optimize vanilla world generation*
*For single plot worlds

Reuse base world data. Instead of taking several seconds, it should now take tens of milliseconds.
2019-04-17 14:30:05 +10:00
27eda9eb7c Don't setup single plot worlds 2019-04-17 14:00:01 +10:00
0fdc5eafbd Allow single plot areas to load survival worlds 2019-04-17 13:46:33 +10:00
59f89980a3 Don't need ratio out of 100 anymore 2019-04-17 13:13:56 +10:00
50acf4f51f Print exception on failed schematic setup 2019-04-13 13:06:21 +10:00
04779d28fb Don't fail on metrics error 2019-04-13 12:26:19 +10:00
1e78368115 Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-04-13 12:23:24 +10:00
0c46df65e6 Not sure why that last commit was a thing locally 2019-04-12 17:42:35 +01:00
4c788cb51e Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-04-12 17:40:16 +01:00
1c915905c6 Fixes #2275 2019-04-11 23:27:47 -04:00
9f3e3c83e0 Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-04-12 12:11:16 +10:00
6916752434 Fixes #2322 2019-04-12 12:11:03 +10:00
b0b328e50b Update offset to match CI 2019-04-11 12:43:16 +01:00
6cea26f436 Add random collection 2019-04-10 17:10:44 +10:00
533edc5f40 Change default threshold to -1 2019-04-10 17:10:17 +10:00
97903f3870 Fix you are not in a plot area for single plot worlds 2019-04-10 11:34:21 +10:00
d571f54c65 Update offset to match ci 2019-04-09 15:48:25 +01:00
e0bd8e3f9d Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-04-09 00:29:30 +10:00
9225a13808 sorry for breaking roads 2019-04-09 00:29:13 +10:00
3f712ed5f0 should check both end/nether 2019-04-08 18:03:38 +10:00
259fe94f83 Potential fix to skip chunks being kept loaded 2019-04-08 01:43:38 +10:00
3651b3ac8d I don't know about coffee, but how about Java? @sauilitired 2019-04-06 23:14:39 +11:00
b32b8a98e2 Fixes #1936 2019-04-06 17:19:48 +11:00
5d515b3863 This shouldn't have been made private 2019-04-06 12:55:45 +11:00
a3cb4e5ffb Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-04-06 03:54:42 +11:00
676ef0159a only change plotY if height not 256 2019-04-06 03:54:27 +11:00
34d11bf23d Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-04-05 17:39:33 +01:00
0c00eb2061 Add clean task back properly 2019-04-05 17:39:16 +01:00
3e3951a3e7 *negate 2019-04-06 02:07:39 +11:00
c71fe00741 Missed this as well 2019-04-06 02:07:14 +11:00
69a029a555 Fix plot schematic y 2019-04-06 01:54:02 +11:00
3f194f90ce Unbreakify things 2019-04-04 18:31:47 +02:00
7e401a83cf Make PlotLoc's immutable 2019-04-04 18:26:10 +02:00
69b05932eb Update to gradle 5. gradlew clean assemble build actually WORKS 2019-04-03 17:15:09 +01:00
ac2d43db68 Update offset to match CI 2019-04-03 14:41:54 +01:00
b5418e4dce Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-04-04 00:20:13 +11:00
6b422582a6 Load WorldEdit onEnable
as otherwise it doesn't work
2019-04-04 00:19:59 +11:00
f5388b9737 Merge remote-tracking branch 'origin/breaking' into breaking 2019-04-01 17:40:10 +02:00
6323fb0041 Add plot like/dislikes 2019-04-01 17:39:28 +02:00
b1835f0998 whoops, wrong schematic 2019-04-01 21:45:55 +11:00
1c9c0d0207 Schematic fixes
The 1.13 schematic format uses the `.schem` extension, use that instead
Support loading both legacy `.schematic` and `.schem` files for road
schematics
Fix reading road schematics with an offset
2019-04-01 21:39:10 +11:00
0f8b7cd588 fixes #2211 2019-04-01 11:14:47 +02:00
c450e4aed3 Fix interval flags (fixes #2302) 2019-04-01 10:17:50 +02:00
14badf8cfc remove rogue debug message 2019-04-01 09:43:29 +02:00
df3e78ee40 Make the "Display all commands" message configurable too 2019-04-01 09:04:19 +02:00
11689bf855 Configurable help categories 2019-04-01 09:00:08 +02:00
4152582ae0 Fix UUID related NPE 2019-04-01 08:35:06 +02:00
3be7511b7c Fix genChunk setCuboid 2019-04-01 05:01:32 +11:00
f3adeeac0e Fix single plot area NPEs & generator stackoverflow 2019-04-01 04:44:18 +11:00
67cf1b45ed Fix another legacy converter NPE 2019-04-01 04:43:44 +11:00
e396da8ee5 fix converter NPE 2019-04-01 03:19:53 +11:00
04b9b67c9d Fixes #2288 2019-03-31 18:31:16 +11:00
45360f0979 Make sure /plot home ignores server owned plots 2019-03-30 13:32:45 +01:00
ae57264487 Add server-plot flag, and option to disable on-claim teleportation 2019-03-30 13:27:18 +01:00
08ebf57c90 Add hide-info flag 2019-03-30 12:50:32 +01:00
d9407d6329 Merge pull request #2312 from IntellectualSites/async-gen
Add support for Paper async chunk generation
2019-03-29 19:31:02 +01:00
c6ae2456f2 Add support for Paper async chunk generation 2019-03-26 09:27:20 +01:00
c9f38430c6 Clean and fix up the fromAny method in Legacy Mappings
it never checked for an id data pair or singular id (5, 5:2 etc) which is sort of the whole point. Fixes #2296
2019-03-20 17:17:45 +00:00
3a761b3b5f Update offset to match CI 2019-03-20 12:20:09 +00:00
c48116b723 Merge remote-tracking branch 'origin/breaking' into breaking 2019-03-18 19:49:31 +01:00
0b77b863ba Update notifications. 2019-03-18 19:49:22 +01:00
832d60ce87 Update README.md 2019-03-17 12:34:33 +01:00
f863dfee42 Update README.md 2019-03-17 12:32:09 +01:00
c44d180352 Update README.md 2019-03-17 12:31:23 +01:00
a17cb735b7 Update README.md 2019-03-17 12:30:14 +01:00
806124b047 Merge remote-tracking branch 'origin/breaking' into breaking 2019-03-15 13:40:04 -04:00
61cb288382 oops sorry.
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-03-15 13:39:51 -04:00
3956adf291 Update ISSUE_TEMPLATE.md
Added a warning about future legacy version support.
2019-03-15 01:00:55 -04:00
672fb0f829 Merge remote-tracking branch 'origin/breaking' into breaking 2019-03-14 21:49:52 -04:00
7f14e88c4c last commit before 4.0.0
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-03-14 21:49:33 -04:00
e146b6a88d Update offset to match CI 2019-03-13 13:21:09 +00:00
cf1764723f Fixes #2291
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-03-12 16:56:51 -04:00
7b788c07b8 Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-03-09 00:05:49 -05:00
dffbaf89a3 Fix for offhandedness 2019-03-09 00:28:21 +00:00
578069b3c9 Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-03-08 19:26:06 -05:00
ed3cadd439 Formatting fixes and minor performance improvement
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-03-08 19:25:59 -05:00
aa894b8ad9 Fixes #2245
Also some minor fixes to PlayerInteractEvent main/off hand logic
2019-03-09 00:12:21 +00:00
ed10877431 Should fix IndexOutOfBoundsException when copying
fixes#2290
2019-03-08 23:04:38 +00:00
1d327ec346 Fixes an issue with boats
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-03-07 18:38:21 -05:00
56c24a6a56 Type weakening and Direction changes
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-03-06 12:47:38 -05:00
4c8457ad14 OCD
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-02-22 11:54:13 -05:00
f93cfb9f8b Update build offset 2019-02-22 16:53:11 +00:00
1755272f81 Merge remote-tracking branch 'origin/breaking' into breaking 2019-02-22 11:51:22 -05:00
25530ed7f0 Doc Updates, Renaming, Reformatting, and a Test
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-02-22 11:51:06 -05:00
53e732b4fe Make replacing wall on merge configurable
In case people are doing fun things with road schematics etc :)
2019-02-22 15:21:44 +00:00
7aebd9b74b Set wall filling on merge 2019-02-22 15:11:35 +00:00
be51d8e159 Correct artifact id for maven 2019-02-22 14:38:18 +00:00
bfc6b62213 Stupid docs
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-02-21 21:31:12 -05:00
a9bebb10da Merge remote-tracking branch 'origin/breaking' into breaking
# Conflicts:
#	Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/WEExtent.java
2019-02-21 21:18:03 -05:00
2f18ef6828 Critical bug fixes, reformatting, and cleaning
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-02-21 21:14:48 -05:00
f2d68642f9 Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-02-20 14:51:01 +00:00
350e151214 Don't use streams as they're lower performance for our use cases.
Some minor reformating too.
2019-02-20 14:50:49 +00:00
72b031e3e5 Update offset to match CI 2019-02-20 11:59:39 +00:00
d0a4465985 Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-02-20 11:55:50 +00:00
0ef8b4ad14 Update to WorldEdit's *breaking* Biome handling changes 2019-02-20 11:55:39 +00:00
c5d9412c6c Cleaning and API Addition
Begins the process of removing "magic values" for directions in the plugin.

Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-02-19 22:57:35 -05:00
92718a5ec8 Merge branch 'consumers' into breaking 2019-02-19 22:29:59 -05:00
099a807ce0 CLeaning of code
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-02-19 22:29:27 -05:00
df47697ca6 CLeaning of code
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-02-19 19:00:37 -05:00
b7aeeb151d Replace RunnableVal with java Consumer
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-02-19 18:39:43 -05:00
2e22dfe056 Update offset to match CI 2019-02-16 22:06:31 +00:00
a64d764cc1 New API method, more 1.13 entity support, and cleanup.
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-02-15 12:50:43 -05:00
4f27abb4a0 Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-02-14 17:39:01 +00:00
b999cb4195 Fix players being able to place boats, armorstands etc using offhand 2019-02-14 17:38:36 +00:00
745fd58e2e * 2019-02-13 21:54:13 +00:00
57981a870e Update version offset to match ci 2019-02-13 21:53:11 +00:00
130e1b6300 Fix armorstands, boats etc being placeable on players plots with "use 0" flag 2019-02-13 21:47:54 +00:00
477e698f7e Reformat 2019-02-13 17:13:57 +00:00
11c4a90cc9 Merge remote-tracking branch 'origin/breaking' into breaking 2019-02-13 12:05:42 -05:00
35493662da Cleanup
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-02-13 12:05:28 -05:00
8710f2f83b Fix NPE when right-clicking a >1.13 block 2019-02-13 13:43:22 +00:00
3e8308ecd7 Catch statement already being null 2019-02-13 13:35:19 +00:00
dae7bbdf9d Fix dropped items being removed from plots 2019-02-13 13:26:19 +00:00
d0994f1b4b Fixes to EntityTask 2019-02-10 23:03:14 +00:00
cae95343ca Update build offset 2019-02-10 22:51:21 +00:00
17027e6292 Javadoc changes and cleaning of old unused code
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-02-08 14:49:37 -05:00
e891873d28 Cleaning and scope changes
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-02-08 11:21:53 -05:00
b39ea1b68b Cleaning and API clarifications
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-02-06 21:29:51 -05:00
3d8179a4e6 Small tweaks
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-02-06 17:30:25 -05:00
9101cb9218 PlotComment API tweaks.
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-02-06 12:33:14 -05:00
6ec6c26a10 Guava needs to be in sync with Minecraft
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-02-06 12:02:20 -05:00
d6a801d854 Reformat 2019-02-06 16:42:27 +00:00
6711788dd0 Fix ClassCastException in runEntityTask 2019-02-06 16:38:01 +00:00
e41060ad65 And again
Because the ci built, but using a specific commit (to split Matt's previous commits into separate builds)
2019-02-06 14:12:50 +00:00
7e7f14a66b Update build ci offset 2019-02-06 14:10:34 +00:00
0c780166e0 Documentation and PlotId updates
minor code tweaks in the plot class too

Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-02-06 00:10:05 -05:00
87547834ef Minor changes to variable names and castings
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-02-05 23:12:01 -05:00
ccc53278a1 Fix the world border issue
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-02-05 20:36:42 -05:00
9a23b718f3 Cleanup of various methods
mainly just more lambda's

Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-02-05 19:41:03 -05:00
e3d43509cf Cleanup of some database methods
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-02-04 18:00:05 -05:00
dfbcecb081 Removes Cluster Flags
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-02-04 12:46:27 -05:00
cf82bc5efb Revert 8ac9b86 2019-02-04 15:18:50 +00:00
14e1296e13 Only thing I can think of in 8ac9b86that would be causing the lack of plot owners (before reverting the commit) 2019-02-04 14:24:17 +00:00
6d6087b1e3 And don't add the Core/ code into Bukkit/ code 2019-02-04 14:02:21 +00:00
51afbdfcdc Apply correct codestyle 2019-02-04 13:59:11 +00:00
9c90928d07 Remove the debug and don't created a new BloxkBucket for every air block. 2019-02-02 16:13:55 +00:00
8ac9b862f8 Major cleanup.
Added todo comments to many 1.13 issues still lingering. Changed access to some methods to be weaker. Removed cluster flags (most of it). Java 8 stuff added. Hid more PlotSetting methods. etc.

Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-01-31 14:20:48 -05:00
cd8a1a0816 Fixed some translation mismatches 2019-01-27 00:48:03 +01:00
a4c3fb26c7 Check for road or unowned plot 2019-01-23 14:02:18 +00:00
fd4a5f2aaa Fix item despawning on plots 2019-01-23 13:34:23 +00:00
25ed9d2798 Fix road schematic pasting height 2019-01-23 12:23:05 +00:00
c96a1afaed Don't fuck up road schematics, I guess 2019-01-22 21:32:24 +01:00
344a2afeff Use StringBuilder, like a sane person 2019-01-22 19:54:31 +01:00
e54f964eca Fix #2009 2019-01-22 18:51:13 +01:00
8733dc6dab Fix deny-teleport flag: Fixes #2128 2019-01-22 10:43:29 +01:00
7e56e47046 Fix block list flag permissions 2019-01-21 17:49:36 +01:00
7edfc313d6 I did an oopsie 2019-01-21 12:24:34 +01:00
d37f5b9aa8 Fix schematic pasting offsets 2019-01-21 09:53:04 +01:00
1fbfc767c4 Use PaperLib and make command task return completable futures 2019-01-21 09:20:33 +01:00
bd797b59fe Allow disabling of scientific notation (disabled by default) for DoubleFlags 2019-01-20 15:56:49 +00:00
0609b3d7f6 Safer generation of the BlockBucketChunk 2019-01-19 16:28:49 +00:00
ca883c211a Add merge permission changes from master 2019-01-18 19:02:12 +00:00
330ab83ece possible NPE fix and add useful debug if it fails 2019-01-17 22:34:28 +00:00
d846bc7a2e Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2019-01-17 16:28:55 +00:00
db2e245b13 alphabetise PlayerEvents stuff and add Turtle Eggs 2019-01-17 16:28:42 +00:00
4e79a3aa16 Fix broken group ID 2019-01-17 15:31:18 +01:00
ea422b5561 Fix NPE on world initialise 2019-01-17 13:19:24 +00:00
f366f5e406 Remove needless generateExtBlockSections method that just reduced performance for no reason 2019-01-17 01:06:32 +00:00
223064567f Plot analysis (#2239)
* Start to fix (and may have fixed) plot analysis with block buxkets and 1.13

* Standard deviation ought also be multiplied by 100, and only obtain the BlockBucket array once

* Add schematics to Plot Analysis
Add generateBlockBucketChunk method to SingleWorldGenerator
2019-01-17 01:04:00 +00:00
0817d7de5a Removed PlotMe converting features.
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
2019-01-15 22:19:29 -05:00
0e0a534620 Fix regenallroads extend (height) 2019-01-16 01:55:45 +00:00
61f8ceaaaa I'm an idiot and left one of my debug messages in 2019-01-16 01:28:07 +00:00
7e6b11a21b Fix plot swap and have a nicer static AIR block 2019-01-15 23:58:21 +00:00
28c219c694 /plot leave has a terrible description 2019-01-15 16:20:50 +00:00
f679d3f873 Debug not debug 2019-01-14 18:27:20 +00:00
232b7ccfc1 Don't allow debugroadregen on merged plots 2019-01-14 18:15:44 +00:00
44fc8a55ea Add "kick" meta check in PlotListener 2019-01-14 17:41:28 +00:00
b2d035cf69 Fix deny-exit flag causing plot kick to break 2019-01-14 17:31:22 +00:00
d81d3c72e4 Update scripts and code to work nicely with each other.
Fixes #2208
2019-01-12 19:56:11 +00:00
f62777bc1a Minor:
Fix BukkitLegacyMappings method map usage
Move obtaining legacy block to default clause
Task should be async
2019-01-12 18:05:20 +00:00
8ba661aa35 Fixed plot owner UUIDs getting unnecessarily randomized. (#2233) 2019-01-12 17:48:53 +00:00
15ea0f3210 Fix BukkitLegacyMappings having maps the wrong way round & fix PlotBlockListFlag to use PlotBlocks.
Fixes #2229
2019-01-12 17:39:29 +00:00
0d76e46fa2 Fix requiring restart for /ps load after /ps save & make descriptions nicer 2019-01-11 12:50:38 +00:00
daf3e3dde5 Merge pull request #2230 from N0tMyFaultOG/breaking
Cleanup - Removing bo3
2019-01-10 22:33:20 +01:00
222585bf01 Update C.java 2019-01-10 22:21:34 +01:00
63af0de9f0 Update Settings.java 2019-01-10 22:20:30 +01:00
5df6f2a13e Update Download.java 2019-01-10 22:18:28 +01:00
c5f1c60ad7 Delete base.yml 2019-01-10 22:16:22 +01:00
3ac7785cc3 Skip empty files in DebugPaste 2019-01-10 21:34:52 +01:00
3bbd97e7e1 Fix PlotDeleteEvent and PlotMergeEvent not being called.
Replaced current PlotMergeEvent with PlotAutoMergeEvent (called when a plot is merged on /plot auto). And made PlotMergeEvent be called for /plot merge command.
2019-01-10 17:10:25 +00:00
e47b4fef20 Remove update and changelog commands 2019-01-10 17:45:40 +01:00
7302480728 Merge branch 'optional' into breaking 2019-01-09 20:01:32 -05:00
457c520eb6 Fixing debugpaste description 2019-01-09 23:40:08 +01:00
053edb823d Use Incendo pasting instead of Hastebin 2019-01-09 23:12:36 +01:00
727d120e70 Regenallroads:
- remove the "estimated time" as it's just not remotely correct, nor would it be correct if it were based on actual chunk number
 - fix the air to be pasted above the road when using regenallroads
2019-01-09 16:15:34 +00:00
ea01a5171b Add missing admin unlink permission 2019-01-03 22:36:09 +00:00
77ddeabca2 Fix NPE with plot version (update to new versioning within code)
Also add date and commit to plugin.properties file.
2019-01-03 17:32:21 +00:00
e12a7bb85f Migrated remaining Optionals 2019-01-02 23:15:42 -05:00
c7b9bfeb4b Migrate from Guava Optionals to Java Optionals 2019-01-02 23:11:26 -05:00
ae9e52f093 Don't dump g_sch 2019-01-02 13:18:20 +00:00
00a5d5ff64 Nicer versioning and match CI build number 2019-01-02 13:01:37 +00:00
29868bdd29 Fix road generation for roads of even width 2019-01-01 14:43:41 +00:00
38a382f8e5 Add missing argument to unlink 2019-01-01 00:55:25 +01:00
f8ce00c2df Also cancel picking water/lava up with a bucket. 2018-12-31 18:03:59 +00:00
6a9038c306 Fix #2205 2018-12-31 17:57:17 +00:00
7bcc4c4ce3 Fix plot move/swap block rotation issue (switch to BaseBlock). Also fix container inventory pasting.
Some cleanup.
Fixes #2209
2018-12-31 17:15:47 +00:00
8c52e20736 Use BaseBlocks in regenallroads and minor cleanup of HybridUtils.
Fixes #2210
2018-12-31 16:08:09 +00:00
3156741664 Fix plot redstone disabling (not sure why it was the way it was, but it was never going to work, so I fixed? it)
also minor reformat to PlayerEvents
2018-12-28 17:25:29 +00:00
750be6c5fe clean merge up 2018-12-28 17:03:00 +00:00
6292bff7c9 Fix rotation (#2200)
* Fix rotation

* Clean up some events and utility classes. Try to use as general type
declarations as possible. Add configurable override for the unsafe block checker.

* Treat tridents as a projectile

* Fix rotation and merged with current breaking branch
2018-12-28 09:42:03 +00:00
f25581c3f1 Treat tridents as a projectile 2018-12-28 08:14:47 +01:00
12b8ae3eed Clean up some events and utility classes. Try to use as general type
declarations as possible. Add configurable override for the unsafe block checker.
2018-12-28 07:39:39 +01:00
660754511b Fix rotation of road schematics 2018-12-28 00:47:48 +00:00
2846363a2c Revert "Use our own schematic readers in only create one input stream, and allow for future customisation of schematics if required/wanted."
This reverts commit 3521b8aa22.
2018-12-27 20:06:02 +00:00
3521b8aa22 Use our own schematic readers in only create one input stream, and allow for future customisation of schematics if required/wanted. 2018-12-27 19:42:56 +00:00
249b5d4068 Revert dors commit 2018-12-27 17:29:35 +01:00
76113cb0ab Allow specifying Y value for default plot home 2018-12-27 16:18:54 +01:00
a529518b91 Minor changes, formatting, comments.
One notable thing added was the inclusion of more of the new mobs in one of the events.
2018-12-27 00:46:32 -05:00
75bcd1adec Update StringMan.java 2018-12-27 01:31:48 +01:00
fba7eac6d8 Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking 2018-12-26 21:18:38 +00:00
6e127db982 Cleanup 2018-12-26 21:18:22 +00:00
927 changed files with 61282 additions and 55578 deletions

1
.github/CODEOWNERS vendored Normal file
View File

@ -0,0 +1 @@
* @IntellectualSites/plotsquared-team

View File

@ -1,2 +0,0 @@
### Bugs
Please provide a `/plot debugpaste` if you are reporting a bug.

12
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1,12 @@
# These are supported funding model platforms
github: [NotMyFault, dordsor21, SirYwell]
patreon: IntellectualSites # Replace with a single Patreon username
open_collective: IntellectualSites
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: https://www.paypal.me/AlexanderBrandes # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

View File

@ -1,22 +0,0 @@
# Bug report template
<!--- In order to create a valid issue report you have to follow this template. -->
<!--- Incomplete reports might be marked as invalid. -->
<!-- Feature requests and enhancements may be suggested at https://github.com/IntellectualSites/PlotSquaredSuggestions. -->
**Debug paste link:**
<!--- Enter /plot debugpaste in game or in your console and copy the output here -->
**Description of the problem:**
**How to replicate:**
<!--- If you can reproduce the issue please tell us as detailed as possible step by step how to do that -->
**Checklist**:
<!-- Make sure you have completed the following steps (put an "X" between of brackets): -->
- [] I included a `/plot debugpaste` link
- [] I made sure there are no duplicates of this report [(Use Search)](https://github.com/IntellectualSites/PlotSquared/issues?utf8=%E2%9C%93&q=is%3Aissue)
- [] I made sure I am using an up-to-date version of PlotSquared
- [] I Made sure the bug/error is not caused by any other plugin

102
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View File

@ -0,0 +1,102 @@
name: Bug report
description: Create a report to help us improve
labels: 'Requires Testing'
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report for PlotSquared! Fill out the following form to your best ability to help us fix the problem.
Only use this if you're absolutely sure that you found a bug and can reproduce it. For anything else, use: [our Discord server](https://discord.gg/intellectualsites) or [the wiki](https://github.com/IntellectualSites/PlotSquared/wiki).
- type: dropdown
attributes:
label: Server Implementation
description: Which server Implementation are you using? If your server implementation is not listed, it is not supported. Switch to a supported version first.
multiple: false
options:
- Paper
- Spigot
- Tuinity
- Purpur
validations:
required: true
- type: dropdown
attributes:
label: Server Version
description: Which server version version you using? If your server version is not listed, it is not supported. Update to a supported version first.
multiple: false
options:
- '1.16.5'
- '1.15.2'
- '1.14.4'
- '1.13.2'
validations:
required: true
- type: textarea
attributes:
label: Describe the bug
description: A clear and concise description of what the bug is.
validations:
required: true
- type: textarea
attributes:
label: To Reproduce
description: Steps to reproduce this behaviour
placeholder: |
1. Go to '...'
2. Click on '...'
3. Scroll down to '...'
4. See error
validations:
required: true
- type: textarea
attributes:
label: Expected behaviour
description: A clear and concise description of what you expected to happen.
validations:
required: true
- type: textarea
attributes:
label: Screenshots / Videos
description: If applicable, add screenshots to help explain your problem.
- type: input
attributes:
label: Error log (if applicable)
description: If you are reporting a console error, upload any relevant log excerpts to either https://paste.gg/ or https://gist.github.com, save and the paste the link in this box.
- type: input
attributes:
label: Plot Debugpaste
description: Run `/plot debugpaste` in your console or ingame and provide the output link here.
validations:
required: true
- type: input
attributes:
label: PlotSquared Version
description: What version of PlotSquared are you running? (`/version PlotSquared`)
placeholder: "For example: PlotSquared version 5.13.11-Premium"
validations:
required: true
- type: checkboxes
attributes:
label: Checklist
description: Make sure you have followed each of the steps outlined here.
options:
- label: I have included a Plot debugpaste.
required: true
- label: I am using the newest build from https://www.spigotmc.org/resources/77506/ and the issue still persists.
required: true
- type: textarea
attributes:
label: Anything else?
description: You can provide additional context below.

8
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: IntellectualSites Discord
url: https://discord.gg/intellectualsites
about: Our support Discord, please ask questions and seek support here.
- name: PlotSquared Wiki
url: https://github.com/IntellectualSites/PlotSquared/wiki
about: Take a look at the wiki page for instructions how to setup PlotSquared and use its commands.

View File

@ -0,0 +1,29 @@
name: Feature request
description: Suggest an idea for this project
labels: 'Enhancement'
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this feature request for PlotSquared! Fill out the following form to your best ability to help us understand your feature request and greately improve the change of it getting added.
For anything else than a feature request, use: [our Discord server](https://discord.gg/intellectualsites) or [the wiki](https://github.com/IntellectualSites/PlotSquared/wiki).
- type: textarea
attributes:
label: What feature do you want to see added?
description: A clear and concise description of your feature request.
validations:
required: true
- type: textarea
attributes:
label: Are there any alternatives?
description: List any alternatives you might have tried
validations:
required: true
- type: textarea
attributes:
label: Anything else?
description: You can provide additional context below.

17
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,17 @@
## Overview
<!-- Please describe which issue this Pull Request targets
If there is no issue, please create one so we can look into it before approving your PR.
You can do so here: https://github.com/IntellectualSites/PlotSquared/issues
-->
**Fixes {Link to issue}**
## Description
## Checklist
<!-- Make sure you have completed the following steps (put an "X" between of brackets): -->
- [] I included all information required in the sections above
- [] I tested my changes and approved their functionality
- [] I ensured my changes do not break other parts of the code
- [] I read and followed the [contribution guidelines](https://github.com/IntellectualSites/PlotSquared/blob/v5/CONTRIBUTING.md)

View File

@ -1,15 +0,0 @@
# Comment to a new issue.
issueOpened: >
Thank your for raising a issue. We will try and get back to you as soon as possible.
Please make sure that you followed the issue template, and provied all neccessary information.
Failure to do so will prevent us from resolving the issue in a timely manner.
Please note that suggestions are now to be submitted to https://git.io/fN5B4 rather than this issue tracker!
pullRequestOpened: >
Thank your for raising your pull request.
Please make sure you have followed our contributing guidelines and to take an extra look at the code to make sure that it is functional!
We will review it as soon as possible!

24
.github/stale.yml vendored
View File

@ -1,16 +1,18 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 60 daysUntilStale: 60
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7 daysUntilClose: 7
# Issues with these labels will never be considered stale only: issues
exemptLabels: exemptLabels:
- [‼] high priority - "Bug"
# Label to use when marking an issue as stale - "Enhancement"
staleLabel: Old - "Approved"
# Comment to post when marking an issue as stale. Set to `false` to disable - "Priority"
- "Under investigation"
staleLabel: "resolution: stale"
markComment: > markComment: >
This issue has been automatically marked as stale because it has not had This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you recent activity. It will be closed if no further activity occurs. If the issue is still present and can be reproduced, please let the team know.
for your contributions. Thank you for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable closeComment: >
closeComment: false This issue has been automatically closed because it has not had activity in
a long time. If the issue still applies to the most recent supported
version, please reply to this issue and the team will reopen it.

20
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,20 @@
name: "build"
on: ["pull_request", "push"]
jobs:
build:
strategy:
matrix:
java: ["1.8", "11"]
os: ["ubuntu-18.04"]
runs-on: "${{ matrix.os }}"
steps:
- name: "Checkout Repository"
uses: "actions/checkout@v2.3.4"
- name: "Setup JDK ${{ matrix.java }}"
uses: "actions/setup-java@v1.4.3"
with:
java-version: "${{ matrix.java }}"
- name: "Clean Build"
run: "./gradlew clean build"

View File

@ -0,0 +1,12 @@
name: "validate gradle wrapper"
on: ["pull_request", "push"]
jobs:
build:
runs-on: "ubuntu-18.04"
steps:
- name: "Checkout Repository"
uses: "actions/checkout@v2.3.4"
- name: "Validate Gradle Wrapper"
uses: "gradle/wrapper-validation-action@v1.0.3"

287
.gitignore vendored
View File

@ -1,142 +1,145 @@
### Others ### ### Others ###
*.cmd *.cmd
*.sh *.sh
*.prefs *.prefs
Sponge/build Sponge/build
Core/build Core/build
Bukkit/build Bukkit/build
Nukkit/build Nukkit/build
buildSrc/
### Maven ###
/mvn ### Maven ###
/target/lib /mvn
/target/maven-archiver /target/lib
/target/classes /target/maven-archiver
/target/maven-status /target/classes
pom.xml.tag /target/maven-status
pom.xml.releaseBackup pom.xml.tag
pom.xml.versionsBackup pom.xml.releaseBackup
pom.xml.next pom.xml.versionsBackup
release.properties pom.xml.next
dependency-reduced-pom.xml release.properties
buildNumber.properties dependency-reduced-pom.xml
.mvn/timing.properties buildNumber.properties
out/ .mvn/timing.properties
out/
### Java ###
*.class ### Java ###
*.class
# Mobile Tools for Java (J2ME)
.mtj.tmp/ # Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.war # Package Files #
*.ear *.war
*.ear
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid* # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm ### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
*.iml
*.iml
## Directory-based project format:
.idea/ ## Directory-based project format:
# if you remove the above rule, at least ignore the following: .idea/
# if you remove the above rule, at least ignore the following:
# User-specific stuff:
# .idea/workspace.xml # User-specific stuff:
# .idea/tasks.xml # .idea/workspace.xml
# .idea/dictionaries # .idea/tasks.xml
# .idea/shelf # .idea/dictionaries
# .idea/shelf
# Sensitive or high-churn files:
# .idea/dataSources.ids # Sensitive or high-churn files:
# .idea/dataSources.xml # .idea/dataSources.ids
# .idea/sqlDataSources.xml # .idea/dataSources.xml
# .idea/dynamic.xml # .idea/sqlDataSources.xml
# .idea/uiDesigner.xml # .idea/dynamic.xml
# .idea/uiDesigner.xml
# Gradle:
# .idea/gradle.xml # Gradle:
# .idea/libraries # .idea/gradle.xml
.gradle # .idea/libraries
.gradle
# Mongo Explorer plugin:
# .idea/mongoSettings.xml # Mongo Explorer plugin:
# .idea/mongoSettings.xml
## File-based project format:
*.ipr ## File-based project format:
*.iws *.ipr
*.iws
## Plugin-specific files:
## Plugin-specific files:
# IntelliJ
/out/ # IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/ # mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml # JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml # Crashlytics plugin (for Android Studio and IntelliJ)
crashlytics.properties com_crashlytics_export_strings.xml
crashlytics-build.properties crashlytics.properties
fabric.properties crashlytics-build.properties
fabric.properties
### Eclipse ###
*.pydevproject ### Eclipse ###
.metadata *.pydevproject
bin/ .metadata
tmp/ bin/
*.tmp tmp/
*.bak *.tmp
*.swp *.bak
*~.nib *.swp
local.properties *~.nib
.settings/ local.properties
.loadpath .settings/
.loadpath
# Eclipse Core
.project # Eclipse Core
.project
# External tool builders
.externalToolBuilders/ # External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch # Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject # CDT-specific
.cproject
# JDT-specific (Eclipse Java Development Tools)
.classpath # JDT-specific (Eclipse Java Development Tools)
.classpath
# Java annotation processor (APT)
.factorypath # Java annotation processor (APT)
.factorypath
# PDT-specific
.buildpath # PDT-specific
.buildpath
# sbteclipse plugin
.target # sbteclipse plugin
.target
# TeXlipse plugin
.texlipse # TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans # STS (Spring Tool Suite)
/target/ .springBeans
Nukkit/build/classes/ /target/
Nukkit/build/dependency-cache/ Nukkit/build/classes/
checkstyle.xml Nukkit/build/dependency-cache/
classes/ checkstyle.xml
p2error.txt classes/
*.bat p2error.txt
Nukkit/build/resources/main/plugin.yml *.bat
Nukkit/build/resources/main/plugin.yml
docs/
build/

View File

@ -1,46 +1,118 @@
plugins {
id "com.github.johnrengelman.shadow"
}
repositories { repositories {
maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" } maven { url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" }
maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" } maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "http://nexus.hc.to/content/repositories/pub_releases" } maven { url = "https://jitpack.io" }
maven { url = "https://repo.codemc.org/repository/maven-public" } maven { url = "https://repo.codemc.org/repository/maven-public" }
maven { url = "https://repo.extendedclip.com/content/repositories/placeholderapi/" }
maven {
name = "papermc"
url = "https://papermc.io/repo/repository/maven-public/"
}
maven { url = "https://ci.ender.zone/plugin/repository/everything/" }
maven { url = "https://mvn.intellectualsites.com/content/repositories/releases" }
maven { url = "https://mvn.intellectualsites.com/content/repositories/thirdparty"}
maven { url = "https://mvn.intellectualsites.com/content/repositories/snapshots" }
maven { url = "http://repo.mvdw-software.be/content/groups/public/" }
mavenLocal() mavenLocal()
} }
dependencies { dependencies {
compile project(':Core') implementation(project(":PlotSquared-Core"))
testCompile project(':Core') compile("org.bstats:bstats-bukkit:1.7")
compile 'org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT' compile(project(":PlotSquared-Core"))
compile(group: 'com.sk89q.worldedit', name: 'worldedit-bukkit', version: '7.0.0-SNAPSHOT') compile("com.destroystokyo.paper:paper-api:1.16.4-R0.1-SNAPSHOT")
compile(group: 'org.bstats', name: 'bstats-bukkit', version: '1.4') implementation("org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT")
compile("net.milkbowl.vault:VaultAPI:1.7") { compile(group: "com.sk89q.worldedit", name: "worldedit-bukkit", version: "7.2.0") {
exclude module: 'bukkit' exclude(module: "bukkit")
} }
compileOnly 'org.projectlombok:lombok:1.18.4' compile("io.papermc:paperlib:1.0.5")
implementation("net.kyori:text-adapter-bukkit:3.0.3")
compile("com.github.MilkBowl:VaultAPI:1.7") {
exclude(module: "bukkit")
}
implementation("me.clip:placeholderapi:2.10.6")
implementation("net.luckperms:api:5.1")
implementation("net.ess3:EssentialsX:2.18.0") {
exclude(group: "io.papermc", module: "paperlib")
}
compile("se.hyperver.hyperverse:Core:0.6.0-SNAPSHOT"){ transitive = false }
compile('com.sk89q:squirrelid:1.0.0-SNAPSHOT'){ transitive = false }
compile('be.maximvdw:MVdWPlaceholderAPI:3.1.1'){ transitive = false }
implementation("org.incendo.serverlib:ServerLib:2.2.0")
} }
sourceCompatibility = 1.8 sourceCompatibility = 1.8
targetCompatibility = 1.8 targetCompatibility = 1.8
processResources { processResources {
from('src/main/resources') { from("src/main/resources") {
include 'plugin.yml' include("plugin.yml")
expand( expand(
name: project.parent.name, name: project.parent.name,
version: project.parent.version version: project.parent.version
) )
} }
} }
// We only want the shadow jar produced
jar.enabled = false //noinspection GroovyAssignabilityCheck
jar.archiveFileName = "PlotSquared-Bukkit-${project.parent.version}.jar"
jar.destinationDirectory = file("../mvn/com/plotsquared/PlotSquared-Bukkit/" + project.parent.version)
task createPom {
doLast {
pom {
project {
groupId = rootProject.group
artifactId = "PlotSquared-Bukkit"
version = rootProject.version
}
}.writeTo("../mvn/com/plotsquared/PlotSquared-Bukkit/${project.parent.version}/PlotSquared-Bukkit-${project.parent.version}.pom")
pom {
project {
groupId = rootProject.group
artifactId = "PlotSquared-Bukkit"
version = "latest"
}
}.writeTo("../mvn/com/plotsquared/PlotSquared-Bukkit/latest/PlotSquared-Bukkit-latest.pom")
.writeTo("pom.xml")
}
}
task copyFiles {
doLast {
copy {
from("../mvn/com/plotsquared/PlotSquared-Bukkit/${project.parent.version}/")
into("../mvn/com/plotsquared/PlotSquared-Bukkit/latest/")
include("PlotSquared-Bukkit*.jar")
rename("PlotSquared-Bukkit-${project.parent.version}.jar", "PlotSquared-Bukkit-latest.jar")
}
}
}
shadowJar { shadowJar {
dependencies { dependencies {
include(dependency(':Core')) include(dependency(":PlotSquared-Core"))
include(dependency('org.bstats:bstats-bukkit:1.4')) include(dependency("io.papermc:paperlib:1.0.5"))
include(dependency("net.kyori:text-adapter-bukkit:3.0.3"))
include(dependency("org.bstats:bstats-bukkit:1.7"))
include(dependency("org.khelekore:prtree:1.7.0-SNAPSHOT"))
include(dependency("com.sk89q:squirrelid:1.0.0-SNAPSHOT"))
include(dependency("com.intellectualsites.paster:Paster:1.0.2-SNAPSHOT"))
include(dependency("org.incendo.serverlib:ServerLib:2.2.0"))
} }
// relocate('org.mcstats', 'com.plotsquared.stats') relocate('net.kyori.text', 'com.plotsquared.formatting.text')
archiveName = "${parent.name}-${project.name}-${parent.version}.jar" relocate("io.papermc.lib", "com.plotsquared.bukkit.paperlib")
destinationDir = file '../target' relocate("org.bstats", "com.plotsquared.metrics")
relocate('com.sk89q.squirrelid', 'com.plotsquared.squirrelid')
relocate('org.khelekore.prtree', 'com.plotsquared.prtree')
relocate('com.intellectualsites.paster', 'com.plotsquared.core.paster')
relocate('org.incendo.serverlib', 'com.plotsquared.bukkit')
archiveFileName = "${project.name}-${parent.version}.jar"
destinationDirectory = file "../target"
} }
shadowJar.doLast { shadowJar.doLast {
@ -49,3 +121,5 @@ shadowJar.doLast {
} }
build.dependsOn(shadowJar) build.dependsOn(shadowJar)
build.finalizedBy(copyFiles)
copyFiles.dependsOn(createPom)

198
Bukkit/pom.xml Normal file
View File

@ -0,0 +1,198 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.plotsquared</groupId>
<artifactId>PlotSquared-Bukkit</artifactId>
<version>latest</version>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20200518</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>1.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.plotsquared</groupId>
<artifactId>PlotSquared-Core</artifactId>
<version>5.13.13</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.16.4-R0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>7.2.0</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>bukkit</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.papermc</groupId>
<artifactId>paperlib</artifactId>
<version>1.0.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>bukkit</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>se.hyperver.hyperverse</groupId>
<artifactId>Core</artifactId>
<version>0.6.0-SNAPSHOT</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>squirrelid</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>be.maximvdw</groupId>
<artifactId>MVdWPlaceholderAPI</artifactId>
<version>3.1.1</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-core</artifactId>
<version>7.2.0</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<artifactId>dummypermscompat</artifactId>
<groupId>*</groupId>
</exclusion>
<exclusion>
<artifactId>bukkit-classloader-check</artifactId>
<groupId>*</groupId>
</exclusion>
<exclusion>
<artifactId>mockito-core</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>text-api</artifactId>
<version>3.0.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>text-serializer-gson</artifactId>
<version>3.0.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>text-serializer-legacy</artifactId>
<version>3.0.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>text-serializer-plain</artifactId>
<version>3.0.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>21.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.4-R0.1-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>text-adapter-bukkit</artifactId>
<version>3.0.3</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.10.6</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>EssentialsX</artifactId>
<version>2.18.0</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<artifactId>paperlib</artifactId>
<groupId>io.papermc</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.incendo.serverlib</groupId>
<artifactId>ServerLib</artifactId>
<version>2.2.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,871 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit;
import com.github.intellectualsites.plotsquared.bukkit.database.plotme.ClassicPlotMeConnector;
import com.github.intellectualsites.plotsquared.bukkit.database.plotme.LikePlotMeConverter;
import com.github.intellectualsites.plotsquared.bukkit.database.plotme.PlotMeConnector_017;
import com.github.intellectualsites.plotsquared.bukkit.generator.BukkitPlotGenerator;
import com.github.intellectualsites.plotsquared.bukkit.listeners.*;
import com.github.intellectualsites.plotsquared.bukkit.titles.DefaultTitle_111;
import com.github.intellectualsites.plotsquared.bukkit.util.*;
import com.github.intellectualsites.plotsquared.bukkit.util.block.BukkitLocalQueue;
import com.github.intellectualsites.plotsquared.bukkit.uuid.*;
import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection;
import com.github.intellectualsites.plotsquared.plot.IPlotMain;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.C;
import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper;
import com.github.intellectualsites.plotsquared.plot.generator.HybridGen;
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator;
import com.github.intellectualsites.plotsquared.plot.object.*;
import com.github.intellectualsites.plotsquared.plot.object.chat.PlainChatManager;
import com.github.intellectualsites.plotsquared.plot.object.worlds.PlotAreaManager;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SingleWorldGenerator;
import com.github.intellectualsites.plotsquared.plot.util.*;
import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider;
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.extension.platform.Capability;
import lombok.Getter;
import lombok.NonNull;
import org.bukkit.*;
import org.bukkit.Location;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import javax.annotation.Nullable;
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getRefClass;
public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
@Getter private static WorldEdit worldEdit;
private static Map<String, Plugin> pluginMap;
static {
// Disable AWE as otherwise both fail to load
PluginManager manager = Bukkit.getPluginManager();
try {
Settings.load(new File("plugins/PlotSquared/config/settings.yml"));
if (Settings.Enabled_Components.PLOTME_CONVERTER) { // Only disable PlotMe if conversion is enabled
Field pluginsField = manager.getClass().getDeclaredField("plugins");
Field lookupNamesField = manager.getClass().getDeclaredField("lookupNames");
pluginsField.setAccessible(true);
lookupNamesField.setAccessible(true);
List<Plugin> plugins = (List<Plugin>) pluginsField.get(manager);
Iterator<Plugin> iter = plugins.iterator();
while (iter.hasNext()) {
if (iter.next().getName().startsWith("PlotMe")) {
iter.remove();
}
}
Map<String, Plugin> lookupNames =
(Map<String, Plugin>) lookupNamesField.get(manager);
lookupNames.remove("PlotMe");
lookupNames.remove("PlotMe-DefaultGenerator");
pluginsField.set(manager, new ArrayList<Plugin>(plugins) {
@Override public boolean add(Plugin plugin) {
if (plugin.getName().startsWith("PlotMe")) {
System.out.print("Disabling `" + plugin.getName()
+ "` for PlotMe conversion (configure in PlotSquared settings.yml)");
} else {
return super.add(plugin);
}
return false;
}
});
pluginMap = new ConcurrentHashMap<String, Plugin>(lookupNames) {
@Override public Plugin put(String key, Plugin plugin) {
if (!plugin.getName().startsWith("PlotMe")) {
return super.put(key, plugin);
}
return null;
}
};
lookupNamesField.set(manager, pluginMap);
}
} catch (Throwable ignore) {
}
// Force WorldEdit to load
try {
System.out.println("[P2] Force loading WorldEdit");
if (!manager.isPluginEnabled("WorldEdit")) {
manager.enablePlugin(WorldEditPlugin.getPlugin(WorldEditPlugin.class));
}
System.out.println("[P2] Testing platform capabilities");
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS);
} catch (final Throwable throwable) {
throw new IllegalStateException(
"Failed to force load WorldEdit." + " Road schematics will fail to generate",
throwable);
}
}
private final LegacyMappings legacyMappings = new BukkitLegacyMappings();
private final BlockRegistry<Material> blockRegistry =
new BukkitBlockRegistry(Material.values());
private int[] version;
@Getter private String pluginName;
@Getter private SingleWorldListener singleWorldListener;
private Method methodUnloadChunk0;
private boolean methodUnloadSetup = false;
private boolean metricsStarted;
@Override public int[] getServerVersion() {
if (this.version == null) {
try {
this.version = new int[3];
String[] split = Bukkit.getBukkitVersion().split("-")[0].split("\\.");
this.version[0] = Integer.parseInt(split[0]);
this.version[1] = Integer.parseInt(split[1]);
if (split.length == 3) {
this.version[2] = Integer.parseInt(split[2]);
}
} catch (NumberFormatException e) {
e.printStackTrace();
PlotSquared.debug(StringMan.getString(Bukkit.getBukkitVersion()));
PlotSquared.debug(
StringMan.getString(Bukkit.getBukkitVersion().split("-")[0].split("\\.")));
return new int[] {1, 13, 0};
}
}
return this.version;
}
@Override public void onEnable() {
if (pluginMap != null) {
pluginMap.put("PlotMe-DefaultGenerator", this);
}
this.pluginName = getDescription().getName();
getServer().getName();
PlotPlayer.registerConverter(Player.class, BukkitUtil::getPlayer);
if (Bukkit.getVersion().contains("git-Spigot")) {
// Uses System.out.println because the logger isn't initialized yet
System.out
.println("[P2] ========================== USE PAPER ==========================");
System.out.println("[P2] Paper offers a more complete API for us to work with");
System.out.println("[P2] and we may come to rely on it in the future.");
System.out.println("[P2] It is also recommended out of a performance standpoint as");
System.out
.println("[P2] it contains many improvements missing from Spigot and Bukkit.");
System.out.println("[P2] DOWNLOAD: https://papermc.io/downloads");
System.out.println("[P2] GUIDE: https://www.spigotmc.org/threads/21726/");
System.out.println("[P2] NOTE: This is only a recommendation");
System.out.println("[P2] both Spigot and CraftBukkit are still supported.");
System.out
.println("[P2] ===============================================================");
}
new PlotSquared(this, "Bukkit");
if (Settings.Enabled_Components.METRICS) {
this.startMetrics();
} else {
PlotSquared.log(C.CONSOLE_PLEASE_ENABLE_METRICS.f(getPluginName()));
}
if (Settings.Enabled_Components.WORLDS) {
TaskManager.IMP.taskRepeat(this::unload, 20);
try {
singleWorldListener = new SingleWorldListener(this);
} catch (Exception e) {
e.printStackTrace();
}
}
}
private void unload() {
if (!this.methodUnloadSetup) {
this.methodUnloadSetup = true;
try {
ReflectionUtils.RefClass classCraftWorld = getRefClass("{cb}.CraftWorld");
this.methodUnloadChunk0 = classCraftWorld.getRealClass()
.getDeclaredMethod("unloadChunk0", int.class, int.class, boolean.class);
this.methodUnloadChunk0.setAccessible(true);
} catch (Throwable ignore) {
ignore.printStackTrace();
}
}
final PlotAreaManager manager = PlotSquared.get().getPlotAreaManager();
if (manager instanceof SinglePlotAreaManager) {
long start = System.currentTimeMillis();
final SinglePlotArea area = ((SinglePlotAreaManager) manager).getArea();
outer:
for (final World world : Bukkit.getWorlds()) {
final String name = world.getName();
final char char0 = name.charAt(0);
if (!Character.isDigit(char0) && char0 != '-') {
continue;
}
if (!world.getPlayers().isEmpty()) {
continue;
}
final PlotId id = PlotId.fromString(name);
if (id != null) {
final Plot plot = area.getOwnedPlot(id);
if (plot != null) {
if (PlotPlayer.wrap(plot.owner) == null) {
if (world.getKeepSpawnInMemory()) {
world.setKeepSpawnInMemory(false);
return;
}
final Chunk[] chunks = world.getLoadedChunks();
if (chunks.length == 0) {
if (!Bukkit.unloadWorld(world, true)) {
PlotSquared.debug("Failed to unload " + world.getName());
}
return;
} else {
int index = 0;
do {
final Chunk chunkI = chunks[index++];
boolean result;
if (methodUnloadChunk0 != null) {
try {
result = (boolean) methodUnloadChunk0
.invoke(world, chunkI.getX(), chunkI.getZ(), true);
} catch (Throwable e) {
methodUnloadChunk0 = null;
e.printStackTrace();
continue outer;
}
} else {
result = world
.unloadChunk(chunkI.getX(), chunkI.getZ(), true, false);
}
if (!result) {
continue outer;
}
} while (index < chunks.length
&& System.currentTimeMillis() - start < 5);
return;
}
}
}
}
}
}
}
@Override public void onDisable() {
PlotSquared.get().disable();
Bukkit.getScheduler().cancelTasks(this);
}
@Override public void log(@NonNull String message) {
try {
message = C.color(message);
if (!Settings.Chat.CONSOLE_COLOR) {
message = ChatColor.stripColor(message);
}
this.getServer().getConsoleSender().sendMessage(message);
} catch (final Throwable ignored) {
System.out.println(ConsoleColors.fromString(message));
}
}
@Override public void shutdown() {
this.getServer().getPluginManager().disablePlugin(this);
}
@Override public void disable() {
onDisable();
}
@Override public int[] getPluginVersion() {
String ver = getDescription().getVersion();
if (ver.contains("-")) {
ver = ver.split("-")[0];
}
String[] split = ver.split("\\.");
return new int[] {Integer.parseInt(split[0]), Integer.parseInt(split[1]),
Integer.parseInt(split[2])};
}
@Override public String getPluginVersionString() {
return getDescription().getVersion();
}
@Override public void registerCommands() {
final BukkitCommand bukkitCommand = new BukkitCommand();
final PluginCommand plotCommand = getCommand("plots");
plotCommand.setExecutor(bukkitCommand);
plotCommand.setAliases(Arrays.asList("p", "ps", "plotme", "plot"));
plotCommand.setTabCompleter(bukkitCommand);
}
@Override public File getDirectory() {
return getDataFolder();
}
@Override public File getWorldContainer() {
return Bukkit.getWorldContainer();
}
@Override public TaskManager getTaskManager() {
return new BukkitTaskManager(this);
}
@Override @SuppressWarnings("deprecation") public void runEntityTask() {
PlotSquared.log(C.PREFIX + "KillAllEntities started.");
TaskManager
.runTaskRepeat(() -> PlotSquared.get().foreachPlotArea(new RunnableVal<PlotArea>() {
@Override public void run(PlotArea plotArea) {
final World world = Bukkit.getWorld(plotArea.worldname);
try {
if (world == null) {
return;
}
List<Entity> entities = world.getEntities();
Iterator<Entity> iterator = entities.iterator();
while (iterator.hasNext()) {
Entity entity = iterator.next();
switch (entity.getType()) {
case EGG:
case COMPLEX_PART:
case FISHING_HOOK:
case ENDER_SIGNAL:
case LINGERING_POTION:
case AREA_EFFECT_CLOUD:
case EXPERIENCE_ORB:
case LEASH_HITCH:
case FIREWORK:
case WEATHER:
case LIGHTNING:
case WITHER_SKULL:
case UNKNOWN:
case PLAYER:
// non moving / unmovable
continue;
case THROWN_EXP_BOTTLE:
case SPLASH_POTION:
case SNOWBALL:
case SHULKER_BULLET:
case SPECTRAL_ARROW:
case TIPPED_ARROW:
case ENDER_PEARL:
case ARROW:
case LLAMA_SPIT:
// managed elsewhere | projectile
continue;
case ITEM_FRAME:
case PAINTING:
// Not vehicles
continue;
case ARMOR_STAND:
// Temporarily classify as vehicle
case MINECART:
case MINECART_CHEST:
case MINECART_COMMAND:
case MINECART_FURNACE:
case MINECART_HOPPER:
case MINECART_MOB_SPAWNER:
case ENDER_CRYSTAL:
case MINECART_TNT:
case BOAT:
if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
com.github.intellectualsites.plotsquared.plot.object.Location
location = BukkitUtil.getLocation(entity.getLocation());
Plot plot = location.getPlot();
if (plot == null) {
if (location.isPlotArea()) {
if (entity.hasMetadata("ps-tmp-teleport")) {
continue;
}
iterator.remove();
entity.remove();
}
continue;
}
List<MetadataValue> meta = entity.getMetadata("plot");
if (meta.isEmpty()) {
continue;
}
Plot origin = (Plot) meta.get(0).value();
if (!plot.equals(origin.getBasePlot(false))) {
if (entity.hasMetadata("ps-tmp-teleport")) {
continue;
}
iterator.remove();
entity.remove();
}
continue;
} else {
continue;
}
case SMALL_FIREBALL:
case FIREBALL:
case DRAGON_FIREBALL:
case DROPPED_ITEM:
if (Settings.Enabled_Components.KILL_ROAD_ITEMS) {
entity.remove();
}
// dropped item
continue;
case PRIMED_TNT:
case FALLING_BLOCK:
// managed elsewhere
continue;
case LLAMA:
case DONKEY:
case MULE:
case ZOMBIE_HORSE:
case SKELETON_HORSE:
case HUSK:
case ELDER_GUARDIAN:
case WITHER_SKELETON:
case STRAY:
case ZOMBIE_VILLAGER:
case EVOKER:
case EVOKER_FANGS:
case VEX:
case VINDICATOR:
case POLAR_BEAR:
case BAT:
case BLAZE:
case CAVE_SPIDER:
case CHICKEN:
case COW:
case CREEPER:
case ENDERMAN:
case ENDERMITE:
case ENDER_DRAGON:
case GHAST:
case GIANT:
case GUARDIAN:
case HORSE:
case IRON_GOLEM:
case MAGMA_CUBE:
case MUSHROOM_COW:
case OCELOT:
case PIG:
case PIG_ZOMBIE:
case RABBIT:
case SHEEP:
case SILVERFISH:
case SKELETON:
case SLIME:
case SNOWMAN:
case SPIDER:
case SQUID:
case VILLAGER:
case WITCH:
case WITHER:
case WOLF:
case ZOMBIE:
default: {
if (Settings.Enabled_Components.KILL_ROAD_MOBS) {
Location location = entity.getLocation();
if (BukkitUtil.getLocation(location).isPlotRoad()) {
if (entity instanceof LivingEntity) {
LivingEntity livingEntity = (LivingEntity) entity;
if (!livingEntity.isLeashed() || !entity
.hasMetadata("keep")) {
Entity passenger = entity.getPassenger();
if (!(passenger instanceof Player) && entity
.getMetadata("keep").isEmpty()) {
if (entity.hasMetadata("ps-tmp-teleport")) {
continue;
}
iterator.remove();
entity.remove();
continue;
}
}
} else {
Entity passenger = entity.getPassenger();
if (!(passenger instanceof Player) && entity
.getMetadata("keep").isEmpty()) {
if (entity.hasMetadata("ps-tmp-teleport")) {
continue;
}
iterator.remove();
entity.remove();
continue;
}
}
}
}
continue;
}
case SHULKER: {
if (Settings.Enabled_Components.KILL_ROAD_MOBS) {
LivingEntity livingEntity = (LivingEntity) entity;
List<MetadataValue> meta = entity.getMetadata("plot");
if (meta != null && !meta.isEmpty()) {
if (livingEntity.isLeashed())
continue;
List<MetadataValue> keep = entity.getMetadata("keep");
if (keep != null && !keep.isEmpty())
continue;
PlotId originalPlotId = (PlotId) meta.get(0).value();
if (originalPlotId != null) {
com.github.intellectualsites.plotsquared.plot.object.Location
pLoc =
BukkitUtil.getLocation(entity.getLocation());
PlotArea area = pLoc.getPlotArea();
if (area != null) {
PlotId currentPlotId =
PlotId.of(area.getPlotAbs(pLoc));
if (!originalPlotId.equals(currentPlotId) && (
currentPlotId == null || !area
.getPlot(originalPlotId)
.equals(area.getPlot(currentPlotId)))) {
if (entity.hasMetadata("ps-tmp-teleport")) {
continue;
}
iterator.remove();
entity.remove();
}
}
}
} else {
//This is to apply the metadata to already spawned shulkers (see EntitySpawnListener.java)
com.github.intellectualsites.plotsquared.plot.object.Location
pLoc = BukkitUtil.getLocation(entity.getLocation());
PlotArea area = pLoc.getPlotArea();
if (area != null) {
PlotId currentPlotId =
PlotId.of(area.getPlotAbs(pLoc));
if (currentPlotId != null) {
entity.setMetadata("plot",
new FixedMetadataValue(
(Plugin) PlotSquared.get().IMP,
currentPlotId));
}
}
}
}
}
}
}
} catch (Throwable e) {
e.printStackTrace();
}
}
}), 20);
}
@Override @Nullable
public final ChunkGenerator getDefaultWorldGenerator(final String world, final String id) {
if (Settings.Enabled_Components.PLOTME_CONVERTER) {
initPlotMeConverter();
Settings.Enabled_Components.PLOTME_CONVERTER = false;
}
final IndependentPlotGenerator result;
if (id != null && id.equalsIgnoreCase("single")) {
result = new SingleWorldGenerator();
} else {
result = PlotSquared.get().IMP.getDefaultGenerator();
if (!PlotSquared.get().setupPlotWorld(world, id, result)) {
return null;
}
}
return (ChunkGenerator) result.specify(world);
}
@Override public void registerPlayerEvents() {
final PlayerEvents main = new PlayerEvents();
getServer().getPluginManager().registerEvents(main, this);
try {
getServer().getClass().getMethod("spigot");
Class.forName("org.bukkit.event.entity.EntitySpawnEvent");
getServer().getPluginManager().registerEvents(new EntitySpawnListener(), this);
} catch (final NoSuchMethodException | ClassNotFoundException ignored) {
PlotSquared.debug("Not running Spigot. Skipping EntitySpawnListener event.");
}
}
@Override public void registerInventoryEvents() {
// Part of PlayerEvents - can be moved if necessary
}
@Override public void registerPlotPlusEvents() {
PlotPlusListener.startRunnable(this);
getServer().getPluginManager().registerEvents(new PlotPlusListener(), this);
}
@Override public void registerForceFieldEvents() {
}
@Override public boolean initWorldEdit() {
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) {
worldEdit = WorldEdit.getInstance();
return true;
}
return false;
}
@Override public EconHandler getEconomyHandler() {
try {
BukkitEconHandler econ = new BukkitEconHandler();
if (econ.init()) {
return econ;
}
} catch (Throwable ignored) {
PlotSquared.debug("No economy detected!");
}
return null;
}
@Override public QueueProvider initBlockQueue() {
try {
new SendChunk();
MainUtil.canSendChunk = true;
} catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) {
PlotSquared.debug(
SendChunk.class + " does not support " + StringMan.getString(getServerVersion()));
MainUtil.canSendChunk = false;
}
return QueueProvider.of(BukkitLocalQueue.class, BukkitLocalQueue.class);
}
@Override public WorldUtil initWorldUtil() {
return new BukkitUtil();
}
@Override public boolean initPlotMeConverter() {
if (new LikePlotMeConverter("PlotMe").run(new ClassicPlotMeConnector())) {
return true;
} else if (new LikePlotMeConverter("PlotMe").run(new PlotMeConnector_017())) {
return true;
}
return false;
}
@Override @Nullable public GeneratorWrapper<?> getGenerator(@NonNull final String world,
@Nullable final String name) {
if (name == null) {
return null;
}
final Plugin genPlugin = Bukkit.getPluginManager().getPlugin(name);
if (genPlugin != null && genPlugin.isEnabled()) {
ChunkGenerator gen = genPlugin.getDefaultWorldGenerator(world, "");
if (gen instanceof GeneratorWrapper<?>) {
return (GeneratorWrapper<?>) gen;
}
return new BukkitPlotGenerator(world, gen);
} else {
return new BukkitPlotGenerator(PlotSquared.get().IMP.getDefaultGenerator());
}
}
@Override public HybridUtils initHybridUtils() {
return new BukkitHybridUtils();
}
@Override public SetupUtils initSetupUtils() {
return new BukkitSetupUtils();
}
@Override public UUIDHandlerImplementation initUUIDHandler() {
boolean checkVersion = false;
try {
OfflinePlayer.class.getDeclaredMethod("getUniqueId");
checkVersion = true;
} catch (Throwable ignore) {
}
final UUIDWrapper wrapper;
if (Settings.UUID.OFFLINE) {
if (Settings.UUID.FORCE_LOWERCASE) {
wrapper = new LowerOfflineUUIDWrapper();
} else {
wrapper = new OfflineUUIDWrapper();
}
Settings.UUID.OFFLINE = true;
} else if (checkVersion) {
wrapper = new DefaultUUIDWrapper();
Settings.UUID.OFFLINE = false;
} else {
if (Settings.UUID.FORCE_LOWERCASE) {
wrapper = new LowerOfflineUUIDWrapper();
} else {
wrapper = new OfflineUUIDWrapper();
}
Settings.UUID.OFFLINE = true;
}
if (!checkVersion) {
PlotSquared.log(C.PREFIX
+ " &c[WARN] Titles are disabled - please update your version of Bukkit to support this feature.");
Settings.TITLES = false;
} else {
AbstractTitle.TITLE_CLASS = new DefaultTitle_111();
if (wrapper instanceof DefaultUUIDWrapper
|| wrapper.getClass() == OfflineUUIDWrapper.class && !Bukkit.getOnlineMode()) {
Settings.UUID.NATIVE_UUID_PROVIDER = true;
}
}
if (Settings.UUID.OFFLINE) {
PlotSquared.log(C.PREFIX + " &6" + getPluginName()
+ " is using Offline Mode UUIDs either because of user preference, or because you are using an old version of "
+ "Bukkit");
} else {
PlotSquared.log(C.PREFIX + " &6" + getPluginName() + " is using online UUIDs");
}
if (Settings.UUID.USE_SQLUUIDHANDLER) {
return new SQLUUIDHandler(wrapper);
} else {
return new FileUUIDHandler(wrapper);
}
}
@Override public ChunkManager initChunkManager() {
return new BukkitChunkManager();
}
@Override public EventUtil initEventUtil() {
return new BukkitEventUtil();
}
@Override public void unregister(@NonNull final PlotPlayer player) {
BukkitUtil.removePlayer(player.getName());
}
@Override public void registerChunkProcessor() {
getServer().getPluginManager().registerEvents(new ChunkListener(), this);
}
@Override public void registerWorldEvents() {
getServer().getPluginManager().registerEvents(new WorldEvents(), this);
}
@Override public IndependentPlotGenerator getDefaultGenerator() {
return new HybridGen();
}
@Override public InventoryUtil initInventoryUtil() {
return new BukkitInventoryUtil();
}
@Override public void startMetrics() {
if (this.metricsStarted) {
return;
}
System.setProperty("bstats.relocatecheck",
"false"); // We do not want to relocate the package...
new org.bstats.bukkit.Metrics(this); // bstats
PlotSquared.log(C.PREFIX + "&6Metrics enabled.");
this.metricsStarted = true;
}
@Override public void setGenerator(@NonNull final String worldName) {
World world = BukkitUtil.getWorld(worldName);
if (world == null) {
// create world
ConfigurationSection worldConfig =
PlotSquared.get().worlds.getConfigurationSection("worlds." + worldName);
String manager = worldConfig.getString("generator.plugin", getPluginName());
SetupObject setup = new SetupObject();
setup.plotManager = manager;
setup.setupGenerator = worldConfig.getString("generator.init", manager);
setup.type = worldConfig.getInt("generator.type");
setup.terrain = worldConfig.getInt("generator.terrain");
setup.step = new ConfigurationNode[0];
setup.world = worldName;
SetupUtils.manager.setupWorld(setup);
world = Bukkit.getWorld(worldName);
} else {
try {
if (!PlotSquared.get().hasPlotArea(worldName)) {
SetGenCB.setGenerator(BukkitUtil.getWorld(worldName));
}
} catch (Exception e) {
PlotSquared.log("Failed to reload world: " + world + " | " + e.getMessage());
Bukkit.getServer().unloadWorld(world, false);
return;
}
}
ChunkGenerator gen = world.getGenerator();
if (gen instanceof BukkitPlotGenerator) {
PlotSquared.get().loadWorld(worldName, (BukkitPlotGenerator) gen);
} else if (gen != null) {
PlotSquared.get().loadWorld(worldName, new BukkitPlotGenerator(worldName, gen));
} else if (PlotSquared.get().worlds.contains("worlds." + worldName)) {
PlotSquared.get().loadWorld(worldName, null);
}
}
@Override public SchematicHandler initSchematicHandler() {
return new BukkitSchematicHandler();
}
@Override public AbstractTitle initTitleManager() {
// Already initialized in UUID handler
return AbstractTitle.TITLE_CLASS;
}
@Override @Nullable public PlotPlayer wrapPlayer(final Object player) {
if (player instanceof Player) {
return BukkitUtil.getPlayer((Player) player);
}
if (player instanceof OfflinePlayer) {
return BukkitUtil.getPlayer((OfflinePlayer) player);
}
if (player instanceof String) {
return UUIDHandler.getPlayer((String) player);
}
if (player instanceof UUID) {
return UUIDHandler.getPlayer((UUID) player);
}
return null;
}
@Override public String getNMSPackage() {
final String name = Bukkit.getServer().getClass().getPackage().getName();
return name.substring(name.lastIndexOf('.') + 1);
}
@Override public ChatManager<?> initChatManager() {
if (Settings.Chat.INTERACTIVE) {
return new BukkitChatManager();
} else {
return new PlainChatManager();
}
}
@Override public GeneratorWrapper<?> wrapPlotGenerator(@Nullable final String world,
@NonNull final IndependentPlotGenerator generator) {
return new BukkitPlotGenerator(generator);
}
@Override public List<String> getPluginIds() {
final List<String> names = new ArrayList<>();
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
names.add(plugin.getName() + ';' + plugin.getDescription().getVersion() + ':' + plugin
.isEnabled());
}
return names;
}
@Override public BlockRegistry<Material> getBlockRegistry() {
return this.blockRegistry;
}
@Override public LegacyMappings getLegacyMappings() {
return this.legacyMappings;
}
}

View File

@ -1,20 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.chat;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
/**
* Represents an object that can be serialized to a JSON writer instance.
*/
interface JsonRepresentedObject {
/**
* Writes the JSON representation of this object to the specified writer.
*
* @param writer The JSON writer which will receive the object.
* @throws IOException If an error occurs writing to the stream.
*/
public void writeJson(JsonWriter writer) throws IOException;
}

View File

@ -1,45 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.chat;
import com.google.gson.stream.JsonWriter;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* Represents a JSON string value.
* Writes by this object will not write name values nor begin/end objects in the JSON stream.
* All writes merely write the represented string value.
*/
final class JsonString implements JsonRepresentedObject, ConfigurationSerializable {
private String _value;
public JsonString(CharSequence value) {
_value = value == null ? null : value.toString();
}
public static JsonString deserialize(Map<String, Object> map) {
return new JsonString(map.get("stringValue").toString());
}
@Override public void writeJson(JsonWriter writer) throws IOException {
writer.value(getValue());
}
public String getValue() {
return _value;
}
public Map<String, Object> serialize() {
HashMap<String, Object> theSingleValue = new HashMap<String, Object>();
theSingleValue.put("stringValue", _value);
return theSingleValue;
}
@Override public String toString() {
return _value;
}
}

View File

@ -1,297 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.commands;
import com.github.intellectualsites.plotsquared.bukkit.uuid.DatFileFilter;
import com.github.intellectualsites.plotsquared.bukkit.uuid.DefaultUUIDWrapper;
import com.github.intellectualsites.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
import com.github.intellectualsites.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
import com.github.intellectualsites.plotsquared.commands.Argument;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.commands.CommandCategory;
import com.github.intellectualsites.plotsquared.plot.commands.RequiredType;
import com.github.intellectualsites.plotsquared.plot.commands.SubCommand;
import com.github.intellectualsites.plotsquared.plot.config.C;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.object.OfflinePlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.StringWrapper;
import com.github.intellectualsites.plotsquared.plot.util.*;
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
import com.google.common.collect.Sets;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.*;
import java.util.Map.Entry;
@CommandDeclaration(command = "uuidconvert", permission = "plots.admin",
description = "Debug UUID conversion", usage = "/plot uuidconvert <lower|offline|online>",
requiredType = RequiredType.CONSOLE, category = CommandCategory.DEBUG) public class DebugUUID
extends SubCommand {
public DebugUUID() {
super(Argument.String);
}
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
final UUIDWrapper currentUUIDWrapper = UUIDHandler.getUUIDWrapper();
final UUIDWrapper newWrapper;
switch (args[0].toLowerCase()) {
case "lower":
newWrapper = new LowerOfflineUUIDWrapper();
break;
case "offline":
newWrapper = new OfflineUUIDWrapper();
break;
case "online":
newWrapper = new DefaultUUIDWrapper();
break;
default:
try {
Class<?> clazz = Class.forName(args[0]);
newWrapper = (UUIDWrapper) clazz.newInstance();
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException ignored) {
MainUtil.sendMessage(player, C.COMMAND_SYNTAX,
"/plot uuidconvert <lower|offline|online>");
return false;
}
}
if (args.length != 2 || !"-o".equals(args[1])) {
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot uuidconvert " + args[0] + " - o");
MainUtil.sendMessage(player, "&cBe aware of the following!");
MainUtil.sendMessage(player,
"&8 - &cUse the database command or another method to backup your plots beforehand");
MainUtil.sendMessage(player,
"&8 - &cIf the process is interrupted, all plots could be deleted");
MainUtil.sendMessage(player, "&8 - &cIf an error occurs, all plots could be deleted");
MainUtil.sendMessage(player, "&8 - &cPlot settings WILL be lost upon conversion");
MainUtil
.sendMessage(player, "&cTO REITERATE: BACK UP YOUR DATABASE BEFORE USING THIS!!!");
MainUtil.sendMessage(player,
"&7Retype the command with the override parameter when ready :)");
return false;
}
if (currentUUIDWrapper.getClass().getCanonicalName()
.equals(newWrapper.getClass().getCanonicalName())) {
MainUtil.sendMessage(player, "&cUUID mode already in use!");
return false;
}
MainUtil.sendMessage(player, "&6Beginning UUID mode conversion");
MainUtil.sendMessage(player, "&7 - Disconnecting players");
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
entry.getValue()
.kick("UUID conversion has been initiated. You may reconnect when finished.");
}
MainUtil.sendMessage(player, "&7 - Initializing map");
final HashMap<UUID, UUID> uCMap = new HashMap<>();
final HashMap<UUID, UUID> uCReverse = new HashMap<>();
MainUtil.sendMessage(player, "&7 - Collecting playerdata");
HashSet<String> worlds = Sets.newHashSet(WorldUtil.IMP.getMainWorld(), "world");
HashSet<UUID> uuids = new HashSet<>();
HashSet<String> names = new HashSet<>();
for (String worldName : worlds) {
File playerDataFolder = new File(worldName + File.separator + "playerdata");
String[] dat = playerDataFolder.list(new DatFileFilter());
if (dat != null) {
for (String current : dat) {
String s = current.replaceAll(".dat$", "");
try {
UUID uuid = UUID.fromString(s);
uuids.add(uuid);
} catch (Exception ignored) {
MainUtil.sendMessage(player, C.PREFIX + "Invalid playerdata: " + current);
}
}
}
File playersFolder = new File(worldName + File.separator + "players");
dat = playersFolder.list(new DatFileFilter());
if (dat != null) {
for (String current : dat) {
names.add(current.replaceAll(".dat$", ""));
}
}
}
MainUtil.sendMessage(player, "&7 - Populating map");
UUID uuid2;
UUIDWrapper wrapper = new DefaultUUIDWrapper();
for (UUID uuid : uuids) {
try {
OfflinePlotPlayer op = wrapper.getOfflinePlayer(uuid);
uuid = currentUUIDWrapper.getUUID(op);
uuid2 = newWrapper.getUUID(op);
if (!uuid.equals(uuid2) && !uCMap.containsKey(uuid) && !uCReverse
.containsKey(uuid2)) {
uCMap.put(uuid, uuid2);
uCReverse.put(uuid2, uuid);
}
} catch (Throwable ignored) {
MainUtil.sendMessage(player,
C.PREFIX + "&6Invalid playerdata: " + uuid.toString() + ".dat");
}
}
for (String name : names) {
UUID uuid = currentUUIDWrapper.getUUID(name);
uuid2 = newWrapper.getUUID(name);
if (!uuid.equals(uuid2)) {
uCMap.put(uuid, uuid2);
uCReverse.put(uuid2, uuid);
}
}
if (uCMap.isEmpty()) {
MainUtil.sendMessage(player, "&c - Error! Attempting to repopulate");
for (OfflinePlotPlayer op : currentUUIDWrapper.getOfflinePlayers()) {
if (op.getLastPlayed() != 0) {
// String name = op.getPluginName();
// StringWrapper wrap = new StringWrapper(name);
UUID uuid = currentUUIDWrapper.getUUID(op);
uuid2 = newWrapper.getUUID(op);
if (!uuid.equals(uuid2)) {
uCMap.put(uuid, uuid2);
uCReverse.put(uuid2, uuid);
}
}
}
if (uCMap.isEmpty()) {
MainUtil.sendMessage(player, "&cError. Failed to collect UUIDs!");
return false;
} else {
MainUtil.sendMessage(player, "&a - Successfully repopulated");
}
}
MainUtil.sendMessage(player, "&7 - Replacing cache");
TaskManager.runTaskAsync(new Runnable() {
@Override public void run() {
for (Entry<UUID, UUID> entry : uCMap.entrySet()) {
String name = UUIDHandler.getName(entry.getKey());
if (name != null) {
UUIDHandler.add(new StringWrapper(name), entry.getValue());
}
}
MainUtil.sendMessage(player, "&7 - Scanning for applicable files (uuids.txt)");
File file = new File(PlotSquared.get().IMP.getDirectory(), "uuids.txt");
if (file.exists()) {
try {
List<String> lines =
Files.readAllLines(file.toPath(), StandardCharsets.UTF_8);
for (String line : lines) {
try {
line = line.trim();
if (line.isEmpty()) {
continue;
}
line = line.replaceAll("[\\|][0-9]+[\\|][0-9]+[\\|]", "");
String[] split = line.split("\\|");
String name = split[0];
if (name.isEmpty() || name.length() > 16 || !StringMan
.isAlphanumericUnd(name)) {
continue;
}
UUID old = currentUUIDWrapper.getUUID(name);
if (old == null) {
continue;
}
UUID now = newWrapper.getUUID(name);
UUIDHandler.add(new StringWrapper(name), now);
uCMap.put(old, now);
uCReverse.put(now, old);
} catch (Exception e2) {
e2.printStackTrace();
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
MainUtil.sendMessage(player, "&7 - Replacing wrapper");
UUIDHandler.setUUIDWrapper(newWrapper);
MainUtil.sendMessage(player, "&7 - Updating plot objects");
for (Plot plot : PlotSquared.get().getPlots()) {
UUID value = uCMap.get(plot.owner);
if (value != null) {
plot.owner = value;
}
plot.getTrusted().clear();
plot.getMembers().clear();
plot.getDenied().clear();
}
MainUtil.sendMessage(player, "&7 - Deleting database");
boolean result = DBFunc.deleteTables();
MainUtil.sendMessage(player, "&7 - Creating tables");
try {
DBFunc.createTables();
if (!result) {
MainUtil.sendMessage(player, "&cConversion failed! Attempting recovery");
for (Plot plot : PlotSquared.get().getPlots()) {
UUID value = uCReverse.get(plot.owner);
if (value != null) {
plot.owner = value;
}
}
DBFunc.createPlotsAndData(new ArrayList<>(PlotSquared.get().getPlots()),
new Runnable() {
@Override public void run() {
MainUtil.sendMessage(player, "&6Recovery was successful!");
}
});
return;
}
} catch (Exception e) {
e.printStackTrace();
return;
}
if (newWrapper instanceof OfflineUUIDWrapper) {
PlotSquared.get().worlds.set("UUID.force-lowercase", false);
PlotSquared.get().worlds.set("UUID.offline", true);
} else if (newWrapper instanceof DefaultUUIDWrapper) {
PlotSquared.get().worlds.set("UUID.force-lowercase", false);
PlotSquared.get().worlds.set("UUID.offline", false);
}
try {
PlotSquared.get().worlds.save(PlotSquared.get().worldsFile);
} catch (IOException ignored) {
MainUtil.sendMessage(player,
"Could not save configuration. It will need to be manual set!");
}
MainUtil.sendMessage(player, "&7 - Populating tables");
TaskManager.runTaskAsync(new Runnable() {
@Override public void run() {
ArrayList<Plot> plots = new ArrayList<>(PlotSquared.get().getPlots());
DBFunc.createPlotsAndData(plots, new Runnable() {
@Override public void run() {
MainUtil.sendMessage(player, "&aConversion complete!");
}
});
}
});
MainUtil.sendMessage(player, "&aIt is now safe for players to join");
MainUtil.sendMessage(player,
"&cConversion is still in progress, you will be notified when it is complete");
}
});
return true;
}
}

View File

@ -1,87 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.database.plotme;
import com.github.intellectualsites.plotsquared.configuration.file.FileConfiguration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collections;
import java.util.HashMap;
public abstract class APlotMeConnector {
public abstract Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig,
String dataFolder);
public abstract HashMap<String, HashMap<PlotId, Plot>> getPlotMePlots(Connection connection)
throws SQLException;
public abstract boolean accepts(String version);
public boolean isValidConnection(Connection connection) {
return connection != null;
}
public void copyConfig(FileConfiguration plotConfig, String world, String actualWorldName) {
int pathWidth = plotConfig.getInt("worlds." + world + ".PathWidth"); //
PlotSquared.get().worlds.set("worlds." + actualWorldName + ".road.width", pathWidth);
int plotSize = plotConfig.getInt("worlds." + world + ".PlotSize"); //
PlotSquared.get().worlds.set("worlds." + actualWorldName + ".plot.size", plotSize);
String wallBlock = plotConfig.getString("worlds." + world + ".WallBlockId"); //
PlotSquared.get().worlds.set("worlds." + actualWorldName + ".wall.block", wallBlock);
String floor = plotConfig.getString("worlds." + world + ".PlotFloorBlockId"); //
PlotSquared.get().worlds
.set("worlds." + actualWorldName + ".plot.floor", Collections.singletonList(floor));
String filling = plotConfig.getString("worlds." + world + ".PlotFillingBlockId"); //
PlotSquared.get().worlds
.set("worlds." + actualWorldName + ".plot.filling", Collections.singletonList(filling));
String road = plotConfig.getString("worlds." + world + ".RoadMainBlockId");
PlotSquared.get().worlds.set("worlds." + actualWorldName + ".road.block", road);
int height = plotConfig.getInt("worlds." + world + ".RoadHeight"); //
PlotSquared.get().worlds.set("worlds." + actualWorldName + ".road.height", height);
PlotSquared.get().worlds.set("worlds." + actualWorldName + ".plot.height", height);
PlotSquared.get().worlds.set("worlds." + actualWorldName + ".wall.height", height);
}
public Location getPlotTopLocAbs(int path, int plot, PlotId plotId) {
int px = plotId.x;
int pz = plotId.y;
int x = px * (path + plot) - (int) Math.floor(path / 2) - 1;
int z = pz * (path + plot) - (int) Math.floor(path / 2) - 1;
return new Location(null, x, 256, z);
}
public Location getPlotBottomLocAbs(int path, int plot, PlotId plotId) {
int px = plotId.x;
int pz = plotId.y;
int x = px * (path + plot) - plot - (int) Math.floor(path / 2) - 1;
int z = pz * (path + plot) - plot - (int) Math.floor(path / 2) - 1;
return new Location(null, x, 1, z);
}
public void setMerged(HashMap<String, HashMap<PlotId, boolean[]>> merges, String world,
PlotId id, int direction) {
HashMap<PlotId, boolean[]> plots = merges.get(world);
PlotId id2 = new PlotId(id.x, id.y);
boolean[] merge1;
if (plots.containsKey(id)) {
merge1 = plots.get(id);
} else {
merge1 = new boolean[] {false, false, false, false};
}
boolean[] merge2;
if (plots.containsKey(id2)) {
merge2 = plots.get(id2);
} else {
merge2 = new boolean[] {false, false, false, false};
}
merge1[direction] = true;
merge2[(direction + 2) % 4] = true;
plots.put(id, merge1);
plots.put(id2, merge1);
}
}

View File

@ -1,240 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.database.plotme;
import com.github.intellectualsites.plotsquared.configuration.file.FileConfiguration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.database.SQLite;
import com.github.intellectualsites.plotsquared.plot.object.*;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.google.common.base.Charsets;
import java.io.File;
import java.nio.ByteBuffer;
import java.sql.*;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.UUID;
public class ClassicPlotMeConnector extends APlotMeConnector {
private String plugin = "PlotMe";
private String prefix;
@Override public Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig,
String dataFolder) {
this.plugin = plugin.toLowerCase();
this.prefix = plotConfig.getString("mySQLprefix", this.plugin.toLowerCase());
try {
if (plotConfig.getBoolean("usemySQL")) {
String user = plotConfig.getString("mySQLuname");
String password = plotConfig.getString("mySQLpass");
String con = plotConfig.getString("mySQLconn");
return DriverManager.getConnection(con, user, password);
} else {
return new SQLite(new File(dataFolder + File.separator + "plots.db"))
.openConnection();
}
} catch (SQLException | ClassNotFoundException e) {
e.printStackTrace();
}
return null;
}
@Override public HashMap<String, HashMap<PlotId, Plot>> getPlotMePlots(Connection connection)
throws SQLException {
HashMap<String, Integer> plotWidth = new HashMap<>();
HashMap<String, Integer> roadWidth = new HashMap<>();
HashMap<String, HashMap<PlotId, Plot>> plots = new HashMap<>();
HashMap<String, HashMap<PlotId, boolean[]>> merges = new HashMap<>();
PreparedStatement statement =
connection.prepareStatement("SELECT * FROM `" + this.prefix + "Plots`");
ResultSet resultSet = statement.executeQuery();
String column = null;
boolean checkUUID = DBFunc.hasColumn(resultSet, "ownerid");
boolean checkUUID2 = DBFunc.hasColumn(resultSet, "ownerId");
if (checkUUID) {
column = "ownerid";
} else if (checkUUID2) {
column = "ownerId";
}
boolean merge =
!"plotme".equalsIgnoreCase(this.plugin) && Settings.Enabled_Components.PLOTME_CONVERTER;
int missing = 0;
while (resultSet.next()) {
PlotId id = new PlotId(resultSet.getInt("idX"), resultSet.getInt("idZ"));
String name = resultSet.getString("owner");
String world = LikePlotMeConverter.getWorld(resultSet.getString("world"));
if (!plots.containsKey(world)) {
plots.put(world, new HashMap<PlotId, Plot>());
if (merge) {
int plot = PlotSquared.get().worlds.getInt("worlds." + world + ".plot.size");
int path = PlotSquared.get().worlds.getInt("worlds." + world + ".road.width");
plotWidth.put(world, plot);
roadWidth.put(world, path);
merges.put(world, new HashMap<PlotId, boolean[]>());
}
}
if (merge) {
int tx = resultSet.getInt("topX");
int tz = resultSet.getInt("topZ");
int bx = resultSet.getInt("bottomX") - 1;
int bz = resultSet.getInt("bottomZ") - 1;
int path = roadWidth.get(world);
int plot = plotWidth.get(world);
Location top = getPlotTopLocAbs(path, plot, id);
Location bot = getPlotBottomLocAbs(path, plot, id);
if (tx > top.getX()) {
setMerged(merges, world, id, 1);
}
if (tz > top.getZ()) {
setMerged(merges, world, id, 2);
}
if (bx < bot.getX()) {
setMerged(merges, world, id, 3);
}
if (bz > bot.getZ()) {
setMerged(merges, world, id, 0);
}
}
UUID owner = UUIDHandler.getUUID(name, null);
if (owner == null) {
if ("*".equals(name)) {
owner = DBFunc.EVERYONE;
} else {
if (checkUUID || checkUUID2) {
byte[] bytes = resultSet.getBytes(column);
if (bytes != null) {
ByteBuffer bb = ByteBuffer.wrap(bytes);
long high = bb.getLong();
long low = bb.getLong();
owner = new UUID(high, low);
UUIDHandler.add(new StringWrapper(name), owner);
}
}
if (name.isEmpty()) {
PlotSquared.log(
"&cCould not identify owner for plot: " + id + " -> '" + name + "'");
missing++;
continue;
}
owner = UUID.nameUUIDFromBytes(
("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
}
} else {
UUIDHandler.add(new StringWrapper(name), owner);
}
Plot plot = new Plot(PlotArea.createGeneric(world), id, owner);
plots.get(world).put(id, plot);
}
if (missing > 0) {
PlotSquared.log("&cSome names could not be identified:");
PlotSquared
.log("&7 - Empty quotes mean PlotMe just stored an unowned plot in the database");
PlotSquared.log(
"&7 - Names you have never seen before could be from people mistyping commands");
PlotSquared.log(
"&7 - Converting from a non-uuid version of PlotMe can't identify owners if the playerdata files are deleted (these plots will "
+ "remain unknown until the player connects)");
}
for (Entry<String, HashMap<PlotId, boolean[]>> entry : merges.entrySet()) {
String world = entry.getKey();
for (Entry<PlotId, boolean[]> entry2 : entry.getValue().entrySet()) {
HashMap<PlotId, Plot> newPlots = plots.get(world);
Plot plot = newPlots.get(entry2.getKey());
if (plot != null) {
plot.setMerged(entry2.getValue());
}
}
}
resultSet.close();
statement.close();
try {
PlotSquared.log(" - " + this.prefix + "Denied");
statement = connection.prepareStatement("SELECT * FROM `" + this.prefix + "Denied`");
resultSet = statement.executeQuery();
while (resultSet.next()) {
PlotId id = new PlotId(resultSet.getInt("idX"), resultSet.getInt("idZ"));
String name = resultSet.getString("player");
String world = LikePlotMeConverter.getWorld(resultSet.getString("world"));
UUID denied = UUIDHandler.getUUID(name, null);
if (denied == null) {
if ("*".equals(name)) {
denied = DBFunc.EVERYONE;
} else if (DBFunc.hasColumn(resultSet, "playerid")) {
byte[] bytes = resultSet.getBytes("playerid");
if (bytes != null) {
ByteBuffer bb = ByteBuffer.wrap(bytes);
long mostSigBits = bb.getLong();
long leastSigBits = bb.getLong();
denied = new UUID(mostSigBits, leastSigBits);
UUIDHandler.add(new StringWrapper(name), denied);
}
}
if (denied == null) {
PlotSquared.log("&6Could not identify denied for plot: " + id);
continue;
}
}
HashMap<PlotId, Plot> worldMap = plots.get(world);
if (worldMap != null) {
Plot plot = worldMap.get(id);
if (plot != null) {
plot.getDenied().add(denied);
}
}
}
statement = connection.prepareStatement("SELECT * FROM `" + this.plugin + "Allowed`");
resultSet = statement.executeQuery();
while (resultSet.next()) {
PlotId id = new PlotId(resultSet.getInt("idX"), resultSet.getInt("idZ"));
String name = resultSet.getString("player");
String world = LikePlotMeConverter.getWorld(resultSet.getString("world"));
UUID helper = UUIDHandler.getUUID(name, null);
if (helper == null) {
if ("*".equals(name)) {
helper = DBFunc.EVERYONE;
} else if (DBFunc.hasColumn(resultSet, "playerid")) {
byte[] bytes = resultSet.getBytes("playerid");
if (bytes != null) {
ByteBuffer bb = ByteBuffer.wrap(bytes);
long mostSigBits = bb.getLong();
long leastSigBits = bb.getLong();
helper = new UUID(mostSigBits, leastSigBits);
UUIDHandler.add(new StringWrapper(name), helper);
}
}
if (helper == null) {
PlotSquared.log("&6Could not identify helper for plot: " + id);
continue;
}
}
HashMap<PlotId, Plot> worldMap = plots.get(world);
if (worldMap != null) {
Plot plot = worldMap.get(id);
if (plot != null) {
plot.getTrusted().add(helper);
}
}
}
resultSet.close();
statement.close();
} catch (SQLException ignored) {
}
return plots;
}
@Override public boolean accepts(String version) {
return version == null || PlotSquared.get().canUpdate(version, "0.17.0") || PlotSquared
.get().canUpdate("0.999.999", version);
}
}

View File

@ -1,393 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.database.plotme;
import com.github.intellectualsites.plotsquared.bukkit.generator.BukkitPlotGenerator;
import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection;
import com.github.intellectualsites.plotsquared.configuration.MemorySection;
import com.github.intellectualsites.plotsquared.configuration.file.FileConfiguration;
import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.command.CommandException;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.atomic.AtomicBoolean;
public class LikePlotMeConverter {
private final String plugin;
public LikePlotMeConverter(String plugin) {
this.plugin = plugin;
}
public static String getWorld(String world) {
for (World newWorld : Bukkit.getWorlds()) {
if (newWorld.getName().equalsIgnoreCase(world)) {
return newWorld.getName();
}
}
return world;
}
private void sendMessage(String message) {
PlotSquared
.debug("&3PlotMe&8->&3" + PlotSquared.imp().getPluginName() + "&8: &7" + message);
}
public String getPlotMePath() {
return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator
+ plugin + File.separator;
}
public FileConfiguration getPlotMeConfig(String dataFolder) {
File plotMeFile = new File(dataFolder + "config.yml");
if (!plotMeFile.exists()) {
return null;
}
return YamlConfiguration.loadConfiguration(plotMeFile);
}
public Set<String> getPlotMeWorlds(FileConfiguration plotConfig) {
return plotConfig.getConfigurationSection("worlds").getKeys(false);
}
public void mergeWorldYml(FileConfiguration plotConfig) {
try {
File genConfig = new File(
"plugins" + File.separator + plugin + File.separator + "PlotMe-DefaultGenerator"
+ File.separator + "config.yml");
if (genConfig.exists()) {
YamlConfiguration yml = YamlConfiguration.loadConfiguration(genConfig);
for (String key : yml.getKeys(true)) {
if (!plotConfig.contains(key)) {
Object value = yml.get(key);
if (!(value instanceof MemorySection)) {
plotConfig.set(key, value);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void updateWorldYml(String location) {
try {
Path path = Paths.get(location);
File file = new File(location);
if (!file.exists()) {
return;
}
String content = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
String pluginName = PlotSquared.imp().getPluginName();
content = content.replace("PlotMe-DefaultGenerator", pluginName);
content = content.replace("PlotMe", pluginName);
content = content.replace("AthionPlots", pluginName);
content = content.replace("PlotZWorld", pluginName);
Files.write(path, content.getBytes(StandardCharsets.UTF_8));
} catch (IOException ignored) {
}
}
private void copyConfig(ConfigurationSection plotmeDgYml, String world) throws IOException {
String actualWorldName = getWorld(world);
String plotMeWorldName = world.toLowerCase();
Integer pathWidth = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
PlotSquared.get().worlds.set("worlds." + world + ".road.width", pathWidth);
int height = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".RoadHeight",
plotmeDgYml.getInt("worlds." + plotMeWorldName + ".GroundHeight", 64)); //
PlotSquared.get().worlds.set("worlds." + world + ".road.height", height);
PlotSquared.get().worlds.set("worlds." + world + ".wall.height", height);
PlotSquared.get().worlds.set("worlds." + world + ".plot.height", height);
int plotSize = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PlotSize", 32); //
PlotSquared.get().worlds.set("worlds." + world + ".plot.size", plotSize);
String wallblock = plotmeDgYml.getString("worlds." + plotMeWorldName + ".UnclaimedBorder",
plotmeDgYml.getString("worlds." + plotMeWorldName + ".WallBlock", "44")); //
PlotSquared.get().worlds.set("worlds." + world + ".wall.block", wallblock);
String claimed =
plotmeDgYml.getString("worlds." + plotMeWorldName + ".ProtectedWallBlock", "44:1"); //
PlotSquared.get().worlds.set("worlds." + world + ".wall.block_claimed", claimed);
String floor =
plotmeDgYml.getString("worlds." + plotMeWorldName + ".PlotFloorBlock", "2"); //
PlotSquared.get().worlds
.set("worlds." + world + ".plot.floor", Collections.singletonList(floor));
String filling = plotmeDgYml.getString("worlds." + plotMeWorldName + ".FillBlock", "3"); //
PlotSquared.get().worlds
.set("worlds." + world + ".plot.filling", Collections.singletonList(filling));
String road = plotmeDgYml.getString("worlds." + plotMeWorldName + ".RoadMainBlock", "5");
PlotSquared.get().worlds.set("worlds." + world + ".road.block", road);
PlotSquared.get().worlds.set("worlds." + actualWorldName + ".road.height", height);
PlotSquared.get().worlds.set("worlds." + actualWorldName + ".plot.height", height);
PlotSquared.get().worlds.set("worlds." + actualWorldName + ".wall.height", height);
PlotSquared.get().worlds.save(PlotSquared.get().worldsFile);
}
public boolean run(APlotMeConnector connector) {
try {
String dataFolder = getPlotMePath();
FileConfiguration plotConfig = getPlotMeConfig(dataFolder);
if (plotConfig == null) {
return false;
}
String version = plotConfig.getString("Version");
if (version == null) {
version = plotConfig.getString("version");
}
if (!connector.accepts(version)) {
return false;
}
PlotSquared.debug("&3Using connector: " + connector.getClass().getCanonicalName());
Connection connection = connector.getPlotMeConnection(plugin, plotConfig, dataFolder);
if (!connector.isValidConnection(connection)) {
sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue");
return false;
}
sendMessage(
"PlotMe conversion has started. To disable this, please set 'enabled-components -> plotme-converter' to false in the 'settings.yml'");
mergeWorldYml(plotConfig);
sendMessage("Connecting to PlotMe DB");
ArrayList<Plot> createdPlots = new ArrayList<>();
sendMessage("Collecting plot data");
String dbPrefix = "PlotMe".toLowerCase();
sendMessage(" - " + dbPrefix + "Plots");
final Set<String> worlds = getPlotMeWorlds(plotConfig);
if (Settings.Enabled_Components.PLOTME_CONVERTER) {
sendMessage("Updating bukkit.yml");
updateWorldYml("bukkit.yml");
updateWorldYml("plugins/Multiverse-Core/worlds.yml");
for (String world : plotConfig.getConfigurationSection("worlds").getKeys(false)) {
sendMessage("Copying config for: " + world);
try {
String actualWorldName = getWorld(world);
connector.copyConfig(plotConfig, world, actualWorldName);
PlotSquared.get().worlds.save(PlotSquared.get().worldsFile);
} catch (IOException e) {
e.printStackTrace();
sendMessage("&c-- &lFailed to save configuration for world '" + world
+ "'\nThis will need to be done using the setup command, or manually");
}
}
}
HashMap<String, HashMap<PlotId, Plot>> plots = connector.getPlotMePlots(connection);
int plotCount = 0;
for (Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
plotCount += entry.getValue().size();
}
if (!Settings.Enabled_Components.PLOTME_CONVERTER) {
return false;
}
sendMessage(" - " + dbPrefix + "Allowed");
sendMessage("Collected " + plotCount + " plots from PlotMe");
File plotmeDgFile = new File(
dataFolder + File.separator + "PlotMe-DefaultGenerator" + File.separator
+ "config.yml");
if (plotmeDgFile.exists()) {
YamlConfiguration plotmeDgYml = YamlConfiguration.loadConfiguration(plotmeDgFile);
try {
HashSet<String> allWorlds = new HashSet<>(plots.keySet());
allWorlds.addAll(worlds);
for (String world : allWorlds) {
copyConfig(plotmeDgYml, world);
}
} catch (IOException ignored) {
ignored.printStackTrace();
}
}
for (Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
String world = entry.getKey();
PlotArea area = PlotSquared.get().getPlotArea(world, null);
int duplicate = 0;
if (area != null) {
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
if (area.getOwnedPlotAbs(entry2.getKey()) != null) {
duplicate++;
} else {
createdPlots.add(entry2.getValue());
}
}
if (duplicate > 0) {
PlotSquared.debug("&c[WARNING] Found " + duplicate
+ " duplicate plots already in DB for world: '" + world
+ "'. Have you run the converter already?");
}
} else {
if (PlotSquared.get().plots_tmp != null) {
HashMap<PlotId, Plot> map = PlotSquared.get().plots_tmp.get(world);
if (map != null) {
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
if (map.containsKey(entry2.getKey())) {
duplicate++;
} else {
createdPlots.add(entry2.getValue());
}
}
if (duplicate > 0) {
PlotSquared.debug("&c[WARNING] Found " + duplicate
+ " duplicate plots already in DB for world: '" + world
+ "'. Have you run the converter already?");
}
continue;
}
}
createdPlots.addAll(entry.getValue().values());
}
}
sendMessage("Creating plot DB");
Thread.sleep(1000);
final AtomicBoolean done = new AtomicBoolean(false);
DBFunc.createPlotsAndData(createdPlots, new Runnable() {
@Override public void run() {
if (done.get()) {
done();
sendMessage("&aDatabase conversion is now complete!");
PlotSquared.debug("&c - Stop the server");
PlotSquared.debug(
"&c - Disable 'plotme-converter' and 'plotme-convert.cache-uuids' in the settings.yml");
PlotSquared.debug(
"&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
PlotSquared.debug("&c - Start the server");
PlotSquared.get().setPlots(DBFunc.getPlots());
} else {
sendMessage(
"&cPlease wait until database conversion is complete. You will be notified with instructions when this happens!");
done.set(true);
}
}
});
sendMessage("Saving configuration...");
try {
PlotSquared.get().worlds.save(PlotSquared.get().worldsFile);
} catch (IOException ignored) {
sendMessage(" - &cFailed to save configuration.");
}
TaskManager.runTask(new Runnable() {
@Override public void run() {
try {
boolean mv = false;
boolean mw = false;
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null)
&& Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
mv = true;
} else if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null)
&& Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
mw = true;
}
for (String worldName : worlds) {
World world = Bukkit.getWorld(getWorld(worldName));
if (world == null) {
sendMessage(
"&cInvalid world in PlotMe configuration: " + worldName);
continue;
}
String actualWorldName = world.getName();
sendMessage(
"Reloading generator for world: '" + actualWorldName + "'...");
if (!Bukkit.getWorlds().isEmpty() && Bukkit.getWorlds().get(0).getName()
.equals(worldName)) {
sendMessage(
"&cYou need to stop the server to reload this world properly");
} else {
PlotSquared.get().removePlotAreas(actualWorldName);
if (mv) {
// unload world with MV
Bukkit.getServer()
.dispatchCommand(Bukkit.getServer().getConsoleSender(),
"mv unload " + actualWorldName);
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
}
// load world with MV
Bukkit.getServer()
.dispatchCommand(Bukkit.getServer().getConsoleSender(),
"mv import " + actualWorldName + " normal -g "
+ PlotSquared.imp().getPluginName());
} else if (mw) {
// unload world with MW
Bukkit.getServer()
.dispatchCommand(Bukkit.getServer().getConsoleSender(),
"mw unload " + actualWorldName);
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
}
// load world with MW
Bukkit.getServer()
.dispatchCommand(Bukkit.getServer().getConsoleSender(),
"mw create " + actualWorldName + " plugin:"
+ PlotSquared.imp().getPluginName());
} else {
// Load using Bukkit API
// - User must set generator manually
Bukkit.getServer().unloadWorld(world, true);
World myWorld = WorldCreator.name(actualWorldName).generator(
new BukkitPlotGenerator(
PlotSquared.get().IMP.getDefaultGenerator()))
.createWorld();
myWorld.save();
}
}
}
} catch (CommandException e) {
e.printStackTrace();
}
if (done.get()) {
done();
sendMessage("&aDatabase conversion is now complete!");
PlotSquared.debug("&c - Stop the server");
PlotSquared.debug(
"&c - Disable 'plotme-converter' and 'plotme-convert.cache-uuids' in the settings.yml");
PlotSquared.debug(
"&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
PlotSquared.debug("&c - Start the server");
} else {
sendMessage(
"&cPlease wait until database conversion is complete. You will be notified with instructions when this happens!");
done.set(true);
}
}
});
} catch (InterruptedException | SQLException e) {
e.printStackTrace();
PlotSquared.debug("&/end/");
}
return true;
}
public void done() {
PlotSquared.get().setPlots(DBFunc.getPlots());
}
}

View File

@ -1,197 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.database.plotme;
import com.github.intellectualsites.plotsquared.configuration.file.FileConfiguration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.database.SQLite;
import com.github.intellectualsites.plotsquared.plot.object.*;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import java.io.File;
import java.sql.*;
import java.util.HashMap;
import java.util.UUID;
public class PlotMeConnector_017 extends APlotMeConnector {
private String plugin;
@Override public Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig,
String dataFolder) {
this.plugin = plugin.toLowerCase();
try {
if (plotConfig.getBoolean("usemySQL")) {
String user = plotConfig.getString("mySQLuname");
String password = plotConfig.getString("mySQLpass");
String con = plotConfig.getString("mySQLconn");
return DriverManager.getConnection(con, user, password);
} else {
File file = new File(dataFolder + File.separator + "plotmecore.db");
if (file.exists()) {
return new SQLite(file).openConnection();
}
return new SQLite(new File(dataFolder + File.separator + "plots.db"))
.openConnection();
}
} catch (SQLException | ClassNotFoundException e) {
e.printStackTrace();
}
return null;
}
@Override public HashMap<String, HashMap<PlotId, Plot>> getPlotMePlots(Connection connection)
throws SQLException {
ResultSet resultSet;
PreparedStatement statement;
HashMap<String, Integer> plotWidth = new HashMap<>();
HashMap<String, Integer> roadWidth = new HashMap<>();
HashMap<Integer, Plot> plots = new HashMap<>();
HashMap<String, HashMap<PlotId, boolean[]>> merges = new HashMap<>();
try {
statement =
connection.prepareStatement("SELECT * FROM `" + this.plugin + "core_plots`");
resultSet = statement.executeQuery();
} catch (SQLException e) {
PlotSquared.debug("========= Table does not exist =========");
e.printStackTrace();
PlotSquared.debug("=======================================");
PlotSquared.debug(
"&8 - &7The database does not match the version specified in the PlotMe config");
PlotSquared.debug(
"&8 - &7Please correct this, or if you are unsure, the most common is 0.16.3");
return null;
}
boolean checkUUID = DBFunc.hasColumn(resultSet, "ownerID");
boolean merge =
!"plotme".equals(this.plugin) && Settings.Enabled_Components.PLOTME_CONVERTER;
while (resultSet.next()) {
int key = resultSet.getInt("plot_id");
PlotId id = new PlotId(resultSet.getInt("plotX"), resultSet.getInt("plotZ"));
String name = resultSet.getString("owner");
String world = LikePlotMeConverter.getWorld(resultSet.getString("world"));
if (!plots.containsKey(world) && merge) {
int plot = PlotSquared.get().worlds.getInt("worlds." + world + ".plot.size");
int path = PlotSquared.get().worlds.getInt("worlds." + world + ".road.width");
plotWidth.put(world, plot);
roadWidth.put(world, path);
merges.put(world, new HashMap<PlotId, boolean[]>());
}
if (merge) {
int tx = resultSet.getInt("topX");
int tz = resultSet.getInt("topZ");
int bx = resultSet.getInt("bottomX") - 1;
int bz = resultSet.getInt("bottomZ") - 1;
int path = roadWidth.get(world);
int plot = plotWidth.get(world);
Location top = getPlotTopLocAbs(path, plot, id);
Location bot = getPlotBottomLocAbs(path, plot, id);
if (tx > top.getX()) {
setMerged(merges, world, id, 1);
}
if (tz > top.getZ()) {
setMerged(merges, world, id, 2);
}
if (bx < bot.getX()) {
setMerged(merges, world, id, 3);
}
if (bz > bot.getZ()) {
setMerged(merges, world, id, 0);
}
}
UUID owner = UUIDHandler.getUUID(name, null);
if (owner == null) {
if (name.equals("*")) {
owner = DBFunc.EVERYONE;
} else {
if (checkUUID) {
byte[] bytes = resultSet.getBytes("ownerid");
if (bytes != null) {
owner = UUID.nameUUIDFromBytes(bytes);
UUIDHandler.add(new StringWrapper(name), owner);
}
}
if (owner == null) {
PlotSquared.log(
"&cCould not identify owner for plot: " + id + " -> '" + name + '\'');
continue;
}
}
} else {
UUIDHandler.add(new StringWrapper(name), owner);
}
Plot plot = new Plot(PlotArea.createGeneric(world), id, owner);
plots.put(key, plot);
}
for (Plot plot : plots.values()) {
HashMap<PlotId, boolean[]> mergeMap = merges.get(plot.getWorldName());
if (mergeMap != null) {
if (mergeMap.containsKey(plot.getId())) {
plot.setMerged(mergeMap.get(plot.getId()));
}
}
}
resultSet.close();
statement.close();
try {
PlotSquared.log(" - " + this.plugin + "core_denied");
statement =
connection.prepareStatement("SELECT * FROM `" + this.plugin + "core_denied`");
resultSet = statement.executeQuery();
while (resultSet.next()) {
int key = resultSet.getInt("plot_id");
Plot plot = plots.get(key);
if (plot == null) {
PlotSquared
.log("&6Denied (" + key + ") references deleted plot; ignoring entry.");
continue;
}
String player = resultSet.getString("player");
UUID denied = player.equals("*") ? DBFunc.EVERYONE : UUID.fromString(player);
plot.getDenied().add(denied);
}
PlotSquared.log(" - " + this.plugin + "core_allowed");
statement =
connection.prepareStatement("SELECT * FROM `" + this.plugin + "core_allowed`");
resultSet = statement.executeQuery();
while (resultSet.next()) {
int key = resultSet.getInt("plot_id");
Plot plot = plots.get(key);
if (plot == null) {
PlotSquared
.log("&6Allowed (" + key + ") references deleted plot; ignoring entry.");
continue;
}
String player = resultSet.getString("player");
UUID allowed = player.equals("*") ? DBFunc.EVERYONE : UUID.fromString(player);
plot.getTrusted().add(allowed);
}
resultSet.close();
statement.close();
} catch (SQLException e) {
e.printStackTrace();
}
HashMap<String, HashMap<PlotId, Plot>> processed = new HashMap<>();
for (Plot plot : plots.values()) {
HashMap<PlotId, Plot> map = processed.get(plot.getWorldName());
if (map == null) {
map = new HashMap<>();
processed.put(plot.getWorldName(), map);
}
map.put(plot.getId(), plot);
}
return processed;
}
@Override public boolean accepts(String version) {
if (version == null) {
return false;
}
return !PlotSquared.get().canUpdate(version, "0.17");
}
}

View File

@ -1,63 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.events;
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
import com.github.intellectualsites.plotsquared.plot.object.PlotCluster;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* Called when a flag is removed from a plot.
*/
public class ClusterFlagRemoveEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final PlotCluster cluster;
private final Flag flag;
private boolean cancelled;
/**
* PlotFlagRemoveEvent: Called when a flag is removed from a plot.
*
* @param flag Flag that was removed
* @param cluster PlotCluster from which the flag was removed
*/
public ClusterFlagRemoveEvent(Flag flag, PlotCluster cluster) {
this.cluster = cluster;
this.flag = flag;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* Get the cluster involved.
*
* @return PlotCluster
*/
public PlotCluster getCluster() {
return this.cluster;
}
/**
* Get the flag involved.
*
* @return Flag
*/
public Flag getFlag() {
return this.flag;
}
@Override public HandlerList getHandlers() {
return handlers;
}
@Override public boolean isCancelled() {
return this.cancelled;
}
@Override public void setCancelled(boolean b) {
this.cancelled = b;
}
}

View File

@ -1,59 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.events;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final Plot plot;
private final boolean auto;
private boolean cancelled;
/**
* PlayerClaimPlotEvent: Called when a plot is claimed.
*
* @param player Player that claimed the plot
* @param plot Plot that was claimed
*/
public PlayerClaimPlotEvent(Player player, Plot plot, boolean auto) {
super(player);
this.plot = plot;
this.auto = auto;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* Get the plot involved
*
* @return Plot
*/
public Plot getPlot() {
return this.plot;
}
/**
* @return true if it was an automated claim, else false
*/
public boolean wasAuto() {
return this.auto;
}
@Override public HandlerList getHandlers() {
return handlers;
}
@Override public boolean isCancelled() {
return this.cancelled;
}
@Override public void setCancelled(boolean b) {
this.cancelled = b;
}
}

View File

@ -1,40 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.events;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
public class PlayerEnterPlotEvent extends PlayerEvent {
private static final HandlerList handlers = new HandlerList();
private final Plot plot;
/**
* Called when a player leaves a plot.
*
* @param player Player that entered the plot
* @param plot Plot that was entered
*/
public PlayerEnterPlotEvent(Player player, Plot plot) {
super(player);
this.plot = plot;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* Get the plot involved.
*
* @return Plot
*/
public Plot getPlot() {
return this.plot;
}
@Override public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -1,44 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.events;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
/**
*/
public class PlayerLeavePlotEvent extends PlayerEvent {
private static final HandlerList handlers = new HandlerList();
private final Plot plot;
/**
* PlayerLeavePlotEvent: Called when a player leaves a plot
*
* @param player Player that left the plot
* @param plot Plot that was left
*/
public PlayerLeavePlotEvent(Player player, Plot plot) {
super(player);
this.plot = plot;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* Get the plot involved
*
* @return Plot
*/
public Plot getPlot() {
return this.plot;
}
@Override public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -1,65 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.events;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import java.util.UUID;
public class PlayerPlotDeniedEvent extends PlotEvent {
private static final HandlerList handlers = new HandlerList();
private final Player initiator;
private final boolean added;
private final UUID player;
/**
* PlayerPlotDeniedEvent: Called when the denied UUID list is modified for a plot.
*
* @param initiator Player that initiated the event
* @param plot Plot in which the event occurred
* @param player Player that was denied/un-denied
* @param added true of add to deny list, false if removed
*/
public PlayerPlotDeniedEvent(Player initiator, Plot plot, UUID player, boolean added) {
super(plot);
this.initiator = initiator;
this.added = added;
this.player = player;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* If a user was added.
*
* @return boolean
*/
public boolean wasAdded() {
return this.added;
}
/**
* The player added/removed.
*
* @return UUID
*/
public UUID getPlayer() {
return this.player;
}
/**
* The player initiating the action.
*
* @return Player
*/
public Player getInitiator() {
return this.initiator;
}
@Override public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -1,69 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.events;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import java.util.UUID;
/**
*/
public class PlayerPlotHelperEvent extends PlotEvent {
private static final HandlerList handlers = new HandlerList();
private final Player initiator;
private final boolean added;
private final UUID player;
/**
* PlayerPlotHelperEvent: Called when a plot helper is added/removed
*
* @param initiator Player that initiated the event
* @param plot Plot in which the event occurred
* @param player Player that was added/removed from the helper list
* @param added true of the player was added, false if the player was removed
*/
public PlayerPlotHelperEvent(Player initiator, Plot plot, UUID player, boolean added) {
super(plot);
this.initiator = initiator;
this.added = added;
this.player = player;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* If a player was added
*
* @return boolean
*/
public boolean wasAdded() {
return this.added;
}
/**
* The UUID added/removed
*
* @return UUID
*/
public UUID getPlayer() {
return this.player;
}
/**
* The player initiating the action
*
* @return Player
*/
public Player getInitiator() {
return this.initiator;
}
@Override public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -1,69 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.events;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import java.util.UUID;
/**
*/
public class PlayerPlotTrustedEvent extends PlotEvent {
private static final HandlerList handlers = new HandlerList();
private final Player initiator;
private final boolean added;
private final UUID player;
/**
* PlayerPlotTrustedEvent: Called when a plot trusted user is added/removed
*
* @param initiator Player that initiated the event
* @param plot Plot in which the event occurred
* @param player Player that was added/removed from the trusted list
* @param added true of the player was added, false if the player was removed
*/
public PlayerPlotTrustedEvent(Player initiator, Plot plot, UUID player, boolean added) {
super(plot);
this.initiator = initiator;
this.added = added;
this.player = player;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* If a player was added
*
* @return boolean
*/
public boolean wasAdded() {
return this.added;
}
/**
* The UUID added/removed
*
* @return UUID
*/
public UUID getPlayer() {
return this.player;
}
/**
* The player initiating the action
*
* @return Player
*/
public Player getInitiator() {
return this.initiator;
}
@Override public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -1,66 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.events;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
/**
* Called when a player teleports to a plot
*/
public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final Location from;
private final Plot plot;
private boolean cancelled;
/**
* PlayerTeleportToPlotEvent: Called when a player teleports to a plot
*
* @param player That was teleported
* @param from Start location
* @param plot Plot to which the player was teleported
*/
public PlayerTeleportToPlotEvent(Player player, Location from, Plot plot) {
super(player);
this.from = from;
this.plot = plot;
}
public static HandlerList getHandlerList() {
return handlers;
}
@Override public HandlerList getHandlers() {
return handlers;
}
/**
* Get the from location
*
* @return Location
*/
public Location getFrom() {
return this.from;
}
/**
* Get the plot involved
*
* @return Plot
*/
public Plot getPlot() {
return this.plot;
}
@Override public boolean isCancelled() {
return this.cancelled;
}
@Override public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}

View File

@ -1,105 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.events;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import java.util.UUID;
public class PlotChangeOwnerEvent extends PlotEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final Player initiator;
private final UUID newOwner;
private final UUID oldOwner;
private boolean hasOldOwner;
private boolean cancelled;
/**
* PlotChangeOwnerEvent: Called when a plot's owner is change.
*
* @param newOwner The new owner of the plot
* @param oldOwner The old owner of the plot
* @param plot The plot having its owner changed
*/
public PlotChangeOwnerEvent(Player initiator, Plot plot, UUID oldOwner, UUID newOwner,
boolean hasOldOwner) {
super(plot);
this.initiator = initiator;
this.newOwner = newOwner;
this.oldOwner = oldOwner;
this.hasOldOwner = hasOldOwner;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* Get the PlotId.
*
* @return PlotId
*/
public PlotId getPlotId() {
return getPlot().getId();
}
/**
* Get the world name.
*
* @return String
*/
public String getWorld() {
return getPlot().getWorldName();
}
/**
* Get the change-owner initator
*
* @return Player
*/
public Player getInitiator() {
return this.initiator;
}
/**
* Get the old owner of the plot. Null if not exists.
*
* @return UUID
*/
public UUID getOldOwner() {
return this.oldOwner;
}
/**
* Get the new owner of the plot
*
* @return UUID
*/
public UUID getNewOwner() {
return this.newOwner;
}
/**
* Get if the plot had an old owner
*
* @return boolean
*/
public boolean hasOldOwner() {
return this.hasOldOwner;
}
@Override public HandlerList getHandlers() {
return handlers;
}
@Override public boolean isCancelled() {
return this.cancelled;
}
@Override public void setCancelled(boolean b) {
this.cancelled = b;
}
}

View File

@ -1,53 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.events;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
/**
* Called when a plot is cleared
*/
public class PlotClearEvent extends PlotEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
public PlotClearEvent(Plot plot) {
super(plot);
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* Get the PlotId.
*
* @return PlotId
*/
public PlotId getPlotId() {
return getPlot().getId();
}
/**
* Get the world name.
*
* @return String
*/
public String getWorld() {
return getPlot().getWorldName();
}
@Override public HandlerList getHandlers() {
return handlers;
}
@Override public boolean isCancelled() {
return this.cancelled;
}
@Override public void setCancelled(boolean b) {
this.cancelled = b;
}
}

View File

@ -1,54 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.events;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import org.bukkit.event.HandlerList;
/**
* Called when a plot component is set
*/
public class PlotComponentSetEvent extends PlotEvent {
private static final HandlerList handlers = new HandlerList();
private final String component;
public PlotComponentSetEvent(Plot plot, String component) {
super(plot);
this.component = component;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* Get the PlotId
*
* @return PlotId
*/
public PlotId getPlotId() {
return getPlot().getId();
}
/**
* Get the world name
*
* @return String
*/
public String getWorld() {
return getPlot().getWorldName();
}
/**
* Get the component which was set
*
* @return Component name
*/
public String getComponent() {
return this.component;
}
@Override public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -1,43 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.events;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import org.bukkit.event.HandlerList;
/**
* Called when a plot is deleted
*/
public class PlotDeleteEvent extends PlotEvent {
private static final HandlerList handlers = new HandlerList();
public PlotDeleteEvent(Plot plot) {
super(plot);
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* Get the PlotId
*
* @return PlotId
*/
public PlotId getPlotId() {
return getPlot().getId();
}
/**
* Get the world name
*
* @return String
*/
public String getWorld() {
return getPlot().getWorldName();
}
@Override public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -1,18 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.events;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import org.bukkit.event.Event;
public abstract class PlotEvent extends Event {
private final Plot plot;
public PlotEvent(Plot plot) {
this.plot = plot;
}
public final Plot getPlot() {
return this.plot;
}
}

View File

@ -1,52 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.events;
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
/**
* Called when a Flag is added to a plot.
*/
public class PlotFlagAddEvent extends PlotEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final Flag flag;
private boolean cancelled;
/**
* PlotFlagAddEvent: Called when a Flag is added to a plot.
*
* @param flag Flag that was added
* @param plot Plot to which the flag was added
*/
public PlotFlagAddEvent(Flag flag, Plot plot) {
super(plot);
this.flag = flag;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* Get the flag involved.
*
* @return Flag
*/
public Flag getFlag() {
return this.flag;
}
@Override public HandlerList getHandlers() {
return handlers;
}
@Override public final boolean isCancelled() {
return this.cancelled;
}
@Override public final void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}

View File

@ -1,52 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.events;
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
/**
* Called when a flag is removed from a plot
*/
public class PlotFlagRemoveEvent extends PlotEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final Flag flag;
private boolean cancelled;
/**
* PlotFlagRemoveEvent: Called when a flag is removed from a plot
*
* @param flag Flag that was removed
* @param plot Plot from which the flag was removed
*/
public PlotFlagRemoveEvent(Flag flag, Plot plot) {
super(plot);
this.flag = flag;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* Get the flag involved
*
* @return Flag
*/
public Flag getFlag() {
return this.flag;
}
@Override public HandlerList getHandlers() {
return handlers;
}
@Override public final boolean isCancelled() {
return this.cancelled;
}
@Override public final void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}

View File

@ -1,59 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.events;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import org.bukkit.World;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import java.util.ArrayList;
public class PlotMergeEvent extends PlotEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final ArrayList<PlotId> plots;
private final World world;
private boolean cancelled;
/**
* PlotMergeEvent: Called when plots are merged
*
* @param world World in which the event occurred
* @param plot Plot that was merged
* @param plots A list of plots involved in the event
*/
public PlotMergeEvent(World world, Plot plot, ArrayList<PlotId> plots) {
super(plot);
this.world = world;
this.plots = plots;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* Get the plots being added.
*
* @return Plot
*/
public ArrayList<PlotId> getPlots() {
return this.plots;
}
public World getWorld() {
return this.world;
}
@Override public HandlerList getHandlers() {
return handlers;
}
@Override public boolean isCancelled() {
return this.cancelled;
}
@Override public void setCancelled(boolean b) {
this.cancelled = b;
}
}

View File

@ -1,49 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.events;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.Rating;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
public class PlotRateEvent extends PlotEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final PlotPlayer rater;
private Rating rating;
private boolean cancelled = false;
public PlotRateEvent(PlotPlayer rater, Rating rating, Plot plot) {
super(plot);
this.rater = rater;
this.rating = rating;
}
public static HandlerList getHandlerList() {
return handlers;
}
public PlotPlayer getRater() {
return this.rater;
}
public Rating getRating() {
return this.rating;
}
public void setRating(Rating rating) {
this.rating = rating;
}
@Override public HandlerList getHandlers() {
return handlers;
}
@Override public boolean isCancelled() {
return this.cancelled;
}
@Override public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}

View File

@ -1,64 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.events;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import org.bukkit.World;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import java.util.ArrayList;
public class PlotUnlinkEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final ArrayList<PlotId> plots;
private final World world;
private final PlotArea area;
private boolean cancelled;
/**
* Called when a mega-plot is unlinked.
*
* @param world World in which the event occurred
* @param plots Plots that are involved in the event
*/
public PlotUnlinkEvent(World world, PlotArea area, ArrayList<PlotId> plots) {
this.plots = plots;
this.world = world;
this.area = area;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* Get the plots involved.
*
* @return The {@link PlotId}'s of the plots involved
*/
public ArrayList<PlotId> getPlots() {
return this.plots;
}
public World getWorld() {
return this.world;
}
public PlotArea getArea() {
return this.area;
}
@Override public HandlerList getHandlers() {
return handlers;
}
@Override public boolean isCancelled() {
return this.cancelled;
}
@Override public void setCancelled(boolean b) {
this.cancelled = b;
}
}

View File

@ -1,30 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.generator;
import com.github.intellectualsites.plotsquared.plot.generator.AugmentedUtils;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import java.util.Random;
public class BukkitAugmentedGenerator extends BlockPopulator {
private static BukkitAugmentedGenerator generator;
public static BukkitAugmentedGenerator get(World world) {
for (BlockPopulator populator : world.getPopulators()) {
if (populator instanceof BukkitAugmentedGenerator) {
return (BukkitAugmentedGenerator) populator;
}
}
if (generator == null) {
generator = new BukkitAugmentedGenerator();
}
world.getPopulators().add(generator);
return generator;
}
@Override public void populate(World world, Random r, Chunk chunk) {
AugmentedUtils.generate(world.getName(), chunk.getX(), chunk.getZ(), null);
}
}

View File

@ -1,333 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.generator;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
import com.github.intellectualsites.plotsquared.bukkit.util.block.GenChunk;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper;
import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator;
import com.github.intellectualsites.plotsquared.plot.object.*;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SingleWorldGenerator;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import java.util.*;
public class BukkitPlotGenerator extends ChunkGenerator
implements GeneratorWrapper<ChunkGenerator> {
private final GenChunk chunkSetter;
private final IndependentPlotGenerator plotGenerator;
private final ChunkGenerator platformGenerator;
private final boolean full;
private final HashMap<ChunkLoc, byte[][]> dataMap = new HashMap<>();
private List<BlockPopulator> populators;
private boolean loaded = false;
public BukkitPlotGenerator(IndependentPlotGenerator generator) {
if (generator == null) {
throw new IllegalArgumentException("Generator may not be null!");
}
this.plotGenerator = generator;
this.platformGenerator = this;
populators = new ArrayList<>();
this.populators.add(new BlockPopulator() {
private LocalBlockQueue queue;
@Override public void populate(World world, Random r, Chunk c) {
if (queue == null) {
queue = GlobalBlockQueue.IMP.getNewQueue(world.getName(), false);
}
PlotArea area = PlotSquared.get().getPlotArea(world.getName(), null);
ChunkWrapper wrap = new ChunkWrapper(area.worldname, c.getX(), c.getZ());
ScopedLocalBlockQueue chunk = queue.getForChunk(wrap.x, wrap.z);
if (BukkitPlotGenerator.this.plotGenerator.populateChunk(chunk, area)) {
queue.flush();
}
}
});
this.chunkSetter = new GenChunk(null, null);
this.full = true;
MainUtil.initCache();
}
public BukkitPlotGenerator(final String world, final ChunkGenerator cg) {
if (cg instanceof BukkitPlotGenerator) {
throw new IllegalArgumentException("ChunkGenerator: " + cg.getClass().getName()
+ " is already a BukkitPlotGenerator!");
}
this.full = false;
PlotSquared.debug("BukkitPlotGenerator does not fully support: " + cg);
this.platformGenerator = cg;
this.plotGenerator = new IndependentPlotGenerator() {
@Override public void processSetup(SetupObject setup) {
}
@Override public void initialize(PlotArea area) {
}
@Override public PlotManager getNewPlotManager() {
return PlotSquared.get().IMP.getDefaultGenerator().getNewPlotManager();
}
@Override public String getName() {
return cg.getClass().getName();
}
@Override
public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
return PlotSquared.get().IMP.getDefaultGenerator()
.getNewPlotArea(world, id, min, max);
}
@Override
public void generateChunk(final ScopedLocalBlockQueue result, PlotArea settings) {
World w = BukkitUtil.getWorld(world);
Location min = result.getMin();
int cx = min.getX() >> 4;
int cz = min.getZ() >> 4;
Random r = new Random(MathMan.pair((short) cx, (short) cz));
BiomeGrid grid = new BiomeGrid() {
@Override public void setBiome(int x, int z, Biome biome) {
result.setBiome(x, z, biome.name());
}
@Override public Biome getBiome(int arg0, int arg1) {
return Biome.FOREST;
}
};
try {
// ChunkData will spill a bit
ChunkData data = cg.generateChunkData(w, r, cx, cz, grid);
if (data != null) {
return;
}
} catch (Throwable ignored) {
}
/* TODO: Redo this
// Populator spillage
short[][] tmp = cg.generateExtBlockSections(w, r, cx, cz, grid);
if (tmp != null) {
for (int i = 0; i < tmp.length; i++) {
short[] section = tmp[i];
if (section == null) {
if (i < 7) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = i << 4; y < (i << 4) + 16; y++) {
result.setBlock(x, y, z, PlotBlock.get("air"));
}
}
}
}
continue;
}
for (int j = 0; j < section.length; j++) {
int x = MainUtil.x_loc[i][j];
int y = MainUtil.y_loc[i][j];
int z = MainUtil.z_loc[i][j];
result.setBlock(x, y, z, section[j], (byte) 0);
}
}
}
*/
for (BlockPopulator populator : cg.getDefaultPopulators(w)) {
populator.populate(w, r, w.getChunkAt(cx, cz));
}
}
};
this.chunkSetter = new GenChunk(null, new ChunkWrapper(world, 0, 0));
MainUtil.initCache();
}
@Override public void augment(PlotArea area) {
BukkitAugmentedGenerator.get(BukkitUtil.getWorld(area.worldname));
}
@Override public boolean isFull() {
return this.full;
}
@Override public IndependentPlotGenerator getPlotGenerator() {
return this.plotGenerator;
}
@Override public ChunkGenerator getPlatformGenerator() {
return this.platformGenerator;
}
@Override public List<BlockPopulator> getDefaultPopulators(World world) {
try {
if (!this.loaded) {
String name = world.getName();
PlotSquared.get().loadWorld(name, this);
Set<PlotArea> areas = PlotSquared.get().getPlotAreas(name);
if (!areas.isEmpty()) {
PlotArea area = areas.iterator().next();
if (!area.MOB_SPAWNING) {
if (!area.SPAWN_EGGS) {
world.setSpawnFlags(false, false);
}
world.setAmbientSpawnLimit(0);
world.setAnimalSpawnLimit(0);
world.setMonsterSpawnLimit(0);
world.setWaterAnimalSpawnLimit(0);
} else {
world.setSpawnFlags(true, true);
world.setAmbientSpawnLimit(-1);
world.setAnimalSpawnLimit(-1);
world.setMonsterSpawnLimit(-1);
world.setWaterAnimalSpawnLimit(-1);
}
}
this.loaded = true;
}
} catch (Exception e) {
e.printStackTrace();
}
ArrayList<BlockPopulator> toAdd = new ArrayList<>();
List<BlockPopulator> existing = world.getPopulators();
if (populators == null && platformGenerator != null) {
populators = new ArrayList<>(platformGenerator.getDefaultPopulators(world));
}
for (BlockPopulator populator : this.populators) {
if (!existing.contains(populator)) {
toAdd.add(populator);
}
}
return toAdd;
}
@Override
public ChunkData generateChunkData(World world, Random random, int cx, int cz, BiomeGrid grid) {
GenChunk result = this.chunkSetter;
if (this.getPlotGenerator() instanceof SingleWorldGenerator) {
if (result.getCd() != null) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
grid.setBiome(x, z, Biome.PLAINS);
}
}
return result.getCd();
}
}
// Set the chunk location
result.setChunk(new ChunkWrapper(world.getName(), cx, cz));
// Set the result data
result.setCd(createChunkData(world));
result.grid = grid;
result.result = generateExtBlockSections(world, random, cx, cz, grid);
// Catch any exceptions (as exceptions usually thrown)
try {
// Fill the result data if necessary
if (this.platformGenerator != this) {
return this.platformGenerator.generateChunkData(world, random, cx, cz, grid);
} else {
generate(world, result);
}
} catch (Throwable e) {
e.printStackTrace();
}
// Return the result data
return result.getCd();
}
private void generate(World world, ScopedLocalBlockQueue result) {
// Load if improperly loaded
if (!this.loaded) {
String name = world.getName();
PlotSquared.get().loadWorld(name, this);
this.loaded = true;
}
// Process the chunk
if (ChunkManager.preProcessChunk(result)) {
return;
}
PlotArea area = PlotSquared.get().getPlotArea(world.getName(), null);
try {
this.plotGenerator.generateChunk(this.chunkSetter, area);
} catch (Throwable e) {
// Recover from generator error
e.printStackTrace();
}
ChunkManager.postProcessChunk(result);
}
public PlotBlock[][] generateExtBlockSections(World world, Random r, int cx, int cz,
BiomeGrid grid) {
GenChunk result = this.chunkSetter;
// Set the chunk location
result.setChunk(new ChunkWrapper(world.getName(), cx, cz));
// Set the result data
result.result = new PlotBlock[16][];
result.grid = grid;
// Catch any exceptions (as exceptions usually thrown)
try {
if (this.platformGenerator != this) {
final ChunkData chunkData =
this.platformGenerator.generateChunkData(world, r, cx, cz, grid);
final PlotBlock[][] blocks = new PlotBlock[world.getMaxHeight() / 16][];
// section ID = Y >> 4
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = 0; y < world.getMaxHeight(); y++) {
if (blocks[y >> 4] == null) {
blocks[y >> 4] = new PlotBlock[4096];
}
blocks[y >> 4][((y & 0xF) << 8) | (z << 4) | x] =
PlotBlock.get(chunkData.getType(x, y, z));
}
}
}
} else {
generate(world, result);
}
} catch (Throwable e) {
e.printStackTrace();
}
// Return the result data
return result.result;
}
/**
* Allow spawning everywhere.
*
* @param world Ignored
* @param x Ignored
* @param z Ignored
* @return always true
*/
@Override public boolean canSpawn(World world, int x, int z) {
return true;
}
@Override public String toString() {
if (this.platformGenerator == this) {
return this.plotGenerator.getName();
}
if (this.platformGenerator == null) {
return "null";
} else {
return this.platformGenerator.getClass().getName();
}
}
@Override public boolean equals(Object obj) {
if (obj == null) {
return false;
}
return toString().equals(obj.toString()) || toString().equals(obj.getClass().getName());
}
}

View File

@ -1,292 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.listeners;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.C;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.RefClass;
import com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.RefField;
import com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.RefMethod;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
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.BlockPhysicsEvent;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import java.lang.reflect.Method;
import java.util.HashSet;
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getRefClass;
@SuppressWarnings("unused") public class ChunkListener implements Listener {
private RefMethod methodGetHandleChunk;
private RefField mustSave;
private Chunk lastChunk;
private boolean ignoreUnload = false;
public ChunkListener() {
if (Settings.Chunk_Processor.AUTO_TRIM) {
try {
RefClass classChunk = getRefClass("{nms}.Chunk");
RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
this.mustSave = classChunk.getField("mustSave");
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
} catch (Throwable ignored) {
PlotSquared.debug(PlotSquared.imp().getPluginName()
+ "/Server not compatible for chunk processor trim/gc");
Settings.Chunk_Processor.AUTO_TRIM = false;
}
}
if (!Settings.Chunk_Processor.AUTO_TRIM) {
return;
}
for (World world : Bukkit.getWorlds()) {
world.setAutoSave(false);
}
TaskManager.runTaskRepeat(new Runnable() {
@Override public void run() {
try {
HashSet<Chunk> toUnload = new HashSet<>();
for (World world : Bukkit.getWorlds()) {
String worldName = world.getName();
if (!PlotSquared.get().hasPlotArea(worldName)) {
continue;
}
Object w = world.getClass().getDeclaredMethod("getHandle").invoke(world);
Object chunkMap =
w.getClass().getDeclaredMethod("getPlayerChunkMap").invoke(w);
Method methodIsChunkInUse = chunkMap.getClass()
.getDeclaredMethod("isChunkInUse", int.class, int.class);
Chunk[] chunks = world.getLoadedChunks();
for (Chunk chunk : chunks) {
if ((boolean) methodIsChunkInUse
.invoke(chunkMap, chunk.getX(), chunk.getZ())) {
continue;
}
int x = chunk.getX();
int z = chunk.getZ();
if (!shouldSave(worldName, x, z)) {
unloadChunk(worldName, chunk, false);
continue;
}
toUnload.add(chunk);
}
}
if (toUnload.isEmpty()) {
return;
}
long start = System.currentTimeMillis();
for (Chunk chunk : toUnload) {
if (System.currentTimeMillis() - start > 5) {
return;
}
chunk.unload(true, false);
}
} catch (Throwable e) {
e.printStackTrace();
}
}
}, 1);
}
public boolean unloadChunk(String world, Chunk chunk, boolean safe) {
if (safe && shouldSave(world, chunk.getX(), chunk.getZ())) {
return false;
}
Object c = this.methodGetHandleChunk.of(chunk).call();
RefField.RefExecutor field = this.mustSave.of(c);
if ((Boolean) field.get() == true) {
field.set(false);
if (chunk.isLoaded()) {
ignoreUnload = true;
chunk.unload(false, false);
ignoreUnload = false;
}
}
return true;
}
public boolean shouldSave(String world, int X, int Z) {
int x = X << 4;
int z = Z << 4;
int x2 = x + 15;
int z2 = z + 15;
Plot plot = new Location(world, x, 1, z).getOwnedPlotAbs();
if (plot != null && plot.hasOwner()) {
return true;
}
plot = new Location(world, x2, 1, z2).getOwnedPlotAbs();
if (plot != null && plot.hasOwner()) {
return true;
}
plot = new Location(world, x2, 1, z).getOwnedPlotAbs();
if (plot != null && plot.hasOwner()) {
return true;
}
plot = new Location(world, x, 1, z2).getOwnedPlotAbs();
if (plot != null && plot.hasOwner()) {
return true;
}
plot = new Location(world, x + 7, 1, z + 7).getOwnedPlotAbs();
return plot != null && plot.hasOwner();
}
@EventHandler public void onChunkUnload(ChunkUnloadEvent event) {
if (ignoreUnload) {
return;
}
if (Settings.Chunk_Processor.AUTO_TRIM) {
Chunk chunk = event.getChunk();
String world = chunk.getWorld().getName();
if (PlotSquared.get().hasPlotArea(world)) {
if (unloadChunk(world, chunk, true)) {
return;
}
}
}
if (processChunk(event.getChunk(), true)) {
event.setCancelled(true);
}
}
@EventHandler public void onChunkLoad(ChunkLoadEvent event) {
processChunk(event.getChunk(), false);
}
@EventHandler(priority = EventPriority.LOWEST) public void onItemSpawn(ItemSpawnEvent event) {
Item entity = event.getEntity();
Chunk chunk = entity.getLocation().getChunk();
if (chunk == this.lastChunk) {
event.getEntity().remove();
event.setCancelled(true);
return;
}
if (!PlotSquared.get().hasPlotArea(chunk.getWorld().getName())) {
return;
}
Entity[] entities = chunk.getEntities();
if (entities.length > Settings.Chunk_Processor.MAX_ENTITIES) {
event.getEntity().remove();
event.setCancelled(true);
this.lastChunk = chunk;
} else {
this.lastChunk = null;
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPhysics(BlockPhysicsEvent event) {
if (Settings.Chunk_Processor.DISABLE_PHYSICS) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onEntitySpawn(CreatureSpawnEvent event) {
LivingEntity entity = event.getEntity();
Chunk chunk = entity.getLocation().getChunk();
if (chunk == this.lastChunk) {
event.getEntity().remove();
event.setCancelled(true);
return;
}
if (!PlotSquared.get().hasPlotArea(chunk.getWorld().getName())) {
return;
}
Entity[] entities = chunk.getEntities();
if (entities.length > Settings.Chunk_Processor.MAX_ENTITIES) {
event.getEntity().remove();
event.setCancelled(true);
this.lastChunk = chunk;
} else {
this.lastChunk = null;
}
}
private void cleanChunk(final Chunk chunk) {
TaskManager.index.incrementAndGet();
final Integer currentIndex = TaskManager.index.get();
Integer task = TaskManager.runTaskRepeat(new Runnable() {
@Override public void run() {
if (!chunk.isLoaded()) {
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
TaskManager.tasks.remove(currentIndex);
PlotSquared
.debug(C.PREFIX.s() + "&aSuccessfully processed and unloaded chunk!");
chunk.unload(true, true);
return;
}
BlockState[] tiles = chunk.getTileEntities();
if (tiles.length == 0) {
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
TaskManager.tasks.remove(currentIndex);
PlotSquared
.debug(C.PREFIX.s() + "&aSuccessfully processed and unloaded chunk!");
chunk.unload(true, true);
return;
}
long start = System.currentTimeMillis();
int i = 0;
while (System.currentTimeMillis() - start < 250) {
if (i >= tiles.length) {
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
TaskManager.tasks.remove(currentIndex);
PlotSquared
.debug(C.PREFIX.s() + "&aSuccessfully processed and unloaded chunk!");
chunk.unload(true, true);
return;
}
tiles[i].getBlock().setType(Material.AIR, false);
i++;
}
}
}, 5);
TaskManager.tasks.put(currentIndex, task);
}
public boolean processChunk(Chunk chunk, boolean unload) {
if (!PlotSquared.get().hasPlotArea(chunk.getWorld().getName())) {
return false;
}
Entity[] entities = chunk.getEntities();
BlockState[] tiles = chunk.getTileEntities();
if (entities.length > Settings.Chunk_Processor.MAX_ENTITIES) {
for (Entity ent : entities) {
if (!(ent instanceof Player)) {
ent.remove();
}
}
PlotSquared.debug(
C.PREFIX.s() + "&a detected unsafe chunk and processed: " + (chunk.getX() << 4)
+ "," + (chunk.getX() << 4));
}
if (tiles.length > Settings.Chunk_Processor.MAX_TILES) {
if (unload) {
PlotSquared.debug(
C.PREFIX.s() + "&c detected unsafe chunk: " + (chunk.getX() << 4) + "," + (
chunk.getX() << 4));
cleanChunk(chunk);
return true;
}
for (BlockState tile : tiles) {
tile.getBlock().setType(Material.AIR, false);
}
}
return false;
}
}

View File

@ -1,142 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.listeners;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import org.bukkit.World;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Vehicle;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.entity.EntityTeleportEvent;
import org.bukkit.event.vehicle.*;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
import java.util.List;
@SuppressWarnings("unused") public class EntitySpawnListener implements Listener {
private static boolean ignoreTP = false;
public static void test(Entity entity) {
List<MetadataValue> meta = entity.getMetadata("plotworld");
World world = entity.getLocation().getWorld();
if (meta == null || meta.isEmpty()) {
if (PlotSquared.get().hasPlotArea(world.getName())) {
entity.setMetadata("plotworld",
new FixedMetadataValue((Plugin) PlotSquared.get().IMP, entity.getLocation()));
}
} else {
org.bukkit.Location origin = (org.bukkit.Location) meta.get(0).value();
World originWorld = origin.getWorld();
if (!originWorld.equals(world)) {
if (!ignoreTP) {
if (!world.getName().equalsIgnoreCase(originWorld + "_the_end")) {
try {
ignoreTP = true;
entity.teleport(origin);
} finally {
ignoreTP = false;
}
if (entity.getLocation().getWorld().equals(world)) {
entity.remove();
}
}
} else {
entity.remove();
}
}
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void creatureSpawnEvent(EntitySpawnEvent event) {
Entity entity = event.getEntity();
Location location = BukkitUtil.getLocation(entity.getLocation());
PlotArea area = location.getPlotArea();
if (area == null) {
return;
}
Plot plot = area.getOwnedPlotAbs(location);
if (plot == null) {
if (!area.MOB_SPAWNING) {
EntityType type = entity.getType();
switch (type) {
case DROPPED_ITEM:
if (Settings.Enabled_Components.KILL_ROAD_ITEMS) {
break;
}
case PLAYER:
return;
}
if (type.isAlive() || !area.MISC_SPAWN_UNOWNED) {
event.setCancelled(true);
}
}
return;
}
if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
event.setCancelled(true);
}
switch (entity.getType()) {
case ENDER_CRYSTAL:
if (PlayerEvents.checkEntity(entity, plot)) {
event.setCancelled(true);
}
case SHULKER:
if (!entity.hasMetadata("plot")) {
entity.setMetadata("plot",
new FixedMetadataValue((Plugin) PlotSquared.get().IMP, plot.getId()));
}
}
}
@EventHandler public void onVehicle(VehicleUpdateEvent event) {
test(event.getVehicle());
}
@EventHandler public void onVehicle(VehicleDestroyEvent event) {
test(event.getVehicle());
}
@EventHandler public void onVehicle(VehicleEntityCollisionEvent event) {
test(event.getVehicle());
}
@EventHandler public void onVehicle(VehicleCreateEvent event) {
test(event.getVehicle());
}
@EventHandler public void onVehicle(VehicleBlockCollisionEvent event) {
test(event.getVehicle());
}
@EventHandler public void onTeleport(EntityTeleportEvent event) {
Entity ent = event.getEntity();
if (ent instanceof Vehicle || ent instanceof ArmorStand)
test(event.getEntity());
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void vehicleMove(VehicleMoveEvent event) throws IllegalAccessException {
test(event.getVehicle());
}
@EventHandler public void spawn(CreatureSpawnEvent event) {
switch (event.getEntityType()) {
case ARMOR_STAND:
test(event.getEntity());
}
}
}

View File

@ -1,195 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.listeners;
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerEnterPlotEvent;
import com.github.intellectualsites.plotsquared.bukkit.events.PlayerLeavePlotEvent;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.listener.PlotListener;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.google.common.base.Optional;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.block.Block;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.UUID;
@SuppressWarnings("unused") public class PlotPlusListener extends PlotListener implements Listener {
private static final HashMap<UUID, Interval> feedRunnable = new HashMap<>();
private static final HashMap<UUID, Interval> healRunnable = new HashMap<>();
public static void startRunnable(JavaPlugin plugin) {
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override public void run() {
if (!healRunnable.isEmpty()) {
for (Iterator<Entry<UUID, Interval>> iterator =
healRunnable.entrySet().iterator(); iterator.hasNext(); ) {
Entry<UUID, Interval> entry = iterator.next();
Interval value = entry.getValue();
++value.count;
if (value.count == value.interval) {
value.count = 0;
Player player = Bukkit.getPlayer(entry.getKey());
if (player == null) {
iterator.remove();
continue;
}
double level = player.getHealth();
if (level != value.max) {
player.setHealth(Math.min(level + value.amount, value.max));
}
}
}
}
if (!feedRunnable.isEmpty()) {
for (Iterator<Entry<UUID, Interval>> iterator =
feedRunnable.entrySet().iterator(); iterator.hasNext(); ) {
Entry<UUID, Interval> entry = iterator.next();
Interval value = entry.getValue();
++value.count;
if (value.count == value.interval) {
value.count = 0;
Player player = Bukkit.getPlayer(entry.getKey());
if (player == null) {
iterator.remove();
continue;
}
int level = player.getFoodLevel();
if (level != value.max) {
player.setFoodLevel(Math.min(level + value.amount, value.max));
}
}
}
}
}
}, 0L, 20L);
}
@EventHandler(priority = EventPriority.HIGH) public void onInteract(BlockDamageEvent event) {
Player player = event.getPlayer();
if (player.getGameMode() != GameMode.SURVIVAL) {
return;
}
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
if (plot == null) {
return;
}
if (Flags.INSTABREAK.isTrue(plot)) {
Block block = event.getBlock();
BlockBreakEvent call = new BlockBreakEvent(block, player);
Bukkit.getServer().getPluginManager().callEvent(call);
if (!call.isCancelled()) {
event.getBlock().breakNaturally();
}
}
}
@EventHandler(priority = EventPriority.HIGH) public void onDamage(EntityDamageEvent event) {
if (event.getEntityType() != EntityType.PLAYER) {
return;
}
Player player = (Player) event.getEntity();
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
if (plot == null) {
return;
}
if (Flags.INVINCIBLE.isTrue(plot)) {
event.setCancelled(true);
}
}
@EventHandler public void onItemDrop(PlayerDropItemEvent event) {
Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player);
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
if (plot == null) {
return;
}
UUID uuid = pp.getUUID();
if (!plot.isAdded(uuid)) {
if (Flags.ITEM_DROP.isFalse(plot)) {
event.setCancelled(true);
}
}
}
@EventHandler public void onPlotEnter(PlayerEnterPlotEvent event) {
Player player = event.getPlayer();
Plot plot = event.getPlot();
Optional<Integer[]> feed = plot.getFlag(Flags.FEED);
if (feed.isPresent()) {
Integer[] value = feed.get();
feedRunnable.put(player.getUniqueId(), new Interval(value[0], value[1], 20));
}
Optional<Integer[]> heal = plot.getFlag(Flags.HEAL);
if (heal.isPresent()) {
Integer[] value = heal.get();
healRunnable.put(player.getUniqueId(), new Interval(value[0], value[1], 20));
}
}
@EventHandler public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
feedRunnable.remove(player.getUniqueId());
healRunnable.remove(player.getUniqueId());
}
@EventHandler public void onPlotLeave(PlayerLeavePlotEvent event) {
Player leaver = event.getPlayer();
Plot plot = event.getPlot();
if (!plot.hasOwner()) {
return;
}
BukkitUtil.getPlayer(leaver);
feedRunnable.remove(leaver.getUniqueId());
healRunnable.remove(leaver.getUniqueId());
}
@EventHandler public void onItemPickup(EntityPickupItemEvent event) {
LivingEntity ent = event.getEntity();
if (ent instanceof Player) {
Player player = (Player) ent;
PlotPlayer pp = BukkitUtil.getPlayer(player);
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
if (plot == null) {
return;
}
UUID uuid = pp.getUUID();
if (!plot.isAdded(uuid) && Flags.DROP_PROTECTION.isTrue(plot)) {
event.setCancelled(true);
}
}
}
private static class Interval {
final int interval;
final int amount;
final int max;
public int count = 0;
Interval(int interval, int amount, int max) {
this.interval = interval;
this.amount = amount;
this.max = max;
}
}
}

View File

@ -1,36 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.listeners;
import com.github.intellectualsites.plotsquared.bukkit.generator.BukkitPlotGenerator;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper;
import com.github.intellectualsites.plotsquared.plot.object.worlds.PlotAreaManager;
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotAreaManager;
import org.bukkit.World;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldInitEvent;
import org.bukkit.generator.ChunkGenerator;
@SuppressWarnings("unused") public class WorldEvents implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onWorldInit(WorldInitEvent event) {
World world = event.getWorld();
String name = world.getName();
PlotAreaManager manager = PlotSquared.get().getPlotAreaManager();
if (manager instanceof SinglePlotAreaManager) {
SinglePlotAreaManager single = (SinglePlotAreaManager) manager;
if (single.isWorld(name)) {
world.setKeepSpawnInMemory(false);
return;
}
}
ChunkGenerator gen = world.getGenerator();
if (gen instanceof GeneratorWrapper) {
PlotSquared.get().loadWorld(name, (GeneratorWrapper<?>) gen);
} else {
PlotSquared.get().loadWorld(name, new BukkitPlotGenerator(name, gen));
}
}
}

View File

@ -1,25 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.object;
import com.github.intellectualsites.plotsquared.plot.object.LazyBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.StringPlotBlock;
import org.bukkit.block.Block;
public class BukkitLazyBlock extends LazyBlock {
private StringPlotBlock pb;
public BukkitLazyBlock(Block block) {
this.pb = (StringPlotBlock) PlotBlock.get(block.getType().toString());
}
public BukkitLazyBlock(StringPlotBlock pb) {
this.pb = pb;
}
public StringPlotBlock getPlotBlock() {
return this.pb;
}
}

View File

@ -1,37 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.object;
import com.github.intellectualsites.plotsquared.plot.object.OfflinePlotPlayer;
import org.bukkit.OfflinePlayer;
import java.util.UUID;
public class BukkitOfflinePlayer implements OfflinePlotPlayer {
public final OfflinePlayer player;
/**
* Please do not use this method. Instead use BukkitUtil.getPlayer(Player),
* as it caches player objects.
*
* @param player
*/
public BukkitOfflinePlayer(OfflinePlayer player) {
this.player = player;
}
@Override public UUID getUUID() {
return this.player.getUniqueId();
}
@Override public long getLastPlayed() {
return this.player.getLastPlayed();
}
@Override public boolean isOnline() {
return this.player.isOnline();
}
@Override public String getName() {
return this.player.getName();
}
}

View File

@ -1,282 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.object;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.C;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.*;
import org.bukkit.*;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventException;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.RegisteredListener;
import java.util.Arrays;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
public class BukkitPlayer extends PlotPlayer {
public final Player player;
public boolean offline;
private UUID uuid;
private String name;
/**
* <p>Please do not use this method. Instead use
* BukkitUtil.getPlayer(Player), as it caches player objects.</p>
*
* @param player
*/
public BukkitPlayer(Player player) {
this.player = player;
super.populatePersistentMetaMap();
}
public BukkitPlayer(Player player, boolean offline) {
this.player = player;
this.offline = offline;
super.populatePersistentMetaMap();
}
@Override public Location getLocation() {
Location location = super.getLocation();
return location == null ? BukkitUtil.getLocation(this.player) : location;
}
@Override public UUID getUUID() {
if (this.uuid == null) {
this.uuid = UUIDHandler.getUUID(this);
}
return this.uuid;
}
@Override public long getLastPlayed() {
return this.player.getLastPlayed();
}
@Override public boolean canTeleport(Location loc) {
org.bukkit.Location to = BukkitUtil.getLocation(loc);
org.bukkit.Location from = player.getLocation();
PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to);
callEvent(event);
if (event.isCancelled() || !event.getTo().equals(to)) {
return false;
}
event = new PlayerTeleportEvent(player, to, from);
callEvent(event);
return true;
}
private void callEvent(final Event event) {
RegisteredListener[] listeners = event.getHandlers().getRegisteredListeners();
for (RegisteredListener listener : listeners) {
if (listener.getPlugin().getName().equals(PlotSquared.imp().getPluginName())) {
continue;
}
try {
listener.callEvent(event);
} catch (EventException e) {
e.printStackTrace();
}
}
}
@Override public boolean hasPermission(String permission) {
if (this.offline && EconHandler.manager != null) {
return EconHandler.manager.hasPermission(getName(), permission);
}
return this.player.hasPermission(permission);
}
@Override public int hasPermissionRange(String stub, int range) {
if (hasPermission(C.PERMISSION_ADMIN.s())) {
return Integer.MAX_VALUE;
}
String[] nodes = stub.split("\\.");
StringBuilder n = new StringBuilder();
for (int i = 0; i < (nodes.length - 1); i++) {
n.append(nodes[i]).append(".");
if (!stub.equals(n + C.PERMISSION_STAR.s())) {
if (hasPermission(n + C.PERMISSION_STAR.s())) {
return Integer.MAX_VALUE;
}
}
}
if (hasPermission(stub + ".*")) {
return Integer.MAX_VALUE;
}
int max = 0;
String stubPlus = stub + ".";
Set<PermissionAttachmentInfo> effective = player.getEffectivePermissions();
if (!effective.isEmpty()) {
for (PermissionAttachmentInfo attach : effective) {
String perm = attach.getPermission();
if (perm.startsWith(stubPlus)) {
String end = perm.substring(stubPlus.length());
if (MathMan.isInteger(end)) {
int val = Integer.parseInt(end);
if (val > range)
return val;
if (val > max)
max = val;
}
}
}
} else {
for (int i = range; i > 0; i--) {
if (hasPermission(stub + "." + i)) {
return i;
}
}
}
return max;
}
@Override public boolean isPermissionSet(String permission) {
return this.player.isPermissionSet(permission);
}
@Override public void sendMessage(String message) {
if (!StringMan.isEqual(this.<String>getMeta("lastMessage"), message) || (
System.currentTimeMillis() - this.<Long>getMeta("lastMessageTime") > 5000)) {
setMeta("lastMessage", message);
setMeta("lastMessageTime", System.currentTimeMillis());
this.player.sendMessage(message);
}
}
@Override public void teleport(Location location) {
if (Math.abs(location.getX()) >= 30000000 || Math.abs(location.getZ()) >= 30000000) {
return;
}
this.player.teleport(
new org.bukkit.Location(BukkitUtil.getWorld(location.getWorld()), location.getX() + 0.5,
location.getY(), location.getZ() + 0.5, location.getYaw(), location.getPitch()),
TeleportCause.COMMAND);
}
@Override public String getName() {
if (this.name == null) {
this.name = this.player.getName();
}
return this.name;
}
@Override public boolean isOnline() {
return !this.offline && this.player.isOnline();
}
@Override public void setCompassTarget(Location location) {
this.player.setCompassTarget(
new org.bukkit.Location(BukkitUtil.getWorld(location.getWorld()), location.getX(),
location.getY(), location.getZ()));
}
@Override public Location getLocationFull() {
return BukkitUtil.getLocationFull(this.player);
}
@Override public void setWeather(PlotWeather weather) {
switch (weather) {
case CLEAR:
this.player.setPlayerWeather(WeatherType.CLEAR);
break;
case RAIN:
this.player.setPlayerWeather(WeatherType.DOWNFALL);
break;
case RESET:
this.player.resetPlayerWeather();
break;
default:
this.player.resetPlayerWeather();
break;
}
}
@Override public PlotGameMode getGameMode() {
switch (this.player.getGameMode()) {
case ADVENTURE:
return PlotGameMode.ADVENTURE;
case CREATIVE:
return PlotGameMode.CREATIVE;
case SPECTATOR:
return PlotGameMode.SPECTATOR;
case SURVIVAL:
return PlotGameMode.SURVIVAL;
default:
return PlotGameMode.NOT_SET;
}
}
@Override public void setGameMode(PlotGameMode gameMode) {
switch (gameMode) {
case ADVENTURE:
this.player.setGameMode(GameMode.ADVENTURE);
break;
case CREATIVE:
this.player.setGameMode(GameMode.CREATIVE);
break;
case SPECTATOR:
this.player.setGameMode(GameMode.SPECTATOR);
break;
case SURVIVAL:
this.player.setGameMode(GameMode.SURVIVAL);
break;
default:
this.player.setGameMode(GameMode.SURVIVAL);
break;
}
}
@Override public void setTime(long time) {
if (time != Long.MAX_VALUE) {
this.player.setPlayerTime(time, false);
} else {
this.player.resetPlayerTime();
}
}
@Override public boolean getFlight() {
return player.getAllowFlight();
}
@Override public void setFlight(boolean fly) {
this.player.setAllowFlight(fly);
}
@Override public void playMusic(Location location, PlotBlock id) {
if (PlotBlock.isEverything(id) || id.isAir()) {
// Let's just stop all the discs because why not?
for (final Sound sound : Arrays.stream(Sound.values()).filter(sound -> sound.name().contains("DISC")).collect(
Collectors.toList())) {
player.stopSound(sound);
}
// this.player.playEffect(BukkitUtil.getLocation(location), Effect.RECORD_PLAY, Material.AIR);
} else {
// this.player.playEffect(BukkitUtil.getLocation(location), Effect.RECORD_PLAY, id.to(Material.class));
this.player.playSound(BukkitUtil.getLocation(location), Sound.valueOf(id.to(Material.class).name()), Float.MAX_VALUE, 1f);
}
}
@Override public void kick(String message) {
this.player.kickPlayer(message);
}
@Override public void stopSpectating() {
if (getGameMode() == PlotGameMode.SPECTATOR) {
this.player.setSpectatorTarget(null);
}
}
@Override public boolean isBanned() {
return this.player.isBanned();
}
}

View File

@ -1,8 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.object.entity;
class AgeableStats {
int age;
boolean locked;
boolean adult;
}

View File

@ -1,15 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.object.entity;
class ArmorStandStats {
final float[] head = new float[3];
final float[] body = new float[3];
final float[] leftLeg = new float[3];
final float[] rightLeg = new float[3];
final float[] leftArm = new float[3];
final float[] rightArm = new float[3];
boolean arms;
boolean noPlate;
boolean invisible;
boolean small;
}

View File

@ -1,13 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.object.entity;
class EntityBaseStats {
EntityWrapper passenger;
float fall;
short fire;
int age;
double vZ;
double vY;
double vX;
}

View File

@ -1,40 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.object.entity;
import lombok.Getter;
import lombok.NonNull;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
@Getter public abstract class EntityWrapper {
protected final float yaw;
protected final float pitch;
private final Entity entity;
private final EntityType type;
public double x;
public double y;
public double z;
EntityWrapper(@NonNull final Entity entity) {
this.entity = entity;
this.type = entity.getType();
final Location location = entity.getLocation();
this.x = location.getX();
this.y = location.getY();
this.z = location.getZ();
this.yaw = location.getYaw();
this.pitch = location.getPitch();
}
@SuppressWarnings("deprecation") @Override public String toString() {
return String.format("[%s, x=%s, y=%s, z=%s]", type.getName(), x, y, z);
}
public abstract Entity spawn(World world, int xOffset, int zOffset);
public abstract void saveEntity();
}

View File

@ -1,12 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.object.entity;
import org.bukkit.entity.Horse;
class HorseStats {
double jump;
boolean chest;
Horse.Variant variant;
Horse.Color color;
Horse.Style style;
}

View File

@ -1,28 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.object.entity;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import java.util.Collection;
class LivingEntityStats {
boolean loot;
String name;
boolean visible;
float health;
short air;
boolean persistent;
boolean leashed;
short leashX;
short leashY;
short leashZ;
boolean equipped;
ItemStack mainHand;
ItemStack helmet;
ItemStack boots;
ItemStack leggings;
ItemStack chestplate;
Collection<PotionEffect> potions;
ItemStack offHand;
}

View File

@ -1,9 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.object.entity;
import org.bukkit.entity.AnimalTamer;
class TameableStats {
AnimalTamer owner;
boolean tamed;
}

View File

@ -1,129 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.titles;
import com.github.intellectualsites.plotsquared.bukkit.chat.Reflection;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
public class DefaultTitleManager extends TitleManager {
/**
* Create a new 1.8 title.
*
* @param title Title text
* @param subtitle Subtitle text
* @param fadeInTime Fade in time
* @param stayTime Stay on screen time
* @param fadeOutTime Fade out time
*/
DefaultTitleManager(String title, String subtitle, int fadeInTime, int stayTime,
int fadeOutTime) {
super(title, subtitle, fadeInTime, stayTime, fadeOutTime);
}
/**
* Load spigot and NMS classes.
*/
@Override void loadClasses() {
this.packetTitle = Reflection.getNMSClass("PacketPlayOutTitle");
this.packetActions = Reflection.getNMSClass("EnumTitleAction");
this.chatBaseComponent = Reflection.getNMSClass("IChatBaseComponent");
this.nmsChatSerializer = Reflection.getNMSClass("ChatSerializer");
}
@Override public void send(Player player)
throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
if (this.packetTitle != null) {
// First reset previous settings
resetTitle(player);
// Send timings first
Object handle = getHandle(player);
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
Object[] actions = this.packetActions.getEnumConstants();
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
Object packet = this.packetTitle
.getConstructor(this.packetActions, this.chatBaseComponent, Integer.TYPE,
Integer.TYPE, Integer.TYPE)
.newInstance(actions[2], null, this.fadeInTime * (this.ticks ? 1 : 20),
this.stayTime * (this.ticks ? 1 : 20),
this.fadeOutTime * (this.ticks ? 1 : 20));
// Send if set
if (this.fadeInTime != -1 && this.fadeOutTime != -1 && this.stayTime != -1) {
sendPacket.invoke(connection, packet);
}
// Send title
Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getTitle())
+ "\",color:" + this.titleColor.name().toLowerCase() + '}');
packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent)
.newInstance(actions[0], serialized);
sendPacket.invoke(connection, packet);
if (!this.getSubtitle().isEmpty()) {
// Send subtitle if present
serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getSubtitle())
+ "\",color:" + this.subtitleColor.name().toLowerCase() + '}');
packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent)
.newInstance(actions[1], serialized);
sendPacket.invoke(connection, packet);
}
}
}
@Override public void clearTitle(Player player)
throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
// Send timings first
Object handle = getHandle(player);
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
Object[] actions = this.packetActions.getEnumConstants();
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent)
.newInstance(actions[3], null);
sendPacket.invoke(connection, packet);
}
/**
* Reset the title settings.
*
* @param player Player
* @throws SecurityException
* @throws ReflectiveOperationException
* @throws SecurityException
*/
@Override public void resetTitle(Player player)
throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
// Send timings first
Object handle = getHandle(player);
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
Object[] actions = this.packetActions.getEnumConstants();
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent)
.newInstance(actions[4], null);
sendPacket.invoke(connection, packet);
}
Field getField(Class<?> clazz, String name) {
try {
Field field = clazz.getDeclaredField(name);
field.setAccessible(true);
return field;
} catch (NoSuchFieldException | SecurityException e) {
e.printStackTrace();
return null;
}
}
Method getMethod(Class<?> clazz, String name, Class<?>... args) {
for (Method m : clazz.getMethods()) {
if (m.getName().equals(name) && (args.length == 0 || classListEqual(args,
m.getParameterTypes()))) {
m.setAccessible(true);
return m;
}
}
return null;
}
}

View File

@ -1,20 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.titles;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.AbstractTitle;
import org.bukkit.entity.Player;
@SuppressWarnings("deprecation") public class DefaultTitle_111 extends AbstractTitle {
@Override
public void sendTitle(PlotPlayer player, String head, String sub, int in, int delay, int out) {
try {
final Player playerObj = ((BukkitPlayer) player).player;
TitleManager_1_11 title = new TitleManager_1_11(head, sub, in, delay, out);
title.send(playerObj);
return;
} catch (Throwable ignored) {
}
}
}

View File

@ -1,22 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.titles;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.AbstractTitle;
public class HackTitle extends AbstractTitle {
@Override
public void sendTitle(PlotPlayer player, String head, String sub, int in, int delay, int out) {
try {
HackTitleManager title = new HackTitleManager(head, sub, in, delay, out);
title.send(((BukkitPlayer) player).player);
} catch (Exception ignored) {
PlotSquared.debug("&cYour server version does not support titles!");
Settings.TITLES = false;
AbstractTitle.TITLE_CLASS = null;
}
}
}

View File

@ -1,177 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.titles;
import com.github.intellectualsites.plotsquared.bukkit.chat.Reflection;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
public class HackTitleManager extends TitleManager {
/**
* Create a new 1.8 title.
*
* @param title Title text
* @param subtitle Subtitle text
* @param fadeInTime Fade in time
* @param stayTime Stay on screen time
* @param fadeOutTime Fade out time
*/
HackTitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
super(title, subtitle, fadeInTime, stayTime, fadeOutTime);
}
/**
* Load spigot and NMS classes.
*/
@Override void loadClasses() {
this.packetTitle = getClass("org.spigotmc.ProtocolInjector$PacketTitle");
this.packetActions = getClass("org.spigotmc.ProtocolInjector$PacketTitle$Action");
this.nmsChatSerializer = Reflection.getNMSClass("ChatSerializer");
}
@Override public void send(Player player)
throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
if ((getProtocolVersion(player) >= 47) && isSpigot() && (this.packetTitle != null)) {
// First reset previous settings
resetTitle(player);
// Send timings first
Object handle = getHandle(player);
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
Object[] actions = this.packetActions.getEnumConstants();
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
Object packet = this.packetTitle
.getConstructor(this.packetActions, Integer.TYPE, Integer.TYPE, Integer.TYPE)
.newInstance(actions[2], this.fadeInTime * (this.ticks ? 1 : 20),
this.stayTime * (this.ticks ? 1 : 20),
this.fadeOutTime * (this.ticks ? 1 : 20));
// Send if set
if ((this.fadeInTime != -1) && (this.fadeOutTime != -1) && (this.stayTime != -1)) {
sendPacket.invoke(connection, packet);
}
// Send title
Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getTitle())
+ "\",color:" + this.titleColor.name().toLowerCase() + "}");
packet = this.packetTitle
.getConstructor(this.packetActions, Reflection.getNMSClass("IChatBaseComponent"))
.newInstance(actions[0], serialized);
sendPacket.invoke(connection, packet);
if (!this.getSubtitle().isEmpty()) {
// Send subtitle if present
serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getSubtitle())
+ "\",color:" + this.subtitleColor.name().toLowerCase() + "}");
packet = this.packetTitle.getConstructor(this.packetActions,
Reflection.getNMSClass("IChatBaseComponent"))
.newInstance(actions[1], serialized);
sendPacket.invoke(connection, packet);
}
}
}
@Override public void clearTitle(Player player)
throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
if ((getProtocolVersion(player) >= 47) && isSpigot()) {
// Send timings first
Object handle = getHandle(player);
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
Object[] actions = this.packetActions.getEnumConstants();
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
Object packet =
this.packetTitle.getConstructor(this.packetActions).newInstance(actions[3]);
sendPacket.invoke(connection, packet);
}
}
@Override public void resetTitle(Player player)
throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
if ((getProtocolVersion(player) >= 47) && isSpigot()) {
// Send timings first
Object handle = getHandle(player);
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
Object[] actions = this.packetActions.getEnumConstants();
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
Object packet =
this.packetTitle.getConstructor(this.packetActions).newInstance(actions[4]);
sendPacket.invoke(connection, packet);
}
}
/**
* Get the protocol version of the player.
*
* @param player Player
* @return Protocol version
* @throws IllegalArgumentException
* @throws ReflectiveOperationException
* @throws SecurityException
*/
private int getProtocolVersion(Player player)
throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
Object handle = getHandle(player);
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
Object networkManager = getValue("networkManager", connection);
return (Integer) getMethod("getVersion", networkManager.getClass()).invoke(networkManager);
}
/**
* Check if running spigot.
*
* @return Spigot
*/
private boolean isSpigot() {
return Bukkit.getVersion().contains("Spigot");
}
/**
* Get class by url.
*
* @param namespace Namespace url
* @return Class
*/
private Class<?> getClass(String namespace) {
try {
return Class.forName(namespace);
} catch (ClassNotFoundException ignored) {
}
return null;
}
private Field getField(String name, Class<?> clazz)
throws NoSuchFieldException, SecurityException {
return clazz.getDeclaredField(name);
}
private Object getValue(String name, Object obj)
throws ReflectiveOperationException, SecurityException, IllegalArgumentException {
Field f = getField(name, obj.getClass());
f.setAccessible(true);
return f.get(obj);
}
private Field getField(Class<?> clazz, String name) {
try {
Field field = clazz.getDeclaredField(name);
field.setAccessible(true);
return field;
} catch (SecurityException | NoSuchFieldException e) {
e.printStackTrace();
return null;
}
}
private Method getMethod(Class<?> clazz, String name, Class<?>... args) {
for (Method m : clazz.getMethods()) {
if (m.getName().equals(name) && ((args.length == 0) || classListEqual(args,
m.getParameterTypes()))) {
m.setAccessible(true);
return m;
}
}
return null;
}
}

View File

@ -1,256 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.titles;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
public abstract class TitleManager {
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES = new HashMap<>();
/* Title packet */ Class<?> packetTitle;
/* Title packet actions ENUM */ Class<?> packetActions;
/* Chat serializer */ Class<?> nmsChatSerializer;
Class<?> chatBaseComponent;
ChatColor titleColor = ChatColor.WHITE;
ChatColor subtitleColor = ChatColor.WHITE;
/* Title timings */ int fadeInTime = -1;
int stayTime = -1;
int fadeOutTime = -1;
boolean ticks = false;
/* Title text and color */
private String title = "";
/* Subtitle text and color */
private String subtitle = "";
/**
* Create a new 1.8 title.
*
* @param title Title text
* @param subtitle Subtitle text
* @param fadeInTime Fade in time
* @param stayTime Stay on screen time
* @param fadeOutTime Fade out time
*/
TitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
this.title = title;
this.subtitle = subtitle;
this.fadeInTime = fadeInTime;
this.stayTime = stayTime;
this.fadeOutTime = fadeOutTime;
loadClasses();
}
abstract void loadClasses();
/**
* Gets title text.
*
* @return Title text
*/
public final String getTitle() {
return this.title;
}
/**
* Sets the text for the title.
*
* @param title Title
*/
public final void setTitle(String title) {
this.title = title;
}
/**
* Gets the subtitle text.
*
* @return Subtitle text
*/
public final String getSubtitle() {
return this.subtitle;
}
/**
* Sets subtitle text.
*
* @param subtitle Subtitle text
*/
public final void setSubtitle(String subtitle) {
this.subtitle = subtitle;
}
/**
* Sets the title color.
*
* @param color Chat color
*/
public final void setTitleColor(ChatColor color) {
this.titleColor = color;
}
/**
* Sets the subtitle color.
*
* @param color Chat color
*/
public final void setSubtitleColor(ChatColor color) {
this.subtitleColor = color;
}
/**
* Sets title fade in time.
*
* @param time Time
*/
public final void setFadeInTime(int time) {
this.fadeInTime = time;
}
/**
* Sets title fade out time.
*
* @param time Time
*/
public final void setFadeOutTime(int time) {
this.fadeOutTime = time;
}
/**
* Sets title stay time.
*
* @param time Time
*/
public final void setStayTime(int time) {
this.stayTime = time;
}
/**
* Sets timings to ticks.
*/
public final void setTimingsToTicks() {
this.ticks = true;
}
/**
* Sets timings to seconds.
*/
public final void setTimingsToSeconds() {
this.ticks = false;
}
/**
* Sends the title to a player.
*
* @param player Player
* @throws IllegalArgumentException
* @throws ReflectiveOperationException
* @throws SecurityException
*/
public abstract void send(Player player)
throws IllegalArgumentException, ReflectiveOperationException, SecurityException;
/**
* Broadcasts the title to all players.
*
* @throws Exception
*/
public final void broadcast() throws Exception {
for (Player player : Bukkit.getOnlinePlayers()) {
send(player);
}
}
/**
* Clears the title.
*
* @param player Player
* @throws IllegalArgumentException
* @throws ReflectiveOperationException
* @throws SecurityException
*/
public abstract void clearTitle(Player player)
throws IllegalArgumentException, ReflectiveOperationException, SecurityException;
/**
* Resets the title settings.
*
* @param player Player
* @throws IllegalArgumentException
* @throws ReflectiveOperationException
* @throws SecurityException
*/
public abstract void resetTitle(Player player)
throws IllegalArgumentException, ReflectiveOperationException, SecurityException;
private Class<?> getPrimitiveType(Class<?> clazz) {
if (CORRESPONDING_TYPES.containsKey(clazz)) {
return CORRESPONDING_TYPES.get(clazz);
} else {
return clazz;
}
}
private Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) {
int a;
if (classes != null) {
a = classes.length;
} else {
a = 0;
}
Class<?>[] types = new Class<?>[a];
for (int i = 0; i < a; i++) {
types[i] = getPrimitiveType(classes[i]);
}
return types;
}
final Object getHandle(Object obj) {
try {
return getMethod("getHandle", obj.getClass()).invoke(obj);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
return null;
}
}
final Method getMethod(String name, Class<?> clazz, Class<?>... paramTypes) {
Class<?>[] t = toPrimitiveTypeArray(paramTypes);
for (Method m : clazz.getMethods()) {
Class<?>[] types = toPrimitiveTypeArray(m.getParameterTypes());
if (m.getName().equals(name) && equalsTypeArray(types, t)) {
return m;
}
}
return null;
}
private boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
if (a.length != o.length) {
return false;
}
for (int i = 0; i < a.length; i++) {
if (!a[i].equals(o[i]) && !a[i].isAssignableFrom(o[i])) {
return false;
}
}
return true;
}
boolean classListEqual(Class<?>[] l1, Class<?>[] l2) {
if (l1.length != l2.length) {
return false;
}
boolean equal = true;
for (int i = 0; i < l1.length; i++) {
if (l1[i] != l2[i]) {
equal = false;
break;
}
}
return equal;
}
}

View File

@ -1,497 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.titles;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
/**
* Minecraft 1.8 Title
* For 1.11
*
* @author Maxim Van de Wynckel
* @version 1.1.0
*/
public class TitleManager_1_11 {
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES =
new HashMap<Class<?>, Class<?>>();
/* Title packet */
private static Class<?> packetTitle;
/* Title packet actions ENUM */
private static Class<?> packetActions;
/* Chat serializer */
private static Class<?> nmsChatSerializer;
private static Class<?> chatBaseComponent;
/* NMS player and connection */
private static Class<?> nmsPlayer;
private static Class<?> nmsPlayerConnection;
private static Field playerConnection;
private static Method sendPacket;
private static Class<?> obcPlayer;
private static Method methodPlayerGetHandle;
/* Title text and color */
private String title = "";
private ChatColor titleColor = ChatColor.WHITE;
/* Subtitle text and color */
private String subtitle = "";
private ChatColor subtitleColor = ChatColor.WHITE;
/* Title timings */
private int fadeInTime = -1;
private int stayTime = -1;
private int fadeOutTime = -1;
private boolean ticks = false;
public TitleManager_1_11() {
loadClasses();
}
/**
* Create a new 1.8 title
*
* @param title Title
*/
public TitleManager_1_11(String title) {
this.title = title;
loadClasses();
}
/**
* Create a new 1.8 title
*
* @param title Title text
* @param subtitle Subtitle text
*/
public TitleManager_1_11(String title, String subtitle) {
this.title = title;
this.subtitle = subtitle;
loadClasses();
}
/**
* Copy 1.8 title
*
* @param title Title
*/
public TitleManager_1_11(TitleManager_1_11 title) {
// Copy title
this.title = title.getTitle();
this.subtitle = title.getSubtitle();
this.titleColor = title.getTitleColor();
this.subtitleColor = title.getSubtitleColor();
this.fadeInTime = title.getFadeInTime();
this.fadeOutTime = title.getFadeOutTime();
this.stayTime = title.getStayTime();
this.ticks = title.isTicks();
loadClasses();
}
/**
* Create a new 1.8 title
*
* @param title Title text
* @param subtitle Subtitle text
* @param fadeInTime Fade in time
* @param stayTime Stay on screen time
* @param fadeOutTime Fade out time
*/
public TitleManager_1_11(String title, String subtitle, int fadeInTime, int stayTime,
int fadeOutTime) {
this.title = title;
this.subtitle = subtitle;
this.fadeInTime = fadeInTime;
this.stayTime = stayTime;
this.fadeOutTime = fadeOutTime;
loadClasses();
}
private static boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
if (a.length != o.length)
return false;
for (int i = 0; i < a.length; i++)
if (!a[i].equals(o[i]) && !a[i].isAssignableFrom(o[i]))
return false;
return true;
}
/**
* Load spigot and NMS classes
*/
private void loadClasses() {
if (packetTitle == null) {
packetTitle = getNMSClass("PacketPlayOutTitle");
packetActions = getNMSClass("PacketPlayOutTitle$EnumTitleAction");
chatBaseComponent = getNMSClass("IChatBaseComponent");
nmsChatSerializer = getNMSClass("ChatComponentText");
nmsPlayer = getNMSClass("EntityPlayer");
nmsPlayerConnection = getNMSClass("PlayerConnection");
playerConnection = getField(nmsPlayer, "playerConnection");
sendPacket = getMethod(nmsPlayerConnection, "sendPacket");
obcPlayer = getOBCClass("entity.CraftPlayer");
methodPlayerGetHandle = getMethod("getHandle", obcPlayer);
}
}
/**
* Get title text
*
* @return Title text
*/
public String getTitle() {
return this.title;
}
/**
* Set title text
*
* @param title Title
*/
public void setTitle(String title) {
this.title = title;
}
/**
* Get subtitle text
*
* @return Subtitle text
*/
public String getSubtitle() {
return this.subtitle;
}
/**
* Set subtitle text
*
* @param subtitle Subtitle text
*/
public void setSubtitle(String subtitle) {
this.subtitle = subtitle;
}
/**
* Set timings to ticks
*/
public void setTimingsToTicks() {
ticks = true;
}
/**
* Set timings to seconds
*/
public void setTimingsToSeconds() {
ticks = false;
}
/**
* Send the title to a player
*
* @param player Player
*/
public void send(Player player) {
if (packetTitle != null) {
// First reset previous settings
resetTitle(player);
try {
// Send timings first
Object handle = getHandle(player);
Object connection = playerConnection.get(handle);
Object[] actions = packetActions.getEnumConstants();
Object packet = packetTitle
.getConstructor(packetActions, chatBaseComponent, Integer.TYPE, Integer.TYPE,
Integer.TYPE).newInstance(actions[3], null, fadeInTime * (ticks ? 1 : 20),
stayTime * (ticks ? 1 : 20), fadeOutTime * (ticks ? 1 : 20));
// Send if set
if (fadeInTime != -1 && fadeOutTime != -1 && stayTime != -1)
sendPacket.invoke(connection, packet);
Object serialized;
if (!subtitle.equals("")) {
// Send subtitle if present
serialized = nmsChatSerializer.getConstructor(String.class).newInstance(
subtitleColor + ChatColor.translateAlternateColorCodes('&', subtitle));
packet = packetTitle.getConstructor(packetActions, chatBaseComponent)
.newInstance(actions[1], serialized);
sendPacket.invoke(connection, packet);
}
// Send title
serialized = nmsChatSerializer.getConstructor(String.class)
.newInstance(titleColor + ChatColor.translateAlternateColorCodes('&', title));
packet = packetTitle.getConstructor(packetActions, chatBaseComponent)
.newInstance(actions[0], serialized);
sendPacket.invoke(connection, packet);
} catch (Exception e) {
e.printStackTrace();
}
}
}
public void updateTimes(Player player) {
if (TitleManager_1_11.packetTitle != null) {
try {
Object handle = getHandle(player);
Object connection = playerConnection.get(handle);
Object[] actions = TitleManager_1_11.packetActions.getEnumConstants();
Object packet = TitleManager_1_11.packetTitle.getConstructor(
new Class[] {TitleManager_1_11.packetActions, chatBaseComponent, Integer.TYPE,
Integer.TYPE, Integer.TYPE})
.newInstance(actions[3], null, this.fadeInTime * (this.ticks ? 1 : 20),
this.stayTime * (this.ticks ? 1 : 20),
this.fadeOutTime * (this.ticks ? 1 : 20));
if ((this.fadeInTime != -1) && (this.fadeOutTime != -1) && (this.stayTime != -1)) {
sendPacket.invoke(connection, packet);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
public void updateTitle(Player player) {
if (TitleManager_1_11.packetTitle != null) {
try {
Object handle = getHandle(player);
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
Object[] actions = TitleManager_1_11.packetActions.getEnumConstants();
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
Object serialized = nmsChatSerializer.getConstructor(String.class).newInstance(
titleColor + ChatColor.translateAlternateColorCodes('&', this.title));
Object packet = TitleManager_1_11.packetTitle.getConstructor(
new Class[] {TitleManager_1_11.packetActions, chatBaseComponent})
.newInstance(actions[0], serialized);
sendPacket.invoke(connection, packet);
} catch (Exception e) {
e.printStackTrace();
}
}
}
public void updateSubtitle(Player player) {
if (TitleManager_1_11.packetTitle != null) {
try {
Object handle = getHandle(player);
Object connection = playerConnection.get(handle);
Object[] actions = TitleManager_1_11.packetActions.getEnumConstants();
Object serialized = nmsChatSerializer.getConstructor(String.class).newInstance(
subtitleColor + ChatColor.translateAlternateColorCodes('&', this.subtitle));
Object packet = TitleManager_1_11.packetTitle.getConstructor(
new Class[] {TitleManager_1_11.packetActions, chatBaseComponent})
.newInstance(actions[1], serialized);
sendPacket.invoke(connection, packet);
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* Broadcast the title to all players
*/
public void broadcast() {
for (Player p : Bukkit.getOnlinePlayers()) {
send(p);
}
}
/**
* Clear the title
*
* @param player Player
*/
public void clearTitle(Player player) {
try {
// Send timings first
Object handle = getHandle(player);
Object connection = playerConnection.get(handle);
Object[] actions = packetActions.getEnumConstants();
Object packet = packetTitle.getConstructor(packetActions, chatBaseComponent)
.newInstance(actions[4], null);
sendPacket.invoke(connection, packet);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Reset the title settings
*
* @param player Player
*/
public void resetTitle(Player player) {
try {
// Send timings first
Object handle = getHandle(player);
Object connection = playerConnection.get(handle);
Object[] actions = packetActions.getEnumConstants();
Object packet = packetTitle.getConstructor(packetActions, chatBaseComponent)
.newInstance(actions[5], null);
sendPacket.invoke(connection, packet);
} catch (Exception e) {
e.printStackTrace();
}
}
private Class<?> getPrimitiveType(Class<?> clazz) {
return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES.get(clazz) : clazz;
}
private Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) {
int a = classes != null ? classes.length : 0;
Class<?>[] types = new Class<?>[a];
for (int i = 0; i < a; i++)
types[i] = getPrimitiveType(classes[i]);
return types;
}
private Object getHandle(Player player) {
try {
return methodPlayerGetHandle.invoke(player);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
private Method getMethod(String name, Class<?> clazz, Class<?>... paramTypes) {
Class<?>[] t = toPrimitiveTypeArray(paramTypes);
for (Method m : clazz.getMethods()) {
Class<?>[] types = toPrimitiveTypeArray(m.getParameterTypes());
if (m.getName().equals(name) && equalsTypeArray(types, t))
return m;
}
return null;
}
private String getVersion() {
String name = Bukkit.getServer().getClass().getPackage().getName();
String version = name.substring(name.lastIndexOf('.') + 1) + ".";
return version;
}
private Class<?> getNMSClass(String className) {
String fullName = "net.minecraft.server." + getVersion() + className;
Class<?> clazz = null;
try {
clazz = Class.forName(fullName);
} catch (Exception e) {
e.printStackTrace();
}
return clazz;
}
private Class<?> getOBCClass(String className) {
String fullName = "org.bukkit.craftbukkit." + getVersion() + className;
Class<?> clazz = null;
try {
clazz = Class.forName(fullName);
} catch (Exception e) {
e.printStackTrace();
}
return clazz;
}
private Field getField(Class<?> clazz, String name) {
try {
Field field = clazz.getDeclaredField(name);
field.setAccessible(true);
return field;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
private Method getMethod(Class<?> clazz, String name, Class<?>... args) {
for (Method m : clazz.getMethods())
if (m.getName().equals(name) && (args.length == 0 || ClassListEqual(args,
m.getParameterTypes()))) {
m.setAccessible(true);
return m;
}
return null;
}
private boolean ClassListEqual(Class<?>[] l1, Class<?>[] l2) {
boolean equal = true;
if (l1.length != l2.length)
return false;
for (int i = 0; i < l1.length; i++)
if (l1[i] != l2[i]) {
equal = false;
break;
}
return equal;
}
public ChatColor getTitleColor() {
return titleColor;
}
/**
* Set the title color
*
* @param color Chat color
*/
public void setTitleColor(ChatColor color) {
this.titleColor = color;
}
public ChatColor getSubtitleColor() {
return subtitleColor;
}
/**
* Set the subtitle color
*
* @param color Chat color
*/
public void setSubtitleColor(ChatColor color) {
this.subtitleColor = color;
}
public int getFadeInTime() {
return fadeInTime;
}
/**
* Set title fade in time
*
* @param time Time
*/
public void setFadeInTime(int time) {
this.fadeInTime = time;
}
public int getFadeOutTime() {
return fadeOutTime;
}
/**
* Set title fade out time
*
* @param time Time
*/
public void setFadeOutTime(int time) {
this.fadeOutTime = time;
}
public int getStayTime() {
return stayTime;
}
/**
* Set title stay time
*
* @param time Time
*/
public void setStayTime(int time) {
this.stayTime = time;
}
public boolean isTicks() {
return ticks;
}
}

View File

@ -1,18 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.plot.object.BlockRegistry;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import lombok.NonNull;
import org.bukkit.Material;
public class BukkitBlockRegistry extends BlockRegistry<Material> {
public BukkitBlockRegistry(final Material... preInitializedItems) {
super(Material.class, preInitializedItems);
}
@Override public PlotBlock getPlotBlock(@NonNull final Material item) {
return PlotBlock.get(item.name());
}
}

View File

@ -1,54 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.bukkit.chat.FancyMessage;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
import com.github.intellectualsites.plotsquared.plot.config.C;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.object.ConsolePlayer;
import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.ChatManager;
import org.bukkit.ChatColor;
import java.util.ArrayList;
import java.util.List;
public class BukkitChatManager extends ChatManager<FancyMessage> {
@Override public FancyMessage builder() {
return new FancyMessage("");
}
@Override public void color(PlotMessage message, String color) {
message.$(this).color(ChatColor.getByChar(C.color(color).substring(1)));
}
@Override public void tooltip(PlotMessage message, PlotMessage... tooltips) {
List<FancyMessage> lines = new ArrayList<>();
for (PlotMessage tooltip : tooltips) {
lines.add(tooltip.$(this));
}
message.$(this).formattedTooltip(lines);
}
@Override public void command(PlotMessage message, String command) {
message.$(this).command(command);
}
@Override public void text(PlotMessage message, String text) {
message.$(this).then(ChatColor.stripColor(text));
}
@Override public void send(PlotMessage plotMessage, PlotPlayer player) {
if (player instanceof ConsolePlayer || !Settings.Chat.INTERACTIVE) {
player.sendMessage(plotMessage.$(this).toOldMessageFormat());
} else {
plotMessage.$(this).send(((BukkitPlayer) player).player);
}
}
@Override public void suggest(PlotMessage plotMessage, String command) {
plotMessage.$(this).suggest(command);
}
}

View File

@ -1,55 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.bukkit.commands.DebugUUID;
import com.github.intellectualsites.plotsquared.plot.commands.MainCommand;
import com.github.intellectualsites.plotsquared.plot.object.ConsolePlayer;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import org.bukkit.command.*;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class BukkitCommand implements CommandExecutor, TabCompleter {
public BukkitCommand() {
new DebugUUID();
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String commandLabel,
String[] args) {
if (commandSender instanceof Player) {
return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), args);
}
if (commandSender instanceof ConsoleCommandSender
|| commandSender instanceof ProxiedCommandSender
|| commandSender instanceof RemoteConsoleCommandSender) {
return MainCommand.onCommand(ConsolePlayer.getConsole(), args);
}
return false;
}
@Override
public List<String> onTabComplete(CommandSender commandSender, Command command, String s,
String[] args) {
if (!(commandSender instanceof Player)) {
return null;
}
PlotPlayer player = BukkitUtil.getPlayer((Player) commandSender);
if (args.length == 0) {
return Collections.singletonList("plots");
}
Collection objects = MainCommand.getInstance().tab(player, args, s.endsWith(" "));
if (objects == null) {
return null;
}
List<String> result = new ArrayList<>();
for (Object o : objects) {
result.add(o.toString());
}
return result.isEmpty() ? null : result;
}
}

View File

@ -1,83 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitOfflinePlayer;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
import com.github.intellectualsites.plotsquared.plot.object.OfflinePlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;
public class BukkitEconHandler extends EconHandler {
private Economy econ;
private Permission perms;
public boolean init() {
if (this.econ == null || this.perms == null) {
setupPermissions();
setupEconomy();
}
return this.econ != null && this.perms != null;
}
private boolean setupPermissions() {
RegisteredServiceProvider<Permission> permissionProvider =
Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
if (permissionProvider != null) {
this.perms = permissionProvider.getProvider();
}
return this.perms != null;
}
private boolean setupEconomy() {
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
}
RegisteredServiceProvider<Economy> economyProvider =
Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
if (economyProvider != null) {
this.econ = economyProvider.getProvider();
}
return this.econ != null;
}
@Override public double getMoney(PlotPlayer player) {
double bal = super.getMoney(player);
if (Double.isNaN(bal)) {
return this.econ.getBalance(((BukkitPlayer) player).player);
}
return bal;
}
@Override public void withdrawMoney(PlotPlayer player, double amount) {
this.econ.withdrawPlayer(((BukkitPlayer) player).player, amount);
}
@Override public void depositMoney(PlotPlayer player, double amount) {
this.econ.depositPlayer(((BukkitPlayer) player).player, amount);
}
@Override public void depositMoney(OfflinePlotPlayer player, double amount) {
this.econ.depositPlayer(((BukkitOfflinePlayer) player).player, amount);
}
@Override public boolean hasPermission(String world, String player, String perm) {
return this.perms.playerHas(world, Bukkit.getOfflinePlayer(player), perm);
}
@Override public double getBalance(PlotPlayer player) {
return this.econ.getBalance(player.getName());
}
public void setPermission(String world, String player, String perm, boolean value) {
if (value) {
this.perms.playerAdd(world, player, perm);
} else {
this.perms.playerRemove(world, player, perm);
}
}
}

View File

@ -1,106 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.bukkit.events.*;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
import com.github.intellectualsites.plotsquared.plot.object.*;
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.UUID;
public class BukkitEventUtil extends EventUtil {
public Player getPlayer(PlotPlayer player) {
if (player instanceof BukkitPlayer) {
return ((BukkitPlayer) player).player;
}
return null;
}
public boolean callEvent(Event event) {
Bukkit.getServer().getPluginManager().callEvent(event);
return !(event instanceof Cancellable) || !((Cancellable) event).isCancelled();
}
@Override public boolean callClaim(PlotPlayer player, Plot plot, boolean auto) {
return callEvent(new PlayerClaimPlotEvent(getPlayer(player), plot, auto));
}
@Override public boolean callTeleport(PlotPlayer player, Location from, Plot plot) {
return callEvent(new PlayerTeleportToPlotEvent(getPlayer(player), from, plot));
}
@Override public boolean callComponentSet(Plot plot, String component) {
return callEvent(new PlotComponentSetEvent(plot, component));
}
@Override public boolean callClear(Plot plot) {
return callEvent(new PlotClearEvent(plot));
}
@Override public void callDelete(Plot plot) {
callEvent(new PlotDeleteEvent(plot));
}
@Override public boolean callFlagAdd(Flag flag, Plot plot) {
return callEvent(new PlotFlagAddEvent(flag, plot));
}
@Override public boolean callFlagRemove(Flag<?> flag, Plot plot, Object value) {
return callEvent(new PlotFlagRemoveEvent(flag, plot));
}
@Override public boolean callMerge(Plot plot, ArrayList<PlotId> plots) {
return callEvent(new PlotMergeEvent(BukkitUtil.getWorld(plot.getWorldName()), plot, plots));
}
@Override public boolean callUnlink(PlotArea area, ArrayList<PlotId> plots) {
return callEvent(new PlotUnlinkEvent(BukkitUtil.getWorld(area.worldname), area, plots));
}
@Override public void callEntry(PlotPlayer player, Plot plot) {
callEvent(new PlayerEnterPlotEvent(getPlayer(player), plot));
}
@Override public void callLeave(PlotPlayer player, Plot plot) {
callEvent(new PlayerLeavePlotEvent(getPlayer(player), plot));
}
@Override public void callDenied(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
callEvent(new PlayerPlotDeniedEvent(getPlayer(initiator), plot, player, added));
}
@Override public void callTrusted(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
callEvent(new PlayerPlotTrustedEvent(getPlayer(initiator), plot, player, added));
}
@Override public void callMember(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
callEvent(new PlayerPlotHelperEvent(getPlayer(initiator), plot, player, added));
}
@Override
public boolean callOwnerChange(PlotPlayer initiator, Plot plot, UUID oldOwner, UUID newOwner,
boolean hasOldOwner) {
return callEvent(
new PlotChangeOwnerEvent(getPlayer(initiator), plot, oldOwner, newOwner, hasOldOwner));
}
@Override public boolean callFlagRemove(Flag flag, Object object, PlotCluster cluster) {
return callEvent(new ClusterFlagRemoveEvent(flag, cluster));
}
@Override @Nullable public Rating callRating(PlotPlayer player, Plot plot, Rating rating) {
PlotRateEvent event = new PlotRateEvent(player, rating, plot);
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return null;
}
return event.getRating();
}
}

View File

@ -1,262 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis;
public class BukkitHybridUtils extends HybridUtils {
@Override public void analyzeRegion(final String world, final RegionWrapper region,
final RunnableVal<PlotAnalysis> whenDone) {
// int diff, int variety, int vertices, int rotation, int height_sd
/*
* diff: compare to base by looping through all blocks
* variety: add to HashSet for each PlotBlock
* height_sd: loop over all blocks and get top block
*
* vertices: store air map and compare with neighbours
* for each block check the adjacent
* - Store all blocks then go through in second loop
* - recheck each block
*
*/
/* TODO: Redo
TaskManager.runTaskAsync(new Runnable() {
@Override public void run() {
final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
final World worldObj = Bukkit.getWorld(world);
final ChunkGenerator gen = worldObj.getGenerator();
if (gen == null) {
return;
}
final BiomeGrid nullBiomeGrid = new BiomeGrid() {
@Override public void setBiome(int a, int b, Biome c) {
}
@Override public Biome getBiome(int a, int b) {
return null;
}
};
final Location bot = new Location(world, region.minX, region.minY, region.minZ);
final Location top = new Location(world, region.maxX, region.maxY, region.maxZ);
final int bx = bot.getX();
final int bz = bot.getZ();
final int tx = top.getX();
final int tz = top.getZ();
final int cbx = bx >> 4;
final int cbz = bz >> 4;
final int ctx = tx >> 4;
final int ctz = tz >> 4;
final Random r = new Random();
MainUtil.initCache();
final int width = tx - bx + 1;
final int length = tz - bz + 1;
System.gc();
System.gc();
final short[][][] oldBlocks = new short[256][width][length];
final short[][][] newBlocks = new short[256][width][length];
final Runnable run = new Runnable() {
@Override public void run() {
ChunkManager.chunkTask(bot, top, new RunnableVal<int[]>() {
@Override public void run(int[] value) {
// [chunkx, chunkz, pos1x, pos1z, pos2x, pos2z, isedge]
int X = value[0];
int Z = value[1];
short[][] result =
gen.generateExtBlockSections(worldObj, r, X, Z, nullBiomeGrid);
int xb = (X << 4) - bx;
int zb = (Z << 4) - bz;
for (int i = 0; i < result.length; i++) {
if (result[i] == null) {
for (int j = 0; j < 4096; j++) {
int x = MainUtil.x_loc[i][j] + xb;
if (x < 0 || x >= width) {
continue;
}
int z = MainUtil.z_loc[i][j] + zb;
if (z < 0 || z >= length) {
continue;
}
int y = MainUtil.y_loc[i][j];
oldBlocks[y][x][z] = 0;
}
continue;
}
for (int j = 0; j < result[i].length; j++) {
int x = MainUtil.x_loc[i][j] + xb;
if (x < 0 || x >= width) {
continue;
}
int z = MainUtil.z_loc[i][j] + zb;
if (z < 0 || z >= length) {
continue;
}
int y = MainUtil.y_loc[i][j];
oldBlocks[y][x][z] = result[i][j];
}
}
}
}, new Runnable() {
@Override public void run() {
TaskManager.runTaskAsync(new Runnable() {
@Override public void run() {
int size = width * length;
int[] changes = new int[size];
int[] faces = new int[size];
int[] data = new int[size];
int[] air = new int[size];
int[] variety = new int[size];
int i = 0;
for (int x = 0; x < width; x++) {
for (int z = 0; z < length; z++) {
HashSet<Short> types = new HashSet<>();
for (int y = 0; y < 256; y++) {
short old = oldBlocks[y][x][z];
short now = newBlocks[y][x][z];
if (old != now) {
changes[i]++;
}
if (now == 0) {
air[i]++;
} else {
// check vertices
// modifications_adjacent
if (x > 0 && z > 0 && y > 0 && x < width - 1
&& z < length - 1 && y < 255) {
if (newBlocks[y - 1][x][z] == 0) {
faces[i]++;
}
if (newBlocks[y][x - 1][z] == 0) {
faces[i]++;
}
if (newBlocks[y][x][z - 1] == 0) {
faces[i]++;
}
if (newBlocks[y + 1][x][z] == 0) {
faces[i]++;
}
if (newBlocks[y][x + 1][z] == 0) {
faces[i]++;
}
if (newBlocks[y][x][z + 1] == 0) {
faces[i]++;
}
}
Material material =
Material.getMaterial(now);
if (material != null) {
Class<? extends MaterialData> md =
material.getData();
if (md.equals(Directional.class)) {
data[i] += 8;
} else if (!md
.equals(MaterialData.class)) {
data[i]++;
}
}
types.add(now);
}
}
variety[i] = types.size();
i++;
}
}
// analyze plot
// put in analysis obj
// run whenDone
PlotAnalysis analysis = new PlotAnalysis();
analysis.changes = (int) (MathMan.getMean(changes) * 100);
analysis.faces = (int) (MathMan.getMean(faces) * 100);
analysis.data = (int) (MathMan.getMean(data) * 100);
analysis.air = (int) (MathMan.getMean(air) * 100);
analysis.variety = (int) (MathMan.getMean(variety) * 100);
analysis.changes_sd =
(int) MathMan.getSD(changes, analysis.changes);
analysis.faces_sd =
(int) MathMan.getSD(faces, analysis.faces);
analysis.data_sd = (int) MathMan.getSD(data, analysis.data);
analysis.air_sd = (int) MathMan.getSD(air, analysis.air);
analysis.variety_sd =
(int) MathMan.getSD(variety, analysis.variety);
System.gc();
System.gc();
whenDone.value = analysis;
whenDone.run();
}
});
}
}, 5);
}
};
System.gc();
MainUtil.initCache();
ChunkManager.chunkTask(bot, top, new RunnableVal<int[]>() {
@Override public void run(int[] value) {
int X = value[0];
int Z = value[1];
worldObj.loadChunk(X, Z);
int minX;
if (X == cbx) {
minX = bx & 15;
} else {
minX = 0;
}
int minZ;
if (Z == cbz) {
minZ = bz & 15;
} else {
minZ = 0;
}
int maxX;
if (X == ctx) {
maxX = tx & 15;
} else {
maxX = 16;
}
int maxZ;
if (Z == ctz) {
maxZ = tz & 15;
} else {
maxZ = 16;
}
int cbx = X << 4;
int cbz = Z << 4;
int xb = cbx - bx;
int zb = cbz - bz;
for (int x = minX; x <= maxX; x++) {
int xx = cbx + x;
for (int z = minZ; z <= maxZ; z++) {
int zz = cbz + z;
for (int y = 0; y < 256; y++) {
PlotBlock block = queue.getBlock(xx, y, zz);
int xr = xb + x;
int zr = zb + z;
newBlocks[y][xr][zr] = block.id;
}
}
}
worldObj.unloadChunkRequest(X, Z, true);
}
}, new Runnable() {
@Override public void run() {
TaskManager.runTaskAsync(run);
}
}, 5);
}
});
*/
}
}

View File

@ -1,828 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.plot.object.LegacyPlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.StringPlotBlock;
import com.github.intellectualsites.plotsquared.plot.util.LegacyMappings;
import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
import lombok.*;
import org.bukkit.Material;
import java.util.*;
import java.util.stream.Collectors;
/**
* Borrowed from https://github.com/Phoenix616/IDConverter/blob/master/mappings/src/main/java/de/themoep/idconverter/IdMappings.java
* Original License:
* <p>
* Minecraft ID mappings
* Copyright (C) 2017 Max Lee (https://github.com/Phoenix616)
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
public final class BukkitLegacyMappings extends LegacyMappings {
private static final LegacyBlock[] BLOCKS =
new LegacyBlock[] {new LegacyBlock(0, "air"), new LegacyBlock(1, "stone"),
new LegacyBlock(1, 1, "stone", "granite"),
new LegacyBlock(1, 2, "stone", "polished_granite"),
new LegacyBlock(1, 3, "stone", "diorite"),
new LegacyBlock(1, 4, "stone", "polished_diorite"),
new LegacyBlock(1, 5, "stone", "andesite"),
new LegacyBlock(1, 6, "stone", "polished_andesite"),
new LegacyBlock(2, "grass", "grass_block"), new LegacyBlock(3, "dirt"),
new LegacyBlock(3, 1, "dirt", "coarse_dirt"), new LegacyBlock(3, 2, "dirt", "podzol"),
new LegacyBlock(4, "cobblestone"), new LegacyBlock(5, "wood", "oak_planks"),
new LegacyBlock(5, 1, "wood", "spruce_planks"),
new LegacyBlock(5, 2, "wood", "birch_planks"),
new LegacyBlock(5, 3, "wood", "jungle_planks"),
new LegacyBlock(5, 4, "wood", "acacia_planks"),
new LegacyBlock(5, 5, "wood", "dark_oak_planks"),
new LegacyBlock(6, "sapling", "oak_sapling"),
new LegacyBlock(6, 1, "sapling", "spruce_sapling"),
new LegacyBlock(6, 2, "sapling", "birch_sapling"),
new LegacyBlock(6, 3, "sapling", "jungle_sapling"),
new LegacyBlock(6, 4, "sapling", "acacia_sapling"),
new LegacyBlock(6, 5, "sapling", "dark_oak_sapling"), new LegacyBlock(7, "bedrock"),
new LegacyBlock(8, "water", "flowing_water"),
new LegacyBlock(9, "stationary_water", "water"),
new LegacyBlock(10, "lava", "flowing_lava"),
new LegacyBlock(11, "stationary_lava", "lava"), new LegacyBlock(12, "sand"),
new LegacyBlock(12, 1, "sand", "red_sand"), new LegacyBlock(13, "gravel"),
new LegacyBlock(14, "gold_ore"), new LegacyBlock(15, "iron_ore"),
new LegacyBlock(16, "coal_ore"), new LegacyBlock(17, "log", "oak_log"),
new LegacyBlock(17, 1, "log", "oak_log"), new LegacyBlock(17, 2, "log", "spruce_log"),
new LegacyBlock(17, 3, "log", "birch_log"), new LegacyBlock(17, 4, "log", "jungle_log"),
new LegacyBlock(17, 5, "log", "oak_bark"), new LegacyBlock(17, 6, "log", "spruce_bark"),
new LegacyBlock(17, 7, "log", "birch_bark"),
new LegacyBlock(17, 8, "log", "jungle_bark"),
new LegacyBlock(18, "leaves", "oak_leaves"),
new LegacyBlock(18, 1, "leaves", "spruce_leaves"),
new LegacyBlock(18, 2, "leaves", "birch_leaves"),
new LegacyBlock(18, 3, "leaves", "jungle_leaves"), new LegacyBlock(19, "sponge"),
new LegacyBlock(19, 1, "sponge", "wet_sponge"), new LegacyBlock(20, "glass"),
new LegacyBlock(21, "lapis_ore"), new LegacyBlock(22, "lapis_block"),
new LegacyBlock(23, "dispenser"), new LegacyBlock(24, "sandstone"),
new LegacyBlock(24, 1, "sandstone", "chisled_sandstone"),
new LegacyBlock(24, 2, "sandstone", "cut_sandstone"), new LegacyBlock(25, "note_block"),
new LegacyBlock(26, "bed_block"), new LegacyBlock(27, "powered_rail"),
new LegacyBlock(28, "detector_rail"),
new LegacyBlock(29, "piston_sticky_base", "sticky_piston"),
new LegacyBlock(30, "web", "cobweb"), new LegacyBlock(31, "long_grass", "dead_bush"),
new LegacyBlock(31, 1, "long_grass", "grass"),
new LegacyBlock(31, 2, "long_grass", "fern"), new LegacyBlock(32, "dead_bush"),
new LegacyBlock(33, "piston_base", "piston"),
new LegacyBlock(34, "piston_extension", "piston_head"),
new LegacyBlock(35, "wool", "white_wool"),
new LegacyBlock(35, 1, "wool", "orange_wool"),
new LegacyBlock(35, 2, "wool", "magenta_wool"),
new LegacyBlock(35, 3, "wool", "light_blue_wool"),
new LegacyBlock(35, 4, "wool", "yellow_wool"),
new LegacyBlock(35, 5, "wool", "lime_wool"),
new LegacyBlock(35, 6, "wool", "pink_wool"),
new LegacyBlock(35, 7, "wool", "gray_wool"),
new LegacyBlock(35, 8, "wool", "light_gray_wool"),
new LegacyBlock(35, 9, "wool", "cyan_wool"),
new LegacyBlock(35, 10, "wool", "purple_wool"),
new LegacyBlock(35, 11, "wool", "blue_wool"),
new LegacyBlock(35, 12, "wool", "brown_wool"),
new LegacyBlock(35, 13, "wool", "green_wool"),
new LegacyBlock(35, 14, "wool", "red_wool"),
new LegacyBlock(35, 15, "wool", "black_wool"),
new LegacyBlock(36, "piston_moving_piece", "moving_piston"),
new LegacyBlock(37, "yellow_flower", "dandelion"),
new LegacyBlock(38, "red_rose", "poppy"),
new LegacyBlock(38, 1, "red_rose", "blue_orchid"),
new LegacyBlock(38, 2, "red_rose", "allium"),
new LegacyBlock(38, 3, "red_rose", "azure_bluet"),
new LegacyBlock(38, 4, "red_rose", "red_tulip"),
new LegacyBlock(38, 5, "red_rose", "orange_tulip"),
new LegacyBlock(38, 6, "red_rose", "white_tulip"),
new LegacyBlock(38, 7, "red_rose", "pink_tulip"),
new LegacyBlock(38, 8, "red_rose", "oxeye_daisy"),
new LegacyBlock(39, "brown_mushroom"), new LegacyBlock(40, "red_mushroom"),
new LegacyBlock(41, "gold_block"), new LegacyBlock(42, "iron_block"),
new LegacyBlock(43, "double_step"),
new LegacyBlock(43, 6, "double_step", "smooth_quartz"),
new LegacyBlock(43, 8, "double_step", "smooth_stone"),
new LegacyBlock(43, 9, "double_step", "smooth_sandstone"),
new LegacyBlock(44, "step", "stone_slab"),
new LegacyBlock(44, 1, "step", "sandstone_slab"),
new LegacyBlock(44, 2, "step", "petrified_oak_slab"),
new LegacyBlock(44, 3, "step", "cobblestone_slab"),
new LegacyBlock(44, 4, "step", "brick_slab"),
new LegacyBlock(44, 5, "step", "stone_brick_slab"),
new LegacyBlock(44, 6, "step", "nether_brick_slab"),
new LegacyBlock(44, 7, "step", "quartz_slab"), new LegacyBlock(45, "brick", "bricks"),
new LegacyBlock(46, "tnt"), new LegacyBlock(47, "bookshelf"),
new LegacyBlock(48, "mossy_cobblestone"), new LegacyBlock(49, "obsidian"),
new LegacyBlock(50, "torch"), new LegacyBlock(50, 1, "torch", "wall_torch"),
new LegacyBlock(50, 2, "torch", "wall_torch"),
new LegacyBlock(50, 3, "torch", "wall_torch"),
new LegacyBlock(50, 4, "torch", "wall_torch"), new LegacyBlock(50, 5, "torch"),
new LegacyBlock(51, "fire"), new LegacyBlock(52, "mob_spawner"),
new LegacyBlock(53, "wood_stairs", "oak_stairs"), new LegacyBlock(54, "chest", "chest"),
new LegacyBlock(55, "redstone_wire"), new LegacyBlock(56, "diamond_ore"),
new LegacyBlock(57, "diamond_block"),
new LegacyBlock(58, "workbench", "crafting_table"),
new LegacyBlock(59, "crops", "wheat"), new LegacyBlock(60, "soil", "farmland"),
new LegacyBlock(61, "furnace"), new LegacyBlock(62, "burning_furnace"),
new LegacyBlock(63, "sign_post", "sign"),
new LegacyBlock(64, "wooden_door", "oak_door"), new LegacyBlock(65, "ladder"),
new LegacyBlock(66, "rails", "rail"), new LegacyBlock(67, "cobblestone_stairs"),
new LegacyBlock(68, "wall_sign"), new LegacyBlock(69, "lever"),
new LegacyBlock(70, "stone_plate", "stone_pressure_plate"),
new LegacyBlock(71, "iron_door_block", "iron_door"),
new LegacyBlock(72, "wood_plate", "oak_pressure_plate"),
new LegacyBlock(73, "redstone_ore"), new LegacyBlock(74, "glowing_redstone_ore"),
new LegacyBlock(75, "redstone_torch_off"),
new LegacyBlock(76, "redstone_torch_on", "redstone_torch"),
new LegacyBlock(76, 1, "redstone_torch_on", "redstone_wall_torch"),
new LegacyBlock(76, 2, "redstone_torch_on", "redstone_wall_torch"),
new LegacyBlock(76, 3, "redstone_torch_on", "redstone_wall_torch"),
new LegacyBlock(76, 4, "redstone_torch_on", "redstone_wall_torch"),
new LegacyBlock(76, 5, "redstone_torch_on", "redstone_torch"),
new LegacyBlock(77, "stone_button"), new LegacyBlock(78, "snow"),
new LegacyBlock(79, "ice"), new LegacyBlock(80, "snow_block"),
new LegacyBlock(81, "cactus"), new LegacyBlock(82, "clay"),
new LegacyBlock(83, "sugar_cane_block", "sugar_cane"), new LegacyBlock(84, "jukebox"),
new LegacyBlock(85, "fence", "oak_fence"),
new LegacyBlock(86, "pumpkin", "carved_pumpkin"), new LegacyBlock(87, "netherrack"),
new LegacyBlock(88, "soul_sand"), new LegacyBlock(89, "glowstone"),
new LegacyBlock(90, "portal"), new LegacyBlock(91, "jack_o_lantern"),
new LegacyBlock(92, "cake_block", "cake"), new LegacyBlock(93, "diode_block_off"),
new LegacyBlock(94, "diode_block_on", "repeater"),
new LegacyBlock(95, "stained_glass", "white_stained_glass"),
new LegacyBlock(95, 1, "stained_glass", "orange_stained_glass"),
new LegacyBlock(95, 2, "stained_glass", "magenta_stained_glass"),
new LegacyBlock(95, 3, "stained_glass", "light_blue_stained_glass"),
new LegacyBlock(95, 4, "stained_glass", "yellow_stained_glass"),
new LegacyBlock(95, 5, "stained_glass", "lime_stained_glass"),
new LegacyBlock(95, 6, "stained_glass", "pink_stained_glass"),
new LegacyBlock(95, 7, "stained_glass", "gray_stained_glass"),
new LegacyBlock(95, 8, "stained_glass", "light_gray_stained_glass"),
new LegacyBlock(95, 9, "stained_glass", "cyan_stained_glass"),
new LegacyBlock(95, 10, "stained_glass", "purple_stained_glass"),
new LegacyBlock(95, 11, "stained_glass", "blue_stained_glass"),
new LegacyBlock(95, 12, "stained_glass", "brown_stained_glass"),
new LegacyBlock(95, 13, "stained_glass", "green_stained_glass"),
new LegacyBlock(95, 14, "stained_glass", "red_stained_glass"),
new LegacyBlock(95, 15, "stained_glass", "black_stained_glass"),
new LegacyBlock(96, "trap_door", "oak_trapdoor"),
new LegacyBlock(97, "monster_eggs", "infested_stone"),
new LegacyBlock(97, 1, "monster_eggs", "infested_coblestone"),
new LegacyBlock(97, 2, "monster_eggs", "infested_stone_bricks"),
new LegacyBlock(97, 3, "monster_eggs", "infested_mossy_stone_bricks"),
new LegacyBlock(97, 4, "monster_eggs", "infested_crcked_stone_bricks"),
new LegacyBlock(97, 5, "monster_eggs", "infested_chiseled_stone_bricks"),
new LegacyBlock(98, "smooth_brick", "stone_bricks"),
new LegacyBlock(98, 1, "smooth_brick", "mossy_stone_bricks"),
new LegacyBlock(98, 2, "smooth_brick", "cracked_stone_bricks"),
new LegacyBlock(98, 3, "smooth_brick", "chiseled_bricks"),
new LegacyBlock(99, "huge_mushroom_1", "brown_mushroom_block"),
new LegacyBlock(99, 1, "huge_mushroom_1"), new LegacyBlock(99, 2, "huge_mushroom_1"),
new LegacyBlock(99, 3, "huge_mushroom_1"), new LegacyBlock(99, 4, "huge_mushroom_1"),
new LegacyBlock(99, 5, "huge_mushroom_1"), new LegacyBlock(99, 6, "huge_mushroom_1"),
new LegacyBlock(99, 7, "huge_mushroom_1"), new LegacyBlock(99, 8, "huge_mushroom_1"),
new LegacyBlock(99, 9, "huge_mushroom_1"),
new LegacyBlock(99, 10, "huge_mushroom_1", "mushroom_stem"),
new LegacyBlock(99, 14, "huge_mushroom_1"), new LegacyBlock(99, 15, "huge_mushroom_1"),
new LegacyBlock(100, "huge_mushroom_2", "red_mushroom_block"),
new LegacyBlock(100, 1, "huge_mushroom_2"), new LegacyBlock(100, 2, "huge_mushroom_2"),
new LegacyBlock(100, 3, "huge_mushroom_2"), new LegacyBlock(100, 4, "huge_mushroom_2"),
new LegacyBlock(100, 5, "huge_mushroom_2"), new LegacyBlock(100, 6, "huge_mushroom_2"),
new LegacyBlock(100, 7, "huge_mushroom_2"), new LegacyBlock(100, 8, "huge_mushroom_2"),
new LegacyBlock(100, 9, "huge_mushroom_2"),
new LegacyBlock(100, 10, "huge_mushroom_2", "mushroom_stem"),
new LegacyBlock(100, 14, "huge_mushroom_2"),
new LegacyBlock(100, 15, "huge_mushroom_2"),
new LegacyBlock(101, "iron_fence", "ironbars"),
new LegacyBlock(102, "thin_glass", "glass_pane"), new LegacyBlock(103, "melon_block"),
new LegacyBlock(104, "pumpkin_stem"), new LegacyBlock(105, "melon_stem"),
new LegacyBlock(106, "vine"), new LegacyBlock(107, "fence_gate", "oak_fence_gate"),
new LegacyBlock(108, "brick_stairs"),
new LegacyBlock(109, "smooth_stairs", "stone_brick_stairs"),
new LegacyBlock(110, "mycel", "mycelium"),
new LegacyBlock(111, "water_lily", "lily_pad"),
new LegacyBlock(112, "nether_brick", "nether_bricks"),
new LegacyBlock(113, "nether_fence", "nether_brick_fence"),
new LegacyBlock(114, "nether_brick_stairs"),
new LegacyBlock(115, "nether_warts", "nether_wart"),
new LegacyBlock(116, "enchantment_table", "enchanting_table"),
new LegacyBlock(117, "brewing_stand"), new LegacyBlock(118, "cauldron"),
new LegacyBlock(119, "ender_portal", "end_portal"),
new LegacyBlock(120, "ender_portal_frame", "end_portal_frame"),
new LegacyBlock(121, "ender_stone", "end_stone"), new LegacyBlock(122, "dragon_egg"),
new LegacyBlock(123, "redstone_lamp_off"),
new LegacyBlock(124, "redstone_lamp_on", "redstone_lamp"),
new LegacyBlock(125, "wood_double_step"), new LegacyBlock(125, 1, "wood_double_step"),
new LegacyBlock(125, 2, "wood_double_step"),
new LegacyBlock(125, 3, "wood_double_step"),
new LegacyBlock(125, 4, "wood_double_step"),
new LegacyBlock(125, 5, "wood_double_step"),
new LegacyBlock(126, "wood_step", "oak_slab"),
new LegacyBlock(126, 1, "wood_step", "spruce_slab"),
new LegacyBlock(126, 2, "wood_step", "birch_slab"),
new LegacyBlock(126, 3, "wood_step", "jungle_slab"),
new LegacyBlock(126, 4, "wood_step", "acacia_slab"),
new LegacyBlock(126, 5, "wood_step", "dark_oak_slab"), new LegacyBlock(127, "cocoa"),
new LegacyBlock(128, "sandstone_stairs"), new LegacyBlock(129, "emerald_ore"),
new LegacyBlock(130, "ender_chest"), new LegacyBlock(131, "tripwire_hook"),
new LegacyBlock(132, "tripwire"), new LegacyBlock(133, "emerald_block"),
new LegacyBlock(134, "spruce_wood_stairs", "spruce_stairs"),
new LegacyBlock(135, "birch_wood_stairs", "birch_stairs"),
new LegacyBlock(136, "jungle_wood_stairs", "jungle_stairs"),
new LegacyBlock(137, "command", "command_block"), new LegacyBlock(138, "beacon"),
new LegacyBlock(139, "cobble_wall", "cobblestone_wall"),
new LegacyBlock(139, 1, "cobble_wall", "mossy_cobblestone_wall"),
new LegacyBlock(140, "flower_pot"), new LegacyBlock(141, "carrot", "carrots"),
new LegacyBlock(142, "potato", "potatoes"),
new LegacyBlock(143, "wood_button", "oak_button"),
new LegacyBlock(144, "skull", "skeleton_skull"),
new LegacyBlock(144, 1, "skull", "skeleton_wall_skull"),
new LegacyBlock(144, 2, "skull", "skeleton_wall_skull"),
new LegacyBlock(144, 3, "skull", "skeleton_wall_skull"),
new LegacyBlock(144, 4, "skull", "skeleton_wall_skull"),
new LegacyBlock(144, 5, "skull", "skeleton_wall_skull"), new LegacyBlock(145, "anvil"),
new LegacyBlock(145, 1, "anvil", "chipped_anvil"),
new LegacyBlock(145, 2, "anvil", "damaged_anvil"),
new LegacyBlock(146, "trapped_chest"),
new LegacyBlock(147, "gold_plate", "light_weighted_pressure_plate"),
new LegacyBlock(148, "iron_plate", "heavy_weighted_pressure_plate"),
new LegacyBlock(149, "redstone_comparator_off"),
new LegacyBlock(150, "redstone_comparator_on", "comparator"),
new LegacyBlock(151, "daylight_detector"), new LegacyBlock(152, "redstone_block"),
new LegacyBlock(153, "quartz_ore", "nether_quartz_ore"), new LegacyBlock(154, "hopper"),
new LegacyBlock(155, "quartz_block"), new LegacyBlock(156, "quartz_stairs"),
new LegacyBlock(157, "activator_rail"), new LegacyBlock(158, "dropper"),
new LegacyBlock(159, "stained_clay", "white_terracotta"),
new LegacyBlock(159, 1, "stained_clay", "orange_terracotta"),
new LegacyBlock(159, 2, "stained_clay", "magenta_terracotta"),
new LegacyBlock(159, 3, "stained_clay", "light_blue_terracotta"),
new LegacyBlock(159, 4, "stained_clay", "yellow_terracotta"),
new LegacyBlock(159, 5, "stained_clay", "lime_terracotta"),
new LegacyBlock(159, 6, "stained_clay", "pink_terracotta"),
new LegacyBlock(159, 7, "stained_clay", "gray_terracotta"),
new LegacyBlock(159, 8, "stained_clay", "light_gray_terracotta"),
new LegacyBlock(159, 9, "stained_clay", "cyan_terracotta"),
new LegacyBlock(159, 10, "stained_clay", "purple_terracotta"),
new LegacyBlock(159, 11, "stained_clay", "blue_terracotta"),
new LegacyBlock(159, 12, "stained_clay", "brown_terracotta"),
new LegacyBlock(159, 13, "stained_clay", "green_terracotta"),
new LegacyBlock(159, 14, "stained_clay", "red_terracotta"),
new LegacyBlock(159, 15, "stained_clay", "black_terracotta"),
new LegacyBlock(160, "stained_glass_pane", "white_stained_glass_pane"),
new LegacyBlock(160, 1, "stained_glass_pane", "orange_stained_glass_pane"),
new LegacyBlock(160, 2, "stained_glass_pane", "magenta_stained_glass_pane"),
new LegacyBlock(160, 3, "stained_glass_pane", "light_blue_stained_glass_pane"),
new LegacyBlock(160, 4, "stained_glass_pane", "yellow_stained_glass_pane"),
new LegacyBlock(160, 5, "stained_glass_pane", "lime_stained_glass_pane"),
new LegacyBlock(160, 6, "stained_glass_pane", "pink_stained_glass_pane"),
new LegacyBlock(160, 7, "stained_glass_pane", "gray_stained_glass_pane"),
new LegacyBlock(160, 8, "stained_glass_pane", "light_gray_stained_glass_pane"),
new LegacyBlock(160, 9, "stained_glass_pane", "cyan_stained_glass_pane"),
new LegacyBlock(160, 10, "stained_glass_pane", "purple_stained_glass_pane"),
new LegacyBlock(160, 11, "stained_glass_pane", "blue_stained_glass_pane"),
new LegacyBlock(160, 12, "stained_glass_pane", "brown_stained_glass_pane"),
new LegacyBlock(160, 13, "stained_glass_pane", "green_stained_glass_pane"),
new LegacyBlock(160, 14, "stained_glass_pane", "red_stained_glass_pane"),
new LegacyBlock(160, 15, "stained_glass_pane", "black_stained_glass_pane"),
new LegacyBlock(161, "leaves_2", "acacia_leaves"),
new LegacyBlock(161, 1, "leaves_2", "dark_oak_leaves"),
new LegacyBlock(162, "log_2", "acacia_log"),
new LegacyBlock(162, 1, "log_2", "spruce_log"),
new LegacyBlock(162, 2, "log_2", "birch_log"),
new LegacyBlock(162, 3, "log_2", "jungle_log"),
new LegacyBlock(163, "acacia_stairs", "acacia_stairs"),
new LegacyBlock(164, "dark_oak_stairs", "dark_oak_stairs"),
new LegacyBlock(165, "slime_block", "slime_block"),
new LegacyBlock(166, "barrier", "barrier"),
new LegacyBlock(167, "iron_trapdoor", "iron_trapdoor"),
new LegacyBlock(168, "prismarine"),
new LegacyBlock(168, 1, "prismarine", "prismarine_bricks"),
new LegacyBlock(168, 2, "prismarine", "dark_prismarine"),
new LegacyBlock(169, "sea_lantern"), new LegacyBlock(170, "hay_block"),
new LegacyBlock(171, "carpet", "white_carpet"),
new LegacyBlock(171, 1, "carpet", "orange_carpet"),
new LegacyBlock(171, 2, "carpet", "magenta_carpet"),
new LegacyBlock(171, 3, "carpet", "light_blue_carpet"),
new LegacyBlock(171, 4, "carpet", "yellow_carpet"),
new LegacyBlock(171, 5, "carpet", "lime_carpet"),
new LegacyBlock(171, 6, "carpet", "pink_carpet"),
new LegacyBlock(171, 7, "carpet", "gray_carpet"),
new LegacyBlock(171, 8, "carpet", "light_gray_carpet"),
new LegacyBlock(171, 9, "carpet", "cyan_carpet"),
new LegacyBlock(171, 10, "carpet", "purple_carpet"),
new LegacyBlock(171, 11, "carpet", "blue_carpet"),
new LegacyBlock(171, 12, "carpet", "brown_carpet"),
new LegacyBlock(171, 13, "carpet", "green_carpet"),
new LegacyBlock(171, 14, "carpet", "red_carpet"),
new LegacyBlock(171, 15, "carpet", "black_carpet"),
new LegacyBlock(172, "hard_clay", "terracotta"), new LegacyBlock(173, "coal_block"),
new LegacyBlock(174, "packed_ice"), new LegacyBlock(175, "double_plant", "sunflower"),
new LegacyBlock(175, 1, "double_plant", "lilac"),
new LegacyBlock(175, 2, "double_plant", "tall_grass"),
new LegacyBlock(175, 3, "double_plant", "large_fern"),
new LegacyBlock(175, 4, "double_plant", "rose_bush"),
new LegacyBlock(175, 5, "double_plant", "peony"),
new LegacyBlock(176, "standing_banner"), new LegacyBlock(177, "wall_banner"),
new LegacyBlock(178, "daylight_detector_inverted"),
new LegacyBlock(179, "red_sandstone", "red_sandstone"),
new LegacyBlock(179, 1, "red_sandstone", "chiseled_red_sandstone"),
new LegacyBlock(179, 2, "red_sandstone", "cut_red_sandstone"),
new LegacyBlock(180, "red_sandstone_stairs"),
new LegacyBlock(181, "double_stone_slab2"),
new LegacyBlock(181, 8, "double_stone_slab2", "smooth_red_sandstone"),
new LegacyBlock(182, "stone_slab2", "red_sandstone_slab"),
new LegacyBlock(183, "spruce_fence_gate"), new LegacyBlock(184, "birch_fence_gate"),
new LegacyBlock(185, "jungle_fence_gate"), new LegacyBlock(186, "dark_oak_fence_gate"),
new LegacyBlock(187, "acacia_fence_gate"), new LegacyBlock(188, "spruce_fence"),
new LegacyBlock(189, "birch_fence"), new LegacyBlock(190, "jungle_fence"),
new LegacyBlock(191, "dark_oak_fence"), new LegacyBlock(192, "acacia_fence"),
new LegacyBlock(193, "spruce_door"), new LegacyBlock(194, "birch_door"),
new LegacyBlock(195, "jungle_door"), new LegacyBlock(196, "acacia_door"),
new LegacyBlock(197, "dark_oak_door"), new LegacyBlock(198, "end_rod"),
new LegacyBlock(199, "chorus_plant"), new LegacyBlock(200, "chorus_flower"),
new LegacyBlock(201, "purpur_block"), new LegacyBlock(202, "purpur_pillar"),
new LegacyBlock(203, "purpur_stairs"), new LegacyBlock(204, "purpur_double_slab"),
new LegacyBlock(205, "purpur_slab"),
new LegacyBlock(206, "end_bricks", "end_stone_bricks"),
new LegacyBlock(207, "beetroot_block", "beetroots"), new LegacyBlock(208, "grass_path"),
new LegacyBlock(209, "end_gateway"),
new LegacyBlock(210, "command_repeating", "repeating_command_block"),
new LegacyBlock(211, "command_chain", "chain_command_block"),
new LegacyBlock(212, "frosted_ice"), new LegacyBlock(213, "magma", "magma_block"),
new LegacyBlock(214, "nether_wart_block"),
new LegacyBlock(215, "red_nether_brick", "red_nether_bricks"),
new LegacyBlock(216, "bone_block"), new LegacyBlock(217, "structure_void"),
new LegacyBlock(218, "observer"), new LegacyBlock(219, "white_shulker_box"),
new LegacyBlock(220, "orange_shulker_box"), new LegacyBlock(221, "magenta_shulker_box"),
new LegacyBlock(222, "light_blue_shulker_box"),
new LegacyBlock(223, "yellow_shulker_box"), new LegacyBlock(224, "lime_shulker_box"),
new LegacyBlock(225, "pink_shulker_box"), new LegacyBlock(226, "gray_shulker_box"),
new LegacyBlock(227, "silver_shulker_box", "light_gray_shulker_box"),
new LegacyBlock(228, "cyan_shulker_box"), new LegacyBlock(229, "purple_shulker_box"),
new LegacyBlock(230, "blue_shulker_box"), new LegacyBlock(231, "brown_shulker_box"),
new LegacyBlock(232, "green_shulker_box"), new LegacyBlock(233, "red_shulker_box"),
new LegacyBlock(234, "black_shulker_box"),
new LegacyBlock(235, "white_glazed_terracotta"),
new LegacyBlock(236, "orange_glazed_terracotta"),
new LegacyBlock(237, "magenta_glazed_terracotta"),
new LegacyBlock(238, "light_blue_glazed_terracotta"),
new LegacyBlock(239, "yellow_glazed_terracotta"),
new LegacyBlock(240, "lime_glazed_terracotta"),
new LegacyBlock(241, "pink_glazed_terracotta"),
new LegacyBlock(242, "gray_glazed_terracotta"),
new LegacyBlock(243, "silver_glazed_terracotta", "light_gray_glazed_terracotta"),
new LegacyBlock(244, "cyan_glazed_terracotta"),
new LegacyBlock(245, "purple_glazed_terracotta"),
new LegacyBlock(246, "blue_glazed_terracotta"),
new LegacyBlock(247, "brown_glazed_terracotta"),
new LegacyBlock(248, "green_glazed_terracotta"),
new LegacyBlock(249, "red_glazed_terracotta"),
new LegacyBlock(250, "black_glazed_terracotta"),
new LegacyBlock(251, "concrete", "white_concrete"),
new LegacyBlock(251, 1, "concrete", "orange_concrete"),
new LegacyBlock(251, 2, "concrete", "magenta_concrete"),
new LegacyBlock(251, 3, "concrete", "light_blue_concrete"),
new LegacyBlock(251, 4, "concrete", "yellow_concrete"),
new LegacyBlock(251, 5, "concrete", "lime_concrete"),
new LegacyBlock(251, 6, "concrete", "pink_concrete"),
new LegacyBlock(251, 7, "concrete", "gray_concrete"),
new LegacyBlock(251, 8, "concrete", "light_gray_concrete"),
new LegacyBlock(251, 9, "concrete", "cyan_concrete"),
new LegacyBlock(251, 10, "concrete", "purple_concrete"),
new LegacyBlock(251, 11, "concrete", "blue_concrete"),
new LegacyBlock(251, 12, "concrete", "brown_concrete"),
new LegacyBlock(251, 13, "concrete", "green_concrete"),
new LegacyBlock(251, 14, "concrete", "red_concrete"),
new LegacyBlock(251, 15, "concrete", "black_concrete"),
new LegacyBlock(252, "concrete_powder", "white_concrete_powder"),
new LegacyBlock(252, 1, "concrete_powder", "orange_concrete_powder"),
new LegacyBlock(252, 2, "concrete_powder", "magenta_concrete_powder"),
new LegacyBlock(252, 3, "concrete_powder", "light_blue_concrete_powder"),
new LegacyBlock(252, 4, "concrete_powder", "yellow_concrete_powder"),
new LegacyBlock(252, 5, "concrete_powder", "lime_concrete_powder"),
new LegacyBlock(252, 6, "concrete_powder", "pink_concrete_powder"),
new LegacyBlock(252, 7, "concrete_powder", "gray_concrete_powder"),
new LegacyBlock(252, 8, "concrete_powder", "light_gray_concrete_powder"),
new LegacyBlock(252, 9, "concrete_powder", "cyan_concrete_powder"),
new LegacyBlock(252, 10, "concrete_powder", "purple_concrete_powder"),
new LegacyBlock(252, 11, "concrete_powder", "blue_concrete_powder"),
new LegacyBlock(252, 12, "concrete_powder", "brown_concrete_powder"),
new LegacyBlock(252, 13, "concrete_powder", "green_concrete_powder"),
new LegacyBlock(252, 14, "concrete_powder", "red_concrete_powder"),
new LegacyBlock(252, 15, "concrete_powder", "black_concrete_powder"),
new LegacyBlock(255, "structure_block"),
new LegacyBlock(256, "iron_spade", "iron_shovel"), new LegacyBlock(257, "iron_pickaxe"),
new LegacyBlock(258, "iron_axe"), new LegacyBlock(259, "flint_and_steel"),
new LegacyBlock(260, "apple"), new LegacyBlock(261, "bow"),
new LegacyBlock(262, "arrow"), new LegacyBlock(263, "coal"),
new LegacyBlock(263, 1, "coal", "charcoal"), new LegacyBlock(264, "diamond"),
new LegacyBlock(265, "iron_ingot"), new LegacyBlock(266, "gold_ingot"),
new LegacyBlock(267, "iron_sword"), new LegacyBlock(268, "wood_sword", "wooden_sword"),
new LegacyBlock(269, "wood_spade", "wooden_shovel"),
new LegacyBlock(270, "wood_pickaxe", "wooden_pickaxe"),
new LegacyBlock(271, "wood_axe", "wooden_axe"), new LegacyBlock(272, "stone_sword"),
new LegacyBlock(273, "stone_spade", "stone_shovel"),
new LegacyBlock(274, "stone_pickaxe"), new LegacyBlock(275, "stone_axe"),
new LegacyBlock(276, "diamond_sword"),
new LegacyBlock(277, "diamond_spade", "diamond_shovel"),
new LegacyBlock(278, "diamond_pickaxe"), new LegacyBlock(279, "diamond_axe"),
new LegacyBlock(280, "stick"), new LegacyBlock(281, "bowl"),
new LegacyBlock(282, "mushroom_soup", "mushroom_stew"),
new LegacyBlock(283, "gold_sword", "golden_sword"),
new LegacyBlock(284, "gold_spade", "golden_shovel"),
new LegacyBlock(285, "gold_pickaxe", "golden_pickaxe"),
new LegacyBlock(286, "gold_axe", "golden_axe"), new LegacyBlock(287, "string"),
new LegacyBlock(288, "feather"), new LegacyBlock(289, "sulphur", "gunpowder"),
new LegacyBlock(290, "wood_hoe", "wooden_hoe"), new LegacyBlock(291, "stone_hoe"),
new LegacyBlock(292, "iron_hoe"), new LegacyBlock(293, "diamond_hoe"),
new LegacyBlock(294, "gold_hoe", "golden_hoe"),
new LegacyBlock(295, "seeds", "wheat_seeds"), new LegacyBlock(296, "wheat"),
new LegacyBlock(297, "bread"), new LegacyBlock(298, "leather_helmet"),
new LegacyBlock(299, "leather_chestplate"), new LegacyBlock(300, "leather_leggings"),
new LegacyBlock(301, "leather_boots"), new LegacyBlock(302, "chainmail_helmet"),
new LegacyBlock(303, "chainmail_chestplate"),
new LegacyBlock(304, "chainmail_leggings"), new LegacyBlock(305, "chainmail_boots"),
new LegacyBlock(306, "iron_helmet"), new LegacyBlock(307, "iron_chestplate"),
new LegacyBlock(308, "iron_leggings"), new LegacyBlock(309, "iron_boots"),
new LegacyBlock(310, "diamond_helmet"), new LegacyBlock(311, "diamond_chestplate"),
new LegacyBlock(312, "diamond_leggings"), new LegacyBlock(313, "diamond_boots"),
new LegacyBlock(314, "gold_helmet", "golden_helmet"),
new LegacyBlock(315, "gold_chestplate", "golden_chestplate"),
new LegacyBlock(316, "gold_leggings", "golden_leggings"),
new LegacyBlock(317, "gold_boots", "golden_boots"), new LegacyBlock(318, "flint"),
new LegacyBlock(319, "pork", "porkchop"),
new LegacyBlock(320, "grilled_pork", "cooked_porkchop"),
new LegacyBlock(321, "painting"), new LegacyBlock(322, "golden_apple", "golden_apple"),
new LegacyBlock(322, 1, "golden_apple", "enchanted_golden_apple"),
new LegacyBlock(323, "sign"), new LegacyBlock(324, "wood_door", "oak_door"),
new LegacyBlock(325, "bucket"), new LegacyBlock(326, "water_bucket"),
new LegacyBlock(327, "lava_bucket"), new LegacyBlock(328, "minecart"),
new LegacyBlock(329, "saddle"), new LegacyBlock(330, "iron_door"),
new LegacyBlock(331, "redstone"), new LegacyBlock(332, "snow_ball", "snowball"),
new LegacyBlock(333, "boat", "oak_boat"), new LegacyBlock(334, "leather"),
new LegacyBlock(335, "milk_bucket"), new LegacyBlock(336, "clay_brick", "brick"),
new LegacyBlock(337, "clay_ball"), new LegacyBlock(338, "sugar_cane"),
new LegacyBlock(339, "paper"), new LegacyBlock(340, "book"),
new LegacyBlock(341, "slime_ball"),
new LegacyBlock(342, "storage_minecart", "chest_minecart"),
new LegacyBlock(343, "powered_minecart", "furnace_minecart"),
new LegacyBlock(344, "egg"), new LegacyBlock(345, "compass"),
new LegacyBlock(346, "fishing_rod"), new LegacyBlock(347, "watch", "clock"),
new LegacyBlock(348, "glowstone_dust"), new LegacyBlock(349, "raw_fish", "cod"),
new LegacyBlock(349, 1, "raw_fish", "salmon"),
new LegacyBlock(349, 2, "raw_fish", "tropical_fish"),
new LegacyBlock(349, 3, "raw_fish", "pufferfish"),
new LegacyBlock(350, "cooked_fish", "cooked_cod"),
new LegacyBlock(350, 1, "cooked_fish", "cooked_salmon"),
new LegacyBlock(351, "ink_sack", "ink_sac"),
new LegacyBlock(351, 1, "ink_sack", "rose_red"),
new LegacyBlock(351, 2, "ink_sack", "cactus_green"),
new LegacyBlock(351, 3, "ink_sack", "cocoa_beans"),
new LegacyBlock(351, 4, "ink_sack", "lapis_lazuli"),
new LegacyBlock(351, 5, "ink_sack", "purple_dye"),
new LegacyBlock(351, 6, "ink_sack", "cyan_dye"),
new LegacyBlock(351, 7, "ink_sack", "light_gray_dye"),
new LegacyBlock(351, 8, "ink_sack", "gray_dye"),
new LegacyBlock(351, 9, "ink_sack", "pink_dye"),
new LegacyBlock(351, 10, "ink_sack", "lime_dye"),
new LegacyBlock(351, 11, "ink_sack", "dandelion_yellow"),
new LegacyBlock(351, 12, "ink_sack", "light_blue_dye"),
new LegacyBlock(351, 13, "ink_sack", "magenta_dye"),
new LegacyBlock(351, 14, "ink_sack", "orange_dye"),
new LegacyBlock(351, 15, "ink_sack", "bone_meal"), new LegacyBlock(352, "bone"),
new LegacyBlock(353, "sugar", "sugar"), new LegacyBlock(354, "cake", "cake"),
new LegacyBlock(355, "bed", "white_bed"), new LegacyBlock(355, 1, "bed", "orange_bed"),
new LegacyBlock(355, 2, "bed", "magenta_bed"),
new LegacyBlock(355, 3, "bed", "light_blue_bed"),
new LegacyBlock(355, 4, "bed", "yellow_bed"),
new LegacyBlock(355, 5, "bed", "lime_bed"), new LegacyBlock(355, 6, "bed", "pink_bed"),
new LegacyBlock(355, 7, "bed", "gray_bed"),
new LegacyBlock(355, 8, "bed", "light_gray_bed"),
new LegacyBlock(355, 9, "bed", "cyan_bed"),
new LegacyBlock(355, 10, "bed", "purple_bed"),
new LegacyBlock(355, 11, "bed", "blue_bed"),
new LegacyBlock(355, 12, "bed", "brown_bed"),
new LegacyBlock(355, 13, "bed", "green_bed"),
new LegacyBlock(355, 14, "bed", "red_bed"),
new LegacyBlock(355, 15, "bed", "black_bed"), new LegacyBlock(356, "diode", "repeater"),
new LegacyBlock(357, "cookie", "cookie"), new LegacyBlock(358, "map"),
new LegacyBlock(359, "shears"), new LegacyBlock(360, "melon", "melon"),
new LegacyBlock(361, "pumpkin_seeds", "pumpkin_seeds"),
new LegacyBlock(362, "melon_seeds", "melon_seeds"),
new LegacyBlock(363, "raw_beef", "beef"), new LegacyBlock(364, "cooked_beef"),
new LegacyBlock(365, "raw_chicken", "chicken"), new LegacyBlock(366, "cooked_chicken"),
new LegacyBlock(367, "rotten_flesh"), new LegacyBlock(368, "ender_pearl"),
new LegacyBlock(369, "blaze_rod"), new LegacyBlock(370, "ghast_tear"),
new LegacyBlock(371, "gold_nugget"),
new LegacyBlock(372, "nether_stalk", "nether_wart"),
new LegacyBlock(373, "potion", "potion"), new LegacyBlock(374, "glass_bottle"),
new LegacyBlock(375, "spider_eye"), new LegacyBlock(376, "fermented_spider_eye"),
new LegacyBlock(377, "blaze_powder"), new LegacyBlock(378, "magma_cream"),
new LegacyBlock(379, "brewing_stand_item", "brewing_stand"),
new LegacyBlock(380, "cauldron_item", "cauldron"),
new LegacyBlock(381, "eye_of_ender", "ender_eye"),
new LegacyBlock(382, "speckled_melon"), new LegacyBlock(383, "monster_egg"),
new LegacyBlock(383, 4, "monster_egg", "elder_guardian_spawn_egg"),
new LegacyBlock(383, 5, "monster_egg", "wither_skeleton_spawn_egg"),
new LegacyBlock(383, 6, "monster_egg", "stray_spawn_egg"),
new LegacyBlock(383, 23, "monster_egg", "husk_spawn_egg"),
new LegacyBlock(383, 27, "monster_egg", "zombe_villager_spawn_egg"),
new LegacyBlock(383, 28, "monster_egg", "skeleton_horse_spawn_egg"),
new LegacyBlock(383, 29, "monster_egg", "zombie_horse_spawn_egg"),
new LegacyBlock(383, 31, "monster_egg", "donkey_spawn_egg"),
new LegacyBlock(383, 32, "monster_egg", "mule_spawn_egg"),
new LegacyBlock(383, 34, "monster_egg", "evocation_illager_spawn_egg"),
new LegacyBlock(383, 35, "monster_egg", "vex_spawn_egg"),
new LegacyBlock(383, 36, "monster_egg", "vindication_illager_spawn_egg"),
new LegacyBlock(383, 50, "monster_egg", "creeper_spawn_egg"),
new LegacyBlock(383, 51, "monster_egg", "skeleton_spawn_egg"),
new LegacyBlock(383, 52, "monster_egg", "spider_spawn_egg"),
new LegacyBlock(383, 54, "monster_egg", "zombie_spawn_egg"),
new LegacyBlock(383, 55, "monster_egg", "slime_spawn_egg"),
new LegacyBlock(383, 56, "monster_egg", "ghast_spawn_egg"),
new LegacyBlock(383, 57, "monster_egg", "zombie_pigman_spawn_egg"),
new LegacyBlock(383, 58, "monster_egg", "enderman_spawn_egg"),
new LegacyBlock(383, 59, "monster_egg", "cave_spider_spawn_egg"),
new LegacyBlock(383, 60, "monster_egg", "silverfish_spawn_egg"),
new LegacyBlock(383, 61, "monster_egg", "blaze_spawn_egg"),
new LegacyBlock(383, 62, "monster_egg", "magma_cube_spawn_egg"),
new LegacyBlock(383, 65, "monster_egg", "bat_spawn_egg"),
new LegacyBlock(383, 66, "monster_egg", "witch_spawn_egg"),
new LegacyBlock(383, 67, "monster_egg", "endermite_spawn_egg"),
new LegacyBlock(383, 68, "monster_egg", "guardian_spawn_egg"),
new LegacyBlock(383, 69, "monster_egg", "shulker_spawn_egg"),
new LegacyBlock(383, 90, "monster_egg", "pig_spawn_egg"),
new LegacyBlock(383, 91, "monster_egg", "sheep_spawn_egg"),
new LegacyBlock(383, 92, "monster_egg", "cow_spawn_egg"),
new LegacyBlock(383, 93, "monster_egg", "chicken_spawn_egg"),
new LegacyBlock(383, 94, "monster_egg", "squid_spawn_egg"),
new LegacyBlock(383, 95, "monster_egg", "wolf_spawn_egg"),
new LegacyBlock(383, 96, "monster_egg", "mooshroom_spawn_egg"),
new LegacyBlock(383, 98, "monster_egg", "ocelot_spawn_egg"),
new LegacyBlock(383, 100, "monster_egg", "horse_spawn_egg"),
new LegacyBlock(383, 101, "monster_egg", "rabbit_spawn_egg"),
new LegacyBlock(383, 102, "monster_egg", "polar_bear_spawn_egg"),
new LegacyBlock(383, 103, "monster_egg", "llama_spawn_egg"),
new LegacyBlock(383, 120, "monster_egg", "villager_spawn_egg"),
new LegacyBlock(384, "exp_bottle", "experience_bottle"),
new LegacyBlock(385, "fireball", "fire_charge"),
new LegacyBlock(386, "book_and_quill", "writable_book"),
new LegacyBlock(387, "written_book"), new LegacyBlock(388, "emerald"),
new LegacyBlock(389, "item_frame"),
new LegacyBlock(390, "flower_pot_item", "flower_pot"),
new LegacyBlock(391, "carrot_item", "carrot"),
new LegacyBlock(392, "potato_item", "potato"), new LegacyBlock(393, "baked_potato"),
new LegacyBlock(394, "poisonous_potato"), new LegacyBlock(395, "empty_map", "map"),
new LegacyBlock(396, "golden_carrot"),
new LegacyBlock(397, "skull_item", "skeleton_skull"),
new LegacyBlock(397, 1, "skull_item", "wither_skeleton_skull"),
new LegacyBlock(397, 2, "skull_item", "zombie_head"),
new LegacyBlock(397, 3, "skull_item", "player_head"),
new LegacyBlock(397, 4, "skull_item", "creeper_head"),
new LegacyBlock(397, 5, "skull_item", "dragon_head"),
new LegacyBlock(398, "carrot_stick"), new LegacyBlock(399, "nether_star"),
new LegacyBlock(400, "pumpkin_pie"),
new LegacyBlock(401, "firework", "firework_rocket"),
new LegacyBlock(402, "firework_charge", "firework_star"),
new LegacyBlock(403, "enchanted_book"),
new LegacyBlock(404, "redstone_comparator", "comparator"),
new LegacyBlock(405, "nether_brick_item", "nether_brick"),
new LegacyBlock(406, "quartz"),
new LegacyBlock(407, "explosive_minecart", "tnt_minecart"),
new LegacyBlock(408, "hopper_minecart"), new LegacyBlock(409, "prismarine_shard"),
new LegacyBlock(410, "prismarine_crystals"), new LegacyBlock(411, "rabbit"),
new LegacyBlock(412, "cooked_rabbit"), new LegacyBlock(413, "rabbit_stew"),
new LegacyBlock(414, "rabbit_foot"), new LegacyBlock(415, "rabbit_hide"),
new LegacyBlock(416, "armor_stand"),
new LegacyBlock(417, "iron_barding", "iron_horse_armor"),
new LegacyBlock(418, "gold_barding", "gold_horse_armor"),
new LegacyBlock(419, "diamond_barding", "diamond_horse_armor"),
new LegacyBlock(420, "leash", "lead"), new LegacyBlock(421, "name_tag"),
new LegacyBlock(422, "command_minecart", "command_block_minecart"),
new LegacyBlock(423, "mutton"), new LegacyBlock(424, "cooked_mutton"),
new LegacyBlock(425, "banner", "white_banner"),
new LegacyBlock(425, 1, "banner", "orange_banner"),
new LegacyBlock(425, 2, "banner", "magenta_banner"),
new LegacyBlock(425, 3, "banner", "light_blue_banner"),
new LegacyBlock(425, 4, "banner", "yellow_banner"),
new LegacyBlock(425, 5, "banner", "lime_banner"),
new LegacyBlock(425, 6, "banner", "pink_banner"),
new LegacyBlock(425, 7, "banner", "gray_banner"),
new LegacyBlock(425, 8, "banner", "light_gray_banner"),
new LegacyBlock(425, 9, "banner", "cyan_banner"),
new LegacyBlock(425, 10, "banner", "purple_banner"),
new LegacyBlock(425, 11, "banner", "blue_banner"),
new LegacyBlock(425, 12, "banner", "brown_banner"),
new LegacyBlock(425, 13, "banner", "green_banner"),
new LegacyBlock(425, 14, "banner", "red_banner"),
new LegacyBlock(425, 15, "banner", "black_banner"), new LegacyBlock(426, "end_crystal"),
new LegacyBlock(427, "spruce_door_item", "spruce_door"),
new LegacyBlock(428, "birch_door_item", "birch_door"),
new LegacyBlock(429, "jungle_door_item", "jungle_door"),
new LegacyBlock(430, "acacia_door_item", "acacia_door"),
new LegacyBlock(431, "dark_oak_door_item", "dark_oak_door"),
new LegacyBlock(432, "chorus_fruit"), new LegacyBlock(433, "chorus_fruit_popped"),
new LegacyBlock(434, "beetroot"), new LegacyBlock(435, "beetroot_seeds"),
new LegacyBlock(436, "beetroot_soup"),
new LegacyBlock(437, "dragons_breath", "dragon_breath"),
new LegacyBlock(438, "splash_potion"), new LegacyBlock(439, "spectral_arrow"),
new LegacyBlock(440, "tipped_arrow"), new LegacyBlock(441, "lingering_potion"),
new LegacyBlock(442, "shield"), new LegacyBlock(443, "elytra"),
new LegacyBlock(444, "boat_spruce", "spruce_boat"),
new LegacyBlock(445, "boat_birch", "birch_boat"),
new LegacyBlock(446, "boat_jungle", "jungle_boat"),
new LegacyBlock(447, "boat_acacia", "acacia_boat"),
new LegacyBlock(448, "boat_dark_oak", "dark_oak_boat"),
new LegacyBlock(449, "totem", "totem_of_undying"),
new LegacyBlock(450, "shulker_shell"), new LegacyBlock(452, "iron_nugget"),
new LegacyBlock(453, "knowledge_book"),
new LegacyBlock(2256, "gold_record", "music_disc_13"),
new LegacyBlock(2257, "green_record", "music_disc_cat"),
new LegacyBlock(2258, "record_3", "music_disc_blocks"),
new LegacyBlock(2259, "record_4", "music_disc_chirp"),
new LegacyBlock(2260, "record_5", "music_disc_far"),
new LegacyBlock(2261, "record_6", "music_disc_mall"),
new LegacyBlock(2262, "record_7", "music_disc_mellohi"),
new LegacyBlock(2263, "record_8", "music_disc_stal"),
new LegacyBlock(2264, "record_9", "music_disc_strad"),
new LegacyBlock(2265, "record_10", "music_disc_ward"),
new LegacyBlock(2266, "record_11", "music_disc_11"),
new LegacyBlock(2267, "record_12", "music_disc_wait")};
// private static final Map<Integer, PlotBlock> LEGACY_ID_TO_STRING_PLOT_BLOCK = new HashMap<>();
private static final Map<IdDataPair, PlotBlock> LEGACY_ID_AND_DATA_TO_STRING_PLOT_BLOCK =
new HashMap<>();
private static final Map<String, PlotBlock> NEW_STRING_TO_LEGACY_PLOT_BLOCK = new HashMap<>();
private static final Map<String, PlotBlock> OLD_STRING_TO_STRING_PLOT_BLOCK = new HashMap<>();
public BukkitLegacyMappings() {
this.addAll(Arrays.asList(BLOCKS));
// Make sure to add new blocks as well
final List<LegacyBlock> missing = new ArrayList<>();
for (final Material material : Material.values()) {
final String materialName = material.name().toLowerCase(Locale.ENGLISH);
if (OLD_STRING_TO_STRING_PLOT_BLOCK.get(materialName) == null) {
final LegacyBlock missingBlock =
new LegacyBlock(material.getId(), materialName, materialName);
missing.add(missingBlock);
}
}
addAll(missing);
}
private void addAll(@NonNull final Collection<LegacyBlock> blocks) {
for (final LegacyBlock legacyBlock : blocks) {
// LEGACY_ID_TO_STRING_PLOT_BLOCK
// .put(legacyBlock.getNumericalId(), legacyBlock.toStringPlotBlock());
/*if (legacyBlock.getDataValue() != 0) {
LEGACY_ID_AND_DATA_TO_STRING_PLOT_BLOCK
.put(new IdDataPair(legacyBlock.getNumericalId(), legacyBlock.getDataValue()),
legacyBlock.toStringPlotBlock());
} */
LEGACY_ID_AND_DATA_TO_STRING_PLOT_BLOCK
.put(new IdDataPair(legacyBlock.getNumericalId(), legacyBlock.getDataValue()),
legacyBlock.toStringPlotBlock());
NEW_STRING_TO_LEGACY_PLOT_BLOCK
.put(legacyBlock.getLegacyName(), legacyBlock.toStringPlotBlock());
OLD_STRING_TO_STRING_PLOT_BLOCK
.put(legacyBlock.getNewName(), legacyBlock.toLegacyPlotBlock());
Material material;
try {
material = Material.valueOf(legacyBlock.getNewName());
} catch (final Exception e) {
material = Material.getMaterial(legacyBlock.getLegacyName(), true);
}
legacyBlock.material = material;
}
}
public Collection<PlotBlock> getPlotBlocks() {
return Arrays.stream(BLOCKS).map(block -> PlotBlock.get(block.getNewName()))
.collect(Collectors.toList());
}
public StringComparison<PlotBlock>.ComparisonResult getClosestsMatch(
@NonNull final String string) {
final StringComparison<PlotBlock> comparison =
new StringComparison<>(string, getPlotBlocks());
return comparison.getBestMatchAdvanced();
}
/**
* Try to find a legacy plot block by any means possible.
* Strategy:
* - Check if the name contains a namespace, if so, strip it
* - Check if there's a (new) material matching the name
* - Check if there's a legacy material matching the name
* - Check if there's a numerical ID matching the name
* - Return null if everything else fails
*
* @param string String ID
* @return LegacyBlock if found, else null
*/
public PlotBlock fromAny(@NonNull final String string) {
if (string.isEmpty()) {
return StringPlotBlock.EVERYTHING;
}
String workingString = string;
String[] parts = null;
if (string.contains(":")) {
parts = string.split(":");
if (parts.length > 1) {
if (parts[0].equalsIgnoreCase("minecraft")) {
workingString = parts[1];
} else {
workingString = parts[0];
}
}
}
PlotBlock plotBlock;
if (NEW_STRING_TO_LEGACY_PLOT_BLOCK.keySet().contains(workingString.toLowerCase())) {
return PlotBlock.get(workingString);
} else if ((plotBlock = fromLegacyToString(workingString)) != null) {
return plotBlock;
} else {
try {
if (parts != null && parts.length > 1) {
final int id = Integer.parseInt(parts[0]);
final int data = Integer.parseInt(parts[1]);
return fromLegacyToString(id, data);
} else {
return fromLegacyToString(Integer.parseInt(workingString), 0);
}
} catch (final Throwable exception) {
return null;
}
}
}
public PlotBlock fromLegacyToString(final int id, final int data) {
return LEGACY_ID_AND_DATA_TO_STRING_PLOT_BLOCK.get(new IdDataPair(id, data));
}
public PlotBlock fromLegacyToString(final String id) {
return NEW_STRING_TO_LEGACY_PLOT_BLOCK.get(id);
}
public PlotBlock fromStringToLegacy(final String id) {
return OLD_STRING_TO_STRING_PLOT_BLOCK.get(id.toLowerCase(Locale.ENGLISH));
}
@Getter @EqualsAndHashCode @ToString @RequiredArgsConstructor
private static final class IdDataPair {
private final int id;
private final int data;
}
@Getter @RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public static final class LegacyBlock {
private final int numericalId;
private final int dataValue;
private final String legacyName;
private final String newName;
private Material material;
LegacyBlock(final int numericalId, final int dataValue, @NonNull final String legacyName) {
this(numericalId, dataValue, legacyName, legacyName);
}
LegacyBlock(final int numericalId, @NonNull final String legacyName,
@NonNull final String newName) {
this(numericalId, 0, legacyName, newName);
}
LegacyBlock(final int numericalId, @NonNull final String legacyName) {
this(numericalId, legacyName, legacyName);
}
PlotBlock toStringPlotBlock() {
return StringPlotBlock.get(newName);
}
PlotBlock toLegacyPlotBlock() {
return LegacyPlotBlock.get(numericalId, dataValue);
}
@Override public String toString() {
return this.newName;
}
}
}

View File

@ -1,201 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.bukkit.object.schematic.StateWrapper;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.sk89q.jnbt.*;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.block.BaseBlock;
import java.io.ByteArrayOutputStream;
import java.util.*;
import java.util.stream.IntStream;
/**
* Schematic Handler.
*/
public class BukkitSchematicHandler extends SchematicHandler {
@Override public void getCompoundTag(final String world, final Set<RegionWrapper> regions,
final RunnableVal<CompoundTag> whenDone) {
// async
TaskManager.runTaskAsync(new Runnable() {
@Override public void run() {
// Main positions
Location[] corners = MainUtil.getCorners(world, regions);
final Location bot = corners[0];
final Location top = corners[1];
CuboidRegion cuboidRegion =
new CuboidRegion(BukkitUtil.IMP.getWeWorld(world), bot.getBlockVector3(),
top.getBlockVector3());
final int width = cuboidRegion.getWidth();
int height = cuboidRegion.getHeight();
final int length = cuboidRegion.getLength();
Map<String, Tag> schematic = new HashMap<>();
schematic.put("Version", new IntTag(1));
Map<String, Tag> metadata = new HashMap<>();
metadata.put("WEOffsetX", new IntTag(0));
metadata.put("WEOffsetY", new IntTag(0));
metadata.put("WEOffsetZ", new IntTag(0));
schematic.put("Metadata", new CompoundTag(metadata));
schematic.put("Width", new ShortTag((short) width));
schematic.put("Height", new ShortTag((short) height));
schematic.put("Length", new ShortTag((short) length));
// The Sponge format Offset refers to the 'min' points location in the world. That's our 'Origin'
schematic.put("Offset", new IntArrayTag(new int[] {0, 0, 0,}));
Map<String, Integer> palette = new HashMap<>();
List<CompoundTag> tileEntities = new ArrayList<>();
ByteArrayOutputStream buffer = new ByteArrayOutputStream(width * height * length);
// Queue
final ArrayDeque<RegionWrapper> queue = new ArrayDeque<>(regions);
TaskManager.runTask(new Runnable() {
@Override public void run() {
if (queue.isEmpty()) {
TaskManager.runTaskAsync(() -> {
schematic.put("PaletteMax", new IntTag(palette.size()));
Map<String, Tag> paletteTag = new HashMap<>();
palette.forEach(
(key, value) -> paletteTag.put(key, new IntTag(value)));
schematic.put("Palette", new CompoundTag(paletteTag));
schematic.put("BlockData", new ByteArrayTag(buffer.toByteArray()));
schematic.put("TileEntities",
new ListTag(CompoundTag.class, tileEntities));
whenDone.value = new CompoundTag(schematic);
TaskManager.runTask(whenDone);
});
return;
}
final Runnable regionTask = this;
RegionWrapper region = queue.poll();
Location pos1 = new Location(world, region.minX, region.minY, region.minZ);
Location pos2 = new Location(world, region.maxX, region.maxY, region.maxZ);
final int p1x = pos1.getX();
final int sy = pos1.getY();
final int p1z = pos1.getZ();
final int p2x = pos2.getX();
final int p2z = pos2.getZ();
final int ey = pos2.getY();
Iterator<Integer> yiter = IntStream.range(sy, ey + 1).iterator();
final Runnable yTask = new Runnable() {
@Override public void run() {
long ystart = System.currentTimeMillis();
while (yiter.hasNext()
&& System.currentTimeMillis() - ystart < 20) {
final int y = yiter.next();
Iterator<Integer> ziter =
IntStream.range(p1z, p2z + 1).iterator();
final Runnable zTask = new Runnable() {
@Override public void run() {
long zstart = System.currentTimeMillis();
while (ziter.hasNext()
&& System.currentTimeMillis() - zstart < 20) {
final int z = ziter.next();
Iterator<Integer> xiter =
IntStream.range(p1x, p2x + 1).iterator();
final Runnable xTask = new Runnable() {
@Override public void run() {
long xstart = System.currentTimeMillis();
final int ry = y - sy;
final int rz = z - p1z;
while (xiter.hasNext()
&& System.currentTimeMillis() - xstart
< 20) {
final int x = xiter.next();
final int rx = x - p1x;
BlockVector3 point =
BlockVector3.at(x, y, z);
BaseBlock block =
cuboidRegion.getWorld()
.getFullBlock(point);
if (block.getNbtData() != null) {
Map<String, Tag> values =
new HashMap<>();
for (Map.Entry<String, Tag> entry : block
.getNbtData().getValue()
.entrySet()) {
values.put(entry.getKey(),
entry.getValue());
}
// Remove 'id' if it exists. We want 'Id'
values.remove("id");
// Positions are kept in NBT, we don't want that.
values.remove("x");
values.remove("y");
values.remove("z");
values.put("Id", new StringTag(
block.getNbtId()));
values.put("Pos", new IntArrayTag(
new int[] {rx, ry, rz}));
tileEntities
.add(new CompoundTag(values));
}
String blockKey =
block.toImmutableState()
.getAsString();
int blockId;
if (palette.containsKey(blockKey)) {
blockId = palette.get(blockKey);
} else {
blockId = palette.size();
palette
.put(blockKey, palette.size());
}
while ((blockId & -128) != 0) {
buffer.write(blockId & 127 | 128);
blockId >>>= 7;
}
buffer.write(blockId);
}
if (xiter.hasNext()) {
this.run();
}
}
};
xTask.run();
}
if (ziter.hasNext()) {
this.run();
}
}
};
zTask.run();
}
if (yiter.hasNext()) {
TaskManager.runTaskLater(this, 1);
} else {
regionTask.run();
}
}
};
yTask.run();
}
});
}
});
}
@Override
public boolean restoreTile(LocalBlockQueue queue, CompoundTag ct, int x, int y, int z) {
return new StateWrapper(ct).restoreTag(queue.getWorld(), x, y, z);
}
}

View File

@ -1,251 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.bukkit.generator.BukkitPlotGenerator;
import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection;
import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode;
import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.SetupObject;
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
import org.bukkit.*;
import org.bukkit.World.Environment;
import org.bukkit.entity.Player;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.Plugin;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Objects;
public class BukkitSetupUtils extends SetupUtils {
@Override public void updateGenerators() {
if (!SetupUtils.generators.isEmpty()) {
return;
}
String testWorld = "CheckingPlotSquaredGenerator";
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
try {
if (plugin.isEnabled()) {
ChunkGenerator generator = plugin.getDefaultWorldGenerator(testWorld, "");
if (generator != null) {
PlotSquared.get().removePlotAreas(testWorld);
String name = plugin.getDescription().getName();
GeneratorWrapper<?> wrapped;
if (generator instanceof GeneratorWrapper<?>) {
wrapped = (GeneratorWrapper<?>) generator;
} else {
wrapped = new BukkitPlotGenerator(testWorld, generator);
}
SetupUtils.generators.put(name, wrapped);
}
}
} catch (Throwable e) { // Recover from third party generator error
e.printStackTrace();
}
}
}
@Override public void unload(String worldName, boolean save) {
World world = Bukkit.getWorld(worldName);
if (world == null) {
return;
}
World dw = Bukkit.getWorlds().get(0);
for (Player player : world.getPlayers()) {
player.teleport(dw.getSpawnLocation());
}
if (save) {
for (Chunk chunk : world.getLoadedChunks()) {
chunk.unload(true, false);
}
} else {
for (Chunk chunk : world.getLoadedChunks()) {
chunk.unload(false, false);
}
}
Bukkit.unloadWorld(world, false);
}
@Override public String setupWorld(SetupObject object) {
SetupUtils.manager.updateGenerators();
ConfigurationNode[] steps = object.step == null ? new ConfigurationNode[0] : object.step;
String world = object.world;
int type = object.type;
String worldPath = "worlds." + object.world;
switch (type) {
case 2: {
if (object.id != null) {
if (!PlotSquared.get().worlds.contains(worldPath)) {
PlotSquared.get().worlds.createSection(worldPath);
}
ConfigurationSection worldSection =
PlotSquared.get().worlds.getConfigurationSection(worldPath);
String areaName = object.id + "-" + object.min + "-" + object.max;
String areaPath = "areas." + areaName;
if (!worldSection.contains(areaPath)) {
worldSection.createSection(areaPath);
}
ConfigurationSection areaSection =
worldSection.getConfigurationSection(areaPath);
HashMap<String, Object> options = new HashMap<>();
for (ConfigurationNode step : steps) {
options.put(step.getConstant(), step.getValue());
}
options.put("generator.type", object.type);
options.put("generator.terrain", object.terrain);
options.put("generator.plugin", object.plotManager);
if (object.setupGenerator != null && !object.setupGenerator
.equals(object.plotManager)) {
options.put("generator.init", object.setupGenerator);
}
for (Entry<String, Object> entry : options.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (worldSection.contains(key)) {
Object current = worldSection.get(key);
if (!Objects.equals(value, current)) {
areaSection.set(key, value);
}
} else {
worldSection.set(key, value);
}
}
}
GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);
if (gen != null && gen.isFull()) {
object.setupGenerator = null;
}
break;
}
case 1: {
if (!PlotSquared.get().worlds.contains(worldPath)) {
PlotSquared.get().worlds.createSection(worldPath);
}
ConfigurationSection worldSection =
PlotSquared.get().worlds.getConfigurationSection(worldPath);
for (ConfigurationNode step : steps) {
worldSection.set(step.getConstant(), step.getValue());
}
PlotSquared.get().worlds.set("worlds." + world + ".generator.type", object.type);
PlotSquared.get().worlds
.set("worlds." + world + ".generator.terrain", object.terrain);
PlotSquared.get().worlds
.set("worlds." + world + ".generator.plugin", object.plotManager);
if (object.setupGenerator != null && !object.setupGenerator
.equals(object.plotManager)) {
PlotSquared.get().worlds
.set("worlds." + world + ".generator.init", object.setupGenerator);
}
GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);
if (gen != null && gen.isFull()) {
object.setupGenerator = null;
}
break;
}
case 0: {
if (steps.length != 0) {
if (!PlotSquared.get().worlds.contains(worldPath)) {
PlotSquared.get().worlds.createSection(worldPath);
}
ConfigurationSection worldSection =
PlotSquared.get().worlds.getConfigurationSection(worldPath);
for (ConfigurationNode step : steps) {
worldSection.set(step.getConstant(), step.getValue());
}
}
break;
}
}
try {
PlotSquared.get().worlds.save(PlotSquared.get().worldsFile);
} catch (IOException e) {
e.printStackTrace();
}
if (object.setupGenerator != null) {
if (Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null && Bukkit
.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
"mv create " + world + " normal -g " + object.setupGenerator);
setGenerator(world, object.setupGenerator);
if (Bukkit.getWorld(world) != null) {
return world;
}
}
if (Bukkit.getPluginManager().getPlugin("MultiWorld") != null && Bukkit
.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
"mw create " + world + " plugin:" + object.setupGenerator);
setGenerator(world, object.setupGenerator);
if (Bukkit.getWorld(world) != null) {
return world;
}
}
WorldCreator wc = new WorldCreator(object.world);
wc.generator(object.setupGenerator);
wc.environment(Environment.NORMAL);
wc.type(WorldType.FLAT);
Bukkit.createWorld(wc);
setGenerator(world, object.setupGenerator);
} else {
if (Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null && Bukkit
.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
"mv create " + world + " normal");
if (Bukkit.getWorld(world) != null) {
return world;
}
}
if (Bukkit.getPluginManager().getPlugin("MultiWorld") != null && Bukkit
.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
Bukkit.getServer()
.dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world);
if (Bukkit.getWorld(world) != null) {
return world;
}
}
World bw =
Bukkit.createWorld(new WorldCreator(object.world).environment(Environment.NORMAL));
}
return object.world;
}
public void setGenerator(String world, String generator) {
if (Bukkit.getWorlds().isEmpty() || !Bukkit.getWorlds().get(0).getName().equals(world)) {
return;
}
File file = new File("bukkit.yml").getAbsoluteFile();
YamlConfiguration yml = YamlConfiguration.loadConfiguration(file);
yml.set("worlds." + world + ".generator", generator);
try {
yml.save(file);
} catch (IOException e) {
e.printStackTrace();
}
}
@Override public String getGenerator(PlotArea plotArea) {
if (SetupUtils.generators.isEmpty()) {
updateGenerators();
}
World world = Bukkit.getWorld(plotArea.worldname);
if (world == null) {
return null;
}
ChunkGenerator generator = world.getGenerator();
if (!(generator instanceof BukkitPlotGenerator)) {
return null;
}
for (Entry<String, GeneratorWrapper<?>> entry : SetupUtils.generators.entrySet()) {
GeneratorWrapper<?> current = entry.getValue();
if (current.equals(generator)) {
return entry.getKey();
}
}
return null;
}
}

View File

@ -1,50 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.bukkit.BukkitMain;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import org.bukkit.Bukkit;
public class BukkitTaskManager extends TaskManager {
private final BukkitMain bukkitMain;
public BukkitTaskManager(BukkitMain bukkitMain) {
this.bukkitMain = bukkitMain;
}
@Override public int taskRepeat(Runnable runnable, int interval) {
return this.bukkitMain.getServer().getScheduler()
.scheduleSyncRepeatingTask(this.bukkitMain, runnable, interval, interval);
}
@SuppressWarnings("deprecation") @Override
public int taskRepeatAsync(Runnable runnable, int interval) {
return this.bukkitMain.getServer().getScheduler()
.scheduleAsyncRepeatingTask(this.bukkitMain, runnable, interval, interval);
}
@Override public void taskAsync(Runnable runnable) {
this.bukkitMain.getServer().getScheduler().runTaskAsynchronously(this.bukkitMain, runnable)
.getTaskId();
}
@Override public void task(Runnable runnable) {
this.bukkitMain.getServer().getScheduler().runTask(this.bukkitMain, runnable).getTaskId();
}
@Override public void taskLater(Runnable runnable, int delay) {
this.bukkitMain.getServer().getScheduler().runTaskLater(this.bukkitMain, runnable, delay)
.getTaskId();
}
@Override public void taskLaterAsync(Runnable runnable, int delay) {
this.bukkitMain.getServer().getScheduler()
.runTaskLaterAsynchronously(this.bukkitMain, runnable, delay);
}
@Override public void cancelTask(int task) {
if (task != -1) {
Bukkit.getScheduler().cancelTask(task);
}
}
}

View File

@ -1,469 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.C;
import com.github.intellectualsites.plotsquared.plot.object.*;
import com.github.intellectualsites.plotsquared.plot.object.schematic.PlotItem;
import com.github.intellectualsites.plotsquared.plot.util.*;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import lombok.NonNull;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.block.*;
import org.bukkit.block.data.type.WallSign;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import javax.annotation.Nullable;
import java.util.*;
@SuppressWarnings({"unused", "WeakerAccess"}) public class BukkitUtil extends WorldUtil {
private static String lastString = null;
private static World lastWorld = null;
private static Player lastPlayer = null;
private static PlotPlayer lastPlotPlayer = null;
public static void removePlayer(String player) {
lastPlayer = null;
lastPlotPlayer = null;
}
public static PlotPlayer getPlayer(@NonNull final OfflinePlayer op) {
if (op.isOnline()) {
return getPlayer(op.getPlayer());
}
final Player player = OfflinePlayerUtil.loadPlayer(op);
player.loadData();
return new BukkitPlayer(player, true);
}
/**
* Get a plot based on the location.
*
* @param location the location to check
* @return plot if found, otherwise it creates a temporary plot
* @see Plot
*/
public static Plot getPlot(org.bukkit.Location location) {
if (location == null) {
return null;
}
return getLocation(location).getPlot();
}
/**
* Get a plot based on the player location.
*
* @param player the player to check
* @return plot if found, otherwise it creates a temporary plot
* @see #getPlot(org.bukkit.Location)
* @see Plot
*/
public static Plot getPlot(Player player) {
return getPlot(player.getLocation());
}
/**
* Get home location.
*
* @param plot Plot that you want to get the location for
* @return plot bottom location
* @see Plot
*/
public static org.bukkit.Location getHomeLocation(Plot plot) {
return BukkitUtil.getLocation(plot.getHome());
}
/**
* Get the PlotPlayer for an offline player.
*
* <p>Note that this will work if the player is offline, however not all
* functionality will work.
*
* @param player the player to wrap
* @return a {@code PlotPlayer}
* @see PlotPlayer#wrap(Object)
*/
public static PlotPlayer wrapPlayer(OfflinePlayer player) {
return PlotPlayer.wrap(player);
}
/**
* Gets the PlotPlayer for a player. The PlotPlayer is usually cached and
* will provide useful functions relating to players.
*
* @param player the player to wrap
* @return a {@code PlotPlayer}
* @see PlotPlayer#wrap(Object)
*/
public static PlotPlayer wrapPlayer(Player player) {
return PlotPlayer.wrap(player);
}
/**
* Gets the number of plots, which the player is able to build in.
*
* @param player player, for whom we're getting the plots
* @return the number of allowed plots
*/
public static int getAllowedPlots(Player player) {
PlotPlayer plotPlayer = PlotPlayer.wrap(player);
return plotPlayer.getAllowedPlots();
}
/**
* Check whether or not a player is in a plot.
*
* @param player who we're checking for
* @return true if the player is in a plot, false if not-
*/
public static boolean isInPlot(Player player) {
return getPlot(player) != null;
}
/**
* Gets a collection containing the players plots.
*
* @param world Specify the world we want to select the plots from
* @param player Player, for whom we're getting the plots
* @return a set containing the players plots
* @see Plot
*/
public static Set<Plot> getPlayerPlots(String world, Player player) {
if (world == null) {
return new HashSet<>();
}
return PlotPlayer.wrap(player).getPlots(world);
}
/**
* Send a message to a player. The message supports color codes.
*
* @param player the recipient of the message
* @param string the message
* @see MainUtil#sendMessage(PlotPlayer, String)
*/
public static void sendMessage(Player player, String string) {
MainUtil.sendMessage(BukkitUtil.getPlayer(player), string);
}
/**
* Gets the player plot count.
*
* @param world Specify the world we want to select the plots from
* @param player Player, for whom we're getting the plot count
* @return the number of plots the player has
*/
public static int getPlayerPlotCount(String world, Player player) {
if (world == null) {
return 0;
}
return BukkitUtil.getPlayer(player).getPlotCount(world);
}
/**
* Send a message to a player.
*
* @param player the recipient of the message
* @param caption the message
* @see MainUtil#sendMessage(PlotPlayer, C, String...)
*/
public static void sendMessage(Player player, C caption) {
MainUtil.sendMessage(BukkitUtil.getPlayer(player), caption);
}
public static PlotPlayer getPlayer(@NonNull final Player player) {
if (player == lastPlayer) {
return lastPlotPlayer;
}
final String name = player.getName();
final PlotPlayer plotPlayer = UUIDHandler.getPlayer(name);
if (plotPlayer != null) {
return plotPlayer;
}
lastPlotPlayer = new BukkitPlayer(player);
UUIDHandler.getPlayers().put(name, lastPlotPlayer);
lastPlayer = player;
return lastPlotPlayer;
}
public static Location getLocation(@NonNull final org.bukkit.Location location) {
return new Location(location.getWorld().getName(), MathMan.roundInt(location.getX()),
MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()));
}
public static org.bukkit.Location getLocation(@NonNull final Location location) {
return new org.bukkit.Location(getWorld(location.getWorld()), location.getX(),
location.getY(), location.getZ());
}
public static World getWorld(@NonNull final String string) {
return Bukkit.getWorld(string);
}
public static String getWorld(@NonNull final Entity entity) {
return entity.getWorld().getName();
}
public static List<Entity> getEntities(@NonNull final String worldName) {
World world = getWorld(worldName);
return world != null ? world.getEntities() : new ArrayList<Entity>();
}
public static Location getLocation(@NonNull final Entity entity) {
final org.bukkit.Location location = entity.getLocation();
String world = location.getWorld().getName();
return new Location(world, location.getBlockX(), location.getBlockY(),
location.getBlockZ());
}
public static Location getLocationFull(@NonNull final Entity entity) {
final org.bukkit.Location location = entity.getLocation();
return new Location(location.getWorld().getName(), MathMan.roundInt(location.getX()),
MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()), location.getYaw(),
location.getPitch());
}
public static BukkitLegacyMappings getBukkitLegacyMappings() {
return (BukkitLegacyMappings) PlotSquared.imp().getLegacyMappings();
}
public static Material getMaterial(@NonNull final PlotBlock plotBlock) {
if (plotBlock instanceof StringPlotBlock) {
return Material
.getMaterial(((StringPlotBlock) plotBlock).getItemId().toUpperCase(Locale.ENGLISH));
} else {
final LegacyPlotBlock legacyPlotBlock = (LegacyPlotBlock) plotBlock;
return getBukkitLegacyMappings()
.fromLegacyToString(legacyPlotBlock.getId(), legacyPlotBlock.getData())
.to(Material.class);
}
}
@Override public boolean isBlockSame(PlotBlock block1, PlotBlock block2) {
if (block1.equals(block2)) {
return true;
}
Material mat1 = getMaterial(block1), mat2 = getMaterial(block2);
return mat1 == mat2;
}
@Override public boolean isWorld(@NonNull final String worldName) {
return getWorld(worldName) != null;
}
@Override public String getBiome(String world, int x, int z) {
return getWorld(world).getBiome(x, z).name();
}
@Override @SuppressWarnings("deprecation")
public void setSign(@NonNull final String worldName, final int x, final int y, final int z,
@NonNull final String[] lines) {
final World world = getWorld(worldName);
final Block block = world.getBlockAt(x, y, z);
// block.setType(Material.AIR);
final Material type = block.getType();
if (type != Material.SIGN && type != Material.WALL_SIGN) {
BlockFace facing = BlockFace.EAST;
if (world.getBlockAt(x, y, z + 1).getType().isSolid())
facing = BlockFace.NORTH;
else if (world.getBlockAt(x + 1, y, z).getType().isSolid())
facing = BlockFace.WEST;
else if (world.getBlockAt(x, y, z - 1).getType().isSolid())
facing = BlockFace.SOUTH;
block.setType(Material.WALL_SIGN, false);
final WallSign sign = (WallSign) block.getBlockData();
sign.setFacing(facing);
block.setBlockData(sign, false);
}
final BlockState blockstate = block.getState();
if (blockstate instanceof Sign) {
final Sign sign = (Sign) blockstate;
for (int i = 0; i < lines.length; i++) {
sign.setLine(i, lines[i]);
}
sign.update(true);
}
}
@Override @Nullable public String[] getSign(@NonNull final Location location) {
Block block = getWorld(location.getWorld())
.getBlockAt(location.getX(), location.getY(), location.getZ());
if (block != null) {
if (block.getState() instanceof Sign) {
Sign sign = (Sign) block.getState();
return sign.getLines();
}
}
return null;
}
@Override public Location getSpawn(@NonNull final PlotPlayer player) {
return getLocation(((BukkitPlayer) player).player.getBedSpawnLocation());
}
@Override public Location getSpawn(@NonNull final String world) {
final org.bukkit.Location temp = getWorld(world).getSpawnLocation();
return new Location(world, temp.getBlockX(), temp.getBlockY(), temp.getBlockZ(),
temp.getYaw(), temp.getPitch());
}
@Override public void setSpawn(@NonNull final Location location) {
final World world = getWorld(location.getWorld());
if (world != null) {
world.setSpawnLocation(location.getX(), location.getY(), location.getZ());
}
}
@Override public void saveWorld(@NonNull final String worldName) {
final World world = getWorld(worldName);
if (world != null) {
world.save();
}
}
@Override public int getHighestBlock(@NonNull final String world, final int x, final int z) {
final World bukkitWorld = getWorld(world);
// Skip top and bottom block
int air = 1;
for (int y = bukkitWorld.getMaxHeight() - 1; y >= 0; y--) {
Block block = bukkitWorld.getBlockAt(x, y, z);
if (block != null) {
Material type = block.getType();
if (type.isSolid()) {
if (air > 1)
return y;
air = 0;
} else {
switch (type) {
case WATER:
case LAVA:
return y;
}
air++;
}
}
}
return bukkitWorld.getMaxHeight() - 1;
}
@Override public int getBiomeFromString(@NonNull final String biomeString) {
try {
final Biome biome = Biome.valueOf(biomeString.toUpperCase());
return Arrays.asList(Biome.values()).indexOf(biome);
} catch (IllegalArgumentException ignored) {
return -1;
}
}
@Override public String[] getBiomeList() {
final Biome[] biomes = Biome.values();
final String[] list = new String[biomes.length];
for (int i = 0; i < biomes.length; i++) {
list[i] = biomes[i].name();
}
return list;
}
@Override
public boolean addItems(@NonNull final String worldName, @NonNull final PlotItem items) {
final World world = getWorld(worldName);
final Block block = world.getBlockAt(items.x, items.y, items.z);
if (block == null) {
return false;
}
final BlockState state = block.getState();
if (state instanceof InventoryHolder) {
InventoryHolder holder = (InventoryHolder) state;
Inventory inv = holder.getInventory();
for (int i = 0; i < items.types.length; i++) {
// ItemStack item = new ItemStack(LegacyMappings.fromLegacyId(items.id[i]).getMaterial(), items.amount[i], items.data[i]);
ItemStack item = new ItemStack(items.types[i].to(Material.class), items.amount[i]);
inv.addItem(item);
}
state.update(true);
return true;
}
return false;
}
@Override public boolean isBlockSolid(@NonNull final PlotBlock block) {
try {
Material material = getMaterial(block);
if (material.isLegacy()) {
material = getBukkitLegacyMappings().fromLegacyToString(material.name())
.to(Material.class);
}
if (material.isBlock() && material.isSolid() && !material.hasGravity()) {
String name = material.name().toLowerCase(Locale.ENGLISH);
if (material.isOccluding() || name.contains("stairs") || name.contains("slab")
|| name.contains("wool")) {
switch (material) {
case NOTE_BLOCK:
case SPAWNER:
return false;
default:
return true;
}
}
}
return false;
} catch (Exception ignored) {
return false;
}
}
@Override public String getClosestMatchingName(@NonNull final PlotBlock block) {
try {
return getMaterial(block).name();
} catch (Exception ignored) {
return null;
}
}
@Override @Nullable
public StringComparison<PlotBlock>.ComparisonResult getClosestBlock(String name) {
final PlotBlock plotBlock = BukkitUtil.getBukkitLegacyMappings().fromAny(name);
if (plotBlock != null) {
return new StringComparison<PlotBlock>().new ComparisonResult(1, plotBlock);
}
return BukkitUtil.getBukkitLegacyMappings().getClosestsMatch(name);
}
@Override
public void setBiomes(@NonNull final String worldName, @NonNull final RegionWrapper region,
@NonNull final String biomeString) {
final World world = getWorld(worldName);
final Biome biome = Biome.valueOf(biomeString.toUpperCase());
for (int x = region.minX; x <= region.maxX; x++) {
for (int z = region.minZ; z <= region.maxZ; z++) {
world.setBiome(x, z, biome);
}
}
}
public com.sk89q.worldedit.world.World getWeWorld(String world) {
return new BukkitWorld(Bukkit.getWorld(world));
}
@Override public PlotBlock getBlock(@NonNull final Location location) {
final World world = getWorld(location.getWorld());
final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ());
if (block == null) {
return StringPlotBlock.EVERYTHING;
}
return PlotBlock.get(block.getType().name());
}
@Override public String getMainWorld() {
return Bukkit.getWorlds().get(0).getName();
}
}

View File

@ -1,7 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.util;
public class BukkitVersion {
public static int[] v1_13_2 = {1, 13, 2};
public static int[] v1_13_1 = {1, 13, 1};
public static int[] v1_13_0 = {1, 13, 0};
}

View File

@ -1,89 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.util;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.UUID;
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.*;
public class OfflinePlayerUtil {
public static Player loadPlayer(String name) {
return loadPlayer(Bukkit.getOfflinePlayer(name));
}
public static Player loadPlayer(UUID id) {
return loadPlayer(Bukkit.getOfflinePlayer(id));
}
public static Player loadPlayer(OfflinePlayer player) {
if (player == null) {
return null;
}
if (player instanceof Player) {
return (Player) player;
}
return loadPlayer(player.getUniqueId(), player.getName());
}
private static Player loadPlayer(UUID id, String name) {
Object server = getMinecraftServer();
Object interactManager = newPlayerInteractManager();
Object worldServer = getWorldServer();
Object profile = newGameProfile(id, name);
Class<?> entityPlayerClass = getNmsClass("EntityPlayer");
Constructor entityPlayerConstructor =
makeConstructor(entityPlayerClass, getNmsClass("MinecraftServer"),
getNmsClass("WorldServer"), getUtilClass("com.mojang.authlib.GameProfile"),
getNmsClass("PlayerInteractManager"));
Object entityPlayer =
callConstructor(entityPlayerConstructor, server, worldServer, profile, interactManager);
return (Player) getBukkitEntity(entityPlayer);
}
private static Object newGameProfile(UUID id, String name) {
Class<?> gameProfileClass = getUtilClass("com.mojang.authlib.GameProfile");
if (gameProfileClass == null) { //Before uuids
return name;
}
Constructor gameProfileConstructor =
makeConstructor(gameProfileClass, UUID.class, String.class);
if (gameProfileConstructor == null) { //Version has string constructor
gameProfileConstructor = makeConstructor(gameProfileClass, String.class, String.class);
return callConstructor(gameProfileConstructor, id.toString(), name);
} else { //Version has uuid constructor
return callConstructor(gameProfileConstructor, id, name);
}
}
private static Object newPlayerInteractManager() {
Object worldServer = getWorldServer();
Class<?> playerInteractClass = getNmsClass("PlayerInteractManager");
Class<?> worldClass = getNmsClass("World");
Constructor c = makeConstructor(playerInteractClass, worldClass);
return callConstructor(c, worldServer);
}
private static Object getWorldServer() {
Object server = getMinecraftServer();
Class<?> minecraftServerClass = getNmsClass("MinecraftServer");
Method getWorldServer = makeMethod(minecraftServerClass, "getWorldServer", int.class);
return callMethod(getWorldServer, server, 0);
}
//NMS Utils
private static Object getMinecraftServer() {
return callMethod(makeMethod(getCbClass("CraftServer"), "getServer"), Bukkit.getServer());
}
private static Entity getBukkitEntity(Object o) {
Method getBukkitEntity = makeMethod(o.getClass(), "getBukkitEntity");
return callMethod(getBukkitEntity, o);
}
}

View File

@ -1,150 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.ChunkLoc;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.RefClass;
import com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.RefConstructor;
import com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.RefField;
import com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.RefMethod;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map.Entry;
import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils.getRefClass;
/**
* An utility that can be used to send chunks, rather than using bukkit code
* to do so (uses heavy NMS).
*/
public class SendChunk {
private final RefMethod methodGetHandlePlayer;
private final RefMethod methodGetHandleChunk;
private final RefConstructor mapChunk;
private final RefField connection;
private final RefMethod send;
private final RefMethod methodInitLighting;
/**
* Constructor.
*/
public SendChunk() throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException {
RefConstructor tempMapChunk;
RefClass classCraftPlayer = getRefClass("{cb}.entity.CraftPlayer");
this.methodGetHandlePlayer = classCraftPlayer.getMethod("getHandle");
RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
RefClass classChunk = getRefClass("{nms}.Chunk");
this.methodInitLighting = classChunk.getMethod("initLighting");
RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
tempMapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), int.class);
this.mapChunk = tempMapChunk;
RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer");
this.connection = classEntityPlayer.getField("playerConnection");
RefClass classPacket = getRefClass("{nms}.Packet");
RefClass classConnection = getRefClass("{nms}.PlayerConnection");
this.send = classConnection.getMethod("sendPacket", classPacket.getRealClass());
}
public void sendChunk(Collection<Chunk> input) {
HashSet<Chunk> chunks = new HashSet<>(input);
HashMap<String, ArrayList<Chunk>> map = new HashMap<>();
int view = Bukkit.getServer().getViewDistance();
for (Chunk chunk : chunks) {
String world = chunk.getWorld().getName();
ArrayList<Chunk> list = map.get(world);
if (list == null) {
list = new ArrayList<>();
map.put(world, list);
}
list.add(chunk);
Object c = this.methodGetHandleChunk.of(chunk).call();
this.methodInitLighting.of(c).call();
}
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
PlotPlayer pp = entry.getValue();
Plot plot = pp.getCurrentPlot();
Location location = null;
String world;
if (plot != null) {
world = plot.getWorldName();
} else {
location = pp.getLocation();
world = location.getWorld();
}
ArrayList<Chunk> list = map.get(world);
if (list == null) {
continue;
}
if (location == null) {
location = pp.getLocation();
}
int cx = location.getX() >> 4;
int cz = location.getZ() >> 4;
Player player = ((BukkitPlayer) pp).player;
Object entity = this.methodGetHandlePlayer.of(player).call();
for (Chunk chunk : list) {
int dx = Math.abs(cx - chunk.getX());
int dz = Math.abs(cz - chunk.getZ());
if ((dx > view) || (dz > view)) {
continue;
}
Object c = this.methodGetHandleChunk.of(chunk).call();
chunks.remove(chunk);
Object con = this.connection.of(entity).get();
Object packet = null;
try {
packet = this.mapChunk.create(c, 65535);
} catch (Exception ignored) {
}
if (packet == null) {
PlotSquared.debug("Error with PacketPlayOutMapChunk reflection.");
}
this.send.of(con).call(packet);
}
}
for (final Chunk chunk : chunks) {
TaskManager.runTask(new Runnable() {
@Override public void run() {
try {
chunk.unload(true, false);
} catch (Throwable ignored) {
String worldName = chunk.getWorld().getName();
PlotSquared.debug(
"$4Could not save chunk: " + worldName + ';' + chunk.getX() + ";"
+ chunk.getZ());
PlotSquared
.debug("$3 - $4File may be open in another process (e.g. MCEdit)");
PlotSquared.debug("$3 - $4" + worldName + "/level.dat or " + worldName
+ "/level_old.dat may be corrupt (try repairing or removing these)");
}
}
});
}
}
public void sendChunk(String worldName, Collection<ChunkLoc> chunkLocations) {
World myWorld = Bukkit.getWorld(worldName);
ArrayList<Chunk> chunks = new ArrayList<>();
for (ChunkLoc loc : chunkLocations) {
if (myWorld.isChunkLoaded(loc.x, loc.z)) {
chunks.add(myWorld.getChunkAt(loc.x, loc.z));
}
}
sendChunk(chunks);
}
}

View File

@ -1,58 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.bukkit.generator.BukkitAugmentedGenerator;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper;
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Iterator;
public class SetGenCB {
public static void setGenerator(World world) throws Exception {
SetupUtils.manager.updateGenerators();
PlotSquared.get().removePlotAreas(world.getName());
ChunkGenerator gen = world.getGenerator();
if (gen == null) {
return;
}
String name = gen.getClass().getCanonicalName();
boolean set = false;
for (GeneratorWrapper<?> wrapper : SetupUtils.generators.values()) {
ChunkGenerator newGen = (ChunkGenerator) wrapper.getPlatformGenerator();
if (newGen == null) {
newGen = (ChunkGenerator) wrapper;
}
if (newGen.getClass().getCanonicalName().equals(name)) {
// set generator
Field generator = world.getClass().getDeclaredField("generator");
Field populators = world.getClass().getDeclaredField("populators");
generator.setAccessible(true);
populators.setAccessible(true);
// Set populators (just in case)
populators.set(world, new ArrayList<>());
// Set generator
generator.set(world, newGen);
populators.set(world, newGen.getDefaultPopulators(world));
// end
set = true;
break;
}
}
if (!set) {
Iterator<BlockPopulator> iterator = world.getPopulators().iterator();
while (iterator.hasNext()) {
if (iterator.next() instanceof BukkitAugmentedGenerator) {
iterator.remove();
}
}
}
PlotSquared.get()
.loadWorld(world.getName(), PlotSquared.get().IMP.getGenerator(world.getName(), null));
}
}

View File

@ -1,261 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.util.block;
import com.github.intellectualsites.plotsquared.bukkit.object.schematic.StateWrapper;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.LegacyPlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.StringPlotBlock;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.block.BasicLocalBlockQueue;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BaseBlock;
import lombok.NonNull;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Locale;
public class BukkitLocalQueue<T> extends BasicLocalBlockQueue<T> {
private Field fieldNeighbors;
private Method chunkGetHandle;
public BukkitLocalQueue(String world) {
super(world);
}
@Override public LocalChunk<T> getLocalChunk(int x, int z) {
return (LocalChunk<T>) new BasicLocalChunk(this, x, z) {
// Custom stuff?
};
}
@Override public void optimize() {
}
@Override public PlotBlock getBlock(int x, int y, int z) {
World worldObj = Bukkit.getWorld(getWorld());
Block block = worldObj.getBlockAt(x, y, z);
if (block == null) {
return PlotBlock.get(0, 0);
}
// int id = block.getTypeId();
// if (id == 0) {
// return PlotBlock.get(0, 0);
// }
// return PlotBlock.get(id, block.getData());
return PlotBlock.get(block.getType().toString());
}
@Override public void refreshChunk(int x, int z) {
World worldObj = Bukkit.getWorld(getWorld());
worldObj.refreshChunk(x, z);
}
@Override public void fixChunkLighting(int x, int z) {
// Do nothing
}
@Override public final void regenChunk(int x, int z) {
World worldObj = Bukkit.getWorld(getWorld());
worldObj.regenerateChunk(x, z);
}
@Override public final void setComponents(LocalChunk<T> lc) {
if (isBaseBlocks()) {
setBaseBlocks(lc);
} else {
setBlocks(lc);
}
}
public World getBukkitWorld() {
return Bukkit.getWorld(getWorld());
}
public Chunk getChunk(int x, int z) {
return getBukkitWorld().getChunkAt(x, z);
}
public void setBlocks(LocalChunk<T> lc) {
World worldObj = Bukkit.getWorld(getWorld());
Chunk chunk = worldObj.getChunkAt(lc.getX(), lc.getZ());
chunk.load(true);
for (int layer = 0; layer < lc.blocks.length; layer++) {
PlotBlock[] blocksLayer = (PlotBlock[]) lc.blocks[layer];
if (blocksLayer != null) {
for (int j = 0; j < blocksLayer.length; j++) {
if (blocksLayer[j] != null) {
PlotBlock block = blocksLayer[j];
int x = MainUtil.x_loc[layer][j];
int y = MainUtil.y_loc[layer][j];
int z = MainUtil.z_loc[layer][j];
Block existing = chunk.getBlock(x, y, z);
if (equals(block, existing)) {
continue;
}
setMaterial(block, existing);
}
}
}
}
}
public void setBaseBlocks(LocalChunk<T> lc) {
World worldObj = Bukkit.getWorld(getWorld());
Chunk chunk = worldObj.getChunkAt(lc.getX(), lc.getZ());
chunk.load(true);
for (int layer = 0; layer < lc.baseblocks.length; layer++) {
BaseBlock[] blocksLayer = lc.baseblocks[layer];
if (blocksLayer != null) {
for (int j = 0; j < blocksLayer.length; j++) {
if (blocksLayer[j] != null) {
BaseBlock block = blocksLayer[j];
int x = MainUtil.x_loc[layer][j];
int y = MainUtil.y_loc[layer][j];
int z = MainUtil.z_loc[layer][j];
Block existing = chunk.getBlock(x, y, z);
if (equals(PlotBlock.get(block), existing) && existing.getBlockData()
.matches(BukkitAdapter.adapt(block))) {
continue;
}
existing.setType(BukkitAdapter.adapt(block.getBlockType()), false);
existing.setBlockData(BukkitAdapter.adapt(block), false);
if (block.hasNbtData()) {
CompoundTag tag = block.getNbtData();
StateWrapper sw = new StateWrapper(tag);
sw.restoreTag(worldObj.getName(), existing.getX(), existing.getY(),
existing.getZ());
}
}
}
}
}
}
private void setMaterial(@NonNull final PlotBlock plotBlock, @NonNull final Block block) {
final Material material;
if (plotBlock instanceof StringPlotBlock) {
material = Material
.getMaterial(((StringPlotBlock) plotBlock).getItemId().toUpperCase(Locale.ENGLISH));
if (material == null) {
throw new IllegalStateException(String
.format("Could not find material that matches %s",
((StringPlotBlock) plotBlock).getItemId()));
}
} else {
final LegacyPlotBlock legacyPlotBlock = (LegacyPlotBlock) plotBlock;
material = PlotSquared.get().IMP.getLegacyMappings()
.fromLegacyToString(legacyPlotBlock.getId(), legacyPlotBlock.getData())
.to(Material.class);
if (material == null) {
throw new IllegalStateException(String
.format("Could not find material that matches %s", legacyPlotBlock.toString()));
}
}
block.setType(material, false);
}
private boolean equals(@NonNull final PlotBlock plotBlock, @NonNull final Block block) {
if (plotBlock instanceof StringPlotBlock) {
return ((StringPlotBlock) plotBlock).idEquals(block.getType().name());
}
final LegacyPlotBlock legacyPlotBlock = (LegacyPlotBlock) plotBlock;
return Material.getMaterial(PlotSquared.get().IMP.getLegacyMappings()
.fromLegacyToString(((LegacyPlotBlock) plotBlock).id,
((LegacyPlotBlock) plotBlock).data).toString()) == block.getType() && (
legacyPlotBlock.id == 0 || legacyPlotBlock.data == block.getData());
}
public void setBiomes(LocalChunk<T> lc) {
if (lc.biomes != null) {
World worldObj = Bukkit.getWorld(getWorld());
int bx = lc.getX() << 4;
int bz = lc.getX() << 4;
String last = null;
Biome biome = null;
for (int x = 0; x < lc.biomes.length; x++) {
String[] biomes2 = lc.biomes[x];
if (biomes2 != null) {
for (int y = 0; y < biomes2.length; y++) {
String biomeStr = biomes2[y];
if (biomeStr != null) {
if (last == null || !StringMan.isEqual(last, biomeStr)) {
biome = Biome.valueOf(biomeStr.toUpperCase());
}
worldObj.setBiome(bx, bz, biome);
}
}
}
}
}
}
/**
* Exploiting a bug in the vanilla lighting algorithm for faster block placement
* - Could have been achieved without reflection by force unloading specific chunks
* - Much faster just setting the variable manually though
*
* @param chunk
* @return
*/
protected Object[] disableLighting(Chunk chunk) {
try {
if (chunkGetHandle == null) {
chunkGetHandle = chunk.getClass().getDeclaredMethod("getHandle");
chunkGetHandle.setAccessible(true);
}
Object nmsChunk = chunkGetHandle.invoke(chunk);
if (fieldNeighbors == null) {
fieldNeighbors = nmsChunk.getClass().getDeclaredField("neighbors");
fieldNeighbors.setAccessible(true);
}
Object value = fieldNeighbors.get(nmsChunk);
fieldNeighbors.set(nmsChunk, 0);
return new Object[] {nmsChunk, value};
} catch (Throwable ignore) {
}
return null;
}
protected void disableLighting(Object[] disableResult) {
if (disableResult != null) {
try {
fieldNeighbors.set(disableResult[0], 0);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
protected void resetLighting(Object[] disableResult) {
if (disableResult != null) {
try {
fieldNeighbors.set(disableResult[0], disableResult[1]);
} catch (Throwable ignore) {
ignore.printStackTrace();
}
}
}
protected void enableLighting(Object[] disableResult) {
if (disableResult != null) {
try {
fieldNeighbors.set(disableResult[0], 0x739C0);
} catch (Throwable ignore) {
}
}
}
}

View File

@ -1,184 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.util.block;
import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
import com.github.intellectualsites.plotsquared.plot.object.ChunkWrapper;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BaseBlock;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
import org.bukkit.generator.ChunkGenerator.ChunkData;
import java.util.Arrays;
public class GenChunk extends ScopedLocalBlockQueue {
public final Biome[] biomes;
public PlotBlock[][] result;
public BiomeGrid grid;
public Chunk chunk;
public String world;
public int cx;
public int cz;
@Getter @Setter private ChunkData cd = null;
public GenChunk(Chunk chunk, ChunkWrapper wrap) {
super(null, new Location(null, 0, 0, 0), new Location(null, 15, 255, 15));
this.biomes = Biome.values();
}
public void setChunk(Chunk chunk) {
this.chunk = chunk;
}
public Chunk getChunk() {
if (chunk == null) {
World worldObj = BukkitUtil.getWorld(world);
if (worldObj != null) {
this.chunk = worldObj.getChunkAt(cx, cz);
}
}
return chunk;
}
public void setChunk(ChunkWrapper wrap) {
chunk = null;
world = wrap.world;
cx = wrap.x;
cz = wrap.z;
}
@Override public void fillBiome(String biomeName) {
if (grid == null) {
return;
}
Biome biome = Biome.valueOf(biomeName.toUpperCase());
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
this.grid.setBiome(x, z, biome);
}
}
}
@Override public void setCuboid(Location pos1, Location pos2, PlotBlock block) {
if (result != null && pos1.getX() == 0 && pos1.getZ() == 0 && pos2.getX() == 15
&& pos2.getZ() == 15) {
for (int y = pos1.getY(); y <= pos2.getY(); y++) {
int layer = y >> 4;
PlotBlock[] data = result[layer];
if (data == null) {
result[layer] = data = new PlotBlock[4096];
}
int start = y << 8;
int end = start + 256;
Arrays.fill(data, start, end, block);
}
}
int minx = Math.min(pos1.getX(), pos2.getX());
int miny = Math.min(pos1.getY(), pos2.getY());
int minz = Math.min(pos1.getZ(), pos2.getZ());
int maxx = Math.max(pos1.getX(), pos2.getX());
int maxy = Math.max(pos1.getY(), pos2.getY());
int maxz = Math.max(pos1.getZ(), pos2.getZ());
cd.setRegion(minx, miny, minz, maxx, maxy, maxz, block.to(Material.class));
}
@Override public boolean setBiome(int x, int z, String biome) {
return setBiome(x, z, Biome.valueOf(biome.toUpperCase()));
}
public boolean setBiome(int x, int z, Biome biome) {
if (this.grid != null) {
this.grid.setBiome(x, z, biome);
return true;
}
return false;
}
@Override public boolean setBlock(int x, int y, int z, PlotBlock id) {
if (this.result == null) {
this.cd.setBlock(x, y, z, id.to(Material.class));
return true;
}
this.cd.setBlock(x, y, z, id.to(Material.class));
this.storeCache(x, y, z, id);
return true;
}
private void storeCache(final int x, final int y, final int z, final PlotBlock id) {
int i = MainUtil.CACHE_I[y][x][z];
PlotBlock[] v = this.result[i];
if (v == null) {
this.result[i] = v = new PlotBlock[4096];
}
int j = MainUtil.CACHE_J[y][x][z];
v[j] = id;
}
@Override public boolean setBlock(int x, int y, int z, BaseBlock id) {
if (this.result == null) {
this.cd.setBlock(x, y, z, BukkitAdapter.adapt(id));
return true;
}
this.cd.setBlock(x, y, z, BukkitAdapter.adapt(id));
this.storeCache(x, y, z, PlotBlock.get(id.getBlockType().getId()));
return true;
}
@Override public PlotBlock getBlock(int x, int y, int z) {
int i = MainUtil.CACHE_I[y][x][z];
if (result == null) {
return PlotBlock.get(cd.getType(x, y, z));
}
PlotBlock[] array = result[i];
if (array == null) {
return PlotBlock.get("");
}
int j = MainUtil.CACHE_J[y][x][z];
return array[j];
}
public int getX() {
return chunk == null ? cx : chunk.getX();
}
public int getZ() {
return chunk == null ? cz : chunk.getZ();
}
@Override public String getWorld() {
return chunk == null ? world : chunk.getWorld().getName();
}
@Override public Location getMax() {
return new Location(getWorld(), 15 + (getX() << 4), 255, 15 + (getZ() << 4));
}
@Override public Location getMin() {
return new Location(getWorld(), getX() << 4, 0, getZ() << 4);
}
public GenChunk clone() {
GenChunk toReturn =
new GenChunk(chunk, new ChunkWrapper(getWorld(), chunk.getX(), chunk.getZ()));
if (this.result != null) {
for (int i = 0; i < this.result.length; i++) {
PlotBlock[] matrix = this.result[i];
if (matrix != null) {
toReturn.result[i] = new PlotBlock[matrix.length];
System.arraycopy(matrix, 0, toReturn.result[i], 0, matrix.length);
}
}
}
toReturn.cd = this.cd;
return toReturn;
}
}

View File

@ -1,11 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.uuid;
import java.io.File;
import java.io.FilenameFilter;
public class DatFileFilter implements FilenameFilter {
@Override public boolean accept(File dir, String name) {
return name.endsWith(".dat");
}
}

View File

@ -1,43 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.uuid;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitOfflinePlayer;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
import com.github.intellectualsites.plotsquared.plot.object.OfflinePlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import java.util.UUID;
public class DefaultUUIDWrapper extends UUIDWrapper {
@Override public UUID getUUID(PlotPlayer player) {
return ((BukkitPlayer) player).player.getUniqueId();
}
@Override public UUID getUUID(OfflinePlotPlayer player) {
return player.getUUID();
}
@Override public OfflinePlotPlayer getOfflinePlayer(UUID uuid) {
return new BukkitOfflinePlayer(Bukkit.getOfflinePlayer(uuid));
}
@Override public UUID getUUID(String name) {
return Bukkit.getOfflinePlayer(name).getUniqueId();
}
@Override public OfflinePlotPlayer[] getOfflinePlayers() {
OfflinePlayer[] ops = Bukkit.getOfflinePlayers();
BukkitOfflinePlayer[] toReturn = new BukkitOfflinePlayer[ops.length];
for (int i = 0; i < ops.length; i++) {
toReturn[i] = new BukkitOfflinePlayer(ops[i]);
}
return toReturn;
}
@Override public OfflinePlotPlayer getOfflinePlayer(String name) {
return new BukkitOfflinePlayer(Bukkit.getOfflinePlayer(name));
}
}

View File

@ -1,250 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.uuid;
import com.github.intellectualsites.plotsquared.bukkit.util.NbtFactory;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.C;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.object.OfflinePlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.object.StringWrapper;
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandlerImplementation;
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.Sets;
import org.bukkit.Bukkit;
import org.bukkit.World;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.UUID;
public class FileUUIDHandler extends UUIDHandlerImplementation {
public FileUUIDHandler(UUIDWrapper wrapper) {
super(wrapper);
}
@Override public boolean startCaching(Runnable whenDone) {
return super.startCaching(whenDone) && cache(whenDone);
}
public boolean cache(final Runnable whenDone) {
final File container = Bukkit.getWorldContainer();
List<World> worlds = Bukkit.getWorlds();
final String world;
if (worlds.isEmpty()) {
world = "world";
} else {
world = worlds.get(0).getName();
}
TaskManager.runTaskAsync(new Runnable() {
@Override public void run() {
PlotSquared.debug(C.PREFIX + "&6Starting player data caching for: " + world);
File uuidFile = new File(PlotSquared.get().IMP.getDirectory(), "uuids.txt");
if (uuidFile.exists()) {
try {
List<String> lines =
Files.readAllLines(uuidFile.toPath(), StandardCharsets.UTF_8);
for (String line : lines) {
try {
line = line.trim();
if (line.isEmpty()) {
continue;
}
line = line.replaceAll("[\\|][0-9]+[\\|][0-9]+[\\|]", "");
String[] split = line.split("\\|");
String name = split[0];
if (name.isEmpty() || (name.length() > 16) || !StringMan
.isAlphanumericUnd(name)) {
continue;
}
UUID uuid = FileUUIDHandler.this.uuidWrapper.getUUID(name);
if (uuid == null) {
continue;
}
UUIDHandler.add(new StringWrapper(name), uuid);
} catch (Exception e2) {
e2.printStackTrace();
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
HashBiMap<StringWrapper, UUID> toAdd =
HashBiMap.create(new HashMap<StringWrapper, UUID>());
if (Settings.UUID.NATIVE_UUID_PROVIDER) {
HashSet<UUID> all = UUIDHandler.getAllUUIDS();
PlotSquared.debug("&aFast mode UUID caching enabled!");
File playerDataFolder =
new File(container, world + File.separator + "playerdata");
String[] dat = playerDataFolder.list(new DatFileFilter());
boolean check = all.isEmpty();
if (dat != null) {
for (String current : dat) {
String s = current.replaceAll(".dat$", "");
try {
UUID uuid = UUID.fromString(s);
if (check || all.remove(uuid)) {
File file = new File(playerDataFolder, current);
NbtFactory.NbtCompound compound = NbtFactory
.fromStream(new FileInputStream(file),
NbtFactory.StreamOptions.GZIP_COMPRESSION);
if (!compound.containsKey("bukkit")) {
PlotSquared.debug("ERROR: Player data (" + uuid.toString()
+ ".dat) does not contain the the key \"bukkit\"");
} else {
NbtFactory.NbtCompound bukkit =
(NbtFactory.NbtCompound) compound.get("bukkit");
String name = (String) bukkit.get("lastKnownName");
long last = (long) bukkit.get("lastPlayed");
long first = (long) bukkit.get("firstPlayed");
if (ExpireManager.IMP != null) {
ExpireManager.IMP.storeDate(uuid, last);
ExpireManager.IMP.storeAccountAge(uuid, last - first);
}
toAdd.put(new StringWrapper(name), uuid);
}
}
} catch (Exception e) {
e.printStackTrace();
PlotSquared.debug(C.PREFIX + "Invalid playerdata: " + current);
}
}
}
add(toAdd);
if (all.isEmpty()) {
if (whenDone != null) {
whenDone.run();
}
return;
} else {
PlotSquared.debug("Failed to cache: " + all.size()
+ " uuids - slowly processing all files");
}
}
HashSet<String> worlds = Sets.newHashSet(world, "world");
HashSet<UUID> uuids = new HashSet<>();
HashSet<String> names = new HashSet<>();
File playerDataFolder = null;
for (String worldName : worlds) {
// Getting UUIDs
playerDataFolder =
new File(container, worldName + File.separator + "playerdata");
String[] dat = playerDataFolder.list(new DatFileFilter());
if ((dat != null) && (dat.length != 0)) {
for (String current : dat) {
String s = current.replaceAll(".dat$", "");
try {
UUID uuid = UUID.fromString(s);
uuids.add(uuid);
} catch (Exception ignored) {
PlotSquared.debug(C.PREFIX + "Invalid PlayerData: " + current);
}
}
break;
}
// Getting names
File playersFolder = new File(worldName + File.separator + "players");
dat = playersFolder.list(new DatFileFilter());
if ((dat != null) && (dat.length != 0)) {
for (String current : dat) {
names.add(current.replaceAll(".dat$", ""));
}
break;
}
}
for (UUID uuid : uuids) {
try {
File file =
new File(playerDataFolder + File.separator + uuid.toString() + ".dat");
if (!file.exists()) {
continue;
}
NbtFactory.NbtCompound compound = NbtFactory
.fromStream(new FileInputStream(file),
NbtFactory.StreamOptions.GZIP_COMPRESSION);
if (!compound.containsKey("bukkit")) {
PlotSquared.debug("ERROR: Player data (" + uuid.toString()
+ ".dat) does not contain the the key \"bukkit\"");
} else {
NbtFactory.NbtCompound bukkit =
(NbtFactory.NbtCompound) compound.get("bukkit");
String name = (String) bukkit.get("lastKnownName");
StringWrapper wrap = new StringWrapper(name);
if (!toAdd.containsKey(wrap)) {
long last = (long) bukkit.get("lastPlayed");
long first = (long) bukkit.get("firstPlayed");
if (Settings.UUID.OFFLINE) {
if (Settings.UUID.FORCE_LOWERCASE && !name.toLowerCase()
.equals(name)) {
uuid = FileUUIDHandler.this.uuidWrapper.getUUID(name);
} else {
long most = (long) compound.get("UUIDMost");
long least = (long) compound.get("UUIDLeast");
uuid = new UUID(most, least);
}
}
if (ExpireManager.IMP != null) {
ExpireManager.IMP.storeDate(uuid, last);
ExpireManager.IMP.storeAccountAge(uuid, last - first);
}
toAdd.put(wrap, uuid);
}
}
} catch (Exception ignored) {
PlotSquared
.debug(C.PREFIX + "&6Invalid PlayerData: " + uuid.toString() + ".dat");
}
}
for (String name : names) {
UUID uuid = FileUUIDHandler.this.uuidWrapper.getUUID(name);
StringWrapper nameWrap = new StringWrapper(name);
toAdd.put(nameWrap, uuid);
}
if (getUUIDMap().isEmpty()) {
for (OfflinePlotPlayer op : FileUUIDHandler.this.uuidWrapper
.getOfflinePlayers()) {
long last = op.getLastPlayed();
if (last != 0) {
String name = op.getName();
StringWrapper wrap = new StringWrapper(name);
if (!toAdd.containsKey(wrap)) {
UUID uuid = FileUUIDHandler.this.uuidWrapper.getUUID(op);
toAdd.put(wrap, uuid);
if (ExpireManager.IMP != null) {
ExpireManager.IMP.storeDate(uuid, last);
}
}
}
}
}
add(toAdd);
if (whenDone != null) {
whenDone.run();
}
}
});
return true;
}
@Override public void fetchUUID(final String name, final RunnableVal<UUID> ifFetch) {
TaskManager.runTaskAsync(new Runnable() {
@Override public void run() {
ifFetch.value = FileUUIDHandler.this.uuidWrapper.getUUID(name);
TaskManager.runTask(ifFetch);
}
});
}
}

View File

@ -1,32 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.uuid;
import com.github.intellectualsites.plotsquared.plot.object.OfflinePlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.google.common.base.Charsets;
import org.bukkit.OfflinePlayer;
import java.util.UUID;
public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
@Override public UUID getUUID(PlotPlayer player) {
return UUID.nameUUIDFromBytes(
("OfflinePlayer:" + player.getName().toLowerCase()).getBytes(Charsets.UTF_8));
}
@Override public UUID getUUID(OfflinePlotPlayer player) {
return UUID.nameUUIDFromBytes(
("OfflinePlayer:" + player.getName().toLowerCase()).getBytes(Charsets.UTF_8));
}
@Override public UUID getUUID(OfflinePlayer player) {
return UUID.nameUUIDFromBytes(
("OfflinePlayer:" + player.getName().toLowerCase()).getBytes(Charsets.UTF_8));
}
@Override public UUID getUUID(String name) {
return UUID
.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
}
}

View File

@ -1,108 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.uuid;
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitOfflinePlayer;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.OfflinePlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.StringWrapper;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
import com.google.common.base.Charsets;
import com.google.common.collect.BiMap;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.UUID;
public class OfflineUUIDWrapper extends UUIDWrapper {
private final Object[] arg = new Object[0];
private Method getOnline = null;
public OfflineUUIDWrapper() {
try {
this.getOnline = Server.class.getMethod("getOnlinePlayers");
} catch (NoSuchMethodException | SecurityException e) {
e.printStackTrace();
}
}
@Override public UUID getUUID(PlotPlayer player) {
return UUID
.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8));
}
@Override public UUID getUUID(OfflinePlotPlayer player) {
return UUID
.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8));
}
public UUID getUUID(OfflinePlayer player) {
return UUID
.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8));
}
@Override public OfflinePlotPlayer getOfflinePlayer(UUID uuid) {
BiMap<UUID, StringWrapper> map = UUIDHandler.getUuidMap().inverse();
String name = null;
if (map.containsKey(uuid)) {
name = map.get(uuid).value;
}
if (name != null) {
OfflinePlayer op = Bukkit.getOfflinePlayer(name);
if (op.hasPlayedBefore()) {
return new BukkitOfflinePlayer(op);
}
}
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
if (getUUID(player).equals(uuid)) {
return new BukkitOfflinePlayer(player);
}
}
return null;
}
public Player[] getOnlinePlayers() {
if (this.getOnline == null) {
Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
return onlinePlayers.toArray(new Player[onlinePlayers.size()]);
}
try {
Object players = this.getOnline.invoke(Bukkit.getServer(), this.arg);
if (players instanceof Player[]) {
return (Player[]) players;
} else {
@SuppressWarnings("unchecked") Collection<? extends Player> p =
(Collection<? extends Player>) players;
return p.toArray(new Player[p.size()]);
}
} catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException ignored) {
PlotSquared.debug("Failed to resolve online players");
this.getOnline = null;
Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
return onlinePlayers.toArray(new Player[onlinePlayers.size()]);
}
}
@Override public UUID getUUID(String name) {
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8));
}
@Override public OfflinePlotPlayer[] getOfflinePlayers() {
OfflinePlayer[] ops = Bukkit.getOfflinePlayers();
BukkitOfflinePlayer[] toReturn = new BukkitOfflinePlayer[ops.length];
for (int i = 0; i < ops.length; i++) {
toReturn[i] = new BukkitOfflinePlayer(ops[i]);
}
return toReturn;
}
@Override public OfflinePlotPlayer getOfflinePlayer(String name) {
return new BukkitOfflinePlayer(Bukkit.getOfflinePlayer(name));
}
}

View File

@ -1,264 +0,0 @@
package com.github.intellectualsites.plotsquared.bukkit.uuid;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.C;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.SQLite;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.object.StringWrapper;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandlerImplementation;
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
import com.google.common.collect.HashBiMap;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayDeque;
import java.util.Collections;
import java.util.HashMap;
import java.util.UUID;
public class SQLUUIDHandler extends UUIDHandlerImplementation {
final int MAX_REQUESTS = 500;
private final String PROFILE_URL =
"https://sessionserver.mojang.com/session/minecraft/profile/";
private final int INTERVAL = 12000;
private final JSONParser jsonParser = new JSONParser();
private final SQLite sqlite;
public SQLUUIDHandler(UUIDWrapper wrapper) {
super(wrapper);
this.sqlite =
new SQLite(MainUtil.getFile(PlotSquared.get().IMP.getDirectory(), "usercache.db"));
try {
this.sqlite.openConnection();
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
try (PreparedStatement stmt = getConnection().prepareStatement(
"CREATE TABLE IF NOT EXISTS `usercache` (uuid VARCHAR(32) NOT NULL, username VARCHAR(32) NOT NULL, PRIMARY KEY (uuid, username)"
+ ')')) {
stmt.execute();
} catch (SQLException e) {
e.printStackTrace();
}
startCaching(null);
}
private Connection getConnection() {
synchronized (this.sqlite) {
return this.sqlite.getConnection();
}
}
@Override public boolean startCaching(final Runnable whenDone) {
if (!super.startCaching(whenDone)) {
return false;
}
TaskManager.runTaskAsync(new Runnable() {
@Override public void run() {
try {
HashBiMap<StringWrapper, UUID> toAdd =
HashBiMap.create(new HashMap<StringWrapper, UUID>());
try (PreparedStatement statement = getConnection()
.prepareStatement("SELECT `uuid`, `username` FROM `usercache`");
ResultSet resultSet = statement.executeQuery()) {
while (resultSet.next()) {
StringWrapper username =
new StringWrapper(resultSet.getString("username"));
UUID uuid = UUID.fromString(resultSet.getString("uuid"));
toAdd.put(new StringWrapper(username.value), uuid);
}
}
add(toAdd);
// This should be called as long as there are some unknown plots
final ArrayDeque<UUID> toFetch = new ArrayDeque<>();
for (UUID u : UUIDHandler.getAllUUIDS()) {
if (!uuidExists(u)) {
toFetch.add(u);
}
}
if (toFetch.isEmpty()) {
if (whenDone != null) {
whenDone.run();
}
return;
}
FileUUIDHandler fileHandler =
new FileUUIDHandler(SQLUUIDHandler.this.uuidWrapper);
fileHandler.startCaching(new Runnable() {
@Override public void run() {
// If the file based UUID handler didn't cache it, then we can't cache offline mode
// Also, trying to cache based on files again, is useless as that's what the file based uuid cacher does
if (Settings.UUID.OFFLINE) {
if (whenDone != null) {
whenDone.run();
}
return;
}
TaskManager.runTaskAsync(new Runnable() {
@Override public void run() {
while (!toFetch.isEmpty()) {
try {
for (int i = 0;
i < Math.min(500, toFetch.size()); i++) {
UUID uuid = toFetch.pop();
HttpURLConnection connection =
(HttpURLConnection) new URL(
SQLUUIDHandler.this.PROFILE_URL + uuid
.toString().replace("-", ""))
.openConnection();
try (InputStream con = connection
.getInputStream()) {
InputStreamReader reader =
new InputStreamReader(con);
JSONObject response =
(JSONObject) SQLUUIDHandler.this.jsonParser
.parse(reader);
String name = (String) response.get("name");
if (name != null) {
add(new StringWrapper(name), uuid);
}
}
connection.disconnect();
}
} catch (IOException | ParseException e) {
PlotSquared.debug(
"Invalid response from Mojang: Some UUIDs will be cached later. (`unknown` until then or player joins)");
}
try {
Thread.sleep(INTERVAL * 50);
} catch (InterruptedException e) {
e.printStackTrace();
break;
}
}
if (whenDone != null) {
whenDone.run();
}
return;
}
});
}
});
} catch (SQLException e) {
throw new SQLUUIDHandlerException("Couldn't select :s", e);
}
}
});
return true;
}
@Override public void fetchUUID(final String name, final RunnableVal<UUID> ifFetch) {
PlotSquared.debug(C.PREFIX + "UUID for '" + name
+ "' was null. We'll cache this from the Mojang servers!");
if (ifFetch == null) {
return;
}
TaskManager.runTaskAsync(new Runnable() {
@Override public void run() {
try {
URL url = new URL(SQLUUIDHandler.this.PROFILE_URL);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
String body = JSONArray.toJSONString(Collections.singletonList(name));
OutputStream stream = connection.getOutputStream();
stream.write(body.getBytes());
stream.flush();
stream.close();
JSONArray array = (JSONArray) SQLUUIDHandler.this.jsonParser
.parse(new InputStreamReader(connection.getInputStream()));
JSONObject jsonProfile = (JSONObject) array.get(0);
String id = (String) jsonProfile.get("id");
String name = (String) jsonProfile.get("name");
ifFetch.value = UUID.fromString(
id.substring(0, 8) + '-' + id.substring(8, 12) + '-' + id.substring(12, 16)
+ '-' + id.substring(16, 20) + '-' + id.substring(20, 32));
} catch (IOException | ParseException e) {
e.printStackTrace();
}
TaskManager.runTask(ifFetch);
}
});
}
@Override public void handleShutdown() {
super.handleShutdown();
try {
getConnection().close();
} catch (SQLException e) {
throw new SQLUUIDHandlerException("Couldn't close database connection", e);
}
}
@Override public boolean add(final StringWrapper name, final UUID uuid) {
// Ignoring duplicates
if (super.add(name, uuid)) {
TaskManager.runTaskAsync(new Runnable() {
@Override public void run() {
try (PreparedStatement statement = getConnection().prepareStatement(
"REPLACE INTO usercache (`uuid`, `username`) VALUES(?, ?)")) {
statement.setString(1, uuid.toString());
statement.setString(2, name.toString());
statement.execute();
PlotSquared
.debug(C.PREFIX + "&cAdded '&6" + uuid + "&c' - '&6" + name + "&c'");
} catch (SQLException e) {
e.printStackTrace();
}
}
});
return true;
}
return false;
}
/**
* This is useful for name changes
*/
@Override public void rename(final UUID uuid, final StringWrapper name) {
super.rename(uuid, name);
TaskManager.runTaskAsync(new Runnable() {
@Override public void run() {
try (PreparedStatement statement = getConnection()
.prepareStatement("UPDATE usercache SET `username`=? WHERE `uuid`=?")) {
statement.setString(1, name.value);
statement.setString(2, uuid.toString());
statement.execute();
PlotSquared.debug(
C.PREFIX + "Name change for '" + uuid + "' to '" + name.value + '\'');
} catch (SQLException e) {
e.printStackTrace();
}
}
});
}
private class SQLUUIDHandlerException extends RuntimeException {
SQLUUIDHandlerException(String s, Throwable c) {
super("SQLUUIDHandler caused an exception: " + s, c);
}
}
}

View File

@ -0,0 +1,83 @@
/*
* _____ _ _ _____ _
* | __ \| | | | / ____| | |
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
* | |
* |_|
* PlotSquared plot management system for Minecraft
* Copyright (C) 2021 IntellectualSites
*
* 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/>.
*/
package com.plotsquared.bukkit;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.core.command.MainCommand;
import com.plotsquared.core.player.ConsolePlayer;
import com.plotsquared.core.player.PlotPlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.ProxiedCommandSender;
import org.bukkit.command.RemoteConsoleCommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class BukkitCommand implements CommandExecutor, TabCompleter {
@Override
public boolean onCommand(CommandSender commandSender, Command command, String commandLabel,
String[] args) {
if (commandSender instanceof Player) {
return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), args);
}
if (commandSender instanceof ConsoleCommandSender
|| commandSender instanceof ProxiedCommandSender
|| commandSender instanceof RemoteConsoleCommandSender) {
return MainCommand.onCommand(ConsolePlayer.getConsole(), args);
}
return false;
}
@Override
public List<String> onTabComplete(CommandSender commandSender, Command command, String s,
String[] args) {
if (!(commandSender instanceof Player)) {
return null;
}
PlotPlayer player = BukkitUtil.getPlayer((Player) commandSender);
if (args.length == 0) {
return Collections.singletonList("plots");
}
Collection<com.plotsquared.core.command.Command> objects =
MainCommand.getInstance().tab(player, args, s.endsWith(" "));
if (objects == null) {
return null;
}
List<String> result = new ArrayList<>();
for (com.plotsquared.core.command.Command o : objects) {
result.add(o.toString());
}
return result;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,29 @@
package com.github.intellectualsites.plotsquared.bukkit.chat; /*
* _____ _ _ _____ _
* | __ \| | | | / ____| | |
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
* | |
* |_|
* PlotSquared plot management system for Minecraft
* Copyright (C) 2021 IntellectualSites
*
* 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/>.
*/
package com.plotsquared.bukkit.chat;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;

View File

@ -1,11 +1,39 @@
package com.github.intellectualsites.plotsquared.bukkit.chat; /*
* _____ _ _ _____ _
* | __ \| | | | / ____| | |
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
* | |
* |_|
* PlotSquared plot management system for Minecraft
* Copyright (C) 2021 IntellectualSites
*
* 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/>.
*/
package com.plotsquared.bukkit.chat;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import com.google.gson.stream.JsonWriter; import com.google.gson.stream.JsonWriter;
import org.bukkit.*; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Statistic;
import org.bukkit.Statistic.Type; import org.bukkit.Statistic.Type;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.ConfigurationSerializable;
@ -16,8 +44,19 @@ import org.bukkit.inventory.ItemStack;
import java.io.IOException; import java.io.IOException;
import java.io.StringWriter; import java.io.StringWriter;
import java.lang.reflect.*; import java.lang.reflect.Constructor;
import java.util.*; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;
/** /**
@ -36,6 +75,7 @@ public class FancyMessage
private static Constructor<?> nmsPacketPlayOutChatConstructor; private static Constructor<?> nmsPacketPlayOutChatConstructor;
// The ChatSerializer's instance of Gson // The ChatSerializer's instance of Gson
private static Object nmsChatSerializerGsonInstance; private static Object nmsChatSerializerGsonInstance;
private static Object chatMessageType;
private static Method fromJsonMethod; private static Method fromJsonMethod;
private static JsonParser _stringParser = new JsonParser(); private static JsonParser _stringParser = new JsonParser();
@ -63,8 +103,16 @@ public class FancyMessage
dirty = false; dirty = false;
if (nmsPacketPlayOutChatConstructor == null) { if (nmsPacketPlayOutChatConstructor == null) {
try { try {
nmsPacketPlayOutChatConstructor = Reflection.getNMSClass("PacketPlayOutChat") Class<?> componentClass = Reflection.getNMSClass("IChatBaseComponent");
.getDeclaredConstructor(Reflection.getNMSClass("IChatBaseComponent")); if (!Reflection.getVersion().startsWith("v1_16")) { // < 1.16 TODO needs to be fixed before 1.17 :P
nmsPacketPlayOutChatConstructor = Reflection.getNMSClass("PacketPlayOutChat")
.getDeclaredConstructor(componentClass);
} else {
Class<Enum> chatMessageTypeClass = (Class<Enum>) Reflection.getNMSClass("ChatMessageType");
nmsPacketPlayOutChatConstructor = Reflection.getNMSClass("PacketPlayOutChat")
.getDeclaredConstructor(componentClass, chatMessageTypeClass, UUID.class);
chatMessageType = Enum.valueOf(chatMessageTypeClass, "SYSTEM");
}
nmsPacketPlayOutChatConstructor.setAccessible(true); nmsPacketPlayOutChatConstructor.setAccessible(true);
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
Bukkit.getLogger() Bukkit.getLogger()
@ -320,34 +368,6 @@ public class FancyMessage
return this; return this;
} }
/**
* Set the behavior of the current editing component to display information about an achievement when the client hovers over the text.
* <p>Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.</p>
*
* @param which The achievement to display.
* @return This builder instance.
*/
public FancyMessage achievementTooltip(final Achievement which) {
try {
Object achievement = Reflection
.getMethod(Reflection.getOBCClass("CraftStatistic"), "getNMSAchievement",
Achievement.class).invoke(null, which);
return achievementTooltip(
(String) Reflection.getField(Reflection.getNMSClass("Achievement"), "name")
.get(achievement));
} catch (IllegalAccessException e) {
Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
return this;
} catch (IllegalArgumentException e) {
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
return this;
} catch (InvocationTargetException e) {
Bukkit.getLogger()
.log(Level.WARNING, "A error has occurred during invoking of method.", e);
return this;
}
}
/** /**
* Set the behavior of the current editing component to display information about a parameterless statistic when the client hovers over the text. * Set the behavior of the current editing component to display information about a parameterless statistic when the client hovers over the text.
* <p>Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.</p> * <p>Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.</p>
@ -648,9 +668,7 @@ public class FancyMessage
* @return This builder instance. * @return This builder instance.
*/ */
public FancyMessage translationReplacements(final FancyMessage... replacements) { public FancyMessage translationReplacements(final FancyMessage... replacements) {
for (FancyMessage str : replacements) { Collections.addAll(latest().translationReplacements, replacements);
latest().translationReplacements.add(str);
}
dirty = true; dirty = true;
@ -765,7 +783,7 @@ public class FancyMessage
Reflection.getField(handle.getClass(), "playerConnection").get(handle); Reflection.getField(handle.getClass(), "playerConnection").get(handle);
Reflection Reflection
.getMethod(connection.getClass(), "sendPacket", Reflection.getNMSClass("Packet")) .getMethod(connection.getClass(), "sendPacket", Reflection.getNMSClass("Packet"))
.invoke(connection, createChatPacket(jsonString)); .invoke(connection, createChatPacket(jsonString, ((Player) sender).getUniqueId()));
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e); Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
@ -782,7 +800,7 @@ public class FancyMessage
} }
} }
private Object createChatPacket(String json) private Object createChatPacket(String json, UUID receiver)
throws IllegalArgumentException, IllegalAccessException, InstantiationException, throws IllegalArgumentException, IllegalAccessException, InstantiationException,
InvocationTargetException, NoSuchMethodException, ClassNotFoundException { InvocationTargetException, NoSuchMethodException, ClassNotFoundException {
if (nmsChatSerializerGsonInstance == null) { if (nmsChatSerializerGsonInstance == null) {
@ -830,7 +848,11 @@ public class FancyMessage
Object serializedChatComponent = fromJsonMethod.invoke(nmsChatSerializerGsonInstance, json, Object serializedChatComponent = fromJsonMethod.invoke(nmsChatSerializerGsonInstance, json,
Reflection.getNMSClass("IChatBaseComponent")); Reflection.getNMSClass("IChatBaseComponent"));
return nmsPacketPlayOutChatConstructor.newInstance(serializedChatComponent); if (!Reflection.getVersion().startsWith("v1_16")) {
return nmsPacketPlayOutChatConstructor.newInstance(serializedChatComponent);
} else {
return nmsPacketPlayOutChatConstructor.newInstance(serializedChatComponent, chatMessageType, receiver);
}
} }
/** /**
@ -869,7 +891,6 @@ public class FancyMessage
* <li>The core text of the message part.</li> * <li>The core text of the message part.</li>
* </ol> * </ol>
* The primary omissions are tooltips and clickable actions. Consequently, this method should be used only as a last resort. * The primary omissions are tooltips and clickable actions. Consequently, this method should be used only as a last resort.
* </p>
* <p> * <p>
* Color and formatting can be removed from the returned string by using {@link ChatColor#stripColor(String)}.</p> * Color and formatting can be removed from the returned string by using {@link ChatColor#stripColor(String)}.</p>
* *

View File

@ -0,0 +1,45 @@
/*
* _____ _ _ _____ _
* | __ \| | | | / ____| | |
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
* | |
* |_|
* PlotSquared plot management system for Minecraft
* Copyright (C) 2021 IntellectualSites
*
* 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/>.
*/
package com.plotsquared.bukkit.chat;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
/**
* Represents an object that can be serialized to a JSON writer instance.
*/
interface JsonRepresentedObject {
/**
* Writes the JSON representation of this object to the specified writer.
*
* @param writer The JSON writer which will receive the object.
* @throws IOException If an error occurs writing to the stream.
*/
public void writeJson(JsonWriter writer) throws IOException;
}

View File

@ -0,0 +1,70 @@
/*
* _____ _ _ _____ _
* | __ \| | | | / ____| | |
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
* | |
* |_|
* PlotSquared plot management system for Minecraft
* Copyright (C) 2021 IntellectualSites
*
* 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/>.
*/
package com.plotsquared.bukkit.chat;
import com.google.gson.stream.JsonWriter;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* Represents a JSON string value.
* Writes by this object will not write name values nor begin/end objects in the JSON stream.
* All writes merely write the represented string value.
*/
final class JsonString implements JsonRepresentedObject, ConfigurationSerializable {
private String _value;
public JsonString(CharSequence value) {
_value = value == null ? null : value.toString();
}
public static JsonString deserialize(Map<String, Object> map) {
return new JsonString(map.get("stringValue").toString());
}
@Override public void writeJson(JsonWriter writer) throws IOException {
writer.value(getValue());
}
public String getValue() {
return _value;
}
public Map<String, Object> serialize() {
HashMap<String, Object> theSingleValue = new HashMap<String, Object>();
theSingleValue.put("stringValue", _value);
return theSingleValue;
}
@Override public String toString() {
return _value;
}
}

View File

@ -1,4 +1,29 @@
package com.github.intellectualsites.plotsquared.bukkit.chat; /*
* _____ _ _ _____ _
* | __ \| | | | / ____| | |
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
* | |
* |_|
* PlotSquared plot management system for Minecraft
* Copyright (C) 2021 IntellectualSites
*
* 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/>.
*/
package com.plotsquared.bukkit.chat;
import com.google.common.collect.BiMap; import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap; import com.google.common.collect.ImmutableBiMap;
@ -123,8 +148,7 @@ final class MessagePart implements JsonRepresentedObject, ConfigurationSerializa
if (insertionData != null) { if (insertionData != null) {
json.name("insertion").value(insertionData); json.name("insertion").value(insertionData);
} }
if (translationReplacements.size() > 0 && text != null && TextualComponent if (translationReplacements.size() > 0 && TextualComponent.isTranslatableText(text)) {
.isTranslatableText(text)) {
json.name("with").beginArray(); json.name("with").beginArray();
for (JsonRepresentedObject obj : translationReplacements) { for (JsonRepresentedObject obj : translationReplacements) {
obj.writeJson(json); obj.writeJson(json);
@ -134,7 +158,7 @@ final class MessagePart implements JsonRepresentedObject, ConfigurationSerializa
json.endObject(); json.endObject();
} catch (IOException e) { } catch (IOException e) {
Bukkit.getLogger() Bukkit.getLogger()
.log(Level.WARNING, "A problem occured during writing of JSON string", e); .log(Level.WARNING, "A problem occurred during writing of JSON string", e);
} }
} }

View File

@ -1,4 +1,29 @@
package com.github.intellectualsites.plotsquared.bukkit.chat; /*
* _____ _ _ _____ _
* | __ \| | | | / ____| | |
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
* | |
* |_|
* PlotSquared plot management system for Minecraft
* Copyright (C) 2021 IntellectualSites
*
* 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/>.
*/
package com.plotsquared.bukkit.chat;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -43,10 +68,6 @@ public final class Reflection {
*/ */
public synchronized static String getVersion() { public synchronized static String getVersion() {
if (_versionString == null) { if (_versionString == null) {
if (Bukkit.getServer() == null) {
// The server hasn't started, static initializer call?
return null;
}
String name = Bukkit.getServer().getClass().getPackage().getName(); String name = Bukkit.getServer().getClass().getPackage().getName();
_versionString = name.substring(name.lastIndexOf('.') + 1) + "."; _versionString = name.substring(name.lastIndexOf('.') + 1) + ".";
} }
@ -180,15 +201,11 @@ public final class Reflection {
* @return A method object with the specified name declared by the specified class. * @return A method object with the specified name declared by the specified class.
*/ */
public synchronized static Method getMethod(Class<?> clazz, String name, Class<?>... args) { public synchronized static Method getMethod(Class<?> clazz, String name, Class<?>... args) {
if (!_loadedMethods.containsKey(clazz)) { _loadedMethods.computeIfAbsent(clazz, k -> new HashMap<>());
_loadedMethods.put(clazz, new HashMap<String, Map<ArrayWrapper<Class<?>>, Method>>());
}
Map<String, Map<ArrayWrapper<Class<?>>, Method>> loadedMethodNames = Map<String, Map<ArrayWrapper<Class<?>>, Method>> loadedMethodNames =
_loadedMethods.get(clazz); _loadedMethods.get(clazz);
if (!loadedMethodNames.containsKey(name)) { loadedMethodNames.computeIfAbsent(name, k -> new HashMap<>());
loadedMethodNames.put(name, new HashMap<ArrayWrapper<Class<?>>, Method>());
}
Map<ArrayWrapper<Class<?>>, Method> loadedSignatures = loadedMethodNames.get(name); Map<ArrayWrapper<Class<?>>, Method> loadedSignatures = loadedMethodNames.get(name);
ArrayWrapper<Class<?>> wrappedArg = new ArrayWrapper<>(args); ArrayWrapper<Class<?>> wrappedArg = new ArrayWrapper<>(args);

View File

@ -1,4 +1,29 @@
package com.github.intellectualsites.plotsquared.bukkit.chat; /*
* _____ _ _ _____ _
* | __ \| | | | / ____| | |
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
* | |
* |_|
* PlotSquared plot management system for Minecraft
* Copyright (C) 2021 IntellectualSites
*
* 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/>.
*/
package com.plotsquared.bukkit.chat;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;

View File

@ -0,0 +1,33 @@
/*
* _____ _ _ _____ _
* | __ \| | | | / ____| | |
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
* | |
* |_|
* PlotSquared plot management system for Minecraft
* Copyright (C) 2021 IntellectualSites
*
* 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/>.
*/
package com.plotsquared.bukkit.entity;
class AgeableStats {
int age;
boolean locked;
boolean adult;
}

View File

@ -0,0 +1,40 @@
/*
* _____ _ _ _____ _
* | __ \| | | | / ____| | |
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
* | |
* |_|
* PlotSquared plot management system for Minecraft
* Copyright (C) 2021 IntellectualSites
*
* 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/>.
*/
package com.plotsquared.bukkit.entity;
class ArmorStandStats {
final float[] head = new float[3];
final float[] body = new float[3];
final float[] leftLeg = new float[3];
final float[] rightLeg = new float[3];
final float[] leftArm = new float[3];
final float[] rightArm = new float[3];
boolean arms;
boolean noPlate;
boolean invisible;
boolean small;
}

Some files were not shown because too many files have changed in this diff Show More