Compare commits
595 Commits
Schematics
...
BauSystem/
| Author | SHA1 | Date | |
|---|---|---|---|
| 4c82469171 | |||
| 633dc67be0 | |||
| ca521f5495 | |||
| 7a598185a0 | |||
| 54b088214f | |||
| c133d57250 | |||
| a0dd017389 | |||
| 863d32ffc3 | |||
| 8061ea52f5 | |||
| 14886eb523 | |||
| bdd681c727 | |||
| 77ae31822f | |||
| 3d9b16f1b1 | |||
| 9279d9cd8e | |||
| b7963f2fe6 | |||
| 3f88ea1e57 | |||
| 8076f31a19 | |||
| 33e9b3409f | |||
| 297aa6151d | |||
| 14be3a8e3b | |||
| 1c1e2e2efe | |||
| e30eb35792 | |||
| e94f273e21 | |||
| c76648e630 | |||
| a943dd6014 | |||
| 0d7776ec6f | |||
| 7db1d80988 | |||
| 50bd18bae7 | |||
| 89a55996fc | |||
| f494729b89 | |||
| bcabce8b23 | |||
| 376da2028b | |||
| b6cfaf8135 | |||
| 5daee0f589 | |||
| 43663ea099 | |||
| 9d1b0063b9 | |||
| e706044f44 | |||
| 332daec716 | |||
| 2daca017c2 | |||
| 7edd72ac27 | |||
| 1355b57a93 | |||
| e04f0d4ad1 | |||
| 79a6c93f8f | |||
| e36bbfd2a7 | |||
| 65cb544b64 | |||
| 8a22afab63 | |||
| caae9542f4 | |||
| 4104c60f6b | |||
| 69260a9b73 | |||
| 4fb6505aef | |||
| bb2f7cf0c1 | |||
| 8516c8e536 | |||
| 066f06a6e3 | |||
| 78e176b55e | |||
| 86a10b3e97 | |||
| d01efffb6a | |||
| fd57ba43e9 | |||
| eac0390dd3 | |||
| 03005adcd8 | |||
| 933e2119ef | |||
| 679d373a1e | |||
| 828084a3d6 | |||
| 2b782585b1 | |||
| b43965be91 | |||
| d82f306094 | |||
| 30cdbe072e | |||
| db7e1a5fc9 | |||
| 3e5055c246 | |||
| 44c06314c6 | |||
| e06742d6d2 | |||
| 62e674ed42 | |||
| 0464442b83 | |||
| c682333771 | |||
| 58ab619144 | |||
| 00de852575 | |||
| 948cf5e8db | |||
| 7aba8da5a0 | |||
| 5a77854752 | |||
| cf1422f532 | |||
| 6260e65b33 | |||
| 6db404c1e6 | |||
| b086fcaa32 | |||
| f33b3521b8 | |||
| dc72ec1b93 | |||
| 0e9c9bd4dc | |||
| 291b6b1804 | |||
| 104f0cf02d | |||
| f7662cdcba | |||
| 167b36b10c | |||
| b9b541957b | |||
| e9d107f0ed | |||
| 1e264a63a2 | |||
| 868ba4073b | |||
| 3410dd5a4b | |||
| b86a26a709 | |||
| 71238a0167 | |||
| 30ac947ebb | |||
| a7d64b5887 | |||
| d7908c8255 | |||
| 12f26b982e | |||
| 2be4118399 | |||
| 9d6981ee0c | |||
| 97a4d47aa7 | |||
| d657f9871d | |||
| a572b84016 | |||
| f1c6b4b453 | |||
| d0414c71f3 | |||
| 3530aec5e2 | |||
| cccd090357 | |||
| 3ae9a41b31 | |||
| b8b38cf777 | |||
| c1eca74dd0 | |||
| 8c23bf5bd4 | |||
| 556c8f7db1 | |||
| 7a03b327ef | |||
| 0091cba336 | |||
| 35d8bfb588 | |||
| 78584fea34 | |||
| 66511e514c | |||
| 6f64d03fee | |||
| c04e8d75eb | |||
| 5c7c982175 | |||
| d5ca1e14e1 | |||
| 60347bc481 | |||
| fbfdcf8fff | |||
| e56c41ca66 | |||
| 3b67048b9c | |||
| 6efbda669e | |||
| 4bd5d9eb0b | |||
| 60a70dfc40 | |||
| 95a97aed93 | |||
| 6fa54aba2f | |||
| d04939fb2c | |||
| 4c98ce4aff | |||
| 4ed6bc52d0 | |||
| bc00873314 | |||
| 8677d59cce | |||
| 6b16bbc785 | |||
| 617bae5a5c | |||
| 9988774fb4 | |||
| 4fc707431f | |||
| 8ff0319fe6 | |||
| 86537a00de | |||
| e9f8a89758 | |||
| f37fbfffdf | |||
| 9798c08cf3 | |||
| dbd979a5fe | |||
| 280202c43f | |||
| 23df187eb1 | |||
| 39af920631 | |||
| e4864e6eaf | |||
| d2bb8e8e59 | |||
| bd9451f2aa | |||
| 1bb15d9551 | |||
| d06faa5d18 | |||
| bc5e781810 | |||
| 14b756261e | |||
| 1f1f99f8f3 | |||
| d9aeb47a3a | |||
| afe30fd348 | |||
| 9f323c8b38 | |||
| b6279fd7fa | |||
| 3f7cd48f27 | |||
| c682678827 | |||
| 1fd8b3c4cb | |||
| c6ecab5aa8 | |||
| 4383e541d8 | |||
| cc4532ab90 | |||
| 3e448e7597 | |||
| d975110470 | |||
| f6852a5523 | |||
| 40437afb73 | |||
| 80a156754d | |||
| dfc7bbbe13 | |||
| dd5f46069f | |||
| b10897c204 | |||
| f6dc1e1059 | |||
| dccb435bce | |||
| 1c8d6580d5 | |||
| 187087f56b | |||
| 77cf101889 | |||
| 0f68f671f5 | |||
| 75c4966e37 | |||
| fcebb4ffd3 | |||
| 9abbcc908d | |||
| 4eb40581f2 | |||
| c3a4e7ed85 | |||
| 5201a3edc0 | |||
| c9821053ce | |||
| eb8562b3a9 | |||
| 37acbf0033 | |||
| 9e294afa8f | |||
| 3e9ffa52c3 | |||
| 3296d9ebb3 | |||
| 3d562cf743 | |||
| 24f4ab7f37 | |||
| 0ea92be2e1 | |||
| 88d8016987 | |||
| 909c1c52aa | |||
| 26b126fdba | |||
| ecb2e736aa | |||
| 38559e8a2b | |||
| 1aba92e707 | |||
| e4df6f55fb | |||
| ff5113e112 | |||
| c425ca1171 | |||
| c1293ffda0 | |||
| 02428868c2 | |||
| adaae7f943 | |||
| c12d2c2ddf | |||
| 428c63429c | |||
| edec84c60a | |||
| 4f885a7269 | |||
| dfd9febd8c | |||
| 1a570dca17 | |||
| 761977c90a | |||
| 5cc417c43c | |||
| 1014df5f31 | |||
| c920664920 | |||
| 3069ffc991 | |||
| c3db2b7f86 | |||
| c30f24ab8f | |||
| bcb0ad4bef | |||
| f2a46e54ea | |||
| daede98a0f | |||
| d37a14f280 | |||
| 083c5c07c2 | |||
| 7b059cde0e | |||
| 30fa3fd66e | |||
| 37f6723542 | |||
| 7a9740c4c4 | |||
| 54eec6d57c | |||
| 2f93f336c9 | |||
| 62f9d37230 | |||
| b479b6667b | |||
| 9bc01a4e3b | |||
| b14cf445df | |||
| 527bc39d38 | |||
| 8defbaa18b | |||
| a5bb62590c | |||
| c35d4741a0 | |||
| a2a101c4e3 | |||
| 277e1f9f9b | |||
| 380506542f | |||
| d410484e4c | |||
| 8768fd7d81 | |||
| 374e314faa | |||
| 45a8aab321 | |||
| 0d15bbc266 | |||
| 7fa97ce36c | |||
| 8cd088050d | |||
| b0bbc09113 | |||
| a5b61fb0d6 | |||
| 297e6c9b59 | |||
| 400c78447a | |||
| 778d0282d3 | |||
| 2a314e7035 | |||
| 6ed639fbb3 | |||
| 3a79f19f37 | |||
| f7e81f8204 | |||
| 7f215b921e | |||
| b0be06136d | |||
| 8132e4fca0 | |||
| bf5eef2ebd | |||
| 69251f42a6 | |||
| 6bbe94150d | |||
| 717cfa8baf | |||
| 260656ad35 | |||
| e893d7934a | |||
| d0665932f4 | |||
| d6fba9b0af | |||
| b229b0d0ae | |||
| ac00245b04 | |||
| 6eb01a61b1 | |||
| fa13872f22 | |||
| 79edc1c591 | |||
| 6e9db276ef | |||
| e3179c69aa | |||
| c633694222 | |||
| a4eea298d2 | |||
| f387805b40 | |||
| 2c644eef26 | |||
| 7f0fa09c56 | |||
| 6940c32b02 | |||
| 5015aca159 | |||
| 32c85b9bd5 | |||
| 15bb92fbba | |||
| d6a5caf95d | |||
| 1912ad52e4 | |||
| 66d18e316b | |||
| f30c3b2f34 | |||
| 7e863e8062 | |||
| 5cdad8c2f4 | |||
| 87a7120a6a | |||
| b5a9564808 | |||
| f93362a023 | |||
| b1bef4ced5 | |||
| e7e1e2d968 | |||
| 713275ba11 | |||
| e72ae3cf94 | |||
| d36753dec1 | |||
| 84cc292df4 | |||
| f89c4e88f9 | |||
| aeff16b7dd | |||
| bb97d80c18 | |||
| 7d45680fcb | |||
| a38f9222dd | |||
| 5ee9d3e167 | |||
| 98321de46c | |||
| 239ba3f213 | |||
| 3d7dedd3ad | |||
| ef66b8c1f1 | |||
| 1201b16ee4 | |||
| 4ddd88f540 | |||
| 147e34c0d6 | |||
| ca35ab9234 | |||
| 3df84a7dad | |||
| 313b22cb44 | |||
| 83c20729fa | |||
| 925901e40e | |||
| 059dd314d1 | |||
| 86ff619548 | |||
| 76e00b07db | |||
| 4edfd32ff5 | |||
| 5669725f9b | |||
| 335649fa87 | |||
| 9001e83321 | |||
| 32703c6659 | |||
| e393aad25f | |||
| 50543ddd4e | |||
| 230ac09b61 | |||
| 48ea88e1a7 | |||
| 05dc42355d | |||
| 17704487c9 | |||
| 76bbfd0381 | |||
| ae9166528d | |||
| 119fae4b51 | |||
| 43621b18b4 | |||
| e5bdbac3c7 | |||
| fd738f539a | |||
| b4c7576433 | |||
| 8204e2ad21 | |||
| 684a74b60d | |||
| 1f58b51af6 | |||
| c9cfb48c4e | |||
| ace567ba33 | |||
| 2094120150 | |||
| e143268caa | |||
| 7802fdd7d9 | |||
| 7fb3d3d137 | |||
| 61d84492dc | |||
| f74780d395 | |||
| 62dac000d4 | |||
| 424c80ec81 | |||
| ae7d394ae2 | |||
| 306444356c | |||
| 29dff8dce6 | |||
| cbaacd4e85 | |||
| e24dada435 | |||
| d04ffd5cf6 | |||
| 9da1de9b6c | |||
| 866c376ee5 | |||
| 0b14a216d9 | |||
| b2853b9dec | |||
| df5c363fb7 | |||
| 5b3c3f36b4 | |||
| e1bcdd59ba | |||
| 40eeb4993f | |||
| 4c23915987 | |||
| c9e4b57f12 | |||
| fdcd248ba6 | |||
| f573771355 | |||
| 80078cd8e2 | |||
| 76fc468d89 | |||
| 1304048509 | |||
| cf4ac95c2f | |||
| 4a816696ec | |||
| 038f54c3b3 | |||
| f2d8c9c02b | |||
| 2405c5e620 | |||
| d9493c7474 | |||
| 2ccb240ef5 | |||
| d1d1679c0a | |||
| 4c6ab2c1a0 | |||
| 62002e44d7 | |||
| 9c3f7526ff | |||
| eefe17e5f7 | |||
| 812e78d277 | |||
| fd220d7fd4 | |||
| 446cd5deae | |||
| a6c46d0270 | |||
| 2686ab285b | |||
| 57ea1470e2 | |||
| bfdc9c118a | |||
| dafe838a8a | |||
| 13bd154383 | |||
| 9248c9fa51 | |||
| 764dec99f4 | |||
| c9a1528dfe | |||
| 8c37466312 | |||
| 3b7e38aceb | |||
| e7c4c998a0 | |||
| 5907648462 | |||
| b32d6e9c69 | |||
| f533e85007 | |||
| 81c310c946 | |||
| 47c8cb1701 | |||
| f62af55d39 | |||
| 1dcd2f102c | |||
| 87f0765506 | |||
| b37ded3a8d | |||
| c4e9f80315 | |||
| 19e14f787a | |||
| 0f629a6387 | |||
| 1a356da6e0 | |||
| f6a18dffcc | |||
| 98cc09a7d3 | |||
| 4c8a03ac9c | |||
| 16f2eaad52 | |||
| 90d2e70a6e | |||
| d22b01f5e6 | |||
| 71522973a7 | |||
| 0da3ebfbcc | |||
| 923142d0cb | |||
| eca9963653 | |||
| 9467291020 | |||
| e14c7321c2 | |||
| 50b6947312 | |||
| 9eca9ab990 | |||
| 34e4cd7060 | |||
| 30cb09c127 | |||
| c94d67660a | |||
| 522cd850a2 | |||
| 394591f302 | |||
| 3016ad31fa | |||
| 1d293b446c | |||
| 3b41cc4ac5 | |||
| a71f3f6c66 | |||
| 2225b811fa | |||
| 96c25687b6 | |||
| 82723e4c31 | |||
| 17eaefe3d0 | |||
| 911a08a156 | |||
| b60111e717 | |||
| 644cc9da84 | |||
| 29cb1cc5da | |||
| 9bc1f8b328 | |||
| f38b85f9cb | |||
| 600c24441c | |||
| f3b5a45f62 | |||
| caee70c07e | |||
| 5f73395b63 | |||
| b4eab65757 | |||
| 0a60654a28 | |||
| 85c0db873c | |||
| f0beb22856 | |||
| af55c946a6 | |||
| 8b49b8a736 | |||
| 6d4ae9593d | |||
| 2fad352f62 | |||
| 2d28cc6182 | |||
| b0bd719627 | |||
| 284c4acd4b | |||
| 96a4168f37 | |||
| c77b8f57ce | |||
| e3c02cfb60 | |||
| ade9a1b5eb | |||
| ce907389df | |||
| d9b58d7170 | |||
| 3db327eb84 | |||
| fd82707414 | |||
| a2b3661605 | |||
| b045f16160 | |||
| dea0d33185 | |||
| 11cf0b6c54 | |||
| 593ca9f0cf | |||
| 7f5b57516e | |||
| 8ec12603b6 | |||
| ef029eb420 | |||
| 9f108a7cea | |||
| b516d1d569 | |||
| 56e1abca7e | |||
| 5420c19b39 | |||
| dd9467fa36 | |||
| ccbac9f7fb | |||
| 6aeecd444e | |||
| ec43e7eba8 | |||
| fbea45fb0f | |||
| abbbf7d3cb | |||
| 1dc0c0d8a8 | |||
| 25cf1ab314 | |||
| 1715fdccdf | |||
| e39db5978b | |||
| b4baef321f | |||
| 93ab1a50f3 | |||
| c6a7107ec2 | |||
| 8ac5fe44ef | |||
| 414bd20eb9 | |||
| 482282f913 | |||
| 3d153d49b5 | |||
| 20c90d9af5 | |||
| c799046f43 | |||
| 90666e2d20 | |||
| 77c6f41f1a | |||
| b3ddc04830 | |||
| 02b63687bc | |||
| dbf59df173 | |||
| 71362bc079 | |||
| 315674ebd8 | |||
| d5fb48ff3f | |||
| 5eaff4c492 | |||
| 4db5c50b06 | |||
| aa01fde5a0 | |||
| aa5fcd3811 | |||
| de591b7a5f | |||
| e83878a49b | |||
| bbd42a769b | |||
| 6541c34cc8 | |||
| 364911e449 | |||
| 7f7f84a4c4 | |||
| 3fadeb7751 | |||
| 8da9a3cfbb | |||
| 0ce7429151 | |||
| 2848db02ab | |||
| 35e4f66c91 | |||
| b4accdf0a1 | |||
| b41eec56b9 | |||
| 35142f108f | |||
| af79ef544b | |||
| ca076f9ffd | |||
| eacae09e4f | |||
| 90ebc93b14 | |||
| 747bb1055d | |||
| 18418cca2a | |||
| a9660bd325 | |||
| 569d5b033e | |||
| 052e549606 | |||
| 6519269d74 | |||
| ee705792bf | |||
| 65cf84f164 | |||
| a13039bce4 | |||
| d721a7496e | |||
| 721723716e | |||
| 3d2cba6a28 | |||
| 3be748b92e | |||
| 898f3c785b | |||
| 2192eddb8b | |||
| 327da139ba | |||
| 658dcd024d | |||
| ab4aaf782f | |||
| 21b389a993 | |||
| 3d78a23af1 | |||
| 07185d0960 | |||
| d42da4c903 | |||
| afd0541039 | |||
| eaae2f4009 | |||
| 0c815ee1d5 | |||
| 429f938f1c | |||
| fba7fe5008 | |||
| 4012426e26 | |||
| fe4e486d41 | |||
| 79a0fcb3aa | |||
| 393f840507 | |||
| 349e36fb6b | |||
| 6096828394 | |||
| 2d84cc8ca7 | |||
| ceff8e9cd5 | |||
| 82e6aff4bb | |||
| 8e7a6a56ca | |||
| 12c2ae435d | |||
| 2564227ec7 | |||
| 91d4a2dac3 | |||
| f7c9c6d796 | |||
| 0f1fbc4b88 | |||
| bfdf6471d2 | |||
| e418109ab7 | |||
| 06010ae27c | |||
| a39f172a34 | |||
| 82c73f9367 | |||
| 1350be9b80 | |||
| 1f65121c68 | |||
| 3c848389c9 | |||
| 33f41869b6 | |||
| 3c1d46398d | |||
| 8e51db3e5b | |||
| fdd25b11a2 | |||
| b6d5f8dcba | |||
| 604a1db218 | |||
| 01da293680 | |||
| e26e590e18 | |||
| 26bc341c4d | |||
| 9a8cb543e9 | |||
| 053bd06342 | |||
| 088965df59 | |||
| 55adb1a052 |
7
.gitignore
vendored
7
.gitignore
vendored
@ -14,6 +14,11 @@ steamwar.properties
|
||||
# VSCode
|
||||
bin/
|
||||
.vscode
|
||||
.settings
|
||||
|
||||
# Other
|
||||
lib
|
||||
lib
|
||||
/WebsiteBackend/data
|
||||
/WebsiteBackend/logs
|
||||
/WebsiteBackend/skins
|
||||
/WebsiteBackend/config.json
|
||||
@ -109,7 +109,7 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
|
||||
|
||||
@Override
|
||||
public void setSelection(Player p, Point minPoint, Point maxPoint) {
|
||||
WORLDEDIT_PLUGIN.getSession(p).setRegionSelector(BUKKITWORLD, new CuboidRegionSelector(BUKKITWORLD, toBlockVector3(minPoint), toBlockVector3(maxPoint)));
|
||||
WORLDEDIT_PLUGIN.getSession(p).setRegionSelector(BUKKITWORLD, new CuboidRegionSelector(BUKKITWORLD, minPoint.toBlockVector3(), maxPoint.toBlockVector3()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -178,9 +178,9 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
|
||||
pastePoint.set(v);
|
||||
|
||||
if (pasteBuilder.isReset()) {
|
||||
e.setBlocks(new CuboidRegion(toBlockVector3(pasteBuilder.getMinPoint()), toBlockVector3(pasteBuilder.getMaxPoint())), Objects.requireNonNull(BlockTypes.AIR).getDefaultState().toBaseBlock());
|
||||
e.setBlocks(new CuboidRegion(pasteBuilder.getMinPoint().toBlockVector3(), pasteBuilder.getMaxPoint().toBlockVector3()), Objects.requireNonNull(BlockTypes.AIR).getDefaultState().toBaseBlock());
|
||||
if (pasteBuilder.getWaterLevel() != 0) {
|
||||
e.setBlocks(new CuboidRegion(toBlockVector3(pasteBuilder.getMinPoint()), toBlockVector3(pasteBuilder.getMaxPoint()).withY(pasteBuilder.getWaterLevel())), Objects.requireNonNull(BlockTypes.WATER).getDefaultState().toBaseBlock());
|
||||
e.setBlocks(new CuboidRegion(pasteBuilder.getMinPoint().toBlockVector3(), pasteBuilder.getMaxPoint().toBlockVector3().withY(pasteBuilder.getWaterLevel())), Objects.requireNonNull(BlockTypes.WATER).getDefaultState().toBaseBlock());
|
||||
}
|
||||
}
|
||||
Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(pasteBuilder.isIgnoreAir()).build());
|
||||
@ -193,7 +193,7 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
|
||||
@Override
|
||||
public Clipboard copy(Point minPoint, Point maxPoint, Point copyPoint) {
|
||||
BukkitWorld bukkitWorld = new BukkitWorld(Bukkit.getWorlds().get(0));
|
||||
CuboidRegion region = new CuboidRegion(bukkitWorld, toBlockVector3(minPoint), toBlockVector3(maxPoint));
|
||||
CuboidRegion region = new CuboidRegion(bukkitWorld, minPoint.toBlockVector3(), maxPoint.toBlockVector3());
|
||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(region);
|
||||
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(bukkitWorld, -1)) {
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(
|
||||
@ -204,7 +204,7 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
|
||||
copy.setCopyingBiomes(false);
|
||||
|
||||
Operations.complete(copy);
|
||||
clipboard.setOrigin(toBlockVector3(copyPoint));
|
||||
clipboard.setOrigin(copyPoint.toBlockVector3());
|
||||
return clipboard;
|
||||
} catch (WorldEditException e) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e);
|
||||
@ -224,10 +224,6 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
private BlockVector3 toBlockVector3(Point point) {
|
||||
return BlockVector3.at(point.getX(), point.getY(), point.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inWater(org.bukkit.World world, Vector tntPosition) {
|
||||
Block block = world.getBlockAt(tntPosition.getBlockX(), tntPosition.getBlockY(), tntPosition.getBlockZ());
|
||||
|
||||
@ -0,0 +1,140 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import de.steamwar.bausystem.region.GlobalRegion;
|
||||
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
||||
import de.steamwar.bausystem.utils.tps.TPSFreezeUtils;
|
||||
import de.steamwar.bausystem.utils.tps.TPSLimitUtils;
|
||||
import de.steamwar.core.TPSWarpUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class TickManager15 implements TickManager, Listener {
|
||||
|
||||
private static float currentTPSLimit = 20;
|
||||
private boolean currentlyStepping = false;
|
||||
private float currentLimit;
|
||||
private int stepsTotal;
|
||||
private int stepsLeft;
|
||||
|
||||
@Override
|
||||
public boolean canFreeze() {
|
||||
return TPSFreezeUtils.isCanFreeze();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTickRate(float tickRate) {
|
||||
if (currentlyStepping) {
|
||||
currentlyStepping = false;
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
BossBarService.instance.remove(player, GlobalRegion.getInstance(), "TickStep");
|
||||
});
|
||||
}
|
||||
TPSWarpUtils.warp(tickRate);
|
||||
if (currentTPSLimit == 0 && tickRate != 0) {
|
||||
TPSFreezeUtils.unfreeze();
|
||||
}
|
||||
currentTPSLimit = tickRate;
|
||||
if (tickRate == 0) {
|
||||
TPSLimitUtils.unlimit();
|
||||
TPSFreezeUtils.freeze();
|
||||
} else if (tickRate < 20.0) {
|
||||
TPSLimitUtils.limit(tickRate);
|
||||
} else if (tickRate >= 20) {
|
||||
TPSLimitUtils.unlimit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFrozen() {
|
||||
return TPSFreezeUtils.frozen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFreeze(boolean freeze) {
|
||||
if (freeze) {
|
||||
setTickRate(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stepTicks(int ticks) {
|
||||
currentLimit = 0;
|
||||
setTickRate(20);
|
||||
stepsLeft = ticks;
|
||||
stepsTotal = ticks;
|
||||
currentlyStepping = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sprintTicks(int ticks) {
|
||||
currentLimit = currentTPSLimit;
|
||||
setTickRate(4000);
|
||||
stepsLeft = ticks;
|
||||
stepsTotal = ticks;
|
||||
currentlyStepping = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSprinting() {
|
||||
return currentlyStepping && currentTPSLimit > 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStepping() {
|
||||
return currentlyStepping && currentTPSLimit <= 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTickRate() {
|
||||
return currentTPSLimit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockTpsPacket(boolean block) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotalTicks() {
|
||||
return stepsTotal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDoneTicks() {
|
||||
return stepsTotal - stepsLeft;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRemainingTicks() {
|
||||
return stepsLeft;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTickEnd(TickEndEvent event) {
|
||||
if (!currentlyStepping) return;
|
||||
stepsLeft--;
|
||||
if (stepsLeft <= 0) {
|
||||
setTickRate(currentLimit);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,23 +1,23 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
* 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.tpslimit;
|
||||
package de.steamwar.bausystem.utils.tps;
|
||||
|
||||
import de.steamwar.Reflection;
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
@ -1,23 +1,23 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
* 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.tpslimit;
|
||||
package de.steamwar.bausystem.utils.tps;
|
||||
|
||||
import de.steamwar.Reflection;
|
||||
import lombok.Getter;
|
||||
@ -17,7 +17,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.tpslimit;
|
||||
package de.steamwar.bausystem.utils.tps;
|
||||
|
||||
import de.steamwar.Reflection;
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
@ -22,7 +22,6 @@ package de.steamwar.bausystem.utils;
|
||||
import com.destroystokyo.paper.event.server.ServerTickEndEvent;
|
||||
import com.destroystokyo.paper.event.server.ServerTickStartEvent;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.tpslimit.TPSFreezeUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -37,7 +36,7 @@ public class TickListener19 implements TickListener, Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onServerTickStart(ServerTickStartEvent event) {
|
||||
if (TPSFreezeUtils.isFrozen()) return;
|
||||
if (TickManager.impl.isFrozen()) return;
|
||||
Bukkit.getPluginManager().callEvent(new TickStartEvent());
|
||||
tickStartRan = true;
|
||||
}
|
||||
|
||||
@ -21,41 +21,39 @@ package de.steamwar.bausystem.utils;
|
||||
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.bausystem.features.util.NoClipCommand;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInSetCreativeSlot;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutExplosion;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutGameStateChange;
|
||||
import net.minecraft.server.level.EntityPlayer;
|
||||
import net.minecraft.server.level.PlayerInteractManager;
|
||||
import net.minecraft.world.entity.player.EntityHuman;
|
||||
import net.minecraft.world.entity.player.PlayerAbilities;
|
||||
import net.minecraft.world.item.component.CustomData;
|
||||
import net.minecraft.world.level.EnumGamemode;
|
||||
import io.papermc.paper.datacomponent.DataComponentTypes;
|
||||
import io.papermc.paper.datacomponent.item.ItemContainerContents;
|
||||
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundExplodePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundGameEventPacket;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||
import net.minecraft.world.entity.player.Abilities;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class NMSWrapper21 implements NMSWrapper {
|
||||
|
||||
private static final Reflection.Field<PlayerInteractManager> playerInteractManager = Reflection.getField(EntityPlayer.class, null, PlayerInteractManager.class);
|
||||
private static final Reflection.Field<ServerPlayerGameMode> playerInteractManager = Reflection.getField(ServerPlayer.class, null, ServerPlayerGameMode.class);
|
||||
|
||||
@Override
|
||||
public void setInternalGameMode(Player player, GameMode gameMode) {
|
||||
playerInteractManager.get(((CraftPlayer) player).getHandle()).a(EnumGamemode.a(gameMode.getValue()));
|
||||
playerInteractManager.get(((CraftPlayer) player).getHandle()).changeGameModeForPlayer(GameType.byId(gameMode.getValue()), PlayerGameModeChangeEvent.Cause.UNKNOWN, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSlotToItemStack(Player player, Object o) {
|
||||
PacketPlayInSetCreativeSlot packetPlayInSetCreativeSlot = (PacketPlayInSetCreativeSlot) o;
|
||||
int index = packetPlayInSetCreativeSlot.b();
|
||||
ClientboundContainerSetSlotPacket packetPlayInSetCreativeSlot = (ClientboundContainerSetSlotPacket) o;
|
||||
int index = packetPlayInSetCreativeSlot.getSlot();
|
||||
if (index >= 36 && index <= 44) {
|
||||
index -= 36;
|
||||
} else if (index > 44) {
|
||||
@ -63,25 +61,23 @@ public class NMSWrapper21 implements NMSWrapper {
|
||||
} else if (index <= 8) {
|
||||
index = index - 8 + 36;
|
||||
}
|
||||
player.getInventory().setItem(index, CraftItemStack.asBukkitCopy(packetPlayInSetCreativeSlot.e()));
|
||||
player.getInventory().setItem(index, CraftItemStack.asBukkitCopy(packetPlayInSetCreativeSlot.getItem()));
|
||||
if (index < 9) player.getInventory().setHeldItemSlot(index);
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
private static final Reflection.Field<PacketPlayOutGameStateChange.a> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, PacketPlayOutGameStateChange.a.class, 12);
|
||||
private static final Reflection.Field<ClientboundGameEventPacket.Type> gameStateChangeReason = Reflection.getField(NoClipCommand.gameStateChange, ClientboundGameEventPacket.Type.class, 12);
|
||||
|
||||
@Override
|
||||
public void setGameStateChangeReason(Object packet) {
|
||||
gameStateChangeReason.set(packet, PacketPlayOutGameStateChange.d);
|
||||
gameStateChangeReason.set(packet, ClientboundGameEventPacket.CHANGE_GAME_MODE);
|
||||
}
|
||||
|
||||
private static final Reflection.Field<PlayerAbilities> playerAbilities = Reflection.getField(EntityHuman.class, null, PlayerAbilities.class);
|
||||
|
||||
@Override
|
||||
public void setPlayerBuildAbilities(Player player) {
|
||||
PlayerAbilities abilities = playerAbilities.get(((CraftPlayer) player).getHandle());
|
||||
abilities.d = true;
|
||||
abilities.e = true;
|
||||
Abilities abilities = (((CraftPlayer) player).getHandle()).getAbilities();
|
||||
abilities.mayBuild = true;
|
||||
abilities.mayfly = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -93,49 +89,45 @@ public class NMSWrapper21 implements NMSWrapper {
|
||||
|
||||
@Override
|
||||
public boolean checkItemStack(ItemStack item) {
|
||||
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
|
||||
NBTTagCompound tag = nmsItem.a(DataComponents.b, CustomData.a).c();
|
||||
if (tag.e("BlockEntityTag")) {
|
||||
NBTTagCompound blockTag = tag.p("BlockEntityTag");
|
||||
if (blockTag.e("Items")) {
|
||||
return drillDown(blockTag.c("Items", 10), 0, 0) > threshold;
|
||||
}
|
||||
ItemContainerContents data = item.getData(DataComponentTypes.CONTAINER);
|
||||
if (data == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
return drillDown(data.contents(), 0, 0) > threshold;
|
||||
}
|
||||
|
||||
private int drillDown(NBTTagList items, int layer, int start) {
|
||||
private int drillDown(List<ItemStack> items, int layer, int start) {
|
||||
if (layer > 2) return start + threshold;
|
||||
int invalid = start;
|
||||
for (NBTBase nbtBase : items) {
|
||||
if (!(nbtBase instanceof NBTTagCompound slot))
|
||||
for (int i = start; i < items.size(); i++) {
|
||||
ItemStack item = items.get(i);
|
||||
if (item.isEmpty()) continue;
|
||||
|
||||
invalid += item.getAmount();
|
||||
|
||||
ItemContainerContents data = item.getData(DataComponentTypes.CONTAINER);
|
||||
if (data == null) {
|
||||
continue;
|
||||
if (slot.e("tag")) {
|
||||
invalid += slot.f("Count");
|
||||
NBTTagCompound iTag = slot.p("tag");
|
||||
if (iTag.e("BlockEntityTag")) {
|
||||
NBTTagCompound blockTag = iTag.p("BlockEntityTag");
|
||||
if (blockTag.e("Items")) {
|
||||
invalid = drillDown(blockTag.c("Items", 10), layer + 1, invalid);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (invalid > threshold)
|
||||
break;
|
||||
|
||||
List<ItemStack> subItems = data.contents();
|
||||
if (subItems.size() > 1) {
|
||||
invalid = drillDown(subItems, layer + 1, invalid);
|
||||
}
|
||||
}
|
||||
return invalid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resetExplosionKnockback(Object packet) {
|
||||
PacketPlayOutExplosion explosion = (PacketPlayOutExplosion) packet;
|
||||
ClientboundExplodePacket explosion = (ClientboundExplodePacket) packet;
|
||||
|
||||
return new PacketPlayOutExplosion(
|
||||
explosion.b(),
|
||||
return new ClientboundExplodePacket(
|
||||
explosion.center(),
|
||||
Optional.empty(),
|
||||
explosion.f(),
|
||||
explosion.g()
|
||||
explosion.explosionParticle(),
|
||||
explosion.explosionSound()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,150 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import net.minecraft.network.protocol.game.ClientboundTickingStatePacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.ServerTickRateManager;
|
||||
import net.minecraft.world.TickRateManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TickManager21 implements TickManager {
|
||||
private static final ServerTickRateManager manager = MinecraftServer.getServer().tickRateManager();
|
||||
private static final Reflection.Field<Integer> frozenTicksToRun = Reflection.getField(TickRateManager.class, int.class, 0);
|
||||
private static final Reflection.Field<Long> remainingSprintTicks = Reflection.getField(ServerTickRateManager.class, long.class, 0);
|
||||
|
||||
private boolean blockTpsPacket = true;
|
||||
private int totalSteps;
|
||||
|
||||
public TickManager21() {
|
||||
TinyProtocol.instance.addFilter(ClientboundTickingStatePacket.class, this::blockPacket);
|
||||
}
|
||||
|
||||
private Object blockPacket(Player player, Object packet) {
|
||||
if (blockTpsPacket) {
|
||||
return new ClientboundTickingStatePacket(20, manager.isFrozen());
|
||||
} else {
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFreeze() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockTpsPacket(boolean block) {
|
||||
blockTpsPacket = block;
|
||||
if (blockTpsPacket) {
|
||||
ClientboundTickingStatePacket packet = new ClientboundTickingStatePacket(20, manager.isFrozen());
|
||||
Bukkit.getOnlinePlayers().forEach(player -> TinyProtocol.instance.sendPacket(player, packet));
|
||||
} else {
|
||||
ClientboundTickingStatePacket packet = new ClientboundTickingStatePacket(manager.tickrate(), manager.isFrozen());
|
||||
Bukkit.getOnlinePlayers().forEach(player -> TinyProtocol.instance.sendPacket(player, packet));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTickRate(float tickRate) {
|
||||
if (isFrozen()) {
|
||||
setFreeze(false);
|
||||
}
|
||||
manager.setTickRate(tickRate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFrozen() {
|
||||
return manager.isFrozen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFreeze(boolean freeze) {
|
||||
manager.setFrozen(freeze);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stepTicks(int ticks) {
|
||||
if (manager.isSprinting()) {
|
||||
manager.stopSprinting();
|
||||
} else if (manager.isSteppingForward()) {
|
||||
manager.stopStepping();
|
||||
}
|
||||
this.totalSteps = ticks;
|
||||
manager.setFrozen(true);
|
||||
manager.stepGameIfPaused(ticks);
|
||||
manager.setFrozen(false);
|
||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), (bukkitTask) -> {
|
||||
if (manager.isSteppingForward()) return;
|
||||
manager.setFrozen(true);
|
||||
bukkitTask.cancel();
|
||||
}, 1, 1);
|
||||
manager.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sprintTicks(int ticks) {
|
||||
if (manager.isSteppingForward()) {
|
||||
manager.stopStepping();
|
||||
} else if (manager.isSprinting()) {
|
||||
manager.stopSprinting();
|
||||
}
|
||||
this.totalSteps = ticks;
|
||||
manager.requestGameToSprint(ticks, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSprinting() {
|
||||
return manager.isSprinting();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStepping() {
|
||||
return manager.isSteppingForward();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTickRate() {
|
||||
return manager.tickrate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRemainingTicks() {
|
||||
if (isSprinting()) {
|
||||
return remainingSprintTicks.get(manager);
|
||||
} else {
|
||||
return frozenTicksToRun.get(manager);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDoneTicks() {
|
||||
return totalSteps - getRemainingTicks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotalTicks() {
|
||||
return totalSteps;
|
||||
}
|
||||
}
|
||||
@ -25,7 +25,7 @@ PAGE_LIST=§e Page ({0}/{1}) »»
|
||||
LIST_PREVIOUS_PAGE=§ePrevious page
|
||||
LIST_NEXT_PAGE=§eNext page
|
||||
# Permissions
|
||||
NO_PERMISSION=You are not allowed to use that here
|
||||
NO_PERMISSION=§7You are not allowed to use that here
|
||||
SPECTATOR=§fSpectator
|
||||
# Scoreboard
|
||||
SCOREBOARD_TIME=Time
|
||||
@ -38,6 +38,7 @@ SCOREBOARD_TRACE_TICKS=Ticks
|
||||
SCOREBOARD_TECHHIDER=TechHider§8: §aOn
|
||||
SCOREBOARD_XRAY=XRay§8: §aOn
|
||||
SCOREBOARD_LOCK_TEAM=Bau Lock§8: §eTeam
|
||||
SCOREBOARD_LOCK_SUPERVISOR=Bau Lock§8: §eSupervisor
|
||||
SCOREBOARD_LOCK_TEAM_AND_SERVERTEAM=Bau Lock§8: §e(Server) Team
|
||||
SCOREBOARD_LOCK_SERVERTEAM=Bau Lock§8: §eServer Team
|
||||
SCOREBOARD_LOCK_NOBODY=Bau Lock§8: §cNobody
|
||||
@ -389,6 +390,12 @@ INVENTORY_FILL_HELP=§8/§einventoryfill §8- §7Toggles InventoryFill
|
||||
INVENTORY_FILL_INFO=§7Helps you fill containers by looking at them while sneaking and dropping the item. Or just scroll on a container to change the amount of the item inside.
|
||||
INVENTORY_FILL_ENABLE=§aInventoryFiller activated
|
||||
INVENTORY_FILL_DISABLE=§cInventoryFiller deactivated
|
||||
INVENTORY_FILL_GUI_NAME=Inventory Filler
|
||||
INVENTORY_FILL_GUI_POWER=§ePower§8:§7 {0}
|
||||
INVENTORY_FILL_GUI_TNT=§eTNT
|
||||
# Ray Visualizer
|
||||
RAY_VISUALIZER_ENABLE=§aRayVisualizer activated
|
||||
RAY_VISUALIZER_DISABLE=§aRayVisualizer deactivated
|
||||
# Killchecker
|
||||
KILLCHECKER_HELP_ENABLE=§8/§ekillchecker enable §8- §7Enables Killchecker / Recalculates kills
|
||||
KILLCHECKER_HELP_DISABLE=§8/§ekillchecker disable §8- §7Disables Killchecker
|
||||
@ -406,6 +413,8 @@ BLOCK_COUNTER_MESSAGE_SECOND=§7Damage §8> §e{0} §7Blocks §e{1} §7TNT §e
|
||||
BLOCK_COUNTER_ENABLE=§7BlockCounter activated
|
||||
BLOCK_COUNTER_DISABLE=§7BlockCounter deactivated
|
||||
# DepthCounter
|
||||
DEPTH_COUNTER_DISABLE=§7Depth Counter disabled
|
||||
DEPTH_COUNTER_ENABLE=§7Depth Counter enabled
|
||||
DEPTH_COUNTER_MESSAGE=§7Depth §8> §7
|
||||
DEPTH_COUNTER_COUNT={0}{1}§8×{2}{3}§8×{4}{5}
|
||||
DEPTH_COUNTER_HOVER=§7X§8×§7Y§8×§7Z
|
||||
@ -512,7 +521,7 @@ LOADER_HELP_GUI=§8/§7loader gui §8- §7Shows Loader gui
|
||||
LOADER_HELP_STOP=§8/§eloader stop §8- §7Stops recording/playback
|
||||
LOADER_HELP_WAIT=§8/§7loader wait §8[§7Ticks§8] - §7Sets wait time between shots
|
||||
LOADER_HELP_SPEED=§8/§7loader speed §8[§7Ticks§8] - §7Sets wait time between actions
|
||||
LOADER_NO_LOADER=§cYou have no Laoder. Create one with /loader setup
|
||||
LOADER_NO_LOADER=§cYou have no Loader. Create one with /loader setup
|
||||
LOADER_NEW=§7Load your cannon and fire it once, to initialise the loader.
|
||||
LOADER_HOW_TO_START=§7Then, execute /§eloader start§7 to start the Loader
|
||||
LOADER_ACTIVE=§7The Loader is now active.
|
||||
@ -844,7 +853,7 @@ LAUFBAU_SETTINGS_INACTIVE=§cInactive
|
||||
LAUFBAU_SETTINGS_MIXED=§e{0}§8/§e{1} §aActive
|
||||
LAUFBAU_SETTINGS_GUI_BACK=§eBack
|
||||
LAUFBAU_SETTINGS_TOGGLE=§eClick §8-§7 Toggle
|
||||
LAUFBAU_SETTINGS_ADVANCED=§eMiddle-Click §8-§7 Advanced settings
|
||||
LAUFBAU_SETTINGS_ADVANCED=§eLeft-Click §8-§7 Advanced settings
|
||||
LAUFBAU_BLOCK_COBWEB=§eCobweb
|
||||
LAUFBAU_BLOCK_GRASS_PATH=§eGrass Path
|
||||
LAUFBAU_BLOCK_SOUL_SAND=§eSoul Sand
|
||||
@ -945,6 +954,9 @@ SPEED_TAB_NAME=Input speed
|
||||
WORLDEDIT_WAND=WorldEdit Wand
|
||||
WORLDEDIT_LEFTCLICK=Left click: select pos #1
|
||||
WORLDEDIT_RIGHTCLICK=Right click: select pos #2
|
||||
TNT_DETAILS_COMMAND=§8/§etntdetails §8-§7 Toggle information printed after clicking on a TNT
|
||||
TNT_DETAILS_ON = §eTNTDetails §aactivated
|
||||
TNT_DETAILS_OFF = §eTNTDetails §cdeactivated
|
||||
TNT_CLICK_HEADER=§8---=== §eTNT §8===---
|
||||
TNT_CLICK_ORDER=§eEntity Order§8: §e{0}
|
||||
TNT_CLICK_FUSE_TIME=§eFuseTime§8: §e{0}
|
||||
|
||||
@ -25,7 +25,7 @@ PAGE_LIST=§e Seite ({0}/{1}) »»
|
||||
LIST_PREVIOUS_PAGE=§eVorherige Seite
|
||||
LIST_NEXT_PAGE=§eNächste Seite
|
||||
# Permission
|
||||
NO_PERMISSION=Du darfst dies hier nicht nutzen
|
||||
NO_PERMISSION=§7Du darfst dies hier nicht nutzen
|
||||
SPECTATOR=§fZuschauer
|
||||
# Scoreboard
|
||||
SCOREBOARD_TIME=Uhrzeit
|
||||
@ -350,8 +350,11 @@ SMART_PLACE_DISABLE=§cSmartPlace deaktiviert
|
||||
# InventoryFiller
|
||||
INVENTORY_FILL_HELP=§8/§einventoryfill §8- §7Toggled InventoryFill
|
||||
INVENTORY_FILL_INFO=§7Hilft dir, Behälter zu füllen, indem du sie beim sneaken ansiehst und den Gegenstand fallen lässt. Oder scrolle einfach auf einen Behälter, um die Menge des gehaltenen Gegenstandes darin zu ändern.
|
||||
INVENTORY_FILL_ENABLE=§aInventoryFiller activated
|
||||
INVENTORY_FILL_DISABLE=§cInventoryFiller deactivated
|
||||
INVENTORY_FILL_ENABLE=§aInventoryFiller aktiviert
|
||||
INVENTORY_FILL_DISABLE=§cInventoryFiller deaktiviert
|
||||
# Ray Visualizer
|
||||
RAY_VISUALIZER_ENABLE=§aRayVisualizer aktiviert
|
||||
RAY_VISUALIZER_DISABLE=§aRayVisualizer deaktiviert
|
||||
# Killchecker
|
||||
KILLCHECKER_HELP_ENABLE=§8/§ekillchecker enable §8- §7Aktiviert Killchecker / Berechnet kills neu
|
||||
KILLCHECKER_HELP_DISABLE=§8/§ekillchecker disable §8- §7Deaktiviert Killchecker
|
||||
@ -369,6 +372,8 @@ BLOCK_COUNTER_MESSAGE_SECOND=§7Schaden §8> §e{0} §7Blöcke §e{1} §7TNT
|
||||
BLOCK_COUNTER_ENABLE=§7BlockCounter angemacht
|
||||
BLOCK_COUNTER_DISABLE=§7BlockCounter ausgemacht
|
||||
# DepthCounter
|
||||
DEPTH_COUNTER_DISABLE=§7Depth Counter deaktiviert
|
||||
DEPTH_COUNTER_ENABLE=§7Depth Counter aktiviert
|
||||
DEPTH_COUNTER_MESSAGE=§7Tiefe §8> §7
|
||||
# TPSLimit
|
||||
TPSLIMIT_FREEZE_HELP=§8/§etpslimit 0 §8-§7 Friere TPS ein
|
||||
@ -790,7 +795,7 @@ LAUFBAU_SETTINGS_INACTIVE=§cInaktiv
|
||||
LAUFBAU_SETTINGS_MIXED=§e{0}§8/§e{1} §aAktiv
|
||||
LAUFBAU_SETTINGS_GUI_BACK=§eBack
|
||||
LAUFBAU_SETTINGS_TOGGLE=§eClick §8-§7 Toggle
|
||||
LAUFBAU_SETTINGS_ADVANCED=§eMiddle-Click §8-§7 Erweiterte Einstellung
|
||||
LAUFBAU_SETTINGS_ADVANCED=§eLinks-Click §8-§7 Erweiterte Einstellung
|
||||
LAUFBAU_BLOCK_COBWEB=§eCobweb
|
||||
LAUFBAU_BLOCK_GRASS_PATH=§eGrass Path
|
||||
LAUFBAU_BLOCK_SOUL_SAND=§eSoul Sand
|
||||
@ -887,6 +892,9 @@ SPEED_TAB_NAME=Geschwindigkeit eingeben
|
||||
WORLDEDIT_WAND=WorldEdit Wand
|
||||
WORLDEDIT_LEFTCLICK=Left click: select pos #1
|
||||
WORLDEDIT_RIGHTCLICK=Right click: select pos #2
|
||||
TNT_DETAILS_COMMAND=§8/§etntdetails §8-§7 Aktiviert/Deaktiviert das senden von Details beim Klick auf TNT
|
||||
TNT_DETAILS_ON = §eTNTDetails §aaktiviert
|
||||
TNT_DETAILS_OFF = §eTNTDetails §cdeaktiviert
|
||||
TNT_CLICK_HEADER=§8---=== §eTNT §8===---
|
||||
TNT_CLICK_ORDER=§eEntity Order§8: §e{0}
|
||||
TNT_CLICK_FUSE_TIME=§eFuseTime§8: §e{0}
|
||||
|
||||
@ -28,7 +28,6 @@ import de.steamwar.bausystem.features.script.lua.libs.LuaLib;
|
||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||
import de.steamwar.bausystem.features.slaves.panzern.Panzern;
|
||||
import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm;
|
||||
import de.steamwar.bausystem.features.tpslimit.TPSFreezeUtils;
|
||||
import de.steamwar.bausystem.features.tracer.TraceManager;
|
||||
import de.steamwar.bausystem.features.tracer.TraceRecorder;
|
||||
import de.steamwar.bausystem.features.world.BauScoreboard;
|
||||
@ -38,11 +37,13 @@ import de.steamwar.bausystem.region.loader.RegionLoader;
|
||||
import de.steamwar.bausystem.region.loader.Updater;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.bausystem.utils.TickListener;
|
||||
import de.steamwar.bausystem.utils.TickManager;
|
||||
import de.steamwar.bausystem.worlddata.WorldData;
|
||||
import de.steamwar.command.AbstractValidator;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.WorldEditRendererCUIEditor;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import de.steamwar.linkage.MaxVersion;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
@ -206,6 +207,8 @@ public class BauSystem extends JavaPlugin {
|
||||
|
||||
TraceManager.instance.init();
|
||||
TraceRecorder.instance.init();
|
||||
|
||||
new WorldEditRendererCUIEditor();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -263,7 +266,7 @@ public class BauSystem extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (TPSFreezeUtils.isFrozen()) return;
|
||||
if (TickManager.impl.isFrozen()) return;
|
||||
if (counter >= delay) {
|
||||
runnable.run();
|
||||
cancel();
|
||||
@ -281,7 +284,7 @@ public class BauSystem extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (TPSFreezeUtils.isFrozen()) return;
|
||||
if (TickManager.impl.isFrozen()) return;
|
||||
if (counter >= (first ? delay : period)) {
|
||||
first = false;
|
||||
runnable.run();
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
package de.steamwar.bausystem.features.cannon.depth;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.configplayer.Config;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
@ -65,7 +66,9 @@ public class Depth {
|
||||
dimensions.setZ(Math.abs(dimensions.getZ()));
|
||||
|
||||
RegionUtils.message(region, player -> {
|
||||
player.spigot().sendMessage(getMessage(player, dimensions.getBlockX() + 1, dimensions.getBlockY() + 1, dimensions.getBlockZ() + 1, tntCount));
|
||||
if (Config.getInstance().get(player).getPlainValueOrDefault("depth_message", true)) {
|
||||
player.spigot().sendMessage(getMessage(player, dimensions.getBlockX() + 1, dimensions.getBlockY() + 1, dimensions.getBlockZ() + 1, tntCount));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.cannon.depth;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.configplayer.Config;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
public class DepthCommand extends SWCommand {
|
||||
|
||||
public DepthCommand() {
|
||||
super("depth");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void toggle(Player player) {
|
||||
if (Config.getInstance().get(player).getPlainValueOrDefault("depth_message", true)) {
|
||||
Config.getInstance().get(player).put("depth_message", false);
|
||||
BauSystem.MESSAGE.send("DEPTH_COUNTER_DISABLE", player);
|
||||
} else {
|
||||
Config.getInstance().get(player).put("depth_message", true);
|
||||
BauSystem.MESSAGE.send("DEPTH_COUNTER_ENABLE", player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.gui.BauGUI;
|
||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||
import de.steamwar.core.TrickyTrialsWrapper;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
import de.steamwar.linkage.Linked;
|
||||
@ -74,7 +75,7 @@ public class BauGuiEditor implements Listener {
|
||||
inv.setItem(mapping.getSize() + 5, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_TRASH", p), Arrays.asList(BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_TRASH_LORE", p)), false, clickType -> {
|
||||
}).getItemStack());
|
||||
inv.setItem(mapping.getSize() + 6, new SWItem(TrickyTrialsWrapper.impl.getTurtleScute(), BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_MORE", p)).getItemStack());
|
||||
inv.setItem(mapping.getSize() + 8, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_CLOSE", p)).getItemStack());
|
||||
inv.setItem(mapping.getSize() + 8, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_CLOSE", p)).setCustomModelData(CMDs.BACK).getItemStack());
|
||||
|
||||
p.openInventory(inv);
|
||||
p.getOpenInventory().setCursor(cursor == null ? new SWItem().getItemStack() : cursor);
|
||||
|
||||
@ -4,12 +4,45 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.bausystem.configplayer.Config;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Barrel;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.block.ShulkerBox;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Linked
|
||||
public class InventoryFillerCommand extends SWCommand {
|
||||
|
||||
private static final Map<Integer, Integer> POWER_TO_FILLLEVEL = new HashMap<>();
|
||||
|
||||
static {
|
||||
POWER_TO_FILLLEVEL.put(0, 0);
|
||||
POWER_TO_FILLLEVEL.put(1, 1);
|
||||
POWER_TO_FILLLEVEL.put(2, 1 * 64 + 60);
|
||||
POWER_TO_FILLLEVEL.put(3, 3 * 64 + 55);
|
||||
POWER_TO_FILLLEVEL.put(4, 5 * 64 + 51);
|
||||
POWER_TO_FILLLEVEL.put(5, 7 * 64 + 46);
|
||||
POWER_TO_FILLLEVEL.put(6, 9 * 64 + 42);
|
||||
POWER_TO_FILLLEVEL.put(7, 11 * 64 + 37);
|
||||
POWER_TO_FILLLEVEL.put(8, 13 * 64 + 32);
|
||||
POWER_TO_FILLLEVEL.put(9, 15 * 64 + 28);
|
||||
POWER_TO_FILLLEVEL.put(10, 17 * 64 + 23);
|
||||
POWER_TO_FILLLEVEL.put(11, 19 * 64 + 19);
|
||||
POWER_TO_FILLLEVEL.put(12, 21 * 64 + 14);
|
||||
POWER_TO_FILLLEVEL.put(13, 23 * 64 + 10);
|
||||
POWER_TO_FILLLEVEL.put(14, 25 * 64 + 5);
|
||||
POWER_TO_FILLLEVEL.put(15, 27 * 64 + 0);
|
||||
}
|
||||
|
||||
public InventoryFillerCommand() {
|
||||
super("inventoryfill");
|
||||
}
|
||||
@ -21,8 +54,116 @@ public class InventoryFillerCommand extends SWCommand {
|
||||
if (!inventoryFill) {
|
||||
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("INVENTORY_FILL_ENABLE", player));
|
||||
BauSystem.MESSAGE.send("INVENTORY_FILL_INFO", player);
|
||||
}else {
|
||||
} else {
|
||||
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("INVENTORY_FILL_DISABLE", player));
|
||||
}
|
||||
}
|
||||
|
||||
@Register("gui")
|
||||
public void gui(Player player) {
|
||||
SWInventory inventory = new SWInventory(player, 18, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_NAME", player));
|
||||
inventory.setItem(0, new SWItem(Material.REDSTONE, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 0)).setAmount(1));
|
||||
inventory.setItem(1, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 1)).setAmount(1));
|
||||
inventory.setItem(2, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 2)).setAmount(2));
|
||||
inventory.setItem(3, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 3)).setAmount(3));
|
||||
inventory.setItem(4, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 4)).setAmount(4));
|
||||
inventory.setItem(5, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 5)).setAmount(5));
|
||||
inventory.setItem(6, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 6)).setAmount(6));
|
||||
inventory.setItem(7, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 7)).setAmount(7));
|
||||
inventory.setItem(8, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 8)).setAmount(8));
|
||||
inventory.setItem(9, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 9)).setAmount(9));
|
||||
inventory.setItem(10, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 10)).setAmount(10));
|
||||
inventory.setItem(11, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 11)).setAmount(11));
|
||||
inventory.setItem(12, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 12)).setAmount(12));
|
||||
inventory.setItem(13, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 13)).setAmount(13));
|
||||
inventory.setItem(14, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 14)).setAmount(14));
|
||||
inventory.setItem(15, new SWItem(Material.REDSTONE_TORCH, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_POWER", player, 15)).setAmount(15));
|
||||
inventory.setItem(17, new SWItem(Material.TNT, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_TNT", player)));
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
inventory.setEventCallback(i, inventoryClickEvent -> {
|
||||
selectInventoryType(player, inventoryClickEvent.getCurrentItem().getItemMeta().getDisplayName(), Material.DANDELION, POWER_TO_FILLLEVEL.get(inventoryClickEvent.getCurrentItem().getAmount()));
|
||||
});
|
||||
}
|
||||
inventory.setEventCallback(17, inventoryClickEvent -> {
|
||||
selectInventoryType(player, inventoryClickEvent.getCurrentItem().getItemMeta().getDisplayName(), Material.TNT, POWER_TO_FILLLEVEL.get(15));
|
||||
});
|
||||
|
||||
inventory.open();
|
||||
}
|
||||
|
||||
private final Material[] SHULKER_BOX_MATERIALS = new Material[]{
|
||||
Material.SHULKER_BOX,
|
||||
Material.WHITE_SHULKER_BOX,
|
||||
Material.LIGHT_GRAY_SHULKER_BOX,
|
||||
Material.GRAY_SHULKER_BOX,
|
||||
Material.BLACK_SHULKER_BOX,
|
||||
Material.BROWN_SHULKER_BOX,
|
||||
Material.RED_SHULKER_BOX,
|
||||
Material.ORANGE_SHULKER_BOX,
|
||||
Material.YELLOW_SHULKER_BOX,
|
||||
Material.LIME_SHULKER_BOX,
|
||||
Material.GREEN_SHULKER_BOX,
|
||||
Material.CYAN_SHULKER_BOX,
|
||||
Material.LIGHT_BLUE_SHULKER_BOX,
|
||||
Material.BLUE_SHULKER_BOX,
|
||||
Material.PURPLE_SHULKER_BOX,
|
||||
Material.MAGENTA_SHULKER_BOX,
|
||||
Material.PINK_SHULKER_BOX
|
||||
};
|
||||
|
||||
private void selectInventoryType(Player player, String name, Material material, int count) {
|
||||
ItemStack[] itemStacks = new ItemStack[27];
|
||||
int index = 0;
|
||||
int amount = count;
|
||||
while (amount > 0) {
|
||||
ItemStack stack;
|
||||
if (amount > 64) {
|
||||
stack = new ItemStack(material, 64);
|
||||
amount -= 64;
|
||||
} else {
|
||||
stack = new ItemStack(material, amount);
|
||||
amount = 0;
|
||||
}
|
||||
itemStacks[index++] = stack;
|
||||
}
|
||||
|
||||
SWInventory inventory = new SWInventory(player, 27, BauSystem.MESSAGE.parse("INVENTORY_FILL_GUI_NAME", player));
|
||||
int i = 0;
|
||||
for (Material type : SHULKER_BOX_MATERIALS) {
|
||||
inventory.setItemEvent(i++, generateFilledInventory(name, type, itemStacks), inventoryClickEvent -> {
|
||||
SWUtils.giveItemToPlayer(player, inventoryClickEvent.getCurrentItem());
|
||||
});
|
||||
}
|
||||
inventory.setItemEvent(27 - 6, generateFilledInventory(name, Material.CHEST, itemStacks), inventoryClickEvent -> {
|
||||
SWUtils.giveItemToPlayer(player, inventoryClickEvent.getCurrentItem());
|
||||
});
|
||||
inventory.setItemEvent(27 - 4, generateFilledInventory(name, Material.BARREL, itemStacks), inventoryClickEvent -> {
|
||||
SWUtils.giveItemToPlayer(player, inventoryClickEvent.getCurrentItem());
|
||||
});
|
||||
inventory.open();
|
||||
}
|
||||
|
||||
private ItemStack generateFilledInventory(String name, Material material, ItemStack[] itemStacks) {
|
||||
ItemStack itemStack = new ItemStack(material);
|
||||
BlockStateMeta meta = (BlockStateMeta) itemStack.getItemMeta();
|
||||
BlockState state = meta.getBlockState();
|
||||
|
||||
if (state instanceof ShulkerBox box) {
|
||||
box.getInventory().setContents(itemStacks);
|
||||
box.update();
|
||||
meta.setBlockState(box);
|
||||
} else if (state instanceof Chest chest) {
|
||||
chest.getInventory().setContents(itemStacks);
|
||||
chest.update();
|
||||
meta.setBlockState(chest);
|
||||
} else if (state instanceof Barrel barrel) {
|
||||
barrel.getInventory().setContents(itemStacks);
|
||||
barrel.update();
|
||||
meta.setBlockState(barrel);
|
||||
}
|
||||
meta.setDisplayName(name);
|
||||
itemStack.setItemMeta(meta);
|
||||
return itemStack;
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ public class Loader implements Listener {
|
||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance());
|
||||
|
||||
BauSystem.runTaskTimer(BauSystem.getInstance(), () -> {
|
||||
if (stage != Stage.RUNNING) return;
|
||||
if (stage != Stage.RUNNING && stage != Stage.SINGLE) return;
|
||||
if(!Permission.BUILD.hasPermission(p)) return;
|
||||
if (waitTime > 0) {
|
||||
waitTime--;
|
||||
@ -149,13 +149,16 @@ public class Loader implements Listener {
|
||||
}
|
||||
|
||||
public boolean setTicksBetweenShots(int delay) {
|
||||
if (elements.size() == 0) return false;
|
||||
if (elements.isEmpty()) return false;
|
||||
LoaderElement loaderElement = elements.get(elements.size() - 1);
|
||||
if (loaderElement instanceof LoaderWait) {
|
||||
((LoaderWait) loaderElement).setDelay(delay);
|
||||
return true;
|
||||
} else {
|
||||
LoaderWait loaderWait = new LoaderWait(delay);
|
||||
elements.add(loaderWait);
|
||||
pause();
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setTicksBetweenBlocks(int delay) {
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
package de.steamwar.bausystem.features.loader.elements;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
@ -113,7 +114,7 @@ public abstract class LoaderInteractionElement<T extends Enum<T> & LoaderSetting
|
||||
});
|
||||
listInv.setItem(48, new SWItem(Material.ARROW, "§7Back", clickType -> {
|
||||
backAction.run();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
listInv.setItem(50, new SWItem(Material.GHAST_SPAWN_EGG, "§7Insert another Setting", clickType -> {
|
||||
elements.add(defaultSetting);
|
||||
extraPower.add(0);
|
||||
@ -150,7 +151,7 @@ public abstract class LoaderInteractionElement<T extends Enum<T> & LoaderSetting
|
||||
|
||||
SWInventory swInventory = new SWInventory(player, guiSize, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_TITLE", player));
|
||||
for (int i = guiSize - 9; i < guiSize; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", clickType -> {}));
|
||||
swInventory.setItem(guiSize - 9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).getItemStack(), clickType -> back.run());
|
||||
swInventory.setItem(guiSize - 9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_BACK", player)).setCustomModelData(CMDs.BACK).getItemStack(), clickType -> back.run());
|
||||
swInventory.setItem(guiSize - 5, new SWItem(Material.WOODEN_AXE, BauSystem.MESSAGE.parse("LOADER_GUI_SETTINGS_COPY", player)).getItemStack(), clickType -> {
|
||||
SWAnvilInv swAnvilInv = new SWAnvilInv(player, BauSystem.MESSAGE.parse("LOADER_GUI_COPY_TITLE", player), "1");
|
||||
swAnvilInv.setCallback(s -> {
|
||||
|
||||
@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.loader.elements.impl;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.loader.elements.LoaderElement;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
@ -60,7 +61,7 @@ public class LoaderWait implements LoaderElement {
|
||||
public void click(Player player, Runnable backAction) {
|
||||
SWInventory swInventory = new SWInventory(player, 18, BauSystem.MESSAGE.parse("LOADER_GUI_WAIT_TITLE", player));
|
||||
for (int i = 9; i < 18; i++) swInventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7"));
|
||||
swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_WAIT_BACK", player)).getItemStack(), clickType -> backAction.run());
|
||||
swInventory.setItem(9, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LOADER_GUI_WAIT_BACK", player)).setCustomModelData(CMDs.BACK).getItemStack(), clickType -> backAction.run());
|
||||
|
||||
swInventory.setItem(3, new SWItem(SWItem.getDye(1), BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE", player), Arrays.asList(BauSystem.MESSAGE.parse("LOADER_SETTING_TICKS_REMOVE_ONE_SHIFT", player)), false, clickType -> {}).getItemStack(), clickType -> {
|
||||
delay -= clickType.isShiftClick() ? 5 : 1;
|
||||
|
||||
@ -0,0 +1,198 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.rayvisualizer;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.bausystem.configplayer.Config;
|
||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.entity.CRay;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Linked
|
||||
@MinVersion(20)
|
||||
public class RayVisualizerCommand extends SWCommand implements Listener {
|
||||
|
||||
private class CRayData {
|
||||
private CRay[] rays = new CRay[27 * 400];
|
||||
private boolean[] used = new boolean[27 * 400];
|
||||
|
||||
public void reset() {
|
||||
for (int i = 0; i < 27 * 400; i++) {
|
||||
if (!used[i] && rays[i] != null) {
|
||||
rays[i].die();
|
||||
rays[i] = null;
|
||||
}
|
||||
used[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean locEquals(Location loc1, Location loc2) {
|
||||
if ((long)(loc1.getX() * 1000) != (long)(loc2.getX() * 1000)) return false;
|
||||
if ((long)(loc1.getY() * 1000) != (long)(loc2.getY() * 1000)) return false;
|
||||
if ((long)(loc1.getZ() * 1000) != (long)(loc2.getZ() * 1000)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public CRay get(Location from, Location to) {
|
||||
for (int i = 0; i < rays.length; i++) {
|
||||
if (rays[i] != null && locEquals(from, rays[i].getFrom()) && locEquals(to, rays[i].getTo())) {
|
||||
used[i] = true;
|
||||
return rays[i];
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < rays.length; i++) {
|
||||
if (rays[i] != null && locEquals(from, rays[i].getFrom()) && !used[i]) {
|
||||
used[i] = true;
|
||||
return rays[i];
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < rays.length; i++) {
|
||||
if (used[i]) continue;
|
||||
CRay ray = rays[i];
|
||||
if (ray != null) {
|
||||
return ray;
|
||||
}
|
||||
ray = new CRay(server);
|
||||
ray.setBlock(Material.LIME_CONCRETE.createBlockData());
|
||||
ray.setWidth(1 / 32f);
|
||||
rays[i] = ray;
|
||||
used[i] = true;
|
||||
return ray;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private CRayData rayData = new CRayData();
|
||||
|
||||
private final REntityServer server = new REntityServer();
|
||||
private final World WORLD = Bukkit.getWorlds().get(0);
|
||||
|
||||
public RayVisualizerCommand() {
|
||||
super("rayvisualizer");
|
||||
|
||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
|
||||
if (server.getPlayers().isEmpty()) return;
|
||||
Map<Integer, List<TNTPrimed>> primedList = WORLD.getEntitiesByClass(TNTPrimed.class)
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(TNTPrimed::getFuseTicks));
|
||||
rayData.reset();
|
||||
if (primedList.isEmpty()) return;
|
||||
|
||||
List<Integer> fuseTicks = primedList.keySet().stream().sorted().collect(Collectors.toList());
|
||||
List<TNTPrimed> current = new ArrayList<>();
|
||||
for (int i = 0; i < fuseTicks.size(); i++) {
|
||||
List<TNTPrimed> tnts = primedList.get(fuseTicks.get(i));
|
||||
calculateRays(current, tnts);
|
||||
current.addAll(tnts);
|
||||
}
|
||||
}, 1, 1);
|
||||
}
|
||||
|
||||
private void calculateRays(List<TNTPrimed> fromTNTs, List<TNTPrimed> toTNTs) {
|
||||
for (TNTPrimed from : fromTNTs) {
|
||||
if (!from.isInWater()) continue;
|
||||
for (TNTPrimed to : toTNTs) {
|
||||
if (from == to) continue;
|
||||
if (to.getLocation().distanceSquared(from.getLocation()) > 25) continue;
|
||||
|
||||
Location fromLoc = from.getLocation();
|
||||
Location toLoc = to.getLocation().clone().add(-0.49, 0, -0.49);
|
||||
|
||||
final double minX = 0.5 * (1 - Math.floor(2 * 0.98 + 1) / (2 * 0.98 + 1));
|
||||
final double minZ = 0.5 * (1 - Math.floor(2 * 0.98 + 1) / (2 * 0.98 + 1));
|
||||
final double spacing = 0.98 / (2 * 0.98 + 1);
|
||||
|
||||
for (int dx = 0; dx < 3; dx++) {
|
||||
for (int dy = 0; dy < 3; dy++) {
|
||||
for (int dz = 0; dz < 3; dz++) {
|
||||
Location end = toLoc.clone().add(minX + dx * spacing, 0 + dy * spacing, minZ + dz * spacing);
|
||||
RayTraceResult result = fromLoc.getWorld().rayTraceBlocks(fromLoc, end.clone().subtract(fromLoc).toVector(), end.distance(fromLoc), FluidCollisionMode.NEVER, true);
|
||||
if (result != null && result.getHitBlock() != null) {
|
||||
continue;
|
||||
}
|
||||
CRay cRay = rayData.get(fromLoc, end);
|
||||
if (cRay == null) continue;
|
||||
cRay.setFrom(fromLoc);
|
||||
cRay.setTo(end);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||
boolean rayvisualizer = Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("rayvisualizer", false);
|
||||
if (rayvisualizer) server.addPlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
server.removePlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBauMemberUpdate(BauMemberUpdateEvent event) {
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (Permission.BUILD.hasPermission(player)) {
|
||||
boolean rayvisualizer = Config.getInstance().get(player).getPlainValueOrDefault("rayvisualizer", false);
|
||||
if (rayvisualizer) server.addPlayer(player);
|
||||
} else {
|
||||
server.removePlayer(player);
|
||||
}
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void toggle(@Validator Player player) {
|
||||
boolean rayvisualizer = Config.getInstance().get(player).getPlainValueOrDefault("rayvisualizer", false);
|
||||
Config.getInstance().get(player).put("rayvisualizer", !rayvisualizer);
|
||||
if (!rayvisualizer) {
|
||||
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("RAY_VISUALIZER_ENABLE", player));
|
||||
server.addPlayer(player);
|
||||
} else {
|
||||
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("RAY_VISUALIZER_DISABLE", player));
|
||||
server.removePlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -34,8 +34,6 @@ import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Linked
|
||||
public class ColorCommand extends SWCommand {
|
||||
|
||||
@ -47,7 +45,7 @@ public class ColorCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register(description = "REGION_COLOR_HELP_COLOR")
|
||||
public void genericColor(Player p, ColorMode color) {
|
||||
public void genericColor(@Validator Player p, ColorMode color) {
|
||||
genericColorSet(p, color, ColorizationType.LOCAL);
|
||||
}
|
||||
|
||||
@ -78,7 +76,7 @@ public class ColorCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericColorSet(Player p, ColorizationType colorizationType, ColorMode color) {
|
||||
public void genericColorSet(@Validator Player p, ColorizationType colorizationType, ColorMode color) {
|
||||
genericColorSet(p, color, colorizationType);
|
||||
}
|
||||
|
||||
|
||||
@ -11,8 +11,9 @@ import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.type.NoteBlock;
|
||||
import org.bukkit.block.data.type.Switch;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -60,6 +61,24 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
||||
@EventHandler
|
||||
public void onPhysicsEvent(BlockPhysicsEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
if (e.getSourceBlock().getType() == Material.NOTE_BLOCK) {
|
||||
BlockState state = e.getSourceBlock().getState();
|
||||
NoteBlock noteBlock = (NoteBlock) state.getBlockData();
|
||||
if (noteBlock.isPowered()) {
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
state.update(true, false);
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
if (e.getBlock().getType() == Material.NOTE_BLOCK) {
|
||||
BlockState state = e.getBlock().getState();
|
||||
NoteBlock noteBlock = (NoteBlock) state.getBlockData();
|
||||
if (noteBlock.isPowered()) {
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
state.update(true, false);
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -71,6 +90,105 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onNotePlay(NotePlayEvent event) {
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=45, z=98},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=44, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=97},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=99},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=custom_head,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=97},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=96},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=99},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-108, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=45, z=98},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-104, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=45, z=98},type=CYAN_TERRACOTTA,data=Block{minecraft:cyan_terracotta},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=BARRIER,data=Block{minecraft:barrier},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=harp,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@78078831}
|
||||
|
||||
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=45, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=46, z=100},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=49, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=99},type=SMOOTH_STONE,data=Block{minecraft:smooth_stone},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
////[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=true],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=102},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-108, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-107, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=100},type=STONE_SLAB,data=Block{minecraft:stone_slab}[type=bottom,waterlogged=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-104, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=46, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=48, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-105, y=47, z=100},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=101},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-107, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-105, y=47, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=46, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=48, z=98},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=97},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=99},type=AIR,data=Block{minecraft:air},fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
//[STDOUT] CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b} -> CraftBlock{pos=BlockPosition{x=-106, y=47, z=98},type=NOTE_BLOCK,data=Block{minecraft:note_block}[instrument=basedrum,note=9,powered=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@1531ed7b}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onPistonRetract(BlockPistonRetractEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
@ -108,13 +226,13 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent e) {
|
||||
if (Core.getVersion() < 19) return;
|
||||
if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return;
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
if (e.isCancelled()) return;
|
||||
e.setCancelled(true);
|
||||
e.getBlock().setType(Material.BARRIER, false);
|
||||
e.getBlock().setType(Material.AIR, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,6 +166,8 @@ public class SteamWarLuaPlugin extends TwoArgFunction {
|
||||
env.set("rawlen", NIL);
|
||||
env.set("rawset", NIL);
|
||||
env.set("xpcall", NIL);
|
||||
env.set("require", NIL);
|
||||
env.set("package", NIL);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
package de.steamwar.bausystem.features.script.lua.libs;
|
||||
|
||||
import de.steamwar.bausystem.features.tpslimit.TPSSystem;
|
||||
import de.steamwar.bausystem.utils.TickManager;
|
||||
import de.steamwar.core.TPSWatcher;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
@ -51,7 +52,7 @@ public class TpsLib implements LuaLib {
|
||||
tpsLib.set("fiveMinute", getter(() -> TPSWatcher.getTPS(TPSWatcher.TPSType.FIVE_MINUTES)));
|
||||
tpsLib.set("tenMinute", getter(() -> TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES)));
|
||||
tpsLib.set("current", getter(TPSWatcher::getTPS));
|
||||
tpsLib.set("limit", getter(tpsSystem::getCurrentTPSLimit));
|
||||
tpsLib.set("limit", getter(() -> (double) TickManager.impl.getTickRate()));
|
||||
return tpsLib;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.script.lua.libs;
|
||||
|
||||
import de.steamwar.bausystem.features.tracer.TNTPoint;
|
||||
import de.steamwar.bausystem.features.tracer.Trace;
|
||||
import de.steamwar.bausystem.features.tracer.TraceManager;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.luaj.vm2.LuaTable;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
import org.luaj.vm2.lib.ZeroArgFunction;
|
||||
|
||||
@Linked
|
||||
public class TracerLib implements LuaLib {
|
||||
@Override
|
||||
public String name() {
|
||||
return "tracer";
|
||||
}
|
||||
|
||||
private static LuaTable convertTrace(Trace trace) {
|
||||
LuaTable luaTrace = new LuaTable();
|
||||
|
||||
luaTrace.set("getRecords", new ZeroArgFunction() {
|
||||
@Override
|
||||
public LuaValue call() {
|
||||
return LuaValue.listOf(
|
||||
trace.getHistories()
|
||||
.stream()
|
||||
.map((history) -> LuaValue.listOf(history
|
||||
.stream()
|
||||
.map(TracerLib::convertTntPoint)
|
||||
.toArray(LuaValue[]::new)))
|
||||
.toArray(LuaValue[]::new));
|
||||
}
|
||||
});
|
||||
|
||||
luaTrace.set("getId", new ZeroArgFunction() {
|
||||
@Override
|
||||
public LuaValue call() {
|
||||
return LuaValue.valueOf(trace.getUuid().toString());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return luaTrace;
|
||||
}
|
||||
|
||||
private static LuaTable convertTntPoint(TNTPoint tntPoint) {
|
||||
Location pointPos = tntPoint.getLocation();
|
||||
LuaTable luaPos = LuaValue.tableOf(new LuaValue[]{
|
||||
LuaValue.valueOf("x"), LuaValue.valueOf(pointPos.getX()),
|
||||
LuaValue.valueOf("y"), LuaValue.valueOf(pointPos.getY()),
|
||||
LuaValue.valueOf("z"), LuaValue.valueOf(pointPos.getZ()),
|
||||
});
|
||||
|
||||
Vector pointVel = tntPoint.getVelocity();
|
||||
LuaTable luaVel = LuaValue.tableOf(new LuaValue[]{
|
||||
LuaValue.valueOf("x"), LuaValue.valueOf(pointVel.getX()),
|
||||
LuaValue.valueOf("y"), LuaValue.valueOf(pointVel.getY()),
|
||||
LuaValue.valueOf("z"), LuaValue.valueOf(pointVel.getZ()),
|
||||
});
|
||||
|
||||
return LuaValue.tableOf(new LuaValue[]{
|
||||
LuaValue.valueOf("pos"), luaPos,
|
||||
LuaValue.valueOf("vel"), luaVel,
|
||||
LuaValue.valueOf("ticksSinceStart"), LuaValue.valueOf(tntPoint.getTicksSinceStart()),
|
||||
LuaValue.valueOf("fuse"), LuaValue.valueOf(tntPoint.getFuse()),
|
||||
LuaValue.valueOf("isExplosion"), LuaValue.valueOf(tntPoint.isExplosion()),
|
||||
LuaValue.valueOf("isInWater"), LuaValue.valueOf(tntPoint.isInWater()),
|
||||
LuaValue.valueOf("hasDestroyedBuild"), LuaValue.valueOf(tntPoint.isDestroyedBuildArea()),
|
||||
LuaValue.valueOf("hasDestroyedTestblock"), LuaValue.valueOf(tntPoint.isDestroyedTestBlock())
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public LuaTable get(Player player) {
|
||||
LuaTable rootTable = LuaValue.tableOf();
|
||||
|
||||
rootTable.set("getTraces", new ZeroArgFunction() {
|
||||
@Override
|
||||
public LuaValue call() {
|
||||
return LuaValue.listOf(TraceManager.instance.getAll()
|
||||
.stream()
|
||||
.map(TracerLib::convertTrace)
|
||||
.toArray(LuaValue[]::new));
|
||||
}
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
return rootTable;
|
||||
}
|
||||
}
|
||||
@ -160,6 +160,11 @@ public class ShieldPrinting implements Listener {
|
||||
|
||||
private void paste(Map<Material, BlockDataConfiguration<?>[]> stateConfiguration) {
|
||||
for (Map.Entry<Vector, BlockData> entry : shieldData.entrySet()) {
|
||||
BlockData copied = entry.getValue();
|
||||
if (copied.getMaterial().isAir()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Block block = entry.getKey().toLocation(WORLD).getBlock();
|
||||
if (entry.getValue().getMaterial() != block.getType()) {
|
||||
block.setBlockData(entry.getValue(), false);
|
||||
@ -171,12 +176,11 @@ public class ShieldPrinting implements Listener {
|
||||
|
||||
BlockDataConfiguration[] stateConfigurations = stateConfiguration.get(entry.getValue().getMaterial());
|
||||
if (stateConfigurations == null) {
|
||||
block.setBlockData(entry.getValue(), false);
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockData worldOriginal = block.getBlockData();
|
||||
BlockData copied = entry.getValue().clone();
|
||||
copied = copied.clone();
|
||||
for (BlockDataConfiguration blockDataConfiguration : stateConfigurations) {
|
||||
if (blockDataConfiguration == null) continue;
|
||||
blockDataConfiguration.apply(copied, worldOriginal);
|
||||
|
||||
@ -1,20 +1,18 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU Affero 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 Affero General Public License for more details.
|
||||
* 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
|
||||
* Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator;
|
||||
@ -22,6 +20,7 @@ package de.steamwar.bausystem.features.simulator;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.display.SimulatorCursor;
|
||||
import de.steamwar.bausystem.features.simulator.execute.SimulatorExecutor;
|
||||
import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommand;
|
||||
@ -49,12 +48,12 @@ public class SimulatorCommand extends SWCommand {
|
||||
@Register(description = "SIMULATOR_HELP")
|
||||
public void genericCommand(@Validator Player p) {
|
||||
SWUtils.giveItemToPlayer(p, SimulatorStorage.getWand(p));
|
||||
simulatorCursor.calcCursor(p);
|
||||
// TODO simulatorCursor.calcCursor(p);
|
||||
}
|
||||
|
||||
@Register(value = "change", description = "SIMULATOR_CHANGE_HELP")
|
||||
public void change(@Validator Player p) {
|
||||
if (!SimulatorCursor.isSimulatorItem(p.getInventory().getItemInMainHand()) && !SimulatorCursor.isSimulatorItem(p.getInventory().getItemInOffHand())) {
|
||||
if (!SimulatorUtils.isSimulatorItem(p.getInventory().getItemInMainHand()) && !SimulatorUtils.isSimulatorItem(p.getInventory().getItemInOffHand())) {
|
||||
BauSystem.MESSAGE.send("SIMULATOR_NO_SIM_IN_HAND", p);
|
||||
return;
|
||||
}
|
||||
@ -76,7 +75,7 @@ public class SimulatorCommand extends SWCommand {
|
||||
|
||||
@Register(value = "start", description = "SIMULATOR_START_HELP")
|
||||
public void start(@Validator Player p, @ErrorMessage("SIMULATOR_NOT_EXISTS") Simulator simulator) {
|
||||
SimulatorExecutor.run(simulator);
|
||||
SimulatorExecutor.run(p, simulator, null);
|
||||
}
|
||||
|
||||
@Register(value = "rename", description = "SIMULATOR_RENAME_HELP")
|
||||
|
||||
@ -1,457 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator;
|
||||
|
||||
import de.steamwar.Reflection;
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.features.simulator.data.observer.ObserverElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.observer.ObserverPhase;
|
||||
import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.redstone.RedstonePhase;
|
||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
|
||||
import de.steamwar.bausystem.features.simulator.execute.SimulatorExecutor;
|
||||
import de.steamwar.bausystem.features.simulator.gui.SimulatorGroupGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.SimulatorGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||
import de.steamwar.bausystem.utils.ItemUtils;
|
||||
import de.steamwar.bausystem.utils.RayTraceUtils;
|
||||
import de.steamwar.entity.REntity;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.entity.RFallingBlockEntity;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Linked
|
||||
@MinVersion(19)
|
||||
public class SimulatorCursor implements Listener {
|
||||
|
||||
private final World WORLD = Bukkit.getWorlds().get(0);
|
||||
private Class<?> position = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Pos");
|
||||
private Class<?> look = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Rot");
|
||||
private Class<?> positionLook = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$PosRot");
|
||||
|
||||
private Map<Player, CursorType> cursorType = Collections.synchronizedMap(new HashMap<>());
|
||||
private Map<Player, REntityServer> cursors = Collections.synchronizedMap(new HashMap<>());
|
||||
private final Set<Player> calculating = new HashSet<>();
|
||||
|
||||
public static boolean isSimulatorItem(ItemStack itemStack) {
|
||||
return ItemUtils.isItem(itemStack, "simulator");
|
||||
}
|
||||
|
||||
public SimulatorCursor() {
|
||||
BiFunction<Player, Object, Object> function = (player, object) -> {
|
||||
calcCursor(player);
|
||||
return object;
|
||||
};
|
||||
TinyProtocol.instance.addFilter(position, function);
|
||||
TinyProtocol.instance.addFilter(look, function);
|
||||
TinyProtocol.instance.addFilter(positionLook, function);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
calcCursor(event.getPlayer());
|
||||
}, 0);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||
calcCursor(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerItemHeld(PlayerItemHeldEvent event) {
|
||||
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
calcCursor(event.getPlayer());
|
||||
}, 1);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBauMemberUpdate(BauMemberUpdateEvent event) {
|
||||
event.getChanged().forEach(this::calcCursor);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
cursorType.remove(event.getPlayer());
|
||||
cursors.remove(event.getPlayer());
|
||||
synchronized (calculating) {
|
||||
calculating.remove(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
private static final Map<Player, Long> LAST_SNEAKS = new HashMap<>();
|
||||
|
||||
static {
|
||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
|
||||
long millis = System.currentTimeMillis();
|
||||
LAST_SNEAKS.entrySet().removeIf(entry -> millis - entry.getValue() > 200);
|
||||
}, 1, 1);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerToggleSneak(PlayerToggleSneakEvent event) {
|
||||
if (!event.isSneaking()) return;
|
||||
Player player = event.getPlayer();
|
||||
if (!isSimulatorItem(player.getInventory().getItemInMainHand()) && !isSimulatorItem(player.getInventory().getItemInOffHand())) {
|
||||
return;
|
||||
}
|
||||
if (LAST_SNEAKS.containsKey(player)) {
|
||||
cursorType.put(player, cursorType.getOrDefault(player, CursorType.TNT).switchType());
|
||||
calcCursor(player);
|
||||
} else {
|
||||
LAST_SNEAKS.put(player, System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
public void calcCursor(Player player) {
|
||||
synchronized (calculating) {
|
||||
if (calculating.contains(player)) return;
|
||||
calculating.add(player);
|
||||
}
|
||||
if (!Permission.BUILD.hasPermission(player) || (!isSimulatorItem(player.getInventory().getItemInMainHand()) && !isSimulatorItem(player.getInventory().getItemInOffHand()))) {
|
||||
if (removeCursor(player) || SimulatorWatcher.show(null, player)) {
|
||||
SWUtils.sendToActionbar(player, "");
|
||||
}
|
||||
synchronized (calculating) {
|
||||
calculating.remove(player);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Simulator simulator = SimulatorStorage.getSimulator(player);
|
||||
SimulatorWatcher.show(simulator, player);
|
||||
|
||||
List<REntity> entities = SimulatorWatcher.getEntitiesOfSimulator(simulator);
|
||||
RayTraceUtils.RRayTraceResult rayTraceResult = RayTraceUtils.traceREntity(player, player.getLocation(), entities);
|
||||
if (rayTraceResult == null) {
|
||||
removeCursor(player);
|
||||
if (simulator == null) {
|
||||
SWUtils.sendToActionbar(player, "§eSelect Simulator");
|
||||
} else {
|
||||
SWUtils.sendToActionbar(player, "§eOpen Simulator");
|
||||
}
|
||||
synchronized (calculating) {
|
||||
calculating.remove(player);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
showCursor(player, rayTraceResult, simulator != null);
|
||||
synchronized (calculating) {
|
||||
calculating.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized boolean removeCursor(Player player) {
|
||||
REntityServer entityServer = cursors.get(player);
|
||||
boolean hadCursor = entityServer != null && !entityServer.getEntities().isEmpty();
|
||||
if (entityServer != null) {
|
||||
entityServer.getEntities().forEach(REntity::die);
|
||||
}
|
||||
return hadCursor;
|
||||
}
|
||||
|
||||
private synchronized void showCursor(Player player, RayTraceUtils.RRayTraceResult rayTraceResult, boolean hasSimulatorSelected) {
|
||||
REntityServer entityServer = cursors.computeIfAbsent(player, __ -> {
|
||||
REntityServer rEntityServer = new REntityServer();
|
||||
rEntityServer.addPlayer(player);
|
||||
return rEntityServer;
|
||||
});
|
||||
|
||||
CursorType type = cursorType.getOrDefault(player, CursorType.TNT);
|
||||
REntity hitEntity = rayTraceResult.getHitEntity();
|
||||
Location location = hitEntity != null ? new Vector(hitEntity.getX(), hitEntity.getY(), hitEntity.getZ()).toLocation(WORLD) :
|
||||
type.position.apply(player, rayTraceResult).toLocation(WORLD);
|
||||
|
||||
Material material = hitEntity != null ? Material.GLASS : type.getMaterial();
|
||||
List<RFallingBlockEntity> entities = entityServer.getEntitiesByType(RFallingBlockEntity.class);
|
||||
entities.removeIf(rFallingBlockEntity -> {
|
||||
if (rFallingBlockEntity.getMaterial() != material) {
|
||||
rFallingBlockEntity.die();
|
||||
return true;
|
||||
}
|
||||
rFallingBlockEntity.move(location);
|
||||
return false;
|
||||
});
|
||||
if (entities.isEmpty()) {
|
||||
RFallingBlockEntity rFallingBlockEntity = new RFallingBlockEntity(entityServer, location, material);
|
||||
rFallingBlockEntity.setNoGravity(true);
|
||||
if (material == Material.GLASS) {
|
||||
rFallingBlockEntity.setGlowing(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasSimulatorSelected) {
|
||||
if (hitEntity != null) {
|
||||
SWUtils.sendToActionbar(player, "§eEdit Position");
|
||||
} else {
|
||||
SWUtils.sendToActionbar(player, "§eAdd new " + type.name);
|
||||
}
|
||||
} else {
|
||||
SWUtils.sendToActionbar(player, "§eCreate new Simulator");
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector getPosFree(Player player, RayTraceUtils.RRayTraceResult result) {
|
||||
Vector pos = result.getHitPosition();
|
||||
|
||||
BlockFace face = result.getHitBlockFace();
|
||||
if (face != null) {
|
||||
switch (face) {
|
||||
case DOWN:
|
||||
pos.setY(pos.getY() - 0.98);
|
||||
break;
|
||||
case EAST:
|
||||
pos.setX(pos.getX() + 0.49);
|
||||
break;
|
||||
case WEST:
|
||||
pos.setX(pos.getX() - 0.49);
|
||||
break;
|
||||
case NORTH:
|
||||
pos.setZ(pos.getZ() - 0.49);
|
||||
break;
|
||||
case SOUTH:
|
||||
pos.setZ(pos.getZ() + 0.49);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (face.getModY() == 0 && player.isSneaking()) {
|
||||
pos.setY(pos.getY() - 0.49);
|
||||
}
|
||||
}
|
||||
|
||||
if (!player.isSneaking()) {
|
||||
pos.setX(pos.getBlockX() + 0.5);
|
||||
if (face == null || face.getModY() == 0)
|
||||
pos.setY(pos.getBlockY() + 0.0);
|
||||
pos.setZ(pos.getBlockZ() + 0.5);
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
private static Vector getPosBlockAligned(Player player, RayTraceUtils.RRayTraceResult result) {
|
||||
Vector pos = result.getHitPosition();
|
||||
|
||||
BlockFace face = result.getHitBlockFace();
|
||||
if (face != null) {
|
||||
switch (face) {
|
||||
case DOWN:
|
||||
pos.setY(pos.getY() - 0.98);
|
||||
break;
|
||||
case EAST:
|
||||
pos.setX(pos.getX() + 0.49);
|
||||
break;
|
||||
case WEST:
|
||||
pos.setX(pos.getX() - 0.49);
|
||||
break;
|
||||
case NORTH:
|
||||
pos.setZ(pos.getZ() - 0.49);
|
||||
break;
|
||||
case SOUTH:
|
||||
pos.setZ(pos.getZ() + 0.49);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pos.setX(pos.getBlockX() + 0.5);
|
||||
if (pos.getY() - pos.getBlockY() != 0 && face == BlockFace.UP) {
|
||||
pos.setY(pos.getBlockY() + 1.0);
|
||||
} else {
|
||||
pos.setY(pos.getBlockY());
|
||||
}
|
||||
pos.setZ(pos.getBlockZ() + 0.5);
|
||||
return pos;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum CursorType {
|
||||
TNT(Material.TNT, SimulatorCursor::getPosFree, "TNT", vector -> new TNTElement(vector).add(new TNTPhase())),
|
||||
REDSTONE_BLOCK(Material.REDSTONE_BLOCK, SimulatorCursor::getPosBlockAligned, "Redstone Block", vector -> new RedstoneElement(vector).add(new RedstonePhase())),
|
||||
OBSERVER(Material.OBSERVER, SimulatorCursor::getPosBlockAligned, "Observer", vector -> new ObserverElement(vector).add(new ObserverPhase())),
|
||||
;
|
||||
|
||||
private Material material;
|
||||
private BiFunction<Player, RayTraceUtils.RRayTraceResult, Vector> position;
|
||||
private String name;
|
||||
private Function<Vector, SimulatorElement<?>> elementFunction;
|
||||
|
||||
public CursorType switchType() {
|
||||
if (this == TNT) {
|
||||
return REDSTONE_BLOCK;
|
||||
}
|
||||
if (this == REDSTONE_BLOCK) {
|
||||
return OBSERVER;
|
||||
}
|
||||
return TNT;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||
if (!ItemUtils.isItem(event.getItem(), "simulator")) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
Player player = event.getPlayer();
|
||||
Simulator simulator = SimulatorStorage.getSimulator(player);
|
||||
|
||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_AIR) {
|
||||
if (simulator == null) {
|
||||
return;
|
||||
}
|
||||
SimulatorExecutor.run(simulator);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
RayTraceUtils.RRayTraceResult rayTraceResult = RayTraceUtils.traceREntity(player, player.getLocation(), SimulatorWatcher.getEntitiesOfSimulator(simulator));
|
||||
if (simulator == null) {
|
||||
if (rayTraceResult == null) {
|
||||
SimulatorStorage.openSimulatorSelector(player);
|
||||
} else {
|
||||
SWAnvilInv anvilInv = new SWAnvilInv(player, "Name");
|
||||
anvilInv.setCallback(s -> {
|
||||
Simulator sim = SimulatorStorage.getSimulator(s);
|
||||
if (sim != null) {
|
||||
BauSystem.MESSAGE.send("SIMULATOR_NAME_ALREADY_EXISTS", player);
|
||||
return;
|
||||
}
|
||||
if (!s.matches("[a-zA-Z_0-9-]+")) {
|
||||
BauSystem.MESSAGE.send("SIMULATOR_NAME_INVALID", player);
|
||||
return;
|
||||
}
|
||||
sim = new Simulator(s);
|
||||
SimulatorStorage.addSimulator(s, sim);
|
||||
createElement(player, rayTraceResult, sim);
|
||||
SimulatorStorage.setSimulator(player, sim);
|
||||
});
|
||||
anvilInv.open();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (rayTraceResult == null) {
|
||||
new SimulatorGui(player, simulator).open();
|
||||
return;
|
||||
}
|
||||
|
||||
if (rayTraceResult.getHitEntity() != null) {
|
||||
REntity hitEntity = rayTraceResult.getHitEntity();
|
||||
Vector vector = new Vector(hitEntity.getX(), hitEntity.getY(), hitEntity.getZ());
|
||||
List<SimulatorElement<?>> elements = simulator.getGroups().stream().map(SimulatorGroup::getElements).flatMap(List::stream).filter(element -> {
|
||||
return element.getWorldPos().distanceSquared(vector) < (1 / 16.0) * (1 / 16.0);
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
switch (elements.size()) {
|
||||
case 0:
|
||||
return;
|
||||
case 1:
|
||||
// Open single element present in Simulator
|
||||
SimulatorElement<?> element = elements.get(0);
|
||||
SimulatorGroup group1 = element.getGroup(simulator);
|
||||
SimulatorBaseGui back = new SimulatorGui(player, simulator);
|
||||
if (group1.getElements().size() > 1) {
|
||||
back = new SimulatorGroupGui(player, simulator, group1, back);
|
||||
}
|
||||
element.open(player, simulator, group1, back);
|
||||
break;
|
||||
default:
|
||||
List<SimulatorGroup> parents = elements.stream().map(e -> e.getGroup(simulator)).distinct().collect(Collectors.toList());
|
||||
if (parents.size() == 1) {
|
||||
// Open multi element present in Simulator in existing group
|
||||
SimulatorGui simulatorGui = new SimulatorGui(player, simulator);
|
||||
new SimulatorGroupGui(player, simulator, parents.get(0), simulatorGui).open();
|
||||
} else {
|
||||
// Open multi element present in Simulator in implicit group
|
||||
SimulatorGroup group2 = new SimulatorGroup();
|
||||
group2.setMaterial(null);
|
||||
group2.getElements().addAll(elements);
|
||||
SimulatorGui simulatorGui = new SimulatorGui(player, simulator);
|
||||
new SimulatorGroupGui(player, simulator, group2, simulatorGui).open();
|
||||
}
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Add new Element to current simulator
|
||||
createElement(player, rayTraceResult, simulator);
|
||||
}
|
||||
|
||||
private void createElement(Player player, RayTraceUtils.RRayTraceResult rayTraceResult, Simulator simulator) {
|
||||
CursorType type = cursorType.getOrDefault(player, CursorType.TNT);
|
||||
Vector vector = type.position.apply(player, rayTraceResult);
|
||||
if (type == CursorType.REDSTONE_BLOCK) {
|
||||
vector.subtract(new Vector(0.5, 0, 0.5));
|
||||
}
|
||||
SimulatorElement<?> element = type.elementFunction.apply(vector);
|
||||
SimulatorGroup group = new SimulatorGroup().add(element);
|
||||
simulator.getGroups().add(group);
|
||||
SimulatorGui simulatorGui = new SimulatorGui(player, simulator);
|
||||
element.open(player, simulator, group, simulatorGui);
|
||||
SimulatorWatcher.update(simulator);
|
||||
calcCursor(player);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,168 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU Affero 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
|
||||
* Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator;
|
||||
|
||||
import de.steamwar.Reflection;
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.features.simulator.data.observer.ObserverElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.observer.ObserverPhase;
|
||||
import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.redstone.RedstonePhase;
|
||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
|
||||
import de.steamwar.bausystem.features.simulator.display.SimulatorCursor;
|
||||
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
|
||||
import de.steamwar.bausystem.features.simulator.execute.SimulatorExecutor;
|
||||
import de.steamwar.bausystem.features.simulator.gui.SimulatorGroupGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.SimulatorGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||
import de.steamwar.bausystem.utils.ItemUtils;
|
||||
import de.steamwar.bausystem.utils.RayTraceUtils;
|
||||
import de.steamwar.bausystem.utils.cursor.Cursor;
|
||||
import de.steamwar.entity.REntity;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.entity.RFallingBlockEntity;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.var;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Linked
|
||||
@MinVersion(19)
|
||||
public class SimulatorCursorManager implements Listener {
|
||||
enum SimulatorCursorMode {
|
||||
TNT, REDSTONE_BLOCK, OBSERVER
|
||||
}
|
||||
|
||||
private final Map<Player, Map<Simulator, Cursor>> activeCursorsByPlayerBySimulator = new HashMap<>();
|
||||
|
||||
public void onPlayerItemEquip(PlayerItemHeldEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
// Show simulator cursor for newly held simulator item and trigger simulator display
|
||||
Simulator heldSimulator = SimulatorStorage.getSimulator(player.getInventory().getItem(event.getNewSlot()));
|
||||
|
||||
if (heldSimulator != null) {
|
||||
Map<Simulator, Cursor> cursorsBySimulator = activeCursorsByPlayerBySimulator.getOrDefault(player, new HashMap<>());
|
||||
Cursor cursor = cursorsBySimulator.get(heldSimulator);
|
||||
|
||||
if (cursor == null) {
|
||||
REntityServer simulatorServer = SimulatorRenderer.show(heldSimulator, player);
|
||||
cursor = new Cursor(simulatorServer, player, Material.GLASS, Material.TNT,
|
||||
Arrays.asList(Cursor.CursorMode.BLOCK_ALIGNED, Cursor.CursorMode.FREE), (clickedLocation, clickedOnEntity, clickAction) -> {
|
||||
});
|
||||
|
||||
cursorsBySimulator.put(heldSimulator, cursor);
|
||||
activeCursorsByPlayerBySimulator.put(player, cursorsBySimulator);
|
||||
cursor.show();
|
||||
}
|
||||
cursor.show();
|
||||
|
||||
}
|
||||
|
||||
// Hide simulator cursor for previously held simulator item
|
||||
Simulator previousSimulator = SimulatorStorage.getSimulator(player.getInventory().getItem(event.getPreviousSlot()));
|
||||
if (previousSimulator != null) {
|
||||
Map<Simulator, Cursor> cursorsBySimulator = activeCursorsByPlayerBySimulator.getOrDefault(player, new HashMap<>());
|
||||
Cursor cursor = cursorsBySimulator.get(previousSimulator);
|
||||
|
||||
if (cursor != null) {
|
||||
cursor.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private synchronized void showCursor(Player player, RayTraceUtils.RRayTraceResult rayTraceResult, boolean hasSimulatorSelected) {
|
||||
REntityServer entityServer = cursors.computeIfAbsent(player, __ -> {
|
||||
REntityServer rEntityServer = new REntityServer();
|
||||
rEntityServer.addPlayer(player);
|
||||
return rEntityServer;
|
||||
});
|
||||
|
||||
CursorType type = cursorType.getOrDefault(player, CursorType.TNT);
|
||||
REntity hitEntity = rayTraceResult.getHitEntity();
|
||||
Location location = hitEntity != null ? new Vector(hitEntity.getX(), hitEntity.getY(), hitEntity.getZ()).toLocation(WORLD)
|
||||
: type.position.apply(player, rayTraceResult).toLocation(WORLD);
|
||||
|
||||
Material material = hitEntity != null ? Material.GLASS : type.getMaterial();
|
||||
List<RFallingBlockEntity> entities = entityServer.getEntitiesByType(RFallingBlockEntity.class);
|
||||
entities.removeIf(rFallingBlockEntity -> {
|
||||
if (rFallingBlockEntity.getMaterial() != material) {
|
||||
rFallingBlockEntity.die();
|
||||
return true;
|
||||
}
|
||||
rFallingBlockEntity.move(location);
|
||||
return false;
|
||||
});
|
||||
if (entities.isEmpty()) {
|
||||
RFallingBlockEntity rFallingBlockEntity = new RFallingBlockEntity(entityServer, location, material);
|
||||
rFallingBlockEntity.setNoGravity(true);
|
||||
if (material == Material.GLASS) {
|
||||
rFallingBlockEntity.setGlowing(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasSimulatorSelected) {
|
||||
if (hitEntity != null) {
|
||||
SWUtils.sendToActionbar(player, "§eEdit Position");
|
||||
} else {
|
||||
SWUtils.sendToActionbar(player, "§eAdd new " + type.name);
|
||||
}
|
||||
} else {
|
||||
SWUtils.sendToActionbar(player, "§eCreate new Simulator");
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum CursorType {
|
||||
|
||||
}
|
||||
|
||||
private void createElement(Player player, RayTraceUtils.RRayTraceResult rayTraceResult, Simulator simulator) {
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,20 +1,18 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU Affero 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 Affero General Public License for more details.
|
||||
* 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
|
||||
* Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator;
|
||||
@ -23,6 +21,7 @@ import com.google.common.io.Files;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.display.SimulatorCursor;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
||||
import de.steamwar.bausystem.features.simulator.storage.SimFormatSimulatorLoader;
|
||||
import de.steamwar.bausystem.features.simulator.storage.SimulatorFormatSimulatorLoader;
|
||||
@ -56,12 +55,13 @@ public class SimulatorStorage implements Enable {
|
||||
|
||||
public static Simulator getSimulator(Player player) {
|
||||
Simulator simulator = getSimulator(player.getInventory().getItemInMainHand());
|
||||
if (simulator != null) return simulator;
|
||||
if (simulator != null)
|
||||
return simulator;
|
||||
return getSimulator(player.getInventory().getItemInOffHand());
|
||||
}
|
||||
|
||||
public static Simulator getSimulator(ItemStack itemStack) {
|
||||
if (!SimulatorCursor.isSimulatorItem(itemStack)) {
|
||||
if (!SimulatorUtils.isSimulatorItem(itemStack)) {
|
||||
return null;
|
||||
}
|
||||
String selection = ItemUtils.getTag(itemStack, simulatorSelection);
|
||||
@ -86,11 +86,11 @@ public class SimulatorStorage implements Enable {
|
||||
YAPIONFormatSimulatorLoader yapionFormatSimulatorLoader = new YAPIONFormatSimulatorLoader();
|
||||
|
||||
File[] files = simulatorsDir.listFiles();
|
||||
if (files == null) return;
|
||||
if (files == null)
|
||||
return;
|
||||
for (File file : files) {
|
||||
try {
|
||||
List<Simulator> simulators = simFormatSimulatorLoader.load(file)
|
||||
.orElse(null);
|
||||
List<Simulator> simulators = simFormatSimulatorLoader.load(file).orElse(null);
|
||||
if (simulators != null) {
|
||||
simulators.forEach(simulator -> {
|
||||
simulatorMap.put(simulator.getName(), simulator);
|
||||
@ -102,8 +102,7 @@ public class SimulatorStorage implements Enable {
|
||||
}
|
||||
|
||||
try {
|
||||
List<Simulator> simulators = simulatorFormatSimulatorLoader.load(file)
|
||||
.orElse(null);
|
||||
List<Simulator> simulators = simulatorFormatSimulatorLoader.load(file).orElse(null);
|
||||
if (simulators != null) {
|
||||
simulators.forEach(simulator -> {
|
||||
simulatorMap.put(simulator.getName(), simulator);
|
||||
@ -116,8 +115,7 @@ public class SimulatorStorage implements Enable {
|
||||
}
|
||||
|
||||
try {
|
||||
List<Simulator> simulators = yapionFormatSimulatorLoader.load(file)
|
||||
.orElse(null);
|
||||
List<Simulator> simulators = yapionFormatSimulatorLoader.load(file).orElse(null);
|
||||
if (simulators != null) {
|
||||
simulators.forEach(simulator -> {
|
||||
simulatorMap.put(simulator.getName(), simulator);
|
||||
@ -131,7 +129,8 @@ public class SimulatorStorage implements Enable {
|
||||
}
|
||||
|
||||
public static void openSimulatorSelector(Player player) {
|
||||
SimulatorPageGui<Simulator> simulatorPageGui = new SimulatorPageGui<Simulator>(player, null, 6 * 9, simulatorMap.values().stream().sorted(Comparator.comparing(Simulator::getName)).collect(Collectors.toList())) {
|
||||
SimulatorPageGui<Simulator> simulatorPageGui = new SimulatorPageGui<Simulator>(player, null, 6 * 9,
|
||||
simulatorMap.values().stream().sorted(Comparator.comparing(Simulator::getName)).collect(Collectors.toList())) {
|
||||
@Override
|
||||
public String baseTitle() {
|
||||
return "Simulators";
|
||||
@ -171,7 +170,11 @@ public class SimulatorStorage implements Enable {
|
||||
}
|
||||
|
||||
public static ItemStack getWand(Player p) {
|
||||
ItemStack itemStack = new SWItem(Material.BLAZE_ROD, BauSystem.MESSAGE.parse("SIMULATOR_WAND_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_1", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_2", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_3", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_4", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_5", p)), false, null).getItemStack();
|
||||
ItemStack itemStack = new SWItem(Material.BLAZE_ROD, BauSystem.MESSAGE.parse("SIMULATOR_WAND_NAME", p),
|
||||
Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_1", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_2", p),
|
||||
BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_3", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_4", p),
|
||||
BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_5", p)),
|
||||
false, null).getItemStack();
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
itemMeta.setCustomModelData(1);
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
@ -183,9 +186,9 @@ public class SimulatorStorage implements Enable {
|
||||
ItemStack mainHand = player.getInventory().getItemInMainHand();
|
||||
ItemStack offHand = player.getInventory().getItemInOffHand();
|
||||
ItemStack itemStack;
|
||||
if (SimulatorCursor.isSimulatorItem(mainHand)) {
|
||||
if (SimulatorUtils.isSimulatorItem(mainHand)) {
|
||||
itemStack = mainHand;
|
||||
} else if (SimulatorCursor.isSimulatorItem(offHand)) {
|
||||
} else if (SimulatorUtils.isSimulatorItem(offHand)) {
|
||||
itemStack = offHand;
|
||||
} else {
|
||||
itemStack = null;
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
package de.steamwar.bausystem.features.simulator;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import de.steamwar.bausystem.utils.ItemUtils;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
@UtilityClass
|
||||
public class SimulatorUtils {
|
||||
public static boolean isSimulatorItem(ItemStack itemStack) {
|
||||
return ItemUtils.isItem(itemStack, "simulator");
|
||||
}
|
||||
}
|
||||
@ -1,129 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.features.simulator.storage.SimulatorSaver;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import de.steamwar.entity.REntity;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.entity.RFallingBlockEntity;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@UtilityClass
|
||||
public class SimulatorWatcher {
|
||||
|
||||
private final World WORLD = Bukkit.getWorlds().get(0);
|
||||
private Map<Simulator, REntityServer> entityServers = new HashMap<>();
|
||||
private Map<Player, Pair<Simulator, Runnable>> watchers = new HashMap<>();
|
||||
|
||||
public void watch(Player player, Simulator simulator, Runnable watcher) {
|
||||
if (simulator == null || watcher == null) {
|
||||
watchers.remove(player);
|
||||
} else {
|
||||
watchers.put(player, new Pair<>(simulator, watcher));
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void update(Simulator simulator) {
|
||||
REntityServer rEntityServer = entityServers.get(simulator);
|
||||
if (rEntityServer != null) {
|
||||
rEntityServer.getEntities().forEach(REntity::die);
|
||||
createSim(rEntityServer, simulator);
|
||||
}
|
||||
|
||||
new ArrayList<>(watchers.values()).forEach(simulatorRunnablePair -> {
|
||||
if (simulatorRunnablePair.getKey() == simulator) {
|
||||
simulatorRunnablePair.getValue().run();
|
||||
}
|
||||
});
|
||||
SimulatorSaver.saveSimulator(SimulatorStorage.simulatorsDir, simulator);
|
||||
}
|
||||
|
||||
@Linked
|
||||
@MinVersion(19)
|
||||
public static class QuitListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
watchers.remove(event.getPlayer());
|
||||
show(null, event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
private REntityServer createSim(REntityServer server, Simulator simulator) {
|
||||
if (simulator == null) {
|
||||
return null;
|
||||
}
|
||||
Map<Vector, Set<Class<?>>> positionCache = new HashMap<>();
|
||||
simulator.getGroups().stream().map(group -> group.getElements().stream().map(element -> new Pair<>(group, element)).collect(Collectors.toList())).flatMap(List::stream).forEach(pair -> {
|
||||
SimulatorGroup group = pair.getKey();
|
||||
SimulatorElement<?> element = pair.getValue();
|
||||
|
||||
boolean wasNotPresent = positionCache.computeIfAbsent(element.getPosition(), __ -> new HashSet<>())
|
||||
.add(element.getClass());
|
||||
if (!wasNotPresent) return;
|
||||
Material material = group.isDisabled() || element.isDisabled() ? element.getWorldDisabledMaterial() : element.getWorldMaterial();
|
||||
Location location = element.getWorldPos().toLocation(WORLD);
|
||||
RFallingBlockEntity rFallingBlockEntity = new RFallingBlockEntity(server, location, material);
|
||||
rFallingBlockEntity.setNoGravity(true);
|
||||
});
|
||||
return server;
|
||||
}
|
||||
|
||||
public synchronized boolean show(Simulator sim, Player player) {
|
||||
AtomicBoolean removed = new AtomicBoolean();
|
||||
entityServers.forEach((simulator, rEntityServer) -> {
|
||||
if (rEntityServer == null) return;
|
||||
if (rEntityServer.getPlayers().contains(player) && sim != simulator) {
|
||||
rEntityServer.removePlayer(player);
|
||||
removed.set(true);
|
||||
}
|
||||
});
|
||||
if (sim == null) return removed.get();
|
||||
entityServers.computeIfAbsent(sim, __ -> createSim(new REntityServer(), sim)).addPlayer(player);
|
||||
return removed.get();
|
||||
}
|
||||
|
||||
synchronized List<REntity> getEntitiesOfSimulator(Simulator simulator) {
|
||||
REntityServer entityServer = entityServers.get(simulator);
|
||||
if (entityServer == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return entityServer.getEntities();
|
||||
}
|
||||
}
|
||||
@ -20,6 +20,7 @@
|
||||
package de.steamwar.bausystem.features.simulator.data;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.execute.SimulatorAction;
|
||||
import de.steamwar.bausystem.features.simulator.execute.SimulatorStabGenerator;
|
||||
import de.steamwar.inventory.InvCallback;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import lombok.Getter;
|
||||
@ -30,18 +31,20 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@RequiredArgsConstructor
|
||||
public final class Simulator {
|
||||
private SimulatorStabGenerator stabGenerator = null;
|
||||
private Material material = Material.BARREL;
|
||||
private final String name;
|
||||
private boolean autoTrace = false;
|
||||
private final List<SimulatorGroup> groups = new ArrayList<>();
|
||||
|
||||
private boolean autoTrace = false;
|
||||
private boolean autoTestblock = false;
|
||||
|
||||
public void move(int x, int y, int z) {
|
||||
groups.forEach(simulatorGroup -> {
|
||||
simulatorGroup.move(x, y, z);
|
||||
|
||||
@ -60,6 +60,7 @@ public final class TNTPhase extends SimulatorPhase {
|
||||
|
||||
@Override
|
||||
public void toSimulatorActions(Vector position, BiConsumer<Integer, SimulatorAction> tickStart, BiConsumer<Integer, SimulatorAction> tickEnd) {
|
||||
if (count <= 0) return;
|
||||
tickStart.accept(tickOffset, new SimulatorAction(order, count) {
|
||||
@Override
|
||||
public void accept(World world) {
|
||||
|
||||
@ -0,0 +1,83 @@
|
||||
package de.steamwar.bausystem.features.simulator.display;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorStorage;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.utils.cursor.Cursor;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
|
||||
public class EmptySimulatorCursor extends Cursor implements Listener {
|
||||
private final Player owner;
|
||||
|
||||
private SimulatorCursorMode cursorMode;
|
||||
|
||||
public EmptySimulatorCursor(Player owner) {
|
||||
super(new REntityServer(), owner, Material.GLASS, Material.TNT, List.of(Cursor.CursorMode.FREE, Cursor.CursorMode.BLOCK_ALIGNED));
|
||||
this.cursorMode = SimulatorCursorMode.TNT;
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public void swapCursorMode() {
|
||||
cursorMode = cursorMode.switchType();
|
||||
setCursorMaterial(cursorMode.getMaterial());
|
||||
setAllowedCursorModes(cursorMode.getAllowedCursorModes());
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
super.hide();
|
||||
super.getTargetServer().removePlayer(owner);
|
||||
}
|
||||
|
||||
public void show() {
|
||||
super.show();
|
||||
super.getTargetServer().addPlayer(owner);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerShift(PlayerToggleSneakEvent event) {
|
||||
if (event.getPlayer() != owner) {
|
||||
return;
|
||||
}
|
||||
swapCursorMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Optional<Location> clickedLocation, boolean clickedOnEntity, Action clickAction) {
|
||||
if (clickAction == Action.LEFT_CLICK_AIR) {
|
||||
SimulatorStorage.openSimulatorSelector(owner);
|
||||
} else if (clickAction == Action.LEFT_CLICK_BLOCK) {
|
||||
SWAnvilInv anvilInv = new SWAnvilInv(owner, "Name");
|
||||
anvilInv.setCallback(name -> {
|
||||
Simulator sim = SimulatorStorage.getSimulator(name);
|
||||
if (sim != null) {
|
||||
BauSystem.MESSAGE.send("SIMULATOR_NAME_ALREADY_EXISTS", owner);
|
||||
return;
|
||||
}
|
||||
if (!name.matches("[a-zA-Z_0-9-]+")) {
|
||||
BauSystem.MESSAGE.send("SIMULATOR_NAME_INVALID", owner);
|
||||
return;
|
||||
}
|
||||
sim = new Simulator(name);
|
||||
SimulatorStorage.addSimulator(name, sim);
|
||||
SimulatorElement<?> element = cursorMode.getElementFunction().apply(clickedLocation.get().toVector());
|
||||
SimulatorGroup group = new SimulatorGroup();
|
||||
group.add(element);
|
||||
sim.add(group);
|
||||
SimulatorStorage.setSimulator(owner, sim);
|
||||
});
|
||||
anvilInv.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,104 @@
|
||||
package de.steamwar.bausystem.features.simulator.display;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.features.simulator.execute.SimulatorExecutor;
|
||||
import de.steamwar.bausystem.features.simulator.gui.SimulatorGroupGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.SimulatorGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.bausystem.utils.cursor.Cursor;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
|
||||
public class SimulatorCursor extends Cursor {
|
||||
private final Simulator simulator;
|
||||
private final Player owner;
|
||||
|
||||
private SimulatorCursorMode cursorMode;
|
||||
|
||||
public SimulatorCursor(Simulator simulator, Player owner, SimulatorCursorMode cursorMode) {
|
||||
super(SimulatorRenderer.renderSimulator(simulator), owner, Material.LIME_STAINED_GLASS_PANE, Material.RED_STAINED_GLASS_PANE,
|
||||
cursorMode.getAllowedCursorModes());
|
||||
|
||||
this.simulator = simulator;
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public void swapCursorMode() {
|
||||
SimulatorCursorMode newMode = cursorMode.switchType();
|
||||
setCursorMaterial(newMode.getMaterial());
|
||||
setAllowedCursorModes(newMode.getAllowedCursorModes());
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
super.hide();
|
||||
super.getTargetServer().removePlayer(owner);
|
||||
}
|
||||
|
||||
public void show() {
|
||||
super.show();
|
||||
super.getTargetServer().addPlayer(owner);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerShift(PlayerToggleSneakEvent event) {
|
||||
if (event.getPlayer() != owner) {
|
||||
return;
|
||||
}
|
||||
swapCursorMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Optional<Location> clickedLocation, boolean clickedOnEntity, Action clickAction) {
|
||||
if (clickAction == Action.RIGHT_CLICK_AIR || clickAction == Action.RIGHT_CLICK_BLOCK) {
|
||||
SimulatorExecutor.run(owner, simulator, null);
|
||||
} else if (!clickedOnEntity || clickedLocation.isEmpty()) {
|
||||
new SimulatorGui(owner, simulator);
|
||||
} else {
|
||||
Vector vector = clickedLocation.get().toVector();
|
||||
List<SimulatorElement<?>> elements = simulator.getGroups().stream().map(SimulatorGroup::getElements).flatMap(List::stream).filter(element -> {
|
||||
return element.getWorldPos().distanceSquared(vector) < (1 / 16.0) * (1 / 16.0);
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
switch (elements.size()) {
|
||||
case 0:
|
||||
return;
|
||||
case 1:
|
||||
// Open single element present in Simulator
|
||||
SimulatorElement<?> element = elements.get(0);
|
||||
SimulatorGroup group1 = element.getGroup(simulator);
|
||||
SimulatorBaseGui back = new SimulatorGui(owner, simulator);
|
||||
if (group1.getElements().size() > 1) {
|
||||
back = new SimulatorGroupGui(owner, simulator, group1, back);
|
||||
}
|
||||
element.open(owner, simulator, group1, back);
|
||||
break;
|
||||
default:
|
||||
List<SimulatorGroup> parents = elements.stream().map(e -> e.getGroup(simulator)).distinct().collect(Collectors.toList());
|
||||
if (parents.size() == 1) {
|
||||
// Open multi element present in Simulator in existing group
|
||||
SimulatorGui simulatorGui = new SimulatorGui(owner, simulator);
|
||||
new SimulatorGroupGui(owner, simulator, parents.get(0), simulatorGui).open();
|
||||
} else {
|
||||
// Open multi element present in Simulator in implicit group
|
||||
SimulatorGroup group2 = new SimulatorGroup();
|
||||
group2.setMaterial(null);
|
||||
group2.getElements().addAll(elements);
|
||||
SimulatorGui simulatorGui = new SimulatorGui(owner, simulator);
|
||||
new SimulatorGroupGui(owner, simulator, group2, simulatorGui).open();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package de.steamwar.bausystem.features.simulator.display;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.util.Vector;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.observer.ObserverElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.observer.ObserverPhase;
|
||||
import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.redstone.RedstonePhase;
|
||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
|
||||
import de.steamwar.bausystem.utils.cursor.Cursor.CursorMode;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum SimulatorCursorMode {
|
||||
TNT(Material.TNT, "TNT", vector -> new TNTElement(vector).add(new TNTPhase()), List.of(CursorMode.FREE, CursorMode.BLOCK_ALIGNED)), REDSTONE_BLOCK(
|
||||
Material.REDSTONE_BLOCK, "Redstone Block", vector -> new RedstoneElement(vector).add(new RedstonePhase()), List.of(CursorMode.BLOCK_ALIGNED)), OBSERVER(
|
||||
Material.OBSERVER, "Observer", vector -> new ObserverElement(vector).add(new ObserverPhase()), List.of(CursorMode.BLOCK_ALIGNED));
|
||||
|
||||
private Material material;
|
||||
private String name;
|
||||
private Function<Vector, SimulatorElement<?>> elementFunction;
|
||||
private List<CursorMode> allowedCursorModes;
|
||||
|
||||
public SimulatorCursorMode switchType() {
|
||||
if (this == TNT) {
|
||||
return REDSTONE_BLOCK;
|
||||
}
|
||||
if (this == REDSTONE_BLOCK) {
|
||||
return OBSERVER;
|
||||
}
|
||||
return TNT;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU Affero 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
|
||||
* Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.display;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorStorage;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.features.simulator.storage.SimulatorSaver;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import de.steamwar.entity.REntity;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.entity.RFallingBlockEntity;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@UtilityClass
|
||||
public class SimulatorRenderer implements Listener {
|
||||
private final World WORLD = Bukkit.getWorlds().get(0);
|
||||
private Map<Simulator, REntityServer> entityServers = new HashMap<>();
|
||||
|
||||
public synchronized void update(Simulator simulator) {
|
||||
renderSimulator(simulator);
|
||||
|
||||
SimulatorSaver.saveSimulator(SimulatorStorage.simulatorsDir, simulator);
|
||||
}
|
||||
|
||||
public REntityServer renderSimulator(Simulator simulator) {
|
||||
if (simulator == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
REntityServer server = entityServers.computeIfAbsent(simulator, __ -> new REntityServer());
|
||||
|
||||
server.getEntities().forEach(REntity::die);
|
||||
|
||||
Map<Vector, Set<Class<?>>> positionCache = new HashMap<>();
|
||||
simulator.getGroups().stream().map(group -> group.getElements().stream().map(element -> new Pair<>(group, element)).collect(Collectors.toList()))
|
||||
.flatMap(List::stream).forEach(pair -> {
|
||||
SimulatorGroup group = pair.getKey();
|
||||
SimulatorElement<?> element = pair.getValue();
|
||||
|
||||
boolean wasNotPresent = positionCache.computeIfAbsent(element.getPosition(), __ -> new HashSet<>()).add(element.getClass());
|
||||
if (!wasNotPresent)
|
||||
return;
|
||||
Material material = group.isDisabled() || element.isDisabled() ? element.getWorldDisabledMaterial() : element.getWorldMaterial();
|
||||
Location location = element.getWorldPos().toLocation(WORLD);
|
||||
RFallingBlockEntity rFallingBlockEntity = new RFallingBlockEntity(server, location, material);
|
||||
rFallingBlockEntity.setNoGravity(true);
|
||||
});
|
||||
return server;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.execute;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@AllArgsConstructor
|
||||
public enum Direction {
|
||||
X(Vector::getBlockX),
|
||||
Y(Vector::getBlockY),
|
||||
Z(Vector::getBlockZ);
|
||||
|
||||
public final Function<Vector, Integer> component;
|
||||
}
|
||||
@ -31,6 +31,7 @@ import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
@ -46,7 +47,7 @@ public class SimulatorExecutor implements Listener {
|
||||
private static Map<Long, Map<Integer, List<SimulatorAction>>> tickStartActions = new HashMap<>();
|
||||
private static Map<Long, List<SimulatorAction>> tickEndActions = new HashMap<>();
|
||||
|
||||
public static boolean run(Simulator simulator) {
|
||||
public static boolean run(Player player, Simulator simulator, Runnable onEnd) {
|
||||
if (currentlyRunning.contains(simulator)) return false;
|
||||
currentlyRunning.add(simulator);
|
||||
|
||||
@ -69,7 +70,7 @@ public class SimulatorExecutor implements Listener {
|
||||
public void accept(World world) {
|
||||
currentlyRunning.remove(simulator);
|
||||
|
||||
if (simulator.isAutoTrace()) {
|
||||
if (simulator.isAutoTrace() && onEnd == null) {
|
||||
simulator.getGroups()
|
||||
.stream()
|
||||
.map(SimulatorGroup::getElements)
|
||||
@ -82,10 +83,17 @@ public class SimulatorExecutor implements Listener {
|
||||
TraceRecorder.instance.stopRecording(region);
|
||||
});
|
||||
}
|
||||
|
||||
if (onEnd != null) {
|
||||
onEnd.run();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (simulator.isAutoTrace()) {
|
||||
if (player != null && simulator.isAutoTestblock()) {
|
||||
player.performCommand("tb");
|
||||
}
|
||||
if (simulator.isAutoTrace() && onEnd == null) {
|
||||
simulator.getGroups()
|
||||
.stream()
|
||||
.map(SimulatorGroup::getElements)
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.execute;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SimulatorStabGenerator {
|
||||
|
||||
private final StabData stabData;
|
||||
|
||||
public SimulatorStabGenerator(Region region, Simulator simulator, TNTElement tntElement, int depthLimit) {
|
||||
stabData = new StabData(region, simulator, tntElement, tntElement.getPhases(), depthLimit);
|
||||
new StabSetup(stabData);
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
stabData.cancel = true;
|
||||
stabData.simulator.setStabGenerator(null);
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
BossBarService.instance.remove(player, stabData.region, "simulator_stab_generator");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.execute;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class StabData {
|
||||
|
||||
protected static final int MAX_RECORDINGS = 5;
|
||||
protected static final int MAX_TICK_DIFFERENCE = 3;
|
||||
protected static final Level LEVEL = Level.INFO;
|
||||
protected static final int TNT_INCREASE = 10;
|
||||
protected static final int MIN_BLOCK_TO_COUNT_AS_DEPTH = 20;
|
||||
|
||||
protected final Region region;
|
||||
protected final Simulator simulator;
|
||||
protected final TNTElement tntElement;
|
||||
protected final List<TNTPhase> phases;
|
||||
protected final int depthLimit;
|
||||
|
||||
protected Clipboard clipboard;
|
||||
protected boolean cancel = false;
|
||||
|
||||
protected Direction direction = null;
|
||||
protected int currentDepth = 0;
|
||||
}
|
||||
@ -0,0 +1,103 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.execute;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorPhase;
|
||||
import de.steamwar.bausystem.features.tracer.TNTPoint;
|
||||
import de.steamwar.bausystem.features.tracer.Trace;
|
||||
import de.steamwar.bausystem.features.tracer.TraceManager;
|
||||
import de.steamwar.bausystem.features.tracer.TraceRecorder;
|
||||
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class StabDirection extends StabStep {
|
||||
|
||||
public StabDirection(StabData data) {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void start() {
|
||||
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) {
|
||||
e.setBlocks((com.sk89q.worldedit.regions.Region) new CuboidRegion(data.region.getMinPointTestblockExtension().toBlockVector3(), data.region.getMaxPointTestblockExtension().toBlockVector3()), Objects.requireNonNull(BlockTypes.AIR).getDefaultState().toBaseBlock());
|
||||
}
|
||||
|
||||
Trace trace = TraceRecorder.instance.startRecording(data.region);
|
||||
runSimulator(() -> {
|
||||
TraceRecorder.instance.stopRecording(data.region);
|
||||
calculateDirection(trace);
|
||||
});
|
||||
}
|
||||
|
||||
private void calculateDirection(Trace trace) {
|
||||
long tickSinceStart = -1;
|
||||
List<TNTPoint> points = null;
|
||||
for (List<TNTPoint> current : trace.getHistories()) {
|
||||
long ticks = current.get(0).getTicksSinceStart();
|
||||
if (points == null || ticks > tickSinceStart) {
|
||||
tickSinceStart = ticks;
|
||||
points = current;
|
||||
} else if (ticks == tickSinceStart && points.get(0).getTntId() < current.get(0).getTntId()) {
|
||||
points = current;
|
||||
}
|
||||
}
|
||||
TraceManager.instance.remove(trace);
|
||||
if (points == null) {
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
TNTPoint current = points.getLast();
|
||||
Vector velocity = current.getVelocity();
|
||||
if (velocity.getX() < 0) velocity.setX(-velocity.getX());
|
||||
if (velocity.getY() < 0) velocity.setY(-velocity.getY());
|
||||
if (velocity.getZ() < 0) velocity.setZ(-velocity.getZ());
|
||||
if (velocity.getX() > velocity.getY() && velocity.getX() > velocity.getZ()) {
|
||||
data.direction = Direction.X;
|
||||
} else if (velocity.getY() > velocity.getX() && velocity.getY() > velocity.getZ()) {
|
||||
data.direction = Direction.Y;
|
||||
} else if (velocity.getZ() > velocity.getX() && velocity.getZ() > velocity.getY()) {
|
||||
data.direction = Direction.Z;
|
||||
} else {
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getLogger().log(StabData.LEVEL, "Direction: {0}", data.direction);
|
||||
data.phases.getFirst().setOrder(SimulatorPhase.ORDER_LIMIT);
|
||||
data.phases.getFirst().setCount(StabData.TNT_INCREASE);
|
||||
new StabGenerator(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bossbar(BauSystemBossbar bossbar, boolean finished) {
|
||||
bossbar.setProgress(0);
|
||||
bossbar.setTitle("§eCalculating Stab Direction");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.execute;
|
||||
|
||||
import de.steamwar.bausystem.features.tracer.Trace;
|
||||
import de.steamwar.bausystem.features.tracer.TraceRecorder;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
||||
|
||||
public class StabFinalizer extends StabStep {
|
||||
|
||||
public StabFinalizer(StabData data) {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void start() {
|
||||
try {
|
||||
PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard);
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider)
|
||||
.color(data.region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
||||
data.region.reset(pasteBuilder, RegionType.TESTBLOCK, RegionExtensionType.EXTENSION);
|
||||
} catch (SecurityException e) {
|
||||
stop();
|
||||
throw e;
|
||||
}
|
||||
|
||||
TraceRecorder.instance.startRecording(data.region);
|
||||
runSimulator(() -> {
|
||||
TraceRecorder.instance.stopRecording(data.region);
|
||||
stop();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bossbar(BauSystemBossbar bossbar, boolean stopped) {
|
||||
bossbar.setProgress(Math.min(data.currentDepth / (double) data.depthLimit, 1.0));
|
||||
bossbar.setTitle("§e" + data.currentDepth + "§8/§7" + data.depthLimit);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,250 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.execute;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static de.steamwar.bausystem.features.simulator.execute.Direction.Y;
|
||||
|
||||
public class StabGenerator extends StabStep implements Listener {
|
||||
|
||||
private int recordings = 0;
|
||||
private List<Integer> currentDepths = new ArrayList<>();
|
||||
private int lastDepth = 0;
|
||||
|
||||
private int retries = 0;
|
||||
|
||||
private final Map<Integer, Set<Location>> destroyedBlocksPerSlice = new HashMap<>();
|
||||
|
||||
private Set<Integer> gabStart = new HashSet<>();
|
||||
private Set<TNTPhase> failedAtLeastOnce = new HashSet<>();
|
||||
|
||||
@EventHandler
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
if (Region.getRegion(event.getEntity().getLocation()) == data.region) {
|
||||
event.blockList().forEach(block -> {
|
||||
if (!data.region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) return;
|
||||
int component = data.direction.component.apply(block.getLocation().toVector());
|
||||
destroyedBlocksPerSlice.computeIfAbsent(component, __ -> new HashSet<>())
|
||||
.add(block.getLocation());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public StabGenerator(StabData data) {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void start() {
|
||||
try {
|
||||
PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard);
|
||||
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider)
|
||||
.color(data.region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
||||
data.region.reset(pasteBuilder, RegionType.TESTBLOCK, RegionExtensionType.EXTENSION);
|
||||
} catch (SecurityException e) {
|
||||
stop();
|
||||
throw e;
|
||||
}
|
||||
|
||||
if (data.cancel) {
|
||||
HandlerList.unregisterAll(this);
|
||||
return;
|
||||
}
|
||||
|
||||
runSimulator(this::calculateStab);
|
||||
}
|
||||
|
||||
private void calculateStab() {
|
||||
TNTPhase lastPhase = data.phases.getLast();
|
||||
|
||||
List<Map.Entry<Integer, Set<Location>>> locations = destroyedBlocksPerSlice.entrySet()
|
||||
.stream()
|
||||
.sorted(Comparator.comparingInt(Map.Entry::getKey))
|
||||
.collect(Collectors.toList());
|
||||
int depth = 0;
|
||||
for (int i = 0; i < locations.size(); i++) {
|
||||
if (data.direction != Y && i > 0 && Math.abs(locations.get(i - 1).getKey() - locations.get(i).getKey()) > 3) {
|
||||
if (gabStart.add(locations.get(i).getKey())) {
|
||||
Bukkit.getLogger().log(StabData.LEVEL, "Increasing tnt count by {0} because of gap", StabData.TNT_INCREASE);
|
||||
lastPhase.setCount(lastPhase.getCount() + StabData.TNT_INCREASE);
|
||||
recordings = 0;
|
||||
currentDepths.clear();
|
||||
|
||||
run();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (i == 0 || i == locations.size() - 1) {
|
||||
if (locations.get(i).getValue().size() > StabData.MIN_BLOCK_TO_COUNT_AS_DEPTH) {
|
||||
depth++;
|
||||
}
|
||||
} else {
|
||||
depth++;
|
||||
}
|
||||
}
|
||||
|
||||
if (depth > 0) {
|
||||
Bukkit.getLogger().log(StabData.LEVEL, "{0} {1} {2}", new Object[]{depth, destroyedBlocksPerSlice.size(), destroyedBlocksPerSlice.values().stream().map(Set::size).collect(Collectors.toList())});
|
||||
destroyedBlocksPerSlice.clear();
|
||||
currentDepths.add(depth);
|
||||
} else {
|
||||
destroyedBlocksPerSlice.clear();
|
||||
lastPhase.setTickOffset(lastPhase.getTickOffset() + 1);
|
||||
Bukkit.getLogger().log(StabData.LEVEL, "No dimension - Increasing tickOffset to: {0}", lastPhase.getTickOffset());
|
||||
lastPhase.setOrder(0);
|
||||
if (lastPhase.getTickOffset() > 80) {
|
||||
stop();
|
||||
} else {
|
||||
run();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int minDepth = currentDepths.stream().min(Integer::compareTo).orElse(0);
|
||||
int maxDepth = currentDepths.stream().max(Integer::compareTo).orElse(0);
|
||||
data.currentDepth = maxDepth;
|
||||
|
||||
int countWithoutLast = 0;
|
||||
for (int i = 0; i < data.phases.size() - 1; i++) {
|
||||
countWithoutLast += data.phases.get(i).getCount();
|
||||
}
|
||||
countWithoutLast -= gabStart.size();
|
||||
|
||||
boolean moreTNTNeeded = maxDepth - countWithoutLast >= lastPhase.getCount() - 5;
|
||||
if (moreTNTNeeded) {
|
||||
Bukkit.getLogger().log(StabData.LEVEL, "Increasing tnt count by {0}", StabData.TNT_INCREASE);
|
||||
lastPhase.setCount(lastPhase.getCount() + StabData.TNT_INCREASE);
|
||||
recordings = 0;
|
||||
currentDepths.clear();
|
||||
|
||||
run();
|
||||
return;
|
||||
}
|
||||
|
||||
if (recordings++ < StabData.MAX_RECORDINGS) {
|
||||
run();
|
||||
return;
|
||||
}
|
||||
|
||||
recordings = 0;
|
||||
currentDepths.clear();
|
||||
|
||||
if (maxDepth - minDepth > lastPhase.getCount()) {
|
||||
Bukkit.getLogger().log(StabData.LEVEL, "Stab failed at least once. Adding one tnt to {0}", minDepth - 3);
|
||||
int current = 0;
|
||||
TNTPhase last = null;
|
||||
for (TNTPhase phase : data.phases) {
|
||||
if (current < minDepth - 3) {
|
||||
current += phase.getCount();
|
||||
last = phase;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (failedAtLeastOnce.add(last)) {
|
||||
last = null;
|
||||
break;
|
||||
}
|
||||
|
||||
if (last != null) {
|
||||
last.setCount(last.getCount() + 1);
|
||||
Bukkit.getLogger().log(StabData.LEVEL, "Added to phase {0} now has {1} tnt", new Object[]{data.phases.indexOf(last), last.getCount()});
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (last != null) {
|
||||
run();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Bukkit.getLogger().log(StabData.LEVEL, "No more TNT needed on phase adjusting - {0} new count; {1} current count", new Object[]{maxDepth - countWithoutLast, lastPhase.getCount()});
|
||||
lastPhase.setCount(maxDepth - countWithoutLast);
|
||||
if (lastPhase.getCount() <= 0) {
|
||||
Bukkit.getLogger().log(StabData.LEVEL, "Count was 0 or negative - removing last phase");
|
||||
data.phases.removeLast();
|
||||
}
|
||||
|
||||
if (maxDepth > data.depthLimit) {
|
||||
Bukkit.getLogger().log(StabData.LEVEL, "Depth is greater than {0} - finished", data.depthLimit);
|
||||
new StabFinalizer(data);
|
||||
return;
|
||||
}
|
||||
if (maxDepth <= lastDepth) {
|
||||
if (lastPhase.getCount() <= 0) {
|
||||
retries++;
|
||||
}
|
||||
if (lastPhase.getCount() > 0 || retries > StabData.MAX_TICK_DIFFERENCE) {
|
||||
Bukkit.getLogger().log(StabData.LEVEL, "Depth is equal to last depth recorded {0} - finished", maxDepth);
|
||||
new StabFinalizer(data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
lastDepth = maxDepth;
|
||||
|
||||
newPhase(data, lastPhase);
|
||||
run();
|
||||
}
|
||||
|
||||
public static void newPhase(StabData data, TNTPhase lastPhase) {
|
||||
Bukkit.getLogger().log(StabData.LEVEL, "Adding new phase in next tick");
|
||||
TNTPhase nextPhase = new TNTPhase();
|
||||
nextPhase.setCount(StabData.TNT_INCREASE);
|
||||
nextPhase.setTickOffset(lastPhase.getTickOffset() + 1);
|
||||
nextPhase.setXJump(lastPhase.isXJump());
|
||||
nextPhase.setYJump(lastPhase.isYJump());
|
||||
nextPhase.setZJump(lastPhase.isZJump());
|
||||
data.phases.add(nextPhase);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bossbar(BauSystemBossbar bossbar, boolean finished) {
|
||||
bossbar.setProgress(Math.min(data.currentDepth / (double) data.depthLimit, 1.0));
|
||||
if (finished) {
|
||||
bossbar.setTitle("§e" + data.currentDepth + "§8/§7" + data.depthLimit);
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder st = new StringBuilder();
|
||||
st.append("§7Direction §e").append(data.direction);
|
||||
st.append(" §e").append(data.currentDepth).append("§8/§7").append(data.depthLimit);
|
||||
if (recordings > 0) {
|
||||
st.append(" §7Retries§8:§e ").append(recordings).append("§8/§7").append(StabData.MAX_RECORDINGS);
|
||||
}
|
||||
bossbar.setTitle(st.toString());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.execute;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
|
||||
import de.steamwar.bausystem.features.tracer.TraceRecorder;
|
||||
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
||||
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class StabSetup extends StabStep {
|
||||
|
||||
public StabSetup(StabData data) {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void start() {
|
||||
TNTPhase tntPhase = data.simulator.getGroups().stream()
|
||||
.filter(simulatorGroup -> !simulatorGroup.isDisabled())
|
||||
.map(SimulatorGroup::getElements)
|
||||
.flatMap(List::stream)
|
||||
.filter(TNTElement.class::isInstance)
|
||||
.map(TNTElement.class::cast)
|
||||
.filter(tntElement -> !tntElement.isDisabled())
|
||||
.filter(tntElement -> data.tntElement != tntElement)
|
||||
.map(tntElement -> tntElement.getPhases().stream().max(Comparator.comparingInt(TNTPhase::getTickOffset)))
|
||||
.filter(Optional::isPresent)
|
||||
.map(Optional::get)
|
||||
.peek(phase -> {
|
||||
if (phase.getOrder() > TNTPhase.ORDER_LIMIT) {
|
||||
phase.setOrder(TNTPhase.ORDER_LIMIT);
|
||||
}
|
||||
})
|
||||
.filter(phase -> phase != data.phases.get(0))
|
||||
.max(Comparator.comparingInt(TNTPhase::getTickOffset))
|
||||
.orElse(null);
|
||||
if (tntPhase == null) {
|
||||
throw new SecurityException("");
|
||||
}
|
||||
|
||||
TNTPhase phase = data.phases.get(0);
|
||||
data.phases.clear();
|
||||
data.phases.add(phase);
|
||||
phase.setCount(1);
|
||||
phase.setTickOffset(tntPhase.getTickOffset());
|
||||
phase.setOrder(100);
|
||||
|
||||
TraceRecorder.instance.stopRecording(data.region);
|
||||
if (TraceRecorder.instance.isAutoTraceEnabledInRegion(data.region)) {
|
||||
TraceRecorder.instance.removeAutoTraceRegion(data.region);
|
||||
}
|
||||
data.clipboard = FlatteningWrapper.impl.copy(data.region.getMinPointTestblockExtension(), data.region.getMaxPointTestblockExtension(), data.region.getTestBlockPoint());
|
||||
|
||||
new StabDirection(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bossbar(BauSystemBossbar bossbar, boolean finished) {
|
||||
bossbar.setProgress(0);
|
||||
bossbar.setTitle("§eSetting up Simulator");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU Affero 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
|
||||
* Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.execute;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
|
||||
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
||||
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public abstract class StabStep {
|
||||
|
||||
protected final StabData data;
|
||||
|
||||
protected StabStep(StabData data) {
|
||||
this.data = data;
|
||||
run();
|
||||
}
|
||||
|
||||
protected final void run() {
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
BauSystemBossbar bossbar = BossBarService.instance.get(player, data.region, "simulator_stab_generator");
|
||||
bossbar.setColor(BarColor.GREEN);
|
||||
bossbar.setStyle(BarStyle.SEGMENTED_10);
|
||||
bossbar(bossbar, false);
|
||||
}
|
||||
}, 1);
|
||||
|
||||
if (this instanceof Listener) {
|
||||
Bukkit.getPluginManager().registerEvents((Listener) this, BauSystem.getInstance());
|
||||
}
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), this::start, 20);
|
||||
}
|
||||
|
||||
protected abstract void start();
|
||||
|
||||
protected final void runSimulator(Runnable onFinish) {
|
||||
SimulatorExecutor.run(null, data.simulator, () -> {
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
if (this instanceof Listener) {
|
||||
HandlerList.unregisterAll((Listener) this);
|
||||
}
|
||||
onFinish.run();
|
||||
}, 20);
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract void bossbar(BauSystemBossbar bossbar, boolean stopped);
|
||||
|
||||
protected final void stop() {
|
||||
data.simulator.setStabGenerator(null);
|
||||
SimulatorRenderer.update(data.simulator);
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
BauSystemBossbar bossbar = BossBarService.instance.get(player, data.region, "simulator_stab_generator");
|
||||
bossbar.setColor(BarColor.GREEN);
|
||||
bossbar.setStyle(BarStyle.SEGMENTED_10);
|
||||
bossbar(bossbar, true);
|
||||
}
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Thread.sleep(4000);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
} finally {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
BossBarService.instance.remove(player, data.region, "simulator_stab_generator");
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
@ -1,28 +1,26 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU Affero 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 Affero General Public License for more details.
|
||||
* 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
|
||||
* Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.gui;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
||||
import de.steamwar.inventory.InvCallback;
|
||||
@ -39,7 +37,8 @@ public class SimulatorGroupChooserGui extends SimulatorPageGui<SimulatorGroup> {
|
||||
private final SimulatorBaseGui back;
|
||||
|
||||
public SimulatorGroupChooserGui(Player player, Simulator simulator, SimulatorElement<?> subject, SimulatorGroup parent, SimulatorBaseGui back) {
|
||||
super(player, simulator, 6 * 9, simulator.getGroups().stream().filter(e -> e != parent).filter(e -> subject.canBeInGroup(e)).collect(Collectors.toList()));
|
||||
super(player, simulator, 6 * 9,
|
||||
simulator.getGroups().stream().filter(e -> e != parent).filter(e -> subject.canBeInGroup(e)).collect(Collectors.toList()));
|
||||
this.subject = subject;
|
||||
this.parent = parent;
|
||||
this.back = back;
|
||||
@ -56,7 +55,7 @@ public class SimulatorGroupChooserGui extends SimulatorPageGui<SimulatorGroup> {
|
||||
simulator.getGroups().add(newParent);
|
||||
parent.getElements().remove(subject);
|
||||
back.open();
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
if (parent.getElements().size() == 1) {
|
||||
parent.setDisabled(false);
|
||||
parent.setMaterial(Material.BARREL);
|
||||
@ -83,7 +82,7 @@ public class SimulatorGroupChooserGui extends SimulatorPageGui<SimulatorGroup> {
|
||||
parent.setMaterial(Material.BARREL);
|
||||
}
|
||||
back.open();
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
};
|
||||
return simulatorGroup.toItem(player, invCallback, invCallback);
|
||||
}
|
||||
|
||||
@ -1,30 +1,29 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU Affero 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 Affero General Public License for more details.
|
||||
* 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
|
||||
* Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.gui;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -59,7 +58,7 @@ public class SimulatorGroupGui extends SimulatorPageGui<SimulatorElement<?>> {
|
||||
}
|
||||
|
||||
if (simulatorGroup.getElements().removeIf(element -> element.getPhases().isEmpty())) {
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
}
|
||||
if (simulatorGroup.getElements().size() < 2) {
|
||||
back.open();
|
||||
@ -70,33 +69,36 @@ public class SimulatorGroupGui extends SimulatorPageGui<SimulatorElement<?>> {
|
||||
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
||||
simulatorGroup.getElements().clear();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||
|
||||
inventory.setItem(4, simulatorGroup.toItem(player, clickType -> {
|
||||
if (simulatorGroup.getMaterial() == null) return;
|
||||
if (simulatorGroup.getMaterial() == null)
|
||||
return;
|
||||
new SimulatorMaterialGui(player, simulator, simulatorGroup::getMaterial, simulatorGroup::setMaterial, this).open();
|
||||
}, clickType -> {
|
||||
}));
|
||||
|
||||
inventory.setItem(48, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
||||
new SimulatorGroupSettingsGui(player, simulator, simulatorGroup, this).open();
|
||||
}));
|
||||
boolean disabled = simulatorGroup.getMaterial() == null ? simulatorGroup.getElements().stream().allMatch(SimulatorElement::isDisabled) : simulatorGroup.isDisabled();
|
||||
inventory.setItem(50, new SWItem(disabled ? Material.ENDER_PEARL : Material.ENDER_EYE, simulatorGroup.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
|
||||
if (simulatorGroup.getMaterial() == null) {
|
||||
simulatorGroup.getElements().forEach(simulatorElement -> {
|
||||
simulatorElement.setDisabled(!disabled);
|
||||
});
|
||||
} else {
|
||||
simulatorGroup.setDisabled(!disabled);
|
||||
}
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.SETTINGS));
|
||||
boolean disabled = simulatorGroup.getMaterial() == null ? simulatorGroup.getElements().stream().allMatch(SimulatorElement::isDisabled)
|
||||
: simulatorGroup.isDisabled();
|
||||
inventory.setItem(50,
|
||||
new SWItem(disabled ? Material.ENDER_PEARL : Material.ENDER_EYE, simulatorGroup.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
|
||||
if (simulatorGroup.getMaterial() == null) {
|
||||
simulatorGroup.getElements().forEach(simulatorElement -> {
|
||||
simulatorElement.setDisabled(!disabled);
|
||||
});
|
||||
} else {
|
||||
simulatorGroup.setDisabled(!disabled);
|
||||
}
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,34 +1,32 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU Affero 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 Affero General Public License for more details.
|
||||
* 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
|
||||
* Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.gui;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
|
||||
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -58,168 +56,160 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, simulatorGroup.toItem(player, clickType -> {
|
||||
if (simulatorGroup.getMaterial() == null) return;
|
||||
if (simulatorGroup.getMaterial() == null)
|
||||
return;
|
||||
new SimulatorMaterialGui(player, simulator, simulatorGroup::getMaterial, simulatorGroup::setMaterial, this).open();
|
||||
}, clickType -> {
|
||||
}));
|
||||
|
||||
// Base Tick
|
||||
int baseTicks = simulatorGroup.getBaseTick();
|
||||
inventory.setItem(9, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(9, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
simulatorGroup.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
|
||||
if (integer < 0) return false;
|
||||
if (integer < 0)
|
||||
return false;
|
||||
simulatorGroup.changeBaseTicks(integer - baseTicks);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).setItem(Material.REPEATER).open();
|
||||
});
|
||||
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
|
||||
inventory.setItem(18, baseTick);
|
||||
inventory.setItem(27, SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(27, new SWItem(SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (baseTicks - (clickType.isShiftClick() ? 5 : 1) < 0) {
|
||||
simulatorGroup.changeBaseTicks(-baseTicks);
|
||||
} else {
|
||||
simulatorGroup.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
|
||||
}
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
boolean allTNT = simulatorGroup.getElements().stream().allMatch(TNTElement.class::isInstance);
|
||||
|
||||
if (allTNT) {
|
||||
// Subpixel Alignment
|
||||
inventory.setItem(21, new SWItem(Material.SUNFLOWER, "§7Align§8: §eCenter", clickType -> {
|
||||
simulatorGroup.getElements().stream()
|
||||
.map(TNTElement.class::cast)
|
||||
.forEach(tntElement -> {
|
||||
tntElement.alignX(0);
|
||||
tntElement.alignZ(0);
|
||||
});
|
||||
SimulatorWatcher.update(simulator);
|
||||
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tntElement -> {
|
||||
tntElement.alignX(0);
|
||||
tntElement.alignZ(0);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}));
|
||||
|
||||
// Z
|
||||
SWItem negativZItem = new SWItem(Material.OAK_BUTTON, "§7Align§8: §eNegativ Z", clickType -> {
|
||||
simulatorGroup.getElements().stream()
|
||||
.map(TNTElement.class::cast)
|
||||
.forEach(tntElement -> {
|
||||
if (tntElement.getAlignment().getZ() != -1) tntElement.alignZ(-1);
|
||||
});
|
||||
SimulatorWatcher.update(simulator);
|
||||
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tntElement -> {
|
||||
if (tntElement.getAlignment().getZ() != -1)
|
||||
tntElement.alignZ(-1);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
});
|
||||
negativZItem.setEnchanted(simulatorGroup.getElements().stream()
|
||||
.map(TNTElement.class::cast)
|
||||
.allMatch(tntElement -> tntElement.getAlignment().getZ() == -1));
|
||||
negativZItem.setEnchanted(
|
||||
simulatorGroup.getElements().stream().map(TNTElement.class::cast).allMatch(tntElement -> tntElement.getAlignment().getZ() == -1));
|
||||
inventory.setItem(20, negativZItem);
|
||||
|
||||
SWItem positivZItem = new SWItem(Material.OAK_BUTTON, "§7Align§8: §ePositiv Z", clickType -> {
|
||||
simulatorGroup.getElements().stream()
|
||||
.map(TNTElement.class::cast)
|
||||
.forEach(tntElement -> {
|
||||
if (tntElement.getAlignment().getZ() != 1) tntElement.alignZ(1);
|
||||
});
|
||||
SimulatorWatcher.update(simulator);
|
||||
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tntElement -> {
|
||||
if (tntElement.getAlignment().getZ() != 1)
|
||||
tntElement.alignZ(1);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
});
|
||||
positivZItem.setEnchanted(simulatorGroup.getElements().stream()
|
||||
.map(TNTElement.class::cast)
|
||||
.allMatch(tntElement -> tntElement.getAlignment().getZ() == 1));
|
||||
positivZItem.setEnchanted(
|
||||
simulatorGroup.getElements().stream().map(TNTElement.class::cast).allMatch(tntElement -> tntElement.getAlignment().getZ() == 1));
|
||||
inventory.setItem(22, positivZItem);
|
||||
|
||||
// X
|
||||
SWItem negativXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §eNegativ X", clickType -> {
|
||||
simulatorGroup.getElements().stream()
|
||||
.map(TNTElement.class::cast)
|
||||
.forEach(tntElement -> {
|
||||
if (tntElement.getAlignment().getX() != -1) tntElement.alignX(-1);
|
||||
});
|
||||
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tntElement -> {
|
||||
if (tntElement.getAlignment().getX() != -1)
|
||||
tntElement.alignX(-1);
|
||||
});
|
||||
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
});
|
||||
negativXItem.setEnchanted(simulatorGroup.getElements().stream()
|
||||
.map(TNTElement.class::cast)
|
||||
.allMatch(tntElement -> tntElement.getAlignment().getX() == -1));
|
||||
negativXItem.setEnchanted(
|
||||
simulatorGroup.getElements().stream().map(TNTElement.class::cast).allMatch(tntElement -> tntElement.getAlignment().getX() == -1));
|
||||
inventory.setItem(12, negativXItem);
|
||||
|
||||
SWItem positivXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §ePositiv X", clickType -> {
|
||||
simulatorGroup.getElements().stream()
|
||||
.map(TNTElement.class::cast)
|
||||
.forEach(tntElement -> {
|
||||
if (tntElement.getAlignment().getX() != 1) tntElement.alignX(1);
|
||||
});
|
||||
SimulatorWatcher.update(simulator);
|
||||
SWItem positivXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §ePositiv X", clickType -> {
|
||||
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tntElement -> {
|
||||
if (tntElement.getAlignment().getX() != 1)
|
||||
tntElement.alignX(1);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
});
|
||||
positivXItem.setEnchanted(simulatorGroup.getElements().stream()
|
||||
.map(TNTElement.class::cast)
|
||||
.allMatch(tntElement -> tntElement.getAlignment().getX() == -1));
|
||||
positivXItem.setEnchanted(
|
||||
simulatorGroup.getElements().stream().map(TNTElement.class::cast).allMatch(tntElement -> tntElement.getAlignment().getX() == -1));
|
||||
inventory.setItem(30, positivXItem);
|
||||
}
|
||||
|
||||
//Pos X
|
||||
inventory.setItem(15, SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
||||
// Pos X
|
||||
inventory.setItem(15, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
||||
simulatorGroup.move(clickType.isShiftClick() ? (allTNT ? 0.0625 : 5) : 1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(24, new SWItem(Material.PAPER, "§eX", clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Relative X", "", Double::parseDouble, number -> {
|
||||
if(!allTNT){
|
||||
if (!allTNT) {
|
||||
number = (double) Math.round(number);
|
||||
}
|
||||
simulatorGroup.move(number, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).setItem(Material.PAPER).open();
|
||||
}));
|
||||
inventory.setItem(33, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(33, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||
simulatorGroup.move(clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos Y
|
||||
inventory.setItem(16, SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
||||
// Pos Y
|
||||
inventory.setItem(16, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
||||
simulatorGroup.move(0, clickType.isShiftClick() ? (allTNT ? 0.0625 : 5) : 1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(25, new SWItem(Material.PAPER, "§eY", clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Relative Y", "", Double::parseDouble, number -> {
|
||||
if(!allTNT){
|
||||
if (!allTNT) {
|
||||
number = (double) Math.round(number);
|
||||
}
|
||||
simulatorGroup.move(0, number, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).setItem(Material.PAPER).open();
|
||||
}));
|
||||
inventory.setItem(34, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(34, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||
simulatorGroup.move(0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||
|
||||
//Pos Z
|
||||
inventory.setItem(17, SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
||||
// Pos Z
|
||||
inventory.setItem(17, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
||||
simulatorGroup.move(0, 0, clickType.isShiftClick() ? (allTNT ? 0.0625 : 5) : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ", clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Relative Z", "", Double::parseDouble, number -> {
|
||||
if(!allTNT){
|
||||
if (!allTNT) {
|
||||
number = (double) Math.round(number);
|
||||
}
|
||||
simulatorGroup.move(0, 0, number);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).setItem(Material.PAPER).open();
|
||||
}));
|
||||
inventory.setItem(35, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(35, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||
simulatorGroup.move(0, 0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,29 +1,28 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU Affero 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 Affero General Public License for more details.
|
||||
* 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
|
||||
* Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.gui;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -41,8 +40,9 @@ public class SimulatorGui extends SimulatorPageGui<SimulatorGroup> {
|
||||
|
||||
@Override
|
||||
public void headerAndFooter() {
|
||||
if (simulator.getGroups().removeIf(element -> element.getElements().isEmpty() || element.getElements().stream().allMatch(simulatorElement -> simulatorElement.getPhases().isEmpty()))) {
|
||||
SimulatorWatcher.update(simulator);
|
||||
if (simulator.getGroups().removeIf(element -> element.getElements().isEmpty()
|
||||
|| element.getElements().stream().allMatch(simulatorElement -> simulatorElement.getPhases().isEmpty()))) {
|
||||
SimulatorRenderer.update(simulator);
|
||||
}
|
||||
|
||||
inventory.setItem(4, simulator.toItem(player, clickType -> {
|
||||
@ -50,7 +50,7 @@ public class SimulatorGui extends SimulatorPageGui<SimulatorGroup> {
|
||||
}));
|
||||
inventory.setItem(49, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
||||
new SimulatorSettingsGui(player, simulator, this).open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.SETTINGS));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,28 +1,27 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU Affero 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 Affero General Public License for more details.
|
||||
* 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
|
||||
* Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.gui;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -35,11 +34,8 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class SimulatorMaterialGui extends SimulatorPageGui<Material> {
|
||||
|
||||
private static final List<Material> MATERIALS = Arrays.stream(Material.values())
|
||||
.filter(material -> !material.isAir())
|
||||
.filter(material -> !material.isLegacy())
|
||||
.filter(Material::isItem)
|
||||
.collect(Collectors.toList());
|
||||
private static final List<Material> MATERIALS = Arrays.stream(Material.values()).filter(material -> !material.isAir())
|
||||
.filter(material -> !material.isLegacy()).filter(Material::isItem).collect(Collectors.toList());
|
||||
|
||||
private final Supplier<Material> currentMaterial;
|
||||
private Material material;
|
||||
@ -53,6 +49,16 @@ public class SimulatorMaterialGui extends SimulatorPageGui<Material> {
|
||||
this.back = back;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldOpen() {
|
||||
if (player.getItemOnCursor().getType().isAir()) {
|
||||
return true;
|
||||
}
|
||||
change.accept(player.getItemOnCursor().getType());
|
||||
SimulatorRenderer.update(simulator);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String baseTitle() {
|
||||
return "Material";
|
||||
@ -65,14 +71,15 @@ public class SimulatorMaterialGui extends SimulatorPageGui<Material> {
|
||||
}));
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SWItem convert(Material material) {
|
||||
return new SWItem(material, "§eNew Material", Arrays.asList(material == this.material ? "§eSelected" : "§eClick to select"), material == this.material, clickType -> {
|
||||
change.accept(material);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
return new SWItem(material, "§eNew Material", Arrays.asList(material == this.material ? "§eSelected" : "§eClick to select"), material == this.material,
|
||||
clickType -> {
|
||||
change.accept(material);
|
||||
SimulatorRenderer.update(simulator);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,31 +1,30 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU Affero 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 Affero General Public License for more details.
|
||||
* 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
|
||||
* Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.gui;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.features.simulator.data.observer.ObserverElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.observer.ObserverPhase;
|
||||
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorScrollGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -59,7 +58,7 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
|
||||
public void headerAndFooter() {
|
||||
if (observer.getPhases().isEmpty()) {
|
||||
back.open();
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -82,12 +81,12 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
|
||||
new SimulatorGroupGui(player, simulator, newParent, simulatorGui).open();
|
||||
}
|
||||
}
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
||||
observer.getPhases().clear();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, observer.toItem(player, clickType -> {
|
||||
@ -97,18 +96,19 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
|
||||
// Settings
|
||||
inventory.setItem(47, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
||||
new SimulatorObserverSettingsGui(player, simulator, observer, this).open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.SETTINGS));
|
||||
|
||||
// Enable/Disable
|
||||
inventory.setItem(48, new SWItem(observer.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, observer.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
|
||||
observer.setDisabled(!observer.isDisabled());
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
inventory.setItem(48,
|
||||
new SWItem(observer.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, observer.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
|
||||
observer.setDisabled(!observer.isDisabled());
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||
|
||||
// Group chooser
|
||||
inventory.setItem(51, new SWItem(Material.LEAD, "§eJoin Group", clickType -> {
|
||||
new SimulatorGroupChooserGui(player, simulator, observer, observer.getGroup(simulator), this).open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.JOIN_GROUP));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -138,7 +138,7 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
|
||||
SWItem observer = new SWItem(Material.OBSERVER, "§eObserver", lore, false, clickType -> {
|
||||
if (clickType == ClickType.MIDDLE) {
|
||||
this.observer.getPhases().remove(observerPhase);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
} else {
|
||||
new SimulatorObserverPhaseSettingsGui(player, simulator, this.observer, observerPhase, this).open();
|
||||
}
|
||||
@ -147,42 +147,35 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
|
||||
|
||||
Supplier<Integer> getter = observerPhase::getTickOffset;
|
||||
Consumer<Integer> setter = observerPhase::setTickOffset;
|
||||
return new SWItem[] {
|
||||
new SWItem(SWItem.getDye(getter.get() < max ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
setter.accept(Math.min(max, getter.get() + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}),
|
||||
observer,
|
||||
return new SWItem[] {new SWItem(SWItem.getDye(getter.get() < max ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
setter.accept(Math.min(max, getter.get() + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED), observer,
|
||||
new SWItem(SWItem.getDye(getter.get() > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8:§e -5"), false, clickType -> {
|
||||
setter.accept(Math.max(min, getter.get() - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}),
|
||||
new SWItem(Material.ANVIL, "§eEdit Activation", clickType -> {
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED), new SWItem(Material.ANVIL, "§eEdit Activation", clickType -> {
|
||||
new SimulatorObserverPhaseSettingsGui(player, simulator, this.observer, observerPhase, this).open();
|
||||
}),
|
||||
};
|
||||
}).setCustomModelData(CMDs.Simulator.EDIT_ACTIVATION),};
|
||||
}
|
||||
|
||||
@Override
|
||||
public SWItem[] lastColumn() {
|
||||
return new SWItem[]{
|
||||
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
addNewPhase(clickType.isShiftClick());
|
||||
}),
|
||||
new SWItem(Material.QUARTZ, "§eObserver§8:§a New Phase", clickType -> {
|
||||
addNewPhase(false);
|
||||
}),
|
||||
new SWItem(SWItem.getDye(8), "§7", clickType -> {
|
||||
}),
|
||||
};
|
||||
return new SWItem[] {new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
addNewPhase(clickType.isShiftClick());
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED), new SWItem(Material.QUARTZ, "§eObserver§8:§a New Phase", clickType -> {
|
||||
addNewPhase(false);
|
||||
}).setCustomModelData(CMDs.Simulator.NEW_PHASE), new SWItem(SWItem.getDye(8), "§7", clickType -> {
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),};
|
||||
}
|
||||
|
||||
private void addNewPhase(boolean shift) {
|
||||
ObserverPhase lastElement = observer.getPhases().get(observer.getPhases().size() - 1);
|
||||
ObserverPhase newPhase = new ObserverPhase(lastElement.getTickOffset() + 4);
|
||||
if (shift) newPhase.setTickOffset(newPhase.getTickOffset() + 5);
|
||||
if (shift)
|
||||
newPhase.setTickOffset(newPhase.getTickOffset() + 5);
|
||||
scroll += 2;
|
||||
observer.add(newPhase);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,32 +1,31 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU Affero 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 Affero General Public License for more details.
|
||||
* 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
|
||||
* Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.gui;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorPhase;
|
||||
import de.steamwar.bausystem.features.simulator.data.observer.ObserverElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.observer.ObserverPhase;
|
||||
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@ -40,7 +39,8 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
|
||||
private final ObserverPhase observer;
|
||||
private final SimulatorBaseGui back;
|
||||
|
||||
public SimulatorObserverPhaseSettingsGui(Player player, Simulator simulator, ObserverElement observerElement, ObserverPhase observer, SimulatorBaseGui back) {
|
||||
public SimulatorObserverPhaseSettingsGui(Player player, Simulator simulator, ObserverElement observerElement, ObserverPhase observer,
|
||||
SimulatorBaseGui back) {
|
||||
super(player, simulator, 5 * 9);
|
||||
this.observerElement = observerElement;
|
||||
this.observer = observer;
|
||||
@ -62,7 +62,7 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, observerElement.toItem(player, clickType -> {
|
||||
@ -73,8 +73,8 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
|
||||
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
||||
observerElement.getPhases().remove(observer);
|
||||
back.open();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||
|
||||
int index = observerElement.getPhases().indexOf(observer);
|
||||
int min;
|
||||
@ -93,80 +93,87 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
|
||||
max = Integer.MAX_VALUE - 4;
|
||||
}
|
||||
|
||||
//Tick Offset
|
||||
// Tick Offset
|
||||
int offset = observer.getTickOffset();
|
||||
inventory.setItem(10, SWItem.getDye(offset < max ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(10, new SWItem(SWItem.getDye(offset < max ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
observer.setTickOffset(Math.min(max, offset + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
|
||||
SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Start at", offset + "", Integer::parseInt, integer -> {
|
||||
if (integer < 0) return false;
|
||||
if (integer < 0)
|
||||
return false;
|
||||
observer.setTickOffset(Math.min(Math.max(integer, min), max));
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).setItem(Material.REPEATER).open();
|
||||
});
|
||||
offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64)));
|
||||
inventory.setItem(19, offsetItem);
|
||||
|
||||
inventory.setItem(28, SWItem.getDye(offset > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(28, new SWItem(SWItem.getDye(offset > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
observer.setTickOffset(Math.max(min, offset - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Order
|
||||
// Order
|
||||
int order = observer.getOrder();
|
||||
inventory.setItem(13, SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
observer.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
inventory.setItem(13,
|
||||
new SWItem(SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
observer.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
|
||||
Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR");
|
||||
SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eActivation Order§8:§7 " + order, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Activation Order", order + "", Integer::parseInt, integer -> {
|
||||
if (integer < -SimulatorPhase.ORDER_LIMIT) return false;
|
||||
if (integer > SimulatorPhase.ORDER_LIMIT) return false;
|
||||
if (integer < -SimulatorPhase.ORDER_LIMIT)
|
||||
return false;
|
||||
if (integer > SimulatorPhase.ORDER_LIMIT)
|
||||
return false;
|
||||
observer.setOrder(integer);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).setItem(order >= 0 ? Material.COMPASS : negativeNumbers).open();
|
||||
});
|
||||
orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30)));
|
||||
inventory.setItem(22, orderItem);
|
||||
|
||||
inventory.setItem(31, SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
observer.setOrder(Math.max(-SimulatorPhase.ORDER_LIMIT, order - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
inventory.setItem(31,
|
||||
new SWItem(SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
observer.setOrder(Math.max(-SimulatorPhase.ORDER_LIMIT, order - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
// Update orientation
|
||||
inventory.setItem(25, new SWItem(Material.SUNFLOWER, "§7", clickType -> {
|
||||
}));
|
||||
inventory.setItem(15, new SWItem(observer.getOrientation() == BlockFace.UP ? Material.LIME_CONCRETE : Material.GRAY_CONCRETE, "§eUp", clickType -> {
|
||||
observer.setOrientation(BlockFace.UP);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
}));
|
||||
inventory.setItem(33, new SWItem(observer.getOrientation() == BlockFace.DOWN ? Material.RED_CONCRETE : Material.GRAY_CONCRETE, "§eDown", clickType -> {
|
||||
observer.setOrientation(BlockFace.DOWN);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
}));
|
||||
inventory.setItem(16, new SWItem(observer.getOrientation() == BlockFace.NORTH ? Material.LIME_WOOL : Material.GRAY_WOOL, "§eNorth", clickType -> {
|
||||
observer.setOrientation(BlockFace.NORTH);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
}));
|
||||
inventory.setItem(34, new SWItem(observer.getOrientation() == BlockFace.SOUTH ? Material.RED_WOOL : Material.GRAY_WOOL, "§eSouth", clickType -> {
|
||||
observer.setOrientation(BlockFace.SOUTH);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
inventory.setItem(24, new SWItem(observer.getOrientation() == BlockFace.EAST ? Material.LIME_STAINED_GLASS : Material.GRAY_STAINED_GLASS, "§eEast", clickType -> {
|
||||
observer.setOrientation(BlockFace.EAST);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
inventory.setItem(26, new SWItem(observer.getOrientation() == BlockFace.WEST ? Material.RED_STAINED_GLASS : Material.GRAY_STAINED_GLASS, "§eWest", clickType -> {
|
||||
observer.setOrientation(BlockFace.WEST);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
}));
|
||||
inventory.setItem(24,
|
||||
new SWItem(observer.getOrientation() == BlockFace.EAST ? Material.LIME_STAINED_GLASS : Material.GRAY_STAINED_GLASS, "§eEast", clickType -> {
|
||||
observer.setOrientation(BlockFace.EAST);
|
||||
SimulatorRenderer.update(simulator);
|
||||
}));
|
||||
inventory.setItem(26,
|
||||
new SWItem(observer.getOrientation() == BlockFace.WEST ? Material.RED_STAINED_GLASS : Material.GRAY_STAINED_GLASS, "§eWest", clickType -> {
|
||||
observer.setOrientation(BlockFace.WEST);
|
||||
SimulatorRenderer.update(simulator);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,29 +1,28 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU Affero 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 Affero General Public License for more details.
|
||||
* 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
|
||||
* Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.gui;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.observer.ObserverElement;
|
||||
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -56,7 +55,7 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, observer.toItem(player, clickType -> {
|
||||
@ -65,78 +64,79 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
// Base Tick
|
||||
int baseTicks = observer.getBaseTick();
|
||||
inventory.setItem(9, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(9, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
observer.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
|
||||
if (integer < 0) return false;
|
||||
if (integer < 0)
|
||||
return false;
|
||||
observer.changeBaseTicks(integer - baseTicks);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).setItem(Material.REPEATER).open();
|
||||
});
|
||||
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
|
||||
inventory.setItem(18, baseTick);
|
||||
inventory.setItem(27, SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(27, new SWItem(SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (baseTicks - (clickType.isShiftClick() ? 5 : 1) < 0) {
|
||||
observer.changeBaseTicks(-baseTicks);
|
||||
} else {
|
||||
observer.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
|
||||
}
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos X
|
||||
inventory.setItem(15, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
// Pos X
|
||||
inventory.setItem(15, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
observer.move(clickType.isShiftClick() ? 5 : 1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(24, new SWItem(Material.PAPER, "§eX§8:§7 " + observer.getPosition().getBlockX(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "X", observer.getPosition().getBlockX() + "", Integer::parseInt, i -> {
|
||||
observer.getPosition().setX(i);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(33, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(33, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
observer.move(clickType.isShiftClick() ? -5 : -1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos Y
|
||||
inventory.setItem(16, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
// Pos Y
|
||||
inventory.setItem(16, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
observer.move(0, clickType.isShiftClick() ? 5 : 1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||
inventory.setItem(25, new SWItem(Material.PAPER, "§eY§8:§7 " + observer.getPosition().getBlockY(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Y", observer.getPosition().getBlockY() + "", Integer::parseInt, i -> {
|
||||
observer.getPosition().setY(i);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(34, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(34, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
observer.move(0, clickType.isShiftClick() ? -5 : -1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos Z
|
||||
inventory.setItem(17, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
// Pos Z
|
||||
inventory.setItem(17, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
observer.move(0, 0, clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ§8:§7 " + observer.getPosition().getBlockZ(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Z", observer.getPosition().getBlockZ() + "", Integer::parseInt, i -> {
|
||||
observer.getPosition().setZ(i);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(35, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(35, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
observer.move(0, 0, clickType.isShiftClick() ? -5 : -1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,31 +1,30 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU Affero 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 Affero General Public License for more details.
|
||||
* 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
|
||||
* Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.gui;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.redstone.RedstonePhase;
|
||||
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorScrollGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.bukkit.Material;
|
||||
@ -60,7 +59,7 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<SimulatorRedstoneGu
|
||||
public void headerAndFooter() {
|
||||
if (redstone.getPhases().isEmpty()) {
|
||||
back.open();
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -88,12 +87,12 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<SimulatorRedstoneGu
|
||||
new SimulatorGroupGui(player, simulator, newParent, simulatorGui).open();
|
||||
}
|
||||
}
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
||||
redstone.getPhases().clear();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, redstone.toItem(player, clickType -> {
|
||||
@ -103,18 +102,19 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<SimulatorRedstoneGu
|
||||
// Settings
|
||||
inventory.setItem(47, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
||||
new SimulatorRedstoneSettingsGui(player, simulator, redstone, this).open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.SETTINGS));
|
||||
|
||||
// Enable/Disable
|
||||
inventory.setItem(48, new SWItem(redstone.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, redstone.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
|
||||
redstone.setDisabled(!redstone.isDisabled());
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
inventory.setItem(48,
|
||||
new SWItem(redstone.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, redstone.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
|
||||
redstone.setDisabled(!redstone.isDisabled());
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||
|
||||
// Group chooser
|
||||
inventory.setItem(51, new SWItem(Material.LEAD, "§eJoin Group", clickType -> {
|
||||
new SimulatorGroupChooserGui(player, simulator, redstone, redstone.getGroup(simulator), this).open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.JOIN_GROUP));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -150,55 +150,49 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<SimulatorRedstoneGu
|
||||
lore.add("");
|
||||
lore.add("§7Click§8:§e Edit");
|
||||
lore.add("§7Middle-Click§8:§e Remove");
|
||||
SWItem redstone = new SWItem(redstoneSubPhase.place ? Material.REDSTONE_BLOCK : Material.STONE, redstoneSubPhase.place ? "§eActivate" : "§eDeactivate", lore, false, clickType -> {
|
||||
if (clickType == ClickType.MIDDLE) {
|
||||
this.redstone.getPhases().remove(redstoneSubPhase.phase);
|
||||
SimulatorWatcher.update(simulator);
|
||||
} else {
|
||||
new SimulatorRedstonePhaseSettingsGui(player, simulator, this.redstone, redstoneSubPhase.phase, this).open();
|
||||
}
|
||||
});
|
||||
SWItem redstone = new SWItem(redstoneSubPhase.place ? Material.REDSTONE_BLOCK : Material.STONE, redstoneSubPhase.place ? "§eActivate" : "§eDeactivate",
|
||||
lore, false, clickType -> {
|
||||
if (clickType == ClickType.MIDDLE) {
|
||||
this.redstone.getPhases().remove(redstoneSubPhase.phase);
|
||||
SimulatorRenderer.update(simulator);
|
||||
} else {
|
||||
new SimulatorRedstonePhaseSettingsGui(player, simulator, this.redstone, redstoneSubPhase.phase, this).open();
|
||||
}
|
||||
});
|
||||
redstone.getItemStack().setAmount(Math.max(1, Math.min(time, 64)));
|
||||
|
||||
Supplier<Integer> getter = redstoneSubPhase.place ? redstoneSubPhase.phase::getTickOffset : redstoneSubPhase.phase::getLifetime;
|
||||
Consumer<Integer> setter = redstoneSubPhase.place ? redstoneSubPhase.phase::setTickOffset : redstoneSubPhase.phase::setLifetime;
|
||||
return new SWItem[] {
|
||||
new SWItem(SWItem.getDye(getter.get() < max ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
setter.accept(Math.min(max, getter.get() + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}),
|
||||
redstone,
|
||||
return new SWItem[] {new SWItem(SWItem.getDye(getter.get() < max ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
setter.accept(Math.min(max, getter.get() + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED), redstone,
|
||||
new SWItem(SWItem.getDye(getter.get() > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8:§e -5"), false, clickType -> {
|
||||
setter.accept(Math.max(min, getter.get() - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}),
|
||||
new SWItem(Material.ANVIL, "§eEdit Activation", clickType -> {
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED), new SWItem(Material.ANVIL, "§eEdit Activation", clickType -> {
|
||||
new SimulatorRedstonePhaseSettingsGui(player, simulator, this.redstone, redstoneSubPhase.phase, this).open();
|
||||
}),
|
||||
};
|
||||
}).setCustomModelData(CMDs.Simulator.EDIT_ACTIVATION),};
|
||||
}
|
||||
|
||||
@Override
|
||||
public SWItem[] lastColumn() {
|
||||
return new SWItem[]{
|
||||
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
addNewPhase(clickType.isShiftClick());
|
||||
}),
|
||||
new SWItem(Material.REDSTONE, "§eRedstone§8:§a New Phase", clickType -> {
|
||||
addNewPhase(false);
|
||||
}),
|
||||
new SWItem(SWItem.getDye(8), "§7", clickType -> {
|
||||
}),
|
||||
};
|
||||
return new SWItem[] {new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
addNewPhase(clickType.isShiftClick());
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED), new SWItem(Material.REDSTONE, "§eRedstone§8:§a New Phase", clickType -> {
|
||||
addNewPhase(false);
|
||||
}).setCustomModelData(CMDs.Simulator.NEW_PHASE), new SWItem(SWItem.getDye(8), "§7", clickType -> {
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),};
|
||||
}
|
||||
|
||||
private void addNewPhase(boolean shift) {
|
||||
RedstonePhase lastElement = redstone.getPhases().get(redstone.getPhases().size() - 1);
|
||||
RedstonePhase newPhase = new RedstonePhase(lastElement.getTickOffset() + lastElement.getLifetime() + 1);
|
||||
if (shift) newPhase.setTickOffset(newPhase.getTickOffset() + 5);
|
||||
if (shift)
|
||||
newPhase.setTickOffset(newPhase.getTickOffset() + 5);
|
||||
scroll += 2;
|
||||
redstone.add(newPhase);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
|
||||
@ -1,32 +1,31 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU Affero 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 Affero General Public License for more details.
|
||||
* 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
|
||||
* Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.gui;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorPhase;
|
||||
import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.redstone.RedstonePhase;
|
||||
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -38,7 +37,8 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
||||
private final RedstonePhase redstone;
|
||||
private final SimulatorBaseGui back;
|
||||
|
||||
public SimulatorRedstonePhaseSettingsGui(Player player, Simulator simulator, RedstoneElement redstoneElement, RedstonePhase redstone, SimulatorBaseGui back) {
|
||||
public SimulatorRedstonePhaseSettingsGui(Player player, Simulator simulator, RedstoneElement redstoneElement, RedstonePhase redstone,
|
||||
SimulatorBaseGui back) {
|
||||
super(player, simulator, 5 * 9);
|
||||
this.redstoneElement = redstoneElement;
|
||||
this.redstone = redstone;
|
||||
@ -60,7 +60,7 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, redstoneElement.toItem(player, clickType -> {
|
||||
@ -71,8 +71,8 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
||||
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
||||
redstoneElement.getPhases().remove(redstone);
|
||||
back.open();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||
|
||||
int index = redstoneElement.getPhases().indexOf(redstone);
|
||||
int min;
|
||||
@ -94,75 +94,81 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
||||
maxOffset = Integer.MAX_VALUE - 5;
|
||||
}
|
||||
|
||||
//Tick Offset
|
||||
// Tick Offset
|
||||
int offset = redstone.getTickOffset();
|
||||
inventory.setItem(10, SWItem.getDye(offset < maxOffset ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(10, new SWItem(SWItem.getDye(offset < maxOffset ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
redstone.setTickOffset(Math.min(maxOffset, offset + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
|
||||
SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Start at", offset + "", Integer::parseInt, integer -> {
|
||||
if (integer < 0) return false;
|
||||
if (integer < 0)
|
||||
return false;
|
||||
redstone.setTickOffset(Math.min(Math.max(integer, min), maxOffset));
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).setItem(Material.REPEATER).open();
|
||||
});
|
||||
offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64)));
|
||||
inventory.setItem(19, offsetItem);
|
||||
|
||||
inventory.setItem(28, SWItem.getDye(offset > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(28, new SWItem(SWItem.getDye(offset > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
redstone.setTickOffset(Math.max(min, offset - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Lifetime
|
||||
// Lifetime
|
||||
int lifetime = redstone.getLifetime();
|
||||
inventory.setItem(11, SWItem.getDye(lifetime < maxLifetime ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(11, new SWItem(SWItem.getDye(lifetime < maxLifetime ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
redstone.setLifetime(Math.min(maxLifetime, lifetime + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
|
||||
SWItem lifetimeItem = new SWItem(Material.CLOCK, "§eActivation Time§8:§7 " + lifetime, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Activation Time", lifetime + "", Integer::parseInt, integer -> {
|
||||
if (integer < 0) return false;
|
||||
if (integer < 0)
|
||||
return false;
|
||||
redstone.setLifetime(Math.min(integer, maxLifetime));
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).setItem(Material.CLOCK).open();
|
||||
});
|
||||
lifetimeItem.getItemStack().setAmount(Math.max(1, Math.min(lifetime, 64)));
|
||||
inventory.setItem(20, lifetimeItem);
|
||||
|
||||
inventory.setItem(29, SWItem.getDye(lifetime > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(29, new SWItem(SWItem.getDye(lifetime > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
redstone.setLifetime(Math.max(0, lifetime - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Order
|
||||
// Order
|
||||
int order = redstone.getOrder();
|
||||
inventory.setItem(13, SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
redstone.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
inventory.setItem(13,
|
||||
new SWItem(SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
redstone.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
|
||||
Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR");
|
||||
SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eActivation Order§8:§7 " + order, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Activation Order", order + "", Integer::parseInt, integer -> {
|
||||
if (integer < -SimulatorPhase.ORDER_LIMIT) return false;
|
||||
if (integer > SimulatorPhase.ORDER_LIMIT) return false;
|
||||
if (integer < -SimulatorPhase.ORDER_LIMIT)
|
||||
return false;
|
||||
if (integer > SimulatorPhase.ORDER_LIMIT)
|
||||
return false;
|
||||
redstone.setOrder(integer);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).setItem(order >= 0 ? Material.COMPASS : negativeNumbers).open();
|
||||
});
|
||||
orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30)));
|
||||
inventory.setItem(22, orderItem);
|
||||
|
||||
inventory.setItem(31, SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
redstone.setOrder(Math.max(-SimulatorPhase.ORDER_LIMIT, order - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
inventory.setItem(31,
|
||||
new SWItem(SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
redstone.setOrder(Math.max(-SimulatorPhase.ORDER_LIMIT, order - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,29 +1,28 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU Affero 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 Affero General Public License for more details.
|
||||
* 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
|
||||
* Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.gui;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement;
|
||||
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -55,7 +54,7 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, redstone.toItem(player, clickType -> {
|
||||
@ -64,78 +63,79 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
// Base Tick
|
||||
int baseTicks = redstone.getBaseTick();
|
||||
inventory.setItem(9, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(9, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
redstone.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
|
||||
if (integer < 0) return false;
|
||||
if (integer < 0)
|
||||
return false;
|
||||
redstone.changeBaseTicks(integer - baseTicks);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).setItem(Material.REPEATER).open();
|
||||
});
|
||||
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
|
||||
inventory.setItem(18, baseTick);
|
||||
inventory.setItem(27, SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(27, new SWItem(SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (baseTicks - (clickType.isShiftClick() ? 5 : 1) < 0) {
|
||||
redstone.changeBaseTicks(-baseTicks);
|
||||
} else {
|
||||
redstone.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
|
||||
}
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos X
|
||||
inventory.setItem(15, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
// Pos X
|
||||
inventory.setItem(15, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
redstone.move(clickType.isShiftClick() ? 5 : 1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(24, new SWItem(Material.PAPER, "§eX§8:§7 " + redstone.getPosition().getBlockX(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "X", redstone.getPosition().getBlockX() + "", Integer::parseInt, i -> {
|
||||
redstone.getPosition().setX(i);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(33, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(33, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
redstone.move(clickType.isShiftClick() ? -5 : -1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos Y
|
||||
inventory.setItem(16, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
// Pos Y
|
||||
inventory.setItem(16, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
redstone.move(0, clickType.isShiftClick() ? 5 : 1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(25, new SWItem(Material.PAPER, "§eY§8:§7 " + redstone.getPosition().getBlockY(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Y", redstone.getPosition().getBlockY() + "", Integer::parseInt, i -> {
|
||||
redstone.getPosition().setY(i);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(34, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(34, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
redstone.move(0, clickType.isShiftClick() ? -5 : -1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos Z
|
||||
inventory.setItem(17, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
// Pos Z
|
||||
inventory.setItem(17, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
redstone.move(0, 0, clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ§8:§7 " + redstone.getPosition().getBlockZ(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Z", redstone.getPosition().getBlockZ() + "", Integer::parseInt, i -> {
|
||||
redstone.getPosition().setZ(i);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(35, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(35, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
redstone.move(0, 0, clickType.isShiftClick() ? -5 : -1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,27 +1,26 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU Affero 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 Affero General Public License for more details.
|
||||
* 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
|
||||
* Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.gui;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -47,53 +46,59 @@ public class SimulatorSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, simulator.toItem(player, clickType -> {
|
||||
new SimulatorMaterialGui(player, simulator, simulator::getMaterial, simulator::setMaterial, this).open();
|
||||
}));
|
||||
|
||||
//AutoTrace
|
||||
inventory.setItem(20, new SWItem(simulator.isAutoTrace() ? Material.CHAIN_COMMAND_BLOCK : Material.COMMAND_BLOCK, "§eAutoTrace§8: " + (simulator.isAutoTrace() ? "§aOn" : "§cOff"), clickType -> {
|
||||
simulator.setAutoTrace(!simulator.isAutoTrace());
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
// AutoTrace
|
||||
inventory.setItem(19, new SWItem(simulator.isAutoTrace() ? Material.CHAIN_COMMAND_BLOCK : Material.COMMAND_BLOCK,
|
||||
"§eAutoTrace§8: " + (simulator.isAutoTrace() ? "§aOn" : "§cOff"), clickType -> {
|
||||
simulator.setAutoTrace(!simulator.isAutoTrace());
|
||||
SimulatorRenderer.update(simulator);
|
||||
}));
|
||||
inventory.setItem(20, new SWItem(simulator.isAutoTestblock() ? Material.END_STONE : Material.BARRIER,
|
||||
"§eTestblock§8: " + (simulator.isAutoTestblock() ? "§aOn" : "§cOff"), clickType -> {
|
||||
simulator.setAutoTestblock(!simulator.isAutoTestblock());
|
||||
SimulatorRenderer.update(simulator);
|
||||
}));
|
||||
|
||||
//Pos X
|
||||
inventory.setItem(15, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
// Pos X
|
||||
inventory.setItem(15, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
simulator.move(clickType.isShiftClick() ? 5 : 1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(24, new SWItem(Material.PAPER, "§eX", clickType -> {
|
||||
}));
|
||||
inventory.setItem(33, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(33, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
simulator.move(clickType.isShiftClick() ? -5 : -1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos Y
|
||||
inventory.setItem(16, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
// Pos Y
|
||||
inventory.setItem(16, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
simulator.move(0, clickType.isShiftClick() ? 5 : 1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(25, new SWItem(Material.PAPER, "§eY", clickType -> {
|
||||
}));
|
||||
inventory.setItem(34, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(34, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
simulator.move(0, clickType.isShiftClick() ? -5 : -1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Pos Z
|
||||
inventory.setItem(17, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
// Pos Z
|
||||
inventory.setItem(17, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
simulator.move(0, 0, clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ", clickType -> {
|
||||
}));
|
||||
inventory.setItem(35, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(35, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
simulator.move(0, 0, clickType.isShiftClick() ? -5 : -1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,31 +1,34 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU Affero 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 Affero General Public License for more details.
|
||||
* 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
|
||||
* Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.gui;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
|
||||
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
|
||||
import de.steamwar.bausystem.features.simulator.execute.SimulatorStabGenerator;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorScrollGui;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -55,7 +58,7 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
|
||||
public void headerAndFooter() {
|
||||
if (tnt.getPhases().isEmpty()) {
|
||||
back.open();
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -78,12 +81,12 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
|
||||
new SimulatorGroupGui(player, simulator, newParent, simulatorGui).open();
|
||||
}
|
||||
}
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
||||
tnt.getPhases().clear();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, tnt.toItem(player, clickType -> {
|
||||
@ -92,71 +95,81 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
|
||||
|
||||
inventory.setItem(47, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
||||
new SimulatorTNTSettingsGui(player, simulator, tnt, this).open();
|
||||
}));
|
||||
inventory.setItem(48, new SWItem(tnt.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, tnt.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
|
||||
tnt.setDisabled(!tnt.isDisabled());
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.SETTINGS));
|
||||
inventory.setItem(48,
|
||||
new SWItem(tnt.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, tnt.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
|
||||
tnt.setDisabled(!tnt.isDisabled());
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||
if (Core.getVersion() > 19) {
|
||||
inventory.setItem(49, new SWItem(Material.CALIBRATED_SCULK_SENSOR, "§eCreate Stab", click -> {
|
||||
new SimulatorAnvilGui<>(player, "Depth Limit", "", Integer::parseInt, depthLimit -> {
|
||||
if (depthLimit <= 0)
|
||||
return false;
|
||||
simulator.setStabGenerator(new SimulatorStabGenerator(Region.getRegion(player.getLocation()), simulator, tnt, depthLimit));
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, null).open();
|
||||
}).setCustomModelData(CMDs.Simulator.CREATE_STAB));
|
||||
}
|
||||
inventory.setItem(50, new SWItem(Material.CHEST, parent.getElements().size() == 1 ? "§eMake Group" : "§eAdd another TNT to Group", clickType -> {
|
||||
TNTElement tntElement = new TNTElement(tnt.getPosition().clone());
|
||||
tntElement.add(new TNTPhase());
|
||||
parent.add(tntElement);
|
||||
new SimulatorGroupGui(player, simulator, parent, new SimulatorGui(player, simulator)).open();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.MAKE_GROUP));
|
||||
inventory.setItem(51, new SWItem(Material.LEAD, "§eJoin Group", clickType -> {
|
||||
new SimulatorGroupChooserGui(player, simulator, tnt, tnt.getGroup(simulator), this).open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.Simulator.JOIN_GROUP));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SWItem[] column(TNTPhase tntSetting, int index) {
|
||||
SWItem tnt = new SWItem(Material.TNT, "§eTNT§8:§7 " + tntSetting.getCount(), Arrays.asList("§7Tick§8: §e" + tntSetting.getTickOffset(), "§7Fuse§8:§e " + tntSetting.getLifetime(), "", "§7Order§8:§e " + tntSetting.getOrder(), "", "§7X-Jump§8: " + (tntSetting.isXJump() ? "§aOn" : "§cOff"), "§7Y-Jump§8: " + (tntSetting.isYJump() ? "§aOn" : "§cOff"), "§7Z-Jump§8: " + (tntSetting.isZJump() ? "§aOn" : "§cOff"), "", "§7Click§8:§e Edit", "§7Middle-Click§8:§e Remove"), false, clickType -> {
|
||||
if (clickType == ClickType.MIDDLE) {
|
||||
this.tnt.getPhases().remove(tntSetting);
|
||||
SimulatorWatcher.update(simulator);
|
||||
} else {
|
||||
new SimulatorTNTPhaseSettingsGui(player, simulator, this.tnt, tntSetting, this).open();
|
||||
}
|
||||
});
|
||||
SWItem tnt = new SWItem(Material.TNT, "§eTNT§8:§7 " + tntSetting.getCount(),
|
||||
Arrays.asList("§7Tick§8: §e" + tntSetting.getTickOffset(), "§7Fuse§8:§e " + tntSetting.getLifetime(), "",
|
||||
"§7Order§8:§e " + tntSetting.getOrder(), "", "§7X-Jump§8: " + (tntSetting.isXJump() ? "§aOn" : "§cOff"),
|
||||
"§7Y-Jump§8: " + (tntSetting.isYJump() ? "§aOn" : "§cOff"), "§7Z-Jump§8: " + (tntSetting.isZJump() ? "§aOn" : "§cOff"), "",
|
||||
"§7Click§8:§e Edit", "§7Middle-Click§8:§e Remove"),
|
||||
false, clickType -> {
|
||||
if (clickType == ClickType.MIDDLE) {
|
||||
this.tnt.getPhases().remove(tntSetting);
|
||||
SimulatorRenderer.update(simulator);
|
||||
} else {
|
||||
new SimulatorTNTPhaseSettingsGui(player, simulator, this.tnt, tntSetting, this).open();
|
||||
}
|
||||
});
|
||||
tnt.getItemStack().setAmount(Math.min(tntSetting.getCount(), 64));
|
||||
|
||||
return new SWItem[]{
|
||||
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
tntSetting.setCount(tntSetting.getCount() + (clickType.isShiftClick() ? 5 : 1));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}),
|
||||
tnt,
|
||||
return new SWItem[] {new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
tntSetting.setCount(tntSetting.getCount() + (clickType.isShiftClick() ? 5 : 1));
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED), tnt,
|
||||
new SWItem(SWItem.getDye(tntSetting.getCount() > 1 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8:§e -5"), false, clickType -> {
|
||||
tntSetting.setCount(Math.max(1, tntSetting.getCount() - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
}),
|
||||
new SWItem(Material.ANVIL, "§eEdit Phase", clickType -> {
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED), new SWItem(Material.ANVIL, "§eEdit Phase", clickType -> {
|
||||
new SimulatorTNTPhaseSettingsGui(player, simulator, this.tnt, tntSetting, this).open();
|
||||
}),
|
||||
};
|
||||
}).setCustomModelData(CMDs.Simulator.EDIT_ACTIVATION),};
|
||||
}
|
||||
|
||||
@Override
|
||||
public SWItem[] lastColumn() {
|
||||
return new SWItem[]{
|
||||
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
addNewPhase(clickType.isShiftClick());
|
||||
}),
|
||||
new SWItem(Material.GUNPOWDER, "§eTNT§8:§a New Phase", clickType -> {
|
||||
addNewPhase(false);
|
||||
}),
|
||||
new SWItem(SWItem.getDye(8), "§7", clickType -> {
|
||||
}),
|
||||
};
|
||||
return new SWItem[] {new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||
addNewPhase(clickType.isShiftClick());
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED), new SWItem(Material.GUNPOWDER, "§eTNT§8:§a New Phase", clickType -> {
|
||||
addNewPhase(false);
|
||||
}).setCustomModelData(CMDs.Simulator.NEW_PHASE), new SWItem(SWItem.getDye(8), "§7", clickType -> {
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),};
|
||||
}
|
||||
|
||||
private void addNewPhase(boolean shift) {
|
||||
TNTPhase lastElement = tnt.getPhases().get(tnt.getPhases().size() - 1);
|
||||
TNTPhase newPhase = new TNTPhase(lastElement.getTickOffset() + 1);
|
||||
if (shift) newPhase.setCount(newPhase.getCount() + 5);
|
||||
if (shift)
|
||||
newPhase.setCount(newPhase.getCount() + 5);
|
||||
scroll++;
|
||||
tnt.add(newPhase);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,32 +1,31 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU Affero 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 Affero General Public License for more details.
|
||||
* 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
|
||||
* Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.gui;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.SimulatorPhase;
|
||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
|
||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
|
||||
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -60,136 +59,146 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
// Material Chooser
|
||||
inventory.setItem(4, tntElement.toItem(player, clickType -> {
|
||||
new SimulatorMaterialGui(player, simulator, tntElement::getMaterial, tntElement::setMaterial, this).open();
|
||||
}));
|
||||
|
||||
//Delete
|
||||
// Delete
|
||||
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
||||
tntElement.getPhases().remove(tnt);
|
||||
back.open();
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||
|
||||
//Count
|
||||
// Count
|
||||
int count = tnt.getCount();
|
||||
inventory.setItem(9, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(9, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
tnt.setCount(count + (clickType.isShiftClick() ? 5 : 1));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
|
||||
SWItem countItem = new SWItem(Material.TNT, "§eCount§8:§7 " + count, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Count", count + "", Integer::parseInt, integer -> {
|
||||
if (integer < 1) return false;
|
||||
if (integer < 1)
|
||||
return false;
|
||||
tnt.setCount(integer);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).setItem(Material.TNT).open();
|
||||
});
|
||||
countItem.getItemStack().setAmount(Math.max(1, Math.min(count, 64)));
|
||||
inventory.setItem(18, countItem);
|
||||
|
||||
inventory.setItem(27, SWItem.getDye(count > 1 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(27, new SWItem(SWItem.getDye(count > 1 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
tnt.setCount(Math.max(1, count - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Tick Offset
|
||||
// Tick Offset
|
||||
int offset = tnt.getTickOffset();
|
||||
inventory.setItem(10, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(10, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
tnt.setTickOffset(offset + (clickType.isShiftClick() ? 5 : 1));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
|
||||
SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Start at", offset + "", Integer::parseInt, integer -> {
|
||||
if (integer < 0) return false;
|
||||
if (integer < 0)
|
||||
return false;
|
||||
tnt.setTickOffset(integer);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).setItem(Material.REPEATER).open();
|
||||
});
|
||||
offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64)));
|
||||
inventory.setItem(19, offsetItem);
|
||||
|
||||
inventory.setItem(28, SWItem.getDye(offset > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(28, new SWItem(SWItem.getDye(offset > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
tnt.setTickOffset(Math.max(0, offset - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Lifetime
|
||||
// Lifetime
|
||||
int lifetime = tnt.getLifetime();
|
||||
inventory.setItem(11, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(11, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
tnt.setLifetime(lifetime + (clickType.isShiftClick() ? 5 : 1));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
|
||||
SWItem lifetimeItem = new SWItem(Material.CLOCK, "§eLifetime§8:§7 " + lifetime, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Lifetime", lifetime + "", Integer::parseInt, integer -> {
|
||||
if (integer < 1) return false;
|
||||
if (integer < 1)
|
||||
return false;
|
||||
tnt.setLifetime(integer);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).setItem(Material.CLOCK).open();
|
||||
});
|
||||
lifetimeItem.getItemStack().setAmount(Math.max(1, Math.min(lifetime, 64)));
|
||||
inventory.setItem(20, lifetimeItem);
|
||||
|
||||
inventory.setItem(29, SWItem.getDye(lifetime > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(29, new SWItem(SWItem.getDye(lifetime > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
tnt.setLifetime(Math.max(1, lifetime - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Order
|
||||
// Order
|
||||
int order = tnt.getOrder();
|
||||
inventory.setItem(13, SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
tnt.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
inventory.setItem(13,
|
||||
new SWItem(SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
tnt.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
|
||||
Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR");
|
||||
SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eCalculation Order§8:§7 " + order, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Calculation Order", order + "", Integer::parseInt, integer -> {
|
||||
if (integer < -SimulatorPhase.ORDER_LIMIT) return false;
|
||||
if (integer > SimulatorPhase.ORDER_LIMIT) return false;
|
||||
if (integer < -SimulatorPhase.ORDER_LIMIT)
|
||||
return false;
|
||||
if (integer > SimulatorPhase.ORDER_LIMIT)
|
||||
return false;
|
||||
tnt.setOrder(integer);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).setItem(order >= 0 ? Material.COMPASS : negativeNumbers).open();
|
||||
});
|
||||
orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30)));
|
||||
inventory.setItem(22, orderItem);
|
||||
|
||||
inventory.setItem(31, SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
tnt.setOrder(Math.max(-SimulatorPhase.ORDER_LIMIT, order - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
inventory.setItem(31,
|
||||
new SWItem(SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
tnt.setOrder(Math.max(-SimulatorPhase.ORDER_LIMIT, order - (clickType.isShiftClick() ? 5 : 1)));
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
//Jump
|
||||
SWItem jumpX = new SWItem(tnt.isXJump() ? Material.LIME_WOOL : Material.RED_WOOL, "§7TNT §eJump X§8: " + (tnt.isZJump() ? "§aon" : "§coff"), clickType -> {
|
||||
tnt.setXJump(!tnt.isXJump());
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
// Jump
|
||||
SWItem jumpX =
|
||||
new SWItem(tnt.isXJump() ? Material.LIME_WOOL : Material.RED_WOOL, "§7TNT §eJump X§8: " + (tnt.isZJump() ? "§aon" : "§coff"), clickType -> {
|
||||
tnt.setXJump(!tnt.isXJump());
|
||||
SimulatorRenderer.update(simulator);
|
||||
});
|
||||
inventory.setItem(33, jumpX);
|
||||
|
||||
SWItem jumpY = new SWItem(tnt.isYJump() ? Material.LIME_WOOL : Material.RED_WOOL, "§7TNT §eJump Y§8: " + (tnt.isYJump() ? "§aon" : "§coff"), clickType -> {
|
||||
tnt.setYJump(!tnt.isYJump());
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SWItem jumpY =
|
||||
new SWItem(tnt.isYJump() ? Material.LIME_WOOL : Material.RED_WOOL, "§7TNT §eJump Y§8: " + (tnt.isYJump() ? "§aon" : "§coff"), clickType -> {
|
||||
tnt.setYJump(!tnt.isYJump());
|
||||
SimulatorRenderer.update(simulator);
|
||||
});
|
||||
inventory.setItem(16, jumpY);
|
||||
|
||||
SWItem jumpZ = new SWItem(tnt.isZJump() ? Material.LIME_WOOL : Material.RED_WOOL, "§7TNT §eJump Z§8: " + (tnt.isZJump() ? "§aon" : "§coff"), clickType -> {
|
||||
tnt.setZJump(!tnt.isZJump());
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SWItem jumpZ =
|
||||
new SWItem(tnt.isZJump() ? Material.LIME_WOOL : Material.RED_WOOL, "§7TNT §eJump Z§8: " + (tnt.isZJump() ? "§aon" : "§coff"), clickType -> {
|
||||
tnt.setZJump(!tnt.isZJump());
|
||||
SimulatorRenderer.update(simulator);
|
||||
});
|
||||
inventory.setItem(35, jumpZ);
|
||||
|
||||
SWItem jumpAll = new SWItem(Material.TNT, "§7TNT §eJump §8: " + (tnt.hasJump() ? "§aon" : "§coff"), clickType -> {
|
||||
tnt.setJump(!tnt.hasJump());
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
});
|
||||
inventory.setItem(25, jumpAll);
|
||||
}
|
||||
|
||||
@ -1,33 +1,31 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU Affero 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 Affero General Public License for more details.
|
||||
* 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
|
||||
* Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.gui;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
|
||||
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -58,7 +56,7 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
|
||||
// Back Arrow
|
||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||
back.open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
|
||||
// Material Chooser
|
||||
List<String> lore = new ArrayList<>();
|
||||
@ -74,115 +72,120 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
// Base Tick
|
||||
int baseTicks = tnt.getBaseTick();
|
||||
inventory.setItem(9, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
inventory.setItem(9, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
||||
tnt.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
|
||||
if (integer < 0) return false;
|
||||
if (integer < 0)
|
||||
return false;
|
||||
tnt.changeBaseTicks(integer - baseTicks);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).setItem(Material.REPEATER).open();
|
||||
});
|
||||
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
|
||||
inventory.setItem(18, baseTick);
|
||||
inventory.setItem(27, SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
inventory.setItem(27, new SWItem(SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
|
||||
if (baseTicks - (clickType.isShiftClick() ? 5 : 1) < 0) {
|
||||
tnt.changeBaseTicks(-baseTicks);
|
||||
} else {
|
||||
tnt.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
|
||||
}
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
// Subpixel Alignment
|
||||
inventory.setItem(21, new SWItem(Material.SUNFLOWER, "§7Align§8: §eCenter", clickType -> {
|
||||
tnt.alignX(0);
|
||||
tnt.alignZ(0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
}));
|
||||
|
||||
// Z
|
||||
SWItem negativZItem = new SWItem(Material.OAK_BUTTON, "§7Align§8: §eNegativ Z", clickType -> {
|
||||
if (tnt.getAlignment().getZ() != -1) tnt.alignZ(-1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
if (tnt.getAlignment().getZ() != -1)
|
||||
tnt.alignZ(-1);
|
||||
SimulatorRenderer.update(simulator);
|
||||
});
|
||||
negativZItem.setEnchanted(tnt.getAlignment().getZ() == -1);
|
||||
inventory.setItem(20, negativZItem);
|
||||
|
||||
SWItem positivZItem = new SWItem(Material.OAK_BUTTON, "§7Align§8: §ePositiv Z", clickType -> {
|
||||
if (tnt.getAlignment().getZ() != 1) tnt.alignZ(1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
if (tnt.getAlignment().getZ() != 1)
|
||||
tnt.alignZ(1);
|
||||
SimulatorRenderer.update(simulator);
|
||||
});
|
||||
positivZItem.setEnchanted(tnt.getAlignment().getZ() == 1);
|
||||
inventory.setItem(22, positivZItem);
|
||||
|
||||
// X
|
||||
SWItem negativXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §eNegativ X", clickType -> {
|
||||
if (tnt.getAlignment().getX() != -1) tnt.alignX(-1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
if (tnt.getAlignment().getX() != -1)
|
||||
tnt.alignX(-1);
|
||||
SimulatorRenderer.update(simulator);
|
||||
});
|
||||
negativXItem.setEnchanted(tnt.getAlignment().getX() == -1);
|
||||
inventory.setItem(12, negativXItem);
|
||||
|
||||
SWItem positivXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §ePositiv X", clickType -> {
|
||||
if(tnt.getAlignment().getX() != 1) tnt.alignX(1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SWItem positivXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §ePositiv X", clickType -> {
|
||||
if (tnt.getAlignment().getX() != 1)
|
||||
tnt.alignX(1);
|
||||
SimulatorRenderer.update(simulator);
|
||||
});
|
||||
positivXItem.setEnchanted(tnt.getAlignment().getX() == 1);
|
||||
inventory.setItem(30, positivXItem);
|
||||
|
||||
// Pos X
|
||||
inventory.setItem(15, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
|
||||
inventory.setItem(15, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
|
||||
tnt.move(clickType.isShiftClick() ? 0.0625 : 1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(24, new SWItem(Material.PAPER, "§eX§8:§7 " + tnt.getPosition().getX(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "X", tnt.getPosition().getX() + "", Double::parseDouble, d -> {
|
||||
tnt.getPosition().setX(d);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(33, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
|
||||
inventory.setItem(33, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
|
||||
tnt.move(clickType.isShiftClick() ? -0.0625 : -1, 0, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
// Pos Y
|
||||
inventory.setItem(16, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
|
||||
inventory.setItem(16, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
|
||||
tnt.move(0, clickType.isShiftClick() ? 0.0625 : 1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(25, new SWItem(Material.PAPER, "§eY§8:§7 " + tnt.getPosition().getY(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Y", tnt.getPosition().getY() + "", Double::parseDouble, d -> {
|
||||
tnt.getPosition().setY(d);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(34, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
|
||||
inventory.setItem(34, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
|
||||
tnt.move(0, clickType.isShiftClick() ? -0.0625 : -1, 0);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
|
||||
// Pos Z
|
||||
inventory.setItem(17, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
|
||||
inventory.setItem(17, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
|
||||
tnt.move(0, 0, clickType.isShiftClick() ? 0.0625 : 1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ§8:§7 " + tnt.getPosition().getZ(), clickType -> {
|
||||
new SimulatorAnvilGui<>(player, "Z", tnt.getPosition().getZ() + "", Double::parseDouble, d -> {
|
||||
tnt.getPosition().setZ(d);
|
||||
SimulatorWatcher.update(simulator);
|
||||
SimulatorRenderer.update(simulator);
|
||||
return true;
|
||||
}, this).open();
|
||||
}));
|
||||
inventory.setItem(35, SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
|
||||
inventory.setItem(35, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
|
||||
tnt.move(0, 0, clickType.isShiftClick() ? -0.0625 : -1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
});
|
||||
SimulatorRenderer.update(simulator);
|
||||
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ public class SimulatorAnvilGui<T extends Number> {
|
||||
if (error.get()) {
|
||||
anvilInv.open();
|
||||
} else {
|
||||
back.open();
|
||||
if (back != null) back.open();
|
||||
}
|
||||
error.set(false);
|
||||
}, 0);
|
||||
|
||||
@ -1,28 +1,25 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU Affero 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 Affero General Public License for more details.
|
||||
* 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
|
||||
* Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License along with this program.
|
||||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.simulator.gui.base;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.TrickyTrialsWrapper;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -46,6 +43,9 @@ public abstract class SimulatorBaseGui {
|
||||
}
|
||||
|
||||
public final void open() {
|
||||
if (!shouldOpen())
|
||||
return;
|
||||
|
||||
String newTitle = title();
|
||||
String originalTitle = player.getOpenInventory().getTitle();
|
||||
|
||||
@ -57,15 +57,17 @@ public abstract class SimulatorBaseGui {
|
||||
setup();
|
||||
if (player.getOpenInventory().getTopInventory() != inv) {
|
||||
inventory.open();
|
||||
SimulatorWatcher.watch(player, simulator, this::open);
|
||||
}
|
||||
if (Core.getVersion() > 19) {
|
||||
player.getOpenInventory().setTitle(title());
|
||||
}
|
||||
populate();
|
||||
if (simulator != null && simulator.getStabGenerator() != null) {
|
||||
populateStabGenerator();
|
||||
} else {
|
||||
populate();
|
||||
}
|
||||
if (player.getOpenInventory().getTopInventory() == inv) {
|
||||
inventory.open();
|
||||
SimulatorWatcher.watch(player, simulator, this::open);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -77,15 +79,26 @@ public abstract class SimulatorBaseGui {
|
||||
return inv;
|
||||
});
|
||||
setup();
|
||||
inventory.addCloseCallback(clickType -> {
|
||||
SimulatorWatcher.watch(player, null, null);
|
||||
});
|
||||
|
||||
SimulatorWatcher.watch(player, simulator, this::open);
|
||||
populate();
|
||||
if (simulator != null && simulator.getStabGenerator() != null) {
|
||||
populateStabGenerator();
|
||||
} else {
|
||||
populate();
|
||||
}
|
||||
inventory.open();
|
||||
}
|
||||
|
||||
private void populateStabGenerator() {
|
||||
inventory.setItem(22, new SWItem(Material.BARRIER, "§cCancel Stab Generator", click -> {
|
||||
simulator.getStabGenerator().cancel();
|
||||
SimulatorRenderer.update(simulator);
|
||||
}));
|
||||
}
|
||||
|
||||
public boolean shouldOpen() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setup() {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
inventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§8", clickType -> {
|
||||
|
||||
@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.simulator.gui.base;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -50,19 +51,19 @@ public abstract class SimulatorPageGui<T> extends SimulatorBaseGui {
|
||||
headerAndFooter();
|
||||
page = Math.min(page, maxPage());
|
||||
|
||||
inventory.setItem(size - 9, SWItem.getDye(page > 0 ? 10 : 8), page > 0 ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(page > 0 ? "SWLISINV_PREVIOUS_PAGE_ACTIVE" : "SWLISINV_PREVIOUS_PAGE_INACTIVE", player), clickType -> {
|
||||
inventory.setItem(size - 9, new SWItem(SWItem.getDye(page > 0 ? 10 : 8), page > 0 ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(page > 0 ? "SWLISINV_PREVIOUS_PAGE_ACTIVE" : "SWLISINV_PREVIOUS_PAGE_INACTIVE", player), clickType -> {
|
||||
if (page > 0) {
|
||||
page--;
|
||||
open();
|
||||
}
|
||||
});
|
||||
}).setCustomModelData(CMDs.PREVIOUS_PAGE));
|
||||
boolean hasNext = page < maxPage() - (data.size() % (size - 18) == 0 ? 1 : 0);
|
||||
inventory.setItem(size - 1, SWItem.getDye(hasNext ? 10 : 8), hasNext ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(hasNext ? "SWLISINV_NEXT_PAGE_ACTIVE" : "SWLISINV_NEXT_PAGE_INACTIVE", player), clickType -> {
|
||||
inventory.setItem(size - 1, new SWItem(SWItem.getDye(hasNext ? 10 : 8), hasNext ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(hasNext ? "SWLISINV_NEXT_PAGE_ACTIVE" : "SWLISINV_NEXT_PAGE_INACTIVE", player), clickType -> {
|
||||
if (hasNext) {
|
||||
page++;
|
||||
open();
|
||||
}
|
||||
});
|
||||
}).setCustomModelData(CMDs.NEXT_PAGE));
|
||||
|
||||
int minElement = page * (size - 18);
|
||||
int maxElement = Math.min(data.size(), (page + 1) * (size - 18));
|
||||
|
||||
@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.simulator.gui.base;
|
||||
|
||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -50,19 +51,19 @@ public abstract class SimulatorScrollGui<T> extends SimulatorBaseGui {
|
||||
headerAndFooter();
|
||||
scroll = maxScroll();
|
||||
|
||||
inventory.setItem(size - 9, SWItem.getDye(scroll > 0 ? 10 : 8), scroll > 0 ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(scroll > 0 ? "SWLISINV_PREVIOUS_PAGE_ACTIVE" : "SWLISINV_PREVIOUS_PAGE_INACTIVE", player), clickType -> {
|
||||
inventory.setItem(size - 9, new SWItem(SWItem.getDye(scroll > 0 ? 10 : 8), scroll > 0 ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(scroll > 0 ? "SWLISINV_PREVIOUS_PAGE_ACTIVE" : "SWLISINV_PREVIOUS_PAGE_INACTIVE", player), clickType -> {
|
||||
if (scroll > 0) {
|
||||
scroll = Math.max(0, scroll - 9);
|
||||
open();
|
||||
}
|
||||
});
|
||||
}).setCustomModelData(CMDs.PREVIOUS_PAGE));
|
||||
boolean hasNext = (data.size() + 1) - scroll > 9;
|
||||
inventory.setItem(size - 1, SWItem.getDye(hasNext ? 10 : 8), hasNext ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(hasNext ? "SWLISINV_NEXT_PAGE_ACTIVE" : "SWLISINV_NEXT_PAGE_INACTIVE", player), clickType -> {
|
||||
inventory.setItem(size - 1, new SWItem(SWItem.getDye(hasNext ? 10 : 8), hasNext ? (byte) 10 : (byte) 8, Core.MESSAGE.parse(hasNext ? "SWLISINV_NEXT_PAGE_ACTIVE" : "SWLISINV_NEXT_PAGE_INACTIVE", player), clickType -> {
|
||||
if (hasNext) {
|
||||
scroll = Math.min(scroll + 9, data.size() + 1 - 9);
|
||||
open();
|
||||
}
|
||||
});
|
||||
}).setCustomModelData(CMDs.NEXT_PAGE));
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (scroll + i < data.size()) {
|
||||
|
||||
@ -68,6 +68,7 @@ public class SimFormatSimulatorLoader implements SimulatorLoader {
|
||||
private void loadSimulator(YAPIONObject simulatorObject, Simulator simulator) {
|
||||
simulator.setMaterial(Material.valueOf(simulatorObject.getPlainValue("material")));
|
||||
simulator.setAutoTrace(simulatorObject.getPlainValue("autoTrace"));
|
||||
simulator.setAutoTestblock(simulatorObject.getPlainValueOrDefault("autoTestblock", false));
|
||||
|
||||
YAPIONArray groups = simulatorObject.getArray("groups");
|
||||
groups.streamObject().forEach(groupObject -> {
|
||||
|
||||
@ -39,6 +39,7 @@ public class SimulatorSaver {
|
||||
YAPIONObject simulatorObject = new YAPIONObject();
|
||||
simulatorObject.add("material", simulator.getMaterial().name());
|
||||
simulatorObject.add("autoTrace", simulator.isAutoTrace());
|
||||
simulatorObject.add("autoTestblock", simulator.isAutoTestblock());
|
||||
|
||||
YAPIONArray groups = new YAPIONArray();
|
||||
simulator.getGroups().forEach(group -> {
|
||||
|
||||
@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.slaves.laufbau;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.shared.Pair;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
import org.bukkit.Material;
|
||||
@ -59,7 +60,7 @@ public class LaufbauSettings {
|
||||
open();
|
||||
return;
|
||||
}
|
||||
if (clickType.isCreativeAction()) {
|
||||
if (clickType.isLeftClick()) {
|
||||
open(entry.getKey());
|
||||
return;
|
||||
}
|
||||
@ -91,7 +92,7 @@ public class LaufbauSettings {
|
||||
});
|
||||
inv.setItem(49, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("LAUFBAU_SETTINGS_GUI_BACK", p), clickType -> {
|
||||
open();
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
inv.open();
|
||||
}
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||
import de.steamwar.core.Core;
|
||||
import lombok.Getter;
|
||||
import lombok.SneakyThrows;
|
||||
import org.bukkit.Location;
|
||||
@ -56,7 +57,7 @@ public class Panzern {
|
||||
|
||||
private BaseBlock blockType;
|
||||
private BaseBlock slabType;
|
||||
private static final BaseBlock jukeboxType = BlockTypes.JUKEBOX.getDefaultState().toBaseBlock();
|
||||
private static final BaseBlock jukeboxType = (Core.getVersion() > 19 ? BlockTypes.get("lodestone"): BlockTypes.get("jukebox")).getDefaultState().toBaseBlock();
|
||||
private static final BaseBlock cobwebType = BlockTypes.COBWEB.getDefaultState().toBaseBlock();
|
||||
private static final BaseBlock airType = BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||
|
||||
|
||||
@ -19,8 +19,8 @@
|
||||
|
||||
package de.steamwar.bausystem.features.smartplace;
|
||||
|
||||
import de.steamwar.Reflection;
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.configplayer.Config;
|
||||
@ -57,6 +57,7 @@ public class SmartPlaceListener implements Listener {
|
||||
static {
|
||||
World world = Bukkit.getWorlds().get(0);
|
||||
Block block = world.getBlockAt(0, 0, 0);
|
||||
block.setType(Material.AIR);
|
||||
BlockState state = block.getState();
|
||||
for (Material material : Material.values()) {
|
||||
if (material.isLegacy()) continue;
|
||||
@ -68,6 +69,7 @@ public class SmartPlaceListener implements Listener {
|
||||
} else if (blockData instanceof Stairs) {
|
||||
CONTAINERS.add(material);
|
||||
}
|
||||
state.update(true, false);
|
||||
}
|
||||
CONTAINERS.add(Material.GRINDSTONE);
|
||||
CONTAINERS.remove(Material.COMPARATOR);
|
||||
@ -223,7 +225,7 @@ public class SmartPlaceListener implements Listener {
|
||||
Block block = event.getBlock().getRelative(BlockFace.DOWN);
|
||||
BlockState old = block.getState();
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
block.setType(Material.GLASS);
|
||||
block.setType(Material.GLASS, true);
|
||||
old.update(true, false);
|
||||
}, 1);
|
||||
}
|
||||
|
||||
@ -1,20 +1,20 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
* 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.tpslimit;
|
||||
@ -42,16 +42,16 @@ public class TPSCommand extends SWCommand {
|
||||
public void genericCommand(Player p, String... args) {
|
||||
BauSystem.MESSAGE.sendPrefixless("OTHER_TPS_HEAD", p);
|
||||
BauSystem.MESSAGE.sendPrefixless("OTHER_TPS_MESSAGE", p,
|
||||
TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_SECOND),
|
||||
TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_SECONDS),
|
||||
TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_MINUTE),
|
||||
TPSWatcher.getTPS(TPSWatcher.TPSType.FIVE_MINUTES),
|
||||
TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES)
|
||||
TPSWatcher.getTPSUnlimited(TPSWatcher.TPSType.ONE_SECOND),
|
||||
TPSWatcher.getTPSUnlimited(TPSWatcher.TPSType.TEN_SECONDS),
|
||||
TPSWatcher.getTPSUnlimited(TPSWatcher.TPSType.ONE_MINUTE),
|
||||
TPSWatcher.getTPSUnlimited(TPSWatcher.TPSType.FIVE_MINUTES),
|
||||
TPSWatcher.getTPSUnlimited(TPSWatcher.TPSType.TEN_MINUTES)
|
||||
);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p, TPSWatcher.TPSType type) {
|
||||
BauSystem.MESSAGE.sendPrefixless("OTHER_TPS_SINGLE", p, tpsSystem.getTPS(type));
|
||||
BauSystem.MESSAGE.sendPrefixless("OTHER_TPS_SINGLE", p, TPSWatcher.getTPSUnlimited(type));
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,18 +27,17 @@ import de.steamwar.bausystem.region.GlobalRegion;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.bausystem.utils.TickEndEvent;
|
||||
import de.steamwar.bausystem.utils.TickManager;
|
||||
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
||||
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
||||
import de.steamwar.command.AbstractSWCommand;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.TPSWarpUtils;
|
||||
import de.steamwar.core.TPSWatcher;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.boss.BarColor;
|
||||
@ -53,92 +52,59 @@ import java.util.Arrays;
|
||||
@Linked
|
||||
public class TPSSystem implements Listener {
|
||||
|
||||
@Getter
|
||||
private double currentTPSLimit = 20;
|
||||
|
||||
public double getTPS(TPSWatcher.TPSType tpsType) {
|
||||
return TPSWatcher.getTPSUnlimited(tpsType);
|
||||
}
|
||||
|
||||
public TPSSystem() {
|
||||
if (TPSFreezeUtils.isCanFreeze()) {
|
||||
if (TickManager.impl.canFreeze()) {
|
||||
new TPSFreezeCommand();
|
||||
new TickFreezeCommand();
|
||||
new TickStepCommand();
|
||||
}
|
||||
new TPSLimitCommand();
|
||||
new TickLimitCommand();
|
||||
if (Core.getVersion() >= 15 && Core.getVersion() <= 20) { // If 1.21 support is not directly present
|
||||
if (Core.getVersion() >= 15) {
|
||||
new TPSWarpCommand();
|
||||
new TickWarpCommand();
|
||||
if (TPSFreezeUtils.isCanFreeze()) {
|
||||
if (TickManager.impl.canFreeze()) {
|
||||
new TickWarpingCommand();
|
||||
}
|
||||
}
|
||||
if (Core.getVersion() >= 21) {
|
||||
new Tick21Command();
|
||||
}
|
||||
new TPSDefaultCommand();
|
||||
new TickDefaultCommand();
|
||||
new TPSBaseCommand();
|
||||
new TickBaseCommand();
|
||||
}
|
||||
|
||||
private void setTPS(double tps) {
|
||||
if (currentlyStepping) {
|
||||
currentlyStepping = false;
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
BossBarService.instance.remove(player, GlobalRegion.getInstance(), "TickStep");
|
||||
});
|
||||
}
|
||||
TPSWarpUtils.warp(tps);
|
||||
if (currentTPSLimit == 0 && tps != 0) {
|
||||
TPSFreezeUtils.unfreeze();
|
||||
}
|
||||
currentTPSLimit = tps;
|
||||
if (tps == 0) {
|
||||
TPSLimitUtils.unlimit();
|
||||
TPSFreezeUtils.freeze();
|
||||
} else if (tps < 20.0) {
|
||||
TPSLimitUtils.limit(tps);
|
||||
} else if (tps >= 20) {
|
||||
TPSLimitUtils.unlimit();
|
||||
}
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
if (currentTPSLimit == 0) {
|
||||
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("TPSLIMIT_FROZEN", player));
|
||||
} else {
|
||||
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("TPSLIMIT_SET", player, currentTPSLimit));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean currentlyStepping = false;
|
||||
private double currentLimit;
|
||||
private int stepsTotal;
|
||||
private int stepsLeft;
|
||||
|
||||
private void setSkip(int steps, double tpsLimitToUse) {
|
||||
currentLimit = tpsLimitToUse == 20 ? 0 : currentTPSLimit;
|
||||
setTPS(tpsLimitToUse);
|
||||
stepsLeft = steps;
|
||||
stepsTotal = steps;
|
||||
currentlyStepping = true;
|
||||
Bukkit.getPluginManager().registerEvents(TickManager.impl, BauSystem.getInstance());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTickEnd(TickEndEvent event) {
|
||||
if (!currentlyStepping) return;
|
||||
if (stepsTotal > 1) {
|
||||
bossbar();
|
||||
}
|
||||
|
||||
private void bossbar() {
|
||||
if ((TickManager.impl.isStepping() || TickManager.impl.isSprinting()) && TickManager.impl.getRemainingTicks() > 0) {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
BauSystemBossbar bossbar = BossBarService.instance.get(player, GlobalRegion.getInstance(), "TickStep");
|
||||
bossbar.setColor(BarColor.YELLOW);
|
||||
bossbar.setTitle(BauSystem.MESSAGE.parse("TICK_BOSSBAR", player, (stepsTotal - stepsLeft), stepsTotal));
|
||||
bossbar.setProgress((stepsTotal - stepsLeft) / (double) stepsTotal);
|
||||
bossbar.setTitle(BauSystem.MESSAGE.parse("TICK_BOSSBAR", player, TickManager.impl.getDoneTicks(), TickManager.impl.getTotalTicks()));
|
||||
bossbar.setProgress(TickManager.impl.getDoneTicks() / (double) TickManager.impl.getTotalTicks());
|
||||
});
|
||||
} else {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
BossBarService.instance.remove(player, GlobalRegion.getInstance(), "TickStep");
|
||||
});
|
||||
}
|
||||
stepsLeft--;
|
||||
if (stepsLeft <= 0) {
|
||||
setTPS(currentLimit);
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendTickRateChange() {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
if (TickManager.impl.isFrozen()) {
|
||||
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("TPSLIMIT_FROZEN", player));
|
||||
} else {
|
||||
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("TPSLIMIT_SET", player, TickManager.impl.getTickRate()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private class TPSBaseCommand extends SWCommand {
|
||||
@ -159,7 +125,8 @@ public class TPSSystem implements Listener {
|
||||
|
||||
@Register(value = "0", description = "TPSLIMIT_FREEZE_HELP")
|
||||
public void freeze(@Validator Player player) {
|
||||
setTPS(0);
|
||||
TickManager.impl.setFreeze(true);
|
||||
sendTickRateChange();
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,8 +138,9 @@ public class TPSSystem implements Listener {
|
||||
}
|
||||
|
||||
@Register(description = "TPSLIMIT_LIMIT_HELP")
|
||||
public void limit(@Validator Player player, @Min(doubleValue = 0.5) @Max(doubleValue = 20.0) double tpsLimit) {
|
||||
setTPS(tpsLimit);
|
||||
public void limit(@Validator Player player, @Min(doubleValue = 0.5) @Max(doubleValue = 20.0) float tpsLimit) {
|
||||
TickManager.impl.setTickRate(tpsLimit);
|
||||
sendTickRateChange();
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,8 +152,9 @@ public class TPSSystem implements Listener {
|
||||
}
|
||||
|
||||
@Register(description = "TPSLIMIT_WARP_HELP")
|
||||
public void warp(@Validator Player player, @Min(doubleValue = 20.0, inclusive = false) double tpsLimit) {
|
||||
setTPS(tpsLimit);
|
||||
public void warp(@Validator Player player, @Min(doubleValue = 20.0, inclusive = false) float tpsLimit) {
|
||||
TickManager.impl.setTickRate(tpsLimit);
|
||||
sendTickRateChange();
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,12 +167,13 @@ public class TPSSystem implements Listener {
|
||||
|
||||
@Register(description = "TPSLIMIT_HELP")
|
||||
public void currentLimit(Player player) {
|
||||
BauSystem.MESSAGE.send("TPSLIMIT_CURRENT", player, currentTPSLimit);
|
||||
BauSystem.MESSAGE.send("TPSLIMIT_CURRENT", player, TickManager.impl.getTickRate());
|
||||
}
|
||||
|
||||
@Register(value = "default", description = "TPSLIMIT_DEFAULT_HELP")
|
||||
public void reset(@Validator Player player) {
|
||||
setTPS(20);
|
||||
TickManager.impl.setTickRate(20.0F);
|
||||
sendTickRateChange();
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,12 +195,14 @@ public class TPSSystem implements Listener {
|
||||
@Register(value = {"rate", "0"}, description = "TICK_FREEZE_HELP")
|
||||
@Register(value = "freeze", description = "TICK_FREEZE_HELP_2")
|
||||
public void freeze(@Validator Player player) {
|
||||
setTPS(0);
|
||||
TickManager.impl.setFreeze(true);
|
||||
sendTickRateChange();
|
||||
}
|
||||
|
||||
@Register(value = "unfreeze", description = "TICK_UNFREEZE_HELP")
|
||||
public void unfreeze(@Validator Player player) {
|
||||
setTPS(20);
|
||||
TickManager.impl.setTickRate(20.0F);
|
||||
sendTickRateChange();
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,7 +215,9 @@ public class TPSSystem implements Listener {
|
||||
|
||||
@Register(value = "step", description = "TICK_STEPPING_HELP")
|
||||
public void step(@Validator Player player, @Min(intValue = 1) @OptionalValue("1") int steps) {
|
||||
setSkip(steps, 20);
|
||||
TickManager.impl.stepTicks(steps);
|
||||
sendTickRateChange();
|
||||
bossbar();
|
||||
}
|
||||
}
|
||||
|
||||
@ -255,8 +229,9 @@ public class TPSSystem implements Listener {
|
||||
}
|
||||
|
||||
@Register(value = "warp", description = "TICK_WARPING_HELP")
|
||||
public void warp(@Validator Player player, @Min(intValue = 1) @OptionalValue("1") int steps, @Min(doubleValue = 20) @OptionalValue("4000") double tps) {
|
||||
setSkip(steps, tps);
|
||||
public void warp(@Validator Player player, @Min(intValue = 1) @OptionalValue("1") int steps) {
|
||||
TickManager.impl.sprintTicks(steps);
|
||||
sendTickRateChange();
|
||||
}
|
||||
}
|
||||
|
||||
@ -268,8 +243,9 @@ public class TPSSystem implements Listener {
|
||||
}
|
||||
|
||||
@Register(value = "rate", description = "TICK_LIMIT_HELP")
|
||||
public void limit(@Validator Player player, @Min(doubleValue = 0.5, inclusive = false) @Max(doubleValue = 20.0) double tpsLimit) {
|
||||
setTPS(tpsLimit);
|
||||
public void limit(@Validator Player player, @Min(doubleValue = 0.5, inclusive = false) @Max(doubleValue = 20.0) float tpsLimit) {
|
||||
TickManager.impl.setTickRate(tpsLimit);
|
||||
sendTickRateChange();
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,8 +257,9 @@ public class TPSSystem implements Listener {
|
||||
}
|
||||
|
||||
@Register(value = "rate", description = "TICK_WARP_HELP")
|
||||
public void warp(@Validator Player player, @Min(doubleValue = 20.0, inclusive = false) double tpsLimit) {
|
||||
setTPS(tpsLimit);
|
||||
public void warp(@Validator Player player, @Min(doubleValue = 20.0, inclusive = false) float tpsLimit) {
|
||||
TickManager.impl.setTickRate(tpsLimit);
|
||||
sendTickRateChange();
|
||||
}
|
||||
}
|
||||
|
||||
@ -295,12 +272,31 @@ public class TPSSystem implements Listener {
|
||||
|
||||
@Register(value = "rate", description = "TICK_HELP")
|
||||
public void currentLimit(Player player) {
|
||||
BauSystem.MESSAGE.send("TPSLIMIT_CURRENT", player, currentTPSLimit);
|
||||
BauSystem.MESSAGE.send("TPSLIMIT_CURRENT", player, TickManager.impl.getTickRate());
|
||||
}
|
||||
|
||||
@Register(value = {"rate", "default"}, description = "TICK_DEFAULT_HELP")
|
||||
public void reset(@Validator Player player) {
|
||||
setTPS(20);
|
||||
TickManager.impl.setTickRate(20.0F);
|
||||
sendTickRateChange();
|
||||
}
|
||||
}
|
||||
|
||||
@AbstractSWCommand.PartOf(TickBaseCommand.class)
|
||||
private class Tick21Command extends SWCommand {
|
||||
|
||||
private Tick21Command() {
|
||||
super("");
|
||||
}
|
||||
|
||||
@Register(value = "normalclient")
|
||||
public void smooth(@Validator Player player) {
|
||||
TickManager.impl.setBlockTpsPacket(true);
|
||||
}
|
||||
|
||||
@Register(value = "slowclient")
|
||||
public void unsmooth(@Validator Player player) {
|
||||
TickManager.impl.setBlockTpsPacket(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,7 +318,10 @@ public class TPSSystem implements Listener {
|
||||
|
||||
@Override
|
||||
public String get(Region region, Player p) {
|
||||
if (tpsSystem != null && tpsSystem.currentlyStepping) {
|
||||
boolean isWarping = TickManager.impl.isSprinting();
|
||||
boolean isFrozen = TickManager.impl.isFrozen();
|
||||
|
||||
if (tpsSystem != null && isWarping) {
|
||||
long time = System.currentTimeMillis() % 1000;
|
||||
if (time < 250) {
|
||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: §7•••";
|
||||
@ -333,29 +332,29 @@ public class TPSSystem implements Listener {
|
||||
} else {
|
||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: §7••§e•";
|
||||
}
|
||||
} else if (TPSFreezeUtils.frozen()) {
|
||||
} else if (isFrozen) {
|
||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: " + BauSystem.MESSAGE.parse("SCOREBOARD_TPS_FROZEN", p);
|
||||
} else {
|
||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: " + tpsColor() + tpsSystem.getTPS(TPSWatcher.TPSType.ONE_SECOND) + tpsLimit();
|
||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8: " + tpsColor() + TPSWatcher.getTPSUnlimited(TPSWatcher.TPSType.ONE_SECOND) + tpsLimit();
|
||||
}
|
||||
}
|
||||
|
||||
private String tpsColor() {
|
||||
double tps = tpsSystem.getTPS(TPSWatcher.TPSType.ONE_SECOND);
|
||||
if (tps > tpsSystem.getCurrentTPSLimit() * 0.9) {
|
||||
double tps = TPSWatcher.getTPSUnlimited(TPSWatcher.TPSType.ONE_SECOND);
|
||||
if (tps > TickManager.impl.getTickRate() * 0.9) {
|
||||
return "§a";
|
||||
}
|
||||
if (tps > tpsSystem.getCurrentTPSLimit() * 0.5) {
|
||||
if (tps > TickManager.impl.getTickRate() * 0.5) {
|
||||
return "§e";
|
||||
}
|
||||
return "§c";
|
||||
}
|
||||
|
||||
private String tpsLimit() {
|
||||
if (tpsSystem.getCurrentTPSLimit() == 20) {
|
||||
if (TickManager.impl.getTickRate() == 20) {
|
||||
return "";
|
||||
}
|
||||
return "§8/§7" + tpsSystem.getCurrentTPSLimit();
|
||||
return "§8/§7" + TickManager.impl.getTickRate();
|
||||
}
|
||||
}
|
||||
|
||||
@ -371,7 +370,7 @@ public class TPSSystem implements Listener {
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(Player player) {
|
||||
return new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("TPSLIMIT_GUI_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("TPSLIMIT_GUI_ITEM_LORE", player, tpsSystem.currentTPSLimit)), false, clickType -> {
|
||||
return new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("TPSLIMIT_GUI_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("TPSLIMIT_GUI_ITEM_LORE", player, TickManager.impl.getTickRate())), false, clickType -> {
|
||||
}).getItemStack();
|
||||
}
|
||||
|
||||
|
||||
@ -22,19 +22,15 @@ package de.steamwar.bausystem.features.tracer;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.core.Core;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.io.Externalizable;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@ -106,7 +102,11 @@ public class TNTPoint{
|
||||
List<TNTPoint> history, List<Block> destroyedBlocks) {
|
||||
this.tntId = tntId;
|
||||
this.explosion = explosion;
|
||||
this.inWater = tnt.isInWater();
|
||||
if (Core.getVersion() > 15) {
|
||||
this.inWater = tnt.isInWater();
|
||||
} else {
|
||||
this.inWater = false;
|
||||
}
|
||||
this.afterFirstExplosion = afterFirstExplosion;
|
||||
this.ticksSinceStart = ticksSinceStart;
|
||||
fuse = tnt.getFuseTicks();
|
||||
|
||||
@ -50,12 +50,6 @@ public class Trace {
|
||||
@Getter
|
||||
private final File recordsSaveFile;
|
||||
|
||||
/**
|
||||
* File the metadata are saved in
|
||||
*/
|
||||
@Getter
|
||||
private final File metadataSaveFile;
|
||||
|
||||
/**
|
||||
* Region the trace was recorded in
|
||||
*/
|
||||
@ -75,7 +69,7 @@ public class Trace {
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private int recordsCount;
|
||||
private int tntIdCount;
|
||||
|
||||
/**
|
||||
* A map of all REntityServers rendering this trace
|
||||
@ -95,21 +89,19 @@ public class Trace {
|
||||
this.date = new Date();
|
||||
records = new SoftReference<>(recordList);
|
||||
recordsSaveFile = new File(TraceRepository.tracesFolder, uuid + ".records");
|
||||
metadataSaveFile = new File(TraceRepository.tracesFolder, uuid + ".meta");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for deserialising a trace from the file system
|
||||
*/
|
||||
@SneakyThrows
|
||||
protected Trace(UUID uuid, Region region, Date date, File metadataFile, File recordsFile, int recordsCount) {
|
||||
this.metadataSaveFile = metadataFile;
|
||||
protected Trace(UUID uuid, Region region, Date date, File recordsFile, int tntIdCount) {
|
||||
recordsSaveFile = recordsFile;
|
||||
this.uuid = uuid;
|
||||
this.region = region;
|
||||
this.date = date;
|
||||
this.records = new SoftReference<>(null);
|
||||
this.recordsCount = recordsCount;
|
||||
this.tntIdCount = tntIdCount;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -311,7 +303,7 @@ public class Trace {
|
||||
", region=" + region +
|
||||
", creationTime=" + date +
|
||||
", recordsSaveFile=" + recordsSaveFile.getName() +
|
||||
", recordCount=" + recordsCount +
|
||||
", tntCount=" + tntIdCount +
|
||||
", records=" + getRecords() +
|
||||
'}';
|
||||
}
|
||||
|
||||
@ -57,19 +57,26 @@ public class TraceManager implements Listener {
|
||||
if (traceFiles == null)
|
||||
return;
|
||||
|
||||
boolean hasMetaFiles = false;
|
||||
for (File traceFile : traceFiles) {
|
||||
if (traceFile.getName().contains(".records"))
|
||||
continue;
|
||||
|
||||
if (TraceRepository.getVersion(traceFile) == TraceRepository.SERIALISATION_VERSION) {
|
||||
add(TraceRepository.readTrace(traceFile));
|
||||
} else {
|
||||
String uuid = traceFile.getName().replace(".meta", "");
|
||||
|
||||
new File(tracesFolder, uuid + ".records").deleteOnExit();
|
||||
new File(tracesFolder, uuid + ".meta").deleteOnExit();
|
||||
if (traceFile.getName().contains(".meta")) {
|
||||
hasMetaFiles = true;
|
||||
}
|
||||
}
|
||||
if (hasMetaFiles) {
|
||||
for (File traceFile : traceFiles) {
|
||||
traceFile.delete();
|
||||
}
|
||||
traceFiles = new File[0];
|
||||
}
|
||||
|
||||
for (File traceFile : traceFiles) {
|
||||
Trace trace = TraceRepository.readTrace(traceFile);
|
||||
if (trace == null) {
|
||||
traceFile.delete();
|
||||
continue;
|
||||
}
|
||||
add(trace);
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,7 +159,6 @@ public class TraceManager implements Listener {
|
||||
if (traceId == null) throw new RuntimeException("Trace not found while trying to remove see (c978eb98-b0b2-4009-91d8-acfa34e2831a)");
|
||||
traces.remove(traceId);
|
||||
trace.hide();
|
||||
trace.getMetadataSaveFile().delete();
|
||||
trace.getRecordsSaveFile().delete();
|
||||
}
|
||||
|
||||
@ -172,7 +178,6 @@ public class TraceManager implements Listener {
|
||||
tracesByRegion.getOrDefault(region, new HashMap<>())
|
||||
.forEach((i, trace) -> {
|
||||
if (trace.getRegion() != region) return;
|
||||
trace.getMetadataSaveFile().delete();
|
||||
trace.getRecordsSaveFile().delete();
|
||||
});
|
||||
tracesByRegion.getOrDefault(region, new HashMap<>()).clear();
|
||||
|
||||
@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
@ -31,7 +32,6 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
@ -40,12 +40,9 @@ import java.util.logging.Logger;
|
||||
@Linked
|
||||
public class TraceRecorder implements Listener {
|
||||
|
||||
@LinkedInstance
|
||||
public static TraceRecorder instance;
|
||||
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map for all traces being actively recorded
|
||||
*/
|
||||
@ -102,11 +99,14 @@ public class TraceRecorder implements Listener {
|
||||
*
|
||||
* @param region region to be recorded
|
||||
*/
|
||||
public void startRecording(Region region) {
|
||||
if (activeTraces.containsKey(region)) return;
|
||||
public Trace startRecording(Region region) {
|
||||
if (activeTraces.containsKey(region)) {
|
||||
return activeTraces.get(region).getTrace();
|
||||
}
|
||||
|
||||
TraceRecordingWrapper wrappedTrace = new TraceRecordingWrapper(region);
|
||||
activeTraces.put(region, wrappedTrace);
|
||||
return wrappedTrace.getTrace();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -65,7 +65,7 @@ public class TraceRecordingWrapper {
|
||||
TraceManager.instance.showPartial(trace, recordsToAdd);
|
||||
|
||||
recordList.addAll(recordsToAdd);
|
||||
trace.setRecordsCount(recordList.size());
|
||||
trace.setTntIdCount((int) recordList.stream().map(TNTPoint::getTntId).distinct().count());
|
||||
recordsToAdd.clear();
|
||||
}
|
||||
|
||||
|
||||
@ -9,95 +9,125 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
public class TraceRepository {
|
||||
|
||||
/**
|
||||
* Increment this when changing serialisation format
|
||||
*/
|
||||
public static final int SERIALISATION_VERSION = 1;
|
||||
public static final int SERIALISATION_VERSION = 2;
|
||||
public static final int WRITE_TICK_DATA = 0b00000001;
|
||||
public static final int EXPLOSION = 0b00000010;
|
||||
public static final int IN_WATER = 0b00000100;
|
||||
public static final int AFTER_FIRST_EXPLOSION = 0b00001000;
|
||||
public static final int DESTROYED_BUILD_AREA = 0b00010000;
|
||||
public static final int DESTROYED_TEST_BLOCK = 0b00100000;
|
||||
public static File tracesFolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "traces");
|
||||
|
||||
@SneakyThrows
|
||||
protected static int getVersion(File metadataFile) {
|
||||
public static Trace readTrace(File recordsFile) {
|
||||
@Cleanup
|
||||
ObjectInputStream reader = new ObjectInputStream(new FileInputStream(metadataFile));
|
||||
reader.readUTF();
|
||||
reader.readUTF();
|
||||
reader.readObject();
|
||||
try {
|
||||
int version = reader.readInt();
|
||||
return version;
|
||||
} catch (EOFException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static Trace readTrace(File metadataFile) {
|
||||
@Cleanup
|
||||
ObjectInputStream reader = new ObjectInputStream(new FileInputStream(metadataFile));
|
||||
ObjectInputStream reader = new ObjectInputStream(new GZIPInputStream(new FileInputStream(recordsFile)));
|
||||
UUID uuid = UUID.fromString(reader.readUTF());
|
||||
Region region = Region.getREGION_MAP().get(reader.readUTF());
|
||||
Date date = (Date) reader.readObject();
|
||||
File recordsFile = new File(tracesFolder,uuid + ".records");
|
||||
int serialisationVersion = reader.readInt();
|
||||
int recordsCount = reader.readInt();
|
||||
if (serialisationVersion != SERIALISATION_VERSION) {
|
||||
return null;
|
||||
}
|
||||
int tntIdCount = reader.readInt();
|
||||
|
||||
return new Trace(uuid, region, date, metadataFile, recordsFile, recordsCount);
|
||||
return new Trace(uuid, region, date, recordsFile, tntIdCount);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
protected static void writeTrace(Trace trace, List<TNTPoint> records) {
|
||||
ObjectOutputStream outputStream = new ObjectOutputStream(new FileOutputStream(trace.getMetadataSaveFile()));
|
||||
ObjectOutputStream outputStream = new ObjectOutputStream(new GZIPOutputStream(new FileOutputStream(trace.getRecordsSaveFile())));
|
||||
outputStream.writeUTF(trace.getUuid().toString());
|
||||
outputStream.writeUTF(trace.getRegion().getName());
|
||||
outputStream.writeObject(trace.getDate());
|
||||
outputStream.writeInt(SERIALISATION_VERSION);
|
||||
outputStream.writeInt(records.size());
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
|
||||
Map<Integer, List<TNTPoint>> pointsByTNTId = new HashMap<>();
|
||||
records.forEach(tntPoint -> {
|
||||
pointsByTNTId.computeIfAbsent(tntPoint.getTntId(), integer -> new ArrayList<>()).add(tntPoint);
|
||||
});
|
||||
|
||||
writeTraceRecords(trace.getRecordsSaveFile(), records);
|
||||
}
|
||||
outputStream.writeInt(pointsByTNTId.size());
|
||||
for (Map.Entry<Integer, List<TNTPoint>> entry : pointsByTNTId.entrySet()) {
|
||||
outputStream.writeInt(entry.getKey());
|
||||
outputStream.writeInt(entry.getValue().size());
|
||||
|
||||
@SneakyThrows
|
||||
protected static void writeTraceRecords(File recordsFile, List<TNTPoint> records) {
|
||||
DataOutputStream outputStream = new DataOutputStream(new FileOutputStream(recordsFile));
|
||||
for (TNTPoint record : records) {
|
||||
outputStream.writeInt(record.getTntId());
|
||||
outputStream.writeBoolean(record.isExplosion());
|
||||
outputStream.writeBoolean(record.isInWater());
|
||||
outputStream.writeBoolean(record.isAfterFirstExplosion());
|
||||
outputStream.writeBoolean(record.isDestroyedBuildArea());
|
||||
outputStream.writeBoolean(record.isDestroyedTestBlock());
|
||||
outputStream.writeLong(record.getTicksSinceStart());
|
||||
outputStream.writeInt(record.getFuse());
|
||||
Location location = record.getLocation();
|
||||
outputStream.writeDouble(location.getX());
|
||||
outputStream.writeDouble(location.getY());
|
||||
outputStream.writeDouble(location.getZ());
|
||||
Vector velocity = record.getVelocity();
|
||||
outputStream.writeDouble(velocity.getX());
|
||||
outputStream.writeDouble(velocity.getY());
|
||||
outputStream.writeDouble(velocity.getZ());
|
||||
for (int i = 0; i < entry.getValue().size(); i++) {
|
||||
TNTPoint current = entry.getValue().get(i);
|
||||
if (i == 0) {
|
||||
writeTNTPoint(outputStream, current, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
TNTPoint last = entry.getValue().get(i - 1);
|
||||
|
||||
boolean writeTickData = true;
|
||||
if (last.getTicksSinceStart() + 1 == current.getTicksSinceStart() && last.getFuse() - 1 == current.getFuse()) {
|
||||
writeTickData = false;
|
||||
}
|
||||
|
||||
writeTNTPoint(outputStream, current, writeTickData);
|
||||
}
|
||||
}
|
||||
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
protected static TNTPoint readTraceRecord(DataInputStream objectInput) {
|
||||
private static void writeTNTPoint(ObjectOutputStream outputStream, TNTPoint tntPoint, boolean writeTickData) {
|
||||
byte data = 0;
|
||||
if (writeTickData) data |= WRITE_TICK_DATA;
|
||||
if (tntPoint.isExplosion()) data |= EXPLOSION;
|
||||
if (tntPoint.isInWater()) data |= IN_WATER;
|
||||
if (tntPoint.isAfterFirstExplosion()) data |= AFTER_FIRST_EXPLOSION;
|
||||
if (tntPoint.isDestroyedBuildArea()) data |= DESTROYED_BUILD_AREA;
|
||||
if (tntPoint.isDestroyedTestBlock()) data |= DESTROYED_TEST_BLOCK;
|
||||
outputStream.write(data);
|
||||
|
||||
int tntId = objectInput.readInt();
|
||||
boolean explosion = objectInput.readBoolean();
|
||||
boolean inWater = objectInput.readBoolean();
|
||||
boolean afterFirstExplosion = objectInput.readBoolean();
|
||||
boolean destroyedBuildArea = objectInput.readBoolean();
|
||||
boolean destroyedTestBlock = objectInput.readBoolean();
|
||||
long ticksSinceStart = objectInput.readLong();
|
||||
int fuse = objectInput.readInt();
|
||||
if (writeTickData) {
|
||||
outputStream.writeLong(tntPoint.getTicksSinceStart());
|
||||
outputStream.writeInt(tntPoint.getFuse());
|
||||
}
|
||||
|
||||
Location location = tntPoint.getLocation();
|
||||
outputStream.writeDouble(location.getX());
|
||||
outputStream.writeDouble(location.getY());
|
||||
outputStream.writeDouble(location.getZ());
|
||||
|
||||
Vector velocity = tntPoint.getVelocity();
|
||||
outputStream.writeDouble(velocity.getX());
|
||||
outputStream.writeDouble(velocity.getY());
|
||||
outputStream.writeDouble(velocity.getZ());
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
protected static TNTPoint readTraceRecord(int tntId, TNTPoint last, ObjectInputStream objectInput) {
|
||||
|
||||
int data = objectInput.read();
|
||||
boolean explosion = (data & EXPLOSION) > 0;
|
||||
boolean inWater = (data & IN_WATER) > 0;
|
||||
boolean afterFirstExplosion = (data & AFTER_FIRST_EXPLOSION) > 0;
|
||||
boolean destroyedBuildArea = (data & DESTROYED_BUILD_AREA) > 0;
|
||||
boolean destroyedTestBlock = (data & DESTROYED_TEST_BLOCK) > 0;
|
||||
|
||||
long ticksSinceStart;
|
||||
int fuse;
|
||||
if ((data & WRITE_TICK_DATA) > 0) {
|
||||
ticksSinceStart = objectInput.readLong();
|
||||
fuse = objectInput.readInt();
|
||||
} else {
|
||||
ticksSinceStart = last.getTicksSinceStart() + 1;
|
||||
fuse = last.getFuse() - 1;
|
||||
}
|
||||
|
||||
double locX = objectInput.readDouble();
|
||||
double locY = objectInput.readDouble();
|
||||
@ -116,21 +146,29 @@ public class TraceRepository {
|
||||
protected static List<TNTPoint> readTraceRecords(Trace trace) {
|
||||
File recordsFile = trace.getRecordsSaveFile();
|
||||
@Cleanup
|
||||
DataInputStream inputStream = new DataInputStream(new FileInputStream(recordsFile));
|
||||
ObjectInputStream inputStream = new ObjectInputStream(new GZIPInputStream(new FileInputStream(recordsFile)));
|
||||
inputStream.readUTF();
|
||||
inputStream.readUTF();
|
||||
inputStream.readObject();
|
||||
inputStream.readInt();
|
||||
inputStream.readInt();
|
||||
|
||||
List<TNTPoint> records = new ArrayList<>();
|
||||
for (int i = 0; i < trace.getRecordsCount(); i++) {
|
||||
records.add(readTraceRecord(inputStream));
|
||||
}
|
||||
|
||||
Map<Integer, List<TNTPoint>> histories = new HashMap<>();
|
||||
for (TNTPoint record : records) {
|
||||
int tntId = record.getTntId();
|
||||
List<TNTPoint> history = histories.computeIfAbsent(tntId, id -> new ArrayList<>());
|
||||
history.add(record);
|
||||
record.setHistory(history);
|
||||
}
|
||||
for (int i = 0; i < trace.getTntIdCount(); i++) {
|
||||
int tntId = inputStream.readInt();
|
||||
int size = inputStream.readInt();
|
||||
List<TNTPoint> points = histories.computeIfAbsent(tntId, id -> new ArrayList<>());
|
||||
|
||||
TNTPoint last = null;
|
||||
for (int j = 0; j < size; j++) {
|
||||
TNTPoint point = readTraceRecord(tntId, last, inputStream);
|
||||
point.setHistory(points);
|
||||
points.add(point);
|
||||
last = point;
|
||||
records.add(point);
|
||||
}
|
||||
}
|
||||
return records;
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@
|
||||
package de.steamwar.bausystem.features.tracer.rendering;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.configplayer.Config;
|
||||
import de.steamwar.bausystem.features.tracer.TNTPoint;
|
||||
import de.steamwar.bausystem.features.tracer.Trace;
|
||||
import de.steamwar.bausystem.features.tracer.TraceManager;
|
||||
@ -30,10 +31,13 @@ import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import yapion.hierarchy.types.YAPIONValue;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static de.steamwar.bausystem.features.util.TNTClickListener.TNT_CLICK_DETAILS;
|
||||
|
||||
/**
|
||||
* Wrapper for the rendering of a record bundle
|
||||
*/
|
||||
@ -66,6 +70,7 @@ public class TraceEntity extends RFallingBlockEntity {
|
||||
* @param player the player the message should be printed for
|
||||
*/
|
||||
public void printIntoChat(Player player) {
|
||||
if (!Config.getInstance().get(player).getOrSetDefault(TNT_CLICK_DETAILS, new YAPIONValue<>(true)).asBoolean().orElse(true)) return;
|
||||
TNTPoint representative = records.get(0);
|
||||
|
||||
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_HEADER", player);
|
||||
|
||||
@ -26,6 +26,7 @@ import de.steamwar.bausystem.shared.EnumDisplay;
|
||||
import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.data.CMDs;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
@ -202,9 +203,9 @@ public class MaterialCommand extends SWCommand implements Listener {
|
||||
private void searchGUI(Player p) {
|
||||
SWInventory swInventory = new SWInventory(p, 54, BauSystem.MESSAGE.parse("MATERIAL_SEARCH", p));
|
||||
Search search = searchMap.get(p);
|
||||
swInventory.setItem(45, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("MATERIAL_BACK", p), clickType -> {
|
||||
swInventory.setItem(0, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("MATERIAL_BACK", p), clickType -> {
|
||||
materialGUI(p);
|
||||
}));
|
||||
}).setCustomModelData(CMDs.BACK));
|
||||
swInventory.setItem(10, new SWItem(Material.NAME_TAG, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_NAME", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.name), clickType -> {
|
||||
SWAnvilInv swAnvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_NAME", p), search.name);
|
||||
swAnvilInv.setCallback(s -> {
|
||||
|
||||
@ -21,13 +21,9 @@ package de.steamwar.bausystem.features.util;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.entity.RFallingBlockEntity;
|
||||
import de.steamwar.entity.*;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -37,101 +33,315 @@ import org.bukkit.block.PistonMoveReaction;
|
||||
import org.bukkit.block.TileState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.type.Piston;
|
||||
import org.bukkit.entity.Display;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TextDisplay;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Linked
|
||||
@MinVersion(20)
|
||||
public class PistonCalculator implements Listener {
|
||||
|
||||
private final Map<Player, Long> DEBOUNCE = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
||||
if (!event.hasItem() || event.getItem().getType() != Material.SLIME_BALL) return;
|
||||
if (event.hasItem() && event.getItem().getType() == Material.SLIME_BALL) {
|
||||
} else if (event.hasItem()) return;
|
||||
if (event.getClickedBlock() == null) return;
|
||||
Block clickedBlock = event.getClickedBlock();
|
||||
Material blockType = clickedBlock.getType();
|
||||
if (!(blockType == Material.PISTON || blockType == Material.STICKY_PISTON)) return;
|
||||
Piston piston = (Piston) clickedBlock.getBlockData();
|
||||
if (System.currentTimeMillis() - DEBOUNCE.getOrDefault(event.getPlayer(), 0L) <= 200) return;
|
||||
DEBOUNCE.put(event.getPlayer(), System.currentTimeMillis());
|
||||
|
||||
if (blockType == Material.PISTON && piston.isExtended()) {
|
||||
BauSystem.MESSAGE.sendPrefixless("PISTON_INFO", event.getPlayer(), ChatMessageType.ACTION_BAR, "§a", 0);
|
||||
Location location = event.getClickedBlock().getLocation();
|
||||
if (pistOrders.containsKey(location)) {
|
||||
PistOrder pistOrder = pistOrders.get(location);
|
||||
if (pistOrder.server.getPlayers().contains(event.getPlayer())) {
|
||||
pistOrder.server.removePlayer(event.getPlayer());
|
||||
} else {
|
||||
pistOrder.server.addPlayer(event.getPlayer());
|
||||
}
|
||||
if (pistOrder.server.getPlayers().isEmpty()) {
|
||||
pistOrders.remove(location);
|
||||
pistOrder.server.close();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
boolean pulling = blockType == Material.STICKY_PISTON && (clickedBlock.getRelative(piston.getFacing()).getType() == Material.AIR || piston.isExtended());
|
||||
PistOrder pistOrder = new PistOrder(clickedBlock);
|
||||
pistOrder.calculate();
|
||||
pistOrder.server.addPlayer(event.getPlayer());
|
||||
pistOrders.put(location, pistOrder);
|
||||
}
|
||||
|
||||
CalculationResult result = calc(clickedBlock, piston.getFacing(), (pulling ? piston.getFacing().getOppositeFace() : piston.getFacing()));
|
||||
result.entityServer.addPlayer(event.getPlayer());
|
||||
BauSystem.MESSAGE.sendPrefixless("PISTON_INFO", event.getPlayer(), ChatMessageType.ACTION_BAR, result.unmovable ? "§c" : (result.tooMany ? "§e" : "§a"), result.amount);
|
||||
@EventHandler
|
||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
movePistOrders(event.getDirection(), event.getBlocks());
|
||||
pistOrders.values().forEach(PistOrder::calculate);
|
||||
}, 3);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
movePistOrders(event.getDirection(), event.getBlocks());
|
||||
pistOrders.values().forEach(PistOrder::calculate);
|
||||
}, 3);
|
||||
}
|
||||
|
||||
private void movePistOrders(BlockFace direction, List<Block> blocks) {
|
||||
Set<PistOrder> orders = new HashSet<>();
|
||||
blocks.forEach(block -> {
|
||||
PistOrder pistOrder = pistOrders.get(block.getLocation());
|
||||
if (pistOrder == null) return;
|
||||
pistOrders.remove(block.getLocation());
|
||||
pistOrder.piston = pistOrder.piston.getRelative(direction);
|
||||
orders.add(pistOrder);
|
||||
});
|
||||
orders.forEach(pistOrder -> {
|
||||
pistOrders.put(pistOrder.piston.getLocation(), pistOrder);
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
pistOrders.values().forEach(PistOrder::calculate);
|
||||
}, 1);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if (pistOrders.containsKey(event.getBlock().getLocation())) {
|
||||
PistOrder pistOrder = pistOrders.remove(event.getBlock().getLocation());
|
||||
pistOrder.server.close();
|
||||
}
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
pistOrders.values().forEach(PistOrder::calculate);
|
||||
}, 1);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
DEBOUNCE.remove(event.getPlayer());
|
||||
|
||||
Set<Location> toRemove = new HashSet<>();
|
||||
pistOrders.forEach((location, pistOrder) -> {
|
||||
pistOrder.server.removePlayer(event.getPlayer());
|
||||
if (pistOrder.server.getPlayers().isEmpty()) {
|
||||
toRemove.add(location);
|
||||
pistOrder.server.close();
|
||||
}
|
||||
});
|
||||
toRemove.forEach(pistOrders::remove);
|
||||
}
|
||||
|
||||
private final BlockFace[] FACES = new BlockFace[]{BlockFace.UP, BlockFace.DOWN, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST};
|
||||
|
||||
private CalculationResult calc(Block origin, BlockFace facing, BlockFace direction) {
|
||||
Set<Block> blockSet = new HashSet<>();
|
||||
Set<Location> unmovable = new HashSet<>();
|
||||
private final Map<Location, PistOrder> pistOrders = new HashMap<>();
|
||||
|
||||
Block calcOrigin = origin;
|
||||
if (facing != direction) calcOrigin = origin.getRelative(facing, 3);
|
||||
private final class PistOrder {
|
||||
private Block piston;
|
||||
private REntityServer server = new REntityServer();
|
||||
|
||||
List<Block> toCalc = new LinkedList<>();
|
||||
calcDirection(origin, null, calcOrigin, facing != direction ? origin.getRelative(facing) : null, facing, direction, blockSet, toCalc, unmovable);
|
||||
private boolean pulling = false;
|
||||
private List<Location> movedBlocks = new ArrayList<>();
|
||||
private List<Location> brokenBlocks = new ArrayList<>();
|
||||
private Set<Location> immovableBlocks = new HashSet<>();
|
||||
|
||||
while (!toCalc.isEmpty()) {
|
||||
Block current = toCalc.remove(0);
|
||||
blockSet.add(current);
|
||||
public PistOrder(Block piston) {
|
||||
this.piston = piston;
|
||||
}
|
||||
|
||||
Material type = current.getType();
|
||||
if (type != Material.SLIME_BLOCK && type != Material.HONEY_BLOCK) continue;
|
||||
Material oppositeType = type == Material.SLIME_BLOCK ? Material.HONEY_BLOCK : Material.SLIME_BLOCK;
|
||||
public void calculate() {
|
||||
movedBlocks.clear();
|
||||
brokenBlocks.clear();
|
||||
immovableBlocks.clear();
|
||||
|
||||
for (BlockFace face : FACES) {
|
||||
Block block = current.getRelative(face);
|
||||
if (block.getType().isAir()) continue;
|
||||
if (!isPiston(block) && (block.getPistonMoveReaction() == PistonMoveReaction.BLOCK || block.getPistonMoveReaction() == PistonMoveReaction.IGNORE || block.getPistonMoveReaction() == PistonMoveReaction.PUSH_ONLY || block.getState() instanceof TileState || block.getPistonMoveReaction() == PistonMoveReaction.BREAK)) continue;
|
||||
if (block.getType() != oppositeType) {
|
||||
if (!blockSet.contains(block)) toCalc.add(block);
|
||||
calcDirection(null, origin, block, null, facing, direction, blockSet, toCalc, unmovable);
|
||||
if (piston.isEmpty()) {
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
server.close();
|
||||
pistOrders.remove(piston.getLocation());
|
||||
}, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
BlockData blockData = piston.getBlockData();
|
||||
if (!(blockData instanceof Piston)) return;
|
||||
Piston pistonData = (Piston) blockData;
|
||||
if (piston.getType() == Material.PISTON && pistonData.isExtended()) {
|
||||
visualize();
|
||||
return;
|
||||
}
|
||||
|
||||
pulling = piston.getType() == Material.STICKY_PISTON && (piston.getRelative(pistonData.getFacing()).getType() == Material.AIR || pistonData.isExtended());
|
||||
|
||||
calculate(piston, pistonData.getFacing(), (pulling ? pistonData.getFacing().getOppositeFace() : pistonData.getFacing()));
|
||||
|
||||
Collections.reverse(movedBlocks);
|
||||
Collections.reverse(brokenBlocks);
|
||||
|
||||
visualize();
|
||||
}
|
||||
|
||||
private void calculate(Block origin, BlockFace facing, BlockFace direction) {
|
||||
Block calcOrigin = origin;
|
||||
if (facing != direction) calcOrigin = origin.getRelative(facing, 3);
|
||||
|
||||
List<Block> toCalc = new LinkedList<>();
|
||||
calcDirection(origin, null, calcOrigin, facing != direction ? origin.getRelative(facing) : null, facing, direction, toCalc);
|
||||
|
||||
while (!toCalc.isEmpty()) {
|
||||
Block current = toCalc.remove(0);
|
||||
if (!movedBlocks.contains(current.getLocation())) {
|
||||
movedBlocks.add(current.getLocation());
|
||||
}
|
||||
|
||||
Material type = current.getType();
|
||||
if (type != Material.SLIME_BLOCK && type != Material.HONEY_BLOCK) continue;
|
||||
Material oppositeType = type == Material.SLIME_BLOCK ? Material.HONEY_BLOCK : Material.SLIME_BLOCK;
|
||||
|
||||
for (BlockFace face : FACES) {
|
||||
Block block = current.getRelative(face);
|
||||
if (block.getType().isAir()) continue;
|
||||
if (isImmovable(block) || block.getPistonMoveReaction() == PistonMoveReaction.BREAK) continue;
|
||||
if (block.getType() != oppositeType) {
|
||||
if (!movedBlocks.contains(block.getLocation())) toCalc.add(block);
|
||||
calcDirection(null, origin, block, null, facing, direction, toCalc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
movedBlocks.remove(origin.getLocation());
|
||||
if (facing != direction) movedBlocks.remove(origin.getRelative(facing, 1).getLocation());
|
||||
if (pulling) immovableBlocks.remove(origin.getRelative(facing).getLocation());
|
||||
}
|
||||
|
||||
blockSet.remove(origin);
|
||||
if (facing != direction) blockSet.remove(origin.getRelative(facing, 1));
|
||||
|
||||
REntityServer entityServer = new REntityServer();
|
||||
for (Location loc : unmovable) {
|
||||
RFallingBlockEntity rFallingBlockEntity = new RFallingBlockEntity(entityServer, loc.clone().add(0.5, 0, 0.5), Material.RED_STAINED_GLASS);
|
||||
rFallingBlockEntity.setGlowing(true);
|
||||
rFallingBlockEntity.setNoGravity(true);
|
||||
rFallingBlockEntity.setInvisible(true);
|
||||
private void calcDirection(Block origin, Block blockOrigin, Block calcOrigin, Block ignore, BlockFace facing, BlockFace direction, List<Block> toCalc) {
|
||||
for (int i = 1; i < 24; i++) {
|
||||
Block block = calcOrigin.getRelative(direction, i);
|
||||
if (block.equals(ignore)) return;
|
||||
if (block.getPistonMoveReaction() == PistonMoveReaction.BREAK) {
|
||||
if (!brokenBlocks.contains(block.getLocation())) {
|
||||
brokenBlocks.add(block.getLocation());
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (isImmovable(block)) {
|
||||
immovableBlocks.add(block.getLocation());
|
||||
return;
|
||||
}
|
||||
if (block.getType().isAir()) return;
|
||||
if (facing == direction && block.equals(blockOrigin)) {
|
||||
immovableBlocks.add(block.getLocation());
|
||||
return;
|
||||
}
|
||||
if (facing != direction && (block.equals(origin) || block.getRelative(facing.getOppositeFace()).equals(origin))) return;
|
||||
if (!movedBlocks.contains(block.getLocation())) toCalc.add(block);
|
||||
}
|
||||
}
|
||||
|
||||
private void visualize() {
|
||||
server.getEntities().forEach(REntity::die);
|
||||
|
||||
for (int i = 0; i < movedBlocks.size(); i++) {
|
||||
Location location = movedBlocks.get(i);
|
||||
int order = i + 1;
|
||||
|
||||
CCubedTextDisplay display = new CCubedTextDisplay(server, location);
|
||||
display.setText("§e" + order);
|
||||
display.setBackgroundColor(0);
|
||||
display.setShadowed(false);
|
||||
|
||||
Set<BlockFace> toHide = Arrays.stream(FACES).filter(blockFace -> {
|
||||
return movedBlocks.contains(location.clone().add(blockFace.getModX(), blockFace.getModY(), blockFace.getModZ()));
|
||||
}).collect(Collectors.toSet());
|
||||
display.hide(toHide);
|
||||
}
|
||||
|
||||
for (int i = 0; i < brokenBlocks.size(); i++) {
|
||||
Location location = brokenBlocks.get(i);
|
||||
int order = i + 1;
|
||||
|
||||
RTextDisplay textDisplay = new RTextDisplay(server, location.clone().add(0.5, 0.4, 0.5));
|
||||
textDisplay.setText("§c" + order);
|
||||
textDisplay.setBillboard(Display.Billboard.CENTER);
|
||||
textDisplay.setAlignment(TextDisplay.TextAlignment.CENTER);
|
||||
textDisplay.setSeeThrough(true);
|
||||
textDisplay.setBackgroundColor(0);
|
||||
textDisplay.setShadowed(false);
|
||||
textDisplay.setBrightness(new Display.Brightness(15, 15));
|
||||
}
|
||||
|
||||
for (Location location : immovableBlocks) {
|
||||
CWireframe wireframe = new CWireframe(server);
|
||||
wireframe.setPos1(location);
|
||||
wireframe.setPos2(location);
|
||||
wireframe.setWidth(1 / 32f);
|
||||
wireframe.setBlock(Material.RED_CONCRETE.createBlockData());
|
||||
}
|
||||
|
||||
CWireframe wireframe = new CWireframe(server);
|
||||
wireframe.setPos1(piston.getLocation());
|
||||
wireframe.setPos2(piston.getLocation());
|
||||
if (!immovableBlocks.isEmpty()) {
|
||||
wireframe.setBlock(Material.RED_CONCRETE.createBlockData());
|
||||
} else if (movedBlocks.size() > 12) {
|
||||
wireframe.setBlock(Material.YELLOW_CONCRETE.createBlockData());
|
||||
} else {
|
||||
wireframe.setBlock(Material.LIME_CONCRETE.createBlockData());
|
||||
}
|
||||
wireframe.setWidth(1 / 32f);
|
||||
|
||||
RTextDisplay textDisplay = new RTextDisplay(server, piston.getLocation().clone().add(0.5, 0.3, 0.5));
|
||||
StringBuilder text = new StringBuilder();
|
||||
if (pulling) {
|
||||
text.append("§ePull\n");
|
||||
} else {
|
||||
text.append("§ePush\n");
|
||||
}
|
||||
text.append("§f").append(movedBlocks.size()).append(" §eBlocks");
|
||||
textDisplay.setText(text.toString());
|
||||
textDisplay.setBillboard(Display.Billboard.CENTER);
|
||||
textDisplay.setAlignment(TextDisplay.TextAlignment.CENTER);
|
||||
textDisplay.setSeeThrough(true);
|
||||
textDisplay.setBackgroundColor(0);
|
||||
textDisplay.setShadowed(false);
|
||||
textDisplay.setBrightness(new Display.Brightness(15, 15));
|
||||
}
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), entityServer::close, 20);
|
||||
return new CalculationResult(blockSet.size(), blockSet.size() > 12, !unmovable.isEmpty(), entityServer);
|
||||
}
|
||||
|
||||
private void calcDirection(Block origin, Block blockOrigin, Block calcOrigin, Block ignore, BlockFace facing, BlockFace direction, Set<Block> blockSet, List<Block> toCalc, Set<Location> unmovable) {
|
||||
for (int i = 1; i < 24; i++) {
|
||||
Block block = calcOrigin.getRelative(direction, i);
|
||||
if (block.equals(ignore)) return;
|
||||
if (block.getPistonMoveReaction() == PistonMoveReaction.BREAK) return;
|
||||
if (!isPiston(block) && (block.getPistonMoveReaction() == PistonMoveReaction.BLOCK || block.getPistonMoveReaction() == PistonMoveReaction.IGNORE || block.getState() instanceof TileState)) {
|
||||
unmovable.add(block.getLocation());
|
||||
return;
|
||||
}
|
||||
if (block.getType().isAir()) return;
|
||||
if (facing == direction && block.equals(blockOrigin)) {
|
||||
unmovable.add(block.getLocation());
|
||||
return;
|
||||
}
|
||||
if (facing != direction && (block.equals(origin) || block.getRelative(facing.getOppositeFace()).equals(origin))) return;
|
||||
if (!blockSet.contains(block)) toCalc.add(block);
|
||||
private boolean isImmovable(Block block) {
|
||||
if (block.isEmpty() || block.isLiquid()) {
|
||||
return false;
|
||||
}
|
||||
BlockData blockData = block.getBlockData();
|
||||
if (blockData instanceof Piston) {
|
||||
return ((Piston) blockData).isExtended();
|
||||
}
|
||||
if (block.getState() instanceof TileState) {
|
||||
return true;
|
||||
}
|
||||
PistonMoveReaction reaction = block.getPistonMoveReaction();
|
||||
if (reaction == PistonMoveReaction.IGNORE) return true;
|
||||
if (reaction == PistonMoveReaction.BLOCK) return true;
|
||||
switch (block.getType()) {
|
||||
case OBSIDIAN:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,13 +352,4 @@ public class PistonCalculator implements Listener {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
private static class CalculationResult {
|
||||
private int amount;
|
||||
private boolean tooMany;
|
||||
private boolean unmovable;
|
||||
private REntityServer entityServer;
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,9 +22,11 @@ package de.steamwar.bausystem.features.util;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Linked
|
||||
@MinVersion(20)
|
||||
public class PistonCalculatorCommand extends SWCommand {
|
||||
|
||||
public PistonCalculatorCommand() {
|
||||
|
||||
@ -42,6 +42,15 @@ public class SkullCommand extends SWCommand {
|
||||
super("skull", "head");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void giveCommand(@Validator Player p) {
|
||||
if (p.getName().startsWith(".")) {
|
||||
BauSystem.MESSAGE.send("SKULL_INVALID", p);
|
||||
return;
|
||||
}
|
||||
giveCommand(p, p.getName());
|
||||
}
|
||||
|
||||
@Register(description = "SKULL_HELP")
|
||||
public void giveCommand(@Validator Player p, @Mapper("player") @ErrorMessage("SKULL_INVALID") String skull) {
|
||||
ItemStack is = SWItem.getPlayerSkull(skull).getItemStack();
|
||||
@ -63,7 +72,7 @@ public class SkullCommand extends SWCommand {
|
||||
|
||||
@Override
|
||||
public List<String> tabCompletes(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
||||
return Bukkit.getOnlinePlayers().stream().map(Player::getName).filter(s1 -> !s1.endsWith("⍇")).collect(Collectors.toList());
|
||||
return Bukkit.getOnlinePlayers().stream().map(Player::getName).filter(s1 -> !s1.startsWith(".")).collect(Collectors.toList());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -21,22 +21,46 @@ package de.steamwar.bausystem.features.util;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.configplayer.Config;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import yapion.hierarchy.types.YAPIONObject;
|
||||
import yapion.hierarchy.types.YAPIONValue;
|
||||
|
||||
@Linked
|
||||
public class TNTClickListener implements Listener {
|
||||
public class TNTClickListener extends SWCommand implements Listener {
|
||||
|
||||
public static final String TNT_CLICK_DETAILS = "tnt_click_details";
|
||||
|
||||
public TNTClickListener() {
|
||||
super("tntdetails");
|
||||
}
|
||||
|
||||
@Register(description = "TNT_DETAILS_COMMAND")
|
||||
public void toggle(Player player) {
|
||||
YAPIONObject yapionObject = Config.getInstance().get(player);
|
||||
if (yapionObject.getOrSetDefault(TNT_CLICK_DETAILS, new YAPIONValue<>(true)).asBoolean().orElse(true)) {
|
||||
yapionObject.put(TNT_CLICK_DETAILS, false);
|
||||
BauSystem.MESSAGE.send("TNT_DETAILS_OFF", player);
|
||||
} else {
|
||||
yapionObject.put(TNT_CLICK_DETAILS, true);
|
||||
BauSystem.MESSAGE.send("TNT_DETAILS_ON", player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
|
||||
if (event.getHand() != EquipmentSlot.HAND) return;
|
||||
if (!Config.getInstance().get(event.getPlayer()).getOrSetDefault(TNT_CLICK_DETAILS, new YAPIONValue<>(true)).asBoolean().orElse(true)) return;
|
||||
|
||||
Entity entity = event.getRightClicked();
|
||||
if (event.getRightClicked() instanceof TNTPrimed) {
|
||||
|
||||
@ -36,7 +36,7 @@ public class Warp {
|
||||
|
||||
public static void enable() {
|
||||
Warp worldSpawn = new Warp("WorldSpawn");
|
||||
worldSpawn.setLocation(Bukkit.getWorlds().get(0).getSpawnLocation().clone().add(0.5, Core.getVersion() == 20 ? 124 : 1, 0.5));
|
||||
worldSpawn.setLocation(Bukkit.getWorlds().get(0).getSpawnLocation().clone().add(0.5, Core.getVersion() >= 20 ? 124 : 1, 0.5));
|
||||
worldSpawn.setMat(Material.NETHER_STAR);
|
||||
warpMap.put("WorldSpawn", worldSpawn);
|
||||
}
|
||||
|
||||
@ -59,6 +59,7 @@ public class BauLockStateScoreboard implements ScoreboardElement {
|
||||
public enum BauLockState {
|
||||
|
||||
NOBODY,
|
||||
SUPERVISOR,
|
||||
SERVERTEAM,
|
||||
TEAM_AND_SERVERTEAM,
|
||||
TEAM,
|
||||
|
||||
@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.world;
|
||||
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.sql.NodeData;
|
||||
import de.steamwar.sql.SchematicData;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
@ -65,7 +66,8 @@ public class ClipboardListener implements Listener {
|
||||
}
|
||||
|
||||
try {
|
||||
new SchematicData(schematic).saveFromPlayer(e.getPlayer());
|
||||
NodeData.get(schematic).forEach(NodeData::delete);
|
||||
SchematicData.saveFromPlayer(e.getPlayer(), schematic);
|
||||
} catch (Exception ex) {
|
||||
if (newSchem) {
|
||||
schematic.delete();
|
||||
|
||||
@ -179,7 +179,12 @@ public class SpectatorListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
if (event.getMessage().startsWith("/schem save") || event.getMessage().startsWith("//schem save") || event.getMessage().startsWith("/schematic save") || event.getMessage().startsWith("//schematic save")) {
|
||||
if (event.getMessage().startsWith("/schem save") ||
|
||||
event.getMessage().startsWith("//schem save") ||
|
||||
event.getMessage().startsWith("/schematic save") ||
|
||||
event.getMessage().startsWith("//schematic save") ||
|
||||
event.getMessage().startsWith("/download") ||
|
||||
event.getMessage().startsWith("//download")) {
|
||||
if (!Permission.SUPERVISOR.hasPermission(event.getPlayer())) {
|
||||
event.setCancelled(true);
|
||||
event.setMessage("/");
|
||||
|
||||
@ -0,0 +1,180 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.features.worldedit;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.region.Point;
|
||||
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
||||
import de.steamwar.core.WorldEditRenderer;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@Linked
|
||||
@MinVersion(20)
|
||||
public class SelectAdjacent implements Listener {
|
||||
|
||||
private Vector[] FACES = {
|
||||
new Vector(1, 0, 0),
|
||||
new Vector(-1, 0, 0),
|
||||
new Vector(0, 1, 0),
|
||||
new Vector(0, -1, 0),
|
||||
new Vector(0, 0, 1),
|
||||
new Vector(0, 0, -1),
|
||||
|
||||
new Vector(1, 1, 0),
|
||||
new Vector(1, -1, 0),
|
||||
new Vector(1, 0, 1),
|
||||
new Vector(1, 0, -1),
|
||||
new Vector(-1, 1, 0),
|
||||
new Vector(-1, -1, 0),
|
||||
new Vector(-1, 0, 1),
|
||||
new Vector(-1, 0, -1),
|
||||
new Vector(0, 1, 1),
|
||||
new Vector(0, 1, -1),
|
||||
new Vector(0, -1, 1),
|
||||
new Vector(0, -1, -1),
|
||||
};
|
||||
|
||||
private Map<Player, Selector> selectors = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (!event.hasItem()) return;
|
||||
if (event.getItem().getType() != Material.WOODEN_AXE) return;
|
||||
if (!event.getPlayer().isSneaking()) return;
|
||||
if (event.getAction() != Action.LEFT_CLICK_BLOCK) return;
|
||||
Selector selector = selectors.get(event.getPlayer());
|
||||
if (selector != null) selector.cancel();
|
||||
Material material = event.getPlayer().getInventory().getItemInOffHand().getType();
|
||||
if (material.isAir()) {
|
||||
selector = new Selector(event.getClickedBlock(), event.getPlayer(), __ -> true);
|
||||
} else {
|
||||
selector = new Selector(event.getClickedBlock(), event.getPlayer(), type -> type == material);
|
||||
}
|
||||
selectors.put(event.getPlayer(), selector);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Selector selector = selectors.remove(event.getPlayer());
|
||||
if (selector != null) selector.cancel();
|
||||
}
|
||||
|
||||
private class Selector {
|
||||
|
||||
private static final int MAX_BLOCKS = 1_000_000;
|
||||
|
||||
private int minX;
|
||||
private int minY;
|
||||
private int minZ;
|
||||
private int maxX;
|
||||
private int maxY;
|
||||
private int maxZ;
|
||||
|
||||
private BukkitTask bukkitTask;
|
||||
private Predicate<Material> predicate;
|
||||
private Set<Location> seen = new HashSet<>();
|
||||
private Set<Location> toCalc = new HashSet<>();
|
||||
|
||||
public Selector(Block block, Player player, Predicate<Material> predicate) {
|
||||
this.predicate = predicate;
|
||||
toCalc.add(block.getLocation());
|
||||
minX = block.getX();
|
||||
minY = block.getY();
|
||||
minZ = block.getZ();
|
||||
maxX = block.getX();
|
||||
maxY = block.getY();
|
||||
maxZ = block.getZ();
|
||||
|
||||
bukkitTask = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
|
||||
run();
|
||||
|
||||
long volume = (long)(maxX - minX + 1) * (long)(maxY - minY + 1) * (long)(maxZ - minZ + 1);
|
||||
player.sendTitle("", "§e" + volume + " §7Blocks", 0, 5, 0);
|
||||
|
||||
Point minPoint = new Point(minX, minY, minZ);
|
||||
Point maxPoint = new Point(maxX, maxY, maxZ);
|
||||
|
||||
FlatteningWrapper.impl.setSelection(player, minPoint, maxPoint);
|
||||
WorldEditRenderer.renderPlayer(player);
|
||||
|
||||
// boolean finished = toCalc.stream().allMatch(location -> {
|
||||
// return location.getBlockX() >= minX && location.getBlockY() >= minY && location.getBlockZ() >= minZ &&
|
||||
// location.getBlockX() <= maxX && location.getBlockY() <= maxY && location.getBlockZ() <= maxZ;
|
||||
// });
|
||||
|
||||
if (toCalc.isEmpty() || seen.size() > MAX_BLOCKS) {
|
||||
bukkitTask.cancel();
|
||||
player.sendTitle("§aDone", "§e" + volume + " §7Blocks", 0, 20, 5);
|
||||
}
|
||||
}, 1, 1);
|
||||
}
|
||||
|
||||
private void cancel() {
|
||||
bukkitTask.cancel();
|
||||
}
|
||||
|
||||
private void run() {
|
||||
Set<Location> current = toCalc;
|
||||
toCalc = new HashSet<>();
|
||||
|
||||
for (Location location : current) {
|
||||
Block block = location.getBlock();
|
||||
if (block.isEmpty() || block.isLiquid()) continue;
|
||||
if (!predicate.test(block.getType())) continue;
|
||||
seen.add(location);
|
||||
|
||||
minX = Math.min(minX, location.getBlockX());
|
||||
maxX = Math.max(maxX, location.getBlockX());
|
||||
minY = Math.min(minY, location.getBlockY());
|
||||
maxY = Math.max(maxY, location.getBlockY());
|
||||
minZ = Math.min(minZ, location.getBlockZ());
|
||||
maxZ = Math.max(maxZ, location.getBlockZ());
|
||||
|
||||
for (Vector face : FACES) {
|
||||
Block next = block.getRelative(face.getBlockX(), face.getBlockY(), face.getBlockZ());
|
||||
if (next.isEmpty() || next.isLiquid()) continue;
|
||||
if (!predicate.test(next.getType())) continue;
|
||||
Location loc = next.getLocation();
|
||||
if (seen.contains(loc)) continue;
|
||||
toCalc.add(loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -73,4 +73,8 @@ public class Point {
|
||||
public Location toLocation(Player player, double dx, double dy, double dz) {
|
||||
return new Location(player.getWorld(), x + dx, y + dy, z + dz, player.getLocation().getYaw(), player.getLocation().getPitch());
|
||||
}
|
||||
|
||||
public BlockVector3 toBlockVector3() {
|
||||
return BlockVector3.at(this.x, this.y, this.z);
|
||||
}
|
||||
}
|
||||
@ -145,6 +145,13 @@ public class PasteBuilder {
|
||||
public PasteBuilder removeWater(boolean removeWater) {
|
||||
if (!removeWater) return this;
|
||||
BaseBlock water = Objects.requireNonNull(BlockTypes.get("water")).getDefaultState().toBaseBlock();
|
||||
BlockType bubble_column_type = BlockTypes.get("bubble_column");
|
||||
BaseBlock bubble_column;
|
||||
if (bubble_column_type == null) {
|
||||
bubble_column = null;
|
||||
} else {
|
||||
bubble_column = bubble_column_type.getDefaultState().toBaseBlock();
|
||||
}
|
||||
BaseBlock air = Objects.requireNonNull(BlockTypes.get("air")).getDefaultState().toBaseBlock();
|
||||
WaterloggedRemover waterloggedRemover = new WaterloggedRemover(getClipboard());
|
||||
|
||||
@ -154,6 +161,10 @@ public class PasteBuilder {
|
||||
clipboard.setBlock(blockVector3, air);
|
||||
return;
|
||||
}
|
||||
if (bubble_column != null && baseBlock.equals(bubble_column)) {
|
||||
clipboard.setBlock(blockVector3, air);
|
||||
return;
|
||||
}
|
||||
String blockName = clipboard.getFullBlock(blockVector3).getBlockType().getName();
|
||||
if (blockName.equals("Water")) {
|
||||
clipboard.setBlock(blockVector3, air);
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.core.VersionDependent;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public interface TickManager extends Listener {
|
||||
TickManager impl = VersionDependent.getVersionImpl(BauSystem.getInstance());
|
||||
|
||||
void setTickRate(float tickRate);
|
||||
float getTickRate();
|
||||
|
||||
boolean canFreeze();
|
||||
void setFreeze(boolean freeze);
|
||||
boolean isFrozen();
|
||||
|
||||
void stepTicks(int ticks);
|
||||
boolean isStepping();
|
||||
|
||||
void sprintTicks(int ticks);
|
||||
boolean isSprinting();
|
||||
|
||||
void setBlockTpsPacket(boolean block);
|
||||
long getRemainingTicks();
|
||||
long getDoneTicks();
|
||||
long getTotalTicks();
|
||||
}
|
||||
@ -0,0 +1,203 @@
|
||||
package de.steamwar.bausystem.utils.cursor;
|
||||
|
||||
import de.steamwar.bausystem.utils.RayTraceUtils;
|
||||
import de.steamwar.entity.REntity;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.entity.RFallingBlockEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@Getter
|
||||
public abstract class Cursor {
|
||||
private final World WORLD = Bukkit.getWorlds().get(0);
|
||||
|
||||
private final REntityServer targetServer;
|
||||
private final REntityServer cursorServer;
|
||||
|
||||
private final Player owner;
|
||||
private final Material highlightMaterial;
|
||||
|
||||
private RFallingBlockEntity cursorEntity;
|
||||
|
||||
private Location cursorLocation;
|
||||
private boolean isHittingEntity = false;
|
||||
|
||||
@Setter
|
||||
private Material cursorMaterial;
|
||||
@Setter
|
||||
private List<CursorMode> allowedCursorModes;
|
||||
private boolean visible = true;
|
||||
|
||||
|
||||
|
||||
protected Cursor(REntityServer targetServer, Player owner, Material highlightMaterial, Material cursorMaterial, List<CursorMode> allowedModes) {
|
||||
this.targetServer = targetServer;
|
||||
this.owner = owner;
|
||||
this.highlightMaterial = highlightMaterial;
|
||||
this.cursorMaterial = cursorMaterial;
|
||||
this.allowedCursorModes = allowedModes;
|
||||
|
||||
cursorServer = new REntityServer();
|
||||
cursorServer.addPlayer(owner);
|
||||
|
||||
CursorManager.getInstance().registerCursor(this);
|
||||
}
|
||||
|
||||
public void render() {
|
||||
if (!visible)
|
||||
return;
|
||||
|
||||
RayTraceUtils.RRayTraceResult rayTraceResult = RayTraceUtils.traceREntity(owner, owner.getLocation(), targetServer.getEntities());
|
||||
if (rayTraceResult == null) {
|
||||
if (cursorEntity != null)
|
||||
cursorEntity.die();
|
||||
cursorEntity = null;
|
||||
return;
|
||||
}
|
||||
|
||||
REntity hitEntity = rayTraceResult.getHitEntity() == cursorEntity ? null : rayTraceResult.getHitEntity();
|
||||
|
||||
|
||||
Material activeCursorMaterial = hitEntity == null ? cursorMaterial : highlightMaterial;
|
||||
CursorMode activeCursorMode = allowedCursorModes.stream().filter((mode) -> mode.isActive.test(owner)).min(Comparator.comparingInt(a -> a.priority))
|
||||
.orElse(CursorMode.BLOCK_ALIGNED);
|
||||
|
||||
Location activeCursorLocation = hitEntity == null ? activeCursorMode.positionTransform.apply(owner, rayTraceResult).toLocation(WORLD)
|
||||
: new Vector(hitEntity.getX(), hitEntity.getY(), hitEntity.getZ()).toLocation(WORLD);
|
||||
|
||||
cursorLocation = activeCursorLocation;
|
||||
isHittingEntity = hitEntity != null;
|
||||
|
||||
if (cursorEntity == null) {
|
||||
cursorEntity = new RFallingBlockEntity(cursorServer, activeCursorLocation, activeCursorMaterial);
|
||||
cursorEntity.setNoGravity(true);
|
||||
} else if (cursorEntity.getMaterial() == activeCursorMaterial) {
|
||||
cursorEntity.move(activeCursorLocation);
|
||||
} else {
|
||||
cursorEntity.die();
|
||||
cursorEntity = new RFallingBlockEntity(cursorServer, activeCursorLocation, activeCursorMaterial);
|
||||
cursorEntity.setNoGravity(true);
|
||||
if (activeCursorMaterial == highlightMaterial) {
|
||||
cursorEntity.setGlowing(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
visible = false;
|
||||
if (cursorEntity != null) {
|
||||
cursorEntity.die();
|
||||
cursorEntity = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void show() {
|
||||
visible = true;
|
||||
}
|
||||
|
||||
final void handleClick(Action action) {
|
||||
if (!visible)
|
||||
return;
|
||||
|
||||
onClick(Optional.ofNullable(this.cursorLocation), isHittingEntity, action);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
cursorServer.close();
|
||||
CursorManager.getInstance().unregisterCursor(this);
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
public enum CursorMode {
|
||||
FREE(1, (player, rayTraceResult) -> {
|
||||
Vector pos = rayTraceResult.getHitPosition();
|
||||
|
||||
BlockFace face = rayTraceResult.getHitBlockFace();
|
||||
if (face != null) {
|
||||
switch (face) {
|
||||
case DOWN:
|
||||
pos.setY(pos.getY() - 0.98);
|
||||
break;
|
||||
case EAST:
|
||||
pos.setX(pos.getX() + 0.49);
|
||||
break;
|
||||
case WEST:
|
||||
pos.setX(pos.getX() - 0.49);
|
||||
break;
|
||||
case NORTH:
|
||||
pos.setZ(pos.getZ() - 0.49);
|
||||
break;
|
||||
case SOUTH:
|
||||
pos.setZ(pos.getZ() + 0.49);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (face.getModY() == 0 && player.isSneaking()) {
|
||||
pos.setY(pos.getY() - 0.49);
|
||||
}
|
||||
}
|
||||
|
||||
return pos;
|
||||
}, (player) -> player.isSneaking()),
|
||||
|
||||
BLOCK_ALIGNED(0, (player, rayTraceResult) -> {
|
||||
Vector pos = rayTraceResult.getHitPosition();
|
||||
|
||||
BlockFace face = rayTraceResult.getHitBlockFace();
|
||||
if (face != null) {
|
||||
switch (face) {
|
||||
case DOWN:
|
||||
pos.setY(pos.getY() - 0.98);
|
||||
break;
|
||||
case EAST:
|
||||
pos.setX(pos.getX() + 0.49);
|
||||
break;
|
||||
case WEST:
|
||||
pos.setX(pos.getX() - 0.49);
|
||||
break;
|
||||
case NORTH:
|
||||
pos.setZ(pos.getZ() - 0.49);
|
||||
break;
|
||||
case SOUTH:
|
||||
pos.setZ(pos.getZ() + 0.49);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pos.setX(pos.getBlockX() + 0.5);
|
||||
if (pos.getY() - pos.getBlockY() != 0 && face == BlockFace.UP) {
|
||||
pos.setY(pos.getBlockY() + 1.0);
|
||||
} else {
|
||||
pos.setY(pos.getBlockY());
|
||||
}
|
||||
pos.setZ(pos.getBlockZ() + 0.5);
|
||||
return pos;
|
||||
}, (player) -> true);
|
||||
|
||||
|
||||
private final int priority;
|
||||
private final BiFunction<Player, RayTraceUtils.RRayTraceResult, Vector> positionTransform;
|
||||
private final Predicate<Player> isActive;
|
||||
}
|
||||
|
||||
public abstract void onClick(Optional<Location> cursorLocation, boolean didHitEntity, Action action);
|
||||
}
|
||||
@ -0,0 +1,118 @@
|
||||
package de.steamwar.bausystem.utils.cursor;
|
||||
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
@Linked
|
||||
public class CursorManager implements Listener {
|
||||
@Getter
|
||||
private static CursorManager instance;
|
||||
|
||||
private final Set<Player> calculationActive = new HashSet<>();
|
||||
private final Map<Player, List<Cursor>> activeCursors = new HashMap<>();
|
||||
|
||||
public CursorManager() {
|
||||
if (instance == null) {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
BiFunction<Player, Object, Object> function = (player, object) -> {
|
||||
updateCursors(player);
|
||||
return object;
|
||||
};
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
Set<Player> playersWithActiveCursor = activeCursors.keySet();
|
||||
|
||||
playersWithActiveCursor.forEach(this::updateCursors);
|
||||
}, 0);
|
||||
|
||||
Class<?> positionPacketClass = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Pos");
|
||||
Class<?> lookPacketClass = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Rot");
|
||||
Class<?> positionLookPacketClass = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$PosRot");
|
||||
|
||||
TinyProtocol.instance.addFilter(positionPacketClass, function);
|
||||
TinyProtocol.instance.addFilter(lookPacketClass, function);
|
||||
TinyProtocol.instance.addFilter(positionLookPacketClass, function);
|
||||
}
|
||||
|
||||
void registerCursor(Cursor cursor) {
|
||||
List<Cursor> cursorsOfPlayer = activeCursors.getOrDefault(cursor.getOwner(), new ArrayList<>());
|
||||
cursorsOfPlayer.add(cursor);
|
||||
activeCursors.put(cursor.getOwner(), cursorsOfPlayer);
|
||||
}
|
||||
|
||||
void unregisterCursor(Cursor cursor) {
|
||||
List<Cursor> cursorsOfPlayer = activeCursors.get(cursor.getOwner());
|
||||
if (cursorsOfPlayer != null) {
|
||||
cursorsOfPlayer.remove(cursor);
|
||||
if (cursorsOfPlayer.isEmpty()) {
|
||||
activeCursors.remove(cursor.getOwner());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void closeCursorsOf(Player player) {
|
||||
List<Cursor> cursorsOfPlayer = activeCursors.remove(player);
|
||||
if (cursorsOfPlayer != null) {
|
||||
new ArrayList<>(cursorsOfPlayer).forEach(Cursor::close);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void updateCursors(Player player) {
|
||||
if (!activeCursors.containsKey(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (calculationActive) {
|
||||
if (calculationActive.contains(player)) {
|
||||
return;
|
||||
} else {
|
||||
calculationActive.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
List<Cursor> cursors = activeCursors.get(player);
|
||||
|
||||
if (cursors != null) {
|
||||
cursors.forEach(Cursor::render);
|
||||
}
|
||||
|
||||
synchronized (calculationActive) {
|
||||
calculationActive.remove(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void handlePlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
List<Cursor> cursorsOfPlayer = activeCursors.get(player);
|
||||
if (cursorsOfPlayer != null) {
|
||||
cursorsOfPlayer.forEach(cursor -> cursor.handleClick(event.getAction()));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void handlePlayerQuit(PlayerQuitEvent event) {
|
||||
closeCursorsOf(event.getPlayer());
|
||||
}
|
||||
}
|
||||
419
BauSystem/SCRIPT.md
Normal file
419
BauSystem/SCRIPT.md
Normal file
@ -0,0 +1,419 @@
|
||||
# SteamWar.de - Script System
|
||||
|
||||
---
|
||||
<!-- TOC -->
|
||||
* [SteamWar.de - Script System](#steamwarde---script-system)
|
||||
* [Einleitung](#einleitung)
|
||||
* [Nutzung mit einer IDE](#nutzung-mit-einer-ide)
|
||||
* [Basis-Apis](#basis-apis)
|
||||
* [SteamWar.de-Api](#steamwarde-api)
|
||||
* [player](#player)
|
||||
* [random](#random)
|
||||
* [region](#region)
|
||||
* [tnt](#tnt)
|
||||
* [trace](#trace)
|
||||
* [server](#server)
|
||||
* [tps](#tps)
|
||||
* [storage](#storage)
|
||||
* [inventory](#inventory)
|
||||
* [SteamWar.de-Global-Api](#steamwarde-global-api)
|
||||
* [Commands](#commands)
|
||||
* [Hotkeys](#hotkeys)
|
||||
* [Eventtypen](#eventtypen)
|
||||
* [BlockEvent](#blockevent)
|
||||
* [InteractEvent](#interactevent)
|
||||
* [Position](#position)
|
||||
* [Instabile APIs](#instabile-apis)
|
||||
* [_worldedit](#worldedit)
|
||||
* [Beispiele](#beispiele)
|
||||
* [Hello, World!](#hello-world)
|
||||
* [Code](#code)
|
||||
* [Ausgabe](#ausgabe)
|
||||
* [BauGUI on DoubleSwap](#baugui-on-doubleswap)
|
||||
* [Code](#code-1)
|
||||
* [SL Command](#sl-command)
|
||||
* [Code](#code-2)
|
||||
* [Paste Hotkey](#paste-hotkey)
|
||||
* [Code](#code-3)
|
||||
* [Inventory](#inventory-1)
|
||||
* [Code](#code-4)
|
||||
<!-- TOC -->
|
||||
|
||||
|
||||
## Einleitung
|
||||
Das Script System auf SteamWar.de basiert auf [Lua](https://www.lua.org/docs.html).
|
||||
Der Code wird einfach in ein Minecraft Buch geschrieben und kann mit einem Links-Klick ausgeführt werden.
|
||||
|
||||
## Nutzung mit einer IDE
|
||||
Im Repository liegen [Lua-Definitionen](sw.def.lua) für [Luanalysis](https://plugins.jetbrains.com/plugin/14698-luanalysis).
|
||||
Diese können in der IDE genutzt werden, um die APIs zu nutzen.
|
||||
|
||||
Einfach die `sw.def.lua` in denselben Ordner wie das Script legen und die IDE sollte die APIs erkennen.
|
||||
|
||||
# Basis-Apis
|
||||
Es werden folgende Standard-Apis zur Verfügung gestellt:
|
||||
- [`math`](https://www.lua.org/manual/5.4/manual.html#6.7)
|
||||
- [`string`](https://www.lua.org/manual/5.4/manual.html#6.4)
|
||||
- [`table`](https://www.lua.org/manual/5.4/manual.html#6.6)
|
||||
- [`bit32`](https://www.lua.org/manual/5.2/manual.html#6.7)
|
||||
|
||||
# SteamWar.de-Api
|
||||
APIs, die mit einem `_` beginnen sind noch nicht stabil und können sich jederzeit ändern.
|
||||
Sie sollten daher nicht verwendet werden, da sie sich noch in der Entwicklung befinden.
|
||||
Diese können auch undokumentierte Funktionen enthalten, die nicht in der Dokumentation aufgeführt sind.
|
||||
|
||||
In den Scripten gibt es dazu noch folgende globale Variablen:
|
||||
- [`player`](#player)
|
||||
- [`random`](#random)
|
||||
- [`region`](#region)
|
||||
- [`server`](#server)
|
||||
- [`storage`](#storage)
|
||||
- [`inventory`](#inventory)
|
||||
- `_worldedit`
|
||||
|
||||
Ohne eine Kategorie sind folgende Funktionen verfügbar, die nicht allgemein sind:
|
||||
|
||||
| Name | Signature | Beschreibung |
|
||||
|-----------|-----------------------------------|-------------------------------------------------------------------------------------------------------------------|
|
||||
| `print` | print(String...) | @see chat(String...) |
|
||||
| `input` | input(String, Function\<String>) | Fragt den User nach einer Eingabe mit der Nachricht und called die zugehörige Funktion nach dieser |
|
||||
| `delayed` | delayed(Number, Function\<Void>) | Wartet die angegebene Anzahl an Ticks und führt danach die zugehörige Funktion aus |
|
||||
| `pos` | pos(Number, Number, Number) | Erstellt aus drei Zahlen eine Position-Table. Die Koordinaten sind unter den Namen `x`, `y` und `z` abgespeichert |
|
||||
| `exec` | exec(String...) | Führt den angegebenen Befehl als Spieler aus |
|
||||
| `length` | length(Any): Int | Gibt die Länge des Objekts zurück |
|
||||
| `join` | length(String, String...): String | Füge die Texte mit den ersten Parameter zusammen |
|
||||
|
||||
### player
|
||||
Das `player`-Modul stellt Funktionen zur Verfügung, die den Spieler betreffen.
|
||||
Es gibt folgende Funktionen:
|
||||
|
||||
| Name | Signature | Beschreibung |
|
||||
|------------------|--------------------------------|---------------------------------------------------------------------------------------------------------------------------|
|
||||
| `name` | name(): String | Gibt den `displayName` des Spielers zurück |
|
||||
| `chat` | chat(String...) | Sendet den Text in den Chat des Spielers |
|
||||
| `actionbar` | actionbar(String...) | Sendet den Text in die ActionBar des Spielers |
|
||||
| `x` | x(Number), x(): Number | Setzt oder gibt die X-Koordinate des Spielers |
|
||||
| `y` | y(Number), y(): Number | Setzt oder gibt die Y-Koordinate des Spielers |
|
||||
| `z` | z(Number), z(): Number | Setzt oder gibt die Z-Koordinate des Spielers |
|
||||
| `yaw` | yaw(Number), yaw(): Number | Setzt oder gibt die Gierung des Spielers |
|
||||
| `pitch` | pitch(Number), pitch(): Number | Setzt oder gibt die Steigung des Spielers |
|
||||
| `sneaking` | sneaking(): Boolean | Wahr, wenn der Spieler am Sneaken ist |
|
||||
| `sprinting` | sprinting(): Boolean | Wahr, wenn der Spieler am Sprinten ist |
|
||||
| `slot` | slot(Number), slot(): Number | Setzt oder gibt den Slot des gehaltenden Items des Spielers [(Wiki)](https://minecraft.fandom.com/wiki/Slot#Java_Edition) |
|
||||
| `item` | item(): String | Gibt den Itemtyp der Main-Hand zurück |
|
||||
| `offHandItem` | offHandItem(): String | Gibt den Itemtyp der Off-Hand zurück |
|
||||
| `closeInventory` | closeInventory() | Schließe das aktuell geöffnete Inventar des Spielers |
|
||||
|
||||
### random
|
||||
Das `random`-Modul stellt Funktionen zur Verfügung, die Zufallszahlen betreffen.
|
||||
Es gibt folgende Funktionen:
|
||||
|
||||
| Name | Signature | Beschreibung |
|
||||
|------------|------------------------------------|-------------------------------------------------------------------------------|
|
||||
| nextInt | nextInt(): Int | Gibt eine Zufallszahl zurück zwischen Integer.MIN_VALUE und Integer.MAX_VALUE |
|
||||
| -"- | nextInt(Int): Int | Gibt eine Zufallszahl zurück zischen 0 und dem Argument |
|
||||
| -"- | nextInt(Int, Int): Int | Gibt eine Zufallszahl zurück zwischen dem ersten und zweiten Argument |
|
||||
| nextDouble | nextDouble(): Double | Gibt eine Zufallszahl zurück zwischen 0 und 1 |
|
||||
| -"- | nextDouble(Double): Double | Gibt eine Zufallszahl zurück zwischen 0 und dem Argument |
|
||||
| -"- | nextDouble(Double, Double): Double | Gibt eine Zufallszahl zurück zwischen ersten und zweiten Argument |
|
||||
| nextBool | nextBool(): Boolean | Gibt true oder false zurück |
|
||||
|
||||
### region
|
||||
Das `region`-Modul stellt Funktion zur Verfügung, die die Region des Spielers betreffen.
|
||||
Es gibt folgende Funktionen:
|
||||
|
||||
| Name | Signature | Beschreibung |
|
||||
|-----------|---------------------|------------------------------------------------------------------------------------------------------------|
|
||||
| `name` | name(): String | Gibt den Regionsnamen |
|
||||
| `type` | type(): String | Gibt den Regionstyp |
|
||||
| `fire` | fire(): Boolean | Gibt den Fire-Modus der Region zurück |
|
||||
| `freeze` | freeze(): Boolean | Gibt den Freeze-Modus der Region zurück |
|
||||
| `protect` | protect(): Boolean | Gibt den Protect-Modus der Region zurück |
|
||||
| `loader` | loader(): String | Gibt den Status des Loaders des Spielers zurück, die Werte sind: `OFF`, `SETUP`, `RUNNING`, `PAUSE`, `END` |
|
||||
| `get` | get(String): Region | Gibt die Region mit dem Namen zurück. Die Region ist gleich aufgebaut wie das Regions-Modul |
|
||||
| `list` | list(): Region[] | Gibt alle Region zurück. Die Region ist gleich aufgebaut wie das Regions-Modul |
|
||||
|
||||
Es gibt folgende weitere Module:
|
||||
|
||||
| Name | Beschreibung |
|
||||
|---------|-----------------|
|
||||
| `tnt` | [tnt](#tnt) |
|
||||
| `trace` | [trace](#trace) |
|
||||
|
||||
#### tnt
|
||||
Das `tnt`-Modul stellt Funktionen zur Verfügung, die den TNT-Modus in der Region des Spielers betreffen.
|
||||
Es gibt folgende Funktionen:
|
||||
|
||||
| Name | Signature | Beschreibung |
|
||||
|-------------|----------------------|-------------------------------------------------------------------------------------|
|
||||
| `mode` | mode(): String | Gibt den Aktuellen TNT-Modus zurück, die werte sind: `ALLOW`, `DENY` oder `ONLY_TB` |
|
||||
| `enabled` | enabled(): Boolean | Gibt zurück, ob der TNT-Modus in der Region des Spielers aktiviert ist oder nicht |
|
||||
| `onlyTb` | onlyTb(): Boolean | Gibt zurück, ob der TNT-Modus auf Only-Tb ist |
|
||||
| `onlyBuild` | onlyBuild(): Boolean | Gibt zurück, ob der TNT-Modus auf Only-Build ist |
|
||||
|
||||
|
||||
#### trace
|
||||
Das `trace`-Modul stellt Funktionen zur Verfügung, die den Status des Tracers der Region betreffen.
|
||||
Es gibt folgende Funktionen:
|
||||
|
||||
| Name | Signature | Beschreibung |
|
||||
|----------|-------------------|--------------------------------------------------------------------------------|
|
||||
| `active` | active(): Boolean | Gibt zurück, ob der Tracer in der Region des Spielers aktiviert ist oder nicht |
|
||||
| `auto` | auto(): Boolean | Gibt zurück, ob der Tracer in der Region ein Auto-Tracer ist |
|
||||
| `status` | status(): String | Gibt den Status des Tracers zurück |
|
||||
| `time` | time(): String | Gibt die Zeit des Tracers zurück |
|
||||
|
||||
## server
|
||||
Das `server`-Modul stellt Funktionen zur Verfügung, die den Server betreffen.
|
||||
Es gibt folgende Funktionen:
|
||||
|
||||
| Name | Signature | Beschreibung |
|
||||
|--------------|-------------------------|---------------------------------------------------------------------|
|
||||
| `time` | time(): String | Gibt die aktuelle Zeit im Format `HH:mm:ss` zurück |
|
||||
| `ticks` | ticks(): Number | Gibt die Ticks seit start des Serverstarts zurück |
|
||||
| `getBlockAt` | getBlockAt(Pos): String | Gibt das Material an der Position zurück |
|
||||
| `setBlockAt` | setBlockAt(Pos, String) | Setzt das Material an der angegebenen Stelle (z.B. Stein = `STONE`) |
|
||||
|
||||
Es gibt folgende weitere Module:
|
||||
|
||||
| Name | Beschreibung |
|
||||
|-------|--------------|
|
||||
| `tps` | [tps](#tps) |
|
||||
|
||||
#### tps
|
||||
Das `tps`-Modul stellt Funktionen zur Verfügung, die die TPS des Servers betreffen.
|
||||
Es gibt folgende Funktionen:
|
||||
|
||||
| Name | Signature | Beschreibung |
|
||||
|--------------|----------------------|-------------------------------------------------------------------|
|
||||
| `current` | current(): Number | Gibt die aktuelle TPS zurück (Das selbe wie `oneSecound()`) |
|
||||
| `oneSecond` | oneSecond(): Number | Gibt die durchschnittliche TPS über die letzte Sekunde zurück |
|
||||
| `tenSecond` | tenSecond(): Number | Gibt die durchschnittliche TPS über die letzte 10 Sekunden zurück |
|
||||
| `oneMinute` | oneMinute(): Number | Gibt die durchschnittliche TPS über die letzte Minute zurück |
|
||||
| `fiveMinute` | fiveMinute(): Number | Gibt die durchschnittliche TPS über die letzte 5 Minuten zurück |
|
||||
| `tenMinute` | tenMinute(): Number | Gibt die durchschnittliche TPS über die letzte 10 Minuten zurück |
|
||||
| `limit` | limit(): Number | Gibt das TPS-Limit zurück |
|
||||
|
||||
## storage
|
||||
Das `storage`-Modul stellt Funktionen zur Verfügung, mit welchen man Werte speichern kann.
|
||||
|
||||
Es gibt folgende Module:
|
||||
|
||||
| Name | Beschreibung |
|
||||
|----------|---------------------|
|
||||
| `player` | Spieler abhängig |
|
||||
| `region` | Region des Spielers |
|
||||
| `global` | Alle Skripte |
|
||||
|
||||
Alle Module haben folgende Funktionen:
|
||||
|
||||
| Name | Signature | Beschreibung |
|
||||
|------------|----------------------------|--------------------------------------------------------|
|
||||
| `get` | get(String): Any | Gibt den Wert des Schlüssels zurück |
|
||||
| `set` | set(String, Any) | Setzt den Wert des Schlüssels auf den angegebenen Wert |
|
||||
| `has` | has(String): Boolean | Prüft ob ein Wert vorhanden ist |
|
||||
| `remove` | remove(String) | Löscht den Schlüssel |
|
||||
| `accessor` | accessor(String): Accessor | Gibt einen Accessor zurück |
|
||||
|
||||
Ein Accessor ist ein Objekt, womit du direkt auf einen Wert zugreifen kannst und es ändern kannst.
|
||||
Es geht wie folgt:
|
||||
```lua
|
||||
keyAccessor = storage.player.accessor("key")
|
||||
|
||||
keyAccessor("Hello World") -- Setzt den Wert auf "Hello World"
|
||||
print(keyAccessor()) -- Gibt den Wert zurück
|
||||
```
|
||||
|
||||
## inventory
|
||||
Das `inventory`-Modul stellt Funktionen zur Verfügung, um ein Inventar zu öffnen.
|
||||
Es gibt folgende Funktionen:
|
||||
|
||||
| Name | Signature | Beschreibung |
|
||||
|----------|-----------------------------------|-------------------------------------------------------------------|
|
||||
| `create` | create(String, Number): Inventory | Erstellt ein Inventar mit dem Title und der Anzahl an Zeilen |
|
||||
|
||||
Das `Inventory`-Objekt hat folgende Funktionen:
|
||||
|
||||
| Name | Signature | Beschreibung |
|
||||
|-------------------|--------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `item` | item(Number, String, String, Function\<String>) | Setze ein Item mit dem Typen des ersten Strings an den Slot (Startet bei 0) mit dem Namen des zweiten Strings mit einem Klick-Handler der den Klick-Typen rein gibt (z.B. `LEFT`, `SHIFT_LEFT`, `RIGHT`, `SHIFT_RIGHT`) |
|
||||
| -"- | item(Number, String, String, Function\<String>, List<String>) | Füge eine Lore an das Item hinzu |
|
||||
| -"- | item(Number, String, String, Function\<String>, List<String>, Boolean) | Gebe an, ob das Item enchanted sein soll |
|
||||
| -"- | item(Number, String, String, Function\<String>, List<String>, Boolean, Number) | Gebe die Anzahl der Items an |
|
||||
| `setCloseHandler` | setCloseHandler(Function\<Void>) | Gebe einen Handler an, der beim schließen des Inventares ausgeführt wird |
|
||||
| `open` | open() | Öffne das Inventar |
|
||||
|
||||
Siehe auch: [Inventory Beispiel](#inventory-1)
|
||||
|
||||
Siehe auch: [Liste an Materials](https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html)
|
||||
|
||||
```
|
||||
⚠️⚠️⚠️
|
||||
|
||||
Wenn eine Barrier statt des richtigen Items angezeigt wird, dann ist das angegebene Material nicht gültig.
|
||||
|
||||
⚠️⚠️⚠️
|
||||
```
|
||||
|
||||
# SteamWar.de-Global-Api
|
||||
Mit `/script` kann man Script-Bücher global abspeichern. Diese haben dann zugrif auf die `global`-Api.
|
||||
Die `global`-Api stellt Funktionen zur Verfügung um auf Events, Commands und Hotkeys mit einem Script zu reagieren.
|
||||
|
||||
Es gibt folgende Funktionen:
|
||||
|
||||
| Name | Signature | Beschreibung |
|
||||
|-----------|-----------------------------------|-----------------------------------------------------------------------------|
|
||||
| `event` | event(EventType, Function(Any)) | Registriere einen Event Listener |
|
||||
| `command` | command(String, Function(Args)) | Registriere einen Befehl |
|
||||
| `hotkey` | hotkey(String, Function(Boolean)) | Registriere einen Hotkey, the function gets a boolean if the key is pressed |
|
||||
|
||||
Es gibt folgende Variablen:
|
||||
|
||||
| Name | Beschreibung |
|
||||
|----------|----------------------------------|
|
||||
| `events` | Siehe: [Event Type](#eventtypen) |
|
||||
|
||||
## Commands
|
||||
Der Command Handler kriegt eine Liste aller angegeben argumenten. Die Argumente sind vom Typ `String`. Mit dem Wert gespeichert unter `args.alias` oder `args["alias"]` erhältst du, welcher command eingegeben wurde. Wenn ein handler für mehrere Befehle registriert wurde kannst du es hiermit erkennen.
|
||||
Du kannst `args.hasShortFlag(String)` um herauszufinden ob eine Flag angegeben wurde wie zum Beispiel `-f`. Mit `args.removeShortFlag(String)` kannst du die Flag entfernen und erhältst ob sie angegeben wurde.
|
||||
|
||||
## Hotkeys
|
||||
|
||||
Hotkeys werden im folgenden Format angegeben: `MODIFIER+KEY`. Bei den Hotkey erstellung ist die Großschreibung egal. Es gibt folgende Modifier:
|
||||
- `ctrl`
|
||||
- `shift`
|
||||
- `alt`
|
||||
- `meta`
|
||||
|
||||
Es können auch mehrere Modifier angegeben werden, z.B. `ctrl+shift+alt+c`. Die Reihenfolge der Modifier und des Keys ist egal.
|
||||
|
||||
## Eventtypen
|
||||
Einige Events sind auch abbrechbar, dazu muss die Funktion `setCancelled()` aufgerufen werden.
|
||||
|
||||
| Name | Wenn | Parameter | Abbrechbar |
|
||||
|---------------------|-----------------------------------------------------|---------------------------------|------------|
|
||||
| `DoubleSwap` | Beim Doppelten Drücken der Swap-Hands taste | NIL | false |
|
||||
| `PlaceBlock` | Beim Platzieren von Blöcken | [BlockEvent](#blockevent) | true |
|
||||
| `BreakBlock` | Beim Zerstören von Blöcken | [BlockEvent](#blockevent) | true |
|
||||
| `RightClick` | Beim Rechtsklick | [InteractEvent](#interactevent) | true |
|
||||
| `LeftClick` | Beim Linksklick | [InteractEvent](#interactevent) | true |
|
||||
| `TNTSpawn` | Wenn ein TNT in der aktuellen Region spawnt | NIL | false |
|
||||
| `TNTExplode` | Wenn ein TNT in der aktuellen Region explodiert | [Position](#position) | true |
|
||||
| `TNTExplodeInBuild` | Wenn ein TNT in der aktuellen Bau Region explodiert | [Position](#position) | true |
|
||||
| `SelfJoin` | Wenn man selbst den Server betritt | NIL | false |
|
||||
| `SelfLeave` | Wenn man den Server verlässt | NIL | false |
|
||||
| `DropItem` | Wenn man ein Item droppt | (type: Material) | true |
|
||||
| `EntityDeath` | Wenn ein Entity stirbt | (type: Entity Type) | false |
|
||||
|
||||
### BlockEvent
|
||||
Das übergebene Objekt an den Handler hat folgende Variablen:
|
||||
|
||||
| Name | Beschreibung |
|
||||
|--------|-----------------------------|
|
||||
| `x` | Die X-Koordinate des Blocks |
|
||||
| `y` | Die Y-Koordinate des Blocks |
|
||||
| `z` | Die Z-Koordinate des Blocks |
|
||||
| `type` | Das Material des Blocks |
|
||||
|
||||
### InteractEvent
|
||||
Das übergebene Objekt an den Handler hat folgende Variablen:
|
||||
|
||||
| Name | Beschreibung |
|
||||
|------------|-------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `action` | Die Action die ausgeführt wurde, Mögliche Werte: `RIGHT_CLICK_BLOCK`, `RIGHT_CLICK_AIR`, `LEFT_CLICK_BLOCK`, `LEFT_CLICK_AIR` |
|
||||
| `hand` | Die Hand die zum ausführen genutzt wird, Mögliche Werte: `HAND`, `OFF_HAND`, `null` |
|
||||
| `block` | Der Typ des Items mit dem geklickt wurde |
|
||||
| `hasBlock` | Wahr, wenn auf einen Block geklickt wurde |
|
||||
|
||||
Wenn `hasBlock` wahr ist, gibt es folgende Variablen:
|
||||
|
||||
| Name | Beschreibung |
|
||||
|-------------|-----------------------------------------|
|
||||
| `blockX` | Die X-Koordinate des Blocks |
|
||||
| `blockY` | Die Y-Koordinate des Blocks |
|
||||
| `blockZ` | Die Z-Koordinate des Blocks |
|
||||
| `blockFace` | Die Seite des Blocks die geklickt wurde |
|
||||
|
||||
|
||||
### Position
|
||||
Die Position ist ein Objekt mit folgenden Variablen:
|
||||
|
||||
| Name | Beschreibung |
|
||||
|------|------------------|
|
||||
| `x` | Die X-Koordinate |
|
||||
| `y` | Die Y-Koordinate |
|
||||
| `z` | Die Z-Koordinate |
|
||||
|
||||
# Instabile APIs
|
||||
Hier sind einige APIs aufgelistet, die nicht stabil sind und sich jederzeit ändern können.
|
||||
|
||||
## _worldedit
|
||||
|
||||
| Name | Signatur | Beschreibung |
|
||||
|-------------|-----------------------------------------------------------|-----------------------------------|
|
||||
| `selection` | selection(Liste\<Pos>), selection(): {min: Pos, max: Pos} | Die aktuelle auswahl des Spielers |
|
||||
|
||||
|
||||
|
||||
# Beispiele
|
||||
|
||||
## Hello, World!
|
||||
Ein einfaches Hello, World!-Script.
|
||||
|
||||
#### Code
|
||||
```lua
|
||||
print("Hello, World!")
|
||||
```
|
||||
|
||||
#### Ausgabe
|
||||
```
|
||||
Hello, World!
|
||||
```
|
||||
|
||||
## BauGUI on DoubleSwap
|
||||
Das Standardskript für das Öffnen des BauGUIs
|
||||
|
||||
#### Code
|
||||
```lua
|
||||
function handler(event)
|
||||
exec("gui")
|
||||
end
|
||||
|
||||
event(events.DoubleSwap, handler)
|
||||
```
|
||||
|
||||
## SL Command
|
||||
Ein einfacher Command Redefiner.
|
||||
|
||||
#### Code
|
||||
```lua
|
||||
function handler(args)
|
||||
exec("stoplag")
|
||||
end
|
||||
|
||||
command("sl", handler)
|
||||
```
|
||||
|
||||
## Paste Hotkey
|
||||
Ein Hotkey zum Pasten des Clipboard-Inhalts.
|
||||
|
||||
#### Code
|
||||
```lua
|
||||
function handler(pressed)
|
||||
if pressed then
|
||||
exec("/paste -o")
|
||||
end
|
||||
end
|
||||
|
||||
hotkey("ctrl+v", handler)
|
||||
```
|
||||
|
||||
## Inventory
|
||||
Ein Beispiel für ein Inventar.
|
||||
|
||||
#### Code
|
||||
```lua
|
||||
inv = inventory.create("Test Inv", 3)
|
||||
inv.item(13, "STONE", "Ich bin ein Stein", function(e) player.chat(e) end, {"Die Lore", "Die Zweite Zeile"}, true)
|
||||
inv.open()
|
||||
```
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
@ -34,3 +34,20 @@ dependencies {
|
||||
implementation(project(":BauSystem:BauSystem_20"))
|
||||
implementation(project(":BauSystem:BauSystem_21"))
|
||||
}
|
||||
|
||||
tasks.register<DevServer>("DevBau20") {
|
||||
group = "run"
|
||||
description = "Run a 1.20 Dev Bau"
|
||||
dependsOn(":SpigotCore:shadowJar")
|
||||
dependsOn(":BauSystem:shadowJar")
|
||||
dependsOn(":SchematicSystem:shadowJar")
|
||||
template = "Bau20"
|
||||
}
|
||||
|
||||
tasks.register<DevServer>("DevBau21") {
|
||||
group = "run"
|
||||
description = "Run a 1.21 Dev Bau"
|
||||
dependsOn(":SpigotCore:shadowJar")
|
||||
dependsOn(":BauSystem:shadowJar")
|
||||
template = "Bau21"
|
||||
}
|
||||
|
||||
87
BauSystem/hotkeys.lua
Normal file
87
BauSystem/hotkeys.lua
Normal file
@ -0,0 +1,87 @@
|
||||
-- This file is a part of the SteamWar software.
|
||||
--
|
||||
-- Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
--
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU Affero General Public License
|
||||
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
---
|
||||
--- This serves both as an example and a quick start to the Stewamwar Script Api
|
||||
---
|
||||
|
||||
function hotkeys_freeze(pressed)
|
||||
if pressed then
|
||||
exec("/freeze")
|
||||
end
|
||||
end
|
||||
|
||||
function hotkeys_rgc(pressed)
|
||||
if pressed then
|
||||
exec("/rgc")
|
||||
end
|
||||
end
|
||||
|
||||
function hotkeys_rgp(pressed)
|
||||
if pressed then
|
||||
exec("/rgp")
|
||||
end
|
||||
end
|
||||
|
||||
trace_cycle_counter = 0;
|
||||
function hotkeys_cycle_trace_view(pressed)
|
||||
if not pressed then
|
||||
return
|
||||
end
|
||||
trace_cycle = (trace_cycle + 1) % 3
|
||||
trace_commands = {"trace hide", "trace show", "trace show -e -c"}
|
||||
exec(trace_commands[trace_cycle + 1])
|
||||
end
|
||||
|
||||
function hotkeys_tick_step(pressed)
|
||||
if pressed then
|
||||
exec("tick step")
|
||||
end
|
||||
end
|
||||
|
||||
function hotkeys_tpslimit(pressed)
|
||||
if not pressed then
|
||||
return
|
||||
end
|
||||
if tps.limit() == 20 then
|
||||
exec("tpslimit 200")
|
||||
else
|
||||
exec("tpslimit 20")
|
||||
end
|
||||
end
|
||||
|
||||
function hotkeys_tb(pressed)
|
||||
if pressed then
|
||||
exec("tb -e")
|
||||
end
|
||||
end
|
||||
|
||||
function hotkeys_trace_delete(pressed)
|
||||
if pressed then
|
||||
exec("trace delete")
|
||||
end
|
||||
end
|
||||
|
||||
hotkey("ctrl+g", hotkeys_freeze)
|
||||
hotkey("ctrl+c", hotkeys_rgc)
|
||||
hotkey("ctrl+v", hotkeys_rgp)
|
||||
hotkey("ctrl+x", hotkeys_tick_step)
|
||||
hotkey("shift+x", hotkeys_cycle_trace_view)
|
||||
hotkey("ctrl+y", hotkeys_tb)
|
||||
hotkey("ctrl+alt", hotkeys_trace_delete)
|
||||
hotkey("ctrl+h", hotkeys_trace_delete)
|
||||
|
||||
432
BauSystem/sw.def.lua
Normal file
432
BauSystem/sw.def.lua
Normal file
@ -0,0 +1,432 @@
|
||||
-- This file is a part of the SteamWar software.
|
||||
--
|
||||
-- Copyright (C) 2021 SteamWar.de-Serverteam
|
||||
--
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU Affero General Public License
|
||||
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
---
|
||||
--- This file contains the definitions for the SteamWar.de script API.
|
||||
--- It is used by the IDE to provide code completion and type checking.
|
||||
--- Created by Chaoscaot
|
||||
---
|
||||
|
||||
inventory = {}
|
||||
|
||||
---@param title string
|
||||
---@param size number
|
||||
---@return Inventory
|
||||
function inventory.create(title, size) return nil end
|
||||
|
||||
---@alias InventoryClick 'LEFT' | 'SHIFT_LEFT' | 'RIGHT' | 'SHIFT_RIGHT' | 'MIDDLE' | 'NUMBER_KEY'
|
||||
|
||||
---@class Inventory
|
||||
local Inventory = {}
|
||||
|
||||
---@overload fun(slot: number, material: string, name: string, handler: fun(click: InventoryClick)): void
|
||||
---@overload fun(slot: number, material: string, name: string, handler: fun(click: InventoryClick), lore: string[]): void
|
||||
---@overload fun(slot: number, material: string, name: string, handler: fun(click: InventoryClick), lore: string[], enchanted: boolean): void
|
||||
---@param slot number
|
||||
---@param material string
|
||||
---@param name string
|
||||
---@param handler fun(click: InventoryClick): void
|
||||
---@param lore string[]
|
||||
---@param enchanted boolean
|
||||
---@param amount number
|
||||
---@return void
|
||||
function Inventory.item(slot, material, name, handler, lore, enchanted, amount) end
|
||||
|
||||
---@param handler fun(): void
|
||||
---@return void
|
||||
function Inventory.setCloseHandler(handler) end
|
||||
|
||||
---@return void
|
||||
function Inventory.open() end
|
||||
|
||||
player = {}
|
||||
|
||||
---@return string
|
||||
---Get the name of the player.
|
||||
function player.name() return "" end
|
||||
|
||||
---@return void
|
||||
function player.chat(...) end
|
||||
|
||||
---@return void
|
||||
---Send a message to the actionbar of the player.
|
||||
function player.actionbar(...) end
|
||||
|
||||
---@overload fun(): number
|
||||
---@param newX number
|
||||
function player.x(newX) end
|
||||
|
||||
---@overload fun(): number
|
||||
---@param newY number
|
||||
function player.y(newY) end
|
||||
|
||||
---@overload fun(): number
|
||||
---@param newZ number
|
||||
function player.z(newZ) end
|
||||
|
||||
---@overload fun(): number
|
||||
---@param newYaw number
|
||||
function player.yaw(newYaw) end
|
||||
|
||||
---@overload fun(): number
|
||||
---@param newPitch number
|
||||
function player.pitch(newPitch) end
|
||||
|
||||
---@return boolean
|
||||
function player.sneaking() return nil end
|
||||
|
||||
---@return boolean
|
||||
function player.sprinting() return nil end
|
||||
|
||||
---@overload fun(): number
|
||||
---@param newSlot number
|
||||
function player.slot(newSlot) end
|
||||
|
||||
---@return string
|
||||
function player.item() return nil end
|
||||
|
||||
---@return string
|
||||
function player.offHandItem() return nil end
|
||||
|
||||
---@return void
|
||||
function player.closeInventory() end
|
||||
|
||||
---@field nextBool fun(): boolean
|
||||
random = {}
|
||||
|
||||
---@overload fun(): number
|
||||
---@overload fun(bound: number): number
|
||||
---@param origin number
|
||||
---@param bound number
|
||||
---@return number
|
||||
function random.nextInt(origin, bound) return nil end
|
||||
|
||||
---@overload fun(): number
|
||||
---@overload fun(bound: number): number
|
||||
---@param origin number
|
||||
---@param bound number
|
||||
---@return number
|
||||
function random.nextDouble(origin, bound) return nil end
|
||||
|
||||
---@return boolean
|
||||
function random.nextBool() return nil end
|
||||
|
||||
---@alias RegionType 'wg' | 'mwg' | 'as' | 'ws' | 'ws_inner' | 'ws_rumpf' | 'ws_rahmen' | 'spawn'
|
||||
|
||||
---@class iregion
|
||||
---@field tnt tnt
|
||||
---@field trace trace
|
||||
local iregion = {}
|
||||
|
||||
---@class region: iregion
|
||||
region = {}
|
||||
|
||||
---@return string
|
||||
function iregion.name() return nil end
|
||||
|
||||
---@return RegionType
|
||||
function iregion.type() return nil end
|
||||
|
||||
---@return boolean
|
||||
function iregion.fire() return nil end
|
||||
|
||||
---@return boolean
|
||||
function iregion.freeze() return nil end
|
||||
|
||||
---@return boolean
|
||||
function iregion.protect() return nil end
|
||||
|
||||
---@return string
|
||||
function iregion.loader() return nil end
|
||||
|
||||
---@return Position
|
||||
function iregion.copyPoint() return nil end
|
||||
|
||||
---@return Position
|
||||
function iregion.minPointBuild() return nil end
|
||||
|
||||
---@return Position
|
||||
function iregion.maxPointBuild() return nil end
|
||||
|
||||
---@return Position
|
||||
function iregion.minPointBuildExtension() return nil end
|
||||
|
||||
---@return Position
|
||||
function iregion.maxPointBuildExtension() return nil end
|
||||
|
||||
---@return Position
|
||||
function iregion.testblockPoint() return nil end
|
||||
|
||||
---@return Position
|
||||
function iregion.minPointTestblock() return nil end
|
||||
|
||||
---@return Position
|
||||
function iregion.maxPointTestblock() return nil end
|
||||
|
||||
---@return Position
|
||||
function iregion.minPointTestblockExtension() return nil end
|
||||
|
||||
---@return Position
|
||||
function iregion.maxPointTestblockExtension() return nil end
|
||||
|
||||
---@alias TNTMode 'ALLOW' | 'DENY' | 'ONLY_TB'
|
||||
|
||||
---@class tnt
|
||||
local tnt = {}
|
||||
|
||||
---@return TNTMode
|
||||
function tnt.mode() return nil end
|
||||
|
||||
---@return boolean
|
||||
function tnt.enabled() return nil end
|
||||
|
||||
---@return boolean
|
||||
function tnt.onlyTb() return nil end
|
||||
|
||||
---@return boolean
|
||||
function tnt.onlyBuild() return nil end
|
||||
|
||||
---@param name string
|
||||
---@return iregion
|
||||
function region.get(name) return nil end
|
||||
|
||||
---@return iregion[]
|
||||
function region.list() return nil end
|
||||
|
||||
---@class tracerLib
|
||||
tracer = {}
|
||||
|
||||
---@class TraceRecord
|
||||
---@field pos Position
|
||||
---@field vel Position
|
||||
---@field ticksSinceStart number
|
||||
---@field fuse number
|
||||
---@field isExplosion boolean
|
||||
---@field isInWater boolean
|
||||
---@field hasDestroyedBuild boolean
|
||||
---@field hasDestroyedTestblock boolean
|
||||
|
||||
---@class Tracer
|
||||
---@field getId fun(): string
|
||||
---@field getRecords fun(): {[number]: {[number]: TraceRecord}}
|
||||
|
||||
function tracer.getTraces() return nil end
|
||||
|
||||
---@class Position
|
||||
---@field x number
|
||||
---@field y number
|
||||
---@field z number
|
||||
|
||||
---@class server
|
||||
---@field tps tps
|
||||
server = {}
|
||||
|
||||
---@return string
|
||||
function server.time() return nil end
|
||||
|
||||
---@return number
|
||||
function server.ticks() return nil end
|
||||
|
||||
---@param position Position
|
||||
---@return string
|
||||
function getBlockAt(position) return nil end
|
||||
|
||||
---@param position Position
|
||||
---@param material string
|
||||
---@return void
|
||||
function setBlockAt(position, material) return nil end
|
||||
|
||||
---@class tps
|
||||
local tps = {}
|
||||
|
||||
---@return number
|
||||
function tps.oneSecond() return nil end
|
||||
|
||||
---@return number
|
||||
function tps.tenSecond() return nil end
|
||||
|
||||
---@return number
|
||||
function tps.oneMinute() return nil end
|
||||
|
||||
---@return number
|
||||
function tps.fiveMinute() return nil end
|
||||
|
||||
---@return number
|
||||
function tps.tenMinute() return nil end
|
||||
|
||||
---@return number
|
||||
function tps.current() return nil end
|
||||
|
||||
---@return number
|
||||
function tps.limit() return nil end
|
||||
|
||||
---@class storage
|
||||
---@field global storageLib
|
||||
---@field player storageLib
|
||||
---@field region storageLib
|
||||
storage = {}
|
||||
|
||||
---@class storageLib
|
||||
---Any Primitive, Array or Table will be saved across restarts, everything else will be discarded
|
||||
local storageLib = {}
|
||||
|
||||
---@param key string
|
||||
---@return any
|
||||
function storageLib.get(key) return nil end
|
||||
|
||||
---@param key string
|
||||
---@param value any
|
||||
---@return void
|
||||
function storageLib.set(key, value) end
|
||||
|
||||
---@param key string
|
||||
---@return boolean
|
||||
function storageLib.has(key) return nil end
|
||||
|
||||
---@param key string
|
||||
---@return void
|
||||
function storageLib.remove(key) end
|
||||
|
||||
---@param key string
|
||||
---@return Accessor
|
||||
function storageLib.accessor(key) return nil end
|
||||
|
||||
---@class Accessor
|
||||
---@overload fun(): any
|
||||
---@overload fun(value: any)
|
||||
|
||||
---@class Selection
|
||||
---@field max Position
|
||||
---@field min Position
|
||||
|
||||
---@class _worldedit
|
||||
_worldedit = {}
|
||||
|
||||
---@overload fun(pos: Position[]): void
|
||||
---@return Selection
|
||||
function _worldedit.selection() return nil end
|
||||
|
||||
---@param msg string
|
||||
---@param callback fun(value: string): void
|
||||
---@return void
|
||||
function input(msg, callback) end
|
||||
|
||||
---@param ticks number
|
||||
---@param callback fun(): void
|
||||
---@return void
|
||||
function delayed(ticks, callback) end
|
||||
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@param z number
|
||||
---@return Position
|
||||
function pos(x, y, z) return nil end
|
||||
|
||||
---@return void
|
||||
function exec(...) end
|
||||
|
||||
---@param obj any
|
||||
---@return number
|
||||
function length(obj) return 0 end
|
||||
|
||||
---@param separator string
|
||||
---@param table any[]
|
||||
---@return string
|
||||
function join(separator, table) return "" end
|
||||
|
||||
---@class EventType
|
||||
---@class events
|
||||
---@field DoubleSwap EventType
|
||||
---@field PlaceBlock EventType
|
||||
---@field BreakBlock EventType
|
||||
---@field RightClick EventType
|
||||
---@field LeftClick EventType
|
||||
---@field TNTSpawn EventType
|
||||
---@field TNTExplode EventType
|
||||
---@field TNTExplodeInBuild EventType
|
||||
---@field SelfJoin EventType
|
||||
---@field SelfLeave EventType
|
||||
---@field DropItem EventType
|
||||
---@field EntityDeath EventType
|
||||
events = {}
|
||||
|
||||
|
||||
---@param id EventType
|
||||
---@param handler fun(params: any): void
|
||||
---@return void
|
||||
function event(id, handler) end
|
||||
|
||||
---@param command string
|
||||
---@param handler fun(params: string[]): void
|
||||
---@return void
|
||||
function command(command, handler) end
|
||||
|
||||
---@param trigger string
|
||||
---@param handler fun(pressed: boolean): void
|
||||
---@return void
|
||||
function hotkey(trigger, handler) end
|
||||
|
||||
---@class bossbar
|
||||
bossbar = {}
|
||||
|
||||
---@alias BossBarColor 'PINK' | 'BLUE' | 'RED' | 'GREEN' | 'YELLOW' | 'PURPLE' | 'WHITE'
|
||||
---@alias BossBarStyle 'SEGMENTED_6' | 'SEGMENTED_10' | 'SEGMENTED_12' | 'SEGMENTED_20' | 'SOLID'
|
||||
---@alias BossBarFlag 'DARKEN_SKY' | 'PLAY_BOSS_MUSIC' | 'CREATE_FOG'
|
||||
|
||||
---@class BossBar
|
||||
local BossBar = {}
|
||||
|
||||
---@param title string
|
||||
---@param color BossBarColor
|
||||
---@param style BossBarStyle
|
||||
---@return BossBar
|
||||
function bossbar.create(title, color, style) return nil end
|
||||
|
||||
---@return string
|
||||
---@overload fun(title: string): void
|
||||
function BossBar.title() end
|
||||
|
||||
---@return BossBarColor
|
||||
---@overload fun(color: BossBarColor): void
|
||||
function BossBar.color() end
|
||||
|
||||
---@return BossBarStyle
|
||||
---@overload fun(style: BossBarStyle): void
|
||||
function BossBar.style() end
|
||||
|
||||
---@return number
|
||||
---@overload fun(progress: number): void
|
||||
function BossBar.progress() end
|
||||
|
||||
---@return boolean
|
||||
---@overload fun(visible: boolean): void
|
||||
function BossBar.visible() end
|
||||
|
||||
---@return boolean
|
||||
---@param flag BossBarFlag
|
||||
function BossBar.hasFlag(flag) return nil end
|
||||
|
||||
---@return void
|
||||
---@param flag BossBarFlag
|
||||
function BossBar.addFlag(flag) end
|
||||
|
||||
---@return boolean
|
||||
---@param flag BossBarFlag
|
||||
function BossBar.removeFlag(flag) return nil end
|
||||
|
||||
---@return void
|
||||
function BossBar.destroy() end
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user