Compare commits
715 Commits
0f1fbc4b88
...
Lobby/refa
| Author | SHA1 | Date | |
|---|---|---|---|
| eb63381b83 | |||
| ed672ec07a | |||
| 67960bfc2a | |||
| c831d994be | |||
| 08706d705d | |||
| 6ccb056065 | |||
| 2b32cf38c7 | |||
| bcdda35b44 | |||
| d154fe90a9 | |||
| a12c620744 | |||
| f9c320cb33 | |||
| 4e050106f5 | |||
| 089503e0a0 | |||
| 7179daedae | |||
| 3bfac2d1cf | |||
| ac24bc4f5b | |||
| e69d203b99 | |||
| e1fa8aaefa | |||
| c38777158a | |||
| 2bc295c620 | |||
| 88cc06560e | |||
| 566a7deee3 | |||
| ea07766460 | |||
| 9c5b7712cb | |||
| 84b14b8c3d | |||
| abeb269368 | |||
| fc002abf37 | |||
| 09f9a8ce32 | |||
| d0d353b24d | |||
| 52828c8b4e | |||
| 01efb9fce5 | |||
| 8b636a11ee | |||
| 8ca1cf9b5c | |||
| ad4304d7b0 | |||
| e5e931d331 | |||
| ed87197681 | |||
| e6e475e4bb | |||
| daa69dc22b | |||
| d011ffa536 | |||
| 4798b16015 | |||
| f4c9ce512e | |||
| bfe9c7559e | |||
| 394e043db3 | |||
| d2a6ccc46b | |||
| ccd992f1db | |||
| fa0a9a5c23 | |||
| fa6b75e2aa | |||
| f2073db1e8 | |||
| 5fe62d67d9 | |||
| 524ce0c579 | |||
| 3685d662fb | |||
| 19344b9f48 | |||
| 3d3c70845e | |||
| 797f3a3158 | |||
| 4b1680967a | |||
| 361c86c99e | |||
| 613cb76edb | |||
| 1231fa5c47 | |||
| 06a7d9c7fc | |||
| 21d628b338 | |||
| 56d34f0311 | |||
| 4322547106 | |||
| 43a582edd8 | |||
| d4eabfe9b2 | |||
| bfbb017c8f | |||
| 5a7349b5a6 | |||
| ef91313c29 | |||
| ba2297ca9a | |||
| ba843633d7 | |||
| 3b43ad3587 | |||
| 26a45fabb1 | |||
| f8bb69e829 | |||
| b74b73b871 | |||
| b695a7e089 | |||
| 464d7c85bd | |||
| 285882be70 | |||
| 50780ad9bd | |||
| bbd2bcae35 | |||
| a3801790a4 | |||
| b14c39683a | |||
| 0a3ae7117d | |||
| 830ca93105 | |||
| 06333d634e | |||
| ecb9571624 | |||
| 9e0e339277 | |||
| 06de120fe1 | |||
| 30db0bb718 | |||
| 0a4dccd95a | |||
| 5550aa4930 | |||
| 811bd00ed2 | |||
| bc371df796 | |||
| 144975d977 | |||
| 0763e4b189 | |||
| 38b061c12c | |||
| 91a41ccd3f | |||
| 576ce891f6 | |||
| 7aff9f08d0 | |||
| 13ef131401 | |||
| 56680119e2 | |||
| 6a5507321e | |||
| 01d9532aa6 | |||
| c49a212c05 | |||
| e6196251a6 | |||
| 698f917828 | |||
| ad87ad7495 | |||
| 6a78499193 | |||
| d55556cb47 | |||
| 4f24adf9fd | |||
| 94e3eed6df | |||
| 8a43809322 | |||
| 8fb10c9266 | |||
| fb518efe63 | |||
| 598daadd33 | |||
| 0287881e33 | |||
| a6b703b821 | |||
| 43cca3376e | |||
| 7e61db5e58 | |||
| c9b4e6ab45 | |||
| 314aaf7a76 | |||
| e98f53bbab | |||
| 7dc9da549c | |||
| 3bb84d0dcc | |||
| 3d0e5fc28d | |||
| 5e5bfedb52 | |||
| ef19959eb2 | |||
| ae15e16dae | |||
| 9a506a34f8 | |||
| 6822dc796f | |||
| 8427ae36f2 | |||
| 7f41559647 | |||
| 4e70a675c2 | |||
| 96daa2c861 | |||
| 45646b6ba3 | |||
| 8d1b15b019 | |||
| 2e91a5a582 | |||
| 018b9a971f | |||
| 70d0f179cc | |||
| 2166096ba5 | |||
| 3a13fc7bb9 | |||
| 01f55c4309 | |||
| d968187750 | |||
| 9e629d09a8 | |||
| d14022e69e | |||
| 6623e9d808 | |||
| 9279d9cd8e | |||
| b7963f2fe6 | |||
| 3f88ea1e57 | |||
| 8076f31a19 | |||
| 33e9b3409f | |||
| e7803dcf82 | |||
| cf52b50333 | |||
| 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 | |||
| bfdf6471d2 | |||
| e418109ab7 | |||
| 82c73f9367 | |||
| 1f65121c68 | |||
| 3c848389c9 | |||
| 33f41869b6 | |||
| 3c1d46398d | |||
| 9a8cb543e9 | |||
| 55adb1a052 |
6
.gitignore
vendored
6
.gitignore
vendored
@ -16,4 +16,8 @@ bin/
|
|||||||
.vscode
|
.vscode
|
||||||
|
|
||||||
# Other
|
# Other
|
||||||
lib
|
lib
|
||||||
|
/WebsiteBackend/data
|
||||||
|
/WebsiteBackend/logs
|
||||||
|
/WebsiteBackend/skins
|
||||||
|
/WebsiteBackend/config.json
|
||||||
@ -109,7 +109,7 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSelection(Player p, Point minPoint, Point maxPoint) {
|
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
|
@Override
|
||||||
@ -178,9 +178,9 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
|
|||||||
pastePoint.set(v);
|
pastePoint.set(v);
|
||||||
|
|
||||||
if (pasteBuilder.isReset()) {
|
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) {
|
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());
|
Operations.completeBlindly(ch.createPaste(e).to(v).ignoreAirBlocks(pasteBuilder.isIgnoreAir()).build());
|
||||||
@ -193,7 +193,7 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
|
|||||||
@Override
|
@Override
|
||||||
public Clipboard copy(Point minPoint, Point maxPoint, Point copyPoint) {
|
public Clipboard copy(Point minPoint, Point maxPoint, Point copyPoint) {
|
||||||
BukkitWorld bukkitWorld = new BukkitWorld(Bukkit.getWorlds().get(0));
|
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);
|
BlockArrayClipboard clipboard = new BlockArrayClipboard(region);
|
||||||
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(bukkitWorld, -1)) {
|
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(bukkitWorld, -1)) {
|
||||||
ForwardExtentCopy copy = new ForwardExtentCopy(
|
ForwardExtentCopy copy = new ForwardExtentCopy(
|
||||||
@ -204,7 +204,7 @@ public class FlatteningWrapper15 implements FlatteningWrapper {
|
|||||||
copy.setCopyingBiomes(false);
|
copy.setCopyingBiomes(false);
|
||||||
|
|
||||||
Operations.complete(copy);
|
Operations.complete(copy);
|
||||||
clipboard.setOrigin(toBlockVector3(copyPoint));
|
clipboard.setOrigin(copyPoint.toBlockVector3());
|
||||||
return clipboard;
|
return clipboard;
|
||||||
} catch (WorldEditException e) {
|
} catch (WorldEditException e) {
|
||||||
Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), 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
|
@Override
|
||||||
public boolean inWater(org.bukkit.World world, Vector tntPosition) {
|
public boolean inWater(org.bukkit.World world, Vector tntPosition) {
|
||||||
Block block = world.getBlockAt(tntPosition.getBlockX(), tntPosition.getBlockY(), tntPosition.getBlockZ());
|
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.Region;
|
||||||
|
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, Region.getGlobalRegion(), "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
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* 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 de.steamwar.Reflection;
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
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
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Affero General Public License for more details.
|
* GNU Affero General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* 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 de.steamwar.Reflection;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -17,7 +17,7 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* 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 de.steamwar.Reflection;
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
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.ServerTickEndEvent;
|
||||||
import com.destroystokyo.paper.event.server.ServerTickStartEvent;
|
import com.destroystokyo.paper.event.server.ServerTickStartEvent;
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.features.tpslimit.TPSFreezeUtils;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -37,7 +36,7 @@ public class TickListener19 implements TickListener, Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onServerTickStart(ServerTickStartEvent event) {
|
public void onServerTickStart(ServerTickStartEvent event) {
|
||||||
if (TPSFreezeUtils.isFrozen()) return;
|
if (TickManager.impl.isFrozen()) return;
|
||||||
Bukkit.getPluginManager().callEvent(new TickStartEvent());
|
Bukkit.getPluginManager().callEvent(new TickStartEvent());
|
||||||
tickStartRan = true;
|
tickStartRan = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,41 +21,39 @@ package de.steamwar.bausystem.utils;
|
|||||||
|
|
||||||
import de.steamwar.Reflection;
|
import de.steamwar.Reflection;
|
||||||
import de.steamwar.bausystem.features.util.NoClipCommand;
|
import de.steamwar.bausystem.features.util.NoClipCommand;
|
||||||
import net.minecraft.core.component.DataComponents;
|
import io.papermc.paper.datacomponent.DataComponentTypes;
|
||||||
import net.minecraft.nbt.NBTBase;
|
import io.papermc.paper.datacomponent.item.ItemContainerContents;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.network.protocol.game.ClientboundExplodePacket;
|
||||||
import net.minecraft.network.protocol.game.PacketPlayInSetCreativeSlot;
|
import net.minecraft.network.protocol.game.ClientboundGameEventPacket;
|
||||||
import net.minecraft.network.protocol.game.PacketPlayOutExplosion;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.network.protocol.game.PacketPlayOutGameStateChange;
|
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||||
import net.minecraft.server.level.EntityPlayer;
|
import net.minecraft.world.entity.player.Abilities;
|
||||||
import net.minecraft.server.level.PlayerInteractManager;
|
import net.minecraft.world.level.GameType;
|
||||||
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 org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class NMSWrapper21 implements NMSWrapper {
|
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);
|
||||||
|
private static final Reflection.Field<GameType> playerGameMode = Reflection.getField(ServerPlayerGameMode.class, GameType.class, 0);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInternalGameMode(Player player, GameMode gameMode) {
|
public void setInternalGameMode(Player player, GameMode gameMode) {
|
||||||
playerInteractManager.get(((CraftPlayer) player).getHandle()).a(EnumGamemode.a(gameMode.getValue()));
|
playerGameMode.set(playerInteractManager.get(((CraftPlayer) player).getHandle()), GameType.byId(gameMode.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSlotToItemStack(Player player, Object o) {
|
public void setSlotToItemStack(Player player, Object o) {
|
||||||
PacketPlayInSetCreativeSlot packetPlayInSetCreativeSlot = (PacketPlayInSetCreativeSlot) o;
|
ClientboundContainerSetSlotPacket packetPlayInSetCreativeSlot = (ClientboundContainerSetSlotPacket) o;
|
||||||
int index = packetPlayInSetCreativeSlot.b();
|
int index = packetPlayInSetCreativeSlot.getSlot();
|
||||||
if (index >= 36 && index <= 44) {
|
if (index >= 36 && index <= 44) {
|
||||||
index -= 36;
|
index -= 36;
|
||||||
} else if (index > 44) {
|
} else if (index > 44) {
|
||||||
@ -63,25 +61,23 @@ public class NMSWrapper21 implements NMSWrapper {
|
|||||||
} else if (index <= 8) {
|
} else if (index <= 8) {
|
||||||
index = index - 8 + 36;
|
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);
|
if (index < 9) player.getInventory().setHeldItemSlot(index);
|
||||||
player.updateInventory();
|
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, 14);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGameStateChangeReason(Object packet) {
|
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
|
@Override
|
||||||
public void setPlayerBuildAbilities(Player player) {
|
public void setPlayerBuildAbilities(Player player) {
|
||||||
PlayerAbilities abilities = playerAbilities.get(((CraftPlayer) player).getHandle());
|
Abilities abilities = (((CraftPlayer) player).getHandle()).getAbilities();
|
||||||
abilities.d = true;
|
abilities.mayBuild = true;
|
||||||
abilities.e = true;
|
abilities.mayfly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -93,49 +89,45 @@ public class NMSWrapper21 implements NMSWrapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkItemStack(ItemStack item) {
|
public boolean checkItemStack(ItemStack item) {
|
||||||
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
|
ItemContainerContents data = item.getData(DataComponentTypes.CONTAINER);
|
||||||
NBTTagCompound tag = nmsItem.a(DataComponents.b, CustomData.a).c();
|
if (data == null) {
|
||||||
if (tag.e("BlockEntityTag")) {
|
return false;
|
||||||
NBTTagCompound blockTag = tag.p("BlockEntityTag");
|
|
||||||
if (blockTag.e("Items")) {
|
|
||||||
return drillDown(blockTag.c("Items", 10), 0, 0) > threshold;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
if (layer > 2) return start + threshold;
|
||||||
int invalid = start;
|
int invalid = start;
|
||||||
for (NBTBase nbtBase : items) {
|
for (int i = start; i < items.size(); i++) {
|
||||||
if (!(nbtBase instanceof NBTTagCompound slot))
|
ItemStack item = items.get(i);
|
||||||
|
if (item.isEmpty()) continue;
|
||||||
|
|
||||||
|
invalid += item.getAmount();
|
||||||
|
|
||||||
|
ItemContainerContents data = item.getData(DataComponentTypes.CONTAINER);
|
||||||
|
if (data == null) {
|
||||||
continue;
|
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;
|
return invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object resetExplosionKnockback(Object packet) {
|
public Object resetExplosionKnockback(Object packet) {
|
||||||
PacketPlayOutExplosion explosion = (PacketPlayOutExplosion) packet;
|
ClientboundExplodePacket explosion = (ClientboundExplodePacket) packet;
|
||||||
|
|
||||||
return new PacketPlayOutExplosion(
|
return new ClientboundExplodePacket(
|
||||||
explosion.b(),
|
explosion.center(),
|
||||||
Optional.empty(),
|
Optional.empty(),
|
||||||
explosion.f(),
|
explosion.explosionParticle(),
|
||||||
explosion.g()
|
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_PREVIOUS_PAGE=§ePrevious page
|
||||||
LIST_NEXT_PAGE=§eNext page
|
LIST_NEXT_PAGE=§eNext page
|
||||||
# Permissions
|
# Permissions
|
||||||
NO_PERMISSION=You are not allowed to use that here
|
NO_PERMISSION=§7You are not allowed to use that here
|
||||||
SPECTATOR=§fSpectator
|
SPECTATOR=§fSpectator
|
||||||
# Scoreboard
|
# Scoreboard
|
||||||
SCOREBOARD_TIME=Time
|
SCOREBOARD_TIME=Time
|
||||||
@ -38,6 +38,7 @@ SCOREBOARD_TRACE_TICKS=Ticks
|
|||||||
SCOREBOARD_TECHHIDER=TechHider§8: §aOn
|
SCOREBOARD_TECHHIDER=TechHider§8: §aOn
|
||||||
SCOREBOARD_XRAY=XRay§8: §aOn
|
SCOREBOARD_XRAY=XRay§8: §aOn
|
||||||
SCOREBOARD_LOCK_TEAM=Bau Lock§8: §eTeam
|
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_TEAM_AND_SERVERTEAM=Bau Lock§8: §e(Server) Team
|
||||||
SCOREBOARD_LOCK_SERVERTEAM=Bau Lock§8: §eServer Team
|
SCOREBOARD_LOCK_SERVERTEAM=Bau Lock§8: §eServer Team
|
||||||
SCOREBOARD_LOCK_NOBODY=Bau Lock§8: §cNobody
|
SCOREBOARD_LOCK_NOBODY=Bau Lock§8: §cNobody
|
||||||
@ -136,7 +137,9 @@ BAU_INFO_ITEM_LORE_FIRE=§7Fire§8: §e{0}
|
|||||||
BAU_INFO_ITEM_LORE_COLOR=§7Color§8: §e{0}
|
BAU_INFO_ITEM_LORE_COLOR=§7Color§8: §e{0}
|
||||||
BAU_INFO_ITEM_LORE_PROTECT=§7Protect§8: §e{0}
|
BAU_INFO_ITEM_LORE_PROTECT=§7Protect§8: §e{0}
|
||||||
BAU_INFO_ITEM_LORE_ITEMS=§7Items§8: §e{0}
|
BAU_INFO_ITEM_LORE_ITEMS=§7Items§8: §e{0}
|
||||||
BAU_INFO_ITEM_LORE_NO_GRAVITY = §8NoGravity§8: §e{0}
|
BAU_INFO_ITEM_LORE_NO_GRAVITY = §7NoGravity§8: §e{0}
|
||||||
|
BAU_INFO_ITEM_LORE_TESTBLOCK=§7Testblock§8: §e{0}
|
||||||
|
BAU_INFO_ITEM_LORE_CHANGED=§7Changed§8: §e{0}
|
||||||
BAU_INFO_COMMAND_HELP=§8/§ebauinfo §8- §7Information regarding this build server
|
BAU_INFO_COMMAND_HELP=§8/§ebauinfo §8- §7Information regarding this build server
|
||||||
BAU_INFO_COMMAND_OWNER=§7Owner§8: §e{0}
|
BAU_INFO_COMMAND_OWNER=§7Owner§8: §e{0}
|
||||||
BAU_INFO_COMMAND_MEMBER=§7{0} §8[§7{1}§8]§8: §e{2}
|
BAU_INFO_COMMAND_MEMBER=§7{0} §8[§7{1}§8]§8: §e{2}
|
||||||
@ -389,6 +392,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_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_ENABLE=§aInventoryFiller activated
|
||||||
INVENTORY_FILL_DISABLE=§cInventoryFiller deactivated
|
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
|
||||||
KILLCHECKER_HELP_ENABLE=§8/§ekillchecker enable §8- §7Enables Killchecker / Recalculates kills
|
KILLCHECKER_HELP_ENABLE=§8/§ekillchecker enable §8- §7Enables Killchecker / Recalculates kills
|
||||||
KILLCHECKER_HELP_DISABLE=§8/§ekillchecker disable §8- §7Disables Killchecker
|
KILLCHECKER_HELP_DISABLE=§8/§ekillchecker disable §8- §7Disables Killchecker
|
||||||
@ -396,6 +405,7 @@ KILLCHECKER_INFO=§7Shows the overlaps of cannon kills in your build area.
|
|||||||
KILLCHECKER_INFO2=§7Only colorable blocks like Wool, Terractotta, Stained Glass and Concrete are counted.
|
KILLCHECKER_INFO2=§7Only colorable blocks like Wool, Terractotta, Stained Glass and Concrete are counted.
|
||||||
KILLCHECKER_ENABLE=§aKillchecker activated
|
KILLCHECKER_ENABLE=§aKillchecker activated
|
||||||
KILLCHECKER_DISABLE=§cKillchecker deactivated
|
KILLCHECKER_DISABLE=§cKillchecker deactivated
|
||||||
|
KILLCHECKER_NO_BUILD=§cThere is no Build Area in this Region
|
||||||
KILLCHECKER_BOSSBAR=§e§l{0} §7(§e{1}%§7) §e§l{2}§7 cannons
|
KILLCHECKER_BOSSBAR=§e§l{0} §7(§e{1}%§7) §e§l{2}§7 cannons
|
||||||
# BlockCounter
|
# BlockCounter
|
||||||
BLOCK_COUNTER_HELP_TOGGLE=§8/§eblockcounter §8- §7Toggle on/off
|
BLOCK_COUNTER_HELP_TOGGLE=§8/§eblockcounter §8- §7Toggle on/off
|
||||||
@ -406,6 +416,8 @@ BLOCK_COUNTER_MESSAGE_SECOND=§7Damage §8> §e{0} §7Blocks §e{1} §7TNT §e
|
|||||||
BLOCK_COUNTER_ENABLE=§7BlockCounter activated
|
BLOCK_COUNTER_ENABLE=§7BlockCounter activated
|
||||||
BLOCK_COUNTER_DISABLE=§7BlockCounter deactivated
|
BLOCK_COUNTER_DISABLE=§7BlockCounter deactivated
|
||||||
# DepthCounter
|
# DepthCounter
|
||||||
|
DEPTH_COUNTER_DISABLE=§7Depth Counter disabled
|
||||||
|
DEPTH_COUNTER_ENABLE=§7Depth Counter enabled
|
||||||
DEPTH_COUNTER_MESSAGE=§7Depth §8> §7
|
DEPTH_COUNTER_MESSAGE=§7Depth §8> §7
|
||||||
DEPTH_COUNTER_COUNT={0}{1}§8×{2}{3}§8×{4}{5}
|
DEPTH_COUNTER_COUNT={0}{1}§8×{2}{3}§8×{4}{5}
|
||||||
DEPTH_COUNTER_HOVER=§7X§8×§7Y§8×§7Z
|
DEPTH_COUNTER_HOVER=§7X§8×§7Y§8×§7Z
|
||||||
@ -512,7 +524,7 @@ LOADER_HELP_GUI=§8/§7loader gui §8- §7Shows Loader gui
|
|||||||
LOADER_HELP_STOP=§8/§eloader stop §8- §7Stops recording/playback
|
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_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_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_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_HOW_TO_START=§7Then, execute /§eloader start§7 to start the Loader
|
||||||
LOADER_ACTIVE=§7The Loader is now active.
|
LOADER_ACTIVE=§7The Loader is now active.
|
||||||
@ -728,12 +740,10 @@ REGION_ITEM_RESET=§eReset
|
|||||||
REGION_ITEM_TESTBLOCK=§eDummy
|
REGION_ITEM_TESTBLOCK=§eDummy
|
||||||
REGION_ITEM_TNT_OFF=§7TNT: §eDeactivated
|
REGION_ITEM_TNT_OFF=§7TNT: §eDeactivated
|
||||||
REGION_ITEM_TNT_ONLY_TB=§7TNT: §eonly dummy
|
REGION_ITEM_TNT_ONLY_TB=§7TNT: §eonly dummy
|
||||||
REGION_ITEM_TNT_ONLY_BUILD=§7TNT: §eonly build
|
|
||||||
REGION_ITEM_TNT_ON=§7TNT: §eActivated
|
REGION_ITEM_TNT_ON=§7TNT: §eActivated
|
||||||
REGION_ITEM_SELECTOR_TITLE=Tnt Mode
|
REGION_ITEM_SELECTOR_TITLE=Tnt Mode
|
||||||
REGION_ITEM_SELECTOR_ON=§eActivate
|
REGION_ITEM_SELECTOR_ON=§eActivate
|
||||||
REGION_ITEM_SELECTOR_ONLY_TB=§eonly dummy
|
REGION_ITEM_SELECTOR_ONLY_TB=§eonly dummy
|
||||||
REGION_ITEM_SELECTOR_ONLY_BUILD=§eonly build
|
|
||||||
REGION_ITEM_SELECTOR_OFF=§eDeactivate
|
REGION_ITEM_SELECTOR_OFF=§eDeactivate
|
||||||
#Region
|
#Region
|
||||||
REGION_COLOR_HELP_COLOR=§8/§ecolor §8[§7Color§8] §8- §7Sets the color of the region
|
REGION_COLOR_HELP_COLOR=§8/§ecolor §8[§7Color§8] §8- §7Sets the color of the region
|
||||||
@ -844,7 +854,7 @@ LAUFBAU_SETTINGS_INACTIVE=§cInactive
|
|||||||
LAUFBAU_SETTINGS_MIXED=§e{0}§8/§e{1} §aActive
|
LAUFBAU_SETTINGS_MIXED=§e{0}§8/§e{1} §aActive
|
||||||
LAUFBAU_SETTINGS_GUI_BACK=§eBack
|
LAUFBAU_SETTINGS_GUI_BACK=§eBack
|
||||||
LAUFBAU_SETTINGS_TOGGLE=§eClick §8-§7 Toggle
|
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_COBWEB=§eCobweb
|
||||||
LAUFBAU_BLOCK_GRASS_PATH=§eGrass Path
|
LAUFBAU_BLOCK_GRASS_PATH=§eGrass Path
|
||||||
LAUFBAU_BLOCK_SOUL_SAND=§eSoul Sand
|
LAUFBAU_BLOCK_SOUL_SAND=§eSoul Sand
|
||||||
@ -930,7 +940,6 @@ SELECT_HELP=§8/§eselect §8[§7RegionsTyp§8] §8- §7Select a region type
|
|||||||
SELECT_EXTENSION_HELP=§8/§eselect §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Select a region type with or without extension
|
SELECT_EXTENSION_HELP=§8/§eselect §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Select a region type with or without extension
|
||||||
SELECT_GLOBAL_REGION=§cThe global region cannot be selected
|
SELECT_GLOBAL_REGION=§cThe global region cannot be selected
|
||||||
SELECT_NO_TYPE=§cThis region has no {0}
|
SELECT_NO_TYPE=§cThis region has no {0}
|
||||||
SELECT_NO_EXTENSION=§cThis region has no extension
|
|
||||||
SELECT_MESSAGE=§7WorldEdit selection set to {0}, {1}, {2} and {3}, {4}, {5}
|
SELECT_MESSAGE=§7WorldEdit selection set to {0}, {1}, {2} and {3}, {4}, {5}
|
||||||
SKULL_HELP=§8/§eskull §8[§eplayer§8] §8-§7 Receive a player head
|
SKULL_HELP=§8/§eskull §8[§eplayer§8] §8-§7 Receive a player head
|
||||||
SKULL_INVALID=§cInvalid player name
|
SKULL_INVALID=§cInvalid player name
|
||||||
@ -945,6 +954,9 @@ SPEED_TAB_NAME=Input speed
|
|||||||
WORLDEDIT_WAND=WorldEdit Wand
|
WORLDEDIT_WAND=WorldEdit Wand
|
||||||
WORLDEDIT_LEFTCLICK=Left click: select pos #1
|
WORLDEDIT_LEFTCLICK=Left click: select pos #1
|
||||||
WORLDEDIT_RIGHTCLICK=Right click: select pos #2
|
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_HEADER=§8---=== §eTNT §8===---
|
||||||
TNT_CLICK_ORDER=§eEntity Order§8: §e{0}
|
TNT_CLICK_ORDER=§eEntity Order§8: §e{0}
|
||||||
TNT_CLICK_FUSE_TIME=§eFuseTime§8: §e{0}
|
TNT_CLICK_FUSE_TIME=§eFuseTime§8: §e{0}
|
||||||
@ -968,10 +980,12 @@ SELECT_ITEM_BAUPLATTFORM=§eBuild platform
|
|||||||
SELECT_ITEM_TESTBLOCK=§eDummy
|
SELECT_ITEM_TESTBLOCK=§eDummy
|
||||||
CHESTFILLER_FILLED=§eChest filled
|
CHESTFILLER_FILLED=§eChest filled
|
||||||
CHESTFILLER_COUNT=§7{0}§8: §e§l{1}
|
CHESTFILLER_COUNT=§7{0}§8: §e§l{1}
|
||||||
PISTON_HELP_1=§7Right click on piston with a slime ball to calculate the moved blocks.
|
PISTON_HELP_1=§7Right click on piston to calculate the moved blocks.
|
||||||
PISTON_HELP_2=§7Count is red, if one unmoveable block is present.
|
PISTON_HELP_2=§7Count is red, if one unmoveable block is present.
|
||||||
PISTON_HELP_3=§7Count is yellow, if too many blocks are present.
|
PISTON_HELP_3=§7Count is yellow, if too many blocks are present.
|
||||||
PISTON_INFO=§7Moved Blocks {0}{1}§8/§712
|
PISTON_INFO=§7Moved Blocks {0}{1}§8/§712
|
||||||
|
PISTON_ENABLED=§aCalculator enabled
|
||||||
|
PISTON_DISABLED=§cCalculator disabled
|
||||||
# Warp
|
# Warp
|
||||||
WARP_LOC_X=§7X§8: §e{0}
|
WARP_LOC_X=§7X§8: §e{0}
|
||||||
WARP_LOC_Y=§7Y§8: §e{0}
|
WARP_LOC_Y=§7Y§8: §e{0}
|
||||||
|
|||||||
@ -25,7 +25,7 @@ PAGE_LIST=§e Seite ({0}/{1}) »»
|
|||||||
LIST_PREVIOUS_PAGE=§eVorherige Seite
|
LIST_PREVIOUS_PAGE=§eVorherige Seite
|
||||||
LIST_NEXT_PAGE=§eNächste Seite
|
LIST_NEXT_PAGE=§eNächste Seite
|
||||||
# Permission
|
# Permission
|
||||||
NO_PERMISSION=Du darfst dies hier nicht nutzen
|
NO_PERMISSION=§7Du darfst dies hier nicht nutzen
|
||||||
SPECTATOR=§fZuschauer
|
SPECTATOR=§fZuschauer
|
||||||
# Scoreboard
|
# Scoreboard
|
||||||
SCOREBOARD_TIME=Uhrzeit
|
SCOREBOARD_TIME=Uhrzeit
|
||||||
@ -119,12 +119,9 @@ BACKUP_LORE=§eKlicken zum Laden
|
|||||||
BAU_COMMAND_HELP_INFO=§8/§ebau info §8- §7Alias für §8/§ebauinfo
|
BAU_COMMAND_HELP_INFO=§8/§ebau info §8- §7Alias für §8/§ebauinfo
|
||||||
BAU_INFO_ITEM_NAME=§eBau-Management
|
BAU_INFO_ITEM_NAME=§eBau-Management
|
||||||
## This is used in BauInfoBauGuiItem.java
|
## This is used in BauInfoBauGuiItem.java
|
||||||
BAU_INFO_ITEM_LORE_TNT=§7TNT§8: §e{0}
|
|
||||||
BAU_INFO_ITEM_LORE_FREEZE=§7Freeze§8: §e{0}
|
|
||||||
BAU_INFO_ITEM_LORE_DAMAGE=§7Damage§8: §e{0}
|
|
||||||
BAU_INFO_ITEM_LORE_FIRE=§7Feuer§8: §e{0}
|
BAU_INFO_ITEM_LORE_FIRE=§7Feuer§8: §e{0}
|
||||||
BAU_INFO_ITEM_LORE_COLOR=§7Farbe§8: §e{0}
|
BAU_INFO_ITEM_LORE_COLOR=§7Farbe§8: §e{0}
|
||||||
BAU_INFO_ITEM_LORE_PROTECT=§7Protect§8: §e{0}
|
BAU_INFO_ITEM_LORE_CHANGED=§7Verändert§8: §e{0}
|
||||||
BAU_INFO_COMMAND_HELP=§8/§ebauinfo §8- §7Gibt Informationen über den Bau
|
BAU_INFO_COMMAND_HELP=§8/§ebauinfo §8- §7Gibt Informationen über den Bau
|
||||||
BAU_INFO_COMMAND_OWNER=§7Besitzer§8: §e{0}
|
BAU_INFO_COMMAND_OWNER=§7Besitzer§8: §e{0}
|
||||||
BAU_INFO_COMMAND_MEMBER=§7{0} §8[§7{1}§8]§8: §e{2}
|
BAU_INFO_COMMAND_MEMBER=§7{0} §8[§7{1}§8]§8: §e{2}
|
||||||
@ -350,8 +347,11 @@ SMART_PLACE_DISABLE=§cSmartPlace deaktiviert
|
|||||||
# InventoryFiller
|
# InventoryFiller
|
||||||
INVENTORY_FILL_HELP=§8/§einventoryfill §8- §7Toggled InventoryFill
|
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_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_ENABLE=§aInventoryFiller aktiviert
|
||||||
INVENTORY_FILL_DISABLE=§cInventoryFiller deactivated
|
INVENTORY_FILL_DISABLE=§cInventoryFiller deaktiviert
|
||||||
|
# Ray Visualizer
|
||||||
|
RAY_VISUALIZER_ENABLE=§aRayVisualizer aktiviert
|
||||||
|
RAY_VISUALIZER_DISABLE=§aRayVisualizer deaktiviert
|
||||||
# Killchecker
|
# Killchecker
|
||||||
KILLCHECKER_HELP_ENABLE=§8/§ekillchecker enable §8- §7Aktiviert Killchecker / Berechnet kills neu
|
KILLCHECKER_HELP_ENABLE=§8/§ekillchecker enable §8- §7Aktiviert Killchecker / Berechnet kills neu
|
||||||
KILLCHECKER_HELP_DISABLE=§8/§ekillchecker disable §8- §7Deaktiviert Killchecker
|
KILLCHECKER_HELP_DISABLE=§8/§ekillchecker disable §8- §7Deaktiviert Killchecker
|
||||||
@ -359,6 +359,7 @@ KILLCHECKER_INFO=§7Zeigt Überlappungen der Kanonen Kills im Baubereich an.
|
|||||||
KILLCHECKER_INFO2=§7Nur farbige Blöcke wie Wolle, Terracotta, Stained Glass und Concrete wird gezählt.
|
KILLCHECKER_INFO2=§7Nur farbige Blöcke wie Wolle, Terracotta, Stained Glass und Concrete wird gezählt.
|
||||||
KILLCHECKER_ENABLE=§aKillchecker aktiviert
|
KILLCHECKER_ENABLE=§aKillchecker aktiviert
|
||||||
KILLCHECKER_DISABLE=§cKillchecker deaktiviert
|
KILLCHECKER_DISABLE=§cKillchecker deaktiviert
|
||||||
|
KILLCHECKER_NO_BUILD=§cEs gibt keinen Baubereich in dieser Region
|
||||||
KILLCHECKER_BOSSBAR=§e§l{0} §7(§e{1}%§7) §e§l{2}§7 Kanonnen
|
KILLCHECKER_BOSSBAR=§e§l{0} §7(§e{1}%§7) §e§l{2}§7 Kanonnen
|
||||||
# BlockCounter
|
# BlockCounter
|
||||||
BLOCK_COUNTER_HELP_TOGGLE=§8/§eblockcounter §8- §7Wechsel zwischen an und aus
|
BLOCK_COUNTER_HELP_TOGGLE=§8/§eblockcounter §8- §7Wechsel zwischen an und aus
|
||||||
@ -369,6 +370,8 @@ BLOCK_COUNTER_MESSAGE_SECOND=§7Schaden §8> §e{0} §7Blöcke §e{1} §7TNT
|
|||||||
BLOCK_COUNTER_ENABLE=§7BlockCounter angemacht
|
BLOCK_COUNTER_ENABLE=§7BlockCounter angemacht
|
||||||
BLOCK_COUNTER_DISABLE=§7BlockCounter ausgemacht
|
BLOCK_COUNTER_DISABLE=§7BlockCounter ausgemacht
|
||||||
# DepthCounter
|
# DepthCounter
|
||||||
|
DEPTH_COUNTER_DISABLE=§7Depth Counter deaktiviert
|
||||||
|
DEPTH_COUNTER_ENABLE=§7Depth Counter aktiviert
|
||||||
DEPTH_COUNTER_MESSAGE=§7Tiefe §8> §7
|
DEPTH_COUNTER_MESSAGE=§7Tiefe §8> §7
|
||||||
# TPSLimit
|
# TPSLimit
|
||||||
TPSLIMIT_FREEZE_HELP=§8/§etpslimit 0 §8-§7 Friere TPS ein
|
TPSLIMIT_FREEZE_HELP=§8/§etpslimit 0 §8-§7 Friere TPS ein
|
||||||
@ -675,12 +678,10 @@ REGION_ITEM_RESET=§eReset
|
|||||||
REGION_ITEM_TESTBLOCK=§eTestblock
|
REGION_ITEM_TESTBLOCK=§eTestblock
|
||||||
REGION_ITEM_TNT_OFF=§7TNT: §eAusgeschaltet
|
REGION_ITEM_TNT_OFF=§7TNT: §eAusgeschaltet
|
||||||
REGION_ITEM_TNT_ONLY_TB=§7TNT: §enur Testblock
|
REGION_ITEM_TNT_ONLY_TB=§7TNT: §enur Testblock
|
||||||
REGION_ITEM_TNT_ONLY_BUILD=§7TNT: §enur Baubereich
|
|
||||||
REGION_ITEM_TNT_ON=§7TNT: §eEingeschaltet
|
REGION_ITEM_TNT_ON=§7TNT: §eEingeschaltet
|
||||||
REGION_ITEM_SELECTOR_TITLE=Tnt Modus
|
REGION_ITEM_SELECTOR_TITLE=Tnt Modus
|
||||||
REGION_ITEM_SELECTOR_ON=§eEinschalten
|
REGION_ITEM_SELECTOR_ON=§eEinschalten
|
||||||
REGION_ITEM_SELECTOR_ONLY_TB=§enur Testblock
|
REGION_ITEM_SELECTOR_ONLY_TB=§enur Testblock
|
||||||
REGION_ITEM_SELECTOR_ONLY_BUILD=§enur Baubereich
|
|
||||||
REGION_ITEM_SELECTOR_OFF=§eAusschalten
|
REGION_ITEM_SELECTOR_OFF=§eAusschalten
|
||||||
#Region
|
#Region
|
||||||
REGION_COLOR_HELP_COLOR=§8/§ecolor §8[§7Color§8] §8- §7Setze die Farbe der Region
|
REGION_COLOR_HELP_COLOR=§8/§ecolor §8[§7Color§8] §8- §7Setze die Farbe der Region
|
||||||
@ -790,7 +791,7 @@ LAUFBAU_SETTINGS_INACTIVE=§cInaktiv
|
|||||||
LAUFBAU_SETTINGS_MIXED=§e{0}§8/§e{1} §aAktiv
|
LAUFBAU_SETTINGS_MIXED=§e{0}§8/§e{1} §aAktiv
|
||||||
LAUFBAU_SETTINGS_GUI_BACK=§eBack
|
LAUFBAU_SETTINGS_GUI_BACK=§eBack
|
||||||
LAUFBAU_SETTINGS_TOGGLE=§eClick §8-§7 Toggle
|
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_COBWEB=§eCobweb
|
||||||
LAUFBAU_BLOCK_GRASS_PATH=§eGrass Path
|
LAUFBAU_BLOCK_GRASS_PATH=§eGrass Path
|
||||||
LAUFBAU_BLOCK_SOUL_SAND=§eSoul Sand
|
LAUFBAU_BLOCK_SOUL_SAND=§eSoul Sand
|
||||||
@ -872,7 +873,6 @@ SELECT_HELP=§8/§eselect §8[§7RegionsTyp§8] §8- §7Wähle einen RegionsTyp
|
|||||||
SELECT_EXTENSION_HELP=§8/§eselect §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Wähle einen RegionsTyp aus mit oder ohne Extension
|
SELECT_EXTENSION_HELP=§8/§eselect §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Wähle einen RegionsTyp aus mit oder ohne Extension
|
||||||
SELECT_GLOBAL_REGION=§cDie globale Region kannst du nicht auswählen
|
SELECT_GLOBAL_REGION=§cDie globale Region kannst du nicht auswählen
|
||||||
SELECT_NO_TYPE=§cDiese Region hat keinen {0}
|
SELECT_NO_TYPE=§cDiese Region hat keinen {0}
|
||||||
SELECT_NO_EXTENSION=§cDiese Region hat keine Ausfahrmaße
|
|
||||||
SELECT_MESSAGE=§7WorldEdit auswahl auf {0}, {1}, {2} und {3}, {4}, {5} gesetzt
|
SELECT_MESSAGE=§7WorldEdit auswahl auf {0}, {1}, {2} und {3}, {4}, {5} gesetzt
|
||||||
SKULL_HELP=§8/§eskull §8[§eSpieler§8] §8-§7 Gibt einen SpielerKopf
|
SKULL_HELP=§8/§eskull §8[§eSpieler§8] §8-§7 Gibt einen SpielerKopf
|
||||||
SKULL_INVALID=§cUngültiger Spieler
|
SKULL_INVALID=§cUngültiger Spieler
|
||||||
@ -887,6 +887,9 @@ SPEED_TAB_NAME=Geschwindigkeit eingeben
|
|||||||
WORLDEDIT_WAND=WorldEdit Wand
|
WORLDEDIT_WAND=WorldEdit Wand
|
||||||
WORLDEDIT_LEFTCLICK=Left click: select pos #1
|
WORLDEDIT_LEFTCLICK=Left click: select pos #1
|
||||||
WORLDEDIT_RIGHTCLICK=Right click: select pos #2
|
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_HEADER=§8---=== §eTNT §8===---
|
||||||
TNT_CLICK_ORDER=§eEntity Order§8: §e{0}
|
TNT_CLICK_ORDER=§eEntity Order§8: §e{0}
|
||||||
TNT_CLICK_FUSE_TIME=§eFuseTime§8: §e{0}
|
TNT_CLICK_FUSE_TIME=§eFuseTime§8: §e{0}
|
||||||
@ -909,10 +912,12 @@ SELECT_ITEM_BAURAHMEN=§eBaurahmen
|
|||||||
SELECT_ITEM_BAUPLATTFORM=§eBauplattform
|
SELECT_ITEM_BAUPLATTFORM=§eBauplattform
|
||||||
SELECT_ITEM_TESTBLOCK=§eTestblock
|
SELECT_ITEM_TESTBLOCK=§eTestblock
|
||||||
CHESTFILLER_FILLED=§eKiste gefüllt
|
CHESTFILLER_FILLED=§eKiste gefüllt
|
||||||
PISTON_HELP_1=§7Rechts Klick auf Piston mit einem Slime Ball berechnet dir die bewegten Blöcke.
|
PISTON_HELP_1=§7Rechts Klick auf einen Piston berechnet dir die bewegten Blöcke.
|
||||||
PISTON_HELP_2=§7Die Anzahl ist Rot, wenn ein unmovable Block vorhanden ist.
|
PISTON_HELP_2=§7Die Anzahl ist Rot, wenn ein unmovable Block vorhanden ist.
|
||||||
PISTON_HELP_3=§7Die Anzahl ist Gelb, wenn zu viele Blöcke vorhanden sind.
|
PISTON_HELP_3=§7Die Anzahl ist Gelb, wenn zu viele Blöcke vorhanden sind.
|
||||||
PISTON_INFO=§7Bewegte Blöcke {0}{1}§8/§712
|
PISTON_INFO=§7Bewegte Blöcke {0}{1}§8/§712
|
||||||
|
PISTON_ENABLED=§aPiston-Berechnung aktiviert
|
||||||
|
PISTON_DISABLED=§cPiston-Berechnung deaktiviert
|
||||||
# Warp
|
# Warp
|
||||||
WARP_LOC_X=§7X§8: §e{0}
|
WARP_LOC_X=§7X§8: §e{0}
|
||||||
WARP_LOC_Y=§7Y§8: §e{0}
|
WARP_LOC_Y=§7Y§8: §e{0}
|
||||||
|
|||||||
@ -28,21 +28,21 @@ import de.steamwar.bausystem.features.script.lua.libs.LuaLib;
|
|||||||
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
|
||||||
import de.steamwar.bausystem.features.slaves.panzern.Panzern;
|
import de.steamwar.bausystem.features.slaves.panzern.Panzern;
|
||||||
import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm;
|
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.TraceManager;
|
||||||
import de.steamwar.bausystem.features.tracer.TraceRecorder;
|
import de.steamwar.bausystem.features.tracer.TraceRecorder;
|
||||||
import de.steamwar.bausystem.features.world.BauScoreboard;
|
import de.steamwar.bausystem.features.world.BauScoreboard;
|
||||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||||
import de.steamwar.bausystem.region.loader.PrototypeLoader;
|
import de.steamwar.bausystem.region.RegionSystem;
|
||||||
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.ScoreboardElement;
|
||||||
import de.steamwar.bausystem.utils.TickListener;
|
import de.steamwar.bausystem.utils.TickListener;
|
||||||
|
import de.steamwar.bausystem.utils.TickManager;
|
||||||
import de.steamwar.bausystem.worlddata.WorldData;
|
import de.steamwar.bausystem.worlddata.WorldData;
|
||||||
import de.steamwar.command.AbstractValidator;
|
import de.steamwar.command.AbstractValidator;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.SWCommandUtils;
|
import de.steamwar.command.SWCommandUtils;
|
||||||
|
import de.steamwar.core.CRIUSleepEvent;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
|
import de.steamwar.core.WorldEditRendererCUIEditor;
|
||||||
import de.steamwar.linkage.LinkedInstance;
|
import de.steamwar.linkage.LinkedInstance;
|
||||||
import de.steamwar.linkage.MaxVersion;
|
import de.steamwar.linkage.MaxVersion;
|
||||||
import de.steamwar.linkage.MinVersion;
|
import de.steamwar.linkage.MinVersion;
|
||||||
@ -55,6 +55,7 @@ import lombok.Getter;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@ -73,7 +74,7 @@ import java.util.function.Consumer;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class BauSystem extends JavaPlugin {
|
public class BauSystem extends JavaPlugin implements Listener {
|
||||||
|
|
||||||
// This should be treated as final!
|
// This should be treated as final!
|
||||||
public static Message MESSAGE;
|
public static Message MESSAGE;
|
||||||
@ -94,6 +95,8 @@ public class BauSystem extends JavaPlugin {
|
|||||||
instance = this;
|
instance = this;
|
||||||
SWUtils.setBausystem(instance);
|
SWUtils.setBausystem(instance);
|
||||||
|
|
||||||
|
RegionSystem.INSTANCE.load();
|
||||||
|
/*
|
||||||
try {
|
try {
|
||||||
PrototypeLoader.load();
|
PrototypeLoader.load();
|
||||||
RegionLoader.load();
|
RegionLoader.load();
|
||||||
@ -106,6 +109,7 @@ public class BauSystem extends JavaPlugin {
|
|||||||
|
|
||||||
new Updater(PrototypeLoader.file, PrototypeLoader::load);
|
new Updater(PrototypeLoader.file, PrototypeLoader::load);
|
||||||
new Updater(RegionLoader.file, RegionLoader::load);
|
new Updater(RegionLoader.file, RegionLoader::load);
|
||||||
|
*/
|
||||||
|
|
||||||
SWCommandUtils.addValidator(Player.class, validator(Permission.BUILD));
|
SWCommandUtils.addValidator(Player.class, validator(Permission.BUILD));
|
||||||
SWCommandUtils.addValidator(CommandSender.class, validator(Permission.BUILD));
|
SWCommandUtils.addValidator(CommandSender.class, validator(Permission.BUILD));
|
||||||
@ -206,6 +210,13 @@ public class BauSystem extends JavaPlugin {
|
|||||||
|
|
||||||
TraceManager.instance.init();
|
TraceManager.instance.init();
|
||||||
TraceRecorder.instance.init();
|
TraceRecorder.instance.init();
|
||||||
|
|
||||||
|
new WorldEditRendererCUIEditor();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onCRIUSleep(CRIUSleepEvent event) {
|
||||||
|
RegionSystem.INSTANCE.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -220,6 +231,7 @@ public class BauSystem extends JavaPlugin {
|
|||||||
});
|
});
|
||||||
|
|
||||||
WorldData.write();
|
WorldData.write();
|
||||||
|
RegionSystem.INSTANCE.save();
|
||||||
Config.getInstance().saveAll();
|
Config.getInstance().saveAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,7 +275,7 @@ public class BauSystem extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (TPSFreezeUtils.isFrozen()) return;
|
if (TickManager.impl.isFrozen()) return;
|
||||||
if (counter >= delay) {
|
if (counter >= delay) {
|
||||||
runnable.run();
|
runnable.run();
|
||||||
cancel();
|
cancel();
|
||||||
@ -281,7 +293,7 @@ public class BauSystem extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (TPSFreezeUtils.isFrozen()) return;
|
if (TickManager.impl.isFrozen()) return;
|
||||||
if (counter >= (first ? delay : period)) {
|
if (counter >= (first ? delay : period)) {
|
||||||
first = false;
|
first = false;
|
||||||
runnable.run();
|
runnable.run();
|
||||||
|
|||||||
@ -21,11 +21,9 @@ package de.steamwar.bausystem;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.config.BauServer;
|
import de.steamwar.bausystem.config.BauServer;
|
||||||
import de.steamwar.bausystem.features.world.BauMemberUpdate;
|
import de.steamwar.bausystem.features.world.BauMemberUpdate;
|
||||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
|
||||||
import de.steamwar.sql.BauweltMember;
|
import de.steamwar.sql.BauweltMember;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|||||||
@ -24,7 +24,6 @@ import de.steamwar.command.PreviousArguments;
|
|||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.MinVersion;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|||||||
@ -24,8 +24,6 @@ import de.steamwar.bausystem.Permission;
|
|||||||
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import de.steamwar.bausystem.utils.ItemUtils;
|
import de.steamwar.bausystem.utils.ItemUtils;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
@ -33,8 +31,6 @@ import lombok.Getter;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.data.type.Chest;
|
import org.bukkit.block.data.type.Chest;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -43,9 +39,9 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
|
|||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.io.File;
|
import java.util.Arrays;
|
||||||
import java.text.SimpleDateFormat;
|
import java.util.HashMap;
|
||||||
import java.util.*;
|
import java.util.Map;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class AutostartListener implements Listener {
|
public class AutostartListener implements Listener {
|
||||||
@ -106,11 +102,11 @@ public class AutostartListener implements Listener {
|
|||||||
|
|
||||||
public void activate(Player player) {
|
public void activate(Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region.isGlobal()) {
|
if (region.getType().isGlobal()) {
|
||||||
BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO_REGION", player);
|
BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO_REGION", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!region.hasType(RegionType.TESTBLOCK)) {
|
if (region.getTestblockArea().isEmpty()) {
|
||||||
BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO_REGION", player);
|
BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO_REGION", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -131,20 +127,12 @@ public class AutostartListener implements Listener {
|
|||||||
event.blockList().forEach(block -> {
|
event.blockList().forEach(block -> {
|
||||||
Region region = Region.getRegion(block.getLocation());
|
Region region = Region.getRegion(block.getLocation());
|
||||||
if (!regionStartTime.containsKey(region)) return;
|
if (!regionStartTime.containsKey(region)) return;
|
||||||
if (!region.hasType(RegionType.TESTBLOCK)) return;
|
if (!region.getTestblockArea().inRegion(block.getLocation(), true)) return;
|
||||||
if (!region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) return;
|
|
||||||
long tickDiff = TPSUtils.currentRealTick.get() - regionStartTime.remove(region);
|
long tickDiff = TPSUtils.currentRealTick.get() - regionStartTime.remove(region);
|
||||||
long preFightDurationInSeconds = getPreFightDurationInSeconds(region);
|
long preFightDurationInSeconds = region.getGameModeConfig().getTimes().getPreFightDuration();
|
||||||
RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT1", tickDiff);
|
RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT1", tickDiff);
|
||||||
RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT2", preFightDurationInSeconds, ((preFightDurationInSeconds * 20) - tickDiff));
|
RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT2", preFightDurationInSeconds, ((preFightDurationInSeconds * 20) - tickDiff));
|
||||||
RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT3");
|
RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT3");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getPreFightDurationInSeconds(Region region) {
|
|
||||||
File file = region.gameModeConfig();
|
|
||||||
if (file == null) return 30;
|
|
||||||
FileConfiguration config = YamlConfiguration.loadConfiguration(file);
|
|
||||||
return config.getInt("Times.PreFightDuration", 30);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,31 +19,23 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.backup;
|
package de.steamwar.bausystem.features.backup;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.bausystem.region.Color;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
import de.steamwar.bausystem.region.RegionBackups;
|
||||||
|
import de.steamwar.bausystem.region.flags.ChangedMode;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
import de.steamwar.command.PreviousArguments;
|
||||||
import de.steamwar.bausystem.region.tags.Tag;
|
|
||||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.SWCommandUtils;
|
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.inventory.SWListInv;
|
import de.steamwar.inventory.SWListInv;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.File;
|
import java.util.*;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
@ -54,7 +46,7 @@ public class BackupCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static boolean checkGlobalRegion(Region region, Player p) {
|
static boolean checkGlobalRegion(Region region, Player p) {
|
||||||
if (region.isGlobal()) {
|
if (region.getType().isGlobal()) {
|
||||||
BauSystem.MESSAGE.send("BACKUP_REGION_NO_REGION", p);
|
BauSystem.MESSAGE.send("BACKUP_REGION_NO_REGION", p);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -67,11 +59,12 @@ public class BackupCommand extends SWCommand {
|
|||||||
if (checkGlobalRegion(region, p)) {
|
if (checkGlobalRegion(region, p)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!region.get(Tag.CHANGED)) {
|
if (region.getFlags().get(Flag.CHANGED).isWithDefault(ChangedMode.NO_CHANGE)) {
|
||||||
BauSystem.MESSAGE.send("BACKUP_CREATE_NO_CHANGE", p);
|
BauSystem.MESSAGE.send("BACKUP_CREATE_NO_CHANGE", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (region.backup()) {
|
Optional<RegionBackups.Backup> backup = region.getBackups().create(RegionBackups.BackupType.MANUAL);
|
||||||
|
if (backup.isPresent()) {
|
||||||
BauSystem.MESSAGE.send("BACKUP_CREATE_SUCCESS", p);
|
BauSystem.MESSAGE.send("BACKUP_CREATE_SUCCESS", p);
|
||||||
} else {
|
} else {
|
||||||
BauSystem.MESSAGE.send("BACKUP_CREATE_FAILURE", p);
|
BauSystem.MESSAGE.send("BACKUP_CREATE_FAILURE", p);
|
||||||
@ -79,25 +72,12 @@ public class BackupCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "load", description = "BACKUP_HELP_LOAD")
|
@Register(value = "load", description = "BACKUP_HELP_LOAD")
|
||||||
public void backupLoad(@Validator("owner") Player p, @Mapper("backupName") String backupName) {
|
public void backupLoad(@Validator("owner") Player p, @Mapper("backup") @ErrorMessage("BACKUP_LOAD_FAILURE") RegionBackups.Backup backup) {
|
||||||
Region region = Region.getRegion(p.getLocation());
|
if (backup.load()) {
|
||||||
if (checkGlobalRegion(region, p)) {
|
BauSystem.MESSAGE.send("BACKUP_LOAD", p);
|
||||||
return;
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
File backupFile = region.getBackupFile(backupName.replace('_', ' '));
|
|
||||||
if (backupFile == null) {
|
|
||||||
BauSystem.MESSAGE.send("BACKUP_LOAD_FAILURE", p);
|
BauSystem.MESSAGE.send("BACKUP_LOAD_FAILURE", p);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
EditSession editSession = new PasteBuilder(new PasteBuilder.FileProvider(backupFile))
|
|
||||||
.pastePoint(region.getMinPoint().add(region.getPrototype().getSizeX() / 2, 0, region.getPrototype().getSizeZ() / 2))
|
|
||||||
.minPoint(region.getMinPoint())
|
|
||||||
.maxPoint(region.getMaxPoint())
|
|
||||||
.waterLevel(region.getWaterLevel())
|
|
||||||
.run();
|
|
||||||
region.remember(editSession);
|
|
||||||
BauSystem.MESSAGE.send("BACKUP_LOAD", p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "list", description = "BACKUP_HELP_LIST")
|
@Register(value = "list", description = "BACKUP_HELP_LIST")
|
||||||
@ -106,10 +86,10 @@ public class BackupCommand extends SWCommand {
|
|||||||
if (checkGlobalRegion(region, p)) {
|
if (checkGlobalRegion(region, p)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<String> backups = listBackup(p);
|
List<RegionBackups.Backup> backups = listBackup(p);
|
||||||
BauSystem.MESSAGE.send("BACKUP_LIST_HEAD", p, backups.size());
|
BauSystem.MESSAGE.send("BACKUP_LIST_HEAD", p, backups.size());
|
||||||
backups.forEach(s -> {
|
backups.forEach(backup -> {
|
||||||
BauSystem.MESSAGE.send("BACKUP_LIST_ENTRY", p, "/backup load " + s, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/backup load " + s), s);
|
BauSystem.MESSAGE.send("BACKUP_LIST_ENTRY", p, "/backup load " + backup.getName(), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/backup load " + backup.getName()), backup.getName());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,34 +99,44 @@ public class BackupCommand extends SWCommand {
|
|||||||
if (checkGlobalRegion(region, p)) {
|
if (checkGlobalRegion(region, p)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<String> backups = listBackup(p);
|
List<RegionBackups.Backup> backups = listBackup(p);
|
||||||
List<SWListInv.SWListEntry<String>> swListEntries = new ArrayList<>();
|
List<SWListInv.SWListEntry<RegionBackups.Backup>> swListEntries = new ArrayList<>();
|
||||||
List<String> lore = Arrays.asList(BauSystem.MESSAGE.parse("BACKUP_LORE", p));
|
List<String> lore = Arrays.asList(BauSystem.MESSAGE.parse("BACKUP_LORE", p));
|
||||||
for (int i = 0; i < backups.size(); i++) {
|
for (int i = 0; i < backups.size(); i++) {
|
||||||
String s = backups.get(i);
|
RegionBackups.Backup backup = backups.get(i);
|
||||||
SWItem swItem = new SWItem(Material.BRICK, BauSystem.MESSAGE.parse("BACKUP_ITEM_NAME", p, s), lore, false, clickType -> {});
|
SWItem swItem = new SWItem(Material.BRICK, BauSystem.MESSAGE.parse("BACKUP_ITEM_NAME", p, backup.getName()), lore, false, clickType -> {});
|
||||||
swItem.getItemStack().setAmount(i + 1);
|
swItem.getItemStack().setAmount(i + 1);
|
||||||
swListEntries.add(new SWListInv.SWListEntry<>(swItem, s));
|
swListEntries.add(new SWListInv.SWListEntry<>(swItem, backup));
|
||||||
}
|
}
|
||||||
SWListInv<String> swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("BACKUP_INV_NAME", p), swListEntries, (clickType, s) -> {
|
SWListInv<RegionBackups.Backup> swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("BACKUP_INV_NAME", p), swListEntries, (clickType, s) -> {
|
||||||
p.getOpenInventory().close();
|
p.getOpenInventory().close();
|
||||||
p.performCommand("backup load " + s);
|
backupLoad(p, s);
|
||||||
});
|
});
|
||||||
swListInv.open();
|
swListInv.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mapper(value = "backupName", local = true)
|
@Mapper(value = "backup", local = true)
|
||||||
public TypeMapper<String> backupMapper() {
|
public TypeMapper<RegionBackups.Backup> backupMapper() {
|
||||||
return SWCommandUtils.createMapper(s -> s, (commandSender, s) -> listBackup((Player) commandSender));
|
return new TypeMapper<>() {
|
||||||
|
@Override
|
||||||
|
public RegionBackups.Backup map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||||
|
return Region.getRegion(((Player) commandSender).getLocation()).getBackups().get(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||||
|
return listBackup((Player) sender).stream().map(RegionBackups.Backup::getName).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> listBackup(Player p) {
|
private List<RegionBackups.Backup> listBackup(Player p) {
|
||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
if (checkGlobalRegion(region, p)) {
|
if (checkGlobalRegion(region, p)) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return region.listBackup().stream().map(s -> s.substring(0, s.length() - 6).replace(' ', '_')).collect(Collectors.toList());
|
return region.getBackups().list();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.config.BauServer;
|
import de.steamwar.bausystem.config.BauServer;
|
||||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||||
|
import de.steamwar.bausystem.region.FlagOptional;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
@ -56,15 +57,10 @@ public class BauInfoBauGuiItem extends BauGuiItem {
|
|||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
List<String> stringList = new ArrayList<>();
|
List<String> stringList = new ArrayList<>();
|
||||||
for (Flag flag : Flag.getFlags()) {
|
for (Flag flag : Flag.getFlags()) {
|
||||||
if (flag == Flag.PROTECT && region.getFloorLevel() == 0) {
|
if (!region.getFlags().has(flag).isApplicable()) continue;
|
||||||
continue;
|
FlagOptional<?> value = region.getFlags().get(flag);
|
||||||
}
|
if (value.isPresent()) {
|
||||||
if (flag == Flag.ITEMS && Core.getVersion() < 19) {
|
stringList.add(BauSystem.MESSAGE.parse("BAU_INFO_ITEM_LORE_" + flag.name(), player, BauSystem.MESSAGE.parse(value.getWithDefault().getChatValue(), player)));
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Flag.Value<?> value = region.get(flag);
|
|
||||||
if (value != null) {
|
|
||||||
stringList.add(BauSystem.MESSAGE.parse("BAU_INFO_ITEM_LORE_" + flag.name(), player, BauSystem.MESSAGE.parse(value.getChatValue(), player)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
itemStack.setLore(stringList);
|
itemStack.setLore(stringList);
|
||||||
|
|||||||
@ -19,13 +19,11 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.bau;
|
package de.steamwar.bausystem.features.bau;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.command.PreviousArguments;
|
import de.steamwar.command.PreviousArguments;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.techhider.TechHider;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package de.steamwar.bausystem.features.bau;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.config.BauServer;
|
import de.steamwar.bausystem.config.BauServer;
|
||||||
|
import de.steamwar.bausystem.region.FlagOptional;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
@ -30,12 +31,10 @@ public class InfoCommand extends SWCommand {
|
|||||||
BauSystem.MESSAGE.send("BAU_INFO_COMMAND_OWNER", p, SteamwarUser.get(bauServer.getOwnerID()).getUserName());
|
BauSystem.MESSAGE.send("BAU_INFO_COMMAND_OWNER", p, SteamwarUser.get(bauServer.getOwnerID()).getUserName());
|
||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
for (Flag flag : Flag.getFlags()) {
|
for (Flag flag : Flag.getFlags()) {
|
||||||
if (flag == Flag.PROTECT && region.getFloorLevel() == 0) {
|
if (!region.getFlags().has(flag).isApplicable()) continue;
|
||||||
continue;
|
FlagOptional<?> value = region.getFlags().get(flag);
|
||||||
}
|
if (value.isPresent()) {
|
||||||
Flag.Value<?> value = region.get(flag);
|
BauSystem.MESSAGE.send("BAU_INFO_COMMAND_FLAG", p, BauSystem.MESSAGE.parse(flag.getChatValue(), p), BauSystem.MESSAGE.parse(value.getWithDefault().getChatValue(), p));
|
||||||
if (value != null) {
|
|
||||||
BauSystem.MESSAGE.send("BAU_INFO_COMMAND_FLAG", p, BauSystem.MESSAGE.parse(flag.getChatValue(), p), BauSystem.MESSAGE.parse(value.getChatValue(), p));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.features.cannon.depth.Depth;
|
import de.steamwar.bausystem.features.cannon.depth.Depth;
|
||||||
import de.steamwar.bausystem.features.cannon.depth.DepthManager;
|
import de.steamwar.bausystem.features.cannon.depth.DepthManager;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.TNTPrimed;
|
import org.bukkit.entity.TNTPrimed;
|
||||||
@ -85,8 +84,8 @@ public class CannonDetector implements Listener {
|
|||||||
grouped.forEach((cannonKey, tntPrimeds) -> {
|
grouped.forEach((cannonKey, tntPrimeds) -> {
|
||||||
if (tntPrimeds.size() <= 5) return;
|
if (tntPrimeds.size() <= 5) return;
|
||||||
Region region = Region.getRegion(tntPrimeds.get(0).getLocation());
|
Region region = Region.getRegion(tntPrimeds.get(0).getLocation());
|
||||||
if (region.isGlobal()) return;
|
if (region.getType().isGlobal()) return;
|
||||||
if (!region.hasType(RegionType.TESTBLOCK)) return;
|
if (region.getTestblockArea().isEmpty()) return;
|
||||||
Depth depth = new Depth(region);
|
Depth depth = new Depth(region);
|
||||||
DepthManager.init(tntPrimeds, depth);
|
DepthManager.init(tntPrimeds, depth);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -22,7 +22,6 @@ package de.steamwar.bausystem.features.cannon;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.entity.TNTPrimed;
|
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|||||||
@ -20,10 +20,9 @@
|
|||||||
package de.steamwar.bausystem.features.cannon.depth;
|
package de.steamwar.bausystem.features.cannon.depth;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.configplayer.Config;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
@ -49,7 +48,7 @@ public class Depth {
|
|||||||
|
|
||||||
public void update(List<Block> blocks) {
|
public void update(List<Block> blocks) {
|
||||||
List<Block> blocksList = blocks.stream()
|
List<Block> blocksList = blocks.stream()
|
||||||
.filter(block -> region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION))
|
.filter(block -> region.getTestblockArea().inRegion(block.getLocation(), true))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
tntCount++;
|
tntCount++;
|
||||||
for (Block block : blocksList) {
|
for (Block block : blocksList) {
|
||||||
@ -65,7 +64,9 @@ public class Depth {
|
|||||||
dimensions.setZ(Math.abs(dimensions.getZ()));
|
dimensions.setZ(Math.abs(dimensions.getZ()));
|
||||||
|
|
||||||
RegionUtils.message(region, player -> {
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -29,12 +29,11 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
import java.util.stream.Collectors;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class DesignEndStone {
|
public class DesignEndStone {
|
||||||
|
|
||||||
@ -44,18 +43,26 @@ public class DesignEndStone {
|
|||||||
private REntityServer entityServer = new REntityServer();
|
private REntityServer entityServer = new REntityServer();
|
||||||
private List<REntity> entities = new ArrayList<>();
|
private List<REntity> entities = new ArrayList<>();
|
||||||
private Set<Location> locations = new HashSet<>();
|
private Set<Location> locations = new HashSet<>();
|
||||||
private boolean wsOrAs;
|
private Set<Material> limited;
|
||||||
private double maxBlastResistance;
|
private boolean calculateFromBottom;
|
||||||
|
|
||||||
public DesignEndStone(Region region) {
|
public DesignEndStone(Region region) {
|
||||||
this.minX = region.getMinPointBuild().getX();
|
this.minX = region.getBuildArea().getMinPoint(false).getX();
|
||||||
this.minY = region.getMinPointBuild().getY();
|
this.minY = region.getBuildArea().getMinPoint(false).getY();
|
||||||
this.minZ = region.getMinPointBuild().getZ();
|
this.minZ = region.getBuildArea().getMinPoint(false).getZ();
|
||||||
this.maxX = region.getMaxPointBuild().getX();
|
this.maxX = region.getBuildArea().getMaxPoint(false).getX();
|
||||||
this.maxY = region.getMaxPointBuild().getY();
|
this.maxY = region.getBuildArea().getMaxPoint(false).getY();
|
||||||
this.maxZ = region.getMaxPointBuild().getZ();
|
this.maxZ = region.getBuildArea().getMaxPoint(false).getZ();
|
||||||
wsOrAs = region.getName().startsWith("ws") || region.getName().startsWith("as");
|
|
||||||
maxBlastResistance = wsOrAs ? 6.1 : 9.0;
|
limited = region.getGameModeConfig()
|
||||||
|
.getSchematic()
|
||||||
|
.getLimited()
|
||||||
|
.entrySet()
|
||||||
|
.stream()
|
||||||
|
.filter(entry -> entry.getValue() == 0)
|
||||||
|
.flatMap(entry -> entry.getKey().stream())
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
calculateFromBottom = region.getGameModeConfig().getArena().isNoFloor();
|
||||||
|
|
||||||
entityServer.setCallback((player, rEntity, entityAction) -> {
|
entityServer.setCallback((player, rEntity, entityAction) -> {
|
||||||
if (entityAction != REntityServer.EntityAction.ATTACK) return;
|
if (entityAction != REntityServer.EntityAction.ATTACK) return;
|
||||||
@ -76,7 +83,7 @@ public class DesignEndStone {
|
|||||||
calc(minX, minY, maxZ, maxX, maxY, maxZ, 0, 0, -1, maxZ - minZ);
|
calc(minX, minY, maxZ, maxX, maxY, maxZ, 0, 0, -1, maxZ - minZ);
|
||||||
calc(minX, minY, minZ, minX, maxY, maxZ, 1, 0, 0, maxX - minX);
|
calc(minX, minY, minZ, minX, maxY, maxZ, 1, 0, 0, maxX - minX);
|
||||||
calc(maxX, minY, minZ, maxX, maxY, maxZ, -1, 0, 0, maxX - minX);
|
calc(maxX, minY, minZ, maxX, maxY, maxZ, -1, 0, 0, maxX - minX);
|
||||||
if (wsOrAs) {
|
if (calculateFromBottom) {
|
||||||
calc(minX, minY, minZ, maxX, minY, maxZ, 0, 1, 0, maxY - minY + 1);
|
calc(minX, minY, minZ, maxX, minY, maxZ, 0, 1, 0, maxY - minY + 1);
|
||||||
} else {
|
} else {
|
||||||
int airBlocks = 0;
|
int airBlocks = 0;
|
||||||
@ -106,7 +113,7 @@ public class DesignEndStone {
|
|||||||
int cz = z + step * dirZ;
|
int cz = z + step * dirZ;
|
||||||
Material material = WORLD.getBlockAt(cx, cy, cz).getType();
|
Material material = WORLD.getBlockAt(cx, cy, cz).getType();
|
||||||
|
|
||||||
if (material != Material.WATER && material != Material.LAVA && material.getBlastResistance() >= maxBlastResistance) {
|
if (material != Material.WATER && material != Material.LAVA && limited.contains(material)) {
|
||||||
Location location = new Location(WORLD, cx + 0.5, cy, cz + 0.5);
|
Location location = new Location(WORLD, cx + 0.5, cy, cz + 0.5);
|
||||||
if (!locations.add(location)) break;
|
if (!locations.add(location)) break;
|
||||||
RFallingBlockEntity entity = new RFallingBlockEntity(entityServer, location, Material.RED_STAINED_GLASS);
|
RFallingBlockEntity entity = new RFallingBlockEntity(entityServer, location, Material.RED_STAINED_GLASS);
|
||||||
|
|||||||
@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.design.endstone;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
@ -49,7 +48,11 @@ public class DesignEndStoneCommand extends SWCommand implements Listener {
|
|||||||
@Register(description = "DESIGN_ENDSTONE_COMMAND_HELP")
|
@Register(description = "DESIGN_ENDSTONE_COMMAND_HELP")
|
||||||
public void genericCommand(@Validator Player player) {
|
public void genericCommand(@Validator Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (!region.hasType(RegionType.BUILD)) {
|
if (region.getBuildArea().isEmpty()) {
|
||||||
|
BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!region.getGameModeConfig().isLoaded()) {
|
||||||
BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player);
|
BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.features.gui.BauGUI;
|
import de.steamwar.bausystem.features.gui.BauGUI;
|
||||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||||
import de.steamwar.core.TrickyTrialsWrapper;
|
import de.steamwar.core.TrickyTrialsWrapper;
|
||||||
|
import de.steamwar.data.CMDs;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.inventory.SWListInv;
|
import de.steamwar.inventory.SWListInv;
|
||||||
import de.steamwar.linkage.Linked;
|
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 -> {
|
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());
|
}).getItemStack());
|
||||||
inv.setItem(mapping.getSize() + 6, new SWItem(TrickyTrialsWrapper.impl.getTurtleScute(), BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_MORE", p)).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.openInventory(inv);
|
||||||
p.getOpenInventory().setCursor(cursor == null ? new SWItem().getItemStack() : cursor);
|
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.SWUtils;
|
||||||
import de.steamwar.bausystem.configplayer.Config;
|
import de.steamwar.bausystem.configplayer.Config;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.inventory.SWInventory;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.linkage.Linked;
|
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.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class InventoryFillerCommand extends SWCommand {
|
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() {
|
public InventoryFillerCommand() {
|
||||||
super("inventoryfill");
|
super("inventoryfill");
|
||||||
}
|
}
|
||||||
@ -21,8 +54,116 @@ public class InventoryFillerCommand extends SWCommand {
|
|||||||
if (!inventoryFill) {
|
if (!inventoryFill) {
|
||||||
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("INVENTORY_FILL_ENABLE", player));
|
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("INVENTORY_FILL_ENABLE", player));
|
||||||
BauSystem.MESSAGE.send("INVENTORY_FILL_INFO", player);
|
BauSystem.MESSAGE.send("INVENTORY_FILL_INFO", player);
|
||||||
}else {
|
} else {
|
||||||
SWUtils.sendToActionbar(player, BauSystem.MESSAGE.parse("INVENTORY_FILL_DISABLE", player));
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,7 +38,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class KillcheckerCommand extends SWCommand implements Listener {
|
public class KillcheckerCommand extends SWCommand implements Listener {
|
||||||
@ -57,6 +56,10 @@ public class KillcheckerCommand extends SWCommand implements Listener {
|
|||||||
@Register(value = "enable", description = "KILLCHECKER_HELP_ENABLE")
|
@Register(value = "enable", description = "KILLCHECKER_HELP_ENABLE")
|
||||||
public void genericCommand(@Validator Player player, @OptionalValue("-outline") @StaticValue(value = {"-area", "-outline"}, allowISE = true) boolean onlyOutline) {
|
public void genericCommand(@Validator Player player, @OptionalValue("-outline") @StaticValue(value = {"-area", "-outline"}, allowISE = true) boolean onlyOutline) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
|
if (region.getBuildArea().isEmpty()) {
|
||||||
|
BauSystem.MESSAGE.send("KILLCHECKER_NO_BUILD", player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
KillcheckerVisualizer killcheckerVisualizer = visualizers.computeIfAbsent(region, region1 -> new KillcheckerVisualizer(region1, bossBarService));
|
KillcheckerVisualizer killcheckerVisualizer = visualizers.computeIfAbsent(region, region1 -> new KillcheckerVisualizer(region1, bossBarService));
|
||||||
killcheckerVisualizer.recalc();
|
killcheckerVisualizer.recalc();
|
||||||
killcheckerVisualizer.show(player, onlyOutline);
|
killcheckerVisualizer.show(player, onlyOutline);
|
||||||
|
|||||||
@ -22,8 +22,6 @@ package de.steamwar.bausystem.features.killchecker;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.region.Point;
|
import de.steamwar.bausystem.region.Point;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
|
||||||
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
import de.steamwar.bausystem.utils.bossbar.BossBarService;
|
||||||
import de.steamwar.entity.REntity;
|
import de.steamwar.entity.REntity;
|
||||||
@ -75,8 +73,8 @@ public class KillcheckerVisualizer {
|
|||||||
|
|
||||||
public KillcheckerVisualizer(Region region, BossBarService bossBarService) {
|
public KillcheckerVisualizer(Region region, BossBarService bossBarService) {
|
||||||
this.region = region;
|
this.region = region;
|
||||||
this.minPoint = region.getMinPoint(RegionType.BUILD, RegionExtensionType.NORMAL);
|
this.minPoint = region.getBuildArea().getMinPoint(false);
|
||||||
this.maxPoint = region.getMaxPoint(RegionType.BUILD, RegionExtensionType.NORMAL);
|
this.maxPoint = region.getBuildArea().getMaxPoint(false);
|
||||||
|
|
||||||
yArea = (maxPoint.getX() - minPoint.getX()) * (maxPoint.getZ() - minPoint.getZ());
|
yArea = (maxPoint.getX() - minPoint.getX()) * (maxPoint.getZ() - minPoint.getZ());
|
||||||
zArea = (maxPoint.getX() - minPoint.getX()) * (maxPoint.getY() - minPoint.getY());
|
zArea = (maxPoint.getX() - minPoint.getX()) * (maxPoint.getY() - minPoint.getY());
|
||||||
|
|||||||
@ -73,7 +73,7 @@ public class Loader implements Listener {
|
|||||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance());
|
Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance());
|
||||||
|
|
||||||
BauSystem.runTaskTimer(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(!Permission.BUILD.hasPermission(p)) return;
|
||||||
if (waitTime > 0) {
|
if (waitTime > 0) {
|
||||||
waitTime--;
|
waitTime--;
|
||||||
@ -149,13 +149,16 @@ public class Loader implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean setTicksBetweenShots(int delay) {
|
public boolean setTicksBetweenShots(int delay) {
|
||||||
if (elements.size() == 0) return false;
|
if (elements.isEmpty()) return false;
|
||||||
LoaderElement loaderElement = elements.get(elements.size() - 1);
|
LoaderElement loaderElement = elements.get(elements.size() - 1);
|
||||||
if (loaderElement instanceof LoaderWait) {
|
if (loaderElement instanceof LoaderWait) {
|
||||||
((LoaderWait) loaderElement).setDelay(delay);
|
((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) {
|
public void setTicksBetweenBlocks(int delay) {
|
||||||
|
|||||||
@ -44,7 +44,6 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
public class LoaderRecorder implements Listener {
|
public class LoaderRecorder implements Listener {
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.bausystem.features.loader.elements;
|
package de.steamwar.bausystem.features.loader.elements;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.data.CMDs;
|
||||||
import de.steamwar.inventory.SWAnvilInv;
|
import de.steamwar.inventory.SWAnvilInv;
|
||||||
import de.steamwar.inventory.SWInventory;
|
import de.steamwar.inventory.SWInventory;
|
||||||
import de.steamwar.inventory.SWItem;
|
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 -> {
|
listInv.setItem(48, new SWItem(Material.ARROW, "§7Back", clickType -> {
|
||||||
backAction.run();
|
backAction.run();
|
||||||
}));
|
}).setCustomModelData(CMDs.BACK));
|
||||||
listInv.setItem(50, new SWItem(Material.GHAST_SPAWN_EGG, "§7Insert another Setting", clickType -> {
|
listInv.setItem(50, new SWItem(Material.GHAST_SPAWN_EGG, "§7Insert another Setting", clickType -> {
|
||||||
elements.add(defaultSetting);
|
elements.add(defaultSetting);
|
||||||
extraPower.add(0);
|
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));
|
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 -> {}));
|
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 -> {
|
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 swAnvilInv = new SWAnvilInv(player, BauSystem.MESSAGE.parse("LOADER_GUI_COPY_TITLE", player), "1");
|
||||||
swAnvilInv.setCallback(s -> {
|
swAnvilInv.setCallback(s -> {
|
||||||
|
|||||||
@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.loader.elements.impl;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.features.loader.elements.LoaderElement;
|
import de.steamwar.bausystem.features.loader.elements.LoaderElement;
|
||||||
|
import de.steamwar.data.CMDs;
|
||||||
import de.steamwar.inventory.SWAnvilInv;
|
import de.steamwar.inventory.SWAnvilInv;
|
||||||
import de.steamwar.inventory.SWInventory;
|
import de.steamwar.inventory.SWInventory;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
@ -60,7 +61,7 @@ public class LoaderWait implements LoaderElement {
|
|||||||
public void click(Player player, Runnable backAction) {
|
public void click(Player player, Runnable backAction) {
|
||||||
SWInventory swInventory = new SWInventory(player, 18, BauSystem.MESSAGE.parse("LOADER_GUI_WAIT_TITLE", player));
|
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"));
|
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 -> {
|
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;
|
delay -= clickType.isShiftClick() ? 5 : 1;
|
||||||
|
|||||||
@ -22,8 +22,6 @@ package de.steamwar.bausystem.features.loadtimer;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -158,7 +156,7 @@ public class Loadtimer implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onTntExplode(EntityExplodeEvent event) {
|
public void onTntExplode(EntityExplodeEvent event) {
|
||||||
if (region.inRegion(event.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION) && stage == Stage.IGNITION) {
|
if (region.getBuildArea().inRegion(event.getLocation(), true) && stage == Stage.IGNITION) {
|
||||||
stage = Stage.END;
|
stage = Stage.END;
|
||||||
explode = TPSUtils.currentRealTick.get();
|
explode = TPSUtils.currentRealTick.get();
|
||||||
print();
|
print();
|
||||||
|
|||||||
@ -39,7 +39,7 @@ public class LoadtimerCommand extends SWCommand {
|
|||||||
@Register(value = "start", description = {"LOADTIMER_HELP_START_2", "LOADTIMER_HELP_START_3"})
|
@Register(value = "start", description = {"LOADTIMER_HELP_START_2", "LOADTIMER_HELP_START_3"})
|
||||||
public void start(@Validator Player p, TimerMode mode) {
|
public void start(@Validator Player p, TimerMode mode) {
|
||||||
Region r = Region.getRegion(p.getLocation());
|
Region r = Region.getRegion(p.getLocation());
|
||||||
if (r.isGlobal()) return;
|
if (r.getType().isGlobal()) return;
|
||||||
if (!Loadtimer.hasTimer(r))
|
if (!Loadtimer.hasTimer(r))
|
||||||
Loadtimer.createLoadtimer(r, mode == TimerMode.HALF);
|
Loadtimer.createLoadtimer(r, mode == TimerMode.HALF);
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@ public class LoadtimerCommand extends SWCommand {
|
|||||||
@Register(value = "stop", description = "LOADTIMER_HELP_STOP")
|
@Register(value = "stop", description = "LOADTIMER_HELP_STOP")
|
||||||
public void stop(@Validator Player p) {
|
public void stop(@Validator Player p) {
|
||||||
Region r = Region.getRegion(p.getLocation());
|
Region r = Region.getRegion(p.getLocation());
|
||||||
if (r.isGlobal()) return;
|
if (r.getType().isGlobal()) return;
|
||||||
if (Loadtimer.hasTimer(r))
|
if (Loadtimer.hasTimer(r))
|
||||||
Loadtimer.getTimer(r).delete();
|
Loadtimer.getTimer(r).delete();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,7 +46,7 @@ public class LoadtimerGuiItem extends BauGuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(Player player) {
|
public ItemStack getItem(Player player) {
|
||||||
Region r = Region.getRegion(player.getLocation());
|
Region r = Region.getRegion(player.getLocation());
|
||||||
if (r.isGlobal())
|
if (r.getType().isGlobal())
|
||||||
return new SWItem(Material.BOWL, BauSystem.MESSAGE.parse("LOADTIMER_GUI_GLOBAL", player)).getItemStack();
|
return new SWItem(Material.BOWL, BauSystem.MESSAGE.parse("LOADTIMER_GUI_GLOBAL", player)).getItemStack();
|
||||||
if (Loadtimer.hasTimer(r)) {
|
if (Loadtimer.hasTimer(r)) {
|
||||||
return new SWItem(Material.BOW, BauSystem.MESSAGE.parse("LOADTIMER_GUI_STOP", player)).getItemStack();
|
return new SWItem(Material.BOW, BauSystem.MESSAGE.parse("LOADTIMER_GUI_STOP", player)).getItemStack();
|
||||||
@ -58,7 +58,7 @@ public class LoadtimerGuiItem extends BauGuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public boolean click(ClickType click, Player p) {
|
public boolean click(ClickType click, Player p) {
|
||||||
Region r = Region.getRegion(p.getLocation());
|
Region r = Region.getRegion(p.getLocation());
|
||||||
if (r.isGlobal()) return false;
|
if (r.getType().isGlobal()) return false;
|
||||||
if (Loadtimer.hasTimer(r)) {
|
if (Loadtimer.hasTimer(r)) {
|
||||||
p.performCommand("lt stop");
|
p.performCommand("lt stop");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -20,7 +20,6 @@
|
|||||||
package de.steamwar.bausystem.features.observer;
|
package de.steamwar.bausystem.features.observer;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|||||||
@ -0,0 +1,207 @@
|
|||||||
|
/*
|
||||||
|
* 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.block.data.BlockData;
|
||||||
|
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.List;
|
||||||
|
|
||||||
|
@Linked
|
||||||
|
@MinVersion(20)
|
||||||
|
public class RayVisualizerCommand extends SWCommand implements Listener {
|
||||||
|
|
||||||
|
private BlockData VISIBLE = Material.LIME_CONCRETE.createBlockData();
|
||||||
|
private BlockData BLOCKED = Material.RED_CONCRETE.createBlockData();
|
||||||
|
|
||||||
|
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;
|
||||||
|
List<TNTPrimed> primedList = WORLD.getEntitiesByClass(TNTPrimed.class)
|
||||||
|
.stream().toList();
|
||||||
|
rayData.reset();
|
||||||
|
if (primedList.isEmpty()) return;
|
||||||
|
calculateRays(primedList, primedList);
|
||||||
|
}, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void calculateRays(List<TNTPrimed> fromTNTs, List<TNTPrimed> toTNTs) {
|
||||||
|
for (TNTPrimed to : toTNTs) {
|
||||||
|
int hitting = 0;
|
||||||
|
int total = 0;
|
||||||
|
for (TNTPrimed from : fromTNTs) {
|
||||||
|
if (from == to) continue;
|
||||||
|
if (from.getFuseTicks() >= to.getFuseTicks()) continue;
|
||||||
|
if (to.getLocation().distanceSquared(from.getLocation()) > 25) continue;
|
||||||
|
if (!from.isInWater()) 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);
|
||||||
|
CRay cRay = rayData.get(fromLoc, end);
|
||||||
|
if (cRay == null) continue;
|
||||||
|
cRay.setFrom(fromLoc);
|
||||||
|
cRay.setTo(end);
|
||||||
|
if (result != null && result.getHitBlock() != null) {
|
||||||
|
cRay.setBlock(BLOCKED);
|
||||||
|
} else {
|
||||||
|
cRay.setBlock(VISIBLE);
|
||||||
|
hitting++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
total += 27;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (total == 0) {
|
||||||
|
to.setCustomNameVisible(false);
|
||||||
|
} else {
|
||||||
|
int remainder = hitting % 27;
|
||||||
|
int whole = hitting / 27;
|
||||||
|
to.setCustomNameVisible(true);
|
||||||
|
to.setCustomName("§e" + whole + " " + remainder + "/27");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -23,8 +23,8 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.config.BauServer;
|
import de.steamwar.bausystem.config.BauServer;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
|
import de.steamwar.bausystem.region.flags.ColorMode;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
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.RegionExtensionType;
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
import de.steamwar.bausystem.region.utils.RegionType;
|
||||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||||
@ -34,8 +34,6 @@ import de.steamwar.linkage.Linked;
|
|||||||
import de.steamwar.linkage.LinkedInstance;
|
import de.steamwar.linkage.LinkedInstance;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class ColorCommand extends SWCommand {
|
public class ColorCommand extends SWCommand {
|
||||||
|
|
||||||
@ -47,29 +45,31 @@ public class ColorCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "REGION_COLOR_HELP_COLOR")
|
@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);
|
genericColorSet(p, color, ColorizationType.LOCAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "REGION_COLOR_HELP_COLOR_TYPE")
|
@Register(description = "REGION_COLOR_HELP_COLOR_TYPE")
|
||||||
public void genericColorSet(@Validator Player p, ColorMode color, ColorizationType colorizationType) {
|
public void genericColorSet(@Validator Player p, ColorMode color, ColorizationType colorizationType) {
|
||||||
if (colorizationType == ColorizationType.GLOBAL) {
|
if (colorizationType == ColorizationType.GLOBAL) {
|
||||||
Region.setGlobal(Flag.COLOR, color);
|
Region.getRegions().forEach(region -> {
|
||||||
|
region.getFlags().set(Flag.COLOR, color);
|
||||||
|
});
|
||||||
BauSystem.MESSAGE.send("REGION_COLOR_GLOBAL", p, BauSystem.MESSAGE.parse(color.getChatValue(), p));
|
BauSystem.MESSAGE.send("REGION_COLOR_GLOBAL", p, BauSystem.MESSAGE.parse(color.getChatValue(), p));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
if (region.isGlobal()) {
|
if (!region.getFlags().has(Flag.COLOR).isWritable()) {
|
||||||
BauSystem.MESSAGE.send("REGION_COLOR_NO_REGION", p);
|
BauSystem.MESSAGE.send("REGION_COLOR_NO_REGION", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
region.set(Flag.COLOR, color);
|
region.getFlags().set(Flag.COLOR, color);
|
||||||
try {
|
try {
|
||||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL)))
|
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile()))
|
||||||
.ignoreAir(true)
|
.ignoreAir(true)
|
||||||
.onlyColors(true)
|
.onlyColors(true)
|
||||||
.color(color.getColor());
|
.color(color);
|
||||||
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
|
region.getArea().reset(pasteBuilder, false);
|
||||||
RegionUtils.message(region, "REGION_REGION_COLORED");
|
RegionUtils.message(region, "REGION_REGION_COLORED");
|
||||||
RegionUtils.message(region, "REGION_REGION_COLORED_FAILED");
|
RegionUtils.message(region, "REGION_REGION_COLORED_FAILED");
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
@ -78,7 +78,7 @@ public class ColorCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void genericColorSet(Player p, ColorizationType colorizationType, ColorMode color) {
|
public void genericColorSet(@Validator Player p, ColorizationType colorizationType, ColorMode color) {
|
||||||
genericColorSet(p, color, colorizationType);
|
genericColorSet(p, color, colorizationType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,13 +19,11 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.region;
|
package de.steamwar.bausystem.features.region;
|
||||||
|
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
|
import de.steamwar.bausystem.region.flags.FireMode;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.FireMode;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -55,14 +53,12 @@ public class FireCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean toggle(Region region) {
|
private boolean toggle(Region region) {
|
||||||
switch (region.getPlain(Flag.FIRE, FireMode.class)) {
|
if (region.getFlags().get(Flag.FIRE).isWithDefault(FireMode.ALLOW)) {
|
||||||
case ALLOW:
|
region.getFlags().set(Flag.FIRE, FireMode.DENY);
|
||||||
region.set(Flag.FIRE, FireMode.DENY);
|
return true;
|
||||||
return true;
|
} else {
|
||||||
default:
|
region.getFlags().set(Flag.FIRE, FireMode.ALLOW);
|
||||||
case DENY:
|
return false;
|
||||||
region.set(Flag.FIRE, FireMode.ALLOW);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,8 +2,8 @@ package de.steamwar.bausystem.features.region;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
import de.steamwar.bausystem.region.flags.FireMode;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.FireMode;
|
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -17,12 +17,12 @@ public class FireListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFireDamage(BlockBurnEvent e) {
|
public void onFireDamage(BlockBurnEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).getPlain(Flag.FIRE, FireMode.class) == FireMode.DENY) e.setCancelled(true);
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FIRE).isWithDefault(FireMode.DENY)) e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFireSpread(BlockSpreadEvent e) {
|
public void onFireSpread(BlockSpreadEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).getPlain(Flag.FIRE, FireMode.class) == FireMode.DENY) e.setCancelled(true);
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FIRE).isWithDefault(FireMode.DENY)) e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -37,7 +37,7 @@ public class FireListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
if (region.get(Flag.FIRE) == Flag.FIRE.getDefaultValue()) return null;
|
if (region.getFlags().get(Flag.FIRE).isWithDefault(FireMode.DENY)) return null;
|
||||||
return "§e" + BauSystem.MESSAGE.parse(Flag.FIRE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.FIRE).getChatValue(), p);
|
return "§e" + BauSystem.MESSAGE.parse(Flag.FIRE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.FIRE).getWithDefault().getChatValue(), p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,13 +19,11 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.region;
|
package de.steamwar.bausystem.features.region;
|
||||||
|
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode;
|
import de.steamwar.bausystem.region.flags.FreezeMode;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -55,14 +53,12 @@ public class FreezeCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean toggle(Region region) {
|
private boolean toggle(Region region) {
|
||||||
switch (region.getPlain(Flag.FREEZE, FreezeMode.class)) {
|
if (region.getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
case ACTIVE:
|
region.getFlags().set(Flag.FREEZE, FreezeMode.INACTIVE);
|
||||||
region.set(Flag.FREEZE, FreezeMode.INACTIVE);
|
return false;
|
||||||
return false;
|
} else {
|
||||||
default:
|
region.getFlags().set(Flag.FREEZE, FreezeMode.ACTIVE);
|
||||||
case INACTIVE:
|
return true;
|
||||||
region.set(Flag.FREEZE, FreezeMode.ACTIVE);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@ package de.steamwar.bausystem.features.region;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode;
|
import de.steamwar.bausystem.region.flags.FreezeMode;
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.core.TrickyTrialsWrapper;
|
import de.steamwar.core.TrickyTrialsWrapper;
|
||||||
@ -11,8 +11,9 @@ import de.steamwar.linkage.Linked;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
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.block.data.type.Switch;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -28,9 +29,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntitySpawn(EntitySpawnEvent e) {
|
public void onEntitySpawn(EntitySpawnEvent e) {
|
||||||
if (Region.getRegion(e.getLocation()).get(Flag.FREEZE) == FreezeMode.INACTIVE) {
|
if (Region.getRegion(e.getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
if (e.getEntityType() == TrickyTrialsWrapper.impl.getTntEntityType()) {
|
if (e.getEntityType() == TrickyTrialsWrapper.impl.getTntEntityType()) {
|
||||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||||
@ -42,8 +41,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockCanBuild(BlockCanBuildEvent e) {
|
public void onBlockCanBuild(BlockCanBuildEvent e) {
|
||||||
if (!e.isBuildable()) return;
|
if (!e.isBuildable()) return;
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.INACTIVE)
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return;
|
||||||
return;
|
|
||||||
if (e.getMaterial() == Material.TNT) {
|
if (e.getMaterial() == Material.TNT) {
|
||||||
e.setBuildable(false);
|
e.setBuildable(false);
|
||||||
e.getBlock().setType(Material.TNT, false);
|
e.getBlock().setType(Material.TNT, false);
|
||||||
@ -52,69 +50,87 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
|
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPhysicsEvent(BlockPhysicsEvent e) {
|
public void onPhysicsEvent(BlockPhysicsEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(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);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPistonExtend(BlockPistonExtendEvent e) {
|
public void onPistonExtend(BlockPistonExtendEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPistonRetract(BlockPistonRetractEvent e) {
|
public void onPistonRetract(BlockPistonRetractEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockGrow(BlockGrowEvent e) {
|
public void onBlockGrow(BlockGrowEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onRedstoneEvent(BlockRedstoneEvent e) {
|
public void onRedstoneEvent(BlockRedstoneEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setNewCurrent(e.getOldCurrent());
|
e.setNewCurrent(e.getOldCurrent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockDispense(BlockDispenseEvent e) {
|
public void onBlockDispense(BlockDispenseEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryMoveEvent(InventoryMoveItemEvent e) {
|
public void onInventoryMoveEvent(InventoryMoveItemEvent e) {
|
||||||
if (e.getDestination().getLocation() != null && Region.getRegion(e.getDestination().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (e.getDestination().getLocation() != null && Region.getRegion(e.getDestination().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
} else if (e.getSource().getLocation() != null && Region.getRegion(e.getSource().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
} else if (e.getSource().getLocation() != null && Region.getRegion(e.getSource().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onBlockBreak(BlockBreakEvent e) {
|
public void onBlockBreak(BlockBreakEvent e) {
|
||||||
if (Core.getVersion() < 19) return;
|
if (Core.getVersion() < 19) return;
|
||||||
if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return;
|
if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return;
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
if (e.isCancelled()) return;
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
e.getBlock().setType(Material.BARRIER, false);
|
||||||
e.getBlock().setType(Material.AIR, false);
|
e.getBlock().setType(Material.AIR, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,35 +151,35 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFluidLevelChange(FluidLevelChangeEvent e) {
|
public void onFluidLevelChange(FluidLevelChangeEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockSpread(BlockSpreadEvent e) {
|
public void onBlockSpread(BlockSpreadEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockFromTo(BlockFromToEvent e) {
|
public void onBlockFromTo(BlockFromToEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onSpongeAbsorb(SpongeAbsorbEvent e) {
|
public void onSpongeAbsorb(SpongeAbsorbEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockForm(BlockFormEvent e) {
|
public void onBlockForm(BlockFormEvent e) {
|
||||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,7 +187,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent e) {
|
public void onPlayerInteract(PlayerInteractEvent e) {
|
||||||
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
||||||
if (Region.getRegion(e.getClickedBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getClickedBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
Block block = e.getClickedBlock();
|
Block block = e.getClickedBlock();
|
||||||
if (block.getType() == Material.LEVER) {
|
if (block.getType() == Material.LEVER) {
|
||||||
Switch data = ((Switch) block.getBlockData());
|
Switch data = ((Switch) block.getBlockData());
|
||||||
@ -182,9 +198,9 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockFade(BlockFadeEvent event) {
|
public void onBlockFade(BlockFadeEvent e) {
|
||||||
if (Region.getRegion(event.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
event.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +216,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
if (region.get(Flag.FREEZE) == Flag.FREEZE.getDefaultValue()) return null;
|
if (region.getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return null;
|
||||||
return "§e" + BauSystem.MESSAGE.parse(Flag.FREEZE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.FREEZE).getChatValue(), p);
|
return "§e" + BauSystem.MESSAGE.parse(Flag.FREEZE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.FREEZE).getWithDefault().getChatValue(), p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,14 +19,11 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.region;
|
package de.steamwar.bausystem.features.region;
|
||||||
|
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.bausystem.region.GlobalRegion;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.ItemMode;
|
import de.steamwar.bausystem.region.flags.ItemMode;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.MinVersion;
|
import de.steamwar.linkage.MinVersion;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -58,14 +55,12 @@ public class ItemsCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean toggle(Region region) {
|
private boolean toggle(Region region) {
|
||||||
switch (region.getPlain(Flag.ITEMS, ItemMode.class)) {
|
if (region.getFlags().get(Flag.ITEMS).isWithDefault(ItemMode.ACTIVE)) {
|
||||||
case ACTIVE:
|
region.getFlags().set(Flag.ITEMS, ItemMode.INACTIVE);
|
||||||
region.set(Flag.ITEMS, ItemMode.INACTIVE);
|
return false;
|
||||||
return false;
|
} else {
|
||||||
default:
|
region.getFlags().set(Flag.ITEMS, ItemMode.ACTIVE);
|
||||||
case INACTIVE:
|
return true;
|
||||||
region.set(Flag.ITEMS, ItemMode.ACTIVE);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ package de.steamwar.bausystem.features.region;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.ItemMode;
|
import de.steamwar.bausystem.region.flags.ItemMode;
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.MinVersion;
|
import de.steamwar.linkage.MinVersion;
|
||||||
@ -35,13 +35,9 @@ import org.bukkit.event.entity.ItemSpawnEvent;
|
|||||||
@MinVersion(19)
|
@MinVersion(19)
|
||||||
public class ItemsListener implements Listener, ScoreboardElement {
|
public class ItemsListener implements Listener, ScoreboardElement {
|
||||||
|
|
||||||
private static ItemMode getMode(Region region) {
|
|
||||||
return region.getPlain(Flag.ITEMS, ItemMode.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onItemSpawn(ItemSpawnEvent event) {
|
public void onItemSpawn(ItemSpawnEvent event) {
|
||||||
if (getMode(Region.getRegion(event.getLocation())) == ItemMode.INACTIVE) {
|
if (Region.getRegion(event.getLocation()).getFlags().get(Flag.ITEMS).isWithDefault(ItemMode.INACTIVE)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,7 +54,7 @@ public class ItemsListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
if (region.get(Flag.ITEMS) == Flag.ITEMS.getDefaultValue()) return null;
|
if (region.getFlags().get(Flag.ITEMS).isWithDefault(ItemMode.INACTIVE)) return null;
|
||||||
return "§e" + BauSystem.MESSAGE.parse(Flag.ITEMS.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.ITEMS).getChatValue(), p);
|
return "§e" + BauSystem.MESSAGE.parse(Flag.ITEMS.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.ITEMS).getWithDefault().getChatValue(), p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ package de.steamwar.bausystem.features.region;
|
|||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.NoGravityMode;
|
import de.steamwar.bausystem.region.flags.NoGravityMode;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -53,14 +53,12 @@ public class NoGravityCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean toggle(Region region) {
|
private boolean toggle(Region region) {
|
||||||
switch (region.getPlain(Flag.NO_GRAVITY, NoGravityMode.class)) {
|
if (region.getFlags().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.ACTIVE)) {
|
||||||
case ACTIVE:
|
region.getFlags().set(Flag.NO_GRAVITY, NoGravityMode.INACTIVE);
|
||||||
region.set(Flag.NO_GRAVITY, NoGravityMode.INACTIVE);
|
return false;
|
||||||
return false;
|
} else {
|
||||||
default:
|
region.getFlags().set(Flag.NO_GRAVITY, NoGravityMode.ACTIVE);
|
||||||
case INACTIVE:
|
return true;
|
||||||
region.set(Flag.NO_GRAVITY, NoGravityMode.ACTIVE);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ package de.steamwar.bausystem.features.region;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.NoGravityMode;
|
import de.steamwar.bausystem.region.flags.NoGravityMode;
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
@ -34,14 +34,10 @@ import org.bukkit.event.entity.EntitySpawnEvent;
|
|||||||
@Linked
|
@Linked
|
||||||
public class NoGravityListener implements Listener, ScoreboardElement {
|
public class NoGravityListener implements Listener, ScoreboardElement {
|
||||||
|
|
||||||
private static NoGravityMode getMode(Region region) {
|
|
||||||
return region.getPlain(Flag.NO_GRAVITY, NoGravityMode.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntitySpawn(EntitySpawnEvent event) {
|
public void onEntitySpawn(EntitySpawnEvent event) {
|
||||||
if (event.getEntityType() == EntityType.PLAYER) return;
|
if (event.getEntityType() == EntityType.PLAYER) return;
|
||||||
if (getMode(Region.getRegion(event.getLocation())) == NoGravityMode.ACTIVE) {
|
if (Region.getRegion(event.getLocation()).getFlags().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.ACTIVE)) {
|
||||||
event.getEntity().setGravity(false);
|
event.getEntity().setGravity(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,7 +54,7 @@ public class NoGravityListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
if (region.get(Flag.NO_GRAVITY) == Flag.NO_GRAVITY.getDefaultValue()) return null;
|
if (region.getFlags().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.INACTIVE)) return null;
|
||||||
return "§e" + BauSystem.MESSAGE.parse(Flag.NO_GRAVITY.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.NO_GRAVITY).getChatValue(), p);
|
return "§e" + BauSystem.MESSAGE.parse(Flag.NO_GRAVITY.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.NO_GRAVITY).getWithDefault().getChatValue(), p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,13 +20,11 @@
|
|||||||
package de.steamwar.bausystem.features.region;
|
package de.steamwar.bausystem.features.region;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode;
|
import de.steamwar.bausystem.region.flags.ProtectMode;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -41,22 +39,18 @@ public class ProtectCommand extends SWCommand {
|
|||||||
public void genericProtectCommand(@Validator Player p) {
|
public void genericProtectCommand(@Validator Player p) {
|
||||||
Region region = regionCheck(p);
|
Region region = regionCheck(p);
|
||||||
if (region == null) return;
|
if (region == null) return;
|
||||||
switch (region.getPlain(Flag.PROTECT, ProtectMode.class)) {
|
if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.ACTIVE)) {
|
||||||
case ACTIVE:
|
region.getFlags().set(Flag.PROTECT, ProtectMode.INACTIVE);
|
||||||
region.set(Flag.PROTECT, ProtectMode.INACTIVE);
|
RegionUtils.actionBar(region, "REGION_PROTECT_DISABLE");
|
||||||
RegionUtils.actionBar(region, "REGION_PROTECT_DISABLE");
|
} else {
|
||||||
break;
|
region.getFlags().set(Flag.PROTECT, ProtectMode.ACTIVE);
|
||||||
default:
|
RegionUtils.actionBar(region, "REGION_PROTECT_ENABLE");
|
||||||
case INACTIVE:
|
|
||||||
region.set(Flag.PROTECT, ProtectMode.ACTIVE);
|
|
||||||
RegionUtils.actionBar(region, "REGION_PROTECT_ENABLE");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Region regionCheck(Player player) {
|
private Region regionCheck(Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region.getFloorLevel() == 0) {
|
if (!region.getFlags().has(Flag.PROTECT).isApplicable()) {
|
||||||
BauSystem.MESSAGE.send("REGION_PROTECT_FALSE_REGION", player);
|
BauSystem.MESSAGE.send("REGION_PROTECT_FALSE_REGION", player);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
package de.steamwar.bausystem.features.region;
|
package de.steamwar.bausystem.features.region;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.region.Point;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode;
|
import de.steamwar.bausystem.region.flags.ProtectMode;
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -21,13 +22,11 @@ public class ProtectListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
private void explode(List<Block> blockList, Location location) {
|
private void explode(List<Block> blockList, Location location) {
|
||||||
Region region = Region.getRegion(location);
|
Region region = Region.getRegion(location);
|
||||||
if (region.getFloorLevel() == 0) {
|
if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.INACTIVE)) return;
|
||||||
return;
|
Point p1 = region.getBuildArea().getMinPoint(true);
|
||||||
}
|
Point p2 = region.getTestblockArea().getMinPoint(true);
|
||||||
if (region.getPlain(Flag.PROTECT, ProtectMode.class) == ProtectMode.INACTIVE) {
|
int floorLevel = Math.min(p1.getY(), p2.getY());
|
||||||
return;
|
blockList.removeIf(block -> block.getY() < floorLevel);
|
||||||
}
|
|
||||||
blockList.removeIf(block -> block.getY() < region.getFloorLevel());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -52,8 +51,7 @@ public class ProtectListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
if (region.getFloorLevel() == 0) return null;
|
if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.INACTIVE)) return null;
|
||||||
if (region.get(Flag.PROTECT) != Flag.PROTECT.getDefaultValue()) return null;
|
return "§e" + BauSystem.MESSAGE.parse(Flag.PROTECT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.PROTECT).getWithDefault().getChatValue(), p);
|
||||||
return "§e" + BauSystem.MESSAGE.parse(Flag.PROTECT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.PROTECT).getChatValue(), p);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,30 +32,20 @@ import de.steamwar.bausystem.region.Point;
|
|||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
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.shared.Pair;
|
import de.steamwar.bausystem.shared.Pair;
|
||||||
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
||||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||||
import de.steamwar.command.PreviousArguments;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.LinkedInstance;
|
import de.steamwar.linkage.LinkedInstance;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class RegionCommand extends SWCommand {
|
public class RegionCommand extends SWCommand {
|
||||||
@ -71,7 +61,7 @@ public class RegionCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static boolean checkGlobalRegion(Region region, Player p) {
|
static boolean checkGlobalRegion(Region region, Player p) {
|
||||||
if (region.isGlobal()) {
|
if (region.getType().isGlobal()) {
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_NO_REGION", p);
|
BauSystem.MESSAGE.send("REGION_REGION_NO_REGION", p);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -83,7 +73,7 @@ public class RegionCommand extends SWCommand {
|
|||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
if (checkGlobalRegion(region, p)) return;
|
if (checkGlobalRegion(region, p)) return;
|
||||||
|
|
||||||
if (region.undo()) {
|
if (region.getHistory().undo()) {
|
||||||
RegionUtils.message(region, "REGION_REGION_UNDID");
|
RegionUtils.message(region, "REGION_REGION_UNDID");
|
||||||
} else {
|
} else {
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_NOTHING_UNDO", p);
|
BauSystem.MESSAGE.send("REGION_REGION_NOTHING_UNDO", p);
|
||||||
@ -97,7 +87,7 @@ public class RegionCommand extends SWCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (region.redo()) {
|
if (region.getHistory().redo()) {
|
||||||
RegionUtils.message(region, "REGION_REGION_REDID");
|
RegionUtils.message(region, "REGION_REGION_REDID");
|
||||||
} else {
|
} else {
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_NOTHING_REDO", p);
|
BauSystem.MESSAGE.send("REGION_REGION_NOTHING_REDO", p);
|
||||||
@ -110,10 +100,10 @@ public class RegionCommand extends SWCommand {
|
|||||||
if(checkGlobalRegion(region, p)) return;
|
if(checkGlobalRegion(region, p)) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL)))
|
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile()))
|
||||||
.ignoreAir(true)
|
.ignoreAir(true)
|
||||||
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||||
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
|
region.getArea().reset(pasteBuilder, false);
|
||||||
RegionUtils.message(region, "REGION_REGION_RESTORED");
|
RegionUtils.message(region, "REGION_REGION_RESTORED");
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p);
|
BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p);
|
||||||
@ -134,8 +124,8 @@ public class RegionCommand extends SWCommand {
|
|||||||
try {
|
try {
|
||||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node))
|
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node))
|
||||||
.ignoreAir(true)
|
.ignoreAir(true)
|
||||||
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||||
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
|
region.getArea().reset(pasteBuilder, false);
|
||||||
RegionUtils.message(region, "REGION_REGION_RESTORED");
|
RegionUtils.message(region, "REGION_REGION_RESTORED");
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p);
|
BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p);
|
||||||
@ -149,11 +139,11 @@ public class RegionCommand extends SWCommand {
|
|||||||
if (checkGlobalRegion(region, p)) {
|
if (checkGlobalRegion(region, p)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (region.getCopyPoint() == null) {
|
if (region.getBuildArea().isEmpty()) {
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p);
|
BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
p.teleport(region.getCopyPoint().toLocation(p, 0.5, 0, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND);
|
p.teleport(region.getBuildArea().getCopyPoint().toLocation(p, 0.5, 0, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND);
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_TP_COPY", p);
|
BauSystem.MESSAGE.send("REGION_REGION_TP_COPY", p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,70 +154,33 @@ public class RegionCommand extends SWCommand {
|
|||||||
if (checkGlobalRegion(region, p)) {
|
if (checkGlobalRegion(region, p)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (region.getTestBlockPoint() == null) {
|
if (region.getTestblockArea().isEmpty()) {
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p);
|
BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
p.teleport(region.getTestBlockPoint().toLocation(p, 0.5, 0, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND);
|
p.teleport(region.getTestblockArea().getCopyPoint().toLocation(p, 0.5, 0, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND);
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_TP_TEST_BLOCK", p);
|
BauSystem.MESSAGE.send("REGION_REGION_TP_TEST_BLOCK", p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "changeskin", description = "REGION_REGION_HELP_CHANGESKIN_INFO")
|
|
||||||
@Register("skin")
|
|
||||||
public void changeSkinCommand(Player p) {
|
|
||||||
Region region = Region.getRegion(p.getLocation());
|
|
||||||
if (checkGlobalRegion(region, p)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_INFO", p, region.getSkin());
|
|
||||||
String creator = region.getPrototype().getSkinMap().get(region.getSkin()).getCreator();
|
|
||||||
if (creator != null) {
|
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_INFO_CREATOR", p, creator);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = "changeskin", description = "REGION_REGION_HELP_CHANGESKIN")
|
|
||||||
@Register("skin")
|
|
||||||
public void changeSkinCommand(@Validator Player p, @Mapper("skinTypeMapper") String s) {
|
|
||||||
Region region = Region.getRegion(p.getLocation());
|
|
||||||
if (checkGlobalRegion(region, p)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!region.getPrototype().getSkinMap().containsKey(s)) {
|
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_UNKNOWN", p);
|
|
||||||
} else {
|
|
||||||
if (region.setSkin(s)) {
|
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_CHANGE", p, s);
|
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_CHANGE_UPDATE", p, BauSystem.MESSAGE.parse("REGION_REGION_CHANGESKIN_CHANGE_UPDATE_HOVER", p), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/reset"));
|
|
||||||
} else {
|
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_CHANGESKIN_INVALID", p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = "copy", description = "REGION_REGION_HELP_COPY")
|
@Register(value = "copy", description = "REGION_REGION_HELP_COPY")
|
||||||
public void copyCommand(@Validator Player p, @OptionalValue("") @StaticValue(value = {"", "-e", "-s"}, allowISE = true) int option) {
|
public void copyCommand(@Validator Player p, @OptionalValue("") @StaticValue(value = {"", "-e", "-s"}, allowISE = true) int option) {
|
||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
if (checkGlobalRegion(region, p)) {
|
if (checkGlobalRegion(region, p)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!region.hasType(RegionType.BUILD)) {
|
if (region.getBuildArea().isEmpty()) {
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_NO_BUILD", p);
|
BauSystem.MESSAGE.send("REGION_REGION_NO_BUILD", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (region.getCopyPoint() == null) {
|
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Point minPoint = region.getMinPoint(RegionType.BUILD, RegionExtensionType.NORMAL);
|
Point minPoint = region.getBuildArea().getMinPoint(false);
|
||||||
Point maxPoint = region.getMaxPoint(RegionType.BUILD, RegionExtensionType.NORMAL);
|
Point maxPoint = region.getBuildArea().getMaxPoint(false);
|
||||||
switch (option) {
|
switch (option) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
minPoint = region.getMinPoint(RegionType.BUILD, RegionExtensionType.EXTENSION);
|
minPoint = region.getBuildArea().getMinPoint(true);
|
||||||
maxPoint = region.getMaxPoint(RegionType.BUILD, RegionExtensionType.EXTENSION);
|
maxPoint = region.getBuildArea().getMaxPoint(true);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
Pair<Location, Location> selection = WorldEditUtils.getSelection(p);
|
Pair<Location, Location> selection = WorldEditUtils.getSelection(p);
|
||||||
@ -238,7 +191,7 @@ public class RegionCommand extends SWCommand {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Clipboard clipboard = FlatteningWrapper.impl.copy(minPoint, maxPoint, region.getCopyPoint());
|
Clipboard clipboard = FlatteningWrapper.impl.copy(minPoint, maxPoint, region.getBuildArea().getCopyPoint());
|
||||||
WorldEdit.getInstance()
|
WorldEdit.getInstance()
|
||||||
.getSessionManager()
|
.getSessionManager()
|
||||||
.get(BukkitAdapter.adapt(p))
|
.get(BukkitAdapter.adapt(p))
|
||||||
@ -252,14 +205,10 @@ public class RegionCommand extends SWCommand {
|
|||||||
if (checkGlobalRegion(region, p)) {
|
if (checkGlobalRegion(region, p)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!region.hasType(RegionType.BUILD)) {
|
if (region.getBuildArea().isEmpty()) {
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_NO_BUILD", p);
|
BauSystem.MESSAGE.send("REGION_REGION_NO_BUILD", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (region.getCopyPoint() == null) {
|
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ClipboardHolder clipboardHolder = WorldEdit.getInstance()
|
ClipboardHolder clipboardHolder = WorldEdit.getInstance()
|
||||||
.getSessionManager()
|
.getSessionManager()
|
||||||
@ -287,13 +236,13 @@ public class RegionCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try (EditSession e = WorldEditUtils.getEditSession(p)) {
|
try (EditSession e = WorldEditUtils.getEditSession(p)) {
|
||||||
Operations.completeBlindly(clipboardHolder.createPaste(e).ignoreAirBlocks(ignoreAir).to(toBlockVector3(region.getCopyPoint())).build());
|
Operations.completeBlindly(clipboardHolder.createPaste(e).ignoreAirBlocks(ignoreAir).to(toBlockVector3(region.getBuildArea().getCopyPoint())).build());
|
||||||
WorldEditUtils.addToPlayer(p, e);
|
WorldEditUtils.addToPlayer(p, e);
|
||||||
|
|
||||||
if (selectPasted) {
|
if (selectPasted) {
|
||||||
Clipboard clipboard = clipboardHolder.getClipboards().get(0);
|
Clipboard clipboard = clipboardHolder.getClipboards().get(0);
|
||||||
BlockVector3 minPointSelection = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()).add(toBlockVector3(region.getCopyPoint()));
|
BlockVector3 minPointSelection = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()).add(toBlockVector3(region.getBuildArea().getCopyPoint()));
|
||||||
BlockVector3 maxPointSelection = clipboard.getRegion().getMaximumPoint().subtract(clipboard.getOrigin()).add(toBlockVector3(region.getCopyPoint()));
|
BlockVector3 maxPointSelection = clipboard.getRegion().getMaximumPoint().subtract(clipboard.getOrigin()).add(toBlockVector3(region.getBuildArea().getCopyPoint()));
|
||||||
FlatteningWrapper.impl.setSelection(p, Point.fromBlockVector3(minPointSelection), Point.fromBlockVector3(maxPointSelection));
|
FlatteningWrapper.impl.setSelection(p, Point.fromBlockVector3(minPointSelection), Point.fromBlockVector3(maxPointSelection));
|
||||||
}
|
}
|
||||||
BauSystem.MESSAGE.send("REGION_REGION_PASTE_DONE", p);
|
BauSystem.MESSAGE.send("REGION_REGION_PASTE_DONE", p);
|
||||||
@ -303,25 +252,4 @@ public class RegionCommand extends SWCommand {
|
|||||||
private BlockVector3 toBlockVector3(Point point) {
|
private BlockVector3 toBlockVector3(Point point) {
|
||||||
return BlockVector3.at(point.getX(), point.getY(), point.getZ());
|
return BlockVector3.at(point.getX(), point.getY(), point.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Mapper(value = "skinTypeMapper", local = true)
|
|
||||||
private TypeMapper<String> skinTypeMapper() {
|
|
||||||
return new TypeMapper<String>() {
|
|
||||||
@Override
|
|
||||||
public List<String> tabCompletes(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
|
||||||
Player p = (Player) commandSender;
|
|
||||||
Region region = Region.getRegion(p.getLocation());
|
|
||||||
if (region.isGlobal()) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
return region.getPrototype().getSkinMap().keySet().stream().map(c -> c.replace(' ', '_')).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String map(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
|
||||||
return s.replace('_', ' ');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,8 @@ package de.steamwar.bausystem.features.region;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.tags.Tag;
|
import de.steamwar.bausystem.region.flags.ChangedMode;
|
||||||
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -180,13 +181,7 @@ public class RegionListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void tagChangedRegion(final Location location) {
|
private static void tagChangedRegion(final Location location) {
|
||||||
new BukkitRunnable() {
|
Region.getRegion(location).getFlags().set(Flag.CHANGED, ChangedMode.HAS_CHANGE);
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Region.getRegion(location).set(Tag.CHANGED);
|
|
||||||
}
|
|
||||||
}.runTaskAsynchronously(BauSystem.getInstance());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -20,12 +20,16 @@
|
|||||||
package de.steamwar.bausystem.features.region;
|
package de.steamwar.bausystem.features.region;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.region.GlobalRegion;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class RegionScoreboardElement implements ScoreboardElement {
|
public class RegionScoreboardElement implements ScoreboardElement {
|
||||||
|
|
||||||
@ -41,7 +45,10 @@ public class RegionScoreboardElement implements ScoreboardElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
if (GlobalRegion.getInstance() == region) return null;
|
if (region.getType().isGlobal()) return null;
|
||||||
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + region.getDisplayName();
|
if (!region.getGameModeConfig().isLoaded()) return null;
|
||||||
|
List<String> names = region.getGameModeConfig().getServer().getChatNames();
|
||||||
|
if (names.isEmpty()) return null;
|
||||||
|
return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + names.get(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,13 +21,10 @@ package de.steamwar.bausystem.features.region;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.config.BauServer;
|
import de.steamwar.bausystem.config.BauServer;
|
||||||
import de.steamwar.bausystem.region.GlobalRegion;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
import de.steamwar.bausystem.region.RegionSystem;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
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.PasteBuilder;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
@ -55,12 +52,11 @@ public class ResetCommand extends SWCommand {
|
|||||||
Region region = regionCheck(p);
|
Region region = regionCheck(p);
|
||||||
if (region == null) return;
|
if (region == null) return;
|
||||||
try {
|
try {
|
||||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL)))
|
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile()))
|
||||||
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||||
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
|
region.getArea().reset(pasteBuilder, false);
|
||||||
for (Flag value : Flag.getResetFlags()) {
|
region.getFlags().clear();
|
||||||
region.set(value, value.getDefaultValue());
|
region.getRegionData().clear();
|
||||||
}
|
|
||||||
RegionUtils.message(region, "REGION_RESET_RESETED");
|
RegionUtils.message(region, "REGION_RESET_RESETED");
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
BauSystem.MESSAGE.send("REGION_RESET_ERROR", p);
|
BauSystem.MESSAGE.send("REGION_RESET_ERROR", p);
|
||||||
@ -88,8 +84,8 @@ public class ResetCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node))
|
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node))
|
||||||
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||||
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL);
|
region.getArea().reset(pasteBuilder, true);
|
||||||
RegionUtils.message(region, "REGION_RESET_RESETED");
|
RegionUtils.message(region, "REGION_RESET_RESETED");
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
BauSystem.MESSAGE.send("REGION_RESET_ERROR", p);
|
BauSystem.MESSAGE.send("REGION_RESET_ERROR", p);
|
||||||
@ -99,7 +95,7 @@ public class ResetCommand extends SWCommand {
|
|||||||
|
|
||||||
private Region regionCheck(Player player) {
|
private Region regionCheck(Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region == GlobalRegion.getInstance()) {
|
if (region == RegionSystem.INSTANCE.getGlobalRegion()) {
|
||||||
BauSystem.MESSAGE.send("REGION_RESET_NO_REGION", player);
|
BauSystem.MESSAGE.send("REGION_RESET_NO_REGION", player);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,16 +20,14 @@
|
|||||||
package de.steamwar.bausystem.features.region;
|
package de.steamwar.bausystem.features.region;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.TNTMode;
|
import de.steamwar.bausystem.region.flags.TNTMode;
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
import de.steamwar.bausystem.region.flags.TestblockMode;
|
||||||
import de.steamwar.command.PreviousArguments;
|
import de.steamwar.command.PreviousArguments;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -74,9 +72,6 @@ public class TNTCommand extends SWCommand {
|
|||||||
case ONLY_TB:
|
case ONLY_TB:
|
||||||
requestedMessage = getTestblockEnableMessage();
|
requestedMessage = getTestblockEnableMessage();
|
||||||
break;
|
break;
|
||||||
case ONLY_BUILD:
|
|
||||||
requestedMessage = getBuildEnableMessage();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
tntToggle(region, tntMode, requestedMessage);
|
tntToggle(region, tntMode, requestedMessage);
|
||||||
}
|
}
|
||||||
@ -92,13 +87,12 @@ public class TNTCommand extends SWCommand {
|
|||||||
Map<String, TNTMode> tntModeMap = new HashMap<>(tntModeMapReduced);
|
Map<String, TNTMode> tntModeMap = new HashMap<>(tntModeMapReduced);
|
||||||
tntModeMap.put("testblock", TNTMode.ONLY_TB);
|
tntModeMap.put("testblock", TNTMode.ONLY_TB);
|
||||||
tntModeMap.put("tb", TNTMode.ONLY_TB);
|
tntModeMap.put("tb", TNTMode.ONLY_TB);
|
||||||
tntModeMap.put("build", TNTMode.ONLY_BUILD);
|
|
||||||
|
|
||||||
return new TypeMapper<TNTMode>() {
|
return new TypeMapper<>() {
|
||||||
@Override
|
@Override
|
||||||
public List<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
public List<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||||
Region region = Region.getRegion(((Player) sender).getLocation());
|
Region region = Region.getRegion(((Player) sender).getLocation());
|
||||||
if (region.hasType(RegionType.TESTBLOCK) && region.hasType(RegionType.BUILD)) {
|
if (region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
|
||||||
return new ArrayList<>(tntModeMap.keySet());
|
return new ArrayList<>(tntModeMap.keySet());
|
||||||
} else {
|
} else {
|
||||||
return new ArrayList<>(tntModeMapReduced.keySet());
|
return new ArrayList<>(tntModeMapReduced.keySet());
|
||||||
@ -108,7 +102,7 @@ public class TNTCommand extends SWCommand {
|
|||||||
@Override
|
@Override
|
||||||
public TNTMode map(CommandSender sender, PreviousArguments previousArguments, String s) {
|
public TNTMode map(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||||
Region region = Region.getRegion(((Player) sender).getLocation());
|
Region region = Region.getRegion(((Player) sender).getLocation());
|
||||||
if (region.hasType(RegionType.TESTBLOCK) && region.hasType(RegionType.BUILD)) {
|
if (region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
|
||||||
return tntModeMap.getOrDefault(s, null);
|
return tntModeMap.getOrDefault(s, null);
|
||||||
} else {
|
} else {
|
||||||
return tntModeMapReduced.getOrDefault(s, null);
|
return tntModeMapReduced.getOrDefault(s, null);
|
||||||
@ -134,24 +128,23 @@ public class TNTCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void tntToggle(Region region, TNTMode requestedMode, String requestedMessage) {
|
private void tntToggle(Region region, TNTMode requestedMode, String requestedMessage) {
|
||||||
if (requestedMode != null && region.hasType(RegionType.TESTBLOCK) && region.hasType(RegionType.BUILD)) {
|
if (requestedMode != null && region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
|
||||||
region.set(Flag.TNT, requestedMode);
|
region.getFlags().set(Flag.TNT, requestedMode);
|
||||||
RegionUtils.actionBar(region, requestedMessage);
|
RegionUtils.actionBar(region, requestedMessage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (region.getPlain(Flag.TNT, TNTMode.class)) {
|
switch (region.getFlags().get(Flag.TNT).getWithDefault()) {
|
||||||
case ALLOW:
|
case ALLOW:
|
||||||
case ONLY_TB:
|
case ONLY_TB:
|
||||||
case ONLY_BUILD:
|
region.getFlags().set(Flag.TNT, TNTMode.DENY);
|
||||||
region.set(Flag.TNT, TNTMode.DENY);
|
|
||||||
RegionUtils.actionBar(region, getDisableMessage());
|
RegionUtils.actionBar(region, getDisableMessage());
|
||||||
break;
|
break;
|
||||||
case DENY:
|
case DENY:
|
||||||
if (region.hasType(RegionType.TESTBLOCK) && region.hasType(RegionType.BUILD)) {
|
if (region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
|
||||||
region.set(Flag.TNT, TNTMode.ONLY_TB);
|
region.getFlags().set(Flag.TNT, TNTMode.ONLY_TB);
|
||||||
RegionUtils.actionBar(region, getTestblockEnableMessage());
|
RegionUtils.actionBar(region, getTestblockEnableMessage());
|
||||||
} else {
|
} else {
|
||||||
region.set(Flag.TNT, TNTMode.ALLOW);
|
region.getFlags().set(Flag.TNT, TNTMode.ALLOW);
|
||||||
RegionUtils.actionBar(region, getEnableMessage());
|
RegionUtils.actionBar(region, getEnableMessage());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -23,9 +23,7 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.TNTMode;
|
import de.steamwar.bausystem.region.flags.TNTMode;
|
||||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -37,7 +35,6 @@ import org.bukkit.event.block.BlockExplodeEvent;
|
|||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class TNTListener implements Listener, ScoreboardElement {
|
public class TNTListener implements Listener, ScoreboardElement {
|
||||||
@ -45,27 +42,14 @@ public class TNTListener implements Listener, ScoreboardElement {
|
|||||||
private void explode(List<Block> blockList) {
|
private void explode(List<Block> blockList) {
|
||||||
blockList.removeIf(block -> {
|
blockList.removeIf(block -> {
|
||||||
Region region = Region.getRegion(block.getLocation());
|
Region region = Region.getRegion(block.getLocation());
|
||||||
TNTMode value = region.getPlain(Flag.TNT);
|
TNTMode value = region.getFlags().get(Flag.TNT).getWithDefault();
|
||||||
if (value == TNTMode.ALLOW) {
|
if (value == TNTMode.ALLOW) {
|
||||||
return false;
|
return false;
|
||||||
} else if (value == TNTMode.ONLY_TB) {
|
} else if (value == TNTMode.ONLY_TB) {
|
||||||
if (region.hasType(RegionType.BUILD) && region.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.NORMAL)) {
|
if (region.getBuildArea().inRegion(block.getLocation(), true)) {
|
||||||
RegionUtils.actionBar(region, "REGION_TNT_BUILD_DESTROY");
|
RegionUtils.actionBar(region, "REGION_TNT_BUILD_DESTROY");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (region.hasType(RegionType.BUILD) && region.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION)) {
|
|
||||||
RegionUtils.actionBar(region, "REGION_TNT_BUILD_DESTROY");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else if (value == TNTMode.ONLY_BUILD) {
|
|
||||||
if (region.hasType(RegionType.TESTBLOCK) && region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.NORMAL)) {
|
|
||||||
RegionUtils.actionBar(region, "REGION_TNT_TB_DESTROY");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (region.hasType(RegionType.TESTBLOCK) && region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) {
|
|
||||||
RegionUtils.actionBar(region, "REGION_TNT_TB_DESTROY");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return value == TNTMode.DENY;
|
return value == TNTMode.DENY;
|
||||||
});
|
});
|
||||||
@ -93,6 +77,7 @@ public class TNTListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(Region region, Player p) {
|
public String get(Region region, Player p) {
|
||||||
return "§e" + BauSystem.MESSAGE.parse(Flag.TNT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(Flag.TNT).getChatValue(), p);
|
if (region.getFlags().get(Flag.TNT).isWithDefault(TNTMode.ALLOW)) return null;
|
||||||
|
return "§e" + BauSystem.MESSAGE.parse(Flag.TNT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.TNT).getWithDefault().getChatValue(), p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,21 +20,18 @@
|
|||||||
package de.steamwar.bausystem.features.region;
|
package de.steamwar.bausystem.features.region;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.bausystem.config.BauServer;
|
import de.steamwar.bausystem.config.BauServer;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.RegionUtils;
|
import de.steamwar.bausystem.region.RegionUtils;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
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.RegionExtensionType;
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import de.steamwar.bausystem.utils.PasteBuilder;
|
import de.steamwar.bausystem.utils.PasteBuilder;
|
||||||
import de.steamwar.command.PreviousArguments;
|
import de.steamwar.command.PreviousArguments;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.LinkedInstance;
|
import de.steamwar.linkage.LinkedInstance;
|
||||||
|
import de.steamwar.sql.BauweltMember;
|
||||||
import de.steamwar.sql.Punishment;
|
import de.steamwar.sql.Punishment;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
@ -43,10 +40,8 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -98,15 +93,44 @@ public class TestblockCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Beta Tester enabled
|
||||||
|
switch (BauServer.getInstance().getOwnerID()) {
|
||||||
|
case 245:
|
||||||
|
case 403:
|
||||||
|
case 1898:
|
||||||
|
case 3320:
|
||||||
|
case 4603:
|
||||||
|
case 5262:
|
||||||
|
case 6032:
|
||||||
|
case 11077:
|
||||||
|
case 11888:
|
||||||
|
case 12258:
|
||||||
|
case 16009:
|
||||||
|
if (node == null) {
|
||||||
|
node = region.getRegionData().getTestblockSchematic();
|
||||||
|
} else {
|
||||||
|
region.getRegionData().setTestblockSchematic(node);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
PasteBuilder.ClipboardProvider clipboardProvider;
|
||||||
|
if (node == null) {
|
||||||
|
clipboardProvider = new PasteBuilder.FileProvider(region.getTestblockArea().getResetFile());
|
||||||
|
} else {
|
||||||
|
clipboardProvider = new PasteBuilder.SchematicProvider(node);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PasteBuilder.ClipboardProvider clipboardProvider = node == null ? new PasteBuilder.FileProvider(region.getResetFile(RegionType.TESTBLOCK)) : new PasteBuilder.SchematicProvider(node);
|
|
||||||
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider)
|
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider)
|
||||||
.ignoreAir(ignoreAir)
|
.ignoreAir(ignoreAir)
|
||||||
.onlyColors(onlyColors)
|
.onlyColors(onlyColors)
|
||||||
.removeTNT(removeTNT)
|
.removeTNT(removeTNT)
|
||||||
.removeWater(removeWater)
|
.removeWater(removeWater)
|
||||||
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor());
|
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||||
region.reset(pasteBuilder, RegionType.TESTBLOCK, regionExtensionType);
|
region.getTestblockArea().reset(pasteBuilder, regionExtensionType == RegionExtensionType.EXTENSION);
|
||||||
RegionUtils.message(region, "REGION_TB_DONE");
|
RegionUtils.message(region, "REGION_TB_DONE");
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
BauSystem.MESSAGE.send("REGION_TB_ERROR", p);
|
BauSystem.MESSAGE.send("REGION_TB_ERROR", p);
|
||||||
@ -159,7 +183,7 @@ public class TestblockCommand extends SWCommand {
|
|||||||
|
|
||||||
private Region regionCheck(Player player) {
|
private Region regionCheck(Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (!region.hasType(RegionType.TESTBLOCK)) {
|
if (region.getTestblockArea().isEmpty()) {
|
||||||
BauSystem.MESSAGE.send("REGION_TB_NO_REGION", player);
|
BauSystem.MESSAGE.send("REGION_TB_NO_REGION", player);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,10 +22,9 @@ package de.steamwar.bausystem.features.region.items;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||||
import de.steamwar.bausystem.region.Color;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
import de.steamwar.bausystem.region.flags.ColorMode;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
|
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.inventory.SWListInv;
|
import de.steamwar.inventory.SWListInv;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
@ -45,7 +44,7 @@ public class ColorBauGuiItem extends BauGuiItem {
|
|||||||
super(2);
|
super(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Material mapColor(Color color) {
|
private static Material mapColor(ColorMode color) {
|
||||||
switch (color) {
|
switch (color) {
|
||||||
case RED:
|
case RED:
|
||||||
return Material.RED_CONCRETE;
|
return Material.RED_CONCRETE;
|
||||||
@ -85,17 +84,17 @@ public class ColorBauGuiItem extends BauGuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(Player player) {
|
public ItemStack getItem(Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
ColorMode mode = region.getPlain(Flag.COLOR, ColorMode.class);
|
ColorMode mode = region.getFlags().get(Flag.COLOR).orElse(ColorMode.PINK);
|
||||||
return new SWItem(mapColor(mode.getColor()), BauSystem.MESSAGE.parse("REGION_ITEM_COLOR", player, BauSystem.MESSAGE.parse(mode.getChatValue(), player))).getItemStack();
|
return new SWItem(mapColor(mode), BauSystem.MESSAGE.parse("REGION_ITEM_COLOR", player, BauSystem.MESSAGE.parse(mode.getChatValue(), player))).getItemStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean click(ClickType click, Player p) {
|
public boolean click(ClickType click, Player p) {
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
ColorMode current = Region.getRegion(p.getLocation()).getPlain(Flag.COLOR, ColorMode.class);
|
ColorMode current = Region.getRegion(p.getLocation()).getFlags().get(Flag.COLOR).orElse(ColorMode.PINK);
|
||||||
List<SWListInv.SWListEntry<ColorMode>> items = new ArrayList<>();
|
List<SWListInv.SWListEntry<ColorMode>> items = new ArrayList<>();
|
||||||
for (ColorMode value : ColorMode.values()) {
|
for (ColorMode value : ColorMode.values()) {
|
||||||
items.add(new SWListInv.SWListEntry<>(new SWItem(mapColor(value.getColor()), (byte) 0, "§f" + BauSystem.MESSAGE.parse(value.getChatValue(), p), Collections.emptyList(), value == current, clickType -> {
|
items.add(new SWListInv.SWListEntry<>(new SWItem(mapColor(value), (byte) 0, "§f" + BauSystem.MESSAGE.parse(value.getChatValue(), p), Collections.emptyList(), value == current, clickType -> {
|
||||||
}), value));
|
}), value));
|
||||||
}
|
}
|
||||||
SWListInv<ColorMode> inv = new SWListInv<>(p, BauSystem.MESSAGE.parse("REGION_ITEM_COLOR_CHOOSE", p), items, (clickType, colorMode) -> {
|
SWListInv<ColorMode> inv = new SWListInv<>(p, BauSystem.MESSAGE.parse("REGION_ITEM_COLOR_CHOOSE", p), items, (clickType, colorMode) -> {
|
||||||
|
|||||||
@ -23,8 +23,8 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
import de.steamwar.bausystem.region.flags.FireMode;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.FireMode;
|
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -42,7 +42,10 @@ public class FireBauGuiItem extends BauGuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(Player player) {
|
public ItemStack getItem(Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region.getPlain(Flag.FIRE, FireMode.class) == FireMode.ALLOW) {
|
if (!region.getFlags().has(Flag.FIRE).isApplicable()) {
|
||||||
|
return new SWItem(Material.BARRIER, "").getItemStack();
|
||||||
|
}
|
||||||
|
if (region.getFlags().get(Flag.FIRE).isWithDefault(FireMode.ALLOW)) {
|
||||||
return new SWItem(Material.FIRE_CHARGE, BauSystem.MESSAGE.parse("REGION_ITEM_FIRE_ALLOW", player)).getItemStack();
|
return new SWItem(Material.FIRE_CHARGE, BauSystem.MESSAGE.parse("REGION_ITEM_FIRE_ALLOW", player)).getItemStack();
|
||||||
} else {
|
} else {
|
||||||
return new SWItem(Material.FIREWORK_STAR, BauSystem.MESSAGE.parse("REGION_ITEM_FIRE_DISALLOW", player)).getItemStack();
|
return new SWItem(Material.FIREWORK_STAR, BauSystem.MESSAGE.parse("REGION_ITEM_FIRE_DISALLOW", player)).getItemStack();
|
||||||
|
|||||||
@ -24,7 +24,7 @@ import de.steamwar.bausystem.Permission;
|
|||||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode;
|
import de.steamwar.bausystem.region.flags.FreezeMode;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -42,7 +42,10 @@ public class FreezeBauGuiItem extends BauGuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(Player player) {
|
public ItemStack getItem(Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region.getPlain(Flag.FREEZE, FreezeMode.class) == FreezeMode.ACTIVE) {
|
if (!region.getFlags().has(Flag.FREEZE).isApplicable()) {
|
||||||
|
return new SWItem(Material.BARRIER, "").getItemStack();
|
||||||
|
}
|
||||||
|
if (region.getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
|
||||||
return new SWItem(Material.GUNPOWDER, BauSystem.MESSAGE.parse("REGION_ITEM_FREEZE_ALLOW", player)).getItemStack();
|
return new SWItem(Material.GUNPOWDER, BauSystem.MESSAGE.parse("REGION_ITEM_FREEZE_ALLOW", player)).getItemStack();
|
||||||
} else {
|
} else {
|
||||||
return new SWItem(Material.REDSTONE, BauSystem.MESSAGE.parse("REGION_ITEM_FREEZE_DISALLOW", player)).getItemStack();
|
return new SWItem(Material.REDSTONE, BauSystem.MESSAGE.parse("REGION_ITEM_FREEZE_DISALLOW", player)).getItemStack();
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import de.steamwar.bausystem.SWUtils;
|
|||||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode;
|
import de.steamwar.bausystem.region.flags.ProtectMode;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -43,7 +43,10 @@ public class ProtectBauGuiItem extends BauGuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(Player player) {
|
public ItemStack getItem(Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region.getPlain(Flag.PROTECT, ProtectMode.class) == ProtectMode.ACTIVE) {
|
if (!region.getFlags().has(Flag.PROTECT).isApplicable()) {
|
||||||
|
return new SWItem(Material.BARRIER, "").getItemStack();
|
||||||
|
}
|
||||||
|
if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.ACTIVE)) {
|
||||||
return SWUtils.setCustomModelData(new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_ALLOW", player)), 1).getItemStack();
|
return SWUtils.setCustomModelData(new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_ALLOW", player)), 1).getItemStack();
|
||||||
} else {
|
} else {
|
||||||
return SWUtils.setCustomModelData(new SWItem(Material.STONE, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_DISALLOW", player)), 1).getItemStack();
|
return SWUtils.setCustomModelData(new SWItem(Material.STONE, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_DISALLOW", player)), 1).getItemStack();
|
||||||
|
|||||||
@ -24,8 +24,7 @@ import de.steamwar.bausystem.Permission;
|
|||||||
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.TNTMode;
|
import de.steamwar.bausystem.region.flags.TNTMode;
|
||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
|
||||||
import de.steamwar.inventory.SWInventory;
|
import de.steamwar.inventory.SWInventory;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
@ -43,13 +42,11 @@ public class TntBauGuiItem extends BauGuiItem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(Player player) {
|
public ItemStack getItem(Player player) {
|
||||||
switch (Region.getRegion(player.getLocation()).getPlain(Flag.TNT, TNTMode.class)) {
|
switch (Region.getRegion(player.getLocation()).getFlags().get(Flag.TNT).getWithDefault()) {
|
||||||
case DENY:
|
case DENY:
|
||||||
return new SWItem(Material.MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_OFF", player)).getItemStack();
|
return new SWItem(Material.MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_OFF", player)).getItemStack();
|
||||||
case ONLY_TB:
|
case ONLY_TB:
|
||||||
return new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_ONLY_TB", player)).getItemStack();
|
return new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_ONLY_TB", player)).getItemStack();
|
||||||
case ONLY_BUILD:
|
|
||||||
return new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_ONLY_BUILD", player)).getItemStack();
|
|
||||||
default:
|
default:
|
||||||
return new SWItem(Material.TNT, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_ON", player)).getItemStack();
|
return new SWItem(Material.TNT, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_ON", player)).getItemStack();
|
||||||
}
|
}
|
||||||
@ -58,12 +55,12 @@ public class TntBauGuiItem extends BauGuiItem {
|
|||||||
@Override
|
@Override
|
||||||
public boolean click(ClickType click, Player p) {
|
public boolean click(ClickType click, Player p) {
|
||||||
if (click == ClickType.LEFT) {
|
if (click == ClickType.LEFT) {
|
||||||
switch (Region.getRegion(p.getLocation()).getPlain(Flag.TNT, TNTMode.class)) {
|
switch (Region.getRegion(p.getLocation()).getFlags().get(Flag.TNT).getWithDefault()) {
|
||||||
case DENY:
|
case DENY:
|
||||||
updateTntMode(TNTMode.ALLOW, p);
|
updateTntMode(TNTMode.ALLOW, p);
|
||||||
break;
|
break;
|
||||||
case ALLOW:
|
case ALLOW:
|
||||||
if (Region.getRegion(p.getLocation()).hasType(RegionType.BUILD) && Region.getRegion(p.getLocation()).hasType(RegionType.TESTBLOCK)) {
|
if (!Region.getRegion(p.getLocation()).getBuildArea().isEmpty() && !Region.getRegion(p.getLocation()).getTestblockArea().isEmpty()) {
|
||||||
updateTntMode(TNTMode.ONLY_TB, p);
|
updateTntMode(TNTMode.ONLY_TB, p);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -77,15 +74,11 @@ public class TntBauGuiItem extends BauGuiItem {
|
|||||||
updateTntMode(TNTMode.ALLOW, p);
|
updateTntMode(TNTMode.ALLOW, p);
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
}));
|
}));
|
||||||
if (Region.getRegion(p.getLocation()).hasType(RegionType.BUILD) && Region.getRegion(p.getLocation()).hasType(RegionType.TESTBLOCK)) {
|
if (!Region.getRegion(p.getLocation()).getBuildArea().isEmpty() && !Region.getRegion(p.getLocation()).getTestblockArea().isEmpty()) {
|
||||||
selector.setItem(3, new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_SELECTOR_ONLY_TB", p), clickType -> {
|
selector.setItem(3, new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_SELECTOR_ONLY_TB", p), clickType -> {
|
||||||
updateTntMode(TNTMode.ONLY_TB, p);
|
updateTntMode(TNTMode.ONLY_TB, p);
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
}));
|
}));
|
||||||
selector.setItem(5, new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_SELECTOR_ONLY_BUILD", p), clickType -> {
|
|
||||||
updateTntMode(TNTMode.ONLY_BUILD, p);
|
|
||||||
p.closeInventory();
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
selector.setItem(7, new SWItem(Material.MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_SELECTOR_OFF", p), clickType -> {
|
selector.setItem(7, new SWItem(Material.MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_SELECTOR_OFF", p), clickType -> {
|
||||||
updateTntMode(TNTMode.DENY, p);
|
updateTntMode(TNTMode.DENY, p);
|
||||||
@ -101,9 +94,6 @@ public class TntBauGuiItem extends BauGuiItem {
|
|||||||
case ONLY_TB:
|
case ONLY_TB:
|
||||||
p.performCommand("tnt tb");
|
p.performCommand("tnt tb");
|
||||||
break;
|
break;
|
||||||
case ONLY_BUILD:
|
|
||||||
p.performCommand("tnt build");
|
|
||||||
break;
|
|
||||||
case ALLOW:
|
case ALLOW:
|
||||||
p.performCommand("tnt on");
|
p.performCommand("tnt on");
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -22,7 +22,6 @@ package de.steamwar.bausystem.features.script;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.SWUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.features.script.lua.SteamWarPlatform;
|
import de.steamwar.bausystem.features.script.lua.SteamWarPlatform;
|
||||||
import de.steamwar.bausystem.utils.ItemUtils;
|
|
||||||
import de.steamwar.inventory.SWAnvilInv;
|
import de.steamwar.inventory.SWAnvilInv;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.inventory.SWListInv;
|
import de.steamwar.inventory.SWListInv;
|
||||||
|
|||||||
@ -28,7 +28,6 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.luaj.vm2.LuaValue;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|||||||
@ -153,7 +153,7 @@ public class EventListener implements Listener {
|
|||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
if(!Permission.BUILD.hasPermission(player)) continue;
|
if(!Permission.BUILD.hasPermission(player)) continue;
|
||||||
if (tntRegion.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) {
|
if (tntRegion.getArea().inRegion(player.getLocation(), false)) {
|
||||||
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTSpawn, LuaValue.NIL, event);
|
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTSpawn, LuaValue.NIL, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,11 +171,11 @@ public class EventListener implements Listener {
|
|||||||
table.set("y", event.getLocation().getY());
|
table.set("y", event.getLocation().getY());
|
||||||
table.set("z", event.getLocation().getZ());
|
table.set("z", event.getLocation().getZ());
|
||||||
|
|
||||||
boolean inBuild = event.blockList().stream().anyMatch(block -> tntRegion.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION));
|
boolean inBuild = event.blockList().stream().anyMatch(block -> tntRegion.getBuildArea().inRegion(block.getLocation(), true));
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
if(!Permission.BUILD.hasPermission(player)) continue;
|
if(!Permission.BUILD.hasPermission(player)) continue;
|
||||||
if (tntRegion.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) {
|
if (tntRegion.getArea().inRegion(player.getLocation(), false)) {
|
||||||
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplode, table, event);
|
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplode, table, event);
|
||||||
if (inBuild) {
|
if (inBuild) {
|
||||||
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplodeInBuild, table, event);
|
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplodeInBuild, table, event);
|
||||||
|
|||||||
@ -22,19 +22,14 @@ package de.steamwar.bausystem.features.script.lua;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
|
||||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.configplayer.Config;
|
|
||||||
import de.steamwar.bausystem.features.script.ScriptRunner;
|
import de.steamwar.bausystem.features.script.ScriptRunner;
|
||||||
import de.steamwar.bausystem.features.script.lua.libs.LuaLib;
|
import de.steamwar.bausystem.features.script.lua.libs.LuaLib;
|
||||||
import de.steamwar.bausystem.features.world.WorldEditListener;
|
import de.steamwar.bausystem.features.world.WorldEditListener;
|
||||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||||
import de.steamwar.inventory.SWAnvilInv;
|
import de.steamwar.inventory.SWAnvilInv;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -47,8 +42,6 @@ import org.luaj.vm2.LuaValue;
|
|||||||
import org.luaj.vm2.Varargs;
|
import org.luaj.vm2.Varargs;
|
||||||
import org.luaj.vm2.lib.*;
|
import org.luaj.vm2.lib.*;
|
||||||
|
|
||||||
import java.lang.reflect.Proxy;
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@ -166,6 +159,8 @@ public class SteamWarLuaPlugin extends TwoArgFunction {
|
|||||||
env.set("rawlen", NIL);
|
env.set("rawlen", NIL);
|
||||||
env.set("rawset", NIL);
|
env.set("rawset", NIL);
|
||||||
env.set("xpcall", NIL);
|
env.set("xpcall", NIL);
|
||||||
|
env.set("require", NIL);
|
||||||
|
env.set("package", NIL);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,19 +20,17 @@
|
|||||||
package de.steamwar.bausystem.features.script.lua.libs;
|
package de.steamwar.bausystem.features.script.lua.libs;
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.loader.Loader;
|
import de.steamwar.bausystem.features.loader.Loader;
|
||||||
import de.steamwar.bausystem.region.GlobalRegion;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.RegionSystem;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.FireMode;
|
import de.steamwar.bausystem.region.flags.*;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode;
|
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode;
|
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.TNTMode;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.luaj.vm2.LuaTable;
|
import org.luaj.vm2.LuaTable;
|
||||||
import org.luaj.vm2.LuaValue;
|
import org.luaj.vm2.LuaValue;
|
||||||
import org.luaj.vm2.lib.OneArgFunction;
|
import org.luaj.vm2.lib.OneArgFunction;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
@ -46,27 +44,29 @@ public class RegionLib implements LuaLib {
|
|||||||
private LuaTable create(Supplier<Region> region, Player player) {
|
private LuaTable create(Supplier<Region> region, Player player) {
|
||||||
LuaTable table = LuaValue.tableOf();
|
LuaTable table = LuaValue.tableOf();
|
||||||
|
|
||||||
table.set("name", getter(() -> region.get().getName()));
|
table.set("name", getter(() -> region.get().getID().toString()));
|
||||||
|
table.set("id", getter(() -> region.get().getID().toString()));
|
||||||
table.set("type", getter(() -> {
|
table.set("type", getter(() -> {
|
||||||
Region region1 = region.get();
|
Region rg = region.get();
|
||||||
if (region1 instanceof GlobalRegion) {
|
if (rg.getType().isGlobal()) {
|
||||||
return "global";
|
return "global";
|
||||||
} else {
|
|
||||||
return region1.getPrototype().getName();
|
|
||||||
}
|
}
|
||||||
|
List<String> chatNames = rg.getGameModeConfig().getServer().getChatNames();
|
||||||
|
if (chatNames.isEmpty()) {
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
return chatNames.get(0).toLowerCase();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
LuaValue tntLib = LuaValue.tableOf();
|
LuaValue tntLib = LuaValue.tableOf();
|
||||||
tntLib.set("mode", getter(() -> region.get().getPlain(Flag.TNT, TNTMode.class).name()));
|
tntLib.set("mode", getter(() -> region.get().getFlags().get(Flag.TNT).nameWithDefault()));
|
||||||
tntLib.set("enabled", getter(() -> region.get().getPlain(Flag.TNT, TNTMode.class) != TNTMode.DENY));
|
tntLib.set("enabled", getter(() -> region.get().getFlags().get(Flag.TNT).orElse(null) != TNTMode.DENY));
|
||||||
tntLib.set("onlyTb", getter(() -> region.get().getPlain(Flag.TNT, TNTMode.class) == TNTMode.ONLY_TB));
|
tntLib.set("onlyTb", getter(() -> region.get().getFlags().get(Flag.TNT).orElse(null) == TNTMode.ONLY_TB));
|
||||||
tntLib.set("onlyBuild", getter(() -> region.get().getPlain(Flag.TNT, TNTMode.class) == TNTMode.ONLY_BUILD));
|
|
||||||
|
|
||||||
table.set("tnt", tntLib);
|
table.set("tnt", tntLib);
|
||||||
|
|
||||||
table.set("fire", getter(() -> region.get().getPlain(Flag.FIRE, FireMode.class) == FireMode.ALLOW));
|
table.set("fire", getter(() -> region.get().getFlags().get(Flag.FIRE).orElse(null) == FireMode.ALLOW));
|
||||||
table.set("freeze", getter(() -> region.get().getPlain(Flag.FREEZE, FreezeMode.class) == FreezeMode.ACTIVE));
|
table.set("freeze", getter(() -> region.get().getFlags().get(Flag.FREEZE).orElse(null) == FreezeMode.ACTIVE));
|
||||||
table.set("protect", getter(() -> region.get().getPlain(Flag.PROTECT, ProtectMode.class) == ProtectMode.ACTIVE));
|
table.set("protect", getter(() -> region.get().getFlags().get(Flag.PROTECT).orElse(null) == ProtectMode.ACTIVE));
|
||||||
|
|
||||||
//LuaValue traceLib = LuaValue.tableOf();
|
//LuaValue traceLib = LuaValue.tableOf();
|
||||||
//traceLib.set("active", getter(() -> !region.get().isGlobal() && Recorder.INSTANCE.get(region.get()) instanceof ActiveTracer));
|
//traceLib.set("active", getter(() -> !region.get().isGlobal() && Recorder.INSTANCE.get(region.get()) instanceof ActiveTracer));
|
||||||
@ -79,16 +79,16 @@ public class RegionLib implements LuaLib {
|
|||||||
Loader loader = Loader.getLoader(player);
|
Loader loader = Loader.getLoader(player);
|
||||||
table.set("loader", getter(() -> loader == null ? "OFF" : loader.getStage().name()));
|
table.set("loader", getter(() -> loader == null ? "OFF" : loader.getStage().name()));
|
||||||
|
|
||||||
table.set("copyPoint", getter(() -> toPos(region.get().getCopyPoint())));
|
table.set("copyPoint", getter(() -> toPos(region.get().getBuildArea().getCopyPoint())));
|
||||||
table.set("minPointBuild", getter(() -> toPos(region.get().getMinPointBuild())));
|
table.set("minPointBuild", getter(() -> toPos(region.get().getBuildArea().getMinPoint(false))));
|
||||||
table.set("maxPointBuild", getter(() -> toPos(region.get().getMaxPointBuild())));
|
table.set("maxPointBuild", getter(() -> toPos(region.get().getBuildArea().getMinPoint(false))));
|
||||||
table.set("minPointBuildExtension", getter(() -> toPos(region.get().getMinPointBuildExtension())));
|
table.set("minPointBuildExtension", getter(() -> toPos(region.get().getBuildArea().getMinPoint(true))));
|
||||||
table.set("maxPointBuildExtension", getter(() -> toPos(region.get().getMaxPointBuildExtension())));
|
table.set("maxPointBuildExtension", getter(() -> toPos(region.get().getBuildArea().getMinPoint(true))));
|
||||||
table.set("testblockPoint", getter(() -> toPos(region.get().getTestBlockPoint())));
|
table.set("testblockPoint", getter(() -> toPos(region.get().getTestblockArea().getCopyPoint())));
|
||||||
table.set("minPointTestblock", getter(() -> toPos(region.get().getMinPointTestblock())));
|
table.set("minPointTestblock", getter(() -> toPos(region.get().getTestblockArea().getMinPoint(false))));
|
||||||
table.set("maxPointTestblock", getter(() -> toPos(region.get().getMaxPointTestblock())));
|
table.set("maxPointTestblock", getter(() -> toPos(region.get().getTestblockArea().getMinPoint(false))));
|
||||||
table.set("minPointTestblockExtension", getter(() -> toPos(region.get().getMinPointTestblockExtension())));
|
table.set("minPointTestblockExtension", getter(() -> toPos(region.get().getTestblockArea().getMinPoint(true))));
|
||||||
table.set("maxPointTestblockExtension", getter(() -> toPos(region.get().getMaxPointTestblockExtension())));
|
table.set("maxPointTestblockExtension", getter(() -> toPos(region.get().getTestblockArea().getMinPoint(true))));
|
||||||
|
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
@ -99,11 +99,11 @@ public class RegionLib implements LuaLib {
|
|||||||
table.set("get", new OneArgFunction() {
|
table.set("get", new OneArgFunction() {
|
||||||
@Override
|
@Override
|
||||||
public LuaValue call(LuaValue arg) {
|
public LuaValue call(LuaValue arg) {
|
||||||
return create(() -> Region.getREGION_MAP().get(arg.checkjstring()), player);
|
return create(() -> RegionSystem.INSTANCE.getRegion(UUID.fromString(arg.checkjstring())).orElse(RegionSystem.INSTANCE.getGlobalRegion()), player);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
table.set("list", getter(() -> LuaValue.listOf(Region.getREGION_MAP().values().stream().map(region -> create(() -> region, player)).toArray(LuaTable[]::new))));
|
table.set("list", getter(() -> LuaValue.listOf(RegionSystem.INSTANCE.getRegions().map(region -> create(() -> region, player)).toArray(LuaTable[]::new))));
|
||||||
|
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,9 +24,7 @@ import de.steamwar.bausystem.utils.ScoreboardElement;
|
|||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.luaj.vm2.LuaTable;
|
import org.luaj.vm2.LuaTable;
|
||||||
import org.luaj.vm2.LuaValue;
|
|
||||||
import org.luaj.vm2.Varargs;
|
import org.luaj.vm2.Varargs;
|
||||||
import org.luaj.vm2.lib.TwoArgFunction;
|
|
||||||
import org.luaj.vm2.lib.VarArgFunction;
|
import org.luaj.vm2.lib.VarArgFunction;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
|
|||||||
@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.script.lua.libs;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.features.loader.Loader;
|
|
||||||
import de.steamwar.bausystem.features.loader.LoaderRecorder;
|
import de.steamwar.bausystem.features.loader.LoaderRecorder;
|
||||||
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
|
|||||||
@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.script.lua.libs;
|
|||||||
|
|
||||||
import com.google.gson.*;
|
import com.google.gson.*;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
|
import de.steamwar.bausystem.region.RegionSystem;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.api.Disable;
|
import de.steamwar.linkage.api.Disable;
|
||||||
@ -74,7 +75,7 @@ public class StorageLib implements LuaLib, Enable, Disable {
|
|||||||
jsonObject.keySet().forEach(key -> {
|
jsonObject.keySet().forEach(key -> {
|
||||||
map.put(key, fromJson(jsonObject.get(key)));
|
map.put(key, fromJson(jsonObject.get(key)));
|
||||||
});
|
});
|
||||||
Region region = Region.getREGION_MAP().get(regionStorage.getName().substring(0, regionStorage.getName().length() - ".json".length()));
|
Region region = RegionSystem.INSTANCE.getRegion(UUID.fromString(regionStorage.getName().substring(0, regionStorage.getName().length() - ".json".length()))).orElse(null);
|
||||||
REGION_STORAGE.put(region, map);
|
REGION_STORAGE.put(region, map);
|
||||||
} catch (Exception e) {}
|
} catch (Exception e) {}
|
||||||
}
|
}
|
||||||
@ -143,7 +144,7 @@ public class StorageLib implements LuaLib, Enable, Disable {
|
|||||||
regionStorageDirectory.mkdirs();
|
regionStorageDirectory.mkdirs();
|
||||||
for (Map.Entry<Region, HashMap<String, LuaValue>> entry : REGION_STORAGE.entrySet()) {
|
for (Map.Entry<Region, HashMap<String, LuaValue>> entry : REGION_STORAGE.entrySet()) {
|
||||||
try {
|
try {
|
||||||
FileWriter fileWriter = new FileWriter(new File(regionStorageDirectory, entry.getKey().getName() + ".json"));
|
FileWriter fileWriter = new FileWriter(new File(regionStorageDirectory, entry.getKey().getID().toString() + ".json"));
|
||||||
gson.toJson(toJson(entry.getValue()), fileWriter);
|
gson.toJson(toJson(entry.getValue()), fileWriter);
|
||||||
fileWriter.close();
|
fileWriter.close();
|
||||||
} catch (IOException e) {}
|
} catch (IOException e) {}
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.bausystem.features.script.lua.libs;
|
package de.steamwar.bausystem.features.script.lua.libs;
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.tpslimit.TPSSystem;
|
import de.steamwar.bausystem.features.tpslimit.TPSSystem;
|
||||||
|
import de.steamwar.bausystem.utils.TickManager;
|
||||||
import de.steamwar.core.TPSWatcher;
|
import de.steamwar.core.TPSWatcher;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.LinkedInstance;
|
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("fiveMinute", getter(() -> TPSWatcher.getTPS(TPSWatcher.TPSType.FIVE_MINUTES)));
|
||||||
tpsLib.set("tenMinute", getter(() -> TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES)));
|
tpsLib.set("tenMinute", getter(() -> TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES)));
|
||||||
tpsLib.set("current", getter(TPSWatcher::getTPS));
|
tpsLib.set("current", getter(TPSWatcher::getTPS));
|
||||||
tpsLib.set("limit", getter(tpsSystem::getCurrentTPSLimit));
|
tpsLib.set("limit", getter(() -> (double) TickManager.impl.getTickRate()));
|
||||||
return tpsLib;
|
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) {
|
private void paste(Map<Material, BlockDataConfiguration<?>[]> stateConfiguration) {
|
||||||
for (Map.Entry<Vector, BlockData> entry : shieldData.entrySet()) {
|
for (Map.Entry<Vector, BlockData> entry : shieldData.entrySet()) {
|
||||||
|
BlockData copied = entry.getValue();
|
||||||
|
if (copied.getMaterial().isAir()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
Block block = entry.getKey().toLocation(WORLD).getBlock();
|
Block block = entry.getKey().toLocation(WORLD).getBlock();
|
||||||
if (entry.getValue().getMaterial() != block.getType()) {
|
if (entry.getValue().getMaterial() != block.getType()) {
|
||||||
block.setBlockData(entry.getValue(), false);
|
block.setBlockData(entry.getValue(), false);
|
||||||
@ -171,12 +176,11 @@ public class ShieldPrinting implements Listener {
|
|||||||
|
|
||||||
BlockDataConfiguration[] stateConfigurations = stateConfiguration.get(entry.getValue().getMaterial());
|
BlockDataConfiguration[] stateConfigurations = stateConfiguration.get(entry.getValue().getMaterial());
|
||||||
if (stateConfigurations == null) {
|
if (stateConfigurations == null) {
|
||||||
block.setBlockData(entry.getValue(), false);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockData worldOriginal = block.getBlockData();
|
BlockData worldOriginal = block.getBlockData();
|
||||||
BlockData copied = entry.getValue().clone();
|
copied = copied.clone();
|
||||||
for (BlockDataConfiguration blockDataConfiguration : stateConfigurations) {
|
for (BlockDataConfiguration blockDataConfiguration : stateConfigurations) {
|
||||||
if (blockDataConfiguration == null) continue;
|
if (blockDataConfiguration == null) continue;
|
||||||
blockDataConfiguration.apply(copied, worldOriginal);
|
blockDataConfiguration.apply(copied, worldOriginal);
|
||||||
|
|||||||
@ -54,7 +54,7 @@ public class ShieldPrintingCommand extends SWCommand implements Listener {
|
|||||||
@Register
|
@Register
|
||||||
public void genericCommand(@Validator Player player, ShieldPrintingState shieldPrintingState) {
|
public void genericCommand(@Validator Player player, ShieldPrintingState shieldPrintingState) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region.isGlobal()) {
|
if (region.getType().isGlobal()) {
|
||||||
BauSystem.MESSAGE.send("SHIELD_PRINTING_NO_REGION", player);
|
BauSystem.MESSAGE.send("SHIELD_PRINTING_NO_REGION", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -90,7 +90,7 @@ public class ShieldPrintingCommand extends SWCommand implements Listener {
|
|||||||
@Register("stop")
|
@Register("stop")
|
||||||
public void stopCommand(@Validator Player player) {
|
public void stopCommand(@Validator Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region.isGlobal()) {
|
if (region.getType().isGlobal()) {
|
||||||
BauSystem.MESSAGE.send("SHIELD_PRINTING_NO_REGION", player);
|
BauSystem.MESSAGE.send("SHIELD_PRINTING_NO_REGION", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ public class ShieldPrintingCommand extends SWCommand implements Listener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region.isGlobal()) {
|
if (region.getType().isGlobal()) {
|
||||||
messageSender.send("SHIELD_PRINTING_NO_REGION", player);
|
messageSender.send("SHIELD_PRINTING_NO_REGION", player);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.features.shieldprinting.BlockDataConfiguration;
|
import de.steamwar.bausystem.features.shieldprinting.BlockDataConfiguration;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.data.BlockData;
|
|
||||||
import org.bukkit.block.data.type.Piston;
|
import org.bukkit.block.data.type.Piston;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|||||||
@ -76,7 +76,7 @@ public class SimulatorCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register(value = "start", description = "SIMULATOR_START_HELP")
|
@Register(value = "start", description = "SIMULATOR_START_HELP")
|
||||||
public void start(@Validator Player p, @ErrorMessage("SIMULATOR_NOT_EXISTS") Simulator simulator) {
|
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")
|
@Register(value = "rename", description = "SIMULATOR_RENAME_HELP")
|
||||||
|
|||||||
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.simulator;
|
package de.steamwar.bausystem.features.simulator;
|
||||||
|
|
||||||
import de.steamwar.Reflection;
|
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
|
import de.steamwar.Reflection;
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.SWUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
@ -71,14 +71,14 @@ import java.util.stream.Collectors;
|
|||||||
@MinVersion(19)
|
@MinVersion(19)
|
||||||
public class SimulatorCursor implements Listener {
|
public class SimulatorCursor implements Listener {
|
||||||
|
|
||||||
private final World WORLD = Bukkit.getWorlds().get(0);
|
private static final World WORLD = Bukkit.getWorlds().get(0);
|
||||||
private Class<?> position = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Pos");
|
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<?> look = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Rot");
|
||||||
private Class<?> positionLook = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$PosRot");
|
private Class<?> positionLook = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$PosRot");
|
||||||
|
|
||||||
private Map<Player, CursorType> cursorType = Collections.synchronizedMap(new HashMap<>());
|
private static Map<Player, CursorType> cursorType = Collections.synchronizedMap(new HashMap<>());
|
||||||
private Map<Player, REntityServer> cursors = Collections.synchronizedMap(new HashMap<>());
|
private static Map<Player, REntityServer> cursors = Collections.synchronizedMap(new HashMap<>());
|
||||||
private final Set<Player> calculating = new HashSet<>();
|
private static final Set<Player> calculating = new HashSet<>();
|
||||||
|
|
||||||
public static boolean isSimulatorItem(ItemStack itemStack) {
|
public static boolean isSimulatorItem(ItemStack itemStack) {
|
||||||
return ItemUtils.isItem(itemStack, "simulator");
|
return ItemUtils.isItem(itemStack, "simulator");
|
||||||
@ -118,7 +118,7 @@ public class SimulatorCursor implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBauMemberUpdate(BauMemberUpdateEvent event) {
|
public void onBauMemberUpdate(BauMemberUpdateEvent event) {
|
||||||
event.getChanged().forEach(this::calcCursor);
|
event.getChanged().forEach(SimulatorCursor::calcCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -147,14 +147,28 @@ public class SimulatorCursor implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (LAST_SNEAKS.containsKey(player)) {
|
if (LAST_SNEAKS.containsKey(player)) {
|
||||||
cursorType.put(player, cursorType.getOrDefault(player, CursorType.TNT).switchType());
|
CursorType currentType = cursorType.getOrDefault(player, CursorType.TNT);
|
||||||
|
if (currentType == CursorType.TNT) {
|
||||||
|
cursorType.put(player, CursorType.REDSTONE_BLOCK);
|
||||||
|
} else {
|
||||||
|
cursorType.put(player, CursorType.TNT);
|
||||||
|
}
|
||||||
calcCursor(player);
|
calcCursor(player);
|
||||||
} else {
|
} else {
|
||||||
LAST_SNEAKS.put(player, System.currentTimeMillis());
|
LAST_SNEAKS.put(player, System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void calcCursor(Player player) {
|
public static CursorType getCursorType(Player player) {
|
||||||
|
return cursorType.getOrDefault(player, CursorType.TNT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setCursorType(Player player, CursorType cursorType) {
|
||||||
|
SimulatorCursor.cursorType.put(player, cursorType);
|
||||||
|
calcCursor(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void calcCursor(Player player) {
|
||||||
synchronized (calculating) {
|
synchronized (calculating) {
|
||||||
if (calculating.contains(player)) return;
|
if (calculating.contains(player)) return;
|
||||||
calculating.add(player);
|
calculating.add(player);
|
||||||
@ -168,9 +182,19 @@ public class SimulatorCursor implements Listener {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Simulator simulator = SimulatorStorage.getSimulator(player);
|
|
||||||
SimulatorWatcher.show(simulator, player);
|
|
||||||
|
|
||||||
|
Simulator simulator = SimulatorStorage.getSimulator(player);
|
||||||
|
if (simulator != null && simulator.getStabGenerator() != null) {
|
||||||
|
removeCursor(player);
|
||||||
|
SimulatorWatcher.show(null, player);
|
||||||
|
SWUtils.sendToActionbar(player, "§cGenerating Stab");
|
||||||
|
synchronized (calculating) {
|
||||||
|
calculating.remove(player);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SimulatorWatcher.show(simulator, player);
|
||||||
List<REntity> entities = SimulatorWatcher.getEntitiesOfSimulator(simulator);
|
List<REntity> entities = SimulatorWatcher.getEntitiesOfSimulator(simulator);
|
||||||
RayTraceUtils.RRayTraceResult rayTraceResult = RayTraceUtils.traceREntity(player, player.getLocation(), entities);
|
RayTraceUtils.RRayTraceResult rayTraceResult = RayTraceUtils.traceREntity(player, player.getLocation(), entities);
|
||||||
if (rayTraceResult == null) {
|
if (rayTraceResult == null) {
|
||||||
@ -192,7 +216,7 @@ public class SimulatorCursor implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized boolean removeCursor(Player player) {
|
private static synchronized boolean removeCursor(Player player) {
|
||||||
REntityServer entityServer = cursors.get(player);
|
REntityServer entityServer = cursors.get(player);
|
||||||
boolean hadCursor = entityServer != null && !entityServer.getEntities().isEmpty();
|
boolean hadCursor = entityServer != null && !entityServer.getEntities().isEmpty();
|
||||||
if (entityServer != null) {
|
if (entityServer != null) {
|
||||||
@ -201,7 +225,7 @@ public class SimulatorCursor implements Listener {
|
|||||||
return hadCursor;
|
return hadCursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void showCursor(Player player, RayTraceUtils.RRayTraceResult rayTraceResult, boolean hasSimulatorSelected) {
|
private static synchronized void showCursor(Player player, RayTraceUtils.RRayTraceResult rayTraceResult, boolean hasSimulatorSelected) {
|
||||||
REntityServer entityServer = cursors.computeIfAbsent(player, __ -> {
|
REntityServer entityServer = cursors.computeIfAbsent(player, __ -> {
|
||||||
REntityServer rEntityServer = new REntityServer();
|
REntityServer rEntityServer = new REntityServer();
|
||||||
rEntityServer.addPlayer(player);
|
rEntityServer.addPlayer(player);
|
||||||
@ -321,25 +345,16 @@ public class SimulatorCursor implements Listener {
|
|||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum CursorType {
|
public enum CursorType {
|
||||||
TNT(Material.TNT, SimulatorCursor::getPosFree, "TNT", vector -> new TNTElement(vector).add(new TNTPhase())),
|
TNT(Material.TNT, Material.GUNPOWDER, 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())),
|
REDSTONE_BLOCK(Material.REDSTONE_BLOCK, Material.REDSTONE, SimulatorCursor::getPosBlockAligned, "Redstone Block", vector -> new RedstoneElement(vector).add(new RedstonePhase())),
|
||||||
OBSERVER(Material.OBSERVER, SimulatorCursor::getPosBlockAligned, "Observer", vector -> new ObserverElement(vector).add(new ObserverPhase())),
|
OBSERVER(Material.OBSERVER, Material.QUARTZ, SimulatorCursor::getPosBlockAligned, "Observer", vector -> new ObserverElement(vector).add(new ObserverPhase())),
|
||||||
;
|
;
|
||||||
|
|
||||||
private Material material;
|
public final Material material;
|
||||||
private BiFunction<Player, RayTraceUtils.RRayTraceResult, Vector> position;
|
public final Material nonSelectedMaterial;
|
||||||
private String name;
|
public final BiFunction<Player, RayTraceUtils.RRayTraceResult, Vector> position;
|
||||||
private Function<Vector, SimulatorElement<?>> elementFunction;
|
public final String name;
|
||||||
|
public final Function<Vector, SimulatorElement<?>> elementFunction;
|
||||||
public CursorType switchType() {
|
|
||||||
if (this == TNT) {
|
|
||||||
return REDSTONE_BLOCK;
|
|
||||||
}
|
|
||||||
if (this == REDSTONE_BLOCK) {
|
|
||||||
return OBSERVER;
|
|
||||||
}
|
|
||||||
return TNT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -357,7 +372,7 @@ public class SimulatorCursor implements Listener {
|
|||||||
if (simulator == null) {
|
if (simulator == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SimulatorExecutor.run(simulator);
|
SimulatorExecutor.run(event.getPlayer(), simulator, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.bausystem.features.simulator.data;
|
package de.steamwar.bausystem.features.simulator.data;
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.simulator.execute.SimulatorAction;
|
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.InvCallback;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -30,18 +31,20 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public final class Simulator {
|
public final class Simulator {
|
||||||
|
private SimulatorStabGenerator stabGenerator = null;
|
||||||
private Material material = Material.BARREL;
|
private Material material = Material.BARREL;
|
||||||
private final String name;
|
private final String name;
|
||||||
private boolean autoTrace = false;
|
|
||||||
private final List<SimulatorGroup> groups = new ArrayList<>();
|
private final List<SimulatorGroup> groups = new ArrayList<>();
|
||||||
|
|
||||||
|
private boolean autoTrace = false;
|
||||||
|
private boolean autoTestblock = false;
|
||||||
|
|
||||||
public void move(int x, int y, int z) {
|
public void move(int x, int y, int z) {
|
||||||
groups.forEach(simulatorGroup -> {
|
groups.forEach(simulatorGroup -> {
|
||||||
simulatorGroup.move(x, y, z);
|
simulatorGroup.move(x, y, z);
|
||||||
|
|||||||
@ -33,7 +33,6 @@ import yapion.hierarchy.types.YAPIONObject;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
|||||||
@ -25,8 +25,6 @@ import lombok.Setter;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import yapion.hierarchy.types.YAPIONObject;
|
import yapion.hierarchy.types.YAPIONObject;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import de.steamwar.bausystem.features.simulator.data.SimulatorPhase;
|
|||||||
import de.steamwar.bausystem.features.simulator.execute.SimulatorAction;
|
import de.steamwar.bausystem.features.simulator.execute.SimulatorAction;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.region.flags.Flag;
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode;
|
import de.steamwar.bausystem.region.flags.FreezeMode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@ -60,11 +60,12 @@ public final class TNTPhase extends SimulatorPhase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toSimulatorActions(Vector position, BiConsumer<Integer, SimulatorAction> tickStart, BiConsumer<Integer, SimulatorAction> tickEnd) {
|
public void toSimulatorActions(Vector position, BiConsumer<Integer, SimulatorAction> tickStart, BiConsumer<Integer, SimulatorAction> tickEnd) {
|
||||||
|
if (count <= 0) return;
|
||||||
tickStart.accept(tickOffset, new SimulatorAction(order, count) {
|
tickStart.accept(tickOffset, new SimulatorAction(order, count) {
|
||||||
@Override
|
@Override
|
||||||
public void accept(World world) {
|
public void accept(World world) {
|
||||||
Location location = position.toLocation(world);
|
Location location = position.toLocation(world);
|
||||||
if (Region.getRegion(location).get(Flag.FREEZE) == FreezeMode.ACTIVE) return;
|
if (Region.getRegion(location).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) return;
|
||||||
TNTPrimed tnt = world.spawn(location, TNTPrimed.class);
|
TNTPrimed tnt = world.spawn(location, TNTPrimed.class);
|
||||||
if (!xJump) tnt.setVelocity(tnt.getVelocity().setX(0));
|
if (!xJump) tnt.setVelocity(tnt.getVelocity().setX(0));
|
||||||
if (!yJump) tnt.setVelocity(tnt.getVelocity().setY(0));
|
if (!yJump) tnt.setVelocity(tnt.getVelocity().setY(0));
|
||||||
|
|||||||
@ -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 de.steamwar.linkage.MinVersion;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
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, Map<Integer, List<SimulatorAction>>> tickStartActions = new HashMap<>();
|
||||||
private static Map<Long, List<SimulatorAction>> tickEndActions = 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;
|
if (currentlyRunning.contains(simulator)) return false;
|
||||||
currentlyRunning.add(simulator);
|
currentlyRunning.add(simulator);
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ public class SimulatorExecutor implements Listener {
|
|||||||
public void accept(World world) {
|
public void accept(World world) {
|
||||||
currentlyRunning.remove(simulator);
|
currentlyRunning.remove(simulator);
|
||||||
|
|
||||||
if (simulator.isAutoTrace()) {
|
if (simulator.isAutoTrace() && onEnd == null) {
|
||||||
simulator.getGroups()
|
simulator.getGroups()
|
||||||
.stream()
|
.stream()
|
||||||
.map(SimulatorGroup::getElements)
|
.map(SimulatorGroup::getElements)
|
||||||
@ -82,10 +83,17 @@ public class SimulatorExecutor implements Listener {
|
|||||||
TraceRecorder.instance.stopRecording(region);
|
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()
|
simulator.getGroups()
|
||||||
.stream()
|
.stream()
|
||||||
.map(SimulatorGroup::getElements)
|
.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.getTestblockArea().getMinPoint(true).toBlockVector3(), data.region.getTestblockArea().getMaxPoint(true).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,59 @@
|
|||||||
|
/*
|
||||||
|
* 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.TraceRecorder;
|
||||||
|
import de.steamwar.bausystem.region.flags.Flag;
|
||||||
|
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);
|
||||||
|
if (data.region.getFlags().has(Flag.COLOR).isReadable()) {
|
||||||
|
pasteBuilder.color(data.region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||||
|
}
|
||||||
|
data.region.getTestblockArea().reset(pasteBuilder, true);
|
||||||
|
} 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.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.getTestblockArea().inRegion(block.getLocation(), true))
|
||||||
|
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);
|
||||||
|
if (data.region.getFlags().has(Flag.COLOR).isReadable()) {
|
||||||
|
pasteBuilder.color(data.region.getFlags().get(Flag.COLOR).getWithDefault());
|
||||||
|
}
|
||||||
|
data.region.getTestblockArea().reset(pasteBuilder, true);
|
||||||
|
} 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.getTestblockArea().getMinPoint(true), data.region.getTestblockArea().getMaxPoint(true), data.region.getTestblockArea().getCopyPoint());
|
||||||
|
|
||||||
|
new StabDirection(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void bossbar(BauSystemBossbar bossbar, boolean finished) {
|
||||||
|
bossbar.setProgress(0);
|
||||||
|
bossbar.setTitle("§eSetting up Simulator");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* 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.SimulatorWatcher;
|
||||||
|
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);
|
||||||
|
SimulatorWatcher.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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* 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.gui;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.features.simulator.SimulatorCursor;
|
||||||
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
|
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 java.util.Collections;
|
||||||
|
|
||||||
|
public class SimulatorCursorSwitcherGui extends SimulatorBaseGui {
|
||||||
|
|
||||||
|
private SimulatorBaseGui back;
|
||||||
|
|
||||||
|
public SimulatorCursorSwitcherGui(Player player, Simulator simulator, SimulatorBaseGui back) {
|
||||||
|
super(player, simulator, 9);
|
||||||
|
this.back = back;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String title() {
|
||||||
|
return "Simulator Cursor";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void populate() {
|
||||||
|
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||||
|
back.open();
|
||||||
|
}).setCustomModelData(CMDs.BACK));
|
||||||
|
|
||||||
|
int slot = 2;
|
||||||
|
SimulatorCursor.CursorType currentType = SimulatorCursor.getCursorType(player);
|
||||||
|
for (SimulatorCursor.CursorType type : SimulatorCursor.CursorType.values()) {
|
||||||
|
boolean selected = type == currentType;
|
||||||
|
SWItem swItem = new SWItem(selected ? type.material : type.nonSelectedMaterial, "§e" + type.name)
|
||||||
|
.setCustomModelData(selected ? 0 : CMDs.Simulator.NEW_PHASE)
|
||||||
|
.setLore(Collections.singletonList("§eClick to select"))
|
||||||
|
.setCallback(click -> {
|
||||||
|
SimulatorCursor.setCursorType(player, type);
|
||||||
|
player.closeInventory();
|
||||||
|
});
|
||||||
|
inventory.setItem(slot, swItem);
|
||||||
|
slot += 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -25,6 +25,7 @@ import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
|||||||
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
||||||
|
import de.steamwar.data.CMDs;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -70,12 +71,12 @@ public class SimulatorGroupGui extends SimulatorPageGui<SimulatorElement<?>> {
|
|||||||
|
|
||||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||||
back.open();
|
back.open();
|
||||||
}));
|
}).setCustomModelData(CMDs.BACK));
|
||||||
|
|
||||||
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
||||||
simulatorGroup.getElements().clear();
|
simulatorGroup.getElements().clear();
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
}));
|
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||||
|
|
||||||
inventory.setItem(4, simulatorGroup.toItem(player, clickType -> {
|
inventory.setItem(4, simulatorGroup.toItem(player, clickType -> {
|
||||||
if (simulatorGroup.getMaterial() == null) return;
|
if (simulatorGroup.getMaterial() == null) return;
|
||||||
@ -85,7 +86,7 @@ public class SimulatorGroupGui extends SimulatorPageGui<SimulatorElement<?>> {
|
|||||||
|
|
||||||
inventory.setItem(48, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
inventory.setItem(48, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
||||||
new SimulatorGroupSettingsGui(player, simulator, simulatorGroup, this).open();
|
new SimulatorGroupSettingsGui(player, simulator, simulatorGroup, this).open();
|
||||||
}));
|
}).setCustomModelData(CMDs.Simulator.SETTINGS));
|
||||||
boolean disabled = simulatorGroup.getMaterial() == null ? simulatorGroup.getElements().stream().allMatch(SimulatorElement::isDisabled) : simulatorGroup.isDisabled();
|
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 -> {
|
inventory.setItem(50, new SWItem(disabled ? Material.ENDER_PEARL : Material.ENDER_EYE, simulatorGroup.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
|
||||||
if (simulatorGroup.getMaterial() == null) {
|
if (simulatorGroup.getMaterial() == null) {
|
||||||
@ -96,7 +97,7 @@ public class SimulatorGroupGui extends SimulatorPageGui<SimulatorElement<?>> {
|
|||||||
simulatorGroup.setDisabled(!disabled);
|
simulatorGroup.setDisabled(!disabled);
|
||||||
}
|
}
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
}));
|
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -25,10 +25,10 @@ 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.TNTElement;
|
||||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
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.SimulatorBaseGui;
|
||||||
|
import de.steamwar.data.CMDs;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
|||||||
// Back Arrow
|
// Back Arrow
|
||||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||||
back.open();
|
back.open();
|
||||||
}));
|
}).setCustomModelData(CMDs.BACK));
|
||||||
|
|
||||||
// Material Chooser
|
// Material Chooser
|
||||||
inventory.setItem(4, simulatorGroup.toItem(player, clickType -> {
|
inventory.setItem(4, simulatorGroup.toItem(player, clickType -> {
|
||||||
@ -69,10 +69,10 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
|||||||
|
|
||||||
// Base Tick
|
// Base Tick
|
||||||
int baseTicks = simulatorGroup.getBaseTick();
|
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);
|
simulatorGroup.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||||
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
|
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
|
||||||
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
|
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
|
||||||
if (integer < 0) return false;
|
if (integer < 0) return false;
|
||||||
@ -83,14 +83,14 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
|||||||
});
|
});
|
||||||
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
|
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
|
||||||
inventory.setItem(18, baseTick);
|
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) {
|
if (baseTicks - (clickType.isShiftClick() ? 5 : 1) < 0) {
|
||||||
simulatorGroup.changeBaseTicks(-baseTicks);
|
simulatorGroup.changeBaseTicks(-baseTicks);
|
||||||
} else {
|
} else {
|
||||||
simulatorGroup.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
|
simulatorGroup.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
|
||||||
}
|
}
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||||
|
|
||||||
boolean allTNT = simulatorGroup.getElements().stream().allMatch(TNTElement.class::isInstance);
|
boolean allTNT = simulatorGroup.getElements().stream().allMatch(TNTElement.class::isInstance);
|
||||||
|
|
||||||
@ -163,10 +163,10 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Pos X
|
//Pos X
|
||||||
inventory.setItem(15, SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
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);
|
simulatorGroup.move(clickType.isShiftClick() ? (allTNT ? 0.0625 : 5) : 1, 0, 0);
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||||
inventory.setItem(24, new SWItem(Material.PAPER, "§eX", clickType -> {
|
inventory.setItem(24, new SWItem(Material.PAPER, "§eX", clickType -> {
|
||||||
new SimulatorAnvilGui<>(player, "Relative X", "", Double::parseDouble, number -> {
|
new SimulatorAnvilGui<>(player, "Relative X", "", Double::parseDouble, number -> {
|
||||||
if(!allTNT){
|
if(!allTNT){
|
||||||
@ -177,16 +177,16 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
|||||||
return true;
|
return true;
|
||||||
}, this).setItem(Material.PAPER).open();
|
}, 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);
|
simulatorGroup.move(clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0, 0);
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||||
|
|
||||||
//Pos Y
|
//Pos Y
|
||||||
inventory.setItem(16, SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
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);
|
simulatorGroup.move(0, clickType.isShiftClick() ? (allTNT ? 0.0625 : 5) : 1, 0);
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||||
inventory.setItem(25, new SWItem(Material.PAPER, "§eY", clickType -> {
|
inventory.setItem(25, new SWItem(Material.PAPER, "§eY", clickType -> {
|
||||||
new SimulatorAnvilGui<>(player, "Relative Y", "", Double::parseDouble, number -> {
|
new SimulatorAnvilGui<>(player, "Relative Y", "", Double::parseDouble, number -> {
|
||||||
if(!allTNT){
|
if(!allTNT){
|
||||||
@ -197,16 +197,16 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
|||||||
return true;
|
return true;
|
||||||
}, this).setItem(Material.PAPER).open();
|
}, 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);
|
simulatorGroup.move(0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0);
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||||
|
|
||||||
//Pos Z
|
//Pos Z
|
||||||
inventory.setItem(17, SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
|
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);
|
simulatorGroup.move(0, 0, clickType.isShiftClick() ? (allTNT ? 0.0625 : 5) : 1);
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||||
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ", clickType -> {
|
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ", clickType -> {
|
||||||
new SimulatorAnvilGui<>(player, "Relative Z", "", Double::parseDouble, number -> {
|
new SimulatorAnvilGui<>(player, "Relative Z", "", Double::parseDouble, number -> {
|
||||||
if(!allTNT){
|
if(!allTNT){
|
||||||
@ -217,9 +217,9 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
|||||||
return true;
|
return true;
|
||||||
}, this).setItem(Material.PAPER).open();
|
}, 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);
|
simulatorGroup.move(0, 0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1);
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,11 +19,13 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.simulator.gui;
|
package de.steamwar.bausystem.features.simulator.gui;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.features.simulator.SimulatorCursor;
|
||||||
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
||||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
|
||||||
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
|
||||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
||||||
|
import de.steamwar.data.CMDs;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -48,9 +50,13 @@ public class SimulatorGui extends SimulatorPageGui<SimulatorGroup> {
|
|||||||
inventory.setItem(4, simulator.toItem(player, clickType -> {
|
inventory.setItem(4, simulator.toItem(player, clickType -> {
|
||||||
new SimulatorMaterialGui(player, simulator, simulator::getMaterial, simulator::setMaterial, this).open();
|
new SimulatorMaterialGui(player, simulator, simulator::getMaterial, simulator::setMaterial, this).open();
|
||||||
}));
|
}));
|
||||||
inventory.setItem(49, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
SimulatorCursor.CursorType cursorType = SimulatorCursor.getCursorType(player);
|
||||||
new SimulatorSettingsGui(player, simulator, this).open();
|
inventory.setItem(48, new SWItem(cursorType.material, "§7Placing §8-§e " + cursorType.name, clickType -> {
|
||||||
|
new SimulatorCursorSwitcherGui(player, simulator, this).open();
|
||||||
}));
|
}));
|
||||||
|
inventory.setItem(50, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
||||||
|
new SimulatorSettingsGui(player, simulator, this).open();
|
||||||
|
}).setCustomModelData(CMDs.Simulator.SETTINGS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
|
|||||||
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
import de.steamwar.bausystem.features.simulator.data.Simulator;
|
||||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
|
||||||
|
import de.steamwar.data.CMDs;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -53,6 +54,16 @@ public class SimulatorMaterialGui extends SimulatorPageGui<Material> {
|
|||||||
this.back = back;
|
this.back = back;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldOpen() {
|
||||||
|
if (player.getItemOnCursor().getType().isAir()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
change.accept(player.getItemOnCursor().getType());
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String baseTitle() {
|
public String baseTitle() {
|
||||||
return "Material";
|
return "Material";
|
||||||
@ -65,7 +76,7 @@ public class SimulatorMaterialGui extends SimulatorPageGui<Material> {
|
|||||||
}));
|
}));
|
||||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||||
back.open();
|
back.open();
|
||||||
}));
|
}).setCustomModelData(CMDs.BACK));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -26,6 +26,7 @@ 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.observer.ObserverPhase;
|
||||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorScrollGui;
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorScrollGui;
|
||||||
|
import de.steamwar.data.CMDs;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -82,12 +83,12 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
|
|||||||
new SimulatorGroupGui(player, simulator, newParent, simulatorGui).open();
|
new SimulatorGroupGui(player, simulator, newParent, simulatorGui).open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}).setCustomModelData(CMDs.BACK));
|
||||||
|
|
||||||
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
||||||
observer.getPhases().clear();
|
observer.getPhases().clear();
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
}));
|
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||||
|
|
||||||
// Material Chooser
|
// Material Chooser
|
||||||
inventory.setItem(4, observer.toItem(player, clickType -> {
|
inventory.setItem(4, observer.toItem(player, clickType -> {
|
||||||
@ -97,18 +98,18 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
|
|||||||
// Settings
|
// Settings
|
||||||
inventory.setItem(47, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
inventory.setItem(47, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
||||||
new SimulatorObserverSettingsGui(player, simulator, observer, this).open();
|
new SimulatorObserverSettingsGui(player, simulator, observer, this).open();
|
||||||
}));
|
}).setCustomModelData(CMDs.Simulator.SETTINGS));
|
||||||
|
|
||||||
// Enable/Disable
|
// Enable/Disable
|
||||||
inventory.setItem(48, new SWItem(observer.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, observer.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
|
inventory.setItem(48, new SWItem(observer.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, observer.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
|
||||||
observer.setDisabled(!observer.isDisabled());
|
observer.setDisabled(!observer.isDisabled());
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
}));
|
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||||
|
|
||||||
// Group chooser
|
// Group chooser
|
||||||
inventory.setItem(51, new SWItem(Material.LEAD, "§eJoin Group", clickType -> {
|
inventory.setItem(51, new SWItem(Material.LEAD, "§eJoin Group", clickType -> {
|
||||||
new SimulatorGroupChooserGui(player, simulator, observer, observer.getGroup(simulator), this).open();
|
new SimulatorGroupChooserGui(player, simulator, observer, observer.getGroup(simulator), this).open();
|
||||||
}));
|
}).setCustomModelData(CMDs.Simulator.JOIN_GROUP));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -151,15 +152,15 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
|
|||||||
new SWItem(SWItem.getDye(getter.get() < max ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
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)));
|
setter.accept(Math.min(max, getter.get() + (clickType.isShiftClick() ? 5 : 1)));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
}),
|
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED),
|
||||||
observer,
|
observer,
|
||||||
new SWItem(SWItem.getDye(getter.get() > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8:§e -5"), false, clickType -> {
|
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)));
|
setter.accept(Math.max(min, getter.get() - (clickType.isShiftClick() ? 5 : 1)));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
}),
|
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
|
||||||
new SWItem(Material.ANVIL, "§eEdit Activation", clickType -> {
|
new SWItem(Material.ANVIL, "§eEdit Activation", clickType -> {
|
||||||
new SimulatorObserverPhaseSettingsGui(player, simulator, this.observer, observerPhase, this).open();
|
new SimulatorObserverPhaseSettingsGui(player, simulator, this.observer, observerPhase, this).open();
|
||||||
}),
|
}).setCustomModelData(CMDs.Simulator.EDIT_ACTIVATION),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,12 +169,12 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
|
|||||||
return new SWItem[]{
|
return new SWItem[]{
|
||||||
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||||
addNewPhase(clickType.isShiftClick());
|
addNewPhase(clickType.isShiftClick());
|
||||||
}),
|
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED),
|
||||||
new SWItem(Material.QUARTZ, "§eObserver§8:§a New Phase", clickType -> {
|
new SWItem(Material.QUARTZ, "§eObserver§8:§a New Phase", clickType -> {
|
||||||
addNewPhase(false);
|
addNewPhase(false);
|
||||||
}),
|
}).setCustomModelData(CMDs.Simulator.NEW_PHASE),
|
||||||
new SWItem(SWItem.getDye(8), "§7", clickType -> {
|
new SWItem(SWItem.getDye(8), "§7", clickType -> {
|
||||||
}),
|
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,7 @@ import de.steamwar.bausystem.features.simulator.data.observer.ObserverPhase;
|
|||||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
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.SimulatorBaseGui;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
|
import de.steamwar.data.CMDs;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
@ -62,7 +63,7 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
|
|||||||
// Back Arrow
|
// Back Arrow
|
||||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||||
back.open();
|
back.open();
|
||||||
}));
|
}).setCustomModelData(CMDs.BACK));
|
||||||
|
|
||||||
// Material Chooser
|
// Material Chooser
|
||||||
inventory.setItem(4, observerElement.toItem(player, clickType -> {
|
inventory.setItem(4, observerElement.toItem(player, clickType -> {
|
||||||
@ -74,7 +75,7 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
|
|||||||
observerElement.getPhases().remove(observer);
|
observerElement.getPhases().remove(observer);
|
||||||
back.open();
|
back.open();
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
}));
|
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||||
|
|
||||||
int index = observerElement.getPhases().indexOf(observer);
|
int index = observerElement.getPhases().indexOf(observer);
|
||||||
int min;
|
int min;
|
||||||
@ -95,10 +96,10 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
|
|||||||
|
|
||||||
//Tick Offset
|
//Tick Offset
|
||||||
int offset = observer.getTickOffset();
|
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)));
|
observer.setTickOffset(Math.min(max, offset + (clickType.isShiftClick() ? 5 : 1)));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||||
|
|
||||||
SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> {
|
SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> {
|
||||||
new SimulatorAnvilGui<>(player, "Start at", offset + "", Integer::parseInt, integer -> {
|
new SimulatorAnvilGui<>(player, "Start at", offset + "", Integer::parseInt, integer -> {
|
||||||
@ -111,17 +112,17 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
|
|||||||
offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64)));
|
offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64)));
|
||||||
inventory.setItem(19, offsetItem);
|
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)));
|
observer.setTickOffset(Math.max(min, offset - (clickType.isShiftClick() ? 5 : 1)));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||||
|
|
||||||
//Order
|
//Order
|
||||||
int order = observer.getOrder();
|
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 -> {
|
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)));
|
observer.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||||
|
|
||||||
Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR");
|
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 -> {
|
SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eActivation Order§8:§7 " + order, clickType -> {
|
||||||
@ -136,10 +137,10 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
|
|||||||
orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30)));
|
orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30)));
|
||||||
inventory.setItem(22, orderItem);
|
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 -> {
|
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)));
|
observer.setOrder(Math.max(-SimulatorPhase.ORDER_LIMIT, order - (clickType.isShiftClick() ? 5 : 1)));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||||
|
|
||||||
// Update orientation
|
// Update orientation
|
||||||
inventory.setItem(25, new SWItem(Material.SUNFLOWER, "§7", clickType -> {
|
inventory.setItem(25, new SWItem(Material.SUNFLOWER, "§7", clickType -> {
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import de.steamwar.bausystem.features.simulator.data.Simulator;
|
|||||||
import de.steamwar.bausystem.features.simulator.data.observer.ObserverElement;
|
import de.steamwar.bausystem.features.simulator.data.observer.ObserverElement;
|
||||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
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.SimulatorBaseGui;
|
||||||
|
import de.steamwar.data.CMDs;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -56,7 +57,7 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
|
|||||||
// Back Arrow
|
// Back Arrow
|
||||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||||
back.open();
|
back.open();
|
||||||
}));
|
}).setCustomModelData(CMDs.BACK));
|
||||||
|
|
||||||
// Material Chooser
|
// Material Chooser
|
||||||
inventory.setItem(4, observer.toItem(player, clickType -> {
|
inventory.setItem(4, observer.toItem(player, clickType -> {
|
||||||
@ -65,10 +66,10 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
|
|||||||
|
|
||||||
// Base Tick
|
// Base Tick
|
||||||
int baseTicks = observer.getBaseTick();
|
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);
|
observer.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||||
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
|
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
|
||||||
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
|
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
|
||||||
if (integer < 0) return false;
|
if (integer < 0) return false;
|
||||||
@ -79,20 +80,20 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
|
|||||||
});
|
});
|
||||||
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
|
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
|
||||||
inventory.setItem(18, baseTick);
|
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) {
|
if (baseTicks - (clickType.isShiftClick() ? 5 : 1) < 0) {
|
||||||
observer.changeBaseTicks(-baseTicks);
|
observer.changeBaseTicks(-baseTicks);
|
||||||
} else {
|
} else {
|
||||||
observer.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
|
observer.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
|
||||||
}
|
}
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||||
|
|
||||||
//Pos X
|
//Pos X
|
||||||
inventory.setItem(15, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
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);
|
observer.move(clickType.isShiftClick() ? 5 : 1, 0, 0);
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||||
inventory.setItem(24, new SWItem(Material.PAPER, "§eX§8:§7 " + observer.getPosition().getBlockX(), clickType -> {
|
inventory.setItem(24, new SWItem(Material.PAPER, "§eX§8:§7 " + observer.getPosition().getBlockX(), clickType -> {
|
||||||
new SimulatorAnvilGui<>(player, "X", observer.getPosition().getBlockX() + "", Integer::parseInt, i -> {
|
new SimulatorAnvilGui<>(player, "X", observer.getPosition().getBlockX() + "", Integer::parseInt, i -> {
|
||||||
observer.getPosition().setX(i);
|
observer.getPosition().setX(i);
|
||||||
@ -100,16 +101,16 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
|
|||||||
return true;
|
return true;
|
||||||
}, this).open();
|
}, 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);
|
observer.move(clickType.isShiftClick() ? -5 : -1, 0, 0);
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||||
|
|
||||||
//Pos Y
|
//Pos Y
|
||||||
inventory.setItem(16, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
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);
|
observer.move(0, clickType.isShiftClick() ? 5 : 1, 0);
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||||
inventory.setItem(25, new SWItem(Material.PAPER, "§eY§8:§7 " + observer.getPosition().getBlockY(), clickType -> {
|
inventory.setItem(25, new SWItem(Material.PAPER, "§eY§8:§7 " + observer.getPosition().getBlockY(), clickType -> {
|
||||||
new SimulatorAnvilGui<>(player, "Y", observer.getPosition().getBlockY() + "", Integer::parseInt, i -> {
|
new SimulatorAnvilGui<>(player, "Y", observer.getPosition().getBlockY() + "", Integer::parseInt, i -> {
|
||||||
observer.getPosition().setY(i);
|
observer.getPosition().setY(i);
|
||||||
@ -117,16 +118,16 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
|
|||||||
return true;
|
return true;
|
||||||
}, this).open();
|
}, 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);
|
observer.move(0, clickType.isShiftClick() ? -5 : -1, 0);
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||||
|
|
||||||
//Pos Z
|
//Pos Z
|
||||||
inventory.setItem(17, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
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);
|
observer.move(0, 0, clickType.isShiftClick() ? 5 : 1);
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||||
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ§8:§7 " + observer.getPosition().getBlockZ(), clickType -> {
|
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ§8:§7 " + observer.getPosition().getBlockZ(), clickType -> {
|
||||||
new SimulatorAnvilGui<>(player, "Z", observer.getPosition().getBlockZ() + "", Integer::parseInt, i -> {
|
new SimulatorAnvilGui<>(player, "Z", observer.getPosition().getBlockZ() + "", Integer::parseInt, i -> {
|
||||||
observer.getPosition().setZ(i);
|
observer.getPosition().setZ(i);
|
||||||
@ -134,9 +135,9 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
|
|||||||
return true;
|
return true;
|
||||||
}, this).open();
|
}, 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);
|
observer.move(0, 0, clickType.isShiftClick() ? -5 : -1);
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,6 +26,7 @@ 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.redstone.RedstonePhase;
|
||||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorScrollGui;
|
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorScrollGui;
|
||||||
|
import de.steamwar.data.CMDs;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -88,12 +89,12 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<SimulatorRedstoneGu
|
|||||||
new SimulatorGroupGui(player, simulator, newParent, simulatorGui).open();
|
new SimulatorGroupGui(player, simulator, newParent, simulatorGui).open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}).setCustomModelData(CMDs.BACK));
|
||||||
|
|
||||||
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
|
||||||
redstone.getPhases().clear();
|
redstone.getPhases().clear();
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
}));
|
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||||
|
|
||||||
// Material Chooser
|
// Material Chooser
|
||||||
inventory.setItem(4, redstone.toItem(player, clickType -> {
|
inventory.setItem(4, redstone.toItem(player, clickType -> {
|
||||||
@ -103,18 +104,18 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<SimulatorRedstoneGu
|
|||||||
// Settings
|
// Settings
|
||||||
inventory.setItem(47, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
inventory.setItem(47, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
|
||||||
new SimulatorRedstoneSettingsGui(player, simulator, redstone, this).open();
|
new SimulatorRedstoneSettingsGui(player, simulator, redstone, this).open();
|
||||||
}));
|
}).setCustomModelData(CMDs.Simulator.SETTINGS));
|
||||||
|
|
||||||
// Enable/Disable
|
// Enable/Disable
|
||||||
inventory.setItem(48, new SWItem(redstone.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, redstone.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
|
inventory.setItem(48, new SWItem(redstone.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, redstone.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
|
||||||
redstone.setDisabled(!redstone.isDisabled());
|
redstone.setDisabled(!redstone.isDisabled());
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
}));
|
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
|
||||||
|
|
||||||
// Group chooser
|
// Group chooser
|
||||||
inventory.setItem(51, new SWItem(Material.LEAD, "§eJoin Group", clickType -> {
|
inventory.setItem(51, new SWItem(Material.LEAD, "§eJoin Group", clickType -> {
|
||||||
new SimulatorGroupChooserGui(player, simulator, redstone, redstone.getGroup(simulator), this).open();
|
new SimulatorGroupChooserGui(player, simulator, redstone, redstone.getGroup(simulator), this).open();
|
||||||
}));
|
}).setCustomModelData(CMDs.Simulator.JOIN_GROUP));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -166,15 +167,15 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<SimulatorRedstoneGu
|
|||||||
new SWItem(SWItem.getDye(getter.get() < max ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
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)));
|
setter.accept(Math.min(max, getter.get() + (clickType.isShiftClick() ? 5 : 1)));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
}),
|
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED),
|
||||||
redstone,
|
redstone,
|
||||||
new SWItem(SWItem.getDye(getter.get() > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8:§e -5"), false, clickType -> {
|
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)));
|
setter.accept(Math.max(min, getter.get() - (clickType.isShiftClick() ? 5 : 1)));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
}),
|
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
|
||||||
new SWItem(Material.ANVIL, "§eEdit Activation", clickType -> {
|
new SWItem(Material.ANVIL, "§eEdit Activation", clickType -> {
|
||||||
new SimulatorRedstonePhaseSettingsGui(player, simulator, this.redstone, redstoneSubPhase.phase, this).open();
|
new SimulatorRedstonePhaseSettingsGui(player, simulator, this.redstone, redstoneSubPhase.phase, this).open();
|
||||||
}),
|
}).setCustomModelData(CMDs.Simulator.EDIT_ACTIVATION),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,12 +184,12 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<SimulatorRedstoneGu
|
|||||||
return new SWItem[]{
|
return new SWItem[]{
|
||||||
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
|
||||||
addNewPhase(clickType.isShiftClick());
|
addNewPhase(clickType.isShiftClick());
|
||||||
}),
|
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED),
|
||||||
new SWItem(Material.REDSTONE, "§eRedstone§8:§a New Phase", clickType -> {
|
new SWItem(Material.REDSTONE, "§eRedstone§8:§a New Phase", clickType -> {
|
||||||
addNewPhase(false);
|
addNewPhase(false);
|
||||||
}),
|
}).setCustomModelData(CMDs.Simulator.NEW_PHASE),
|
||||||
new SWItem(SWItem.getDye(8), "§7", clickType -> {
|
new SWItem(SWItem.getDye(8), "§7", clickType -> {
|
||||||
}),
|
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,7 @@ import de.steamwar.bausystem.features.simulator.data.redstone.RedstonePhase;
|
|||||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
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.SimulatorBaseGui;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
|
import de.steamwar.data.CMDs;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -60,7 +61,7 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
|||||||
// Back Arrow
|
// Back Arrow
|
||||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||||
back.open();
|
back.open();
|
||||||
}));
|
}).setCustomModelData(CMDs.BACK));
|
||||||
|
|
||||||
// Material Chooser
|
// Material Chooser
|
||||||
inventory.setItem(4, redstoneElement.toItem(player, clickType -> {
|
inventory.setItem(4, redstoneElement.toItem(player, clickType -> {
|
||||||
@ -72,7 +73,7 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
|||||||
redstoneElement.getPhases().remove(redstone);
|
redstoneElement.getPhases().remove(redstone);
|
||||||
back.open();
|
back.open();
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
}));
|
}).setCustomModelData(CMDs.Simulator.DELETE));
|
||||||
|
|
||||||
int index = redstoneElement.getPhases().indexOf(redstone);
|
int index = redstoneElement.getPhases().indexOf(redstone);
|
||||||
int min;
|
int min;
|
||||||
@ -96,10 +97,10 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
|||||||
|
|
||||||
//Tick Offset
|
//Tick Offset
|
||||||
int offset = redstone.getTickOffset();
|
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)));
|
redstone.setTickOffset(Math.min(maxOffset, offset + (clickType.isShiftClick() ? 5 : 1)));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||||
|
|
||||||
SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> {
|
SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> {
|
||||||
new SimulatorAnvilGui<>(player, "Start at", offset + "", Integer::parseInt, integer -> {
|
new SimulatorAnvilGui<>(player, "Start at", offset + "", Integer::parseInt, integer -> {
|
||||||
@ -112,17 +113,17 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
|||||||
offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64)));
|
offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64)));
|
||||||
inventory.setItem(19, offsetItem);
|
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)));
|
redstone.setTickOffset(Math.max(min, offset - (clickType.isShiftClick() ? 5 : 1)));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||||
|
|
||||||
//Lifetime
|
//Lifetime
|
||||||
int lifetime = redstone.getLifetime();
|
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)));
|
redstone.setLifetime(Math.min(maxLifetime, lifetime + (clickType.isShiftClick() ? 5 : 1)));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||||
|
|
||||||
SWItem lifetimeItem = new SWItem(Material.CLOCK, "§eActivation Time§8:§7 " + lifetime, clickType -> {
|
SWItem lifetimeItem = new SWItem(Material.CLOCK, "§eActivation Time§8:§7 " + lifetime, clickType -> {
|
||||||
new SimulatorAnvilGui<>(player, "Activation Time", lifetime + "", Integer::parseInt, integer -> {
|
new SimulatorAnvilGui<>(player, "Activation Time", lifetime + "", Integer::parseInt, integer -> {
|
||||||
@ -135,17 +136,17 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
|||||||
lifetimeItem.getItemStack().setAmount(Math.max(1, Math.min(lifetime, 64)));
|
lifetimeItem.getItemStack().setAmount(Math.max(1, Math.min(lifetime, 64)));
|
||||||
inventory.setItem(20, lifetimeItem);
|
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)));
|
redstone.setLifetime(Math.max(0, lifetime - (clickType.isShiftClick() ? 5 : 1)));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||||
|
|
||||||
//Order
|
//Order
|
||||||
int order = redstone.getOrder();
|
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 -> {
|
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)));
|
redstone.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||||
|
|
||||||
Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR");
|
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 -> {
|
SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eActivation Order§8:§7 " + order, clickType -> {
|
||||||
@ -160,9 +161,9 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
|
|||||||
orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30)));
|
orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30)));
|
||||||
inventory.setItem(22, orderItem);
|
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 -> {
|
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)));
|
redstone.setOrder(Math.max(-SimulatorPhase.ORDER_LIMIT, order - (clickType.isShiftClick() ? 5 : 1)));
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import de.steamwar.bausystem.features.simulator.data.Simulator;
|
|||||||
import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement;
|
import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement;
|
||||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
|
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.SimulatorBaseGui;
|
||||||
|
import de.steamwar.data.CMDs;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -55,7 +56,7 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
|
|||||||
// Back Arrow
|
// Back Arrow
|
||||||
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
inventory.setItem(0, new SWItem(Material.ARROW, "§eBack", clickType -> {
|
||||||
back.open();
|
back.open();
|
||||||
}));
|
}).setCustomModelData(CMDs.BACK));
|
||||||
|
|
||||||
// Material Chooser
|
// Material Chooser
|
||||||
inventory.setItem(4, redstone.toItem(player, clickType -> {
|
inventory.setItem(4, redstone.toItem(player, clickType -> {
|
||||||
@ -64,10 +65,10 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
|
|||||||
|
|
||||||
// Base Tick
|
// Base Tick
|
||||||
int baseTicks = redstone.getBaseTick();
|
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);
|
redstone.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||||
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
|
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
|
||||||
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
|
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
|
||||||
if (integer < 0) return false;
|
if (integer < 0) return false;
|
||||||
@ -78,20 +79,20 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
|
|||||||
});
|
});
|
||||||
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
|
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
|
||||||
inventory.setItem(18, baseTick);
|
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) {
|
if (baseTicks - (clickType.isShiftClick() ? 5 : 1) < 0) {
|
||||||
redstone.changeBaseTicks(-baseTicks);
|
redstone.changeBaseTicks(-baseTicks);
|
||||||
} else {
|
} else {
|
||||||
redstone.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
|
redstone.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
|
||||||
}
|
}
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||||
|
|
||||||
//Pos X
|
//Pos X
|
||||||
inventory.setItem(15, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
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);
|
redstone.move(clickType.isShiftClick() ? 5 : 1, 0, 0);
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||||
inventory.setItem(24, new SWItem(Material.PAPER, "§eX§8:§7 " + redstone.getPosition().getBlockX(), clickType -> {
|
inventory.setItem(24, new SWItem(Material.PAPER, "§eX§8:§7 " + redstone.getPosition().getBlockX(), clickType -> {
|
||||||
new SimulatorAnvilGui<>(player, "X", redstone.getPosition().getBlockX() + "", Integer::parseInt, i -> {
|
new SimulatorAnvilGui<>(player, "X", redstone.getPosition().getBlockX() + "", Integer::parseInt, i -> {
|
||||||
redstone.getPosition().setX(i);
|
redstone.getPosition().setX(i);
|
||||||
@ -99,16 +100,16 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
|
|||||||
return true;
|
return true;
|
||||||
}, this).open();
|
}, 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);
|
redstone.move(clickType.isShiftClick() ? -5 : -1, 0, 0);
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||||
|
|
||||||
//Pos Y
|
//Pos Y
|
||||||
inventory.setItem(16, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
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);
|
redstone.move(0, clickType.isShiftClick() ? 5 : 1, 0);
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||||
inventory.setItem(25, new SWItem(Material.PAPER, "§eY§8:§7 " + redstone.getPosition().getBlockY(), clickType -> {
|
inventory.setItem(25, new SWItem(Material.PAPER, "§eY§8:§7 " + redstone.getPosition().getBlockY(), clickType -> {
|
||||||
new SimulatorAnvilGui<>(player, "Y", redstone.getPosition().getBlockY() + "", Integer::parseInt, i -> {
|
new SimulatorAnvilGui<>(player, "Y", redstone.getPosition().getBlockY() + "", Integer::parseInt, i -> {
|
||||||
redstone.getPosition().setY(i);
|
redstone.getPosition().setY(i);
|
||||||
@ -116,16 +117,16 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
|
|||||||
return true;
|
return true;
|
||||||
}, this).open();
|
}, 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);
|
redstone.move(0, clickType.isShiftClick() ? -5 : -1, 0);
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||||
|
|
||||||
//Pos Z
|
//Pos Z
|
||||||
inventory.setItem(17, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
|
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);
|
redstone.move(0, 0, clickType.isShiftClick() ? 5 : 1);
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
|
||||||
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ§8:§7 " + redstone.getPosition().getBlockZ(), clickType -> {
|
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ§8:§7 " + redstone.getPosition().getBlockZ(), clickType -> {
|
||||||
new SimulatorAnvilGui<>(player, "Z", redstone.getPosition().getBlockZ() + "", Integer::parseInt, i -> {
|
new SimulatorAnvilGui<>(player, "Z", redstone.getPosition().getBlockZ() + "", Integer::parseInt, i -> {
|
||||||
redstone.getPosition().setZ(i);
|
redstone.getPosition().setZ(i);
|
||||||
@ -133,9 +134,9 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
|
|||||||
return true;
|
return true;
|
||||||
}, this).open();
|
}, 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);
|
redstone.move(0, 0, clickType.isShiftClick() ? -5 : -1);
|
||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user