mirror of https://github.com/PikaMug/Quests.git
Compare commits
528 Commits
Author | SHA1 | Date |
---|---|---|
PikaMug | 5d9bab93c3 | |
PikaMug | 3f9d43c93d | |
PikaMug | c56d358153 | |
PikaMug | 7ce87b8644 | |
PikaMug | 4dacb4532f | |
PikaMug | a7e9e41d68 | |
PikaMug | 0b19116362 | |
PikaMug | 37316238e2 | |
PikaMug | abe97e558e | |
PikaMug | 15044ba9e2 | |
PikaMug | 9f26e9d053 | |
PikaMug | 181f4e0dec | |
PikaMug | 90f8f0ec27 | |
PikaMug | 1fdb1b8a80 | |
PikaMug | 3d6c0fad63 | |
PikaMug | 94fee10e96 | |
PikaMug | 74a3d093fa | |
PikaMug | d0c1f92acf | |
PikaMug | 6c4f0b2196 | |
PikaMug | a40054d420 | |
PikaMug | a6635bb79c | |
PikaMug | c31362baa7 | |
PikaMug | 63f6ea0402 | |
PikaMug | d8a7addc9b | |
PikaMug | 605e63d2a4 | |
PikaMug | c58e591e43 | |
PikaMug | 00046d1dcb | |
PikaMug | 085cb1e53f | |
PikaMug | 190e4f4b34 | |
PikaMug | 2c1a0e8551 | |
PikaMug | f908d1c353 | |
PikaMug | a4446cc3d5 | |
PikaMug | f440ea43cd | |
PikaMug | ff4dcacea8 | |
PikaMug | 9a5b5725bb | |
PikaMug | a153702387 | |
PikaMug | f619b6c091 | |
PikaMug | d75aa9b248 | |
PikaMug | 307326d1b1 | |
PikaMug | 8eae46ad07 | |
PikaMug | 0cc6d7770b | |
PikaMug | f0eb129843 | |
PikaMug | d35301d1e5 | |
PikaMug | a85c2d4b81 | |
PikaMug | 5ebeb77cd7 | |
PikaMug | 76397b6e1a | |
PikaMug | 2695d4008d | |
PikaMug | c91e2f6149 | |
PikaMug | 38d58088be | |
PikaMug | 3f2465fe6c | |
PikaMug | 3e59fc5659 | |
PikaMug | 3413895abf | |
PikaMug | 969bac022d | |
PikaMug | 82de833b60 | |
PikaMug | a587a0c1c0 | |
PikaMug | f565a6d263 | |
PikaMug | 0675b357fc | |
PikaMug | 7e42ec5ecb | |
PikaMug | 577f4d13ce | |
PikaMug | 5805b47e88 | |
PikaMug | 45a64a05ed | |
PikaMug | 5c5d4dd0b3 | |
PikaMug | 7a581532cf | |
PikaMug | 3359fd3175 | |
PikaMug | bc65715551 | |
PikaMug | dfd987dd32 | |
PikaMug | c9ae34c146 | |
PikaMug | 85c99bac5a | |
PikaMug | 8507ebcb64 | |
D3v1s0m | 24272a7243 | |
PikaMug | 46e5364b88 | |
D3v1s0m | 90a38e06ae | |
PikaMug | 2e6ab6c038 | |
PikaMug | 4a935b0346 | |
PikaMug | 521f7ab278 | |
PikaMug | 8240d0555c | |
PikaMug | 977a386366 | |
PikaMug | 6c15c41d97 | |
PikaMug | 162db479d2 | |
PikaMug | 07c1ae8610 | |
PikaMug | 10fc926395 | |
PikaMug | fa2c34d36e | |
PikaMug | 16ee58326b | |
PikaMug | 19c6f02cc8 | |
PikaMug | f5f872bd25 | |
PikaMug | 720538d0f8 | |
PikaMug | e0970db2a4 | |
PikaMug | 93e57c2573 | |
PikaMug | 45235ec59e | |
PikaMug | d08df181a7 | |
PikaMug | d76082d484 | |
PikaMug | 3eb180a36e | |
Drăghiciu Nicolae | 870eb02540 | |
PikaMug | af1469a913 | |
PikaMug | 90bf028624 | |
PikaMug | 56a75acc37 | |
PikaMug | 8d4b39c9d7 | |
PikaMug | 5b63533e7b | |
PikaMug | 5e2e122a05 | |
PikaMug | 7ae0551bf3 | |
PikaMug | 068ac6fe6d | |
PikaMug | a34978a14a | |
PikaMug | efb42f4d2c | |
PikaMug | b3bd277478 | |
PikaMug | 7f821a8b17 | |
PikaMug | b2b20144d0 | |
PikaMug | 85d0f035a6 | |
PikaMug | 3d8179f55d | |
PikaMug | 60368fddd9 | |
PikaMug | ab0879d5a3 | |
PikaMug | 7c30a0ce8e | |
PikaMug | 778c41f254 | |
PikaMug | cc916c5af4 | |
PikaMug | 85b0e0017a | |
PikaMug | 8b9385c0de | |
PikaMug | e5322074b8 | |
PikaMug | 3c8acea21a | |
PikaMug | 0ee5e9e730 | |
PikaMug | 1f5ede8f2c | |
PikaMug | 5344c4c6d7 | |
Drăghiciu Nicolae | 5f681e7e92 | |
PikaMug | a91b033d4e | |
PikaMug | ccea1acba5 | |
PikaMug | c5a753e19e | |
PikaMug | 49392e5d1c | |
PikaMug | 496e8eedce | |
PikaMug | 87e7bdbd6c | |
PikaMug | b82cf9e377 | |
PikaMug | ec24e5f0ea | |
PikaMug | e7a6456a34 | |
PikaMug | 0fe72d418b | |
PikaMug | fc2d558e5c | |
PikaMug | 9b3736be87 | |
PikaMug | 447023626e | |
PikaMug | 5c061f17a6 | |
PikaMug | df9c40785d | |
PikaMug | aa02e57735 | |
PikaMug | 656b99703b | |
PikaMug | 4a428c014f | |
PikaMug | 858c81bcd6 | |
PikaMug | dea6d561b3 | |
PikaMug | fcdff55310 | |
PikaMug | 7f2430441a | |
PikaMug | 0d106297ad | |
PikaMug | be0dce3cbe | |
PikaMug | a77771cf72 | |
PikaMug | b8aa2d0379 | |
PikaMug | 0520145baf | |
PikaMug | 0e177afdc1 | |
PikaMug | e6472bcae2 | |
PikaMug | 40b78b68ff | |
PikaMug | 64aa1387a0 | |
PikaMug | 609d8e9c4d | |
PikaMug | 12c8e1e4a8 | |
PikaMug | 3277eef7d3 | |
PikaMug | 43e9b6a7ae | |
PikaMug | e38e6006c4 | |
PikaMug | 20bbd3d6e8 | |
PikaMug | aa4d7b6d3d | |
PikaMug | 763be3bb94 | |
PikaMug | 9e4c1de8e2 | |
PikaMug | 60cefdaf1c | |
PikaMug | 5261576517 | |
PikaMug | 12e540e923 | |
PikaMug | 32913081f2 | |
PikaMug | aec6219f21 | |
PikaMug | 387913e173 | |
PikaMug | 2b2fdc69b0 | |
PikaMug | 328aba4bc3 | |
PikaMug | b32b2b6ef2 | |
PikaMug | fd40f15b8b | |
PikaMug | f14040c7fe | |
PikaMug | d9292e0222 | |
PikaMug | 11a251bbf4 | |
PikaMug | 354c72ba4a | |
PikaMug | e0bbbe7e90 | |
PikaMug | 0329e71f3c | |
PikaMug | 5604392814 | |
PikaMug | cd4818bfee | |
PikaMug | 35819b619c | |
PikaMug | 676eae4819 | |
PikaMug | 96780c0bfd | |
PikaMug | e83db9a0fe | |
PikaMug | 4c4c0dc21c | |
PikaMug | a5429d3ede | |
PikaMug | ee45d26a5a | |
PikaMug | a28e94813d | |
PikaMug | 71abe19187 | |
PikaMug | f78dccf90e | |
PikaMug | b5d7dccbad | |
PikaMug | 7bc860248d | |
PikaMug | dd227102d6 | |
PikaMug | d676f86758 | |
PikaMug | 0a0952eaa6 | |
PikaMug | ee2a3190aa | |
PikaMug | 468491e8d8 | |
PikaMug | af4c6232c6 | |
PikaMug | 19dc1dce37 | |
PikaMug | ec4dc943c5 | |
PikaMug | 3423424908 | |
PikaMug | 4b50760c2e | |
PikaMug | a9446d9168 | |
PikaMug | 56e2fb1cf9 | |
PikaMug | d6586bec9f | |
PikaMug | cfe2a660ec | |
datatags | a070255c0b | |
PikaMug | 0df7b37529 | |
PikaMug | 7e194579d2 | |
PikaMug | 74ad68d49c | |
PikaMug | c8d4b02060 | |
PikaMug | 8d7fe3e108 | |
PikaMug | 72ab32c71a | |
PikaMug | b38ee19dab | |
PikaMug | 67a72d31c6 | |
PikaMug | 55d2679f56 | |
PikaMug | e5d00e04d4 | |
PikaMug | abe4570d6e | |
PikaMug | b634348cd7 | |
PikaMug | a367831405 | |
PikaMug | 03136d8945 | |
PikaMug | f12a592f06 | |
PikaMug | 565bfe02e0 | |
PikaMug | 70615b30c9 | |
PikaMug | 1eb85f0178 | |
PikaMug | a54700a870 | |
PikaMug | 6c322582dc | |
PikaMug | 4d9a102a7d | |
dependabot[bot] | 635de4a0fd | |
PikaMug | c59f1882e8 | |
PikaMug | 581e00c6a1 | |
PikaMug | 78f5766b78 | |
PikaMug | 1e1175d061 | |
PikaMug | df2716074f | |
PikaMug | 86df2aa0b0 | |
PikaMug | 5c66d01d7c | |
PikaMug | fae968c3e6 | |
PikaMug | 5a78e20efc | |
PikaMug | 6ff11bed03 | |
PikaMug | 12174c5164 | |
PikaMug | 2f360562a6 | |
PikaMug | 7cbf317b42 | |
PikaMug | 2d1387cda1 | |
PikaMug | 5c212cb5d3 | |
PikaMug | ea1d720b51 | |
PikaMug | b234e097e3 | |
PikaMug | a7be8e9eb6 | |
PikaMug | 9dbbce3ea1 | |
PikaMug | 1eb79a6d14 | |
therbz | 11612439f9 | |
PikaMug | baf377e304 | |
PikaMug | 67b8018f93 | |
PikaMug | ae70523ac6 | |
PikaMug | 69f6d0acc4 | |
PikaMug | 53a4e5ef6e | |
PikaMug | 44ce64a7e9 | |
PikaMug | a02ca87d79 | |
PikaMug | ea6e50a49f | |
PikaMug | 74d071ffe8 | |
PikaMug | 054d86d6bc | |
PikaMug | 8fc1ad4bda | |
PikaMug | 5ef365c861 | |
therbz | 56ccaaab32 | |
PikaMug | c351ad699d | |
PikaMug | e40a00b236 | |
PikaMug | 68a626b117 | |
PikaMug | 9aa26d5b28 | |
PikaMug | 86d9e2c665 | |
PikaMug | 2a1c78b947 | |
PikaMug | 939b6b8f63 | |
PikaMug | 2d3592a89c | |
PikaMug | 684a3ebbdb | |
PikaMug | 9bf260ad59 | |
PikaMug | 3338001a97 | |
PikaMug | 002c4607cc | |
PikaMug | c1ef9b8fb2 | |
PikaMug | 1345b8251b | |
PikaMug | 298b18a536 | |
PikaMug | c593c210a3 | |
PikaMug | b7282cbada | |
PikaMug | d3c3b1d6c9 | |
PikaMug | 0ba111ec6a | |
PikaMug | 39633f2d15 | |
PikaMug | 67dc1dfe88 | |
Maximilian Dorn | 89922c3255 | |
PikaMug | 746f294628 | |
PikaMug | 025badce6b | |
PikaMug | 2c34ace51e | |
PikaMug | 33474fbc5c | |
PikaMug | 17e8510335 | |
PikaMug | 11ffbf46be | |
PikaMug | acf3daac60 | |
PikaMug | d07a777818 | |
PikaMug | 77d392dba2 | |
PikaMug | 260c66f4de | |
PikaMug | 38ab11e088 | |
PikaMug | 5c93285df2 | |
PikaMug | 2db149067d | |
PikaMug | 80088d7f52 | |
PikaMug | 81f7fb4d3c | |
PikaMug | d363d6d81c | |
PikaMug | e036074af5 | |
PikaMug | b8e8c97b3e | |
PikaMug | 9302fe0e54 | |
PikaMug | 126e531fe2 | |
PikaMug | 91cb2c6851 | |
PikaMug | 9528042751 | |
PikaMug | b81e4fc16b | |
PikaMug | d38d09f482 | |
PikaMug | d382da8a42 | |
PikaMug | 965071a907 | |
PikaMug | 51d55ac626 | |
PikaMug | 02e7f284b3 | |
PikaMug | 570d3ea854 | |
PikaMug | 34eb2e458a | |
PikaMug | 83c720c021 | |
PikaMug | c999f7697d | |
PikaMug | d1875ae377 | |
PikaMug | 609eb183bd | |
PikaMug | 637ac02ee2 | |
PikaMug | 0c699b2de8 | |
PikaMug | ba14b57741 | |
PikaMug | ea80add107 | |
PikaMug | 8dd848ae16 | |
PikaMug | b25449f89f | |
PikaMug | 945e06c33f | |
PikaMug | 2bfbc68cfa | |
PikaMug | 5befbb1e8c | |
PikaMug | 08ae5b4f76 | |
PikaMug | ce5039d67b | |
PikaMug | 5b2d9a97dd | |
PikaMug | afcc682261 | |
PikaMug | 77b79f0689 | |
PikaMug | ee82e62805 | |
PikaMug | d38fad634f | |
PikaMug | bc5df18c06 | |
PikaMug | a82df20994 | |
PikaMug | 423357c6e1 | |
PikaMug | 6140580fd2 | |
PikaMug | 5739998125 | |
PikaMug | 8a218031cf | |
PikaMug | c7cfa9aaa5 | |
PikaMug | 7205e5a14a | |
PikaMug | fd5b6c1eca | |
PikaMug | 4e996bb1f4 | |
PikaMug | 51ba556864 | |
PikaMug | fbae888275 | |
PikaMug | a81fdf2918 | |
PikaMug | 4fb8e5e781 | |
PikaMug | a00a5176e2 | |
PikaMug | 2922808834 | |
PikaMug | 0640ac8852 | |
PikaMug | 0c7c727acc | |
PikaMug | fa768de8b0 | |
PikaMug | 275e1759f4 | |
PikaMug | 7c05200909 | |
PikaMug | 2c92e6cd46 | |
PikaMug | 7ba5a884af | |
PikaMug | 63a6456d80 | |
PikaMug | dc406ce60f | |
PikaMug | 722ccf7678 | |
PikaMug | 6320122549 | |
PikaMug | 5813d7fbd3 | |
PikaMug | d94a015e9e | |
PikaMug | 8b7013df0b | |
PikaMug | e2282494e0 | |
PikaMug | 1f204f2590 | |
PikaMug | c243a5e6d0 | |
PikaMug | 3554de1c0d | |
PikaMug | 2e622d5673 | |
PikaMug | 0e9bb7ce75 | |
PikaMug | 60be61fe8f | |
PikaMug | 7d936ba72a | |
PikaMug | af14209e12 | |
PikaMug | 448c5398a0 | |
PikaMug | 49341ea4f5 | |
PikaMug | 25ea0c5377 | |
PikaMug | 25044baafa | |
PikaMug | 278accd4ad | |
PikaMug | f9e9e49b04 | |
PikaMug | f47b955c62 | |
PikaMug | 2f0063a8af | |
PikaMug | 39439f552e | |
PikaMug | 4069c73c67 | |
PikaMug | 021af0c4e3 | |
PikaMug | 7c8c0acd3e | |
PikaMug | dbe35fa95e | |
PikaMug | 4e832817e0 | |
PikaMug | 849b881b2d | |
PikaMug | a5b2617855 | |
PikaMug | aea20a7b12 | |
PikaMug | 459a3fd4b7 | |
PikaMug | 37e63821ed | |
PikaMug | 27cb51c4cf | |
PikaMug | 25079d5129 | |
PikaMug | 429b8b0e8f | |
PikaMug | d553e1701e | |
PikaMug | e3b0ddf959 | |
PikaMug | 69486dbfb9 | |
PikaMug | d2136df07f | |
PikaMug | 10a9b7a102 | |
PikaMug | e3aef932e7 | |
PikaMug | 26c23a991b | |
PikaMug | 83852c7051 | |
PikaMug | 4bfdc2132c | |
PikaMug | 1fad8d6b7e | |
PikaMug | 823b82edaa | |
PikaMug | e8e8d1d0dd | |
PikaMug | 7eaedf079f | |
PikaMug | 7dbe851d8b | |
PikaMug | 47f52fbb1f | |
PikaMug | 25910ac66d | |
PikaMug | 4cfde2b126 | |
PikaMug | 9df27c2fa7 | |
PikaMug | f4b96c0dac | |
PikaMug | 5a28fc10c3 | |
PikaMug | 108ecb9952 | |
PikaMug | 33e4a5661f | |
PikaMug | b45ca9b8d3 | |
PikaMug | 7656f6ace6 | |
PikaMug | 40b23bcb96 | |
PikaMug | 731d21deb7 | |
PikaMug | 613ba96e34 | |
PikaMug | ba1aa443e3 | |
PikaMug | 182ecb3433 | |
PikaMug | d9d93552a3 | |
PikaMug | 8f8c1bd2d5 | |
PikaMug | 6e139cc465 | |
PikaMug | 3222c42999 | |
PikaMug | 0850f4c404 | |
PikaMug | e325e67635 | |
PikaMug | 378b8bc909 | |
PikaMug | 513a4e8be0 | |
PikaMug | a2bc97dfa0 | |
PikaMug | 00972980e6 | |
PikaMug | 506d584291 | |
PikaMug | b3b378fe9f | |
PikaMug | 359e03837c | |
PikaMug | cc646478f0 | |
PikaMug | de40e2f57c | |
PikaMug | 668ce8f1f9 | |
PikaMug | 8f6752eb9a | |
PikaMug | e1f658935a | |
PikaMug | 1347f32e49 | |
PikaMug | 089362b0f5 | |
datatags | d084823deb | |
PikaMug | 25c9f9ece8 | |
PikaMug | 66d5cfe8ea | |
PikaMug | e8b3ba5ef5 | |
PikaMug | c1b2a94ee3 | |
PikaMug | 7b820e32e9 | |
PikaMug | 9926ee3746 | |
PikaMug | a6a3a1a14f | |
PikaMug | e68a8858e8 | |
PikaMug | 3d82e95beb | |
PikaMug | 680afe8c44 | |
PikaMug | 164d9801e2 | |
PikaMug | 26430e8c10 | |
PikaMug | de50d3aa08 | |
PikaMug | 2bd85cae9f | |
PikaMug | 71511a4f8a | |
PikaMug | 43e2044b98 | |
PikaMug | 7da6ea4b97 | |
PikaMug | ff3a8bbd1b | |
PikaMug | dce3d13707 | |
PikaMug | 622578a002 | |
PikaMug | cb0793e0d4 | |
PikaMug | 5004e0c930 | |
PikaMug | 90329ffcf4 | |
PikaMug | 002adc653e | |
PikaMug | ee97390f8e | |
PikaMug | 5c166f2041 | |
PikaMug | 7b7b676b8d | |
PikaMug | 095fd8c419 | |
PikaMug | 5b0ab9c817 | |
PikaMug | d80b09c64f | |
PikaMug | aaf54722a2 | |
PikaMug | 5c45682cf7 | |
datatags | 1e91a8568a | |
PikaMug | 18e29ce396 | |
PikaMug | 7871e370c9 | |
PikaMug | d11d1a5146 | |
PikaMug | 69e1a1f2a5 | |
PikaMug | 826d5883e1 | |
PikaMug | 21e6c03d7b | |
PikaMug | 4f6c032e68 | |
PikaMug | 480e53a2c0 | |
PikaMug | fdf121252c | |
PikaMug | 8f801f2094 | |
PikaMug | 971931ded8 | |
PikaMug | 84be40a3ed | |
PikaMug | a5f4c470d5 | |
PikaMug | 20cecf8462 | |
PikaMug | 9da6fe3b4d | |
PikaMug | 3d20f41add | |
PikaMug | 523da1cf19 | |
PikaMug | 0621ccd1e1 | |
PikaMug | b544a193e9 | |
PikaMug | be04b26fc5 | |
PikaMug | 2b0c808503 | |
PikaMug | a8d59e6c12 | |
PikaMug | 3c8aa5ee4c | |
PikaMug | 8c2b077786 | |
PikaMug | d5f3f7f10e | |
PikaMug | 1fcca05658 | |
PikaMug | 7a6b642893 | |
PikaMug | 8e77e625ca | |
PikaMug | a078973df2 | |
PikaMug | 3f26d3478b | |
PikaMug | 75658b6399 | |
PikaMug | 3b3eedf56c | |
PikaMug | 48b6679a93 | |
PikaMug | a795ebe360 | |
PikaMug | 845753ebf4 | |
PikaMug | bd1f0b8389 | |
PikaMug | 3f7e920043 | |
PikaMug | 3cf7ad2719 | |
PikaMug | 7818d7ae1e | |
PikaMug | 222313083e | |
PikaMug | 2383bafc98 | |
PikaMug | a7a03eca5b | |
PikaMug | 9b402c28bf | |
PikaMug | a7eebe7919 | |
PikaMug | df04c72c99 | |
PikaMug | e3b449ed8b | |
PikaMug | 7531e20d4e | |
PikaMug | 27b6f97c2b | |
PikaMug | 61f9f2ede2 | |
PikaMug | 7514820ef1 |
|
@ -0,0 +1,13 @@
|
|||
# These are supported funding model platforms
|
||||
|
||||
github: PikaMug
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||
custom: paypal.com/donate/?hosted_button_id=FZAFJVB7FC4GU
|
|
@ -1,12 +0,0 @@
|
|||
---
|
||||
name: Ask a question
|
||||
about: if it's complex or code-related.
|
||||
labels: question
|
||||
---
|
||||
<!--
|
||||
Thanks for sticking with us! Please answer the following questions:
|
||||
-->
|
||||
|
||||
**Where else have you looked for answers to this question?**
|
||||
|
||||
**Share your question with as much detail as possible?**
|
|
@ -0,0 +1,22 @@
|
|||
name: Ask a question
|
||||
description: if it's complex or code-related.
|
||||
labels: [question]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for inquiring about the project! Please answer the following questions:
|
||||
- type: 'textarea'
|
||||
attributes:
|
||||
label: 'Where else have you looked for answers to this question?'
|
||||
description: 'Such as the documentation or an Internet search.'
|
||||
placeholder: 'I looked for an answer in...'
|
||||
validations:
|
||||
required: true
|
||||
- type: 'textarea'
|
||||
attributes:
|
||||
label: 'Share your question with as much detail as possible.'
|
||||
description: 'Every question is a cry to understand the world.'
|
||||
placeholder: 'I could not figure out...'
|
||||
validations:
|
||||
required: true
|
|
@ -1,14 +0,0 @@
|
|||
---
|
||||
name: Report a bug
|
||||
about: when something isn't working right.
|
||||
labels: bug
|
||||
---
|
||||
<!--
|
||||
Thanks for submitting a bug report! Please answer the following questions:
|
||||
-->
|
||||
|
||||
**What is your Quests version / build number (do _not_ say "latest")?**
|
||||
|
||||
**Describe the problem and how to replicate it. Any console errors to post _using a pastebin_?**
|
||||
|
||||
**If applicable, can you provide an example quest from quests.yml _using a pastebin_?**
|
|
@ -0,0 +1,36 @@
|
|||
name: Report a bug
|
||||
description: when something isn't working right.
|
||||
labels: [bug]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for submitting a bug report! Please answer the following questions:
|
||||
- type: 'textarea'
|
||||
attributes:
|
||||
label: 'What is your Quests version / build number (do *not* say "latest")?'
|
||||
description: 'You can find this using the `/quests info` command.'
|
||||
placeholder: 'The version used is...'
|
||||
validations:
|
||||
required: true
|
||||
- type: 'textarea'
|
||||
attributes:
|
||||
label: 'Describe the problem and how to replicate it.'
|
||||
description: 'Be as detailed as possible.'
|
||||
placeholder: "What happened was..."
|
||||
validations:
|
||||
required: true
|
||||
- type: 'textarea'
|
||||
attributes:
|
||||
label: 'Any console errors to share?'
|
||||
description: 'Paste into the field below.'
|
||||
render: shell
|
||||
validations:
|
||||
required: true
|
||||
- type: 'textarea'
|
||||
attributes:
|
||||
label: 'If applicable, can you provide an example quest from quests.yml?'
|
||||
description: 'Do not upload the file itself.'
|
||||
render: yaml
|
||||
validations:
|
||||
required: false
|
|
@ -1 +1,11 @@
|
|||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Documentation
|
||||
about: 'to read before reporting issues.'
|
||||
url: 'https://pikamug.gitbook.io/quests/'
|
||||
- name: Discord
|
||||
about: 'for quick answers to basic questions.'
|
||||
url: 'https://discordapp.com/invite/QdJAv2G7qg'
|
||||
- name: Development Builds
|
||||
about: 'to try after backing up your server.'
|
||||
url: 'https://ci.codemc.io/job/PikaMug/job/Quests/'
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
---
|
||||
name: Suggest a feature
|
||||
about: once you know all the details.
|
||||
labels: enhancement
|
||||
---
|
||||
<!--
|
||||
Thanks for sharing your new idea! Please answer the following questions:
|
||||
-->
|
||||
|
||||
**What does your feature do?**
|
||||
|
||||
**How would people use it?**
|
|
@ -0,0 +1,22 @@
|
|||
name: Suggest a feature
|
||||
description: once you know all the details.
|
||||
labels: [enhancement]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for sharing your idea! Please answer the following questions:
|
||||
- type: 'textarea'
|
||||
attributes:
|
||||
label: 'What does your feature do?'
|
||||
description: 'Be certain it does not already exist.'
|
||||
placeholder: 'My new idea is...'
|
||||
validations:
|
||||
required: true
|
||||
- type: 'textarea'
|
||||
attributes:
|
||||
label: 'How would people use it?'
|
||||
description: 'Consider ways it would benefit all.'
|
||||
placeholder: 'It would be used when...'
|
||||
validations:
|
||||
required: true
|
|
@ -19,10 +19,11 @@ nbdist/
|
|||
# Maven files
|
||||
*/target
|
||||
*dependency-reduced-pom.xml
|
||||
*.flattened-pom.xml
|
||||
|
||||
# Java files
|
||||
*.class
|
||||
*.log
|
||||
*.ctxt
|
||||
hs_err_pid*
|
||||
/target/
|
||||
hs_err_pid*
|
||||
/target/
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 64 KiB |
|
@ -0,0 +1,64 @@
|
|||
Contributing
|
||||
============
|
||||
|
||||
Thank you for your interest in contributing to Quests! We appreciate your
|
||||
effort, but to make sure that the inclusion of your patch is a smooth process, we
|
||||
ask that you make note of the following guidelines.
|
||||
|
||||
* **Target Java 8 for source and compilation.** Make sure to mark methods with
|
||||
` @Override` that override methods of parent classes, or that implement
|
||||
methods of interfaces.
|
||||
* **Use only spaces for indentation.** Our indents are 4-spaces long, and tabs
|
||||
are unacceptable.
|
||||
* **Wrap code to a 120 column limit.** We do this to make side by side diffs
|
||||
and other such tasks easier. Ignore this guideline if it makes the code
|
||||
too unreadable.
|
||||
* **Write complete Javadocs.** Do so only for public methods, and make sure
|
||||
that your `@param` and `@return` fields are not just blank.
|
||||
* **Don't tag classes with @author.** Some legacy classes may have this tag,
|
||||
but we are phasing it out.
|
||||
* **Make sure the code is efficient.** One way you can achieve this is to spend
|
||||
around ten minutes to think about what the code is doing and whether it
|
||||
seems awfully roundabout. If you had to copy the same large piece of
|
||||
code in several places, that's bad.
|
||||
* **Keep commit summaries under 70 characters.** For more details, place two
|
||||
new lines after the summary line and write away!
|
||||
* **Test your code.** We're not interested in broken code, for the obvious reasons.
|
||||
|
||||
|
||||
Branches
|
||||
----------------
|
||||
When submitting a feature or bugfix, base your code on the newest development branch,
|
||||
and PR against that same branch. If such a branch does not exist, base your code
|
||||
against the `main` branch, and PR against that same branch.
|
||||
|
||||
|
||||
Checklist
|
||||
---------
|
||||
|
||||
Ready to submit? Perform the checklist below:
|
||||
|
||||
1. Have all tabs been replaced into four spaces? Are indentations 4-space wide?
|
||||
2. Have I written proper Javadocs for my public methods? Are the @param and
|
||||
@return fields actually filled out?
|
||||
3. Have I run [`git rebase`](https://docs.github.com/github/getting-started-with-github/about-git-rebase) to the latest commit of the target branch?
|
||||
4. Have I combined my commits into a reasonably small number (if not one)
|
||||
commit using [`git rebase`](https://docs.github.com/github/getting-started-with-github/about-git-rebase)?
|
||||
5. Have I made my pull request too large? Pull requests should introduce
|
||||
small sets of changes at a time. Major changes should be discussed with
|
||||
other contributors prior to starting work.
|
||||
6. Are my commit messages descriptive?
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
This is **GOOD:**
|
||||
|
||||
if (var.func(param1, param2)) {
|
||||
// do things
|
||||
}
|
||||
|
||||
This is **BAD:**
|
||||
|
||||
if(vAR.func( param1, param2 ))
|
||||
//do things
|
|
@ -0,0 +1,22 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) PikaMug
|
||||
Copyright (c) contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
11
README.md
11
README.md
|
@ -16,20 +16,23 @@ Download
|
|||
---
|
||||
|
||||
Distributed through these fine vendors:
|
||||
- CurseForge (https://www.curseforge.com/minecraft/bukkit-plugins/quests/)
|
||||
- Modrinth (https://modrinth.com/plugin/quests.classic)
|
||||
- SpigotMC (https://www.spigotmc.org/resources/quests.3711/)
|
||||
- MC-Market (https://www.mc-market.org/resources/19187/)
|
||||
|
||||
Usage
|
||||
---
|
||||
|
||||
Documentation can be found in the Wiki: https://github.com/PikaMug/Quests/wiki
|
||||
Read about usage in the documentation: https://pikamug.gitbook.io/quests/
|
||||
|
||||
Compile
|
||||
---
|
||||
|
||||
Requires Java 8 and Maven: https://github.com/PikaMug/Quests/wiki/Master-%E2%80%90-Plugin-Compilation
|
||||
Java 8 and Maven required: https://pikamug.gitbook.io/quests/master/plugin-compilation
|
||||
|
||||
Translate
|
||||
---
|
||||
|
||||
Help localize into your language: https://crowdin.com/project/translate-quests
|
||||
Help localize into your language:
|
||||
- Project (https://crowdin.com/project/translate-quests)
|
||||
- Documentation (https://github.com/PikaMug/QuestsDoc)
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>me.pikamug.quests</groupId>
|
||||
<artifactId>quests-parent</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<artifactId>quests-api</artifactId>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>24.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.28</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
<!-- Do not update until Java 11 is min -->
|
||||
<version>4.0.3</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean package install</defaultGoal>
|
||||
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.10.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<minimizeJar>false</minimizeJar>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>me.*</include>
|
||||
<include>com.zaxxer:HikariCP</include>
|
||||
<include>mysql</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.MF</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.zaxxer.hikari</pattern>
|
||||
<shadedPattern>me.pikamug.quests.libs.hikari</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.mysql</pattern>
|
||||
<shadedPattern>me.pikamug.quests.libs.mysql</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests;
|
||||
|
||||
import me.pikamug.quests.actions.Action;
|
||||
import me.pikamug.quests.actions.ActionFactory;
|
||||
import me.pikamug.quests.conditions.Condition;
|
||||
import me.pikamug.quests.conditions.ConditionFactory;
|
||||
import me.pikamug.quests.config.ConfigSettings;
|
||||
import me.pikamug.quests.dependencies.Dependencies;
|
||||
import me.pikamug.quests.module.CustomObjective;
|
||||
import me.pikamug.quests.module.CustomRequirement;
|
||||
import me.pikamug.quests.module.CustomReward;
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
import me.pikamug.quests.quests.QuestFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public interface Quests {
|
||||
|
||||
boolean isEnabled();
|
||||
|
||||
boolean isLoading();
|
||||
|
||||
String getDetectedServerSoftwareVersion();
|
||||
|
||||
File getPluginDataFolder();
|
||||
|
||||
Logger getPluginLogger();
|
||||
|
||||
InputStream getPluginResource(String filename);
|
||||
|
||||
Dependencies getDependencies();
|
||||
|
||||
ConfigSettings getConfigSettings();
|
||||
|
||||
List<CustomObjective> getCustomObjectives();
|
||||
|
||||
List<CustomReward> getCustomRewards();
|
||||
|
||||
List<CustomRequirement> getCustomRequirements();
|
||||
|
||||
Collection<Quest> getLoadedQuests();
|
||||
|
||||
Collection<Action> getLoadedActions();
|
||||
|
||||
Collection<Condition> getLoadedConditions();
|
||||
|
||||
Quester getQuester(final UUID id);
|
||||
|
||||
Collection<Quester> getOnlineQuesters();
|
||||
|
||||
Collection<Quester> getOfflineQuesters();
|
||||
|
||||
void setOfflineQuesters(final Collection<Quester> questers);
|
||||
|
||||
QuestFactory getQuestFactory();
|
||||
|
||||
ActionFactory getActionFactory();
|
||||
|
||||
ConditionFactory getConditionFactory();
|
||||
|
||||
/*ConvoListener getConvoListener();
|
||||
|
||||
BlockListener getBlockListener();
|
||||
|
||||
ItemListener getItemListener();
|
||||
|
||||
NpcListener getNpcListener();
|
||||
|
||||
PlayerListener getPlayerListener();
|
||||
|
||||
UniteListener getUniteListener();
|
||||
|
||||
NpcEffectThread getNpcEffectThread();
|
||||
|
||||
PlayerMoveThread getPlayerMoveThread();
|
||||
|
||||
PartiesListener getPartiesListener();
|
||||
|
||||
DenizenTrigger getDenizenTrigger();
|
||||
|
||||
LocaleManager getLocaleManager();
|
||||
|
||||
QuesterStorage getStorage();*/
|
||||
|
||||
void saveResourceAs(String resourcePath, final String outputPath, final boolean replace);
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.actions;
|
||||
|
||||
import me.pikamug.quests.entity.QuestMob;
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
public interface Action extends Comparable<Action> {
|
||||
String getName();
|
||||
|
||||
void setName(final String name);
|
||||
|
||||
String getMessage();
|
||||
|
||||
void setMessage(final String message);
|
||||
|
||||
boolean isClearInv();
|
||||
|
||||
void setClearInv(final boolean clearInv);
|
||||
|
||||
boolean isFailQuest();
|
||||
|
||||
void setFailQuest(final boolean failQuest);
|
||||
|
||||
int getStormDuration();
|
||||
|
||||
void setStormDuration(final int stormDuration);
|
||||
|
||||
int getThunderDuration();
|
||||
|
||||
void setThunderDuration(final int thunderDuration);
|
||||
|
||||
int getTimer();
|
||||
|
||||
void setTimer(final int timer);
|
||||
|
||||
boolean isCancelTimer();
|
||||
|
||||
void setCancelTimer(final boolean cancelTimer);
|
||||
|
||||
LinkedList<QuestMob> getMobSpawns();
|
||||
|
||||
void setMobSpawns(final LinkedList<QuestMob> mobSpawns);
|
||||
|
||||
LinkedList<String> getCommands();
|
||||
|
||||
void setCommands(final LinkedList<String> commands);
|
||||
|
||||
int getHunger();
|
||||
|
||||
void setHunger(final int hunger);
|
||||
|
||||
int getSaturation();
|
||||
|
||||
void setSaturation(final int saturation);
|
||||
|
||||
float getHealth();
|
||||
|
||||
void setHealth(final float health);
|
||||
|
||||
String getBook();
|
||||
|
||||
void setBook(final String book);
|
||||
|
||||
String getDenizenScript();
|
||||
|
||||
void setDenizenScript(final String scriptName);
|
||||
|
||||
void fire(final Quester quester, final Quest quest);
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.actions;
|
||||
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.ConversationFactory;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ActionFactory {
|
||||
|
||||
ConversationFactory getConversationFactory();
|
||||
|
||||
List<String> getNamesOfActionsBeingEdited();
|
||||
|
||||
void setNamesOfActionsBeingEdited(final List<String> actionNames);
|
||||
|
||||
Prompt returnToMenu(final ConversationContext context);
|
||||
|
||||
void loadData(final ConversationContext context, final Action action);
|
||||
|
||||
void clearData(final ConversationContext context);
|
||||
|
||||
void deleteAction(final ConversationContext context);
|
||||
|
||||
void saveAction(final ConversationContext context);
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.conditions;
|
||||
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface Condition extends Comparable<Condition> {
|
||||
String getName();
|
||||
|
||||
void setName(final String name);
|
||||
|
||||
boolean isFailQuest();
|
||||
|
||||
void setFailQuest(final boolean failQuest);
|
||||
|
||||
LinkedList<String> getEntitiesWhileRiding();
|
||||
|
||||
void setEntitiesWhileRiding(final LinkedList<String> entitiesWhileRiding);
|
||||
|
||||
LinkedList<UUID> getNpcsWhileRiding();
|
||||
|
||||
void setNpcsWhileRiding(final LinkedList<UUID> npcsWhileRiding);
|
||||
|
||||
LinkedList<String> getPermissions();
|
||||
|
||||
void setPermissions(final LinkedList<String> permissions);
|
||||
|
||||
LinkedList<String> getWorldsWhileStayingWithin();
|
||||
|
||||
void setWorldsWhileStayingWithin(final LinkedList<String> worldsWhileStayingWithin);
|
||||
|
||||
int getTickStartWhileStayingWithin();
|
||||
|
||||
void setTickStartWhileStayingWithin(final int tickStartWhileStayingWithin);
|
||||
|
||||
int getTickEndWhileStayingWithin();
|
||||
|
||||
void setTickEndWhileStayingWithin(final int tickEndWhileStayingWithin);
|
||||
|
||||
LinkedList<String> getBiomesWhileStayingWithin();
|
||||
|
||||
void setBiomesWhileStayingWithin(final LinkedList<String> biomesWhileStayingWithin);
|
||||
|
||||
LinkedList<String> getRegionsWhileStayingWithin();
|
||||
|
||||
void setRegionsWhileStayingWithin(final LinkedList<String> biomesWhileStayingWithin);
|
||||
|
||||
LinkedList<String> getPlaceholdersCheckIdentifier();
|
||||
|
||||
void setPlaceholdersCheckIdentifier(final LinkedList<String> placeholdersCheckIdentifier);
|
||||
|
||||
LinkedList<String> getPlaceholdersCheckValue();
|
||||
|
||||
void setPlaceholdersCheckValue(final LinkedList<String> placeholdersCheckValue);
|
||||
|
||||
boolean check(final Quester quester, final Quest quest);
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.conditions;
|
||||
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.ConversationFactory;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ConditionFactory {
|
||||
ConversationFactory getConversationFactory();
|
||||
|
||||
List<String> getNamesOfConditionsBeingEdited();
|
||||
|
||||
void setNamesOfConditionsBeingEdited(final List<String> conditionNames);
|
||||
|
||||
Prompt returnToMenu(final ConversationContext context);
|
||||
|
||||
void loadData(final ConversationContext context, final Condition condition);
|
||||
|
||||
void clearData(final ConversationContext context);
|
||||
|
||||
void deleteCondition(final ConversationContext context);
|
||||
|
||||
void saveCondition(final ConversationContext context);
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.config;
|
||||
|
||||
public interface ConfigSettings {
|
||||
int getAcceptTimeout();
|
||||
void setAcceptTimeout(final int acceptTimeout);
|
||||
boolean canAllowCommands();
|
||||
void setAllowCommands(final boolean allowCommands);
|
||||
boolean canAllowCommandsForNpcQuests();
|
||||
void setAllowCommandsForNpcQuests(final boolean allowCommandsForNpcQuests);
|
||||
boolean canAllowPranks();
|
||||
void setAllowPranks(final boolean allowPranks);
|
||||
boolean canClickablePrompts();
|
||||
void setClickablePrompts(boolean clickablePrompts);
|
||||
int getConditionInterval();
|
||||
void setConditionInterval(final int conditionInterval);
|
||||
boolean canConfirmAbandon();
|
||||
void setConfirmAbandon(final boolean confirmAbandon);
|
||||
boolean canConfirmAccept();
|
||||
void setConfirmAccept(final boolean confirmAccept);
|
||||
int getConsoleLogging();
|
||||
void setConsoleLogging(final int consoleLogging);
|
||||
boolean canDisableCommandFeedback();
|
||||
void setDisableCommandFeedback(final boolean disableCommandFeedback);
|
||||
boolean canGenFilesOnJoin();
|
||||
void setGenFilesOnJoin(final boolean genFilesOnJoin);
|
||||
boolean canGiveJournalItem();
|
||||
void setGiveJournalItem(final boolean giveJournalItem);
|
||||
boolean canIgnoreLockedQuests();
|
||||
void setIgnoreLockedQuests(final boolean ignoreLockedQuests);
|
||||
int getKillDelay();
|
||||
void setKillDelay(final int killDelay);
|
||||
String getLanguage();
|
||||
void setLanguage(final String language);
|
||||
boolean canLanguageOverrideClient();
|
||||
void setLanguageOverrideClient(final boolean languageOverrideClient);
|
||||
int getMaxQuests();
|
||||
void setMaxQuests(final int maxQuests);
|
||||
boolean canNpcEffects();
|
||||
void setNpcEffects(final boolean npcEffects);
|
||||
String getEffect();
|
||||
void setEffect(final String effect);
|
||||
String getRedoEffect();
|
||||
void setRedoEffect(final String redoEffect);
|
||||
boolean canShowCompletedObjs();
|
||||
void setShowCompletedObjs(final boolean showCompletedObjs);
|
||||
boolean canShowQuestReqs();
|
||||
void setShowQuestReqs(final boolean showQuestReqs);
|
||||
boolean canShowQuestTitles();
|
||||
void setShowQuestTitles(final boolean showQuestTitles);
|
||||
int getStrictPlayerMovement();
|
||||
void setStrictPlayerMovement(final int strictPlayerMovement);
|
||||
boolean canTrialSave();
|
||||
void setTrialSave(final boolean trialSave);
|
||||
int getTopLimit();
|
||||
void setTopLimit(final int topLimit);
|
||||
boolean canTranslateNames();
|
||||
void setTranslateNames(final boolean translateItems);
|
||||
boolean canTranslateSubCommands();
|
||||
void setTranslateSubCommands(final boolean translateSubCommands);
|
||||
boolean canUpdateCheck();
|
||||
void setUpdateCheck(final boolean updateCheck);
|
||||
void init();
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.convo;
|
||||
|
||||
import me.pikamug.quests.Quests;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.NumericPrompt;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public abstract class QuestsNumericPrompt extends NumericPrompt {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private static final Pattern NUMBER_PATTERN = Pattern.compile("^(\\d+) - ");
|
||||
|
||||
public QuestsNumericPrompt() {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getPromptText(@NotNull final ConversationContext cc) {
|
||||
return sendClickableSelection(getBasicPromptText(cc), cc);
|
||||
}
|
||||
|
||||
public abstract String getBasicPromptText(ConversationContext cc);
|
||||
|
||||
/**
|
||||
* Takes a Quests-styled conversation interface and decides how to send it
|
||||
* to the target. Players receive clickable text, others (i.e. console)
|
||||
* receive plain text, which is returned to be delivered through the
|
||||
* Conversations API.
|
||||
*
|
||||
* @param input the Quests-styled conversation interface
|
||||
* @param context the conversation context
|
||||
* @return plain text to deliver
|
||||
*/
|
||||
public static String sendClickableSelection(final String input, final ConversationContext context) {
|
||||
if (context.getPlugin() == null) {
|
||||
return "ERROR";
|
||||
}
|
||||
if (!(context.getForWhom() instanceof Player) || !((Quests)context.getPlugin()).getConfigSettings().canClickablePrompts()) {
|
||||
return input;
|
||||
}
|
||||
final String[] basicText = input.split("\n");
|
||||
final TextComponent component = new TextComponent("");
|
||||
boolean first = true;
|
||||
for (final String line : basicText) {
|
||||
final Matcher matcher = NUMBER_PATTERN.matcher(ChatColor.stripColor(line));
|
||||
final TextComponent lineComponent = new TextComponent(TextComponent.fromLegacyText(line));
|
||||
if (matcher.find()) {
|
||||
lineComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/quests choice " + matcher.group(1)));
|
||||
}
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
component.addExtra("\n");
|
||||
}
|
||||
component.addExtra(lineComponent);
|
||||
}
|
||||
((Player)context.getForWhom()).spigot().sendMessage(component);
|
||||
return "";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.convo;
|
||||
|
||||
import me.pikamug.quests.Quests;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.StringPrompt;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class QuestsStringPrompt extends StringPrompt {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
public QuestsStringPrompt() {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a header, footer, and a list of names, formats them in Quests
|
||||
* style, and decides how to deliver the result. Players are sent
|
||||
* clickable text, all others (i.e. console) are sent plain text,
|
||||
* which is returned to be delivered through the Conversations API.
|
||||
*
|
||||
* @param header the menu header
|
||||
* @param list a list of strings to display
|
||||
* @param footer the menu footer
|
||||
* @param context the conversation context
|
||||
* @return plain text to deliver
|
||||
*/
|
||||
protected String sendClickableMenu(final String header, final List<String> list, final String footer,
|
||||
final ConversationContext context) {
|
||||
if (context.getPlugin() == null) {
|
||||
return "ERROR";
|
||||
}
|
||||
if (!(context.getForWhom() instanceof Player) || !((Quests)context.getPlugin()).getConfigSettings().canClickablePrompts()) {
|
||||
return ChatColor.GOLD + header + "\n" + ChatColor.AQUA + String.join(ChatColor.GRAY + ", " + ChatColor.AQUA, list) + "\n" + ChatColor.YELLOW + footer;
|
||||
}
|
||||
final TextComponent component = new TextComponent(header + "\n");
|
||||
component.setColor(ChatColor.GOLD);
|
||||
final TextComponent footerComponent = new TextComponent("\n" + footer);
|
||||
footerComponent.setColor(ChatColor.YELLOW);
|
||||
final TextComponent separator = new TextComponent(", ");
|
||||
separator.setColor(ChatColor.GRAY);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
final TextComponent questName = new TextComponent(list.get(i));
|
||||
questName.setColor(ChatColor.AQUA);
|
||||
questName.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/quests choice " + ChatColor.stripColor(list.get(i))));
|
||||
component.addExtra(questName);
|
||||
if (i < (list.size() - 1)) {
|
||||
component.addExtra(separator);
|
||||
}
|
||||
}
|
||||
component.addExtra(footerComponent);
|
||||
((Player)context.getForWhom()).spigot().sendMessage(component);
|
||||
return "";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.convo.actions;
|
||||
|
||||
import me.pikamug.quests.Quests;
|
||||
import me.pikamug.quests.actions.ActionFactory;
|
||||
import me.pikamug.quests.convo.QuestsNumericPrompt;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
|
||||
public abstract class ActionsEditorNumericPrompt extends QuestsNumericPrompt {
|
||||
private final ConversationContext context;
|
||||
private ActionFactory factory;
|
||||
|
||||
public ActionsEditorNumericPrompt(final ConversationContext context) {
|
||||
this.context = context;
|
||||
if (context != null && context.getPlugin() != null) {
|
||||
this.factory = ((Quests)context.getPlugin()).getActionFactory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
public ConversationContext getConversationContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public ActionFactory getActionFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
public abstract int getSize();
|
||||
|
||||
public abstract String getTitle(ConversationContext context);
|
||||
|
||||
public abstract ChatColor getNumberColor(ConversationContext context, int number);
|
||||
|
||||
public abstract String getSelectionText(ConversationContext context, int number);
|
||||
|
||||
public abstract String getAdditionalText(ConversationContext context, int number);
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.convo.actions;
|
||||
|
||||
import me.pikamug.quests.Quests;
|
||||
import me.pikamug.quests.actions.ActionFactory;
|
||||
import me.pikamug.quests.convo.QuestsStringPrompt;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
|
||||
public abstract class ActionsEditorStringPrompt extends QuestsStringPrompt {
|
||||
private final ConversationContext context;
|
||||
private ActionFactory factory;
|
||||
|
||||
public ActionsEditorStringPrompt(final ConversationContext context) {
|
||||
this.context = context;
|
||||
if (context != null && context.getPlugin() != null) {
|
||||
this.factory = ((Quests)context.getPlugin()).getActionFactory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
public ConversationContext getConversationContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public ActionFactory getActionFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
public abstract String getTitle(ConversationContext context);
|
||||
|
||||
public abstract String getQueryText(ConversationContext context);
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.convo.conditions;
|
||||
|
||||
import me.pikamug.quests.Quests;
|
||||
import me.pikamug.quests.conditions.ConditionFactory;
|
||||
import me.pikamug.quests.convo.QuestsNumericPrompt;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
|
||||
public abstract class ConditionsEditorNumericPrompt extends QuestsNumericPrompt {
|
||||
private final ConversationContext context;
|
||||
private ConditionFactory factory;
|
||||
|
||||
public ConditionsEditorNumericPrompt(final ConversationContext context) {
|
||||
this.context = context;
|
||||
if (context != null && context.getPlugin() != null) {
|
||||
this.factory = ((Quests)context.getPlugin()).getConditionFactory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
public ConversationContext getConversationContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public ConditionFactory getConditionFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
public abstract int getSize();
|
||||
|
||||
public abstract String getTitle(ConversationContext context);
|
||||
|
||||
public abstract ChatColor getNumberColor(ConversationContext context, int number);
|
||||
|
||||
public abstract String getSelectionText(ConversationContext context, int number);
|
||||
|
||||
public abstract String getAdditionalText(ConversationContext context, int number);
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.convo.conditions;
|
||||
|
||||
import me.pikamug.quests.Quests;
|
||||
import me.pikamug.quests.conditions.ConditionFactory;
|
||||
import me.pikamug.quests.convo.QuestsStringPrompt;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
|
||||
public abstract class ConditionsEditorStringPrompt extends QuestsStringPrompt {
|
||||
private final ConversationContext context;
|
||||
private ConditionFactory factory;
|
||||
|
||||
public ConditionsEditorStringPrompt(final ConversationContext context) {
|
||||
this.context = context;
|
||||
if (context != null && context.getPlugin() != null) {
|
||||
this.factory = ((Quests)context.getPlugin()).getConditionFactory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
public ConversationContext getConversationContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public ConditionFactory getConditionFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
public abstract String getTitle(ConversationContext context);
|
||||
|
||||
public abstract String getQueryText(ConversationContext context);
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.convo.quests;
|
||||
|
||||
import me.pikamug.quests.quests.QuestFactory;
|
||||
import me.pikamug.quests.Quests;
|
||||
import me.pikamug.quests.convo.QuestsNumericPrompt;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
|
||||
public abstract class QuestsEditorNumericPrompt extends QuestsNumericPrompt {
|
||||
private final ConversationContext context;
|
||||
private QuestFactory factory;
|
||||
|
||||
public QuestsEditorNumericPrompt(final ConversationContext context) {
|
||||
this.context = context;
|
||||
if (context != null && context.getPlugin() != null) {
|
||||
factory = ((Quests)context.getPlugin()).getQuestFactory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
public ConversationContext getConversationContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public QuestFactory getQuestFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
public abstract int getSize();
|
||||
|
||||
public abstract String getTitle(ConversationContext context);
|
||||
|
||||
public abstract ChatColor getNumberColor(ConversationContext context, int number);
|
||||
|
||||
public abstract String getSelectionText(ConversationContext context, int number);
|
||||
|
||||
public abstract String getAdditionalText(ConversationContext context, int number);
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.convo.quests;
|
||||
|
||||
import me.pikamug.quests.quests.QuestFactory;
|
||||
import me.pikamug.quests.Quests;
|
||||
import me.pikamug.quests.convo.QuestsStringPrompt;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
|
||||
public abstract class QuestsEditorStringPrompt extends QuestsStringPrompt {
|
||||
private final ConversationContext context;
|
||||
private QuestFactory factory;
|
||||
|
||||
public QuestsEditorStringPrompt(final ConversationContext context) {
|
||||
this.context = context;
|
||||
if (context != null && context.getPlugin() != null) {
|
||||
factory = ((Quests)context.getPlugin()).getQuestFactory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
public ConversationContext getConversationContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public QuestFactory getQuestFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
public abstract String getTitle(ConversationContext context);
|
||||
|
||||
public abstract String getQueryText(ConversationContext context);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.dependencies;
|
||||
|
||||
public interface Dependencies {
|
||||
|
||||
boolean isPluginAvailable(final String pluginName);
|
||||
|
||||
void init();
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.entity;
|
||||
|
||||
public interface QuestMob {
|
||||
String getName();
|
||||
|
||||
void setName(final String name);
|
||||
|
||||
Integer getSpawnAmounts();
|
||||
|
||||
void setSpawnAmounts(final int spawnAmounts);
|
||||
|
||||
Float[] getDropChances();
|
||||
|
||||
void setDropChances(final Float[] dropChances);
|
||||
|
||||
void spawn();
|
||||
}
|
|
@ -1,83 +1,81 @@
|
|||
/*******************************************************************************************************
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************************************/
|
||||
|
||||
package me.blackvein.quests.enums;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum ObjectiveType {
|
||||
|
||||
BREAK_BLOCK(1, "BreakBlock"),
|
||||
DAMAGE_BLOCK(2, "DamageBlock"),
|
||||
PLACE_BLOCK(3, "PlaceBlock"),
|
||||
USE_BLOCK(4, "UseBlock"),
|
||||
CUT_BLOCK(5, "CutBlock"),
|
||||
CRAFT_ITEM(6, "CraftItem"),
|
||||
SMELT_ITEM(7, "SmeltItem"),
|
||||
ENCHANT_ITEM(8, "EnchantItem"),
|
||||
BREW_ITEM(9, "BrewItem"),
|
||||
CONSUME_ITEM(10, "ConsumeItem"),
|
||||
DELIVER_ITEM(11, "DeliverItem"),
|
||||
MILK_COW(12, "MilkCow"),
|
||||
CATCH_FISH(13, "CatchFish"),
|
||||
KILL_MOB(14, "KillMob"),
|
||||
KILL_PLAYER(15, "KillPlayer"),
|
||||
TALK_TO_NPC(16, "TalkToNPC"),
|
||||
KILL_NPC(17, "KillNPC"),
|
||||
TAME_MOB(18, "TameMob"),
|
||||
SHEAR_SHEEP(19, "ShearSheep"),
|
||||
REACH_LOCATION(20, "ReachLocation"),
|
||||
PASSWORD(21, "Password"),
|
||||
CUSTOM(127, "Custom");
|
||||
|
||||
private String name;
|
||||
private byte typeId;
|
||||
|
||||
private static final Map<String, ObjectiveType> NAME_MAP = new HashMap<String, ObjectiveType>();
|
||||
private static final Map<Byte, ObjectiveType> ID_MAP = new HashMap<Byte, ObjectiveType>();
|
||||
|
||||
static {
|
||||
for (final ObjectiveType type : values()) {
|
||||
if (type.name != null) {
|
||||
NAME_MAP.put(type.name.toLowerCase(), type);
|
||||
}
|
||||
if (type.typeId > 0) {
|
||||
ID_MAP.put(type.typeId, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ObjectiveType(final int typeId, final String name) {
|
||||
this.typeId = (byte) typeId;
|
||||
// Capitalize first letter for legacy reasons
|
||||
this.name = name.substring(0, 1).toUpperCase() + name.substring(1);
|
||||
}
|
||||
|
||||
public static ObjectiveType fromName(final String name) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
// Return custom for legacy reasons
|
||||
if (name.startsWith("custom")) {
|
||||
return CUSTOM;
|
||||
}
|
||||
return NAME_MAP.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
public static ObjectiveType fromId(final int id) {
|
||||
if (id > Byte.MAX_VALUE) {
|
||||
return null;
|
||||
}
|
||||
return ID_MAP.get((byte) id);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.enums;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum ObjectiveType {
|
||||
|
||||
BREAK_BLOCK(1, "BreakBlock"),
|
||||
DAMAGE_BLOCK(2, "DamageBlock"),
|
||||
PLACE_BLOCK(3, "PlaceBlock"),
|
||||
USE_BLOCK(4, "UseBlock"),
|
||||
CUT_BLOCK(5, "CutBlock"),
|
||||
CRAFT_ITEM(6, "CraftItem"),
|
||||
SMELT_ITEM(7, "SmeltItem"),
|
||||
ENCHANT_ITEM(8, "EnchantItem"),
|
||||
BREW_ITEM(9, "BrewItem"),
|
||||
CONSUME_ITEM(10, "ConsumeItem"),
|
||||
DELIVER_ITEM(11, "DeliverItem"),
|
||||
MILK_COW(12, "MilkCow"),
|
||||
CATCH_FISH(13, "CatchFish"),
|
||||
KILL_MOB(14, "KillMob"),
|
||||
KILL_PLAYER(15, "KillPlayer"),
|
||||
TALK_TO_NPC(16, "TalkToNPC"),
|
||||
KILL_NPC(17, "KillNPC"),
|
||||
TAME_MOB(18, "TameMob"),
|
||||
SHEAR_SHEEP(19, "ShearSheep"),
|
||||
REACH_LOCATION(20, "ReachLocation"),
|
||||
PASSWORD(21, "Password"),
|
||||
CUSTOM(127, "Custom");
|
||||
|
||||
private final String name;
|
||||
private final byte typeId;
|
||||
|
||||
private static final Map<String, ObjectiveType> NAME_MAP = new HashMap<>();
|
||||
private static final Map<Byte, ObjectiveType> ID_MAP = new HashMap<>();
|
||||
|
||||
static {
|
||||
for (final ObjectiveType type : values()) {
|
||||
if (type.name != null) {
|
||||
NAME_MAP.put(type.name.toLowerCase(), type);
|
||||
}
|
||||
if (type.typeId > 0) {
|
||||
ID_MAP.put(type.typeId, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ObjectiveType(final int typeId, final String name) {
|
||||
this.typeId = (byte) typeId;
|
||||
// Capitalize first letter for legacy reasons
|
||||
this.name = name.substring(0, 1).toUpperCase() + name.substring(1);
|
||||
}
|
||||
|
||||
public static ObjectiveType fromName(final String name) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
// Return custom for legacy reasons
|
||||
if (name.startsWith("custom")) {
|
||||
return CUSTOM;
|
||||
}
|
||||
return NAME_MAP.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
public static ObjectiveType fromId(final int id) {
|
||||
if (id > Byte.MAX_VALUE) {
|
||||
return null;
|
||||
}
|
||||
return ID_MAP.get((byte) id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public enum StorageType {
|
||||
|
||||
// Local text file
|
||||
YAML("YAML", "yaml", "yml"),
|
||||
|
||||
// Remote database
|
||||
MYSQL("MySQL", "mysql"),
|
||||
|
||||
// Local archive
|
||||
JAR("JAR", "jar"),
|
||||
|
||||
// Custom
|
||||
CUSTOM("Custom", "custom");
|
||||
|
||||
private final String name;
|
||||
|
||||
private final List<String> identifiers;
|
||||
|
||||
StorageType(final String name, final String... identifiers) {
|
||||
this.name = name;
|
||||
this.identifiers = Collections.unmodifiableList(Arrays.asList(identifiers));
|
||||
}
|
||||
|
||||
public static StorageType parse(final String name, final StorageType def) {
|
||||
for (final StorageType t : values()) {
|
||||
for (final String id : t.getIdentifiers()) {
|
||||
if (id.equalsIgnoreCase(name)) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public List<String> getIdentifiers() {
|
||||
return identifiers;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class QuestsEvent extends Event {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
public QuestsEvent() {
|
||||
}
|
||||
|
||||
public QuestsEvent(final boolean async) {
|
||||
super(async);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -1,80 +1,80 @@
|
|||
/*******************************************************************************************************
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************************************/
|
||||
|
||||
package me.blackvein.quests.events.editor.actions;
|
||||
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.actions.ActionFactory;
|
||||
import me.blackvein.quests.events.QuestsEvent;
|
||||
|
||||
/**
|
||||
* Represents an Actions Editor-related event
|
||||
*/
|
||||
public abstract class ActionsEditorEvent extends QuestsEvent {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
protected ConversationContext context;
|
||||
private final ActionFactory factory;
|
||||
private final Prompt prompt;
|
||||
|
||||
public ActionsEditorEvent(final ConversationContext context, final Prompt prompt) {
|
||||
this.context = context;
|
||||
this.factory = ((Quests)context.getPlugin()).getActionFactory();
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
public ActionsEditorEvent(final ConversationContext context, final Prompt prompt, final boolean async) {
|
||||
super(async);
|
||||
this.context = context;
|
||||
this.factory = ((Quests)context.getPlugin()).getActionFactory();
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the context involved in this event
|
||||
*
|
||||
* @return ConversationContext which is involved in this event
|
||||
*/
|
||||
public ConversationContext getConversationContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the factory involved in this event
|
||||
*
|
||||
* @return ActionFactory which is involved in this event
|
||||
*/
|
||||
public ActionFactory getActionFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the prompt involved in this event
|
||||
*
|
||||
* @return Prompt which is involved in this event
|
||||
*/
|
||||
public Prompt getPrompt() {
|
||||
return prompt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.events.editor.actions;
|
||||
|
||||
import me.pikamug.quests.Quests;
|
||||
import me.pikamug.quests.actions.ActionFactory;
|
||||
import me.pikamug.quests.events.QuestsEvent;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Represents an Actions Editor-related event
|
||||
*/
|
||||
public abstract class ActionsEditorEvent extends QuestsEvent {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
protected ConversationContext context;
|
||||
private final ActionFactory factory;
|
||||
private final Prompt prompt;
|
||||
|
||||
public ActionsEditorEvent(final ConversationContext context, final Prompt prompt) {
|
||||
this.context = context;
|
||||
this.factory = ((Quests) Objects.requireNonNull(context.getPlugin())).getActionFactory();
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
public ActionsEditorEvent(final ConversationContext context, final Prompt prompt, final boolean async) {
|
||||
super(async);
|
||||
this.context = context;
|
||||
this.factory = ((Quests) Objects.requireNonNull(context.getPlugin())).getActionFactory();
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the context involved in this event
|
||||
*
|
||||
* @return ConversationContext which is involved in this event
|
||||
*/
|
||||
public ConversationContext getConversationContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the factory involved in this event
|
||||
*
|
||||
* @return ActionFactory which is involved in this event
|
||||
*/
|
||||
public ActionFactory getActionFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the prompt involved in this event
|
||||
*
|
||||
* @return Prompt which is involved in this event
|
||||
*/
|
||||
public Prompt getPrompt() {
|
||||
return prompt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.events.editor.actions;
|
||||
|
||||
import me.pikamug.quests.convo.actions.ActionsEditorNumericPrompt;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ActionsEditorPostOpenNumericPromptEvent extends ActionsEditorEvent {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final ActionsEditorNumericPrompt prompt;
|
||||
|
||||
public ActionsEditorPostOpenNumericPromptEvent(final ConversationContext context, final ActionsEditorNumericPrompt prompt) {
|
||||
super(context, prompt);
|
||||
this.context = context;
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the numeric prompt involved in this event
|
||||
*
|
||||
* @return Prompt which is involved in this event
|
||||
*/
|
||||
@Override
|
||||
public ActionsEditorNumericPrompt getPrompt() {
|
||||
return prompt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.events.editor.actions;
|
||||
|
||||
import me.pikamug.quests.convo.actions.ActionsEditorStringPrompt;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ActionsEditorPostOpenStringPromptEvent extends ActionsEditorEvent {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final ActionsEditorStringPrompt prompt;
|
||||
|
||||
public ActionsEditorPostOpenStringPromptEvent(final ConversationContext context, final ActionsEditorStringPrompt prompt) {
|
||||
super(context, prompt);
|
||||
this.context = context;
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string prompt involved in this event
|
||||
*
|
||||
* @return Prompt which is involved in this event
|
||||
*/
|
||||
@Override
|
||||
public ActionsEditorStringPrompt getPrompt() {
|
||||
return prompt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -1,80 +1,80 @@
|
|||
/*******************************************************************************************************
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************************************/
|
||||
|
||||
package me.blackvein.quests.events.editor.conditions;
|
||||
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.conditions.ConditionFactory;
|
||||
import me.blackvein.quests.events.QuestsEvent;
|
||||
|
||||
/**
|
||||
* Represents an Conditions Editor-related event
|
||||
*/
|
||||
public abstract class ConditionsEditorEvent extends QuestsEvent {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
protected ConversationContext context;
|
||||
private final ConditionFactory factory;
|
||||
private final Prompt prompt;
|
||||
|
||||
public ConditionsEditorEvent(final ConversationContext context, final Prompt prompt) {
|
||||
this.context = context;
|
||||
this.factory = ((Quests)context.getPlugin()).getConditionFactory();
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
public ConditionsEditorEvent(final ConversationContext context, final Prompt prompt, final boolean async) {
|
||||
super(async);
|
||||
this.context = context;
|
||||
this.factory = ((Quests)context.getPlugin()).getConditionFactory();
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the context involved in this event
|
||||
*
|
||||
* @return ConversationContext which is involved in this event
|
||||
*/
|
||||
public ConversationContext getConversationContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the factory involved in this event
|
||||
*
|
||||
* @return ConditionFactory which is involved in this event
|
||||
*/
|
||||
public ConditionFactory getConditionFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the prompt involved in this event
|
||||
*
|
||||
* @return Prompt which is involved in this event
|
||||
*/
|
||||
public Prompt getPrompt() {
|
||||
return prompt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.events.editor.conditions;
|
||||
|
||||
import me.pikamug.quests.Quests;
|
||||
import me.pikamug.quests.conditions.ConditionFactory;
|
||||
import me.pikamug.quests.events.QuestsEvent;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Represents an Conditions Editor-related event
|
||||
*/
|
||||
public abstract class ConditionsEditorEvent extends QuestsEvent {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
protected ConversationContext context;
|
||||
private final ConditionFactory factory;
|
||||
private final Prompt prompt;
|
||||
|
||||
public ConditionsEditorEvent(final ConversationContext context, final Prompt prompt) {
|
||||
this.context = context;
|
||||
this.factory = ((Quests) Objects.requireNonNull(context.getPlugin())).getConditionFactory();
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
public ConditionsEditorEvent(final ConversationContext context, final Prompt prompt, final boolean async) {
|
||||
super(async);
|
||||
this.context = context;
|
||||
this.factory = ((Quests) Objects.requireNonNull(context.getPlugin())).getConditionFactory();
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the context involved in this event
|
||||
*
|
||||
* @return ConversationContext which is involved in this event
|
||||
*/
|
||||
public ConversationContext getConversationContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the factory involved in this event
|
||||
*
|
||||
* @return ConditionFactory which is involved in this event
|
||||
*/
|
||||
public ConditionFactory getConditionFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the prompt involved in this event
|
||||
*
|
||||
* @return Prompt which is involved in this event
|
||||
*/
|
||||
public Prompt getPrompt() {
|
||||
return prompt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.events.editor.conditions;
|
||||
|
||||
import me.pikamug.quests.convo.conditions.ConditionsEditorNumericPrompt;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ConditionsEditorPostOpenNumericPromptEvent extends ConditionsEditorEvent {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final ConditionsEditorNumericPrompt prompt;
|
||||
|
||||
public ConditionsEditorPostOpenNumericPromptEvent(final ConversationContext context, final ConditionsEditorNumericPrompt prompt) {
|
||||
super(context, prompt);
|
||||
this.context = context;
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the numeric prompt involved in this event
|
||||
*
|
||||
* @return Prompt which is involved in this event
|
||||
*/
|
||||
@Override
|
||||
public ConditionsEditorNumericPrompt getPrompt() {
|
||||
return prompt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.events.editor.conditions;
|
||||
|
||||
import me.pikamug.quests.convo.conditions.ConditionsEditorStringPrompt;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ConditionsEditorPostOpenStringPromptEvent extends ConditionsEditorEvent {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final ConditionsEditorStringPrompt prompt;
|
||||
|
||||
public ConditionsEditorPostOpenStringPromptEvent(final ConversationContext context, final ConditionsEditorStringPrompt prompt) {
|
||||
super(context, prompt);
|
||||
this.context = context;
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string prompt involved in this event
|
||||
*
|
||||
* @return Prompt which is involved in this event
|
||||
*/
|
||||
@Override
|
||||
public ConditionsEditorStringPrompt getPrompt() {
|
||||
return prompt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -1,80 +1,80 @@
|
|||
/*******************************************************************************************************
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************************************/
|
||||
|
||||
package me.blackvein.quests.events.editor.quests;
|
||||
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import me.blackvein.quests.QuestFactory;
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.events.QuestsEvent;
|
||||
|
||||
/**
|
||||
* Represents a Quests Editor-related event
|
||||
*/
|
||||
public abstract class QuestsEditorEvent extends QuestsEvent {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
protected ConversationContext context;
|
||||
private final QuestFactory factory;
|
||||
private final Prompt prompt;
|
||||
|
||||
public QuestsEditorEvent(final ConversationContext context, final Prompt prompt) {
|
||||
this.context = context;
|
||||
this.factory = ((Quests)context.getPlugin()).getQuestFactory();
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
public QuestsEditorEvent(final ConversationContext context, final Prompt prompt, final boolean async) {
|
||||
super(async);
|
||||
this.context = context;
|
||||
this.factory = ((Quests)context.getPlugin()).getQuestFactory();
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the context involved in this event
|
||||
*
|
||||
* @return ConversationContext which is involved in this event
|
||||
*/
|
||||
public ConversationContext getConversationContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the factory involved in this event
|
||||
*
|
||||
* @return QuestFactory which is involved in this event
|
||||
*/
|
||||
public QuestFactory getQuestFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the prompt involved in this event
|
||||
*
|
||||
* @return Prompt which is involved in this event
|
||||
*/
|
||||
public Prompt getPrompt() {
|
||||
return prompt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.events.editor.quests;
|
||||
|
||||
import me.pikamug.quests.quests.QuestFactory;
|
||||
import me.pikamug.quests.Quests;
|
||||
import me.pikamug.quests.events.QuestsEvent;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Represents a Quests Editor-related event
|
||||
*/
|
||||
public abstract class QuestsEditorEvent extends QuestsEvent {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
protected ConversationContext context;
|
||||
private final QuestFactory factory;
|
||||
private final Prompt prompt;
|
||||
|
||||
public QuestsEditorEvent(final ConversationContext context, final Prompt prompt) {
|
||||
this.context = context;
|
||||
this.factory = ((Quests) Objects.requireNonNull(context.getPlugin())).getQuestFactory();
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
public QuestsEditorEvent(final ConversationContext context, final Prompt prompt, final boolean async) {
|
||||
super(async);
|
||||
this.context = context;
|
||||
this.factory = ((Quests) Objects.requireNonNull(context.getPlugin())).getQuestFactory();
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the context involved in this event
|
||||
*
|
||||
* @return ConversationContext which is involved in this event
|
||||
*/
|
||||
public ConversationContext getConversationContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the factory involved in this event
|
||||
*
|
||||
* @return QuestFactory which is involved in this event
|
||||
*/
|
||||
public QuestFactory getQuestFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the prompt involved in this event
|
||||
*
|
||||
* @return Prompt which is involved in this event
|
||||
*/
|
||||
public Prompt getPrompt() {
|
||||
return prompt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.events.editor.quests;
|
||||
|
||||
import me.pikamug.quests.convo.quests.QuestsEditorNumericPrompt;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class QuestsEditorPostOpenNumericPromptEvent extends QuestsEditorEvent {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final QuestsEditorNumericPrompt prompt;
|
||||
|
||||
public QuestsEditorPostOpenNumericPromptEvent(final ConversationContext context, final QuestsEditorNumericPrompt prompt) {
|
||||
super(context, prompt);
|
||||
this.context = context;
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the numeric prompt involved in this event
|
||||
*
|
||||
* @return Prompt which is involved in this event
|
||||
*/
|
||||
@Override
|
||||
public QuestsEditorNumericPrompt getPrompt() {
|
||||
return prompt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.events.editor.quests;
|
||||
|
||||
import me.pikamug.quests.convo.quests.QuestsEditorStringPrompt;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class QuestsEditorPostOpenStringPromptEvent extends QuestsEditorEvent {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final QuestsEditorStringPrompt prompt;
|
||||
|
||||
public QuestsEditorPostOpenStringPromptEvent(final ConversationContext context, final QuestsEditorStringPrompt prompt) {
|
||||
super(context, prompt);
|
||||
this.context = context;
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string prompt involved in this event
|
||||
*
|
||||
* @return Prompt which is involved in this event
|
||||
*/
|
||||
@Override
|
||||
public QuestsEditorStringPrompt getPrompt() {
|
||||
return prompt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -1,21 +1,20 @@
|
|||
/*******************************************************************************************************
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************************************/
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.blackvein.quests.events.misc;
|
||||
package me.pikamug.quests.events.misc;
|
||||
|
||||
import me.blackvein.quests.events.QuestsEvent;
|
||||
import me.pikamug.quests.events.QuestsEvent;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a miscellaneous editor-related event
|
||||
|
@ -55,7 +54,7 @@ public class MiscEditorEvent extends QuestsEvent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.events.misc;
|
||||
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MiscPostNpcOfferQuestEvent extends MiscEditorEvent {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final Prompt prompt;
|
||||
|
||||
public MiscPostNpcOfferQuestEvent(final ConversationContext context, final Prompt prompt) {
|
||||
super(context, prompt);
|
||||
this.context = context;
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the context involved in this event
|
||||
*
|
||||
* @return ConversationContext which is involved in this event
|
||||
*/
|
||||
public ConversationContext getConversationContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the prompt involved in this event
|
||||
*
|
||||
* @return Prompt which is involved in this event
|
||||
*/
|
||||
public Prompt getPrompt() {
|
||||
return prompt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.events.misc;
|
||||
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MiscPostQuestAbandonEvent extends MiscEditorEvent {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final Prompt prompt;
|
||||
|
||||
public MiscPostQuestAbandonEvent(final ConversationContext context, final Prompt prompt) {
|
||||
super(context, prompt);
|
||||
this.context = context;
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the context involved in this event
|
||||
*
|
||||
* @return ConversationContext which is involved in this event
|
||||
*/
|
||||
public ConversationContext getConversationContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the prompt involved in this event
|
||||
*
|
||||
* @return Prompt which is involved in this event
|
||||
*/
|
||||
public Prompt getPrompt() {
|
||||
return prompt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.events.misc;
|
||||
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MiscPostQuestAcceptEvent extends MiscEditorEvent {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final Prompt prompt;
|
||||
|
||||
public MiscPostQuestAcceptEvent(final ConversationContext context, final Prompt prompt) {
|
||||
super(context, prompt);
|
||||
this.context = context;
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the context involved in this event
|
||||
*
|
||||
* @return ConversationContext which is involved in this event
|
||||
*/
|
||||
public ConversationContext getConversationContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the prompt involved in this event
|
||||
*
|
||||
* @return Prompt which is involved in this event
|
||||
*/
|
||||
public Prompt getPrompt() {
|
||||
return prompt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.events.quest;
|
||||
|
||||
import me.pikamug.quests.events.QuestsEvent;
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a quest-related event
|
||||
*/
|
||||
public abstract class QuestEvent extends QuestsEvent {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final Quest quest;
|
||||
|
||||
public QuestEvent(final Quest quest) {
|
||||
this.quest = quest;
|
||||
}
|
||||
|
||||
public QuestEvent(final Quest quest, final boolean async) {
|
||||
super(async);
|
||||
this.quest = quest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quest involved in this event
|
||||
*
|
||||
* @return Quest which is involved in this event
|
||||
*/
|
||||
public final Quest getQuest() {
|
||||
return quest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.events.quest;
|
||||
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a quest is quit by a quester
|
||||
*/
|
||||
public class QuestQuitEvent extends QuestEvent implements Cancellable {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final Quester quester;
|
||||
private boolean cancel = false;
|
||||
|
||||
public QuestQuitEvent(final Quest quest, final Quester who) {
|
||||
super(quest);
|
||||
this.quester = who;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quester involved in this event
|
||||
*
|
||||
* @return Quester who is involved in this event
|
||||
*/
|
||||
public Quester getQuester() {
|
||||
return quester;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancel = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.events.quest;
|
||||
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a quest is taken by a quester
|
||||
*/
|
||||
public class QuestTakeEvent extends QuestEvent implements Cancellable {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final Quester quester;
|
||||
private boolean cancel = false;
|
||||
|
||||
public QuestTakeEvent(final Quest quest, final Quester who) {
|
||||
super(quest);
|
||||
this.quester = who;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quester involved in this event
|
||||
*
|
||||
* @return Quester who is involved in this event
|
||||
*/
|
||||
public Quester getQuester() {
|
||||
return quester;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancel = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -1,61 +1,72 @@
|
|||
package me.blackvein.quests.events.quest;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import me.blackvein.quests.Quest;
|
||||
import me.blackvein.quests.Quester;
|
||||
|
||||
/**
|
||||
* Called when a quest has its compass target updated for a quester
|
||||
*/
|
||||
public class QuestUpdateCompassEvent extends QuestEvent implements Cancellable {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final Quester quester;
|
||||
private final Location target;
|
||||
private boolean cancel = false;
|
||||
|
||||
public QuestUpdateCompassEvent(final Quest quest, final Quester who, final Location target) {
|
||||
super(quest);
|
||||
this.quester = who;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quester involved in this event
|
||||
*
|
||||
* @return Quester who is involved in this event
|
||||
*/
|
||||
public Quester getQuester() {
|
||||
return quester;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the new compass target in this event
|
||||
*
|
||||
* @return Location which shall be the new target
|
||||
*/
|
||||
public Location getNewCompassTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancel = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.events.quest;
|
||||
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a quest has its compass target updated for a quester
|
||||
*/
|
||||
public class QuestUpdateCompassEvent extends QuestEvent implements Cancellable {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final Quester quester;
|
||||
private final Location target;
|
||||
private boolean cancel = false;
|
||||
|
||||
public QuestUpdateCompassEvent(final Quest quest, final Quester who, final Location target) {
|
||||
super(quest);
|
||||
this.quester = who;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quester involved in this event
|
||||
*
|
||||
* @return Quester who is involved in this event
|
||||
*/
|
||||
public Quester getQuester() {
|
||||
return quester;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the new compass target in this event
|
||||
*
|
||||
* @return Location which shall be the new target
|
||||
*/
|
||||
public Location getNewCompassTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancel = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.exceptions;
|
||||
|
||||
public class ActionFormatException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 6165516939621807530L;
|
||||
private final String message;
|
||||
private final String actionId;
|
||||
|
||||
public ActionFormatException(final String message, final String actionId) {
|
||||
super(message + ", see action of ID " + actionId);
|
||||
this.message = message + ", see action of ID " + actionId;
|
||||
this.actionId = actionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message associated with this exception.
|
||||
*
|
||||
* @return The message.
|
||||
*/
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the action ID associated with this exception.
|
||||
*
|
||||
* @return The action that an invalid value was set within.
|
||||
*/
|
||||
public String getActionId() {
|
||||
return actionId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.exceptions;
|
||||
|
||||
public class ConditionFormatException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 6165516939621807530L;
|
||||
private final String message;
|
||||
private final String conditionId;
|
||||
|
||||
public ConditionFormatException(final String message, final String conditionId) {
|
||||
super(message + ", see condition of ID " + conditionId);
|
||||
this.message = message + ", see condition of ID " + conditionId;
|
||||
this.conditionId = conditionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message associated with this exception.
|
||||
*
|
||||
* @return The message.
|
||||
*/
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the condition ID associated with this exception.
|
||||
*
|
||||
* @return The condition that an invalid value was set within.
|
||||
*/
|
||||
public String getConditionId() {
|
||||
return conditionId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.exceptions;
|
||||
|
||||
public class QuestFormatException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -5960613170308750149L;
|
||||
private final String message;
|
||||
private final String questId;
|
||||
|
||||
public QuestFormatException(final String message, final String questId) {
|
||||
super(message + ", see quest of ID " + questId);
|
||||
this.message = message + ", see quest of ID " + questId;
|
||||
this.questId = questId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message associated with this exception.
|
||||
*
|
||||
* @return The message.
|
||||
*/
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the quest ID associated with this exception.
|
||||
*
|
||||
* @return The quest that an invalid value was set within.
|
||||
*/
|
||||
public String getQuestId() {
|
||||
return questId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.exceptions;
|
||||
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
|
||||
public class StageFormatException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -8217391053042612896L;
|
||||
private final String message;
|
||||
private final Quest quest;
|
||||
private final int stage;
|
||||
|
||||
|
||||
public StageFormatException(final String message, final Quest quest, final int stage) {
|
||||
super(message + ", see quest " + quest.getName() + " stage " + stage);
|
||||
this.message = message + ", see quest " + quest.getName() + " stage " + stage;
|
||||
this.quest = quest;
|
||||
this.stage = stage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message associated with this exception.
|
||||
*
|
||||
* @return The message.
|
||||
*/
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the quest instance associated with this exception.
|
||||
*
|
||||
* @return The quest that an invalid stage id was set within.
|
||||
*/
|
||||
public Quest getQuest() {
|
||||
return quest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the invalid stage id that was attempted to be set within the quest class.
|
||||
*
|
||||
* @return The invalid stage id that was set.
|
||||
*/
|
||||
public int getStage() {
|
||||
return stage;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.interfaces;
|
||||
|
||||
public interface ReloadCallback<T> {
|
||||
void execute(T response);
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.module;
|
||||
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface CustomObjective {
|
||||
|
||||
String getModuleName();
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
Map.Entry<String, Short> getModuleItem();
|
||||
|
||||
String getName();
|
||||
|
||||
void setName(final String name);
|
||||
|
||||
String getAuthor();
|
||||
|
||||
void setAuthor(final String author);
|
||||
|
||||
String getDisplay();
|
||||
|
||||
void setDisplay(final String display);
|
||||
|
||||
Map.Entry<String, Short> getItem();
|
||||
|
||||
void setItem(final String type, final short durability);
|
||||
|
||||
LinkedList<Map.Entry<String, Object>> getData();
|
||||
|
||||
/**
|
||||
* Add a new prompt<p>
|
||||
*
|
||||
* Note that the "defaultValue" Object will be cast to a String internally
|
||||
*
|
||||
* @param title Prompt name
|
||||
* @param description Description of expected input
|
||||
* @param defaultValue Value to be used if input is not received
|
||||
*/
|
||||
void addStringPrompt(final String title, final String description, final Object defaultValue);
|
||||
|
||||
Map<String, String> getDescriptions();
|
||||
|
||||
int getCount();
|
||||
|
||||
void setCount(final int count);
|
||||
|
||||
String getCountPrompt();
|
||||
|
||||
void setCountPrompt(final String countPrompt);
|
||||
|
||||
/**
|
||||
* Check whether to let user set required amount for objective
|
||||
*/
|
||||
boolean canShowCount();
|
||||
|
||||
/**
|
||||
* Set whether to let user set required amount for objective
|
||||
*
|
||||
* @param showCount Whether to show the count
|
||||
*/
|
||||
void setShowCount(final boolean showCount);
|
||||
|
||||
/**
|
||||
* Get custom objective data for applicable player
|
||||
*
|
||||
* @param uuid UUID of player attempting this objective
|
||||
* @param customObj The objective being attempted
|
||||
* @param quest Current me.pikamug.quests.Quest which includes this objective
|
||||
* @return data Map of custom objective data
|
||||
*/
|
||||
Map<String, Object> getDataForPlayer(final UUID uuid, final CustomObjective customObj, final Quest quest);
|
||||
|
||||
/**
|
||||
* Increment objective count for applicable player
|
||||
*
|
||||
* @param uuid UUID of player attempting this objective
|
||||
* @param customObj The objective being attempted
|
||||
* @param quest Current me.pikamug.quests.Quest which includes this objective
|
||||
* @param count Amount to increase objective count by
|
||||
*/
|
||||
void incrementObjective(final UUID uuid, final CustomObjective customObj, final Quest quest, final int count);
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.module;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface CustomRequirement {
|
||||
|
||||
String getModuleName();
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
Map.Entry<String, Short> getModuleItem();
|
||||
|
||||
String getName();
|
||||
|
||||
void setName(final String name);
|
||||
|
||||
String getAuthor();
|
||||
|
||||
void setAuthor(final String author);
|
||||
|
||||
String getDisplay();
|
||||
|
||||
void setDisplay(final String display);
|
||||
|
||||
Map.Entry<String, Short> getItem();
|
||||
|
||||
void setItem(final String type, final short durability);
|
||||
|
||||
Map<String, Object> getData();
|
||||
|
||||
Map<String, String> getDescriptions();
|
||||
|
||||
/**
|
||||
* Add a new prompt<p>
|
||||
*
|
||||
* Note that the "defaultValue" Object will be cast to a String internally
|
||||
*
|
||||
* @param title Prompt name
|
||||
* @param description Description of expected input
|
||||
* @param defaultValue Value to be used if input is not received
|
||||
*/
|
||||
void addStringPrompt(final String title, final String description, final Object defaultValue);
|
||||
|
||||
/**
|
||||
* Test whether a player has met the requirement
|
||||
*
|
||||
* @param uuid UUID of player being tested
|
||||
* @param data Map of custom requirement data
|
||||
* @return true if met
|
||||
*/
|
||||
boolean testRequirement(UUID uuid, Map<String, Object> data);
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.module;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface CustomReward {
|
||||
|
||||
String getModuleName();
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
Map.Entry<String, Short> getModuleItem();
|
||||
|
||||
String getName();
|
||||
|
||||
void setName(final String name);
|
||||
|
||||
String getAuthor();
|
||||
|
||||
void setAuthor(final String author);
|
||||
|
||||
String getDisplay();
|
||||
|
||||
void setDisplay(final String display);
|
||||
|
||||
Map.Entry<String, Short> getItem();
|
||||
|
||||
void setItem(final String type, final short durability);
|
||||
|
||||
Map<String, Object> getData();
|
||||
|
||||
Map<String, String> getDescriptions();
|
||||
|
||||
/**
|
||||
* Add a new prompt<p>
|
||||
*
|
||||
* Note that the "defaultValue" Object will be cast to a String internally
|
||||
*
|
||||
* @param title Prompt name
|
||||
* @param description Description of expected input
|
||||
* @param defaultValue Value to be used if input is not received
|
||||
*/
|
||||
void addStringPrompt(final String title, final String description, final Object defaultValue);
|
||||
|
||||
/**
|
||||
* Give loot reward to a player
|
||||
*
|
||||
* @param uuid UUID of player being tested
|
||||
* @param data Map of custom reward data
|
||||
*/
|
||||
void giveReward(UUID uuid, Map<String, Object> data);
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.player;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
public interface QuestProgress {
|
||||
LinkedList<?> getBlocksBroken();
|
||||
|
||||
LinkedList<?> getBlocksDamaged();
|
||||
|
||||
LinkedList<?> getBlocksPlaced();
|
||||
|
||||
LinkedList<?> getBlocksUsed();
|
||||
|
||||
LinkedList<?> getBlocksCut();
|
||||
|
||||
LinkedList<?> getItemsCrafted();
|
||||
|
||||
LinkedList<?> getItemsSmelted();
|
||||
|
||||
LinkedList<?> getItemsEnchanted();
|
||||
|
||||
LinkedList<?> getItemsBrewed();
|
||||
|
||||
LinkedList<?> getItemsConsumed();
|
||||
|
||||
LinkedList<?> getItemsDelivered();
|
||||
|
||||
LinkedList<Boolean> getNpcsInteracted();
|
||||
|
||||
void setNpcsInteracted(final LinkedList<Boolean> npcsInteracted);
|
||||
|
||||
LinkedList<Integer> getNpcsNumKilled();
|
||||
|
||||
void setNpcsNumKilled(final LinkedList<Integer> npcsNumKilled);
|
||||
|
||||
LinkedList<Integer> getMobNumKilled();
|
||||
|
||||
void setMobNumKilled(final LinkedList<Integer> mobNumKilled);
|
||||
|
||||
LinkedList<Integer> getMobsTamed();
|
||||
|
||||
void setMobsTamed(final LinkedList<Integer> mobsTamed);
|
||||
|
||||
int getFishCaught();
|
||||
|
||||
void setFishCaught(final int fishCaught);
|
||||
|
||||
int getCowsMilked();
|
||||
|
||||
void setCowsMilked(final int cowsMilked);
|
||||
|
||||
LinkedList<Integer> getSheepSheared();
|
||||
|
||||
void setSheepSheared(final LinkedList<Integer> sheepSheared);
|
||||
|
||||
int getPlayersKilled();
|
||||
|
||||
void setPlayersKilled(final int playersKilled);
|
||||
|
||||
LinkedList<Boolean> getLocationsReached();
|
||||
|
||||
void setLocationsReached(final LinkedList<Boolean> locationsReached);
|
||||
|
||||
LinkedList<Boolean> getPasswordsSaid();
|
||||
|
||||
void setPasswordsSaid(final LinkedList<Boolean> passwordsSaid);
|
||||
|
||||
LinkedList<Integer> getCustomObjectiveCounts();
|
||||
|
||||
void setCustomObjectiveCounts(final LinkedList<Integer> customObjectiveCounts);
|
||||
|
||||
long getDelayStartTime();
|
||||
|
||||
void setDelayStartTime(final long delayStartTime);
|
||||
|
||||
long getDelayTimeLeft();
|
||||
|
||||
void setDelayTimeLeft(final long delayTimeLeft);
|
||||
|
||||
boolean canDoJournalUpdate();
|
||||
|
||||
void setDoJournalUpdate(final boolean b);
|
||||
}
|
|
@ -0,0 +1,256 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.player;
|
||||
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
import me.pikamug.quests.quests.components.Stage;
|
||||
import me.pikamug.quests.quests.components.Objective;
|
||||
import me.pikamug.quests.enums.ObjectiveType;
|
||||
import me.pikamug.quests.module.CustomObjective;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
public interface Quester extends Comparable<Quester> {
|
||||
UUID getUUID();
|
||||
|
||||
void setUUID(final UUID id);
|
||||
|
||||
String getQuestIdToTake();
|
||||
|
||||
void setQuestIdToTake(final String questIdToTake);
|
||||
|
||||
String getQuestIdToQuit();
|
||||
|
||||
void setQuestIdToQuit(final String questIdToQuit);
|
||||
|
||||
String getLastKnownName();
|
||||
|
||||
void setLastKnownName(final String lastKnownName);
|
||||
|
||||
int getQuestPoints();
|
||||
|
||||
void setQuestPoints(final int questPoints);
|
||||
|
||||
/**
|
||||
* Get compass target quest. Returns null if not set
|
||||
*
|
||||
* @return Quest or null
|
||||
*/
|
||||
Quest getCompassTarget();
|
||||
|
||||
/**
|
||||
* Set compass target quest. Does not update in-game
|
||||
*
|
||||
* @param quest The target quest
|
||||
*/
|
||||
void setCompassTarget(final Quest quest);
|
||||
|
||||
ConcurrentHashMap<Integer, Quest> getTimers();
|
||||
|
||||
void setTimers(final ConcurrentHashMap<Integer, Quest> timers);
|
||||
|
||||
void removeTimer(final Integer timerId);
|
||||
|
||||
ConcurrentHashMap<Quest, Integer> getCurrentQuests();
|
||||
|
||||
void setCurrentQuests(final ConcurrentHashMap<Quest, Integer> currentQuests);
|
||||
|
||||
ConcurrentSkipListSet<Quest> getCompletedQuests();
|
||||
|
||||
void setCompletedQuests(final ConcurrentSkipListSet<Quest> completedQuests);
|
||||
|
||||
ConcurrentHashMap<Quest, Long> getCompletedTimes();
|
||||
|
||||
void setCompletedTimes(final ConcurrentHashMap<Quest, Long> completedTimes);
|
||||
|
||||
ConcurrentHashMap<Quest, Integer> getAmountsCompleted();
|
||||
|
||||
void setAmountsCompleted(final ConcurrentHashMap<Quest, Integer> amountsCompleted);
|
||||
|
||||
Player getPlayer();
|
||||
|
||||
OfflinePlayer getOfflinePlayer();
|
||||
|
||||
void sendMessage(final String message);
|
||||
|
||||
Stage getCurrentStage(final Quest quest);
|
||||
|
||||
QuestProgress getQuestDataOrDefault(final Quest quest);
|
||||
|
||||
boolean hasJournal();
|
||||
|
||||
ItemStack getJournal();
|
||||
|
||||
int getJournalIndex();
|
||||
|
||||
void updateJournal();
|
||||
|
||||
boolean offerQuest(final Quest quest, final boolean giveReason);
|
||||
|
||||
boolean canAcceptOffer(final Quest quest, final boolean giveReason);
|
||||
|
||||
boolean isOnTime(final Quest quest, final boolean giveReason);
|
||||
|
||||
void takeQuest(final Quest quest, final boolean ignoreRequirements);
|
||||
|
||||
boolean abandonQuest(final Quest quest, final String message);
|
||||
|
||||
boolean abandonQuest(final Quest quest, final String[] messages);
|
||||
|
||||
void quitQuest(final Quest quest, final String message);
|
||||
|
||||
void quitQuest(final Quest quest, final String[] messages);
|
||||
|
||||
void listQuests(final Quester quester, final int page);
|
||||
|
||||
LinkedList<String> getCurrentRequirements(final Quest quest, final boolean ignoreOverrides);
|
||||
|
||||
LinkedList<Objective> getCurrentObjectives(final Quest quest, final boolean ignoreOverrides, final boolean formatNames);
|
||||
|
||||
void showCurrentObjectives(final Quest quest, final Quester quester, final boolean ignoreOverrides);
|
||||
|
||||
boolean hasObjective(final Quest quest, final ObjectiveType type);
|
||||
|
||||
boolean hasCustomObjective(final Quest quest, final String name);
|
||||
|
||||
void showCurrentConditions(final Quest quest, final Quester quester);
|
||||
|
||||
void breakBlock(final Quest quest, final ItemStack itemStack);
|
||||
|
||||
void damageBlock(final Quest quest, final ItemStack itemStack);
|
||||
|
||||
void placeBlock(final Quest quest, final ItemStack itemStack);
|
||||
|
||||
void useBlock(final Quest quest, final ItemStack itemStack);
|
||||
|
||||
void cutBlock(final Quest quest, final ItemStack itemStack);
|
||||
|
||||
void craftItem(final Quest quest, final ItemStack itemStack);
|
||||
|
||||
void smeltItem(final Quest quest, final ItemStack itemStack);
|
||||
|
||||
void enchantBook(final Quest quest, final ItemStack itemStack, final Map<Enchantment, Integer> enchantsToAdd);
|
||||
|
||||
void enchantItem(final Quest quest, final ItemStack itemStack);
|
||||
|
||||
void brewItem(final Quest quest, final ItemStack itemStack);
|
||||
|
||||
void consumeItem(final Quest quest, final ItemStack itemStack);
|
||||
|
||||
void deliverToNPC(final Quest quest, final UUID npc, final ItemStack itemStack);
|
||||
|
||||
void interactWithNPC(final Quest quest, final UUID npc);
|
||||
|
||||
void killNPC(final Quest quest, final UUID npc);
|
||||
|
||||
void milkCow(final Quest quest);
|
||||
|
||||
void catchFish(final Quest quest);
|
||||
|
||||
void killMob(final Quest quest, final Location killedLocation, final EntityType entityType);
|
||||
|
||||
void killPlayer(final Quest quest, final Player player);
|
||||
|
||||
void reachLocation(final Quest quest, final Location location);
|
||||
|
||||
void tameMob(final Quest quest, final EntityType entityType);
|
||||
|
||||
void shearSheep(final Quest quest, final DyeColor color);
|
||||
|
||||
void sayPassword(final Quest quest, final AsyncPlayerChatEvent evt);
|
||||
|
||||
void finishObjective(final Quest quest, final Objective objective, final EntityType mob,
|
||||
final String extra, final UUID npc, final Location location, final DyeColor color,
|
||||
final String pass, final CustomObjective co);
|
||||
|
||||
boolean testComplete(final Quest quest);
|
||||
|
||||
void addEmptiesFor(final Quest quest, final int stage);
|
||||
|
||||
boolean saveData();
|
||||
|
||||
long getCompletionDifference(final Quest quest);
|
||||
|
||||
long getRemainingCooldown(final Quest quest);
|
||||
|
||||
FileConfiguration getBaseData();
|
||||
|
||||
boolean hasData();
|
||||
|
||||
boolean hasBaseData();
|
||||
|
||||
void startStageTimer(final Quest quest);
|
||||
|
||||
void stopStageTimer(final Quest quest);
|
||||
|
||||
long getStageTime(final Quest quest);
|
||||
|
||||
void checkQuest(final Quest quest);
|
||||
|
||||
void showGUIDisplay(final UUID npc, final LinkedList<Quest> quests);
|
||||
|
||||
void hardQuit(final Quest quest);
|
||||
|
||||
void hardRemove(final Quest quest);
|
||||
|
||||
void hardClear();
|
||||
|
||||
void hardStagePut(final Quest key, final Integer val);
|
||||
|
||||
void hardDataPut(final Quest key, final QuestProgress val);
|
||||
|
||||
boolean canUseCompass();
|
||||
|
||||
void resetCompass();
|
||||
|
||||
void findCompassTarget();
|
||||
|
||||
void findNextCompassTarget(final boolean notify);
|
||||
|
||||
boolean hasItem(final ItemStack is);
|
||||
|
||||
Set<String> dispatchMultiplayerEverything(final Quest quest, final ObjectiveType type,
|
||||
final BiFunction<Quester, Quest, Void> fun);
|
||||
|
||||
Set<String> dispatchMultiplayerObjectives(final Quest quest, final Stage currentStage,
|
||||
final Function<Quester, Void> fun);
|
||||
|
||||
List<Quester> getMultiplayerQuesters(final Quest quest);
|
||||
|
||||
boolean meetsCondition(final Quest quest, final boolean giveReason);
|
||||
|
||||
boolean isSelectingBlock();
|
||||
|
||||
boolean isInRegion(final String regionID);
|
||||
|
||||
boolean canAcceptQuest(final UUID npc);
|
||||
|
||||
boolean canAcceptCompletedQuest(final UUID npc);
|
||||
|
||||
boolean canAcceptCompletedRedoableQuest(final UUID npc);
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.quests;
|
||||
|
||||
import me.pikamug.quests.actions.Action;
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.quests.components.Options;
|
||||
import me.pikamug.quests.quests.components.Planner;
|
||||
import me.pikamug.quests.quests.components.Requirements;
|
||||
import me.pikamug.quests.quests.components.Rewards;
|
||||
import me.pikamug.quests.quests.components.Stage;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface Quest extends Comparable<Quest> {
|
||||
|
||||
String getId();
|
||||
|
||||
void setId(String id);
|
||||
|
||||
String getName();
|
||||
|
||||
void setName(final String name);
|
||||
|
||||
String getDescription();
|
||||
|
||||
void setDescription(final String description);
|
||||
|
||||
String getFinished();
|
||||
|
||||
void setFinished(final String finished);
|
||||
|
||||
String getRegionStart();
|
||||
|
||||
void setRegionStart(final String regionStart);
|
||||
|
||||
Stage getStage(final int index);
|
||||
|
||||
LinkedList<Stage> getStages();
|
||||
|
||||
UUID getNpcStart();
|
||||
|
||||
void setNpcStart(final UUID npcStart);
|
||||
|
||||
String getNpcStartName();
|
||||
|
||||
Action getInitialAction();
|
||||
|
||||
void setInitialAction(final Action initialAction);
|
||||
|
||||
Requirements getRequirements();
|
||||
|
||||
void setRequirements(final Requirements requirements);
|
||||
|
||||
Planner getPlanner();
|
||||
|
||||
void setPlanner(final Planner planner);
|
||||
|
||||
Rewards getRewards();
|
||||
|
||||
void setRewards(final Rewards rewards);
|
||||
|
||||
Options getOptions();
|
||||
|
||||
void setOptions(final Options options);
|
||||
|
||||
void nextStage(final Quester quester, final boolean allowSharedProgress);
|
||||
|
||||
void setStage(final Quester quester, final int stage);
|
||||
|
||||
boolean updateCompass(final Quester quester, final Stage stage);
|
||||
|
||||
boolean testRequirements(final Quester quester);
|
||||
|
||||
void completeQuest(final Quester quester);
|
||||
|
||||
void completeQuest(final Quester quester, final boolean allowMultiplayer);
|
||||
|
||||
void failQuest(final Quester quester);
|
||||
|
||||
void failQuest(final Quester quester, final boolean ignoreFailAction);
|
||||
|
||||
boolean isInRegionStart(final Quester quester);
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.quests;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.ConversationFactory;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
|
||||
public interface QuestFactory {
|
||||
|
||||
ConcurrentSkipListSet<UUID> getSelectingNpcs();
|
||||
|
||||
void setSelectingNpcs(final ConcurrentSkipListSet<UUID> selectingNpcs);
|
||||
|
||||
List<String> getNamesOfQuestsBeingEdited();
|
||||
|
||||
void setNamesOfQuestsBeingEdited(final List<String> questNames);
|
||||
|
||||
ConversationFactory getConversationFactory();
|
||||
|
||||
Prompt returnToMenu(final ConversationContext context);
|
||||
|
||||
void loadQuest(final ConversationContext context, final Quest q);
|
||||
|
||||
void deleteQuest(final ConversationContext context);
|
||||
|
||||
void saveQuest(final ConversationContext context, final ConfigurationSection section);
|
||||
|
||||
/*void saveRequirements(final ConversationContext context, final ConfigurationSection section);
|
||||
|
||||
void saveStages(final ConversationContext context, final ConfigurationSection section);
|
||||
|
||||
void saveRewards(final ConversationContext context, final ConfigurationSection section);
|
||||
|
||||
void savePlanner(final ConversationContext context, final ConfigurationSection section);
|
||||
|
||||
void saveOptions(final ConversationContext context, final ConfigurationSection section);*/
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.quests.components;
|
||||
|
||||
import me.pikamug.quests.enums.ObjectiveType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface Objective {
|
||||
ObjectiveType getType();
|
||||
|
||||
String getMessage();
|
||||
|
||||
int getProgress();
|
||||
|
||||
int getGoal();
|
||||
|
||||
@NotNull Object getProgressObject();
|
||||
|
||||
@NotNull Object getGoalObject();
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.quests.components;
|
||||
|
||||
public interface Options {
|
||||
boolean canAllowCommands();
|
||||
|
||||
void setAllowCommands(final boolean allowCommands);
|
||||
|
||||
boolean canAllowQuitting();
|
||||
|
||||
void setAllowQuitting(final boolean allowQuitting);
|
||||
|
||||
boolean canIgnoreSilkTouch();
|
||||
|
||||
void setIgnoreSilkTouch(final boolean ignoreSilkTouch);
|
||||
|
||||
String getExternalPartyPlugin();
|
||||
|
||||
void setExternalPartyPlugin(final String externalPartyPlugin);
|
||||
|
||||
boolean canUsePartiesPlugin();
|
||||
|
||||
void setUsePartiesPlugin(final boolean usePartiesPlugin);
|
||||
|
||||
int getShareProgressLevel();
|
||||
|
||||
void setShareProgressLevel(final int shareProgressLevel);
|
||||
|
||||
boolean canShareSameQuestOnly();
|
||||
|
||||
void setShareSameQuestOnly(final boolean shareSameQuestOnly);
|
||||
|
||||
double getShareDistance();
|
||||
|
||||
void setShareDistance(final double shareDistance);
|
||||
|
||||
boolean canHandleOfflinePlayers();
|
||||
|
||||
void setHandleOfflinePlayers(final boolean handleOfflinePlayers);
|
||||
|
||||
boolean canIgnoreBlockReplace();
|
||||
|
||||
void setIgnoreBlockReplace(final boolean ignoreBlockReplace);
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.quests.components;
|
||||
|
||||
public interface Planner {
|
||||
String getStart();
|
||||
|
||||
long getStartInMillis();
|
||||
|
||||
boolean hasStart();
|
||||
|
||||
void setStart(final String start);
|
||||
|
||||
String getEnd();
|
||||
|
||||
long getEndInMillis();
|
||||
|
||||
boolean hasEnd();
|
||||
|
||||
void setEnd(final String end);
|
||||
|
||||
long getRepeat();
|
||||
|
||||
boolean hasRepeat();
|
||||
|
||||
void setRepeat(final long repeat);
|
||||
|
||||
long getCooldown();
|
||||
|
||||
boolean hasCooldown();
|
||||
|
||||
void setCooldown(final long cooldown);
|
||||
|
||||
boolean getOverride();
|
||||
|
||||
void setOverride(final boolean override);
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.quests.components;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface Requirements {
|
||||
int getMoney();
|
||||
|
||||
void setMoney(final int money);
|
||||
|
||||
int getQuestPoints();
|
||||
|
||||
void setQuestPoints(final int questPoints);
|
||||
|
||||
int getExp();
|
||||
|
||||
void setExp(final int exp);
|
||||
|
||||
List<?> getItems();
|
||||
|
||||
List<Boolean> getRemoveItems();
|
||||
|
||||
void setRemoveItems(final List<Boolean> removeItems);
|
||||
|
||||
List<String> getNeededQuestIds();
|
||||
|
||||
void setNeededQuestIds(final List<String> neededQuests);
|
||||
|
||||
List<String> getBlockQuestIds();
|
||||
|
||||
void setBlockQuestIds(final List<String> blockQuests);
|
||||
|
||||
List<String> getPermissions();
|
||||
|
||||
void setPermissions(final List<String> permissions);
|
||||
|
||||
List<String> getMcmmoSkills();
|
||||
|
||||
void setMcmmoSkills(final List<String> mcmmoSkills);
|
||||
|
||||
List<Integer> getMcmmoAmounts();
|
||||
|
||||
void setMcmmoAmounts(final List<Integer> mcmmoAmounts);
|
||||
|
||||
String getHeroesPrimaryClass();
|
||||
|
||||
void setHeroesPrimaryClass(final String heroesPrimaryClass);
|
||||
|
||||
String getHeroesSecondaryClass();
|
||||
|
||||
void setHeroesSecondaryClass(final String heroesSecondaryClass);
|
||||
|
||||
Map<String, Map<String, Object>> getCustomRequirements();
|
||||
|
||||
void setCustomRequirements(final Map<String, Map<String, Object>> customRequirements);
|
||||
|
||||
List<String> getDetailsOverride();
|
||||
|
||||
void setDetailsOverride(final List<String> detailsOverride);
|
||||
|
||||
/**
|
||||
* Check if quest has at least one requirement
|
||||
*
|
||||
* @return true if quest contains an requirement
|
||||
*/
|
||||
boolean hasRequirement();
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.quests.components;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface Rewards {
|
||||
int getMoney();
|
||||
|
||||
void setMoney(final int money);
|
||||
|
||||
int getQuestPoints();
|
||||
|
||||
void setQuestPoints(final int questPoints);
|
||||
|
||||
int getExp();
|
||||
|
||||
void setExp(final int exp);
|
||||
|
||||
List<String> getCommands();
|
||||
|
||||
void setCommands(final List<String> commands);
|
||||
|
||||
List<String> getCommandsOverrideDisplay();
|
||||
|
||||
void setCommandsOverrideDisplay(final List<String> commandsOverrideDisplay);
|
||||
|
||||
List<String> getPermissions();
|
||||
|
||||
void setPermissions(final List<String> permissions);
|
||||
|
||||
List<String> getPermissionWorlds();
|
||||
|
||||
void setPermissionWorlds(final List<String> worldNames);
|
||||
|
||||
List<?> getItems();
|
||||
|
||||
List<String> getMcmmoSkills();
|
||||
|
||||
void setMcmmoSkills(final List<String> mcmmoSkills);
|
||||
|
||||
List<Integer> getMcmmoAmounts();
|
||||
|
||||
void setMcmmoAmounts(final List<Integer> mcmmoAmounts);
|
||||
|
||||
List<String> getHeroesClasses();
|
||||
|
||||
void setHeroesClasses(final List<String> heroesClasses);
|
||||
|
||||
List<Double> getHeroesAmounts();
|
||||
|
||||
void setHeroesAmounts(final List<Double> heroesAmounts);
|
||||
|
||||
int getPartiesExperience();
|
||||
|
||||
void setPartiesExperience(final int partiesExperience);
|
||||
|
||||
List<String> getPhatLoots();
|
||||
|
||||
void setPhatLoots(final List<String> phatLoots);
|
||||
|
||||
Map<String, Map<String, Object>> getCustomRewards();
|
||||
|
||||
void setCustomRewards(final Map<String, Map<String, Object>> customRewards);
|
||||
|
||||
List<String> getDetailsOverride();
|
||||
|
||||
void setDetailsOverride(final List<String> detailsOverride);
|
||||
|
||||
/**
|
||||
* Check if quest has at least one reward
|
||||
*
|
||||
* @return true if quest contains an reward
|
||||
*/
|
||||
boolean hasReward();
|
||||
}
|
|
@ -0,0 +1,220 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.quests.components;
|
||||
|
||||
import me.pikamug.quests.actions.Action;
|
||||
import me.pikamug.quests.conditions.Condition;
|
||||
import me.pikamug.quests.enums.ObjectiveType;
|
||||
import me.pikamug.quests.module.CustomObjective;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface Stage {
|
||||
LinkedList<?> getBlocksToBreak();
|
||||
|
||||
LinkedList<?> getBlocksToDamage();
|
||||
|
||||
LinkedList<?> getBlocksToPlace();
|
||||
|
||||
LinkedList<?> getBlocksToUse();
|
||||
|
||||
LinkedList<?> getBlocksToCut();
|
||||
|
||||
LinkedList<?> getItemsToCraft();
|
||||
|
||||
LinkedList<?> getItemsToSmelt();
|
||||
|
||||
LinkedList<?> getItemsToEnchant();
|
||||
|
||||
LinkedList<?> getItemsToBrew();
|
||||
|
||||
LinkedList<?> getItemsToConsume();
|
||||
|
||||
LinkedList<?> getItemsToDeliver();
|
||||
|
||||
LinkedList<UUID> getItemDeliveryTargets();
|
||||
|
||||
void setItemDeliveryTargets(final LinkedList<UUID> itemDeliveryTargets);
|
||||
|
||||
LinkedList<String> getDeliverMessages();
|
||||
|
||||
void setDeliverMessages(final LinkedList<String> deliverMessages);
|
||||
|
||||
LinkedList<UUID> getNpcsToInteract();
|
||||
|
||||
void setNpcsToInteract(final LinkedList<UUID> npcsToInteract);
|
||||
|
||||
LinkedList<UUID> getNpcsToKill();
|
||||
|
||||
void setNpcsToKill(final LinkedList<UUID> npcsToKill);
|
||||
|
||||
LinkedList<Integer> getNpcNumToKill();
|
||||
|
||||
void setNpcNumToKill(final LinkedList<Integer> npcNumToKill);
|
||||
|
||||
LinkedList<?> getMobsToKill();
|
||||
|
||||
LinkedList<Integer> getMobNumToKill();
|
||||
|
||||
void setMobNumToKill(final LinkedList<Integer> mobNumToKill);
|
||||
|
||||
LinkedList<?> getLocationsToKillWithin();
|
||||
|
||||
LinkedList<Integer> getRadiiToKillWithin();
|
||||
|
||||
void setRadiiToKillWithin(final LinkedList<Integer> radiiToKillWithin);
|
||||
|
||||
LinkedList<String> getKillNames();
|
||||
|
||||
void setKillNames(final LinkedList<String> killNames);
|
||||
|
||||
LinkedList<?> getLocationsToReach();
|
||||
|
||||
LinkedList<Integer> getRadiiToReachWithin();
|
||||
|
||||
void setRadiiToReachWithin(final LinkedList<Integer> radiiToReachWithin);
|
||||
|
||||
LinkedList<?> getWorldsToReachWithin();
|
||||
|
||||
LinkedList<String> getLocationNames();
|
||||
|
||||
void setLocationNames(final LinkedList<String> locationNames);
|
||||
|
||||
LinkedList<?> getMobsToTame();
|
||||
|
||||
LinkedList<Integer> getMobNumToTame();
|
||||
|
||||
void setMobNumToTame(final LinkedList<Integer> mobNumToTame);
|
||||
|
||||
Integer getFishToCatch();
|
||||
|
||||
void setFishToCatch(final Integer fishToCatch);
|
||||
|
||||
Integer getCowsToMilk();
|
||||
|
||||
void setCowsToMilk(final Integer cowsToMilk);
|
||||
|
||||
Integer getPlayersToKill();
|
||||
|
||||
void setPlayersToKill(final Integer playersToKill);
|
||||
|
||||
LinkedList<?> getSheepToShear();
|
||||
|
||||
LinkedList<Integer> getSheepNumToShear();
|
||||
|
||||
void setSheepNumToShear(final LinkedList<Integer> sheepNumToShear);
|
||||
|
||||
LinkedList<String> getPasswordDisplays();
|
||||
|
||||
void setPasswordDisplays(final LinkedList<String> passwordDisplays);
|
||||
|
||||
LinkedList<String> getPasswordPhrases();
|
||||
|
||||
void setPasswordPhrases(final LinkedList<String> passwordPhrases);
|
||||
|
||||
String getScript();
|
||||
|
||||
void setScript(final String script);
|
||||
|
||||
Action getStartAction();
|
||||
|
||||
void setStartAction(final Action startAction);
|
||||
|
||||
Action getFinishAction();
|
||||
|
||||
void setFinishAction(final Action finishAction);
|
||||
|
||||
Action getFailAction();
|
||||
|
||||
void setFailAction(final Action failAction);
|
||||
|
||||
Action getDeathAction();
|
||||
|
||||
void setDeathAction(final Action deathAction);
|
||||
|
||||
Map<String, Action> getChatActions();
|
||||
|
||||
void setChatActions(final Map<String, Action> chatActions);
|
||||
|
||||
Map<String, Action> getCommandActions();
|
||||
|
||||
void setCommandActions(final Map<String, Action> commandActions);
|
||||
|
||||
Action getDisconnectAction();
|
||||
|
||||
void setDisconnectAction(final Action disconnectAction);
|
||||
|
||||
Condition getCondition();
|
||||
|
||||
void setCondition(final Condition condition);
|
||||
|
||||
long getDelay();
|
||||
|
||||
void setDelay(final long delay);
|
||||
|
||||
String getDelayMessage();
|
||||
|
||||
void setDelayMessage(final String delayMessage);
|
||||
|
||||
String getCompleteMessage();
|
||||
|
||||
void setCompleteMessage(final String completeMessage);
|
||||
|
||||
String getStartMessage();
|
||||
|
||||
void setStartMessage(final String startMessage);
|
||||
|
||||
LinkedList<String> getObjectiveOverrides();
|
||||
|
||||
void setObjectiveOverrides(final LinkedList<String> objectiveOverrides);
|
||||
|
||||
LinkedList<CustomObjective> getCustomObjectives();
|
||||
|
||||
void clearCustomObjectives();
|
||||
|
||||
LinkedList<Integer> getCustomObjectiveCounts();
|
||||
|
||||
void clearCustomObjectiveCounts();
|
||||
|
||||
LinkedList<String> getCustomObjectiveDisplays();
|
||||
|
||||
void clearCustomObjectiveDisplays();
|
||||
|
||||
LinkedList<Map.Entry<String, Object>> getCustomObjectiveData();
|
||||
|
||||
void clearCustomObjectiveData();
|
||||
|
||||
/**
|
||||
* Check if stage has at least one objective<p>
|
||||
*
|
||||
* Excludes start/complete message, delay, and objective-override
|
||||
*
|
||||
* @return true if stage contains an objective
|
||||
*/
|
||||
boolean hasObjective();
|
||||
|
||||
/**
|
||||
* Check if stage has at least one objective of which the target can be located easily<p>
|
||||
*
|
||||
* @return true if stage contains a locatable objective
|
||||
*/
|
||||
boolean hasLocatableObjective();
|
||||
|
||||
/**
|
||||
* Check if stage has the specified type of objective<p>
|
||||
*
|
||||
* @param type The type of objective to check for
|
||||
* @return true if stage contains specified objective
|
||||
*/
|
||||
boolean containsObjective(final ObjectiveType type);
|
||||
}
|
|
@ -1,120 +1,125 @@
|
|||
/*******************************************************************************************************
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************************************/
|
||||
|
||||
package me.blackvein.quests.storage;
|
||||
|
||||
import me.blackvein.quests.Quester;
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.storage.implementation.StorageImplementation;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
|
||||
public class Storage {
|
||||
private final Quests plugin;
|
||||
private final StorageImplementation implementation;
|
||||
|
||||
public Storage(final Quests plugin, final StorageImplementation implementation) {
|
||||
this.plugin = plugin;
|
||||
this.implementation = implementation;
|
||||
}
|
||||
|
||||
public StorageImplementation getImplementation() {
|
||||
return implementation;
|
||||
}
|
||||
|
||||
public Collection<StorageImplementation> getImplementations() {
|
||||
return Collections.singleton(implementation);
|
||||
}
|
||||
|
||||
private <T> CompletableFuture<T> makeFuture(final Callable<T> supplier) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
try {
|
||||
return supplier.call();
|
||||
} catch (final Exception e) {
|
||||
if (e instanceof RuntimeException) {
|
||||
throw (RuntimeException) e;
|
||||
}
|
||||
throw new CompletionException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private CompletableFuture<Void> makeFuture(final Runnable runnable) {
|
||||
return CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
runnable.run();
|
||||
} catch (final Exception e) {
|
||||
if (e instanceof RuntimeException) {
|
||||
throw (RuntimeException) e;
|
||||
}
|
||||
throw new CompletionException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return implementation.getImplementationName();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
try {
|
||||
implementation.init();
|
||||
} catch (final Exception e) {
|
||||
plugin.getLogger().severe("Failed to initialize storage implementation");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
try {
|
||||
implementation.close();
|
||||
} catch (final Exception e) {
|
||||
plugin.getLogger().severe("Failed to close storage implementation");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public CompletableFuture<Quester> loadQuester(final UUID uniqueId) {
|
||||
return makeFuture(() -> {
|
||||
return implementation.loadQuester(uniqueId);
|
||||
});
|
||||
}
|
||||
|
||||
public CompletableFuture<Void> saveQuester(final Quester quester) {
|
||||
return makeFuture(() -> {
|
||||
try {
|
||||
implementation.saveQuester(quester);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public CompletableFuture<Void> deleteQuester(final UUID uniqueId) {
|
||||
return makeFuture(() -> {
|
||||
try {
|
||||
implementation.deleteQuester(uniqueId);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public CompletableFuture<String> getQuesterLastKnownName(final UUID uniqueId) {
|
||||
return makeFuture(() -> implementation.getQuesterLastKnownName(uniqueId));
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.storage;
|
||||
|
||||
import me.pikamug.quests.Quests;
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.storage.implementation.QuesterStorageImpl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
|
||||
public class QuesterStorage {
|
||||
private final Quests plugin;
|
||||
private final QuesterStorageImpl implementation;
|
||||
|
||||
public QuesterStorage(final Quests plugin, final QuesterStorageImpl implementation) {
|
||||
this.plugin = plugin;
|
||||
this.implementation = implementation;
|
||||
}
|
||||
|
||||
public QuesterStorageImpl getImplementation() {
|
||||
return implementation;
|
||||
}
|
||||
|
||||
public Collection<QuesterStorageImpl> getImplementations() {
|
||||
return Collections.singleton(implementation);
|
||||
}
|
||||
|
||||
private <T> CompletableFuture<T> makeFuture(final Callable<T> supplier) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
try {
|
||||
return supplier.call();
|
||||
} catch (final Exception e) {
|
||||
if (e instanceof RuntimeException) {
|
||||
throw (RuntimeException) e;
|
||||
}
|
||||
throw new CompletionException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private CompletableFuture<Void> makeFuture(final Runnable runnable) {
|
||||
return CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
runnable.run();
|
||||
} catch (final Exception e) {
|
||||
throw (RuntimeException) e;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return implementation.getImplementationName();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
try {
|
||||
implementation.init();
|
||||
} catch (final Exception e) {
|
||||
// Failed to initialize storage implementation
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
try {
|
||||
implementation.close();
|
||||
} catch (final Exception e) {
|
||||
// Failed to close storage implementation
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public CompletableFuture<Quester> loadQuester(final UUID uniqueId) {
|
||||
return makeFuture(() -> implementation.loadQuester(uniqueId));
|
||||
}
|
||||
|
||||
public CompletableFuture<Void> saveQuester(final Quester quester) {
|
||||
return makeFuture(() -> {
|
||||
try {
|
||||
implementation.saveQuester(quester);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public CompletableFuture<Void> saveOfflineQuesters() {
|
||||
return makeFuture(() -> {
|
||||
try {
|
||||
for (Quester quester : plugin.getOfflineQuesters()) {
|
||||
implementation.saveQuester(quester);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public CompletableFuture<Void> deleteQuester(final UUID uniqueId) {
|
||||
return makeFuture(() -> {
|
||||
try {
|
||||
implementation.deleteQuester(uniqueId);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public CompletableFuture<String> getQuesterLastKnownName(final UUID uniqueId) {
|
||||
return makeFuture(() -> implementation.getQuesterLastKnownName(uniqueId));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.storage.implementation;
|
||||
|
||||
import me.pikamug.quests.Quests;
|
||||
import me.pikamug.quests.actions.Action;
|
||||
import me.pikamug.quests.exceptions.ActionFormatException;
|
||||
|
||||
public interface ActionStorageImpl {
|
||||
Quests getPlugin();
|
||||
|
||||
String getImplementationName();
|
||||
|
||||
void init() throws Exception;
|
||||
|
||||
void close();
|
||||
|
||||
Action loadAction(final String name) throws ActionFormatException;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.storage.implementation;
|
||||
|
||||
import me.pikamug.quests.Quests;
|
||||
import me.pikamug.quests.conditions.Condition;
|
||||
import me.pikamug.quests.exceptions.ConditionFormatException;
|
||||
|
||||
public interface ConditionStorageImpl {
|
||||
Quests getPlugin();
|
||||
|
||||
String getImplementationName();
|
||||
|
||||
void init() throws Exception;
|
||||
|
||||
void close();
|
||||
|
||||
Condition loadCondition(final String name) throws ConditionFormatException;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package me.pikamug.quests.storage.implementation;
|
||||
|
||||
import me.pikamug.quests.Quests;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public interface ModuleStorageImpl {
|
||||
Quests getPlugin();
|
||||
|
||||
String getImplementationName();
|
||||
|
||||
void init();
|
||||
|
||||
void close();
|
||||
|
||||
void loadModule(final File jar);
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.storage.implementation;
|
||||
|
||||
import me.pikamug.quests.Quests;
|
||||
import me.pikamug.quests.exceptions.QuestFormatException;
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
|
||||
public interface QuestStorageImpl {
|
||||
Quests getPlugin();
|
||||
|
||||
String getImplementationName();
|
||||
|
||||
void init() throws Exception;
|
||||
|
||||
void close();
|
||||
|
||||
Quest loadQuest(final String name) throws QuestFormatException;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.storage.implementation;
|
||||
|
||||
import me.pikamug.quests.Quests;
|
||||
import me.pikamug.quests.player.Quester;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface QuesterStorageImpl {
|
||||
Quests getPlugin();
|
||||
|
||||
String getImplementationName();
|
||||
|
||||
void init() throws Exception;
|
||||
|
||||
void close();
|
||||
|
||||
Quester loadQuester(final UUID uniqueId) throws Exception;
|
||||
|
||||
void saveQuester(final Quester quester) throws Exception;
|
||||
|
||||
void deleteQuester(final UUID uniqueId) throws Exception;
|
||||
|
||||
String getQuesterLastKnownName(final UUID uniqueId) throws Exception;
|
||||
|
||||
Collection<UUID> getSavedUniqueIds() throws Exception;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.storage.implementation.custom;
|
||||
|
||||
import me.pikamug.quests.Quests;
|
||||
import me.pikamug.quests.storage.implementation.QuesterStorageImpl;
|
||||
|
||||
public interface CustomStorageProvider {
|
||||
QuesterStorageImpl provide(Quests plugin);
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.storage.implementation.custom;
|
||||
|
||||
public final class CustomStorageProviders {
|
||||
private CustomStorageProviders() {}
|
||||
|
||||
private static CustomStorageProvider provider = null;
|
||||
|
||||
public static void register(final CustomStorageProvider provider) {
|
||||
CustomStorageProviders.provider = provider;
|
||||
}
|
||||
|
||||
public static CustomStorageProvider getProvider() {
|
||||
if (provider == null) {
|
||||
throw new IllegalStateException("Provider not found.");
|
||||
}
|
||||
|
||||
return provider;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.storage.implementation.sql.connection;
|
||||
|
||||
import me.pikamug.quests.Quests;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public interface ConnectionFactory {
|
||||
String getImplementationName();
|
||||
|
||||
void init(Quests plugin);
|
||||
|
||||
void close() throws Exception;
|
||||
|
||||
default Map<String, String> getMeta() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
Function<String, String> getStatementProcessor();
|
||||
|
||||
Connection getConnection() throws SQLException;
|
||||
}
|
|
@ -1,141 +1,136 @@
|
|||
/*******************************************************************************************************
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************************************/
|
||||
|
||||
package me.blackvein.quests.storage.implementation.sql.connection.hikari;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.storage.implementation.sql.connection.ConnectionFactory;
|
||||
import me.blackvein.quests.storage.misc.StorageCredentials;
|
||||
|
||||
public abstract class HikariConnectionFactory implements ConnectionFactory {
|
||||
private final StorageCredentials configuration;
|
||||
private HikariDataSource hikari;
|
||||
|
||||
public HikariConnectionFactory(final StorageCredentials configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default port used by the database
|
||||
*
|
||||
* @return the default port
|
||||
*/
|
||||
protected abstract String defaultPort();
|
||||
|
||||
/**
|
||||
* Configures the {@link HikariConfig} with the relevant database properties.
|
||||
*
|
||||
* <p>Each driver does this slightly differently.</p>
|
||||
*
|
||||
* @param config the hikari config
|
||||
* @param address the database address
|
||||
* @param port the database port
|
||||
* @param databaseName the database name
|
||||
* @param username the database username
|
||||
* @param password the database password
|
||||
*/
|
||||
protected abstract void configureDatabase(HikariConfig config, String address, String port, String databaseName,
|
||||
String username, String password);
|
||||
|
||||
/**
|
||||
* Allows the connection factory instance to override certain properties before they are set.
|
||||
*
|
||||
* @param properties the current properties
|
||||
*/
|
||||
protected void overrideProperties(final Map<String, String> properties) {
|
||||
// https://github.com/brettwooldridge/HikariCP/wiki/Rapid-Recovery
|
||||
properties.putIfAbsent("socketTimeout", String.valueOf(TimeUnit.SECONDS.toMillis(30)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given connection properties onto the config.
|
||||
*
|
||||
* @param config the hikari config
|
||||
* @param properties the properties
|
||||
*/
|
||||
protected void setProperties(final HikariConfig config, final Map<String, String> properties) {
|
||||
for (final Map.Entry<String, String> property : properties.entrySet()) {
|
||||
config.addDataSourceProperty(property.getKey(), property.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(final Quests plugin) {
|
||||
final HikariConfig config = new HikariConfig();
|
||||
config.setPoolName("quests-hikari");
|
||||
|
||||
final String[] addressSplit = configuration.getAddress().split(":");
|
||||
final String address = addressSplit[0];
|
||||
final String port = addressSplit.length > 1 ? addressSplit[1] : defaultPort();
|
||||
|
||||
configureDatabase(config, address, port, configuration.getDatabase(), configuration.getUsername(),
|
||||
configuration.getPassword());
|
||||
|
||||
final Map<String, String> properties = new HashMap<>(this.configuration.getProperties());
|
||||
|
||||
overrideProperties(properties);
|
||||
|
||||
setProperties(config, properties);
|
||||
|
||||
config.setMaximumPoolSize(this.configuration.getMaxPoolSize());
|
||||
config.setMinimumIdle(this.configuration.getMinIdleConnections());
|
||||
config.setMaxLifetime(this.configuration.getMaxLifetime());
|
||||
config.setConnectionTimeout(this.configuration.getConnectionTimeout());
|
||||
|
||||
hikari = new HikariDataSource(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
if (hikari != null) {
|
||||
hikari.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection getConnection() throws SQLException {
|
||||
if (hikari == null) {
|
||||
throw new SQLException("Unable to get a connection from the pool because hikari is null");
|
||||
}
|
||||
|
||||
final Connection connection = hikari.getConnection();
|
||||
if (connection == null) {
|
||||
throw new SQLException("Unable to get a connection from the pool because getConnection returned null");
|
||||
}
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
public static String identifyClassLoader(final ClassLoader classLoader) throws ReflectiveOperationException {
|
||||
final Class<?> pluginClassLoaderClass = Class.forName("org.bukkit.plugin.java.PluginClassLoader");
|
||||
if (pluginClassLoaderClass.isInstance(classLoader)) {
|
||||
final Method getPluginMethod = pluginClassLoaderClass.getDeclaredMethod("getPlugin");
|
||||
getPluginMethod.setAccessible(true);
|
||||
|
||||
final JavaPlugin plugin = (JavaPlugin) getPluginMethod.invoke(classLoader);
|
||||
return plugin.getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.storage.implementation.sql.connection.hikari;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import me.pikamug.quests.Quests;
|
||||
import me.pikamug.quests.storage.implementation.sql.connection.ConnectionFactory;
|
||||
import me.pikamug.quests.storage.misc.StorageCredentials;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public abstract class HikariConnectionFactory implements ConnectionFactory {
|
||||
private final StorageCredentials configuration;
|
||||
private HikariDataSource hikari;
|
||||
|
||||
public HikariConnectionFactory(final StorageCredentials configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default port used by the database
|
||||
*
|
||||
* @return the default port
|
||||
*/
|
||||
protected abstract String defaultPort();
|
||||
|
||||
/**
|
||||
* Configures the {@link HikariConfig} with the relevant database properties.
|
||||
*
|
||||
* <p>Each driver does this slightly differently.</p>
|
||||
*
|
||||
* @param config the hikari config
|
||||
* @param address the database address
|
||||
* @param port the database port
|
||||
* @param databaseName the database name
|
||||
* @param username the database username
|
||||
* @param password the database password
|
||||
*/
|
||||
protected abstract void configureDatabase(HikariConfig config, String address, String port, String databaseName,
|
||||
String username, String password);
|
||||
|
||||
/**
|
||||
* Allows the connection factory instance to override certain properties before they are set.
|
||||
*
|
||||
* @param properties the current properties
|
||||
*/
|
||||
protected void overrideProperties(final Map<String, String> properties) {
|
||||
// https://github.com/brettwooldridge/HikariCP/wiki/Rapid-Recovery
|
||||
properties.putIfAbsent("socketTimeout", String.valueOf(TimeUnit.SECONDS.toMillis(30)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given connection properties onto the config.
|
||||
*
|
||||
* @param config the hikari config
|
||||
* @param properties the properties
|
||||
*/
|
||||
protected void setProperties(final HikariConfig config, final Map<String, String> properties) {
|
||||
for (final Map.Entry<String, String> property : properties.entrySet()) {
|
||||
config.addDataSourceProperty(property.getKey(), property.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(final Quests plugin) {
|
||||
final HikariConfig config = new HikariConfig();
|
||||
config.setPoolName("quests-hikari");
|
||||
|
||||
final String[] addressSplit = configuration.getAddress().split(":");
|
||||
final String address = addressSplit[0];
|
||||
final String port = addressSplit.length > 1 ? addressSplit[1] : defaultPort();
|
||||
|
||||
configureDatabase(config, address, port, configuration.getDatabase(), configuration.getUsername(),
|
||||
configuration.getPassword());
|
||||
|
||||
final Map<String, String> properties = new HashMap<>(this.configuration.getProperties());
|
||||
|
||||
overrideProperties(properties);
|
||||
|
||||
setProperties(config, properties);
|
||||
|
||||
config.setMaximumPoolSize(this.configuration.getMaxPoolSize());
|
||||
config.setMinimumIdle(this.configuration.getMinIdleConnections());
|
||||
config.setMaxLifetime(this.configuration.getMaxLifetime());
|
||||
//config.setKeepaliveTime(this.configuration.getKeepAliveTime());
|
||||
config.setConnectionTimeout(this.configuration.getConnectionTimeout());
|
||||
|
||||
hikari = new HikariDataSource(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
if (hikari != null) {
|
||||
hikari.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection getConnection() throws SQLException {
|
||||
if (hikari == null) {
|
||||
throw new SQLException("Unable to get a connection from the pool because hikari is null");
|
||||
}
|
||||
|
||||
final Connection connection = hikari.getConnection();
|
||||
if (connection == null) {
|
||||
throw new SQLException("Unable to get a connection from the pool because getConnection returned null");
|
||||
}
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
/*public static String identifyClassLoader(final ClassLoader classLoader) throws ReflectiveOperationException {
|
||||
final Class<?> pluginClassLoaderClass = Class.forName("org.bukkit.plugin.java.PluginClassLoader");
|
||||
if (pluginClassLoaderClass.isInstance(classLoader)) {
|
||||
final Method getPluginMethod = pluginClassLoaderClass.getDeclaredMethod("getPlugin");
|
||||
getPluginMethod.setAccessible(true);
|
||||
|
||||
final JavaPlugin plugin = (JavaPlugin) getPluginMethod.invoke(classLoader);
|
||||
return plugin.getName();
|
||||
}
|
||||
return null;
|
||||
}*/
|
||||
}
|
|
@ -1,72 +1,69 @@
|
|||
/*******************************************************************************************************
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************************************/
|
||||
|
||||
package me.blackvein.quests.storage.implementation.sql.connection.hikari;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
|
||||
import me.blackvein.quests.storage.misc.StorageCredentials;
|
||||
|
||||
public class MySqlConnectionFactory extends HikariConnectionFactory {
|
||||
public MySqlConnectionFactory(final StorageCredentials configuration) {
|
||||
super(configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getImplementationName() {
|
||||
return "MySQL";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String defaultPort() {
|
||||
return "3306";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureDatabase(final HikariConfig config, final String address, final String port,
|
||||
final String databaseName, final String username, final String password) {
|
||||
config.setDriverClassName("com.mysql.cj.jdbc.Driver");
|
||||
config.setJdbcUrl("jdbc:mysql://" + address + ":" + port + "/" + databaseName);
|
||||
config.setUsername(username);
|
||||
config.setPassword(password);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void overrideProperties(final Map<String, String> properties) {
|
||||
// https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration
|
||||
properties.putIfAbsent("cachePrepStmts", "true");
|
||||
properties.putIfAbsent("prepStmtCacheSize", "250");
|
||||
properties.putIfAbsent("prepStmtCacheSqlLimit", "2048");
|
||||
properties.putIfAbsent("useServerPrepStmts", "true");
|
||||
properties.putIfAbsent("useLocalSessionState", "true");
|
||||
properties.putIfAbsent("rewriteBatchedStatements", "true");
|
||||
properties.putIfAbsent("cacheResultSetMetadata", "true");
|
||||
properties.putIfAbsent("cacheServerConfiguration", "true");
|
||||
properties.putIfAbsent("elideSetAutoCommits", "true");
|
||||
properties.putIfAbsent("maintainTimeStats", "false");
|
||||
properties.putIfAbsent("alwaysSendSetIsolation", "false");
|
||||
properties.putIfAbsent("cacheCallableStmts", "true");
|
||||
|
||||
// https://stackoverflow.com/a/54256150
|
||||
properties.putIfAbsent("serverTimezone", "UTC");
|
||||
|
||||
super.overrideProperties(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Function<String, String> getStatementProcessor() {
|
||||
return s -> s.replace("'", "`");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.storage.implementation.sql.connection.hikari;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import me.pikamug.quests.storage.misc.StorageCredentials;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class MySqlConnectionFactory extends HikariConnectionFactory {
|
||||
public MySqlConnectionFactory(final StorageCredentials configuration) {
|
||||
super(configuration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getImplementationName() {
|
||||
return "MySQL";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String defaultPort() {
|
||||
return "3306";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureDatabase(final HikariConfig config, final String address, final String port,
|
||||
final String databaseName, final String username, final String password) {
|
||||
config.setDriverClassName("com.mysql.cj.jdbc.Driver");
|
||||
config.setJdbcUrl("jdbc:mysql://" + address + ":" + port + "/" + databaseName);
|
||||
config.setUsername(username);
|
||||
config.setPassword(password);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void overrideProperties(final Map<String, String> properties) {
|
||||
// https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration
|
||||
properties.putIfAbsent("cachePrepStmts", "true");
|
||||
properties.putIfAbsent("prepStmtCacheSize", "250");
|
||||
properties.putIfAbsent("prepStmtCacheSqlLimit", "2048");
|
||||
properties.putIfAbsent("useServerPrepStmts", "true");
|
||||
properties.putIfAbsent("useLocalSessionState", "true");
|
||||
properties.putIfAbsent("rewriteBatchedStatements", "true");
|
||||
properties.putIfAbsent("cacheResultSetMetadata", "true");
|
||||
properties.putIfAbsent("cacheServerConfiguration", "true");
|
||||
properties.putIfAbsent("elideSetAutoCommits", "true");
|
||||
properties.putIfAbsent("maintainTimeStats", "false");
|
||||
properties.putIfAbsent("alwaysSendSetIsolation", "false");
|
||||
properties.putIfAbsent("cacheCallableStmts", "true");
|
||||
|
||||
// https://stackoverflow.com/a/54256150
|
||||
properties.putIfAbsent("serverTimezone", "UTC");
|
||||
|
||||
super.overrideProperties(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Function<String, String> getStatementProcessor() {
|
||||
return s -> s.replace('\'', '`');
|
||||
}
|
||||
}
|
|
@ -1,79 +1,83 @@
|
|||
/*******************************************************************************************************
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************************************/
|
||||
|
||||
package me.blackvein.quests.storage.misc;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class StorageCredentials {
|
||||
|
||||
private final String address;
|
||||
private final String database;
|
||||
private final String username;
|
||||
private final String password;
|
||||
private final int maxPoolSize;
|
||||
private final int minIdleConnections;
|
||||
private final int maxLifetime;
|
||||
private final int connectionTimeout;
|
||||
private final Map<String, String> properties;
|
||||
|
||||
public StorageCredentials(final String address, final String database, final String username, final String password,
|
||||
final int maxPoolSize, final int minIdleConnections, final int maxLifetime, final int connectionTimeout,
|
||||
final Map<String, String> properties) {
|
||||
this.address = address;
|
||||
this.database = database;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.maxPoolSize = maxPoolSize;
|
||||
this.minIdleConnections = minIdleConnections;
|
||||
this.maxLifetime = maxLifetime;
|
||||
this.connectionTimeout = connectionTimeout;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return Objects.requireNonNull(address, "address");
|
||||
}
|
||||
|
||||
public String getDatabase() {
|
||||
return Objects.requireNonNull(database, "database");
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return Objects.requireNonNull(username, "username");
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return Objects.requireNonNull(password, "password");
|
||||
}
|
||||
|
||||
public int getMaxPoolSize() {
|
||||
return maxPoolSize;
|
||||
}
|
||||
|
||||
public int getMinIdleConnections() {
|
||||
return minIdleConnections;
|
||||
}
|
||||
|
||||
public int getMaxLifetime() {
|
||||
return maxLifetime;
|
||||
}
|
||||
|
||||
public int getConnectionTimeout() {
|
||||
return connectionTimeout;
|
||||
}
|
||||
|
||||
public Map<String, String> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.storage.misc;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class StorageCredentials {
|
||||
|
||||
private final String address;
|
||||
private final String database;
|
||||
private final String username;
|
||||
private final String password;
|
||||
private final int maxPoolSize;
|
||||
private final int minIdleConnections;
|
||||
private final int maxLifetime;
|
||||
private final int keepAliveTime;
|
||||
private final int connectionTimeout;
|
||||
private final Map<String, String> properties;
|
||||
|
||||
public StorageCredentials(final String address, final String database, final String username, final String password,
|
||||
final int maxPoolSize, final int minIdleConnections, final int maxLifetime, final int keepAliveTime,
|
||||
final int connectionTimeout, final Map<String, String> properties) {
|
||||
this.address = address;
|
||||
this.database = database;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.maxPoolSize = maxPoolSize;
|
||||
this.minIdleConnections = minIdleConnections;
|
||||
this.maxLifetime = maxLifetime;
|
||||
this.keepAliveTime = keepAliveTime;
|
||||
this.connectionTimeout = connectionTimeout;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return Objects.requireNonNull(address, "address");
|
||||
}
|
||||
|
||||
public String getDatabase() {
|
||||
return Objects.requireNonNull(database, "database");
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return Objects.requireNonNull(username, "username");
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return Objects.requireNonNull(password, "password");
|
||||
}
|
||||
|
||||
public int getMaxPoolSize() {
|
||||
return maxPoolSize;
|
||||
}
|
||||
|
||||
public int getMinIdleConnections() {
|
||||
return minIdleConnections;
|
||||
}
|
||||
|
||||
public int getMaxLifetime() {
|
||||
return maxLifetime;
|
||||
}
|
||||
|
||||
public int getKeepAliveTime() {
|
||||
return keepAliveTime;
|
||||
}
|
||||
|
||||
public int getConnectionTimeout() {
|
||||
return connectionTimeout;
|
||||
}
|
||||
|
||||
public Map<String, String> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
}
|
|
@ -1,193 +1,198 @@
|
|||
/*******************************************************************************************************
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************************************/
|
||||
|
||||
package me.blackvein.quests.util;
|
||||
|
||||
public class CK {
|
||||
|
||||
// Temporary data storage for prompts and factories
|
||||
public static final String ED_QUEST_EDIT = "edit";
|
||||
public static final String ED_QUEST_DELETE = "delQuest";
|
||||
public static final String ED_EVENT_DELETE = "delEvent";
|
||||
public static final String ED_CONDITION_DELETE = "delCondition";
|
||||
// Quests
|
||||
public static final String Q_ID = "questId";
|
||||
public static final String Q_NAME = "questName";
|
||||
public static final String Q_ASK_MESSAGE = "askMessage";
|
||||
public static final String Q_FINISH_MESSAGE = "finishMessage";
|
||||
public static final String Q_START_NPC = "npcStart";
|
||||
public static final String Q_START_BLOCK = "blockStart";
|
||||
public static final String Q_INITIAL_EVENT = "initialEvent";
|
||||
public static final String Q_REGION = "region";
|
||||
public static final String Q_GUIDISPLAY = "guiDisplay";
|
||||
// Requirements
|
||||
public static final String REQ_MONEY = "moneyReq";
|
||||
public static final String REQ_QUEST_POINTS = "questPointsReq";
|
||||
public static final String REQ_ITEMS = "itemReqs";
|
||||
public static final String REQ_ITEMS_REMOVE = "removeItemReqs";
|
||||
public static final String REQ_PERMISSION = "permissionReqs";
|
||||
public static final String REQ_MCMMO_SKILLS = "mcMMOSkillReqs";
|
||||
public static final String REQ_MCMMO_SKILL_AMOUNTS = "mcMMOSkillAmountReqs";
|
||||
public static final String REQ_HEROES_PRIMARY_CLASS = "heroesPrimaryClassReq";
|
||||
public static final String REQ_HEROES_SECONDARY_CLASS = "heroesSecondaryClassReq";
|
||||
public static final String REQ_QUEST = "questReqs";
|
||||
public static final String REQ_QUEST_BLOCK = "questBlocks";
|
||||
public static final String REQ_CUSTOM = "customReqs";
|
||||
public static final String REQ_CUSTOM_DATA = "customReqData";
|
||||
public static final String REQ_CUSTOM_DATA_DESCRIPTIONS = "customReqDataDesc";
|
||||
public static final String REQ_CUSTOM_DATA_TEMP = "customReqDataTemp";
|
||||
public static final String REQ_FAIL_MESSAGE = "failMessage";
|
||||
// Stages
|
||||
public static final String S_BREAK_NAMES = "breakNames";
|
||||
public static final String S_BREAK_AMOUNTS = "breakAmounts";
|
||||
public static final String S_BREAK_DURABILITY = "breakDurability";
|
||||
public static final String S_DAMAGE_NAMES = "damageNames";
|
||||
public static final String S_DAMAGE_AMOUNTS = "damageAmounts";
|
||||
public static final String S_DAMAGE_DURABILITY = "damageDurability";
|
||||
public static final String S_PLACE_NAMES = "placeNames";
|
||||
public static final String S_PLACE_AMOUNTS = "placeAmounts";
|
||||
public static final String S_PLACE_DURABILITY = "placeDurability";
|
||||
public static final String S_USE_NAMES = "useNames";
|
||||
public static final String S_USE_AMOUNTS = "useAmounts";
|
||||
public static final String S_USE_DURABILITY = "useDurability";
|
||||
public static final String S_CUT_NAMES = "cutNames";
|
||||
public static final String S_CUT_AMOUNTS = "cutAmounts";
|
||||
public static final String S_CUT_DURABILITY = "cutDurability";
|
||||
public static final String S_COW_MILK = "cowMilk";
|
||||
public static final String S_FISH = "fish";
|
||||
public static final String S_PLAYER_KILL = "playerKill";
|
||||
public static final String S_CRAFT_ITEMS = "craftItems";
|
||||
public static final String S_SMELT_ITEMS = "smeltItems";
|
||||
public static final String S_CONSUME_ITEMS = "consumeItems";
|
||||
public static final String S_ENCHANT_ITEMS = "enchantItems";
|
||||
public static final String S_BREW_ITEMS = "brewItems";
|
||||
public static final String S_DELIVERY_ITEMS = "deliveryItems";
|
||||
public static final String S_DELIVERY_NPCS = "deliveryNPCs";
|
||||
public static final String S_DELIVERY_MESSAGES = "deliveryMessages";
|
||||
public static final String S_NPCS_TO_TALK_TO = "npcIdsToTalkTo";
|
||||
public static final String S_NPCS_TO_KILL = "npcIdsToKill";
|
||||
public static final String S_NPCS_TO_KILL_AMOUNTS = "npcAmountsToKill";
|
||||
public static final String S_MOB_TYPES = "mobTypes";
|
||||
public static final String S_MOB_AMOUNTS = "mobAmounts";
|
||||
public static final String S_MOB_KILL_LOCATIONS = "killLocations";
|
||||
public static final String S_MOB_KILL_LOCATIONS_RADIUS = "killLocationRadii";
|
||||
public static final String S_MOB_KILL_LOCATIONS_NAMES = "killLocationNames";
|
||||
public static final String S_REACH_LOCATIONS = "reachLocations";
|
||||
public static final String S_REACH_LOCATIONS_RADIUS = "reachLocationRadii";
|
||||
public static final String S_REACH_LOCATIONS_NAMES = "reachLocationNames";
|
||||
public static final String S_TAME_TYPES = "tameTypes";
|
||||
public static final String S_TAME_AMOUNTS = "tameAmounts";
|
||||
public static final String S_SHEAR_COLORS = "shearColors";
|
||||
public static final String S_SHEAR_AMOUNTS = "shearAmounts";
|
||||
public static final String S_START_EVENT = "startEvent";
|
||||
public static final String S_FINISH_EVENT = "finishEvent";
|
||||
public static final String S_FAIL_EVENT = "failEvent";
|
||||
public static final String S_CHAT_EVENTS = "chatEvents";
|
||||
public static final String S_CHAT_EVENT_TRIGGERS = "chatEventTriggers";
|
||||
public static final String S_CHAT_TEMP_EVENT = "chatTempEvent";
|
||||
public static final String S_COMMAND_EVENTS = "commandEvents";
|
||||
public static final String S_COMMAND_EVENT_TRIGGERS = "commandEventTriggers";
|
||||
public static final String S_COMMAND_TEMP_EVENT = "commandTempEvent";
|
||||
public static final String S_DEATH_EVENT = "deathEvent";
|
||||
public static final String S_DISCONNECT_EVENT = "disconnectEvent";
|
||||
public static final String S_CONDITION = "condition";
|
||||
public static final String S_DELAY = "delay";
|
||||
public static final String S_DELAY_MESSAGE = "delayMessage";
|
||||
public static final String S_DENIZEN = "denizen"; // Legacy
|
||||
public static final String S_COMPLETE_MESSAGE = "completeMessage";
|
||||
public static final String S_START_MESSAGE = "startMessage";
|
||||
public static final String S_PASSWORD_DISPLAYS = "passwordDisplays";
|
||||
public static final String S_PASSWORD_PHRASES = "passwordPhrases";
|
||||
public static final String S_CUSTOM_OBJECTIVES = "customObjectives";
|
||||
public static final String S_CUSTOM_OBJECTIVES_COUNT = "customObjectiveCounts";
|
||||
public static final String S_CUSTOM_OBJECTIVES_DATA = "customObjectiveData";
|
||||
public static final String S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS = "customObjectiveDataDescriptions";
|
||||
public static final String S_CUSTOM_OBJECTIVES_DATA_TEMP = "customObjectiveDataTemp";
|
||||
public static final String S_OVERRIDE_DISPLAY = "overrideDisplay";
|
||||
// Rewards
|
||||
public static final String REW_MONEY = "moneyRew";
|
||||
public static final String REW_QUEST_POINTS = "questPointsRew";
|
||||
public static final String REW_ITEMS = "itemRews";
|
||||
public static final String REW_EXP = "expRew";
|
||||
public static final String REW_COMMAND = "commandRews";
|
||||
public static final String REW_COMMAND_OVERRIDE_DISPLAY = "commandOverrideDisplay";
|
||||
public static final String REW_PERMISSION = "permissionRews";
|
||||
public static final String REW_PERMISSION_WORLDS = "permissionWorlds";
|
||||
public static final String REW_MCMMO_SKILLS = "mcMMOSkillRews";
|
||||
public static final String REW_MCMMO_AMOUNTS = "mcMMOSkillAmounts";
|
||||
public static final String REW_HEROES_CLASSES = "heroesClassRews";
|
||||
public static final String REW_HEROES_AMOUNTS = "heroesAmountRews";
|
||||
public static final String REW_PARTIES_EXPERIENCE = "partiesExperienceRews";
|
||||
public static final String REW_PHAT_LOOTS = "phatLootRews";
|
||||
public static final String REW_CUSTOM = "customRews";
|
||||
public static final String REW_CUSTOM_DATA = "customRewData";
|
||||
public static final String REW_CUSTOM_DATA_DESCRIPTIONS = "customRewDataDesc";
|
||||
public static final String REW_CUSTOM_DATA_TEMP = "customRewDataTemp";
|
||||
public static final String REW_DETAILS_OVERRIDE = "detailsOverrideRew";
|
||||
// Planner
|
||||
public static final String PLN_START_DATE = "startDatePln";
|
||||
public static final String PLN_END_DATE = "endDatePln";
|
||||
public static final String PLN_REPEAT_CYCLE = "repeatCyclePln";
|
||||
public static final String PLN_COOLDOWN = "cooldownPln";
|
||||
public static final String PLN_OVERRIDE = "overridePln";
|
||||
// Options
|
||||
public static final String OPT_ALLOW_COMMANDS = "allowCommandsOpt";
|
||||
public static final String OPT_ALLOW_QUITTING = "allowQuittingOpt";
|
||||
public static final String OPT_IGNORE_SILK_TOUCH = "ignoreSilkTouchOpt";
|
||||
public static final String OPT_USE_DUNGEONSXL_PLUGIN = "useDungeonsXLPluginOpt";
|
||||
public static final String OPT_USE_PARTIES_PLUGIN = "usePartiesPluginOpt";
|
||||
public static final String OPT_SHARE_PROGRESS_LEVEL = "shareProgressLevelOpt";
|
||||
public static final String OPT_SHARE_SAME_QUEST_ONLY = "shareSameQuestOnlyOpt";
|
||||
public static final String OPT_SHARE_DISTANCE = "shareDistance";
|
||||
public static final String OPT_HANDLE_OFFLINE_PLAYERS = "handleOfflinePlayers";
|
||||
// Actions
|
||||
public static final String E_OLD_EVENT = "oldEvent";
|
||||
public static final String E_NAME = "evtName";
|
||||
public static final String E_MESSAGE = "evtMessage";
|
||||
public static final String E_CLEAR_INVENTORY = "evtClearInv";
|
||||
public static final String E_FAIL_QUEST = "evtFailQuest";
|
||||
public static final String E_ITEMS = "evtItems";
|
||||
public static final String E_ITEMS_AMOUNTS = "evtItemAmounts";
|
||||
public static final String E_EXPLOSIONS = "evtExplosions";
|
||||
public static final String E_EFFECTS = "evtEffects";
|
||||
public static final String E_EFFECTS_LOCATIONS = "evtEffectLocations";
|
||||
public static final String E_WORLD_STORM = "evtStormWorld";
|
||||
public static final String E_WORLD_STORM_DURATION = "evtStormDuration";
|
||||
public static final String E_WORLD_THUNDER = "evtThunderWorld";
|
||||
public static final String E_WORLD_THUNDER_DURATION = "evtThunderDuration";
|
||||
public static final String E_MOB_TYPES = "evtMobTypes";
|
||||
public static final String E_LIGHTNING = "evtLightningStrikes";
|
||||
public static final String E_POTION_TYPES = "evtPotionTypes";
|
||||
public static final String E_POTION_DURATIONS = "evtPotionDurations";
|
||||
public static final String E_POTION_STRENGTH = "evtPotionMagnitudes";
|
||||
public static final String E_HUNGER = "evtHunger";
|
||||
public static final String E_SATURATION = "evtSaturation";
|
||||
public static final String E_HEALTH = "evtHealth";
|
||||
public static final String E_TELEPORT = "evtTeleportLocation";
|
||||
public static final String E_COMMANDS = "evtCommands";
|
||||
public static final String E_TIMER = "evtTimer";
|
||||
public static final String E_CANCEL_TIMER = "evtCancelTimer";
|
||||
public static final String E_DENIZEN = "evtDenizen";
|
||||
// Conditions
|
||||
public static final String C_OLD_CONDITION = "oldCondition";
|
||||
public static final String C_NAME = "conName";
|
||||
public static final String C_FAIL_QUEST = "conFailQuest";
|
||||
public static final String C_WHILE_RIDING_ENTITY = "conRidingEntity";
|
||||
public static final String C_WHILE_RIDING_NPC = "conRidingNpc";
|
||||
public static final String C_WHILE_PERMISSION = "conPermission";
|
||||
public static final String C_WHILE_HOLDING_MAIN_HAND = "conHoldingMainHand";
|
||||
public static final String C_WHILE_WITHIN_WORLD = "conWithinWorld";
|
||||
public static final String C_WHILE_WITHIN_BIOME = "conWithinBiome";
|
||||
public static final String C_WHILE_WITHIN_REGION = "conWithinRegion";
|
||||
public static final String C_WHILE_PLACEHOLDER_ID = "conPlaceholderId";
|
||||
public static final String C_WHILE_PLACEHOLDER_VAL = "conPlaceholderVal";
|
||||
}
|
||||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.util;
|
||||
|
||||
/**
|
||||
* Human-readable keys for session data of prompts and factories
|
||||
*/
|
||||
public class Key {
|
||||
|
||||
public static final String ED_QUEST_EDIT = "edit";
|
||||
public static final String ED_QUEST_DELETE = "delQuest";
|
||||
public static final String ED_EVENT_DELETE = "delEvent";
|
||||
public static final String ED_CONDITION_DELETE = "delCondition";
|
||||
// Quests
|
||||
public static final String Q_ID = "questId";
|
||||
public static final String Q_NAME = "questName";
|
||||
public static final String Q_ASK_MESSAGE = "askMessage";
|
||||
public static final String Q_FINISH_MESSAGE = "finishMessage";
|
||||
public static final String Q_START_NPC = "npcStart";
|
||||
public static final String Q_START_BLOCK = "blockStart";
|
||||
public static final String Q_INITIAL_EVENT = "initialEvent";
|
||||
public static final String Q_REGION = "region";
|
||||
public static final String Q_GUIDISPLAY = "guiDisplay";
|
||||
// Requirements
|
||||
public static final String REQ_MONEY = "moneyReq";
|
||||
public static final String REQ_QUEST_POINTS = "questPointsReq";
|
||||
public static final String REQ_ITEMS = "itemReqs";
|
||||
public static final String REQ_ITEMS_REMOVE = "removeItemReqs";
|
||||
public static final String REQ_EXP = "expReq";
|
||||
public static final String REQ_PERMISSION = "permissionReqs";
|
||||
public static final String REQ_MCMMO_SKILLS = "mcMMOSkillReqs";
|
||||
public static final String REQ_MCMMO_SKILL_AMOUNTS = "mcMMOSkillAmountReqs";
|
||||
public static final String REQ_HEROES_PRIMARY_CLASS = "heroesPrimaryClassReq";
|
||||
public static final String REQ_HEROES_SECONDARY_CLASS = "heroesSecondaryClassReq";
|
||||
public static final String REQ_QUEST = "questReqs";
|
||||
public static final String REQ_QUEST_BLOCK = "questBlocks";
|
||||
public static final String REQ_CUSTOM = "customReqs";
|
||||
public static final String REQ_CUSTOM_DATA = "customReqData";
|
||||
public static final String REQ_CUSTOM_DATA_DESCRIPTIONS = "customReqDataDesc";
|
||||
public static final String REQ_CUSTOM_DATA_TEMP = "customReqDataTemp";
|
||||
public static final String REQ_FAIL_MESSAGE = "failMessage";
|
||||
// Stages
|
||||
public static final String S_BREAK_NAMES = "breakNames";
|
||||
public static final String S_BREAK_AMOUNTS = "breakAmounts";
|
||||
public static final String S_BREAK_DURABILITY = "breakDurability";
|
||||
public static final String S_DAMAGE_NAMES = "damageNames";
|
||||
public static final String S_DAMAGE_AMOUNTS = "damageAmounts";
|
||||
public static final String S_DAMAGE_DURABILITY = "damageDurability";
|
||||
public static final String S_PLACE_NAMES = "placeNames";
|
||||
public static final String S_PLACE_AMOUNTS = "placeAmounts";
|
||||
public static final String S_PLACE_DURABILITY = "placeDurability";
|
||||
public static final String S_USE_NAMES = "useNames";
|
||||
public static final String S_USE_AMOUNTS = "useAmounts";
|
||||
public static final String S_USE_DURABILITY = "useDurability";
|
||||
public static final String S_CUT_NAMES = "cutNames";
|
||||
public static final String S_CUT_AMOUNTS = "cutAmounts";
|
||||
public static final String S_CUT_DURABILITY = "cutDurability";
|
||||
public static final String S_COW_MILK = "cowMilk";
|
||||
public static final String S_FISH = "fish";
|
||||
public static final String S_PLAYER_KILL = "playerKill";
|
||||
public static final String S_CRAFT_ITEMS = "craftItems";
|
||||
public static final String S_SMELT_ITEMS = "smeltItems";
|
||||
public static final String S_CONSUME_ITEMS = "consumeItems";
|
||||
public static final String S_ENCHANT_ITEMS = "enchantItems";
|
||||
public static final String S_BREW_ITEMS = "brewItems";
|
||||
public static final String S_DELIVERY_ITEMS = "deliveryItems";
|
||||
public static final String S_DELIVERY_NPCS = "deliveryNPCs";
|
||||
public static final String S_DELIVERY_MESSAGES = "deliveryMessages";
|
||||
public static final String S_NPCS_TO_TALK_TO = "npcIdsToTalkTo";
|
||||
public static final String S_NPCS_TO_KILL = "npcIdsToKill";
|
||||
public static final String S_NPCS_TO_KILL_AMOUNTS = "npcAmountsToKill";
|
||||
public static final String S_MOB_TYPES = "mobTypes";
|
||||
public static final String S_MOB_AMOUNTS = "mobAmounts";
|
||||
public static final String S_MOB_KILL_LOCATIONS = "killLocations";
|
||||
public static final String S_MOB_KILL_LOCATIONS_RADIUS = "killLocationRadii";
|
||||
public static final String S_MOB_KILL_LOCATIONS_NAMES = "killLocationNames";
|
||||
public static final String S_REACH_LOCATIONS = "reachLocations";
|
||||
public static final String S_REACH_LOCATIONS_RADIUS = "reachLocationRadii";
|
||||
public static final String S_REACH_LOCATIONS_NAMES = "reachLocationNames";
|
||||
public static final String S_TAME_TYPES = "tameTypes";
|
||||
public static final String S_TAME_AMOUNTS = "tameAmounts";
|
||||
public static final String S_SHEAR_COLORS = "shearColors";
|
||||
public static final String S_SHEAR_AMOUNTS = "shearAmounts";
|
||||
public static final String S_START_EVENT = "startEvent";
|
||||
public static final String S_FINISH_EVENT = "finishEvent";
|
||||
public static final String S_FAIL_EVENT = "failEvent";
|
||||
public static final String S_CHAT_EVENTS = "chatEvents";
|
||||
public static final String S_CHAT_EVENT_TRIGGERS = "chatEventTriggers";
|
||||
public static final String S_CHAT_TEMP_EVENT = "chatTempEvent";
|
||||
public static final String S_COMMAND_EVENTS = "commandEvents";
|
||||
public static final String S_COMMAND_EVENT_TRIGGERS = "commandEventTriggers";
|
||||
public static final String S_COMMAND_TEMP_EVENT = "commandTempEvent";
|
||||
public static final String S_DEATH_EVENT = "deathEvent";
|
||||
public static final String S_DISCONNECT_EVENT = "disconnectEvent";
|
||||
public static final String S_CONDITION = "condition";
|
||||
public static final String S_DELAY = "delay";
|
||||
public static final String S_DELAY_MESSAGE = "delayMessage";
|
||||
public static final String S_DENIZEN = "denizen"; // Legacy
|
||||
public static final String S_COMPLETE_MESSAGE = "completeMessage";
|
||||
public static final String S_START_MESSAGE = "startMessage";
|
||||
public static final String S_PASSWORD_DISPLAYS = "passwordDisplays";
|
||||
public static final String S_PASSWORD_PHRASES = "passwordPhrases";
|
||||
public static final String S_CUSTOM_OBJECTIVES = "customObjectives";
|
||||
public static final String S_CUSTOM_OBJECTIVES_COUNT = "customObjectiveCounts";
|
||||
public static final String S_CUSTOM_OBJECTIVES_DATA = "customObjectiveData";
|
||||
public static final String S_CUSTOM_OBJECTIVES_DATA_DESCRIPTIONS = "customObjectiveDataDescriptions";
|
||||
public static final String S_CUSTOM_OBJECTIVES_DATA_TEMP = "customObjectiveDataTemp";
|
||||
public static final String S_OVERRIDE_DISPLAY = "overrideDisplay";
|
||||
// Rewards
|
||||
public static final String REW_MONEY = "moneyRew";
|
||||
public static final String REW_QUEST_POINTS = "questPointsRew";
|
||||
public static final String REW_ITEMS = "itemRews";
|
||||
public static final String REW_EXP = "expRew";
|
||||
public static final String REW_COMMAND = "commandRews";
|
||||
public static final String REW_COMMAND_OVERRIDE_DISPLAY = "commandOverrideDisplay";
|
||||
public static final String REW_PERMISSION = "permissionRews";
|
||||
public static final String REW_PERMISSION_WORLDS = "permissionWorlds";
|
||||
public static final String REW_MCMMO_SKILLS = "mcMMOSkillRews";
|
||||
public static final String REW_MCMMO_AMOUNTS = "mcMMOSkillAmounts";
|
||||
public static final String REW_HEROES_CLASSES = "heroesClassRews";
|
||||
public static final String REW_HEROES_AMOUNTS = "heroesAmountRews";
|
||||
public static final String REW_PARTIES_EXPERIENCE = "partiesExperienceRews";
|
||||
public static final String REW_PHAT_LOOTS = "phatLootRews";
|
||||
public static final String REW_CUSTOM = "customRews";
|
||||
public static final String REW_CUSTOM_DATA = "customRewData";
|
||||
public static final String REW_CUSTOM_DATA_DESCRIPTIONS = "customRewDataDesc";
|
||||
public static final String REW_CUSTOM_DATA_TEMP = "customRewDataTemp";
|
||||
public static final String REW_DETAILS_OVERRIDE = "detailsOverrideRew";
|
||||
// Planner
|
||||
public static final String PLN_START_DATE = "startDatePln";
|
||||
public static final String PLN_END_DATE = "endDatePln";
|
||||
public static final String PLN_REPEAT_CYCLE = "repeatCyclePln";
|
||||
public static final String PLN_COOLDOWN = "cooldownPln";
|
||||
public static final String PLN_OVERRIDE = "overridePln";
|
||||
// Options
|
||||
public static final String OPT_ALLOW_COMMANDS = "allowCommandsOpt";
|
||||
public static final String OPT_ALLOW_QUITTING = "allowQuittingOpt";
|
||||
public static final String OPT_IGNORE_SILK_TOUCH = "ignoreSilkTouchOpt";
|
||||
public static final String OPT_EXTERNAL_PARTY_PLUGIN = "externalPartyPluginOpt";
|
||||
public static final String OPT_USE_PARTIES_PLUGIN = "usePartiesPluginOpt";
|
||||
public static final String OPT_SHARE_PROGRESS_LEVEL = "shareProgressLevelOpt";
|
||||
public static final String OPT_SHARE_SAME_QUEST_ONLY = "shareSameQuestOnlyOpt";
|
||||
public static final String OPT_SHARE_DISTANCE = "shareDistance";
|
||||
public static final String OPT_HANDLE_OFFLINE_PLAYERS = "handleOfflinePlayers";
|
||||
public static final String OPT_IGNORE_BLOCK_REPLACE = "ignoreBlockReplace";
|
||||
// Actions
|
||||
public static final String A_OLD_ACTION = "oldAction";
|
||||
public static final String A_NAME = "actName";
|
||||
public static final String A_MESSAGE = "actMessage";
|
||||
public static final String A_CLEAR_INVENTORY = "actClearInv";
|
||||
public static final String A_FAIL_QUEST = "actFailQuest";
|
||||
public static final String A_ITEMS = "actItems";
|
||||
public static final String A_ITEMS_AMOUNTS = "actItemAmounts";
|
||||
public static final String A_EXPLOSIONS = "actExplosions";
|
||||
public static final String A_EFFECTS = "actEffects";
|
||||
public static final String A_EFFECTS_LOCATIONS = "actEffectLocations";
|
||||
public static final String A_WORLD_STORM = "actStormWorld";
|
||||
public static final String A_WORLD_STORM_DURATION = "actStormDuration";
|
||||
public static final String A_WORLD_THUNDER = "actThunderWorld";
|
||||
public static final String A_WORLD_THUNDER_DURATION = "actThunderDuration";
|
||||
public static final String A_MOBS = "actMobs";
|
||||
public static final String A_LIGHTNING = "actLightningStrikes";
|
||||
public static final String A_POTION_TYPES = "actPotionTypes";
|
||||
public static final String A_POTION_DURATIONS = "actPotionDurations";
|
||||
public static final String A_POTION_STRENGTH = "actPotionMagnitudes";
|
||||
public static final String A_HUNGER = "actHunger";
|
||||
public static final String A_SATURATION = "actSaturation";
|
||||
public static final String A_HEALTH = "actHealth";
|
||||
public static final String A_TELEPORT = "actTeleportLocation";
|
||||
public static final String A_COMMANDS = "actCommands";
|
||||
public static final String A_TIMER = "actTimer";
|
||||
public static final String A_CANCEL_TIMER = "actCancelTimer";
|
||||
public static final String A_DENIZEN = "actDenizen";
|
||||
// Conditions
|
||||
public static final String C_OLD_CONDITION = "oldCondition";
|
||||
public static final String C_NAME = "conName";
|
||||
public static final String C_FAIL_QUEST = "conFailQuest";
|
||||
public static final String C_WHILE_RIDING_ENTITY = "conRidingEntity";
|
||||
public static final String C_WHILE_RIDING_NPC = "conRidingNpc";
|
||||
public static final String C_WHILE_PERMISSION = "conPermission";
|
||||
public static final String C_WHILE_HOLDING_MAIN_HAND = "conHoldingMainHand";
|
||||
public static final String C_WHILE_WEARING = "conWearing";
|
||||
public static final String C_WHILE_WITHIN_WORLD = "conWithinWorld";
|
||||
public static final String C_WHILE_WITHIN_TICKS_START = "conWithinTicksStart";
|
||||
public static final String C_WHILE_WITHIN_TICKS_END = "conWithinTicksEnd";
|
||||
public static final String C_WHILE_WITHIN_BIOME = "conWithinBiome";
|
||||
public static final String C_WHILE_WITHIN_REGION = "conWithinRegion";
|
||||
public static final String C_WHILE_PLACEHOLDER_ID = "conPlaceholderId";
|
||||
public static final String C_WHILE_PLACEHOLDER_VAL = "conPlaceholderVal";
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.util;
|
||||
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class RomanNumeral {
|
||||
|
||||
private final static TreeMap<Integer, String> map = new TreeMap<>();
|
||||
|
||||
static {
|
||||
map.put(1000, "M");
|
||||
map.put(900, "CM");
|
||||
map.put(500, "D");
|
||||
map.put(400, "CD");
|
||||
map.put(100, "C");
|
||||
map.put(90, "XC");
|
||||
map.put(50, "L");
|
||||
map.put(40, "XL");
|
||||
map.put(10, "X");
|
||||
map.put(9, "IX");
|
||||
map.put(5, "V");
|
||||
map.put(4, "IV");
|
||||
map.put(1, "I");
|
||||
}
|
||||
|
||||
public static String getNumeral(final int number) {
|
||||
final int l = map.floorKey(number);
|
||||
if ( number == l ) {
|
||||
return map.get(number);
|
||||
}
|
||||
return map.get(l) + getNumeral(number-l);
|
||||
}
|
||||
}
|
|
@ -1,20 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>me.blackvein.quests</groupId>
|
||||
<groupId>me.pikamug.quests</groupId>
|
||||
<artifactId>quests-parent</artifactId>
|
||||
<version>4.0.6</version>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<artifactId>quests-main</artifactId>
|
||||
|
||||
<artifactId>quests-core</artifactId>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<!-- CitizensBooks, DungeonsXL, GPS, LocaleLib, mcMMO Classic, PhatLoots -->
|
||||
<!-- LocaleLib, mcMMO Classic, PhatLoots, Unite, ZNPCsPlus -->
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
|
@ -23,14 +25,19 @@
|
|||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<!-- Citizens, Denizen -->
|
||||
<id>citizens-repo</id>
|
||||
<url>http://repo.citizensnpcs.co/</url>
|
||||
<!-- NBT API -->
|
||||
<id>codemc-repo</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<!-- WorldEdit -->
|
||||
<id>sk89q-repo</id>
|
||||
<url>http://maven.sk89q.com/repo/</url>
|
||||
<!-- Citizens, Denizen -->
|
||||
<id>citizens-repo</id>
|
||||
<url>https://repo.citizensnpcs.co/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<!-- WorldEdit, WorldGuard -->
|
||||
<id>enginehub-repo</id>
|
||||
<url>https://maven.enginehub.org/repo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<!-- Parties -->
|
||||
|
@ -40,32 +47,48 @@
|
|||
<repository>
|
||||
<!-- PlaceholderAPI -->
|
||||
<id>papi-repo</id>
|
||||
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<!-- Heroes, Vault -->
|
||||
<id>hc-repo</id>
|
||||
<url>http://nexus.hc.to/content/repositories/pub_releases/</url>
|
||||
<url>https://nexus.hc.to/content/repositories/pub_releases/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<!-- AstralBooks -->
|
||||
<id>repsy-release</id>
|
||||
<url>https://repo.repsy.io/mvn/niconeko/release</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<!-- PacketEvents for ZNPCsPlus -->
|
||||
<id>codemc-snapshots</id>
|
||||
<url>https://repo.codemc.io/repository/maven-snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<!-- Pyr's Repo (ZNPCsPlus 2.X) -->
|
||||
<id>pyr-snapshots</id>
|
||||
<name>Pyr's Repo</name>
|
||||
<url>https://repo.pyr.lol/snapshots</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.citizensnpcs</groupId>
|
||||
<artifactId>citizens</artifactId>
|
||||
<version>2.0.21-SNAPSHOT</version>
|
||||
<artifactId>citizensapi</artifactId>
|
||||
<version>2.0.30-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.denizenscript</groupId>
|
||||
<artifactId>denizen</artifactId>
|
||||
<version>1.1.3-SNAPSHOT</version>
|
||||
<version>1.2.5-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -82,14 +105,14 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.herocraftonline.heroes</groupId>
|
||||
<artifactId>heroes-stripped</artifactId>
|
||||
<version>4dd3dd85</version>
|
||||
<artifactId>Heroes</artifactId>
|
||||
<version>1.9.26-RELEASE</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>worldedit-bukkit</artifactId>
|
||||
<version>7.2.5-SNAPSHOT</version>
|
||||
<version>7.2.8</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -101,71 +124,82 @@
|
|||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.9.2</version>
|
||||
<version>2.11.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.nicuch</groupId>
|
||||
<artifactId>CitizensBooks</artifactId>
|
||||
<version>2.5.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.RednedEpic</groupId>
|
||||
<artifactId>PhatLoots</artifactId>
|
||||
<version>e55d0ba1f6</version>
|
||||
<groupId>ro.niconeko</groupId>
|
||||
<artifactId>astralbooks-api</artifactId>
|
||||
<version>3.0.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alessiodp.parties</groupId>
|
||||
<artifactId>parties-api</artifactId>
|
||||
<version>3.1.6</version>
|
||||
<version>3.2.9</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.retrooper.packetevents</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.Pyrbu</groupId>
|
||||
<artifactId>ZNPCsPlus</artifactId>
|
||||
<version>271b087586</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>lol.pyr</groupId>
|
||||
<artifactId>znpcsplus-api</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.PikaMug</groupId>
|
||||
<artifactId>Unite</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>d0c4de0ca1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.PikaMug</groupId>
|
||||
<artifactId>LocaleLib</artifactId>
|
||||
<version>2.2</version>
|
||||
<version>3.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.22</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<groupId>de.tr7zw</groupId>
|
||||
<artifactId>item-nbt-api-plugin</artifactId>
|
||||
<version>2.12.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
<version>3.4.5</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<groupId>xyz.upperlevel.spigot.book</groupId>
|
||||
<artifactId>spigot-book-api</artifactId>
|
||||
<version>1.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.7.30</version>
|
||||
<version>1.7.33</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.17.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.pikamug.quests</groupId>
|
||||
<artifactId>quests-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean package install</defaultGoal>
|
||||
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
|
||||
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>.</targetPath>
|
||||
|
@ -183,19 +217,20 @@
|
|||
</resource>
|
||||
<resource>
|
||||
<targetPath>.</targetPath>
|
||||
<directory>${basedir}/</directory>
|
||||
<directory>${basedir}</directory>
|
||||
<filtering>false</filtering>
|
||||
<includes>
|
||||
<include>README.md</include>
|
||||
<include>LICENSE.txt</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<version>3.10.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
|
@ -211,7 +246,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<version>3.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
|
@ -224,34 +259,49 @@
|
|||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
||||
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>me.*</include>
|
||||
<include>com.github.PikaMug:LocaleLib</include>
|
||||
<include>com.zaxxer:HikariCP</include>
|
||||
<include>de.tr7zw:item-nbt-api-plugin</include>
|
||||
<include>org.slf4j:slf4j-simple</include>
|
||||
<include>org.slf4j:slf4j-api</include>
|
||||
<include>mysql</include>
|
||||
<include>xyz.upperlevel.spigot.book:spigot-book-api</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.MF</exclude>
|
||||
<exclude>LICENSE</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
<filter>
|
||||
<artifact>com.github.PikaMug:LocaleLib</artifact>
|
||||
<excludes>
|
||||
<exclude>plugin.yml</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>me.pikamug.localelib</pattern>
|
||||
<shadedPattern>me.blackvein.quests.libs.localelib</shadedPattern>
|
||||
<shadedPattern>me.pikamug.quests.libs.localelib</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.zaxxer.hikari</pattern>
|
||||
<shadedPattern>me.blackvein.quests.libs.hikari</shadedPattern>
|
||||
<pattern>de.tr7zw</pattern>
|
||||
<shadedPattern>me.pikamug.quests.libs.nbtapi</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.slf4j</pattern>
|
||||
<shadedPattern>me.blackvein.quests.libs.slf4j</shadedPattern>
|
||||
<shadedPattern>me.pikamug.quests.libs.slf4j</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.mysql</pattern>
|
||||
<shadedPattern>me.blackvein.quests.libs.mysql</shadedPattern>
|
||||
<pattern>xyz.upperlevel.spigot.book</pattern>
|
||||
<shadedPattern>me.pikamug.quests.libs.bookutil</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
|
@ -0,0 +1,895 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests;
|
||||
|
||||
import me.pikamug.localelib.LocaleManager;
|
||||
import me.pikamug.quests.actions.Action;
|
||||
import me.pikamug.quests.actions.BukkitActionFactory;
|
||||
import me.pikamug.quests.conditions.BukkitConditionFactory;
|
||||
import me.pikamug.quests.conditions.Condition;
|
||||
import me.pikamug.quests.config.BukkitConfigSettings;
|
||||
import me.pikamug.quests.config.ConfigSettings;
|
||||
import me.pikamug.quests.convo.misc.NpcOfferQuestPrompt;
|
||||
import me.pikamug.quests.convo.misc.QuestAcceptPrompt;
|
||||
import me.pikamug.quests.dependencies.BukkitDenizenTrigger;
|
||||
import me.pikamug.quests.dependencies.BukkitDependencies;
|
||||
import me.pikamug.quests.interfaces.ReloadCallback;
|
||||
import me.pikamug.quests.listeners.*;
|
||||
import me.pikamug.quests.logging.BukkitQuestsLog4JFilter;
|
||||
import me.pikamug.quests.storage.implementation.jar.BukkitModuleJarStorage;
|
||||
import me.pikamug.quests.storage.implementation.ModuleStorageImpl;
|
||||
import me.pikamug.quests.module.CustomObjective;
|
||||
import me.pikamug.quests.module.CustomRequirement;
|
||||
import me.pikamug.quests.module.CustomReward;
|
||||
import me.pikamug.quests.player.BukkitQuester;
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.quests.BukkitQuestFactory;
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
import me.pikamug.quests.statistics.BukkitMetrics;
|
||||
import me.pikamug.quests.storage.BukkitStorageFactory;
|
||||
import me.pikamug.quests.storage.QuesterStorage;
|
||||
import me.pikamug.quests.storage.implementation.file.BukkitActionYamlStorage;
|
||||
import me.pikamug.quests.storage.implementation.file.BukkitConditionYamlStorage;
|
||||
import me.pikamug.quests.storage.implementation.file.BukkitQuestYamlStorage;
|
||||
import me.pikamug.quests.tasks.BukkitNpcEffectThread;
|
||||
import me.pikamug.quests.tasks.BukkitPlayerMoveThread;
|
||||
import me.pikamug.quests.util.BukkitLang;
|
||||
import me.pikamug.quests.util.BukkitUpdateChecker;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.conversations.Conversable;
|
||||
import org.bukkit.conversations.ConversationFactory;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class BukkitQuestsPlugin extends JavaPlugin implements Quests {
|
||||
|
||||
private boolean loading = true;
|
||||
private String bukkitVersion = "0";
|
||||
private BukkitDependencies depends;
|
||||
private BukkitActionYamlStorage actionLoader;
|
||||
private BukkitConditionYamlStorage conditionLoader;
|
||||
private ConfigSettings configSettings;
|
||||
private ModuleStorageImpl customLoader;
|
||||
private BukkitQuestYamlStorage questLoader;
|
||||
private List<CustomObjective> customObjectives = new LinkedList<>();
|
||||
private List<CustomRequirement> customRequirements = new LinkedList<>();
|
||||
private List<CustomReward> customRewards = new LinkedList<>();
|
||||
private Collection<Quester> questers = new ConcurrentSkipListSet<>();
|
||||
private Collection<Quest> quests = new ConcurrentSkipListSet<>();
|
||||
private Collection<Action> actions = new ConcurrentSkipListSet<>();
|
||||
private Collection<Condition> conditions = new ConcurrentSkipListSet<>();
|
||||
private Collection<UUID> questNpcUuids = new ConcurrentSkipListSet<>();
|
||||
private TabExecutor cmdExecutor;
|
||||
private ConversationFactory conversationFactory;
|
||||
private ConversationFactory npcConversationFactory;
|
||||
private BukkitQuestFactory questFactory;
|
||||
private BukkitActionFactory actionFactory;
|
||||
private BukkitConditionFactory conditionFactory;
|
||||
private BukkitConvoListener convoListener;
|
||||
private BukkitBlockListener blockListener;
|
||||
private BukkitItemListener itemListener;
|
||||
private BukkitCitizensListener citizensListener;
|
||||
private BukkitZnpcsListener znpcsListener;
|
||||
private BukkitZnpcsApiListener znpcsPlusListener;
|
||||
private BukkitPlayerListener playerListener;
|
||||
private BukkitNpcEffectThread effectThread;
|
||||
private BukkitPlayerMoveThread moveThread;
|
||||
private BukkitUniteListener uniteListener;
|
||||
private BukkitPartiesListener partiesListener;
|
||||
private BukkitDenizenTrigger trigger;
|
||||
private LocaleManager localeManager;
|
||||
private QuesterStorage storage;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
/*----> WARNING: ORDER OF STEPS MATTERS <----*/
|
||||
|
||||
// 1 - Trigger server to initialize Legacy Material Support
|
||||
try {
|
||||
Material.matchMaterial("STONE", true);
|
||||
} catch (final NoSuchMethodError ignored) {
|
||||
}
|
||||
|
||||
((org.apache.logging.log4j.core.Logger) LogManager.getRootLogger()).addFilter(new BukkitQuestsLog4JFilter());
|
||||
|
||||
// 2 - Initialize variables
|
||||
bukkitVersion = Bukkit.getServer().getBukkitVersion().split("-")[0];
|
||||
actionLoader = new BukkitActionYamlStorage(this);
|
||||
conditionLoader = new BukkitConditionYamlStorage(this);
|
||||
configSettings = new BukkitConfigSettings(this);
|
||||
customLoader = new BukkitModuleJarStorage(this);
|
||||
questLoader = new BukkitQuestYamlStorage(this);
|
||||
try {
|
||||
Class.forName("me.pikamug.quests.libs.localelib.LocaleManager");
|
||||
localeManager = new LocaleManager();
|
||||
} catch (final Exception ignored) {
|
||||
getLogger().warning("LocaleLib not present! Is this a debug environment?");
|
||||
}
|
||||
convoListener = new BukkitConvoListener();
|
||||
blockListener = new BukkitBlockListener(this);
|
||||
itemListener = new BukkitItemListener(this);
|
||||
citizensListener = new BukkitCitizensListener(this);
|
||||
znpcsListener = new BukkitZnpcsListener(this);
|
||||
znpcsPlusListener = new BukkitZnpcsApiListener(this);
|
||||
playerListener = new BukkitPlayerListener(this);
|
||||
uniteListener = new BukkitUniteListener();
|
||||
partiesListener = new BukkitPartiesListener();
|
||||
effectThread = new BukkitNpcEffectThread(this);
|
||||
moveThread = new BukkitPlayerMoveThread(this);
|
||||
questFactory = new BukkitQuestFactory(this);
|
||||
actionFactory = new BukkitActionFactory(this);
|
||||
conditionFactory = new BukkitConditionFactory(this);
|
||||
depends = new BukkitDependencies(this);
|
||||
trigger = new BukkitDenizenTrigger(this);
|
||||
|
||||
// 3 - Load main config
|
||||
configSettings.init();
|
||||
if (configSettings.getLanguage().contains("-")) {
|
||||
final BukkitMetrics metrics = new BukkitMetrics(this);
|
||||
metrics.addCustomChart(new BukkitMetrics.SimplePie("language", () -> configSettings.getLanguage()));
|
||||
}
|
||||
|
||||
// 4 - Setup language files
|
||||
try {
|
||||
BukkitLang.init(this);
|
||||
} catch (final IOException | URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// 5 - Load command executor
|
||||
cmdExecutor = new BukkitCommandManager(this);
|
||||
|
||||
// 6 - Load soft-depends
|
||||
depends.init();
|
||||
|
||||
// 7 - Transfer resources from jar
|
||||
moveStorageResource("quests.yml");
|
||||
moveStorageResource("actions.yml");
|
||||
moveStorageResource("conditions.yml");
|
||||
saveResourceAs("quests.yml", "storage/quests.yml", false);
|
||||
saveResourceAs("actions.yml", "storage/actions.yml", false);
|
||||
saveResourceAs("conditions.yml", "storage/conditions.yml", false);
|
||||
|
||||
// 8 - Save config with any new options
|
||||
getConfig().options().copyDefaults(true);
|
||||
getConfig().options().header("See https://pikamug.gitbook.io/quests/setup/configuration");
|
||||
saveConfig();
|
||||
final BukkitStorageFactory storageFactory = new BukkitStorageFactory(this);
|
||||
storage = storageFactory.getInstance();
|
||||
|
||||
// 9 - Setup commands
|
||||
if (getCommand("quests") != null) {
|
||||
Objects.requireNonNull(getCommand("quests")).setExecutor(getTabExecutor());
|
||||
Objects.requireNonNull(getCommand("quests")).setTabCompleter(getTabExecutor());
|
||||
}
|
||||
if (getCommand("questadmin") != null) {
|
||||
Objects.requireNonNull(getCommand("questadmin")).setExecutor(getTabExecutor());
|
||||
Objects.requireNonNull(getCommand("questadmin")).setTabCompleter(getTabExecutor());
|
||||
}
|
||||
if (getCommand("quest") != null) {
|
||||
Objects.requireNonNull(getCommand("quest")).setExecutor(getTabExecutor());
|
||||
Objects.requireNonNull(getCommand("quest")).setTabCompleter(getTabExecutor());
|
||||
}
|
||||
|
||||
// 10 - Build conversation factories
|
||||
this.conversationFactory = new ConversationFactory(this).withModality(false)
|
||||
.withPrefix(context -> ChatColor.GRAY.toString())
|
||||
.withFirstPrompt(new QuestAcceptPrompt(this)).withTimeout(configSettings.getAcceptTimeout())
|
||||
.thatExcludesNonPlayersWithMessage("Console may not perform this conversation!")
|
||||
.addConversationAbandonedListener(convoListener);
|
||||
this.npcConversationFactory = new ConversationFactory(this).withModality(false)
|
||||
.withFirstPrompt(new NpcOfferQuestPrompt(this)).withTimeout(configSettings.getAcceptTimeout())
|
||||
.withLocalEcho(false).addConversationAbandonedListener(convoListener);
|
||||
|
||||
// 11 - Register listeners
|
||||
getServer().getPluginManager().registerEvents(getBlockListener(), this);
|
||||
getServer().getPluginManager().registerEvents(getItemListener(), this);
|
||||
depends.linkCitizens();
|
||||
if (depends.getZnpcsPlus() != null) {
|
||||
getServer().getPluginManager().registerEvents(getZnpcsListener(), this);
|
||||
}
|
||||
depends.linkZnpcsPlusApi();
|
||||
getServer().getPluginManager().registerEvents(getPlayerListener(), this);
|
||||
if (configSettings.getStrictPlayerMovement() > 0) {
|
||||
final long ticks = configSettings.getStrictPlayerMovement() * 20L;
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, getPlayerMoveThread(), ticks, ticks);
|
||||
}
|
||||
if (depends.getPartyProvider() != null) {
|
||||
getServer().getPluginManager().registerEvents(getUniteListener(), this);
|
||||
} else if (depends.getPartiesApi() != null) {
|
||||
getServer().getPluginManager().registerEvents(getPartiesListener(), this);
|
||||
}
|
||||
|
||||
// 12 - Attempt to check for updates
|
||||
new BukkitUpdateChecker(this, 3711).getVersion(version -> {
|
||||
if (!getDescription().getVersion().split("-")[0].equalsIgnoreCase(version)) {
|
||||
getLogger().info(ChatColor.DARK_GREEN + BukkitLang.get("updateTo").replace("<version>",
|
||||
version).replace("<url>", ChatColor.AQUA + getDescription().getWebsite()));
|
||||
}
|
||||
});
|
||||
|
||||
// 13 - Delay loading of quests, actions and modules
|
||||
delayLoadQuestInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getLogger().info("Saving Quester data...");
|
||||
for (final Player p : getServer().getOnlinePlayers()) {
|
||||
getQuester(p.getUniqueId()).saveData();
|
||||
}
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
getLogger().info("Closing storage...");
|
||||
if (storage != null) {
|
||||
storage.close();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isProVersion() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isLoading() {
|
||||
return loading;
|
||||
}
|
||||
|
||||
public File getPluginDataFolder() {
|
||||
return getDataFolder();
|
||||
}
|
||||
|
||||
public Logger getPluginLogger() {
|
||||
return getLogger();
|
||||
}
|
||||
|
||||
public InputStream getPluginResource(String filename) {
|
||||
return getResource(filename);
|
||||
}
|
||||
|
||||
public String getDetectedServerSoftwareVersion() {
|
||||
return bukkitVersion;
|
||||
}
|
||||
|
||||
public BukkitDependencies getDependencies() {
|
||||
return depends;
|
||||
}
|
||||
|
||||
public BukkitConfigSettings getConfigSettings() {
|
||||
return (BukkitConfigSettings) configSettings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CustomObjective> getCustomObjectives() {
|
||||
return customObjectives;
|
||||
}
|
||||
|
||||
public Optional<CustomObjective> getCustomObjective(final String className) {
|
||||
for (final CustomObjective co : customObjectives) {
|
||||
if (co.getClass().getName().equals(className)) {
|
||||
return Optional.of(co);
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public void setCustomObjectives(List<CustomObjective> customObjectives) {
|
||||
this.customObjectives = customObjectives;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CustomRequirement> getCustomRequirements() {
|
||||
return customRequirements;
|
||||
}
|
||||
|
||||
public Optional<CustomRequirement> getCustomRequirement(final String className) {
|
||||
for (final CustomRequirement cr : customRequirements) {
|
||||
if (cr.getClass().getName().equals(className)) {
|
||||
return Optional.of(cr);
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public void setCustomRequirements(List<CustomRequirement> customRequirements) {
|
||||
this.customRequirements = customRequirements;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CustomReward> getCustomRewards() {
|
||||
return customRewards;
|
||||
}
|
||||
|
||||
public Optional<CustomReward> getCustomReward(final String className) {
|
||||
for (final CustomReward cr : customRewards) {
|
||||
if (cr.getClass().getName().equals(className)) {
|
||||
return Optional.of(cr);
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public void setCustomRewards(List<CustomReward> customRewards) {
|
||||
this.customRewards = customRewards;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get every Quest loaded in memory
|
||||
*
|
||||
* @return a collection of all Quests
|
||||
*/
|
||||
public Collection<Quest> getLoadedQuests() {
|
||||
return quests;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set every Quest loaded in memory
|
||||
*
|
||||
*/
|
||||
public void setLoadedQuests(final Collection<Quest> quests) {
|
||||
this.quests = quests;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get every Action loaded in memory
|
||||
*
|
||||
* @return a collection of all Actions
|
||||
*/
|
||||
public Collection<Action> getLoadedActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set every Action loaded in memory
|
||||
*
|
||||
*/
|
||||
public void setLoadedActions(final Collection<Action> actions) {
|
||||
this.actions = actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get every Condition loaded in memory
|
||||
*
|
||||
* @return a collection of all Conditions
|
||||
*/
|
||||
public Collection<Condition> getLoadedConditions() {
|
||||
return conditions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set every Condition loaded in memory
|
||||
*
|
||||
*/
|
||||
public void setLoadedConditions(final Collection<Condition> conditions) {
|
||||
this.conditions = conditions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Quester from player UUID
|
||||
*
|
||||
* @param id Player UUID
|
||||
* @return new or existing Quester
|
||||
*/
|
||||
public BukkitQuester getQuester(final @NotNull UUID id) {
|
||||
final ConcurrentSkipListSet<Quester> set = (ConcurrentSkipListSet<Quester>) questers;
|
||||
for (final Quester q : set) {
|
||||
if (q != null && q.getUUID().equals(id)) {
|
||||
return (BukkitQuester) q;
|
||||
}
|
||||
}
|
||||
final BukkitQuester quester = new BukkitQuester(this, id);
|
||||
if (depends.getCitizens() != null) {
|
||||
if (depends.getCitizens().getNPCRegistry().getByUniqueId(id) != null) {
|
||||
return quester;
|
||||
}
|
||||
}
|
||||
final BukkitQuester q = new BukkitQuester(this, id);
|
||||
questers.add(q);
|
||||
return q;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get every online Quester playing on this server
|
||||
*
|
||||
* @return a collection of all online Questers
|
||||
*/
|
||||
public Collection<Quester> getOnlineQuesters() {
|
||||
final Collection<Quester> questers = new ConcurrentSkipListSet<>();
|
||||
for (final Quester q : getOfflineQuesters()) {
|
||||
if (q.getOfflinePlayer().isOnline()) {
|
||||
// Workaround for issues with the compass on fast join
|
||||
q.findCompassTarget();
|
||||
questers.add(q);
|
||||
}
|
||||
}
|
||||
return questers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get every Quester that has ever played on this server
|
||||
*
|
||||
* @return a collection of all Questers
|
||||
*/
|
||||
public Collection<Quester> getOfflineQuesters() {
|
||||
return questers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set every Quester that has ever played on this server
|
||||
*
|
||||
* @param questers a collection of Questers
|
||||
*/
|
||||
public void setOfflineQuesters(final Collection<Quester> questers) {
|
||||
this.questers = new ConcurrentSkipListSet<>(questers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get every NPC UUID which sees use a quest giver, talk target, or kill target
|
||||
*
|
||||
* @return a collection of all UUIDs
|
||||
*/
|
||||
public Collection<UUID> getQuestNpcUuids() {
|
||||
return questNpcUuids;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set every NPC UUID which sees use a quest giver, talk target, or kill target
|
||||
*
|
||||
* @param questNpcUuids a collection of UUIDs
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public void setQuestNpcUuids(final Collection<UUID> questNpcUuids) {
|
||||
this.questNpcUuids = new ConcurrentSkipListSet<>(questNpcUuids);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public CommandExecutor getCommandExecutor() {
|
||||
return cmdExecutor;
|
||||
}
|
||||
|
||||
public TabExecutor getTabExecutor() {
|
||||
return cmdExecutor;
|
||||
}
|
||||
|
||||
public ConversationFactory getConversationFactory() {
|
||||
return conversationFactory;
|
||||
}
|
||||
|
||||
public ConversationFactory getNpcConversationFactory() {
|
||||
return npcConversationFactory;
|
||||
}
|
||||
|
||||
public BukkitQuestFactory getQuestFactory() {
|
||||
return questFactory;
|
||||
}
|
||||
|
||||
public BukkitActionFactory getActionFactory() {
|
||||
return actionFactory;
|
||||
}
|
||||
|
||||
public BukkitConditionFactory getConditionFactory() {
|
||||
return conditionFactory;
|
||||
}
|
||||
|
||||
public BukkitConvoListener getConvoListener() {
|
||||
return convoListener;
|
||||
}
|
||||
|
||||
public BukkitBlockListener getBlockListener() {
|
||||
return blockListener;
|
||||
}
|
||||
|
||||
public BukkitItemListener getItemListener() {
|
||||
return itemListener;
|
||||
}
|
||||
|
||||
public BukkitCitizensListener getCitizensListener() {
|
||||
return citizensListener;
|
||||
}
|
||||
|
||||
public BukkitZnpcsListener getZnpcsListener() {
|
||||
return znpcsListener;
|
||||
}
|
||||
|
||||
public BukkitZnpcsApiListener getZNpcsPlusListener() {
|
||||
return znpcsPlusListener;
|
||||
}
|
||||
|
||||
public BukkitPlayerListener getPlayerListener() {
|
||||
return playerListener;
|
||||
}
|
||||
|
||||
public BukkitUniteListener getUniteListener() {
|
||||
return uniteListener;
|
||||
}
|
||||
|
||||
public BukkitNpcEffectThread getNpcEffectThread() {
|
||||
return effectThread;
|
||||
}
|
||||
|
||||
public BukkitPlayerMoveThread getPlayerMoveThread() {
|
||||
return moveThread;
|
||||
}
|
||||
|
||||
public BukkitPartiesListener getPartiesListener() {
|
||||
return partiesListener;
|
||||
}
|
||||
|
||||
public BukkitDenizenTrigger getDenizenTrigger() {
|
||||
return trigger;
|
||||
}
|
||||
|
||||
public LocaleManager getLocaleManager() {
|
||||
return localeManager;
|
||||
}
|
||||
|
||||
public QuesterStorage getStorage() {
|
||||
return storage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a storage file from legacy location, if present
|
||||
*
|
||||
* @param fileName Name of file to attempt move
|
||||
*/
|
||||
private void moveStorageResource(String fileName) {
|
||||
final File storageFile = new File(getDataFolder(), fileName);
|
||||
if (!storageFile.isFile()) {
|
||||
return;
|
||||
}
|
||||
final File outFile = new File(getDataFolder(), "storage" + File.separatorChar + fileName);
|
||||
final File outDir = new File(outFile.getPath().replace(fileName, ""));
|
||||
|
||||
if (!outDir.exists()) {
|
||||
if (!outDir.mkdirs()) {
|
||||
getLogger().log(Level.SEVERE, "Failed to make directories for " + fileName + " (canWrite= "
|
||||
+ outDir.canWrite() + ")");
|
||||
}
|
||||
}
|
||||
final boolean moved = storageFile.renameTo(outFile);
|
||||
if (!moved) {
|
||||
getLogger().severe("Unable to move " + fileName + " file. Check folder permissions and restart server.");
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a Quests plugin resource to a specific path in the filesystem
|
||||
*
|
||||
* @param resourcePath jar file location starting from resource folder, i.e. "lang/el-GR/strings.yml"
|
||||
* @param outputPath file destination starting from Quests folder, i.e. "lang/el-GR/strings.yml"
|
||||
* @param replace whether or not to replace the destination file
|
||||
*/
|
||||
@Override
|
||||
public void saveResourceAs(String resourcePath, final String outputPath, final boolean replace) {
|
||||
if (resourcePath == null || resourcePath.isEmpty()) {
|
||||
throw new IllegalArgumentException("ResourcePath cannot be null or empty");
|
||||
}
|
||||
|
||||
resourcePath = resourcePath.replace('\\', '/');
|
||||
final InputStream in = getResource(resourcePath);
|
||||
if (in == null) {
|
||||
throw new IllegalArgumentException("The embedded resource '" + resourcePath
|
||||
+ "' cannot be found in Quests jar");
|
||||
}
|
||||
|
||||
final String outPath = outputPath.replace('/', File.separatorChar).replace('\\', File.separatorChar);
|
||||
final File outFile = new File(getDataFolder(), outPath);
|
||||
final File outDir = new File(outFile.getPath().replace(outFile.getName(), ""));
|
||||
|
||||
if (!outDir.exists()) {
|
||||
if (!outDir.mkdirs()) {
|
||||
getLogger().log(Level.SEVERE, "Failed to make directories for " + outFile.getName() + " (canWrite= "
|
||||
+ outDir.canWrite() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (!outFile.exists() || replace) {
|
||||
final OutputStream out = new FileOutputStream(outFile);
|
||||
final byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while ((len = in.read(buf)) > 0) {
|
||||
out.write(buf, 0, len);
|
||||
}
|
||||
out.close();
|
||||
in.close();
|
||||
if (!outFile.exists()) {
|
||||
getLogger().severe("Unable to copy " + outFile.getName() + " (canWrite= " + outFile.canWrite()
|
||||
+ ")");
|
||||
}
|
||||
}
|
||||
} catch (final IOException ex) {
|
||||
getLogger().log(Level.SEVERE, "Could not save " + outFile.getName() + " to " + outFile, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load quests, actions, conditions, and modules<br>
|
||||
* At startup, this lets soft-depends (namely Citizens) fully load first
|
||||
*/
|
||||
private void delayLoadQuestInfo() {
|
||||
getServer().getScheduler().scheduleSyncDelayedTask(this, () -> {
|
||||
conditionLoader.init();
|
||||
actionLoader.init();
|
||||
questLoader.init();
|
||||
getLogger().log(Level.INFO, "Loaded " + quests.size() + " Quest(s), " + actions.size() + " Action(s), "
|
||||
+ conditions.size() + " Condition(s) and " + BukkitLang.size() + " Phrase(s)");
|
||||
for (final Player p : getServer().getOnlinePlayers()) {
|
||||
final Quester quester = new BukkitQuester(BukkitQuestsPlugin.this, p.getUniqueId());
|
||||
if (!quester.hasData()) {
|
||||
quester.saveData();
|
||||
}
|
||||
// Workaround for issues with the compass on fast join
|
||||
quester.findCompassTarget();
|
||||
questers.add(quester);
|
||||
}
|
||||
if (depends.getCitizens() != null) {
|
||||
if (depends.getCitizens().getNPCRegistry() == null) {
|
||||
getLogger().log(Level.SEVERE,
|
||||
"Citizens was enabled but NPCRegistry was null. Disabling linkage.");
|
||||
depends.unlinkCitizens();
|
||||
}
|
||||
}
|
||||
if (depends.getZnpcsPlusApi() != null) {
|
||||
if (depends.getZnpcsPlusApi().getNpcRegistry() == null) {
|
||||
getLogger().log(Level.SEVERE,
|
||||
"ZNPCsPlus was enabled but NpcRegistry was null. Disabling linkage.");
|
||||
depends.unlinkZnpcsPlusApi();
|
||||
}
|
||||
}
|
||||
customLoader.init();
|
||||
questLoader.importQuests();
|
||||
if (getConfigSettings().canDisableCommandFeedback()) {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "gamerule sendCommandFeedback false");
|
||||
}
|
||||
loading = false;
|
||||
}, 5L);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload quests, actions, conditions, config settings, lang, modules, and player data
|
||||
*/
|
||||
public void reload(final ReloadCallback<Boolean> callback) {
|
||||
if (loading) {
|
||||
getLogger().warning(ChatColor.YELLOW + BukkitLang.get("errorLoading"));
|
||||
return;
|
||||
}
|
||||
loading = true;
|
||||
reloadConfig();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this, () -> {
|
||||
try {
|
||||
getStorage().saveOfflineQuesters().get();
|
||||
BukkitLang.clear();
|
||||
configSettings.init();
|
||||
BukkitLang.load(BukkitQuestsPlugin.this, configSettings.getLanguage());
|
||||
quests.clear();
|
||||
actions.clear();
|
||||
conditions.clear();
|
||||
conditionLoader.init();
|
||||
actionLoader.init();
|
||||
questLoader.init();
|
||||
for (final Quester quester : questers) {
|
||||
final Quester loaded = getStorage().loadQuester(quester.getUUID()).get();
|
||||
for (final Quest quest : loaded.getCurrentQuests().keySet()) {
|
||||
loaded.checkQuest(quest);
|
||||
}
|
||||
}
|
||||
customLoader.init();
|
||||
questLoader.importQuests();
|
||||
finishLoading(callback, true, null);
|
||||
} catch (final Exception e) {
|
||||
finishLoading(callback, false, e);
|
||||
}
|
||||
loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute finishing task and print provided exception
|
||||
*
|
||||
* @param callback Callback to execute
|
||||
* @param result Result to pass through callback
|
||||
* @param exception Exception to print, or null
|
||||
*/
|
||||
private void finishLoading(final ReloadCallback<Boolean> callback, boolean result, final Exception exception) {
|
||||
if (exception != null) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
if (callback != null) {
|
||||
Bukkit.getScheduler().runTask(BukkitQuestsPlugin.this, () -> {
|
||||
loading = false;
|
||||
callback.execute(result);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if player can use the Quests plugin
|
||||
*
|
||||
* @param uuid the entity UUID to be checked
|
||||
* @return {@code true} if entity is a Player that has permission
|
||||
*/
|
||||
public boolean canUseQuests(final UUID uuid) {
|
||||
final Player p = Bukkit.getPlayer(uuid);
|
||||
if (p != null) {
|
||||
for (final Permission perm : getDescription().getPermissions()) {
|
||||
if (p.hasPermission(perm.getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if conversable is non-op, non-* player in Trial Mode
|
||||
*
|
||||
* @param conversable the editor user to be checked
|
||||
* @return {@code true} if user is a Player with quests.mode.trial permission
|
||||
*/
|
||||
public boolean hasLimitedAccess(final Conversable conversable) {
|
||||
if (!(conversable instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
final Player player = ((Player)conversable);
|
||||
if (player.isOp() || player.hasPermission("*")) {
|
||||
return false;
|
||||
}
|
||||
return player.hasPermission("quests.mode.trial");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Quest by ID
|
||||
*
|
||||
* @param id ID of the quest
|
||||
* @return Exact match or null if not found
|
||||
* @since 3.8.6
|
||||
*/
|
||||
public Quest getQuestById(final String id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
for (final Quest q : quests) {
|
||||
if (q.getId().equals(id)) {
|
||||
return q;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Quest by name
|
||||
*
|
||||
* @param name Name of the quest
|
||||
* @return Closest match or null if not found
|
||||
*/
|
||||
public Quest getQuest(final String name) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
for (final Quest q : quests) {
|
||||
if (q.getName().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', name))) {
|
||||
return q;
|
||||
}
|
||||
}
|
||||
for (final Quest q : quests) {
|
||||
if (q.getName().toLowerCase().startsWith(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) {
|
||||
return q;
|
||||
}
|
||||
}
|
||||
for (final Quest q : quests) {
|
||||
if (q.getName().toLowerCase().contains(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) {
|
||||
return q;
|
||||
}
|
||||
}
|
||||
for (final Quest q : quests) {
|
||||
// For tab completion
|
||||
if (ChatColor.stripColor(q.getName()).equals(ChatColor.stripColor(ChatColor
|
||||
.translateAlternateColorCodes('&', name)))) {
|
||||
return q;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an Action by name
|
||||
*
|
||||
* @param name Name of the action
|
||||
* @return Closest match or null if not found
|
||||
*/
|
||||
public Action getAction(final String name) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
for (final Action a : actions) {
|
||||
if (a.getName().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', name))) {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
for (final Action a : actions) {
|
||||
if (a.getName().toLowerCase().startsWith(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
for (final Action a : actions) {
|
||||
if (a.getName().toLowerCase().contains(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
for (final Action a : actions) {
|
||||
// For tab completion
|
||||
if (ChatColor.stripColor(a.getName()).equals(ChatColor.stripColor(ChatColor.
|
||||
translateAlternateColorCodes('&', name)))) {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Condition by name
|
||||
*
|
||||
* @param name Name of the condition
|
||||
* @return Closest match or null if not found
|
||||
*/
|
||||
public Condition getCondition(final String name) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
for (final Condition c : conditions) {
|
||||
if (c.getName().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', name))) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
for (final Condition c : conditions) {
|
||||
if (c.getName().toLowerCase().startsWith(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
for (final Condition c : conditions) {
|
||||
if (c.getName().toLowerCase().contains(ChatColor.translateAlternateColorCodes('&', name).toLowerCase())) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
for (final Condition c : conditions) {
|
||||
// For tab completion
|
||||
if (ChatColor.stripColor(c.getName()).equals(ChatColor.stripColor(ChatColor
|
||||
.translateAlternateColorCodes('&', name)))) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,20 +1,24 @@
|
|||
/*******************************************************************************************************
|
||||
* Copyright (c) 2014 PikaMug and contributors. All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************************************/
|
||||
package me.blackvein.quests.actions;
|
||||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
package me.pikamug.quests.actions;
|
||||
|
||||
import me.pikamug.quests.BukkitQuestsPlugin;
|
||||
import me.pikamug.quests.entity.QuestMob;
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
import me.pikamug.quests.tasks.BukkitActionTimer;
|
||||
import me.pikamug.quests.util.BukkitConfigUtil;
|
||||
import me.pikamug.quests.util.BukkitInventoryUtil;
|
||||
import me.pikamug.quests.util.BukkitLang;
|
||||
import me.pikamug.quests.util.BukkitMiscUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
|
@ -23,25 +27,22 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
import me.blackvein.quests.Quest;
|
||||
import me.blackvein.quests.QuestMob;
|
||||
import me.blackvein.quests.Quester;
|
||||
import me.blackvein.quests.Quests;
|
||||
import me.blackvein.quests.tasks.ActionTimer;
|
||||
import me.blackvein.quests.util.ConfigUtil;
|
||||
import me.blackvein.quests.util.InventoryUtil;
|
||||
import me.blackvein.quests.util.Lang;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Action implements Comparable<Action> {
|
||||
public class BukkitAction implements Action {
|
||||
|
||||
private final Quests plugin;
|
||||
private final BukkitQuestsPlugin plugin;
|
||||
private String name = "";
|
||||
protected String message = null;
|
||||
protected boolean clearInv = false;
|
||||
protected boolean failQuest = false;
|
||||
protected LinkedList<Location> explosions = new LinkedList<Location>();
|
||||
protected Map<Location, Effect> effects = new HashMap<Location, Effect>();
|
||||
protected LinkedList<ItemStack> items = new LinkedList<ItemStack>();
|
||||
protected LinkedList<Location> explosions = new LinkedList<>();
|
||||
protected Map<Location, Effect> effects = new HashMap<>();
|
||||
protected LinkedList<ItemStack> items = new LinkedList<>();
|
||||
protected World stormWorld = null;
|
||||
protected int stormDuration = 0;
|
||||
protected World thunderWorld = null;
|
||||
|
@ -62,7 +63,7 @@ public class Action implements Comparable<Action> {
|
|||
return false;
|
||||
}
|
||||
for (int i = 0; i < size(); i++) {
|
||||
if (get(i).equals(other.get(i)) == false) {
|
||||
if (!get(i).equals(other.get(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -70,9 +71,9 @@ public class Action implements Comparable<Action> {
|
|||
return false;
|
||||
}
|
||||
};
|
||||
protected LinkedList<Location> lightningStrikes = new LinkedList<Location>();
|
||||
protected LinkedList<String> commands = new LinkedList<String>();
|
||||
protected LinkedList<PotionEffect> potionEffects = new LinkedList<PotionEffect>();
|
||||
protected LinkedList<Location> lightningStrikes = new LinkedList<>();
|
||||
protected LinkedList<String> commands = new LinkedList<>();
|
||||
protected LinkedList<PotionEffect> potionEffects = new LinkedList<>();
|
||||
protected int hunger = -1;
|
||||
protected int saturation = -1;
|
||||
protected float health = -1;
|
||||
|
@ -80,43 +81,51 @@ public class Action implements Comparable<Action> {
|
|||
protected String book = "";
|
||||
protected String denizenScript;
|
||||
|
||||
public Action(final Quests plugin) {
|
||||
public BukkitAction(final BukkitQuestsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(final Action action) {
|
||||
return name.compareTo(action.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMessage(final String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClearInv() {
|
||||
return clearInv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClearInv(final boolean clearInv) {
|
||||
this.clearInv = clearInv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFailQuest() {
|
||||
return failQuest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFailQuest(final boolean failQuest) {
|
||||
this.failQuest = failQuest;
|
||||
}
|
||||
|
@ -153,10 +162,12 @@ public class Action implements Comparable<Action> {
|
|||
this.stormWorld = stormWorld;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStormDuration() {
|
||||
return stormDuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStormDuration(final int stormDuration) {
|
||||
this.stormDuration = stormDuration;
|
||||
}
|
||||
|
@ -169,34 +180,42 @@ public class Action implements Comparable<Action> {
|
|||
this.thunderWorld = thunderWorld;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getThunderDuration() {
|
||||
return thunderDuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setThunderDuration(final int thunderDuration) {
|
||||
this.thunderDuration = thunderDuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTimer() {
|
||||
return timer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTimer(final int timer) {
|
||||
this.timer = timer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelTimer() {
|
||||
return cancelTimer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelTimer(final boolean cancelTimer) {
|
||||
this.cancelTimer = cancelTimer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkedList<QuestMob> getMobSpawns() {
|
||||
return mobSpawns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMobSpawns(final LinkedList<QuestMob> mobSpawns) {
|
||||
this.mobSpawns = mobSpawns;
|
||||
}
|
||||
|
@ -209,10 +228,12 @@ public class Action implements Comparable<Action> {
|
|||
this.lightningStrikes = lightningStrikes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkedList<String> getCommands() {
|
||||
return commands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCommands(final LinkedList<String> commands) {
|
||||
this.commands = commands;
|
||||
}
|
||||
|
@ -225,26 +246,32 @@ public class Action implements Comparable<Action> {
|
|||
this.potionEffects = potionEffects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHunger() {
|
||||
return hunger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHunger(final int hunger) {
|
||||
this.hunger = hunger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSaturation() {
|
||||
return saturation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSaturation(final int saturation) {
|
||||
this.saturation = saturation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHealth() {
|
||||
return health;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHealth(final float health) {
|
||||
this.health = health;
|
||||
}
|
||||
|
@ -257,18 +284,22 @@ public class Action implements Comparable<Action> {
|
|||
this.teleport = teleport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBook() {
|
||||
return book;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBook(final String book) {
|
||||
this.book = book;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getDenizenScript() {
|
||||
return book;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDenizenScript(final String scriptName) {
|
||||
this.denizenScript = scriptName;
|
||||
}
|
||||
|
@ -276,25 +307,29 @@ public class Action implements Comparable<Action> {
|
|||
public void fire(final Quester quester, final Quest quest) {
|
||||
final Player player = quester.getPlayer();
|
||||
if (message != null) {
|
||||
player.sendMessage(ConfigUtil.parseStringWithPossibleLineBreaks(message, quest, player));
|
||||
player.sendMessage(BukkitConfigUtil.parseStringWithPossibleLineBreaks(message, quest, player));
|
||||
}
|
||||
if (clearInv == true) {
|
||||
if (clearInv) {
|
||||
player.getInventory().clear();
|
||||
}
|
||||
if (explosions.isEmpty() == false) {
|
||||
if (!explosions.isEmpty()) {
|
||||
for (final Location l : explosions) {
|
||||
l.getWorld().createExplosion(l, 4F, false);
|
||||
if (l.getWorld() != null) {
|
||||
l.getWorld().createExplosion(l, 4F, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (effects.isEmpty() == false) {
|
||||
if (!effects.isEmpty()) {
|
||||
for (final Location l : effects.keySet()) {
|
||||
l.getWorld().playEffect(l, effects.get(l), 1);
|
||||
if (l.getWorld() != null) {
|
||||
l.getWorld().playEffect(l, effects.get(l), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (items.isEmpty() == false) {
|
||||
if (!items.isEmpty()) {
|
||||
for (final ItemStack is : items) {
|
||||
try {
|
||||
InventoryUtil.addItem(player, is);
|
||||
BukkitInventoryUtil.addItem(player, is);
|
||||
} catch (final Exception e) {
|
||||
plugin.getLogger().severe("Unable to add null item to inventory of "
|
||||
+ player.getName() + " during quest " + quest.getName() + " event " + name);
|
||||
|
@ -311,23 +346,25 @@ public class Action implements Comparable<Action> {
|
|||
thunderWorld.setThundering(true);
|
||||
thunderWorld.setThunderDuration(thunderDuration);
|
||||
}
|
||||
if (mobSpawns.isEmpty() == false) {
|
||||
if (!mobSpawns.isEmpty()) {
|
||||
for (final QuestMob questMob : mobSpawns) {
|
||||
questMob.spawn();
|
||||
}
|
||||
}
|
||||
if (lightningStrikes.isEmpty() == false) {
|
||||
if (!lightningStrikes.isEmpty()) {
|
||||
for (final Location l : lightningStrikes) {
|
||||
l.getWorld().strikeLightning(l);
|
||||
if (l.getWorld() != null) {
|
||||
l.getWorld().strikeLightning(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (commands.isEmpty() == false) {
|
||||
if (!commands.isEmpty()) {
|
||||
for (final String s : commands) {
|
||||
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(),
|
||||
s.replace("<player>", quester.getPlayer().getName()));
|
||||
}
|
||||
}
|
||||
if (potionEffects.isEmpty() == false) {
|
||||
if (!potionEffects.isEmpty()) {
|
||||
for (final PotionEffect p : potionEffects) {
|
||||
player.addPotionEffect(p);
|
||||
}
|
||||
|
@ -343,7 +380,7 @@ public class Action implements Comparable<Action> {
|
|||
}
|
||||
if (teleport != null) {
|
||||
if (player.isDead()) {
|
||||
plugin.getLogger().warning("Tried to fire Action " + name + " but player " + player.getUniqueId()
|
||||
plugin.getLogger().warning("Tried to fire Action " + name + " but player " + player.getUniqueId()
|
||||
+ " was dead (known Bukkit limitation).");
|
||||
} else {
|
||||
player.teleport(teleport);
|
||||
|
@ -351,65 +388,40 @@ public class Action implements Comparable<Action> {
|
|||
}
|
||||
if (book != null) {
|
||||
if (!book.isEmpty()) {
|
||||
if (plugin.getDependencies().getCitizensBooksApi() != null) {
|
||||
if (plugin.getDependencies().getCitizensBooksApi().hasFilter(book)) {
|
||||
plugin.getDependencies().getCitizensBooksApi().openBook(player, plugin.getDependencies()
|
||||
.getCitizensBooksApi().getFilter(book));
|
||||
if (plugin.getDependencies().getAstralBooksApi() != null) {
|
||||
if (plugin.getDependencies().getAstralBooksApi().hasFilterBook(book)) {
|
||||
plugin.getDependencies().getAstralBooksApi().openBook(player, plugin.getDependencies()
|
||||
.getAstralBooksApi().getFilterBook(book));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (failQuest == true) {
|
||||
if (failQuest) {
|
||||
quest.failQuest(quester, true);
|
||||
}
|
||||
if (timer > 0) {
|
||||
player.sendMessage(ChatColor.GREEN + Lang.get(player, "timerStart")
|
||||
.replace("<time>", ChatColor.RED + String.valueOf(timer) + ChatColor.GREEN));
|
||||
if (timer > 60) {
|
||||
quester.getTimers().put(new ActionTimer(quester, quest, 60, false)
|
||||
.runTaskLater(plugin, (timer-60)*20).getTaskId(), quest);
|
||||
player.sendMessage(ChatColor.GREEN + BukkitLang.get(player, "timerStart")
|
||||
.replace("<time>", BukkitMiscUtil.getTime(timer * 1000L)).replace("<quest>", quest.getName()));
|
||||
final List<Integer> toNotify = Arrays.asList(60, 30, 10, 5, 4, 3, 2, 1);
|
||||
for (final int seconds : toNotify) {
|
||||
if (timer > seconds) {
|
||||
quester.getTimers().put(new BukkitActionTimer(quester, quest, seconds)
|
||||
.runTaskLater(plugin, (timer - seconds) * 20L).getTaskId(), quest);
|
||||
}
|
||||
}
|
||||
if (timer > 30) {
|
||||
quester.getTimers().put(new ActionTimer(quester, quest, 30, false)
|
||||
.runTaskLater(plugin, (timer-30)*20).getTaskId(), quest);
|
||||
}
|
||||
if (timer > 10) {
|
||||
quester.getTimers().put(new ActionTimer(quester, quest, 10, false)
|
||||
.runTaskLater(plugin, (timer-10)*20).getTaskId(), quest);
|
||||
}
|
||||
if (timer > 5) {
|
||||
quester.getTimers().put(new ActionTimer(quester, quest, 5, false)
|
||||
.runTaskLater(plugin, (timer-5)*20).getTaskId(), quest);
|
||||
}
|
||||
if (timer > 4) {
|
||||
quester.getTimers().put(new ActionTimer(quester, quest, 4, false)
|
||||
.runTaskLater(plugin, (timer-4)*20).getTaskId(), quest);
|
||||
}
|
||||
if (timer > 3) {
|
||||
quester.getTimers().put(new ActionTimer(quester, quest, 3, false)
|
||||
.runTaskLater(plugin, (timer-3)*20).getTaskId(), quest);
|
||||
}
|
||||
if (timer > 2) {
|
||||
quester.getTimers().put(new ActionTimer(quester, quest, 2, false)
|
||||
.runTaskLater(plugin, (timer-2)*20).getTaskId(), quest);
|
||||
}
|
||||
if (timer > 1) {
|
||||
quester.getTimers().put(new ActionTimer(quester, quest, 1, false)
|
||||
.runTaskLater(plugin, (timer-1)*20).getTaskId(), quest);
|
||||
}
|
||||
quester.getTimers().put(new ActionTimer(quester, quest, 0, true)
|
||||
.runTaskLater(plugin, timer*20).getTaskId(), quest);
|
||||
quester.getTimers().put(new BukkitActionTimer(quester, quest, 0)
|
||||
.runTaskLater(plugin, timer * 20L).getTaskId(), quest);
|
||||
}
|
||||
if (cancelTimer) {
|
||||
for (final Map.Entry<Integer, Quest> entry : quester.getTimers().entrySet()) {
|
||||
if (entry.getValue().getName().equals(quest.getName())) {
|
||||
if (entry.getValue().getId().equals(quest.getId())) {
|
||||
plugin.getServer().getScheduler().cancelTask(entry.getKey());
|
||||
quester.getTimers().remove(entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (denizenScript != null) {
|
||||
plugin.getDenizenTrigger().runDenizenScript(denizenScript, quester);
|
||||
plugin.getDenizenTrigger().runDenizenScript(denizenScript, quester, null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,471 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.actions;
|
||||
|
||||
import me.pikamug.quests.BukkitQuestsPlugin;
|
||||
import me.pikamug.quests.convo.actions.main.ActionMainPrompt;
|
||||
import me.pikamug.quests.convo.actions.menu.ActionMenuPrompt;
|
||||
import me.pikamug.quests.entity.BukkitQuestMob;
|
||||
import me.pikamug.quests.entity.QuestMob;
|
||||
import me.pikamug.quests.interfaces.ReloadCallback;
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
import me.pikamug.quests.util.BukkitConfigUtil;
|
||||
import me.pikamug.quests.util.BukkitFakeConversable;
|
||||
import me.pikamug.quests.util.BukkitLang;
|
||||
import me.pikamug.quests.util.Key;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.conversations.ConversationAbandonedEvent;
|
||||
import org.bukkit.conversations.ConversationAbandonedListener;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.ConversationFactory;
|
||||
import org.bukkit.conversations.ConversationPrefix;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class BukkitActionFactory implements ActionFactory, ConversationAbandonedListener {
|
||||
|
||||
private final BukkitQuestsPlugin plugin;
|
||||
private final ConversationFactory conversationFactory;
|
||||
private ConcurrentHashMap<UUID, Block> selectedExplosionLocations = new ConcurrentHashMap<>();
|
||||
private ConcurrentHashMap<UUID, Block> selectedEffectLocations = new ConcurrentHashMap<>();
|
||||
private ConcurrentHashMap<UUID, Block> selectedMobLocations = new ConcurrentHashMap<>();
|
||||
private ConcurrentHashMap<UUID, Block> selectedLightningLocations = new ConcurrentHashMap<>();
|
||||
private ConcurrentHashMap<UUID, Block> selectedTeleportLocations = new ConcurrentHashMap<>();
|
||||
private List<String> editingActionNames = new LinkedList<>();
|
||||
|
||||
public BukkitActionFactory(final BukkitQuestsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
// Ensure to initialize factory last so that 'this' is fully initialized before it is passed
|
||||
this.conversationFactory = new ConversationFactory(plugin).withModality(false).withLocalEcho(false)
|
||||
.withFirstPrompt(new ActionMenuPrompt(new ConversationContext(plugin, new BukkitFakeConversable(),
|
||||
new HashMap<>()))).withTimeout(3600)
|
||||
.withPrefix(new LineBreakPrefix()).addConversationAbandonedListener(this);
|
||||
}
|
||||
|
||||
public static class LineBreakPrefix implements ConversationPrefix {
|
||||
@Override
|
||||
public @NotNull String getPrefix(final @NotNull ConversationContext context) {
|
||||
return "\n";
|
||||
}
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<UUID, Block> getSelectedExplosionLocations() {
|
||||
return selectedExplosionLocations;
|
||||
}
|
||||
|
||||
public void setSelectedExplosionLocations(final ConcurrentHashMap<UUID, Block> selectedExplosionLocations) {
|
||||
this.selectedExplosionLocations = selectedExplosionLocations;
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<UUID, Block> getSelectedEffectLocations() {
|
||||
return selectedEffectLocations;
|
||||
}
|
||||
|
||||
public void setSelectedEffectLocations(final ConcurrentHashMap<UUID, Block> selectedEffectLocations) {
|
||||
this.selectedEffectLocations = selectedEffectLocations;
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<UUID, Block> getSelectedMobLocations() {
|
||||
return selectedMobLocations;
|
||||
}
|
||||
|
||||
public void setSelectedMobLocations(final ConcurrentHashMap<UUID, Block> selectedMobLocations) {
|
||||
this.selectedMobLocations = selectedMobLocations;
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<UUID, Block> getSelectedLightningLocations() {
|
||||
return selectedLightningLocations;
|
||||
}
|
||||
|
||||
public void setSelectedLightningLocations(final ConcurrentHashMap<UUID, Block> selectedLightningLocations) {
|
||||
this.selectedLightningLocations = selectedLightningLocations;
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<UUID, Block> getSelectedTeleportLocations() {
|
||||
return selectedTeleportLocations;
|
||||
}
|
||||
|
||||
public void setSelectedTeleportLocations(final ConcurrentHashMap<UUID, Block> selectedTeleportLocations) {
|
||||
this.selectedTeleportLocations = selectedTeleportLocations;
|
||||
}
|
||||
|
||||
public ConversationFactory getConversationFactory() {
|
||||
return conversationFactory;
|
||||
}
|
||||
|
||||
public List<String> getNamesOfActionsBeingEdited() {
|
||||
return editingActionNames;
|
||||
}
|
||||
|
||||
public void setNamesOfActionsBeingEdited(final List<String> actionNames) {
|
||||
this.editingActionNames = actionNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void conversationAbandoned(final ConversationAbandonedEvent abandonedEvent) {
|
||||
if (abandonedEvent.getContext().getForWhom() instanceof Player) {
|
||||
final UUID uuid = ((Player) abandonedEvent.getContext().getForWhom()).getUniqueId();
|
||||
selectedExplosionLocations.remove(uuid);
|
||||
selectedEffectLocations.remove(uuid);
|
||||
selectedMobLocations.remove(uuid);
|
||||
selectedLightningLocations.remove(uuid);
|
||||
selectedTeleportLocations.remove(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
public Prompt returnToMenu(final ConversationContext context) {
|
||||
return new ActionMainPrompt(context);
|
||||
}
|
||||
|
||||
public void loadData(final ConversationContext context, final Action action) {
|
||||
BukkitAction bukkitAction = (BukkitAction) action;
|
||||
if (bukkitAction.getMessage() != null) {
|
||||
context.setSessionData(Key.A_MESSAGE, bukkitAction.getMessage());
|
||||
}
|
||||
if (bukkitAction.isClearInv()) {
|
||||
context.setSessionData(Key.A_CLEAR_INVENTORY, true);
|
||||
} else {
|
||||
context.setSessionData(Key.A_CLEAR_INVENTORY, false);
|
||||
}
|
||||
if (bukkitAction.isFailQuest()) {
|
||||
context.setSessionData(Key.A_FAIL_QUEST, true);
|
||||
} else {
|
||||
context.setSessionData(Key.A_FAIL_QUEST, false);
|
||||
}
|
||||
if (bukkitAction.getItems() != null && !bukkitAction.getItems().isEmpty()) {
|
||||
final LinkedList<ItemStack> items = new LinkedList<>(bukkitAction.getItems());
|
||||
context.setSessionData(Key.A_ITEMS, items);
|
||||
}
|
||||
if (bukkitAction.getExplosions() != null && !bukkitAction.getExplosions().isEmpty()) {
|
||||
final LinkedList<String> locs = new LinkedList<>();
|
||||
for (final Location loc : bukkitAction.getExplosions()) {
|
||||
locs.add(BukkitConfigUtil.getLocationInfo(loc));
|
||||
}
|
||||
context.setSessionData(Key.A_EXPLOSIONS, locs);
|
||||
}
|
||||
if (bukkitAction.getEffects() != null && !bukkitAction.getEffects().isEmpty()) {
|
||||
final LinkedList<String> locs = new LinkedList<>();
|
||||
final LinkedList<String> effs = new LinkedList<>();
|
||||
for (final Entry<Location, Effect> e : bukkitAction.getEffects().entrySet()) {
|
||||
locs.add(BukkitConfigUtil.getLocationInfo(e.getKey()));
|
||||
effs.add(e.getValue().toString());
|
||||
}
|
||||
context.setSessionData(Key.A_EFFECTS, effs);
|
||||
context.setSessionData(Key.A_EFFECTS_LOCATIONS, locs);
|
||||
}
|
||||
if (bukkitAction.getStormWorld() != null) {
|
||||
context.setSessionData(Key.A_WORLD_STORM, bukkitAction.getStormWorld().getName());
|
||||
context.setSessionData(Key.A_WORLD_STORM_DURATION, bukkitAction.getStormDuration());
|
||||
}
|
||||
if (bukkitAction.getThunderWorld() != null) {
|
||||
context.setSessionData(Key.A_WORLD_THUNDER, bukkitAction.getThunderWorld().getName());
|
||||
context.setSessionData(Key.A_WORLD_THUNDER_DURATION, bukkitAction.getThunderDuration());
|
||||
}
|
||||
if (bukkitAction.getMobSpawns() != null && !bukkitAction.getMobSpawns().isEmpty()) {
|
||||
context.setSessionData(Key.A_MOBS, bukkitAction.getMobSpawns());
|
||||
}
|
||||
if (bukkitAction.getLightningStrikes() != null && !bukkitAction.getLightningStrikes().isEmpty()) {
|
||||
final LinkedList<String> locs = new LinkedList<>();
|
||||
for (final Location loc : bukkitAction.getLightningStrikes()) {
|
||||
locs.add(BukkitConfigUtil.getLocationInfo(loc));
|
||||
}
|
||||
context.setSessionData(Key.A_LIGHTNING, locs);
|
||||
}
|
||||
if (bukkitAction.getPotionEffects() != null && !bukkitAction.getPotionEffects().isEmpty()) {
|
||||
final LinkedList<String> types = new LinkedList<>();
|
||||
final LinkedList<Long> durations = new LinkedList<>();
|
||||
final LinkedList<Integer> mags = new LinkedList<>();
|
||||
for (final PotionEffect pe : bukkitAction.getPotionEffects()) {
|
||||
types.add(pe.getType().getName());
|
||||
durations.add((long) pe.getDuration());
|
||||
mags.add(pe.getAmplifier());
|
||||
}
|
||||
context.setSessionData(Key.A_POTION_TYPES, types);
|
||||
context.setSessionData(Key.A_POTION_DURATIONS, durations);
|
||||
context.setSessionData(Key.A_POTION_STRENGTH, mags);
|
||||
}
|
||||
if (bukkitAction.getHunger() > -1) {
|
||||
context.setSessionData(Key.A_HUNGER, bukkitAction.getHunger());
|
||||
}
|
||||
if (bukkitAction.getSaturation() > -1) {
|
||||
context.setSessionData(Key.A_SATURATION, bukkitAction.getSaturation());
|
||||
}
|
||||
if (bukkitAction.getHealth() > -1) {
|
||||
context.setSessionData(Key.A_HEALTH, bukkitAction.getHealth());
|
||||
}
|
||||
if (bukkitAction.getTeleport() != null) {
|
||||
context.setSessionData(Key.A_TELEPORT, BukkitConfigUtil.getLocationInfo(bukkitAction.getTeleport()));
|
||||
}
|
||||
if (bukkitAction.getCommands() != null) {
|
||||
context.setSessionData(Key.A_COMMANDS, bukkitAction.getCommands());
|
||||
}
|
||||
if (bukkitAction.getTimer() > 0) {
|
||||
context.setSessionData(Key.A_TIMER, bukkitAction.getTimer());
|
||||
}
|
||||
if (bukkitAction.isCancelTimer()) {
|
||||
context.setSessionData(Key.A_CANCEL_TIMER, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearData(final ConversationContext context) {
|
||||
context.setSessionData(Key.A_OLD_ACTION, null);
|
||||
context.setSessionData(Key.A_NAME, null);
|
||||
context.setSessionData(Key.A_MESSAGE, null);
|
||||
context.setSessionData(Key.A_CLEAR_INVENTORY, null);
|
||||
context.setSessionData(Key.A_FAIL_QUEST, null);
|
||||
context.setSessionData(Key.A_ITEMS, null);
|
||||
context.setSessionData(Key.A_ITEMS_AMOUNTS, null);
|
||||
context.setSessionData(Key.A_EXPLOSIONS, null);
|
||||
context.setSessionData(Key.A_EFFECTS, null);
|
||||
context.setSessionData(Key.A_EFFECTS_LOCATIONS, null);
|
||||
context.setSessionData(Key.A_WORLD_STORM, null);
|
||||
context.setSessionData(Key.A_WORLD_STORM_DURATION, null);
|
||||
context.setSessionData(Key.A_WORLD_THUNDER, null);
|
||||
context.setSessionData(Key.A_WORLD_THUNDER_DURATION, null);
|
||||
context.setSessionData(Key.A_MOBS, null);
|
||||
context.setSessionData(Key.A_LIGHTNING, null);
|
||||
context.setSessionData(Key.A_POTION_TYPES, null);
|
||||
context.setSessionData(Key.A_POTION_DURATIONS, null);
|
||||
context.setSessionData(Key.A_POTION_STRENGTH, null);
|
||||
context.setSessionData(Key.A_HUNGER, null);
|
||||
context.setSessionData(Key.A_SATURATION, null);
|
||||
context.setSessionData(Key.A_HEALTH, null);
|
||||
context.setSessionData(Key.A_TELEPORT, null);
|
||||
context.setSessionData(Key.A_COMMANDS, null);
|
||||
context.setSessionData(Key.A_TIMER, null);
|
||||
context.setSessionData(Key.A_CANCEL_TIMER, null);
|
||||
}
|
||||
|
||||
public void deleteAction(final ConversationContext context) {
|
||||
final YamlConfiguration data = new YamlConfiguration();
|
||||
final File actionsFile = new File(plugin.getDataFolder(), "storage" + File.separatorChar + "actions.yml");
|
||||
try {
|
||||
data.load(actionsFile);
|
||||
} catch (final IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("questErrorReadingFile")
|
||||
.replace("<file>", actionsFile.getName()));
|
||||
return;
|
||||
}
|
||||
final String action = (String) context.getSessionData(Key.ED_EVENT_DELETE);
|
||||
String key = "actions";
|
||||
ConfigurationSection sec = data.getConfigurationSection(key);
|
||||
if (sec == null) {
|
||||
key = "events";
|
||||
sec = data.getConfigurationSection(key);
|
||||
}
|
||||
if (sec != null && action != null) {
|
||||
sec.set(action, null);
|
||||
}
|
||||
try {
|
||||
data.save(actionsFile);
|
||||
} catch (final IOException e) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("questSaveError"));
|
||||
return;
|
||||
}
|
||||
final ReloadCallback<Boolean> callback = response -> {
|
||||
if (!response) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("unknownError"));
|
||||
}
|
||||
};
|
||||
plugin.reload(callback);
|
||||
context.getForWhom().sendRawMessage(ChatColor.YELLOW + BukkitLang.get("eventEditorDeleted"));
|
||||
if (plugin.getConfigSettings().getConsoleLogging() > 0) {
|
||||
final String identifier = context.getForWhom() instanceof Player ?
|
||||
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
|
||||
plugin.getLogger().info(identifier + " deleted action " + action);
|
||||
}
|
||||
for (final Quester q : plugin.getOfflineQuesters()) {
|
||||
for (final Quest quest : q.getCurrentQuests().keySet()) {
|
||||
q.checkQuest(quest);
|
||||
}
|
||||
}
|
||||
clearData(context);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void saveAction(final ConversationContext context) {
|
||||
final YamlConfiguration data = new YamlConfiguration();
|
||||
final File actionsFile = new File(plugin.getDataFolder(), "storage" + File.separatorChar + "actions.yml");
|
||||
try {
|
||||
data.load(actionsFile);
|
||||
} catch (final IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("questErrorReadingFile")
|
||||
.replace("<file>", actionsFile.getName()));
|
||||
return;
|
||||
}
|
||||
String key = "actions";
|
||||
if (data.getConfigurationSection(key) == null) {
|
||||
key = "events";
|
||||
}
|
||||
if (context.getSessionData(Key.A_OLD_ACTION) != null
|
||||
&& !((String) Objects.requireNonNull(context.getSessionData(Key.A_OLD_ACTION))).isEmpty()) {
|
||||
data.set(key + "." + context.getSessionData(Key.A_OLD_ACTION), null);
|
||||
final Collection<Action> temp = plugin.getLoadedActions();
|
||||
temp.remove(plugin.getAction((String) context.getSessionData(Key.A_OLD_ACTION)));
|
||||
plugin.setLoadedActions(temp);
|
||||
}
|
||||
final ConfigurationSection section = data.createSection(key + "." + context.getSessionData(Key.A_NAME));
|
||||
editingActionNames.remove((String) context.getSessionData(Key.A_NAME));
|
||||
if (context.getSessionData(Key.A_MESSAGE) != null) {
|
||||
section.set("message", context.getSessionData(Key.A_MESSAGE));
|
||||
}
|
||||
if (context.getSessionData(Key.A_CLEAR_INVENTORY) != null) {
|
||||
final Boolean b = (Boolean) context.getSessionData(Key.A_CLEAR_INVENTORY);
|
||||
if (b != null) {
|
||||
section.set("clear-inventory", b);
|
||||
}
|
||||
}
|
||||
if (context.getSessionData(Key.A_FAIL_QUEST) != null) {
|
||||
final Boolean b = (Boolean) context.getSessionData(Key.A_FAIL_QUEST);
|
||||
if (b != null) {
|
||||
section.set("fail-quest", b);
|
||||
}
|
||||
}
|
||||
if (context.getSessionData(Key.A_ITEMS) != null) {
|
||||
section.set("items", context.getSessionData(Key.A_ITEMS));
|
||||
}
|
||||
if (context.getSessionData(Key.A_EXPLOSIONS) != null) {
|
||||
section.set("explosions", context.getSessionData(Key.A_EXPLOSIONS));
|
||||
}
|
||||
if (context.getSessionData(Key.A_EFFECTS) != null) {
|
||||
section.set("effects", context.getSessionData(Key.A_EFFECTS));
|
||||
section.set("effect-locations", context.getSessionData(Key.A_EFFECTS_LOCATIONS));
|
||||
}
|
||||
if (context.getSessionData(Key.A_WORLD_STORM) != null) {
|
||||
section.set("storm-world", context.getSessionData(Key.A_WORLD_STORM));
|
||||
section.set("storm-duration", context.getSessionData(Key.A_WORLD_STORM_DURATION));
|
||||
}
|
||||
if (context.getSessionData(Key.A_WORLD_THUNDER) != null) {
|
||||
section.set("thunder-world", context.getSessionData(Key.A_WORLD_THUNDER));
|
||||
section.set("thunder-duration", context.getSessionData(Key.A_WORLD_THUNDER_DURATION));
|
||||
}
|
||||
try {
|
||||
if (context.getSessionData(Key.A_MOBS) != null) {
|
||||
int count = 0;
|
||||
for (final QuestMob mob : (LinkedList<QuestMob>) Objects.requireNonNull(context
|
||||
.getSessionData(Key.A_MOBS))) {
|
||||
ConfigurationSection cs = section.getConfigurationSection("mob-spawns." + count);
|
||||
if (cs == null) {
|
||||
cs = section.createSection("mob-spawns." + count);
|
||||
}
|
||||
final BukkitQuestMob questMob = (BukkitQuestMob) mob;
|
||||
if (questMob.getName() != null) {
|
||||
cs.set("name", questMob.getName());
|
||||
}
|
||||
cs.set("spawn-location", BukkitConfigUtil.getLocationInfo(questMob.getSpawnLocation()));
|
||||
cs.set("mob-type", questMob.getType().name());
|
||||
cs.set("spawn-amounts", questMob.getSpawnAmounts());
|
||||
cs.set("held-item", questMob.getInventory()[0]);
|
||||
cs.set("held-item-drop-chance", questMob.getDropChances()[0]);
|
||||
cs.set("boots", questMob.getInventory()[1]);
|
||||
cs.set("boots-drop-chance", questMob.getDropChances()[1]);
|
||||
cs.set("leggings", questMob.getInventory()[2]);
|
||||
cs.set("leggings-drop-chance", questMob.getDropChances()[2]);
|
||||
cs.set("chest-plate", questMob.getInventory()[3]);
|
||||
cs.set("chest-plate-drop-chance", questMob.getDropChances()[3]);
|
||||
cs.set("helmet", questMob.getInventory()[4]);
|
||||
cs.set("helmet-drop-chance", questMob.getDropChances()[4]);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (context.getSessionData(Key.A_LIGHTNING) != null) {
|
||||
section.set("lightning-strikes", context.getSessionData(Key.A_LIGHTNING));
|
||||
}
|
||||
if (context.getSessionData(Key.A_COMMANDS) != null) {
|
||||
final LinkedList<String> commands = (LinkedList<String>) context.getSessionData(Key.A_COMMANDS);
|
||||
if (commands != null && !commands.isEmpty()) {
|
||||
section.set("commands", commands);
|
||||
}
|
||||
}
|
||||
if (context.getSessionData(Key.A_POTION_TYPES) != null) {
|
||||
section.set("potion-effect-types", context.getSessionData(Key.A_POTION_TYPES));
|
||||
section.set("potion-effect-durations", context.getSessionData(Key.A_POTION_DURATIONS));
|
||||
section.set("potion-effect-amplifiers", context.getSessionData(Key.A_POTION_STRENGTH));
|
||||
}
|
||||
if (context.getSessionData(Key.A_HUNGER) != null) {
|
||||
section.set("hunger", context.getSessionData(Key.A_HUNGER));
|
||||
}
|
||||
if (context.getSessionData(Key.A_SATURATION) != null) {
|
||||
section.set("saturation", context.getSessionData(Key.A_SATURATION));
|
||||
}
|
||||
if (context.getSessionData(Key.A_HEALTH) != null) {
|
||||
section.set("health", context.getSessionData(Key.A_HEALTH));
|
||||
}
|
||||
if (context.getSessionData(Key.A_TELEPORT) != null) {
|
||||
section.set("teleport-location", context.getSessionData(Key.A_TELEPORT));
|
||||
}
|
||||
if (context.getSessionData(Key.A_TIMER) != null) {
|
||||
final Integer i = (Integer) context.getSessionData(Key.A_TIMER);
|
||||
if (i != null && i > 0) {
|
||||
section.set("timer", context.getSessionData(Key.A_TIMER));
|
||||
}
|
||||
}
|
||||
if (context.getSessionData(Key.A_CANCEL_TIMER) != null) {
|
||||
final Boolean b = (Boolean) context.getSessionData(Key.A_CANCEL_TIMER);
|
||||
if (b != null) {
|
||||
section.set("cancel-timer", b);
|
||||
}
|
||||
}
|
||||
if (context.getSessionData(Key.A_DENIZEN) != null) {
|
||||
section.set("denizen-script", context.getSessionData(Key.A_DENIZEN));
|
||||
}
|
||||
try {
|
||||
data.save(actionsFile);
|
||||
} catch (final IOException e) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("questSaveError"));
|
||||
return;
|
||||
}
|
||||
final ReloadCallback<Boolean> callback = response -> {
|
||||
if (!response) {
|
||||
context.getForWhom().sendRawMessage(ChatColor.RED + BukkitLang.get("unknownError"));
|
||||
}
|
||||
};
|
||||
plugin.reload(callback);
|
||||
context.getForWhom().sendRawMessage(ChatColor.YELLOW + BukkitLang.get("eventEditorSaved"));
|
||||
if (plugin.getConfigSettings().getConsoleLogging() > 0) {
|
||||
final String identifier = context.getForWhom() instanceof Player ?
|
||||
"Player " + ((Player)context.getForWhom()).getUniqueId() : "CONSOLE";
|
||||
plugin.getLogger().info(identifier + " saved action " + context.getSessionData(Key.A_NAME));
|
||||
}
|
||||
for (final Quester q : plugin.getOfflineQuesters()) {
|
||||
for (final Quest quest : q.getCurrentQuests().keySet()) {
|
||||
q.checkQuest(quest);
|
||||
}
|
||||
}
|
||||
clearData(context);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.commands;
|
||||
|
||||
import me.pikamug.quests.util.BukkitLang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class BukkitQuestsSubCommand {
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
public abstract String getNameI18N();
|
||||
|
||||
public abstract String getDescription();
|
||||
|
||||
public abstract String getPermission();
|
||||
|
||||
public abstract String getSyntax();
|
||||
|
||||
public abstract int getMaxArguments();
|
||||
|
||||
public abstract void execute(CommandSender commandSender, String[] args);
|
||||
|
||||
public List<String> tabComplete(CommandSender commandSender, String[] args) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public static boolean assertNonPlayer(CommandSender commandSender) {
|
||||
if (!(commandSender instanceof Player)) {
|
||||
commandSender.sendMessage(ChatColor.YELLOW + BukkitLang.get("consoleError"));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an online Player by name
|
||||
*
|
||||
* @param name Name of the player
|
||||
* @return Player or null if not found
|
||||
*/
|
||||
public static Player getOnlinePlayer(final String name) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
for (final Player p : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (p.getName().equalsIgnoreCase(name)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
for (final Player p : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (p.getName().toLowerCase().startsWith(name)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
for (final Player p : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (p.getName().toLowerCase().contains(name)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a potentially offline Player by name
|
||||
*
|
||||
* @param name Name of the player
|
||||
* @return Player or null if not found
|
||||
*/
|
||||
public static OfflinePlayer getOfflinePlayer(final String name) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
final Player player = getOnlinePlayer(name);
|
||||
if (player != null) {
|
||||
return player;
|
||||
}
|
||||
for (final OfflinePlayer p : Bukkit.getServer().getOfflinePlayers()) {
|
||||
if (p != null && p.getName() != null && p.getName().equalsIgnoreCase(name)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
for (final OfflinePlayer p : Bukkit.getServer().getOfflinePlayers()) {
|
||||
if (p != null && p.getName() != null && p.getName().toLowerCase().startsWith(name)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
for (final OfflinePlayer p : Bukkit.getServer().getOfflinePlayers()) {
|
||||
if (p != null && p.getName() != null && p.getName().toLowerCase().contains(name)) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get quest names that contain spaces from command input
|
||||
*
|
||||
* @param args an array of Strings
|
||||
* @param startingIndex the index to start combining at
|
||||
* @param endingIndex the index to stop combining at
|
||||
* @param delimiter the character for which the array was split
|
||||
* @return a String or null
|
||||
*/
|
||||
public static String concatArgArray(final String[] args, final int startingIndex, final int endingIndex,
|
||||
final char delimiter) {
|
||||
StringBuilder s = new StringBuilder();
|
||||
for (int i = startingIndex; i <= endingIndex; i++) {
|
||||
s.append(args[i]).append(delimiter);
|
||||
}
|
||||
s = new StringBuilder(s.substring(0, s.length()));
|
||||
return s.toString().trim().isEmpty() ? null : s.toString().trim();
|
||||
}
|
||||
|
||||
public static Map<String, Integer> sort(final Map<String, Integer> unsortedMap) {
|
||||
final List<Map.Entry<String, Integer>> list = new LinkedList<>(unsortedMap.entrySet());
|
||||
list.sort((o1, o2) -> {
|
||||
final int i = o1.getValue();
|
||||
final int i2 = o2.getValue();
|
||||
return Integer.compare(i2, i);
|
||||
});
|
||||
final Map<String, Integer> sortedMap = new LinkedHashMap<>();
|
||||
for (final Map.Entry<String, Integer> entry : list) {
|
||||
sortedMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return sortedMap;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,230 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.commands.quest;
|
||||
|
||||
import me.pikamug.quests.BukkitQuestsPlugin;
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.quests.components.BukkitRequirements;
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
import me.pikamug.quests.quests.components.Stage;
|
||||
import me.pikamug.quests.util.BukkitItemUtil;
|
||||
import me.pikamug.quests.util.BukkitMiscUtil;
|
||||
import me.pikamug.quests.util.BukkitLang;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BukkitQuestCommandHandler {
|
||||
|
||||
private final BukkitQuestsPlugin plugin;
|
||||
|
||||
public BukkitQuestCommandHandler(BukkitQuestsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public boolean check(final CommandSender cs, final String[] args) {
|
||||
if (cs instanceof Player) {
|
||||
if (cs.hasPermission("quests.quest")) {
|
||||
if (args.length == 0) {
|
||||
final Player player = (Player) cs;
|
||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
if (!quester.getCurrentQuests().isEmpty()) {
|
||||
for (final Quest q : quester.getCurrentQuests().keySet()) {
|
||||
final Stage stage = quester.getCurrentStage(q);
|
||||
q.updateCompass(quester, stage);
|
||||
if (plugin.getQuester(player.getUniqueId()).getQuestDataOrDefault(q).getDelayStartTime() == 0
|
||||
|| plugin.getQuester(player.getUniqueId()).getStageTime(q) < 0L) {
|
||||
final String msg = BukkitLang.get(player, "questObjectivesTitle")
|
||||
.replace("<quest>", q.getName());
|
||||
BukkitLang.send(player, ChatColor.GOLD + msg);
|
||||
quester.showCurrentObjectives(q, quester, false);
|
||||
} else {
|
||||
final long time = plugin.getQuester(player.getUniqueId()).getStageTime(q);
|
||||
String msg = ChatColor.YELLOW + "(" + BukkitLang.get(player, "delay") + ") " + ChatColor.RED
|
||||
+ BukkitLang.get(player, "plnTooEarly");
|
||||
msg = msg.replace("<quest>", q.getName());
|
||||
msg = msg.replace("<time>", BukkitMiscUtil.getTime(time));
|
||||
BukkitLang.send(player, msg);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
BukkitLang.send(player, ChatColor.YELLOW + BukkitLang.get(player, "noActiveQuest"));
|
||||
}
|
||||
} else {
|
||||
showQuestDetails(cs, args);
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + BukkitLang.get("noPermission"));
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.YELLOW + BukkitLang.get("consoleError"));
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> suggest(final CommandSender cs, final String[] args) {
|
||||
if (args.length != 1) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
final List<String> results = new ArrayList<>();
|
||||
for (final Quest quest : plugin.getLoadedQuests()) {
|
||||
if (quest.getName().toLowerCase().startsWith(args[0].toLowerCase())) {
|
||||
results.add(ChatColor.stripColor(quest.getName()));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private void showQuestDetails(final CommandSender cs, final String[] args) {
|
||||
if (cs.hasPermission("quests.questinfo")) {
|
||||
StringBuilder name = new StringBuilder();
|
||||
if (args.length == 1) {
|
||||
name = new StringBuilder(args[0].toLowerCase());
|
||||
} else {
|
||||
int index = 0;
|
||||
for (final String s : args) {
|
||||
if (index == (args.length - 1)) {
|
||||
name.append(s.toLowerCase());
|
||||
} else {
|
||||
name.append(s.toLowerCase()).append(" ");
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
final Quest q = plugin.getQuest(name.toString());
|
||||
if (q != null) {
|
||||
final Player player = (Player) cs;
|
||||
final Quester quester = plugin.getQuester(player.getUniqueId());
|
||||
cs.sendMessage(ChatColor.GOLD + "- " + q.getName() + " -");
|
||||
cs.sendMessage(" ");
|
||||
if (q.getNpcStart() != null) {
|
||||
String msg = BukkitLang.get("speakTo");
|
||||
msg = msg.replace("<npc>", q.getNpcStartName());
|
||||
cs.sendMessage(ChatColor.YELLOW + msg);
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.YELLOW + q.getDescription());
|
||||
}
|
||||
cs.sendMessage(" ");
|
||||
if (plugin.getConfigSettings().canShowQuestReqs()) {
|
||||
final BukkitRequirements reqs = (BukkitRequirements) q.getRequirements();
|
||||
if (reqs.hasRequirement()) {
|
||||
cs.sendMessage(ChatColor.GOLD + BukkitLang.get("requirements"));
|
||||
if (!reqs.getPermissions().isEmpty()) {
|
||||
for (final String perm : reqs.getPermissions()) {
|
||||
if (plugin.getDependencies().getVaultPermission().has(player, perm)) {
|
||||
cs.sendMessage(ChatColor.GREEN + BukkitLang.get("permissionDisplay") + " " + perm);
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + BukkitLang.get("permissionDisplay") + " " + perm);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (reqs.getHeroesPrimaryClass() != null) {
|
||||
if (plugin.getDependencies()
|
||||
.testPrimaryHeroesClass(reqs.getHeroesPrimaryClass(), player.getUniqueId())) {
|
||||
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + reqs.getHeroesPrimaryClass()
|
||||
+ ChatColor.RESET + "" + ChatColor.DARK_GREEN + " " + BukkitLang.get("heroesClass"));
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.DARK_RED + reqs.getHeroesPrimaryClass()
|
||||
+ ChatColor.RESET + "" + ChatColor.RED + " " + BukkitLang.get("heroesClass"));
|
||||
}
|
||||
}
|
||||
if (reqs.getHeroesSecondaryClass() != null) {
|
||||
if (plugin.getDependencies()
|
||||
.testSecondaryHeroesClass(reqs.getHeroesSecondaryClass(), player.getUniqueId())) {
|
||||
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.DARK_RED + reqs.getHeroesSecondaryClass()
|
||||
+ ChatColor.RESET + "" + ChatColor.RED + " " + BukkitLang.get("heroesClass"));
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.BOLD + "" + ChatColor.GREEN + reqs.getHeroesSecondaryClass()
|
||||
+ ChatColor.RESET + "" + ChatColor.DARK_GREEN + " " + BukkitLang.get("heroesClass"));
|
||||
}
|
||||
}
|
||||
for (final String skill : reqs.getMcmmoSkills()) {
|
||||
final int level = plugin.getDependencies().getMcmmoSkillLevel(plugin.getDependencies()
|
||||
.getMcMMOSkill(skill), player.getName());
|
||||
final int req = reqs.getMcmmoAmounts().get(reqs.getMcmmoSkills().indexOf(skill));
|
||||
final String skillName = BukkitMiscUtil.getCapitalized(skill);
|
||||
if (level >= req) {
|
||||
cs.sendMessage(ChatColor.GREEN + skillName + " " + BukkitLang.get("mcMMOLevel") + " " + req);
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + skillName + " " + BukkitLang.get("mcMMOLevel") + " " + req);
|
||||
}
|
||||
}
|
||||
if (reqs.getQuestPoints() != 0) {
|
||||
if (quester.getQuestPoints() >= reqs.getQuestPoints()) {
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + reqs.getQuestPoints() + " "
|
||||
+ BukkitLang.get("questPoints"));
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + reqs.getQuestPoints() + " "
|
||||
+ BukkitLang.get("questPoints"));
|
||||
}
|
||||
}
|
||||
if (reqs.getMoney() != 0) {
|
||||
if (plugin.getDependencies().getVaultEconomy() != null && plugin.getDependencies()
|
||||
.getVaultEconomy().getBalance(quester.getOfflinePlayer()) >= reqs.getMoney()) {
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + reqs.getMoney() + " "
|
||||
+ (reqs.getMoney() > 1 ? plugin.getDependencies().getVaultEconomy()
|
||||
.currencyNamePlural() : plugin.getDependencies().getVaultEconomy()
|
||||
.currencyNameSingular()));
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + reqs.getMoney() + " "
|
||||
+ (reqs.getMoney() > 1 ? plugin.getDependencies().getVaultEconomy()
|
||||
.currencyNamePlural() : plugin.getDependencies().getVaultEconomy()
|
||||
.currencyNameSingular()));
|
||||
}
|
||||
}
|
||||
for (final ItemStack is : reqs.getItems()) {
|
||||
if (plugin.getQuester(player.getUniqueId()).hasItem(is)) {
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + BukkitItemUtil.getString(is));
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + BukkitItemUtil.getString(is));
|
||||
}
|
||||
}
|
||||
for (Quest quest : quester.getCompletedQuests()) {
|
||||
if (reqs.getNeededQuestIds().contains(quest.getId())) {
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + BukkitLang.get("complete") + " "
|
||||
+ ChatColor.ITALIC + quest.getName());
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + BukkitLang.get("complete") + " "
|
||||
+ ChatColor.ITALIC + quest.getName());
|
||||
}
|
||||
}
|
||||
final Map<String, String> completed = quester.getCompletedQuests().stream()
|
||||
.collect(Collectors.toMap(Quest::getId, Quest::getName));
|
||||
for (final String questId : reqs.getBlockQuestIds()) {
|
||||
if (completed.containsKey(questId)) {
|
||||
String msg = BukkitLang.get("haveCompleted");
|
||||
msg = msg.replace("<quest>", completed.get(questId));
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + msg);
|
||||
} else {
|
||||
String msg = BukkitLang.get("cannotComplete");
|
||||
msg = msg.replace("<quest>", plugin.getQuestById(questId).getName());
|
||||
cs.sendMessage(ChatColor.GRAY + "- " + ChatColor.GREEN + msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.YELLOW + BukkitLang.get("questNotFound").replace("<input>", name.toString()));
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + BukkitLang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,171 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.commands.questadmin;
|
||||
|
||||
import me.pikamug.quests.BukkitQuestsPlugin;
|
||||
import me.pikamug.quests.commands.questadmin.subcommands.BukkitQuestadminFinishCommand;
|
||||
import me.pikamug.quests.commands.questadmin.subcommands.BukkitQuestadminGiveCommand;
|
||||
import me.pikamug.quests.commands.questadmin.subcommands.BukkitQuestadminGivepointsCommand;
|
||||
import me.pikamug.quests.commands.questadmin.subcommands.BukkitQuestadminNextstageCommand;
|
||||
import me.pikamug.quests.commands.questadmin.subcommands.BukkitQuestadminPointsCommand;
|
||||
import me.pikamug.quests.commands.questadmin.subcommands.BukkitQuestadminQuitCommand;
|
||||
import me.pikamug.quests.commands.questadmin.subcommands.BukkitQuestadminReloadCommand;
|
||||
import me.pikamug.quests.commands.questadmin.subcommands.BukkitQuestadminRemoveCommand;
|
||||
import me.pikamug.quests.commands.questadmin.subcommands.BukkitQuestadminResetCommand;
|
||||
import me.pikamug.quests.commands.questadmin.subcommands.BukkitQuestadminSetstageCommand;
|
||||
import me.pikamug.quests.commands.questadmin.subcommands.BukkitQuestadminStatsCommand;
|
||||
import me.pikamug.quests.commands.questadmin.subcommands.BukkitQuestadminTakepointsCommand;
|
||||
import me.pikamug.quests.commands.BukkitQuestsSubCommand;
|
||||
import me.pikamug.quests.util.BukkitLang;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class BukkitQuestadminCommandHandler {
|
||||
|
||||
private final BukkitQuestsPlugin plugin;
|
||||
private final Map<String, BukkitQuestsSubCommand> subCommands;
|
||||
|
||||
public BukkitQuestadminCommandHandler(BukkitQuestsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
subCommands = Stream.of(new BukkitQuestadminStatsCommand(plugin),
|
||||
new BukkitQuestadminGiveCommand(plugin),
|
||||
new BukkitQuestadminQuitCommand(plugin),
|
||||
new BukkitQuestadminPointsCommand(plugin),
|
||||
new BukkitQuestadminTakepointsCommand(plugin),
|
||||
new BukkitQuestadminGivepointsCommand(plugin),
|
||||
new BukkitQuestadminFinishCommand(plugin),
|
||||
new BukkitQuestadminNextstageCommand(plugin),
|
||||
new BukkitQuestadminSetstageCommand(plugin),
|
||||
new BukkitQuestadminResetCommand(plugin),
|
||||
new BukkitQuestadminRemoveCommand(plugin),
|
||||
new BukkitQuestadminReloadCommand(plugin))
|
||||
.collect(Collectors.toMap(BukkitQuestsSubCommand::getName, Function.identity()));
|
||||
}
|
||||
|
||||
public boolean check(final CommandSender cs, final String[] args) {
|
||||
if (args.length == 0) {
|
||||
printAdminHelp(cs);
|
||||
return true;
|
||||
}
|
||||
for (Map.Entry<String, BukkitQuestsSubCommand> cmd : subCommands.entrySet()) {
|
||||
if (args[0].equalsIgnoreCase(cmd.getKey()) || args[0].equalsIgnoreCase(cmd.getValue().getNameI18N())) {
|
||||
if (args.length < cmd.getValue().getMaxArguments()) {
|
||||
cs.sendMessage(getAdminCommandUsage(cs, args[0]));
|
||||
}
|
||||
cmd.getValue().execute(cs, args);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
cs.sendMessage(ChatColor.YELLOW + BukkitLang.get("questsUnknownAdminCommand"));
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<String> suggest(final CommandSender cs, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
final List<String> results = new ArrayList<>();
|
||||
for (Map.Entry<String, BukkitQuestsSubCommand> cmd : subCommands.entrySet()) {
|
||||
if (cmd.getKey().startsWith(args[0]) || cmd.getValue().getNameI18N().startsWith(args[0])) {
|
||||
results.add(cmd.getValue().getNameI18N());
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
for (Map.Entry<String, BukkitQuestsSubCommand> cmd : subCommands.entrySet()) {
|
||||
if (args[0].equalsIgnoreCase(cmd.getKey()) || args[0].equalsIgnoreCase(cmd.getValue().getNameI18N())) {
|
||||
return cmd.getValue().tabComplete(cs, args);
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private void printAdminHelp(final CommandSender cs) {
|
||||
if (!(cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin"))) {
|
||||
cs.sendMessage(ChatColor.RED + BukkitLang.get("noPermission"));
|
||||
return;
|
||||
}
|
||||
cs.sendMessage(ChatColor.GOLD + BukkitLang.get("questAdminHelpTitle"));
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin" + ChatColor.RED + " " + BukkitLang.get("COMMAND_QUESTADMIN_HELP"));
|
||||
final boolean translateSubCommands = plugin.getConfigSettings().canTranslateSubCommands();
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.stats")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED + BukkitLang.get("COMMAND_QUESTADMIN_STATS_HELP")
|
||||
.replace("<command>", translateSubCommands ? BukkitLang.get("COMMAND_QUESTADMIN_STATS") : "stats"));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.give")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED + BukkitLang.get("COMMAND_QUESTADMIN_GIVE_HELP")
|
||||
.replace("<command>", translateSubCommands ? BukkitLang.get("COMMAND_QUESTADMIN_GIVE") : "give"));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.quit")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED + BukkitLang.get("COMMAND_QUESTADMIN_QUIT_HELP")
|
||||
.replace("<command>", translateSubCommands ? BukkitLang.get("COMMAND_QUESTADMIN_QUIT") : "quit"));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.points")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED
|
||||
+ BukkitLang.get("COMMAND_QUESTADMIN_POINTS_HELP")
|
||||
.replace("<points>", BukkitLang.get("questPoints"))
|
||||
.replace("<command>", translateSubCommands ? BukkitLang.get("COMMAND_QUESTADMIN_POINTS") : "points"));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.takepoints")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED
|
||||
+ BukkitLang.get("COMMAND_QUESTADMIN_TAKEPOINTS_HELP")
|
||||
.replace("<points>", BukkitLang.get("questPoints"))
|
||||
.replace("<command>", translateSubCommands ? BukkitLang.get("COMMAND_QUESTADMIN_TAKEPOINTS") : "takepoints"));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.givepoints")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED
|
||||
+ BukkitLang.get("COMMAND_QUESTADMIN_GIVEPOINTS_HELP")
|
||||
.replace("<points>", BukkitLang.get("questPoints"))
|
||||
.replace("<command>", translateSubCommands ? BukkitLang.get("COMMAND_QUESTADMIN_GIVEPOINTS") : "givepoints"));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.finish")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED
|
||||
+ BukkitLang.get("COMMAND_QUESTADMIN_FINISH_HELP").replace("<command>",
|
||||
translateSubCommands ? BukkitLang.get("COMMAND_QUESTADMIN_FINISH") : "finish"));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.nextstage")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED
|
||||
+ BukkitLang.get("COMMAND_QUESTADMIN_NEXTSTAGE_HELP").replace("<command>",
|
||||
translateSubCommands ? BukkitLang.get("COMMAND_QUESTADMIN_NEXTSTAGE") : "nextstage"));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.setstage")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED
|
||||
+ BukkitLang.get("COMMAND_QUESTADMIN_SETSTAGE_HELP").replace("<command>",
|
||||
translateSubCommands ? BukkitLang.get("COMMAND_QUESTADMIN_SETSTAGE") : "setstage"));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.reset")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED+ BukkitLang.get("COMMAND_QUESTADMIN_RESET_HELP")
|
||||
.replace("<command>", translateSubCommands ? BukkitLang.get("COMMAND_QUESTADMIN_RESET") : "reset"));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.remove")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED
|
||||
+ BukkitLang.get("COMMAND_QUESTADMIN_REMOVE_HELP").replace("<command>",
|
||||
translateSubCommands ? BukkitLang.get("COMMAND_QUESTADMIN_REMOVE") : "remove"));
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.reload")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "/questadmin " + ChatColor.RED
|
||||
+ BukkitLang.get("COMMAND_QUESTADMIN_RELOAD_HELP").replace("<command>",
|
||||
translateSubCommands ? BukkitLang.get("COMMAND_QUESTADMIN_RELOAD") : "reload"));
|
||||
}
|
||||
}
|
||||
|
||||
private String getAdminCommandUsage(final CommandSender cs, final String cmd) {
|
||||
return ChatColor.RED + BukkitLang.get(cs, "usage") + ": " + ChatColor.YELLOW + "/questadmin "
|
||||
+ BukkitLang.get(cs, BukkitLang.getKeyFromPrefix("COMMAND_QUESTADMIN_", cmd) + "_HELP")
|
||||
.replace("<command>", cmd.toLowerCase());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.pikamug.quests.player.BukkitQuester;
|
||||
import me.pikamug.quests.BukkitQuestsPlugin;
|
||||
import me.pikamug.quests.commands.BukkitQuestsSubCommand;
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
import me.pikamug.quests.util.BukkitLang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitQuestadminFinishCommand extends BukkitQuestsSubCommand {
|
||||
|
||||
private final BukkitQuestsPlugin plugin;
|
||||
|
||||
public BukkitQuestadminFinishCommand(BukkitQuestsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "finish";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return BukkitLang.get("COMMAND_QUESTADMIN_FINISH");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return BukkitLang.get("COMMAND_QUESTADMIN_FINISH_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.finish";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin finish";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxArguments() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.finish")) {
|
||||
OfflinePlayer target = getOfflinePlayer(args[1]);
|
||||
if (target == null) {
|
||||
try {
|
||||
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
if (target == null || target.getName() == null) {
|
||||
cs.sendMessage(ChatColor.YELLOW + BukkitLang.get("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
final Quester quester = plugin.getQuester(target.getUniqueId());
|
||||
if (quester.getCurrentQuests().isEmpty() && target.getName() != null) {
|
||||
String msg = BukkitLang.get("noCurrentQuest");
|
||||
msg = msg.replace("<player>", target.getName());
|
||||
cs.sendMessage(ChatColor.YELLOW + msg);
|
||||
} else {
|
||||
final String questName = concatArgArray(args, 2, args.length - 1, ' ');
|
||||
final Quest quest = plugin.getQuest(questName);
|
||||
if (quest == null) {
|
||||
cs.sendMessage(ChatColor.RED + BukkitLang.get("questNotFound")
|
||||
.replace("<input>", questName != null ? questName : ""));
|
||||
return;
|
||||
}
|
||||
String msg1 = BukkitLang.get("questForceFinish");
|
||||
msg1 = msg1.replace("<player>", target.getName());
|
||||
msg1 = msg1.replace("<quest>", quest.getName());
|
||||
cs.sendMessage(ChatColor.GOLD + msg1);
|
||||
if (target.isOnline()) {
|
||||
final Player p = (Player)target;
|
||||
String msg2 = BukkitLang.get(p, "questForcedFinish");
|
||||
msg2 = msg2.replace("<player>", cs.getName());
|
||||
msg2 = msg2.replace("<quest>", quest.getName());
|
||||
p.sendMessage(ChatColor.GREEN + msg2);
|
||||
}
|
||||
quest.completeQuest(quester);
|
||||
quester.saveData();
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + BukkitLang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender commandSender, String[] args) {
|
||||
if (args.length == 2) {
|
||||
return null; // Shows online players
|
||||
} else if (args.length == 3) {
|
||||
final List<String> results = new ArrayList<>();
|
||||
final Player player = Bukkit.getPlayer(args[1]);
|
||||
if (player != null) {
|
||||
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
|
||||
if (quester != null) {
|
||||
for (final Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
|
||||
results.add(ChatColor.stripColor(quest.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (final Quest quest : plugin.getLoadedQuests()) {
|
||||
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
|
||||
results.add(ChatColor.stripColor(quest.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,148 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.pikamug.quests.BukkitQuestsPlugin;
|
||||
import me.pikamug.quests.commands.BukkitQuestsSubCommand;
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
import me.pikamug.quests.util.BukkitLang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitQuestadminGiveCommand extends BukkitQuestsSubCommand {
|
||||
|
||||
private final BukkitQuestsPlugin plugin;
|
||||
|
||||
public BukkitQuestadminGiveCommand(BukkitQuestsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "give";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return BukkitLang.get("COMMAND_QUESTADMIN_GIVE");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return BukkitLang.get("COMMAND_QUESTADMIN_GIVE_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.give";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin give";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxArguments() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.give")) {
|
||||
OfflinePlayer target = getOfflinePlayer(args[1]);
|
||||
if (target == null) {
|
||||
try {
|
||||
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
if (target == null || target.getName() == null) {
|
||||
cs.sendMessage(ChatColor.YELLOW + BukkitLang.get("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
final Quest questToGive;
|
||||
StringBuilder name = new StringBuilder();
|
||||
if (args.length == 3) {
|
||||
name = new StringBuilder(args[2].toLowerCase());
|
||||
} else {
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
final int lastIndex = args.length - 1;
|
||||
if (i == lastIndex) {
|
||||
name.append(args[i].toLowerCase());
|
||||
} else {
|
||||
name.append(args[i].toLowerCase()).append(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
questToGive = plugin.getQuest(name.toString());
|
||||
if (questToGive == null) {
|
||||
cs.sendMessage(ChatColor.YELLOW + BukkitLang.get("questNotFound").replace("<input>", name.toString()));
|
||||
} else {
|
||||
final Quester quester = plugin.getQuester(target.getUniqueId());
|
||||
for (final Quest q : quester.getCurrentQuests().keySet()) {
|
||||
if (q.getName().equalsIgnoreCase(questToGive.getName())) {
|
||||
String msg = BukkitLang.get("questsPlayerHasQuestAlready");
|
||||
msg = msg.replace("<player>", target.getName());
|
||||
msg = msg.replace("<quest>", questToGive.getName());
|
||||
cs.sendMessage(ChatColor.YELLOW + msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
quester.hardQuit(questToGive);
|
||||
String msg1 = BukkitLang.get("questForceTake");
|
||||
msg1 = msg1.replace("<player>", target.getName());
|
||||
msg1 = msg1.replace("<quest>", questToGive.getName());
|
||||
cs.sendMessage(ChatColor.GOLD + msg1);
|
||||
if (target.isOnline()) {
|
||||
final Player p = (Player)target;
|
||||
String msg2 = BukkitLang.get(p, "questForcedTake");
|
||||
msg2 = msg2.replace("<player>", cs.getName());
|
||||
msg2 = msg2.replace("<quest>", questToGive.getName());
|
||||
p.sendMessage(ChatColor.GREEN + msg2);
|
||||
}
|
||||
quester.takeQuest(questToGive, true);
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + BukkitLang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender commandSender, String[] args) {
|
||||
if (args.length == 2) {
|
||||
return null; // Shows online players
|
||||
} else if (args.length == 3) {
|
||||
final List<String> results = new ArrayList<>();
|
||||
for (final Quest quest : plugin.getLoadedQuests()) {
|
||||
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
|
||||
results.add(ChatColor.stripColor(quest.getName()));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.pikamug.quests.BukkitQuestsPlugin;
|
||||
import me.pikamug.quests.commands.BukkitQuestsSubCommand;
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.util.BukkitLang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitQuestadminGivepointsCommand extends BukkitQuestsSubCommand {
|
||||
|
||||
private final BukkitQuestsPlugin plugin;
|
||||
|
||||
public BukkitQuestadminGivepointsCommand(BukkitQuestsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "givepoints";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return BukkitLang.get("COMMAND_QUESTADMIN_GIVEPOINTS");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return BukkitLang.get("COMMAND_QUESTADMIN_GIVEPOINTS_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.givepoints";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin givepoints";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxArguments() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.givepoints")) {
|
||||
OfflinePlayer target = getOfflinePlayer(args[1]);
|
||||
if (target == null) {
|
||||
try {
|
||||
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
if (target == null || target.getName() == null) {
|
||||
cs.sendMessage(ChatColor.YELLOW + BukkitLang.get("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
final int points;
|
||||
try {
|
||||
points = Integer.parseInt(args[2]);
|
||||
} catch (final NumberFormatException e) {
|
||||
cs.sendMessage(ChatColor.YELLOW + BukkitLang.get("inputNum"));
|
||||
return;
|
||||
}
|
||||
final Quester quester = plugin.getQuester(target.getUniqueId());
|
||||
quester.setQuestPoints(quester.getQuestPoints() + Math.abs(points));
|
||||
String msg1 = BukkitLang.get("giveQuestPoints").replace("<points>", BukkitLang.get("questPoints"));
|
||||
msg1 = msg1.replace("<player>", target.getName());
|
||||
msg1 = msg1.replace("<number>", String.valueOf(points));
|
||||
cs.sendMessage(ChatColor.GOLD + msg1);
|
||||
if (target.isOnline()) {
|
||||
final Player p = (Player)target;
|
||||
String msg2 = BukkitLang.get(p, "questPointsGiven").replace("<points>", BukkitLang.get("questPoints"));
|
||||
msg2 = msg2.replace("<player>", cs.getName());
|
||||
msg2 = msg2.replace("<number>", String.valueOf(points));
|
||||
p.sendMessage(ChatColor.GREEN + msg2);
|
||||
}
|
||||
quester.saveData();
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + BukkitLang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender commandSender, String[] args) {
|
||||
if (args.length == 2) {
|
||||
return null; // Shows online players
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.pikamug.quests.player.BukkitQuester;
|
||||
import me.pikamug.quests.BukkitQuestsPlugin;
|
||||
import me.pikamug.quests.commands.BukkitQuestsSubCommand;
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
import me.pikamug.quests.util.BukkitLang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitQuestadminNextstageCommand extends BukkitQuestsSubCommand {
|
||||
|
||||
private final BukkitQuestsPlugin plugin;
|
||||
|
||||
public BukkitQuestadminNextstageCommand(BukkitQuestsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "nextstage";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return BukkitLang.get("COMMAND_QUESTADMIN_NEXTSTAGE");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return BukkitLang.get("COMMAND_QUESTADMIN_NEXTSTAGE_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.nextstage";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin nextstage";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxArguments() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.nextstage")) {
|
||||
OfflinePlayer target = getOfflinePlayer(args[1]);
|
||||
if (target == null) {
|
||||
try {
|
||||
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
if (target == null || target.getName() == null) {
|
||||
cs.sendMessage(ChatColor.YELLOW + BukkitLang.get("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
final Quester quester = plugin.getQuester(target.getUniqueId());
|
||||
if (quester.getCurrentQuests().isEmpty()) {
|
||||
String msg = BukkitLang.get("noCurrentQuest");
|
||||
msg = msg.replace("<player>", target.getName());
|
||||
cs.sendMessage(ChatColor.YELLOW + msg);
|
||||
} else {
|
||||
final String questName = concatArgArray(args, 2, args.length - 1, ' ');
|
||||
final Quest quest = plugin.getQuest(questName);
|
||||
if (quest == null) {
|
||||
cs.sendMessage(ChatColor.RED + BukkitLang.get("questNotFound")
|
||||
.replace("<input>", questName != null ? questName : ""));
|
||||
return;
|
||||
}
|
||||
String msg1 = BukkitLang.get("questForceNextStage");
|
||||
msg1 = msg1.replace("<player>", target.getName());
|
||||
msg1 = msg1.replace("<quest>", quest.getName());
|
||||
cs.sendMessage(ChatColor.GOLD + msg1);
|
||||
if (target.isOnline()) {
|
||||
final Player p = (Player)target;
|
||||
String msg2 = BukkitLang.get(p, "questForcedNextStage");
|
||||
msg2 = msg2.replace("<player>", cs.getName());
|
||||
msg2 = msg2.replace("<quest>", quest.getName());
|
||||
p.sendMessage(ChatColor.GREEN + msg2);
|
||||
}
|
||||
quest.nextStage(quester, false);
|
||||
quester.saveData();
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + BukkitLang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender commandSender, String[] args) {
|
||||
if (args.length == 2) {
|
||||
return null; // Shows online players
|
||||
} else if (args.length == 3) {
|
||||
final List<String> results = new ArrayList<>();
|
||||
final Player player = Bukkit.getPlayer(args[1]);
|
||||
if (player != null) {
|
||||
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
|
||||
if (quester != null) {
|
||||
for (final Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
|
||||
results.add(ChatColor.stripColor(quest.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (final Quest quest : plugin.getLoadedQuests()) {
|
||||
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
|
||||
results.add(ChatColor.stripColor(quest.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.pikamug.quests.BukkitQuestsPlugin;
|
||||
import me.pikamug.quests.commands.BukkitQuestsSubCommand;
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.util.BukkitLang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitQuestadminPointsCommand extends BukkitQuestsSubCommand {
|
||||
|
||||
private final BukkitQuestsPlugin plugin;
|
||||
|
||||
public BukkitQuestadminPointsCommand(BukkitQuestsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "points";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return BukkitLang.get("COMMAND_QUESTADMIN_POINTS");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return BukkitLang.get("COMMAND_QUESTADMIN_POINTS_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.points";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin points";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxArguments() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.points")) {
|
||||
OfflinePlayer target = getOfflinePlayer(args[1]);
|
||||
if (target == null) {
|
||||
try {
|
||||
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
if (target == null || target.getName() == null) {
|
||||
cs.sendMessage(ChatColor.YELLOW + BukkitLang.get("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
final int points;
|
||||
try {
|
||||
points = Integer.parseInt(args[2]);
|
||||
} catch (final NumberFormatException e) {
|
||||
cs.sendMessage(ChatColor.YELLOW + BukkitLang.get("inputNum"));
|
||||
return;
|
||||
}
|
||||
final Quester quester = plugin.getQuester(target.getUniqueId());
|
||||
quester.setQuestPoints(points);
|
||||
String msg1 = BukkitLang.get("setQuestPoints").replace("<points>", BukkitLang.get("questPoints"));
|
||||
msg1 = msg1.replace("<player>", target.getName());
|
||||
msg1 = msg1.replace("<number>", String.valueOf(points));
|
||||
cs.sendMessage(ChatColor.GOLD + msg1);
|
||||
if (target.isOnline()) {
|
||||
final Player p = (Player)target;
|
||||
String msg2 = BukkitLang.get(p, "questPointsSet").replace("<points>", BukkitLang.get("questPoints"));
|
||||
msg2 = msg2.replace("<player>", cs.getName());
|
||||
msg2 = msg2.replace("<number>", String.valueOf(points));
|
||||
p.sendMessage(ChatColor.GREEN + msg2);
|
||||
}
|
||||
quester.saveData();
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + BukkitLang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender commandSender, String[] args) {
|
||||
if (args.length == 2) {
|
||||
return null; // Shows online players
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.pikamug.quests.player.BukkitQuester;
|
||||
import me.pikamug.quests.BukkitQuestsPlugin;
|
||||
import me.pikamug.quests.commands.BukkitQuestsSubCommand;
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
import me.pikamug.quests.util.BukkitLang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitQuestadminQuitCommand extends BukkitQuestsSubCommand {
|
||||
|
||||
private final BukkitQuestsPlugin plugin;
|
||||
|
||||
public BukkitQuestadminQuitCommand(BukkitQuestsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "quit";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return BukkitLang.get("COMMAND_QUESTADMIN_QUIT");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return BukkitLang.get("COMMAND_QUESTADMIN_QUIT_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.quit";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin quit";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxArguments() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.quit")) {
|
||||
OfflinePlayer target = getOfflinePlayer(args[1]);
|
||||
if (target == null) {
|
||||
try {
|
||||
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
if (target == null || target.getName() == null) {
|
||||
cs.sendMessage(ChatColor.YELLOW + BukkitLang.get("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
final Quester quester = plugin.getQuester(target.getUniqueId());
|
||||
if (quester.getCurrentQuests().isEmpty() && target.getName() != null) {
|
||||
String msg = BukkitLang.get("noCurrentQuest");
|
||||
msg = msg.replace("<player>", target.getName());
|
||||
cs.sendMessage(ChatColor.YELLOW + msg);
|
||||
} else {
|
||||
final String questName = concatArgArray(args, 2, args.length - 1, ' ');
|
||||
final Quest quest = plugin.getQuest(questName);
|
||||
if (quest == null) {
|
||||
cs.sendMessage(ChatColor.RED + BukkitLang.get("questNotFound")
|
||||
.replace("<input>", questName != null ? questName : ""));
|
||||
return;
|
||||
}
|
||||
String msg1 = BukkitLang.get("questForceQuit");
|
||||
msg1 = msg1.replace("<player>", target.getName());
|
||||
msg1 = msg1.replace("<quest>", quest.getName());
|
||||
cs.sendMessage(ChatColor.GOLD + msg1);
|
||||
String msg2 = BukkitLang.get((Player) target, "questForcedQuit");
|
||||
msg2 = msg2.replace("<player>", cs.getName());
|
||||
msg2 = msg2.replace("<quest>", quest.getName());
|
||||
quester.quitQuest(quest, msg2);
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + BukkitLang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender commandSender, String[] args) {
|
||||
if (args.length == 2) {
|
||||
return null; // Shows online players
|
||||
} else if (args.length == 3) {
|
||||
final List<String> results = new ArrayList<>();
|
||||
final Player player = Bukkit.getPlayer(args[1]);
|
||||
if (player != null) {
|
||||
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
|
||||
if (quester != null) {
|
||||
for (final Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
|
||||
results.add(ChatColor.stripColor(quest.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (final Quest quest : plugin.getLoadedQuests()) {
|
||||
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
|
||||
results.add(ChatColor.stripColor(quest.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.pikamug.quests.BukkitQuestsPlugin;
|
||||
import me.pikamug.quests.commands.BukkitQuestsSubCommand;
|
||||
import me.pikamug.quests.interfaces.ReloadCallback;
|
||||
import me.pikamug.quests.util.BukkitLang;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class BukkitQuestadminReloadCommand extends BukkitQuestsSubCommand {
|
||||
|
||||
private final BukkitQuestsPlugin plugin;
|
||||
|
||||
public BukkitQuestadminReloadCommand(BukkitQuestsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "reload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return BukkitLang.get("COMMAND_QUESTADMIN_RELOAD");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return BukkitLang.get("COMMAND_QUESTADMIN_RELOAD_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.reload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin reload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxArguments() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.reload")) {
|
||||
final ReloadCallback<Boolean> callback = response -> {
|
||||
if (response) {
|
||||
cs.sendMessage(ChatColor.GOLD + BukkitLang.get("questsReloaded"));
|
||||
String msg = BukkitLang.get("numQuestsLoaded");
|
||||
msg = msg.replace("<number>", String.valueOf(plugin.getLoadedQuests().size()));
|
||||
cs.sendMessage(ChatColor.GOLD + msg);
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + BukkitLang.get("unknownError"));
|
||||
}
|
||||
};
|
||||
plugin.reload(callback);
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + BukkitLang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.pikamug.quests.player.BukkitQuester;
|
||||
import me.pikamug.quests.BukkitQuestsPlugin;
|
||||
import me.pikamug.quests.commands.BukkitQuestsSubCommand;
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
import me.pikamug.quests.util.BukkitLang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitQuestadminRemoveCommand extends BukkitQuestsSubCommand {
|
||||
|
||||
private final BukkitQuestsPlugin plugin;
|
||||
|
||||
public BukkitQuestadminRemoveCommand(BukkitQuestsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "remove";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return BukkitLang.get("COMMAND_QUESTADMIN_REMOVE");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return BukkitLang.get("COMMAND_QUESTADMIN_REMOVE_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.remove";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin remove";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxArguments() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") && cs.hasPermission("quests.admin.remove")) {
|
||||
OfflinePlayer target = getOfflinePlayer(args[1]);
|
||||
if (target == null) {
|
||||
try {
|
||||
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
if (target == null || target.getName() == null) {
|
||||
cs.sendMessage(ChatColor.YELLOW + BukkitLang.get("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
final String questName = concatArgArray(args, 2, args.length - 1, ' ');
|
||||
final Quest toRemove = plugin.getQuest(questName);
|
||||
if (toRemove == null) {
|
||||
cs.sendMessage(ChatColor.RED + BukkitLang.get("questNotFound")
|
||||
.replace("<input>", questName != null ? questName : ""));
|
||||
return;
|
||||
}
|
||||
final Quester quester = plugin.getQuester(target.getUniqueId());
|
||||
String msg = BukkitLang.get("questRemoved");
|
||||
if (target.getName() != null) {
|
||||
msg = msg.replace("<player>", target.getName());
|
||||
} else {
|
||||
msg = msg.replace("<player>", args[1]);
|
||||
}
|
||||
msg = msg.replace("<quest>", toRemove.getName());
|
||||
cs.sendMessage(ChatColor.GOLD + msg);
|
||||
cs.sendMessage(ChatColor.DARK_PURPLE + " UUID: " + ChatColor.DARK_AQUA + quester.getUUID().toString());
|
||||
quester.hardRemove(toRemove);
|
||||
quester.saveData();
|
||||
quester.updateJournal();
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + BukkitLang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender commandSender, String[] args) {
|
||||
if (args.length == 2) {
|
||||
return null; // Shows online players
|
||||
} else if (args.length == 3) {
|
||||
final List<String> results = new ArrayList<>();
|
||||
final Player player = Bukkit.getPlayer(args[1]);
|
||||
if (player != null) {
|
||||
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
|
||||
if (quester != null) {
|
||||
for (final Quest quest : quester.getCompletedQuests()) {
|
||||
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
|
||||
results.add(ChatColor.stripColor(quest.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (final Quest quest : plugin.getLoadedQuests()) {
|
||||
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
|
||||
results.add(ChatColor.stripColor(quest.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.pikamug.quests.player.BukkitQuester;
|
||||
import me.pikamug.quests.BukkitQuestsPlugin;
|
||||
import me.pikamug.quests.commands.BukkitQuestsSubCommand;
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.storage.QuesterStorage;
|
||||
import me.pikamug.quests.util.BukkitLang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
|
||||
public class BukkitQuestadminResetCommand extends BukkitQuestsSubCommand {
|
||||
|
||||
private final BukkitQuestsPlugin plugin;
|
||||
|
||||
public BukkitQuestadminResetCommand(BukkitQuestsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "reset";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return BukkitLang.get("COMMAND_QUESTADMIN_RESET");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return BukkitLang.get("COMMAND_QUESTADMIN_RESET_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.reset";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin reset";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxArguments() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.reset")) {
|
||||
OfflinePlayer target = getOfflinePlayer(args[1]);
|
||||
if (target == null) {
|
||||
try {
|
||||
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
if (target == null || target.getName() == null) {
|
||||
cs.sendMessage(ChatColor.YELLOW + BukkitLang.get("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
final UUID id = target.getUniqueId();
|
||||
final ConcurrentSkipListSet<Quester> temp = (ConcurrentSkipListSet<Quester>) plugin.getOfflineQuesters();
|
||||
temp.removeIf(quester -> quester.getUUID().equals(id));
|
||||
plugin.setOfflineQuesters(temp);
|
||||
Quester quester = plugin.getQuester(id);
|
||||
try {
|
||||
quester.resetCompass();
|
||||
quester.hardClear();
|
||||
quester.saveData();
|
||||
quester.updateJournal();
|
||||
final QuesterStorage storage = plugin.getStorage();
|
||||
storage.deleteQuester(id);
|
||||
String msg = BukkitLang.get("questReset");
|
||||
if (target.getName() != null) {
|
||||
msg = msg.replace("<player>", target.getName());
|
||||
} else {
|
||||
msg = msg.replace("<player>", args[1]);
|
||||
}
|
||||
cs.sendMessage(ChatColor.GOLD + msg);
|
||||
cs.sendMessage(ChatColor.DARK_PURPLE + " UUID: " + ChatColor.DARK_AQUA + id);
|
||||
} catch (final Exception e) {
|
||||
plugin.getLogger().info("Data file does not exist for " + id);
|
||||
}
|
||||
quester = new BukkitQuester(plugin, id);
|
||||
quester.saveData();
|
||||
final ConcurrentSkipListSet<Quester> temp2 = (ConcurrentSkipListSet<Quester>) plugin.getOfflineQuesters();
|
||||
temp2.add(quester);
|
||||
plugin.setOfflineQuesters(temp2);
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + BukkitLang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender commandSender, String[] args) {
|
||||
if (args.length == 2) {
|
||||
return null; // Shows online players
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,171 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.pikamug.quests.BukkitQuestsPlugin;
|
||||
import me.pikamug.quests.commands.BukkitQuestsSubCommand;
|
||||
import me.pikamug.quests.player.BukkitQuester;
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
import me.pikamug.quests.util.BukkitLang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitQuestadminSetstageCommand extends BukkitQuestsSubCommand {
|
||||
|
||||
private final BukkitQuestsPlugin plugin;
|
||||
|
||||
public BukkitQuestadminSetstageCommand(BukkitQuestsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "setstage";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return BukkitLang.get("COMMAND_QUESTADMIN_SETSTAGE");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return BukkitLang.get("COMMAND_QUESTADMIN_SETSTAGE_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.setstage";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin setstage";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxArguments() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.setstage")) {
|
||||
OfflinePlayer target = getOfflinePlayer(args[1]);
|
||||
if (target == null) {
|
||||
try {
|
||||
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
if (target == null || target.getName() == null) {
|
||||
cs.sendMessage(ChatColor.YELLOW + BukkitLang.get("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
int stage;
|
||||
try {
|
||||
stage = Integer.parseInt(args[args.length - 1]);
|
||||
} catch (final NumberFormatException e) {
|
||||
cs.sendMessage(ChatColor.YELLOW + BukkitLang.get("inputNum"));
|
||||
return;
|
||||
}
|
||||
final Quester quester = plugin.getQuester(target.getUniqueId());
|
||||
if (quester.getCurrentQuests().isEmpty() && target.getName() != null) {
|
||||
String msg = BukkitLang.get("noCurrentQuest");
|
||||
msg = msg.replace("<player>", target.getName());
|
||||
cs.sendMessage(ChatColor.YELLOW + msg);
|
||||
} else {
|
||||
final String questName = concatArgArray(args, 2, args.length - 2, ' ');
|
||||
final Quest quest = plugin.getQuest(concatArgArray(args, 2, args.length - 2, ' '));
|
||||
if (quest == null) {
|
||||
cs.sendMessage(ChatColor.RED + BukkitLang.get("questNotFound")
|
||||
.replace("<input>", questName != null ? questName : ""));
|
||||
return;
|
||||
}
|
||||
if (!quester.getCurrentQuests().containsKey(quest)) {
|
||||
String msg1 = BukkitLang.get("questForceTake");
|
||||
msg1 = msg1.replace("<player>", quester.getLastKnownName());
|
||||
msg1 = msg1.replace("<quest>", quest.getName());
|
||||
cs.sendMessage(ChatColor.GOLD + msg1);
|
||||
if (quester.getPlayer() != null && quester.getPlayer().isOnline()) {
|
||||
String msg2 = BukkitLang.get("questForcedTake");
|
||||
msg2 = msg2.replace("<player>", quester.getLastKnownName());
|
||||
msg2 = msg2.replace("<quest>", quest.getName());
|
||||
quester.sendMessage(ChatColor.GREEN + msg2);
|
||||
}
|
||||
quester.takeQuest(quest, true);
|
||||
quester.saveData();
|
||||
}
|
||||
try {
|
||||
quest.setStage(quester, stage - 1);
|
||||
} catch (final IndexOutOfBoundsException e) {
|
||||
String msg = BukkitLang.get("invalidRange");
|
||||
msg = msg.replace("<least>", "1").replace("<greatest>", String.valueOf(quest.getStages().size()));
|
||||
cs.sendMessage(ChatColor.RED + msg);
|
||||
}
|
||||
quester.saveData();
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + BukkitLang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender commandSender, String[] args) {
|
||||
if (args.length == 2) {
|
||||
return null; // Shows online players
|
||||
} else if (args.length == 3) {
|
||||
final List<String> results = new ArrayList<>();
|
||||
final Player player = Bukkit.getPlayer(args[1]);
|
||||
if (player != null) {
|
||||
final BukkitQuester quester = plugin.getQuester(player.getUniqueId());
|
||||
if (quester != null) {
|
||||
for (final Quest quest : quester.getCurrentQuests().keySet()) {
|
||||
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
|
||||
results.add(ChatColor.stripColor(quest.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (final Quest quest : plugin.getLoadedQuests()) {
|
||||
if (quest.getName().toLowerCase().startsWith(args[2].toLowerCase())) {
|
||||
results.add(ChatColor.stripColor(quest.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
} else if (args.length > 3) {
|
||||
final Quest quest = plugin.getQuest(args[2]);
|
||||
if (quest != null) {
|
||||
final List<String> results = new ArrayList<>();
|
||||
for (int i = 1; i <= quest.getStages().size(); i++) {
|
||||
results.add(String.valueOf(i));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* Copyright (c) PikaMug and contributors
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package me.pikamug.quests.commands.questadmin.subcommands;
|
||||
|
||||
import me.pikamug.quests.BukkitQuestsPlugin;
|
||||
import me.pikamug.quests.commands.BukkitQuestsSubCommand;
|
||||
import me.pikamug.quests.player.Quester;
|
||||
import me.pikamug.quests.quests.Quest;
|
||||
import me.pikamug.quests.util.BukkitLang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitQuestadminStatsCommand extends BukkitQuestsSubCommand {
|
||||
|
||||
private final BukkitQuestsPlugin plugin;
|
||||
|
||||
public BukkitQuestadminStatsCommand(BukkitQuestsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "stats";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameI18N() {
|
||||
return BukkitLang.get("COMMAND_QUESTADMIN_STATS");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return BukkitLang.get("COMMAND_QUESTADMIN_STATS_HELP");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "quests.admin.stats";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/questadmin stats";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxArguments() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") && cs.hasPermission("quests.admin.stats")) {
|
||||
OfflinePlayer target = getOfflinePlayer(args[1]);
|
||||
if (target == null) {
|
||||
try {
|
||||
target = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
|
||||
} catch (final IllegalArgumentException e) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
if (target == null || target.getName() == null) {
|
||||
cs.sendMessage(ChatColor.YELLOW + BukkitLang.get("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
final Quester quester = plugin.getQuester(target.getUniqueId());
|
||||
cs.sendMessage(ChatColor.GOLD + "- " + target.getName() + " -");
|
||||
cs.sendMessage(ChatColor.YELLOW + BukkitLang.get("questPoints") + " - " + ChatColor.DARK_PURPLE
|
||||
+ quester.getQuestPoints());
|
||||
if (quester.getCurrentQuests().isEmpty()) {
|
||||
cs.sendMessage(ChatColor.YELLOW + BukkitLang.get("currentQuest") + " " + ChatColor.DARK_PURPLE+ BukkitLang.get("none"));
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.YELLOW + BukkitLang.get("currentQuest"));
|
||||
for (final Map.Entry<Quest, Integer> set : quester.getCurrentQuests().entrySet()) {
|
||||
final Quest q = set.getKey();
|
||||
final String msg = ChatColor.LIGHT_PURPLE + " - " + ChatColor.DARK_PURPLE + q.getName()
|
||||
+ ChatColor.LIGHT_PURPLE + " (" + BukkitLang.get("stageEditorStage") + " " + (set.getValue() + 1) + ")";
|
||||
cs.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
cs.sendMessage(ChatColor.YELLOW + BukkitLang.get("completedQuest"));
|
||||
|
||||
if (quester.getCompletedQuests().isEmpty()) {
|
||||
cs.sendMessage(ChatColor.DARK_PURPLE + BukkitLang.get("none"));
|
||||
} else {
|
||||
final StringBuilder completed = new StringBuilder(" ");
|
||||
int index = 1;
|
||||
for (final Quest q : quester.getCompletedQuests()) {
|
||||
completed.append(ChatColor.DARK_PURPLE).append(q.getName());
|
||||
if (quester.getAmountsCompleted().containsKey(q) && quester.getAmountsCompleted().get(q) > 1) {
|
||||
completed.append(ChatColor.LIGHT_PURPLE).append(" (x").append(quester.getAmountsCompleted()
|
||||
.get(q)).append(")");
|
||||
}
|
||||
if (index < (quester.getCompletedQuests().size())) {
|
||||
completed.append(", ");
|
||||
}
|
||||
index++;
|
||||
}
|
||||
cs.sendMessage(completed.toString());
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.RED + BukkitLang.get("noPermission"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender commandSender, String[] args) {
|
||||
if (args.length == 2) {
|
||||
return null; // Shows online players
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue