9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-19 15:09:19 +00:00

Compare commits

...

464 Commits

Author SHA1 Message Date
LoJoSho
8453a8b20d version bump (2.5.0) 2023-07-30 10:55:25 -05:00
lucian929
e59ee03ac7 feat: add hibiscus flower cosmetic 2023-07-29 19:04:41 -04:00
lucian929
01155f40dd fix: i forgot jetpack 2023-07-29 18:48:39 -04:00
lucian929
fa9f81e5e2 feat: add firstperson-items for cosmetics 2023-07-29 18:34:47 -04:00
LoJoSho
54bcef1a45 Merge pull request #120 from AverageGithub/fixes
Fixes
2023-07-28 10:55:04 -05:00
AverageGithub
8e14899397 Fix to 1.18 & 1.19.1/2 2023-07-28 14:21:30 +02:00
AverageGithub
061718a3b6 Fix title times not being used correctly 2023-07-28 13:05:24 +02:00
AverageGithub
2eea426460 Fix skin layers 2023-07-28 13:00:40 +02:00
LoJoSho
b0136d6076 Merge pull request #119 from AverageGithub/exploit-fix
fix players in wardrobe after teleporting
2023-07-27 09:01:35 -05:00
AverageGithub
d0b45b951c Fix import messup 2023-07-27 10:53:15 +02:00
AverageGithub
e42f5c8c7d Fix exploit 2023-07-27 10:48:08 +02:00
LoJoSho
5d4fb85fec fix: first-person backpack not in correct position in first seconds on join 2023-07-26 15:23:24 -05:00
LoJoSho
04b11a0830 feat: backend recode of the menu system, add refresh rate to auto-update gui 2023-07-26 15:09:25 -05:00
LoJoSho
353086b9c1 fix: not formatting minimessage in translations 2023-07-26 12:46:50 -05:00
LoJoSho
4e40a7cc96 clean: remove unused backpack type 2023-07-25 19:21:25 -05:00
LoJoSho
e2715fe631 fix: remove entities from players 2023-07-25 19:20:41 -05:00
LoJoSho
c7deb756db fix: first-person backpacks in hidden areas 2023-07-25 19:20:20 -05:00
LoJoSho
11f26f8f0a fix: first-person backpacks not showing properly in wardrobes 2023-07-25 19:12:46 -05:00
LoJoSho
6d814d86b3 feat: second iteration of first-person backpacks (focused on other player viewing the backpack) 2023-07-25 15:06:57 -05:00
LoJoSho
12f8b05469 feat: first iteration of first-person backpacks 2023-07-25 14:09:09 -05:00
LoJoSho
b5322bc10b clean: push runserver to 1.20.1 2023-07-25 10:21:37 -05:00
LoJoSho
7a4fd9a98b clean: remove unused utils 2023-07-19 13:39:27 -05:00
LoJoSho
239e13fab2 clean: annotations turned bad 2023-07-19 13:37:58 -05:00
LoJoSho
94b5a1bb3b Merge remote-tracking branch 'origin/remapped' into remapped
# Conflicts:
#	common/src/main/java/com/hibiscusmc/hmccosmetics/api/HMCCosmeticsAPI.java
2023-07-19 13:19:21 -05:00
LoJoSho
71ed820917 feat: slightly expanded api to equip and uneqip cosmetics in main API class 2023-07-19 13:19:04 -05:00
LoJoSho
20532fbaf2 feat: slightly expanded api to equip and remove cosmetics in main API class 2023-07-19 13:18:06 -05:00
LoJoSho
4068af98d2 fix: supervanish dependency 2023-07-19 12:26:50 -05:00
LoJoSho
95e83992de feat: update to gradle 8 2023-07-19 12:25:07 -05:00
LoJoSho
96817d7279 clean: update plugin-yml gradle plugin 2023-07-19 11:09:25 -05:00
LoJoSho
ba7a99247a fix: showing hidden cosmetics actionbar while playing emotes 2023-07-19 10:08:43 -05:00
LoJoSho
f1da6105c0 feat: disable playing emotes in WG region 2023-07-19 10:07:08 -05:00
LoJoSho
c06a4fcede feat: move ModelEngine integration to hook system 2023-07-19 09:54:10 -05:00
LoJoSho
afb20ea0bb clean: update PAPI dependency 2023-07-09 21:44:15 -05:00
LoJoSho
774caf8d91 version bump (2.4.11-DEV) 2023-07-09 21:25:41 -05:00
LoJoSho
a0c2c8a9aa clean: removed unused packet 2023-07-09 21:05:04 -05:00
LoJoSho
5b7f75f7a0 version bump (2.4.10) 2023-07-09 17:53:13 -05:00
LoJoSho
3f7d010dfa clean: optimize imports 2023-07-08 22:48:28 -05:00
LoJoSho
4d84bd681d clean: optimize imports 2023-07-08 22:48:17 -05:00
LoJoSho
0daff3044d feat: move placeholder processing to one method 2023-07-08 22:47:42 -05:00
LoJoSho
ee87338cd4 fix: Cosmin taking up our command >:( 2023-07-08 22:27:06 -05:00
LoJoSho
2b467e63ce feat: remove internal data (deprecated) 2023-07-08 22:11:37 -05:00
LoJoSho
6000cf9c1b clean: clean 2 am coding 2023-07-08 12:04:42 -05:00
LoJoSho
f2b0fb29d3 fix: Leads not properly disappearing teleporting into WG region with hidden cosmetics 2023-07-08 11:40:08 -05:00
LoJoSho
d2962ba5ed version bump (2.4.10-DEV) 2023-07-08 11:39:41 -05:00
LoJoSho
b37083a298 version bump (2.4.9) 2023-06-29 10:00:24 -05:00
LoJoSho
e35a29a13b feat: empty cosmetic type item name go through PAPI 2023-06-29 09:57:08 -05:00
LoJoSho
344aaf32e0 fix: PAPI placeholders not being applied in displaynames in guis 2023-06-28 18:06:58 -05:00
LoJoSho
6498cb43ea version bump (2.4.9-DEV) 2023-06-28 18:06:41 -05:00
LoJoSho
0120720cc3 version bump (2.4.8) 2023-06-27 10:27:43 -05:00
LoJoSho
d1bfa5abbc feat: add force-show-join to show regardless of hidden in database 2023-06-27 10:16:30 -05:00
LoJoSho
71a080a3d5 feat: Option to open menu on wardrobe enter 2023-06-27 09:54:35 -05:00
LoJoSho
78f48703db fix: prevent kicking when message is null/empty 2023-06-27 09:44:11 -05:00
LoJoSho
b9e5096d33 feat: actionbar when player has hidden cosmetics 2023-06-27 09:43:56 -05:00
LoJoSho
d7603b5108 version bump (2.4.8-DEV) 2023-06-27 09:28:03 -05:00
LoJoSho
756e3390a1 clean: remove old code commented out 2023-06-24 20:45:59 -05:00
LoJoSho
8054a35f43 feat: add recursive file lookup 2023-06-23 14:45:27 -05:00
LoJoSho
3b863e6dde version bump (2.4.7) 2023-06-22 13:38:54 -05:00
LoJoSho
b682dd7c42 feat: optimize new packet pufferfish system 2023-06-22 13:15:44 -05:00
LoJoSho
f34f5f01aa version bump (2.4.7-DEV) 2023-06-22 12:56:04 -05:00
LoJoSho
cb9248db7a feat: Refactored CosmeticUser to accept other entities, not just players 2023-06-22 12:55:56 -05:00
LoJoSho
61ee228990 version bump (2.4.6) 2023-06-19 14:00:05 -05:00
LoJoSho
14e061e487 fix: exiting emote does not refresh armor 2023-06-19 13:26:33 -05:00
LoJoSho
9dc2c23d04 feat: create HMCCosmeticsAPI class 2023-06-19 13:19:24 -05:00
LoJoSho
684f8a4790 clean: move events to their own api package 2023-06-19 13:16:43 -05:00
LoJoSho
5d782bb6a3 fix: send empty equipment packet on emote for player 2023-06-19 13:03:19 -05:00
LoJoSho
988ec04a2e feat: remove 1.17 support 2023-06-19 12:37:34 -05:00
LoJoSho
ebf87f01b8 version bump (2.4.5) 2023-06-16 22:41:34 -05:00
LoJoSho
6032eb0782 fix: improve handling of invalid backpacks 2023-06-16 22:34:57 -05:00
LoJoSho
6d8c46783f feat: add PAPI support for display names 2023-06-16 22:33:59 -05:00
LoJoSho
407061d125 clean: remove previous todo 2023-06-16 22:15:47 -05:00
LoJoSho
f8192d734b feat: Cosmetics now support PAPI in lore and skull owners/textures 2023-06-16 22:15:25 -05:00
LoJoSho
190f8f776d feat: WorldGuard listens to PlayerTeleportEvent 2023-06-16 17:37:49 -05:00
LoJoSho
cd80bc746e fix: wrong index for 1.18.2 player info packet 2023-06-15 13:13:16 -05:00
LoJoSho
d96a8e5622 version bump (2.4.4) 2023-06-14 21:17:29 -05:00
LoJoSho
53091f102e feat: Readded Translations 2023-06-14 21:11:06 -05:00
LoJoSho
1d24881df1 version bump (2.4.4-DEV) 2023-06-14 20:30:06 -05:00
LoJoSho
ae0dc7bd14 fix: Geary Hook 2023-06-14 20:29:36 -05:00
LoJoSho
b9a57fc48f version bump (2.4.3) 2023-06-13 11:59:54 -05:00
LoJoSho
1e2db05e45 feat: equipping emote stops emote 2023-06-13 11:59:16 -05:00
LoJoSho
4e2291d16f clean: menu class cleaning 2023-06-13 11:51:38 -05:00
LoJoSho
2e95a9bf58 version bump (2.4.3-DEV) 2023-06-13 11:12:07 -05:00
LoJoSho
0de6c1416c fix: balloons causing NPC disappearance 2023-06-13 11:11:15 -05:00
LoJoSho
f8c2e0e605 feat: add PlayerCosmeticPostEquipEvent to api 2023-06-13 11:10:24 -05:00
LoJoSho
23ad3eaf65 version bump (2.4.2) 2023-06-12 15:07:51 -05:00
LoJoSho
97887961db fix: playeranimator bump to 1.2.7 2023-06-12 14:55:50 -05:00
LoJoSho
e48dcf9150 version bump (2.4.1) 2023-06-10 16:02:27 -05:00
LoJoSho
0f65c20095 fix: include 1.20 files into jar 2023-06-10 15:49:40 -05:00
LoJoSho
68b0955a1f feat: add 1.20 NMS support 2023-06-10 15:40:13 -05:00
LoJoSho
1193bc43d7 Merge remote-tracking branch 'origin/remapped' into remapped 2023-06-10 15:18:18 -05:00
LoJoSho
f5105200de fix: unchecked wardrobes not unapplying 2023-06-10 15:17:11 -05:00
Boy
1b7fdd3dcf fix geary-hook 2023-06-10 20:23:13 +02:00
LoJoSho
2e4130012f temp remove Geary Hook 2023-06-09 09:28:37 -05:00
LoJoSho
bf7517ab20 feat: text can now be applied above player while emote playing 2023-06-08 21:30:05 -05:00
LoJoSho
813642ee92 version bump (2.4.1-DEV) 2023-05-25 16:23:03 -05:00
LoJoSho
f266721781 fix: backpacks disappearing on teleporting 2023-05-25 16:19:04 -05:00
LoJoSho
9793114ea0 fix: Geary logic not being under load 2023-05-25 13:33:50 -05:00
LoJoSho
b00c79f67b Merge pull request #111 from HibiscusMC/multi_wardrobe
Wardrobe Improvements (2.4.0)
2023-05-25 10:10:21 -05:00
LoJoSho
0528ebfa84 feat: rename setlocation to setwardrobesetting to allow modification of permission and distance ingame 2023-05-24 16:56:06 -05:00
LoJoSho
1e0ffdc08b clean: summer cleaning of CosmeticUser.java 2023-05-24 16:41:54 -05:00
LoJoSho
cc08cc6537 feat: message.yml to sync as well 2023-05-24 16:36:47 -05:00
LoJoSho
455b8cd1a1 version bump (2.4.0) 2023-05-24 16:29:07 -05:00
LoJoSho
5c6bb93e6c feat: add removeWardrobe method 2023-05-24 15:08:43 -05:00
LoJoSho
e9c7946319 feat: create new wardrobes in-game 2023-05-24 15:05:13 -05:00
LoJoSho
fcde8e7f25 feat: send message if locations are not all setup 2023-05-24 15:03:41 -05:00
LoJoSho
7fcbbd6b5a feat: add wardrobes to internal map 2023-05-24 15:03:23 -05:00
LoJoSho
a92b4c15f5 feat: check if wardrobe locations are not null 2023-05-24 15:03:13 -05:00
LoJoSho
7439aabfd1 clean: random space in wardrobe debug message 2023-05-24 14:53:59 -05:00
LoJoSho
50bda8343c fix: wardrobe region not entering wardrobe 2023-05-24 14:53:16 -05:00
LoJoSho
c189424aa8 fix: setlocation command now shows no-wardrobes message when there is no wardrobe with inputted name 2023-05-24 14:44:38 -05:00
LoJoSho
70b97667c3 feat: only show wardrobes player has access to 2023-05-24 14:38:01 -05:00
LoJoSho
128a33a21f fix: Menus being janky 2023-05-24 12:41:58 -05:00
LoJoSho
538edb67dd fix: placeholders out of bounds slight rework 2023-05-24 12:41:43 -05:00
LoJoSho
9b607a099e fix: unlocked placeholder producing out of bounds expection 2023-05-24 12:20:39 -05:00
LoJoSho
f084d9e782 feat: add values method to Menus class 2023-05-24 11:03:54 -05:00
LoJoSho
8ee1400f85 feat: menu permissions added to registered permissions 2023-05-24 11:03:40 -05:00
LoJoSho
8e33b2022b fix: going to another wg region while cosmetic hidden from wg causes cosmetics to stay hidden 2023-05-24 10:58:34 -05:00
LoJoSho
a661ea09e1 feat: better file generating logic 2023-05-24 10:11:02 -05:00
LoJoSho
9c2120d13d version bump (2.4.0-DEV) 2023-05-24 09:57:03 -05:00
LoJoSho
7ea4ccccef feat: config updater 2023-05-24 09:56:46 -05:00
LoJoSho
0b1ed0fbeb clean: create path variables to be more in line with existing code 2023-05-23 14:33:36 -05:00
LoJoSho
0aac0a2377 clean: deprecate inDistanceOfWardrobe and inDistanceOfStatic 2023-05-23 14:30:58 -05:00
LoJoSho
04810b91ef feat: add ability to select any cosmetic in wardrobe, resolves #55 2023-05-23 11:11:24 -05:00
LoJoSho
f072f0e044 clean: old variable 2023-05-23 11:06:05 -05:00
LoJoSho
6e2278f4f0 clean: loose message 2023-05-23 10:58:42 -05:00
LoJoSho
7c95d9614d clean: remove players list, just use permissions if you wish to limit it to a certain group. 2023-05-23 10:53:37 -05:00
LoJoSho
54e8e5102a feat: Multiple Wardrobes 2023-05-23 10:50:09 -05:00
LoJoSho
b270d022d4 feat: Check if there is air below emote usage 2023-05-23 09:10:00 -05:00
LoJoSho
f087933d48 Merge pull request #110 from HibiscusMC/update_geary_hook
Update Geary Hook
2023-05-22 14:31:33 -05:00
Boy
ed1d1515bc fix invalid material error before pipeline finishes 2023-05-21 23:39:09 +02:00
Boy
aa364f5e77 properly inject setup into loadPhase 2023-05-21 19:19:51 +02:00
Boy
5ae6d17ef3 update geary hook 2023-05-21 18:25:55 +02:00
LoJoSho
4590bdcde1 feat: PlayerWardrobeEnterEvent now passes wardrobe location that is modifiable 2023-05-16 15:24:26 -05:00
LoJoSho
f9465e8206 clean: finish wardrobe location overhaul 2023-05-16 15:21:20 -05:00
LoJoSho
cd3a9f1af4 clean: move wardrobe location to its own class, rename wardrobe location to NPCLocation 2023-05-16 15:09:05 -05:00
LoJoSho
853668ff1b clean: better invalid backpack debug messages 2023-05-16 14:44:48 -05:00
LoJoSho
e2ee55bab4 fix: cosmetic armor updating when a player is emoting 2023-05-16 14:17:41 -05:00
LoJoSho
7a13715897 fix: protocollib moved to correct version 2023-05-16 14:09:59 -05:00
LoJoSho
d92e3e4616 clean: include user when shown invalid backpack error 2023-05-11 19:27:12 -05:00
LoJoSho
49023ff701 fix: equipped emotes not going through emote manager 2023-05-10 16:43:08 -05:00
LoJoSho
1bd405d13e version bump (2.3.2-DEV) 2023-05-10 16:32:55 -05:00
LoJoSho
69de2fa178 version bump (2.3.1) 2023-05-09 14:20:23 -05:00
LoJoSho
cdcf904ac8 fix: cosmetic tpe gui items not processing placeholders 2023-05-08 12:23:20 -05:00
LoJoSho
80f9100bf0 fix: translation file generating 2023-05-08 12:22:57 -05:00
LoJoSho
751509ece4 version bump (2.3.1-DEV) 2023-05-08 12:22:46 -05:00
LoJoSho
f36d558e13 clean: updateCosmetic use proper method 2023-05-06 10:40:15 -05:00
LoJoSho
ab8ae8ee76 version bump (2.3.0) 2023-05-06 10:28:26 -05:00
LoJoSho
aca14f8a04 clean: config referenced wrong value in comments 2023-05-06 09:47:24 -05:00
LoJoSho
6ec13051bb clean: user tick debug message 2023-05-06 09:40:13 -05:00
LoJoSho
ebc7bfa30a feat: menu now passes int slot to gui item types 2023-05-06 09:37:54 -05:00
LoJoSho
e59717d61d feat: positive emote distances show camera facing player 2023-05-06 09:34:10 -05:00
LoJoSho
7f5a90b080 Merge pull request #105 from Craftinators/remapped
feat: allow for multiple emotes in one bbmodel file
2023-05-06 09:19:45 -05:00
LoJoSho
51d26a7983 Merge pull request #104 from HibiscusMC/2.3.0
Improved GUI configuration options (2.3.0)
2023-05-06 09:16:22 -05:00
Craftinators
d1d001fcf6 refactor(EmoteManager): move emote loading logic to EmoteManager class 2023-05-06 00:02:03 -04:00
Craftinators
79f33ca0d1 feat: allow for multiple emotes in one bbmodel file 2023-05-05 18:39:14 -04:00
LoJoSho
7f37937185 clean: removed method not needed 2023-05-05 16:34:01 -05:00
LoJoSho
0e9164a506 fix: multi-slot gui items actions not running 2023-05-05 16:23:03 -05:00
LoJoSho
91361a6373 feat: equipped and locked cosmetic item in gui 2023-05-05 14:38:54 -05:00
LoJoSho
cfe5f33a63 version bump (2.3.0-DEV) 2023-05-05 14:38:38 -05:00
LoJoSho
e50566e2cb feat: add hasCosmeticInSlot for cosmetic 2023-05-05 13:53:01 -05:00
LoJoSho
f793f4e67a Merge pull request #103 from Craftinators/main
chore: add contact link
2023-04-30 15:53:07 -05:00
Craftinators
b57428e3fe style: remove emoji from name 2023-04-30 14:13:21 -04:00
Craftinators
3137c45704 chore: add contact link
Add a contact link for general questions
2023-04-30 14:09:46 -04:00
LoJoSho
38c270558c fix: update PlayerAnimator to 1.2.6 for 1.19.4 support 2023-04-30 10:37:57 -05:00
LoJoSho
39a36fa73c Merge remote-tracking branch 'origin/remapped' into remapped
# Conflicts:
#	build.gradle.kts
2023-04-29 22:58:39 -05:00
LoJoSho
ae83355860 feat: add LibsDisguise hook, resolves #85 2023-04-29 22:57:40 -05:00
LoJoSho
60d910d148 Merge pull request #100 from Craftinators/remapped
Issue template changes
2023-04-29 12:09:21 -05:00
LoJoSho
251d227ddb Merge pull request #99 from mergu/denizen_item_support
Add support for Denizen items
2023-04-29 12:07:30 -05:00
LoJoSho
45e597c665 version bump (2.2.9-DEV) 2023-04-29 12:01:20 -05:00
Craftinators
f0e60903b5 chore: more PR description options 2023-04-29 12:55:31 -04:00
Craftinators
db49946e5e chore: add discord link at top 2023-04-29 12:49:10 -04:00
Craftinators
50ebc737e6 chore: fix 02-feature-request indent error 2023-04-29 12:47:25 -04:00
Craftinators
28d1775c86 chore: fix 02-feature_request syntax error 2023-04-29 12:46:49 -04:00
Craftinators
0a1a381ebc chore: update 02-feature_request 2023-04-29 12:45:58 -04:00
Craftinators
651067fb17 style: rename feature-request.yml 2023-04-29 12:40:43 -04:00
Craftinators
1f634d668e style: rename bug-report.yml 2023-04-29 12:40:14 -04:00
Craftinators
f5bf8c70b4 chore: modify text 2023-04-29 12:39:22 -04:00
Craftinators
f50731f83e chore: fix bug-report.yml validation errors 2023-04-29 12:36:29 -04:00
Craftinators
f44d916b32 chore: fix bug-report.yml syntax error 2023-04-29 12:34:17 -04:00
Craftinators
9cfb27da28 chore: update bug-report.yml 2023-04-29 12:33:03 -04:00
Mergu
b09bd35737 Add support for Denizen items 2023-04-29 11:56:17 -04:00
LoJoSho
b998cac5c8 clean: default earth day grabber had model field that was unused 2023-04-26 15:01:30 -05:00
LoJoSho
9b34ffebb8 version bump (2.2.8) 2023-04-23 15:44:28 -05:00
LoJoSho
3eaaf75bfb clean: removed persistant data container not being used 2023-04-23 15:42:54 -05:00
LoJoSho
c1bae96ad9 fix: cosmetic data container now contains cosmetic id 2023-04-23 15:42:31 -05:00
LoJoSho
ddb6f53655 fix: cancel event for clicking in HMCColor 2023-04-23 15:23:10 -05:00
LoJoSho
c37f52bbb1 feat: destroy loose items cover gamemode switch 2023-04-23 10:47:44 -05:00
LoJoSho
dd805f1860 feat: add cosmetics containing who they were generated for 2023-04-23 10:38:43 -05:00
LoJoSho
d9551f2827 clean: better debug messages in CosmeticUser 2023-04-22 19:09:49 -05:00
LoJoSho
1750a1bf5f fix: 1.19.2 fake player info packet issue 2023-04-22 19:05:22 -05:00
LoJoSho
d42f5ef5af fix: player still in wardrobe after death 2023-04-22 18:32:28 -05:00
LoJoSho
2ca940a929 fix: papi expansion does not persist 2023-04-22 16:31:52 -05:00
LoJoSho
36f33b54af fix: cosmetic null showing error 2023-04-22 16:27:05 -05:00
LoJoSho
d0b4be6db8 fix: wardrobe not ending with transition false 2023-04-22 16:22:18 -05:00
LoJoSho
4afa0bb538 clean: new debug messages 2023-04-22 16:21:02 -05:00
LoJoSho
201bcceaab fix: 1.19.3 fake info packet not properly casting in protocol lib 2023-04-20 14:12:25 -05:00
LoJoSho
92ad314ce1 version bump (2.2.8-DEV) 2023-04-20 14:12:05 -05:00
lucian929
b8962539e8 Add earth day cosmetics 2023-04-18 16:44:50 -04:00
LoJoSho
01db728b99 version bump (2.2.7) 2023-04-17 15:22:24 -05:00
LoJoSho
8525dda6f4 feat: add gamemode-options when exiting wardrobe 2023-04-17 15:21:16 -05:00
LoJoSho
e8f7f57e0b feat: Destroy loose cosmetics to remove unwanted cosmetics 2023-04-17 14:25:48 -05:00
LoJoSho
8c62b47d5b clean: remove unused loop 2023-04-17 10:51:56 -05:00
LoJoSho
2ab0b119e7 Merge remote-tracking branch 'origin/remapped' into remapped 2023-04-17 10:50:35 -05:00
LoJoSho
20d919c65e clean: improved animation variable 2023-04-17 10:50:28 -05:00
LoJoSho
bd41c5b9ff feat: Option to make lead invisible for balloons, resolves #95 2023-04-17 10:31:27 -05:00
LoJoSho
60aaf0cff6 feat: Equipped placeholder now takes type 2023-04-09 11:37:55 -05:00
LoJoSho
71c8f8171b fix: Standing does not readd backpack 2023-04-09 11:08:40 -05:00
LoJoSho
2bc4e3dd3f Merge pull request #93 from Craftinators/remapped
Remove `build` workflow
2023-04-06 16:43:18 -05:00
Craftinators
302eaa13c9 Merge branch 'HibiscusMC:remapped' into remapped 2023-04-06 17:40:17 -04:00
Craftinators
23ff51bab8 github: remove build workflow 2023-04-06 17:39:23 -04:00
LoJoSho
96ee695521 Merge pull request #92 from Craftinators/remapped
Minor Repository Changes
2023-04-06 16:33:24 -05:00
Craftinators
a9a587495a github: build workflow only fires on pr 2023-04-06 17:20:33 -04:00
Craftinators
0b69e20adc github: remove note from CONTRIBUTING.md 2023-04-06 01:46:43 -04:00
Craftinators
a08e531226 fix: contribution guide updates 2023-04-05 23:20:42 -04:00
Craftinators
1e27933573 github: add contribution guide 2023-04-05 22:07:16 -04:00
Craftinators
0b4815842f github: remove cache from build action 2023-04-05 19:47:30 -04:00
LoJoSho
cc6aec99e0 fix: NPE on player exit if user not created 2023-04-05 17:21:02 -05:00
Craftinators
b51bace9f5 fix: Feature Request add enhancement label 2023-04-05 13:09:08 -04:00
Craftinators
c70223a800 github: remove matrix versions >=18 2023-04-05 13:07:05 -04:00
Craftinators
36353b5693 github: expand java matrix to include versions 19 & 20 2023-04-05 12:54:30 -04:00
Craftinators
d4fc903c14 fix: revert to temurin 2023-04-05 12:45:14 -04:00
Craftinators
980d2d89df fix: oracle typo 2023-04-05 12:44:12 -04:00
Craftinators
c952a8ac08 github: try versions >17.0 2023-04-05 12:42:50 -04:00
Craftinators
a651c9b8da fix: remove java version matrix 2023-04-05 12:32:29 -04:00
Craftinators
c695e8b2f9 fix: distribution from orcale to temurin 2023-04-05 12:26:27 -04:00
Craftinators
ee72bc2ef5 fix: distribution issue 2023-04-05 12:24:58 -04:00
Craftinators
ebd47e9b56 fix: actions/setup-java@v3.6 -> actions/setup-java@v3 2023-04-05 12:20:41 -04:00
Craftinators
5cf5e7c543 github: add matrix samples 2023-04-05 12:18:54 -04:00
Craftinators
7f2d62b5e5 fix: add chmod permission changes 2023-04-05 11:45:50 -04:00
Craftinators
8d07f7cf9f github: add build workflow 2023-04-05 08:14:23 -04:00
LoJoSho
789db52b57 fix: player_move_check changed to player-move-check in configuration 2023-04-04 07:55:02 -05:00
LoJoSho
5fb3458a98 fix: player emoting then teleporting glitches out 2023-04-02 13:34:47 -05:00
LoJoSho
f6935ce60b Merge remote-tracking branch 'origin/remapped' into remapped 2023-04-02 12:54:50 -05:00
lucian929
b1eb592137 chore: update transition info for oraxen/itemsadder 2023-04-02 13:54:27 -04:00
LoJoSho
913f8ccdf7 version bump (2.2.7-DEV) 2023-04-02 12:39:23 -05:00
LoJoSho
3f951263b9 version bump (2.2.6) 2023-04-02 12:39:01 -05:00
LoJoSho
744fc87491 feat: add option to disable World Guard listener #87 2023-04-02 12:30:41 -05:00
LoJoSho
ca01a94502 feat: full 1.19.4 support 2023-04-02 12:00:31 -05:00
LoJoSho
879a58d1f4 clean: update test servers to 1.19.4 2023-04-02 11:59:32 -05:00
LoJoSho
aab40b68a7 clean: add md-5 repo for future plugins 2023-04-01 22:34:38 -05:00
LoJoSho
9533e2ec46 fix: add 1.19.4 in SUPPORTED_VERSIONS constant 2023-04-01 22:28:26 -05:00
LoJoSho
7b2e767cac fix: fixes #88 throwing runtime exception on reload 2023-04-01 22:27:38 -05:00
LoJoSho
4bdd000917 Merge remote-tracking branch 'origin/remapped' into remapped 2023-03-22 19:52:01 -05:00
LoJoSho
b397ae52f9 fix: check valid balloon entity before teleport 2023-03-22 19:51:56 -05:00
LoJoSho
40620f1daa Merge pull request #83 from Craftinators/hooks
Abstraction and Documentation of `/hooks` directory
2023-03-17 15:53:13 -05:00
Craftinators
4d8d43ee2a docs(Hooks): getActive -> isActive 2023-03-17 16:03:18 -04:00
Craftinators
4f8a32c3e8 docs(HMCPlaceholderExpansion): documented class 2023-03-17 16:01:55 -04:00
LoJoSho
1d303dee71 feat: add 1.19.4 nms support 2023-03-17 11:47:41 -05:00
LoJoSho
e9659ab1e8 version bump (2.2.6-DEV) 2023-03-17 11:27:32 -05:00
LoJoSho
ee917dbf32 fix: Riptide fixes #84 2023-03-17 11:25:08 -05:00
LoJoSho
2a275fe503 Merge remote-tracking branch 'origin/remapped' into remapped 2023-03-17 11:15:51 -05:00
LoJoSho
a5631cd2e4 fix: player during riptide have their backpack hidden #84 2023-03-17 11:15:04 -05:00
Craftinators
1ed1a2c41d docs(WGListener): documented class 2023-03-17 09:08:11 -04:00
Craftinators
c2bf0322a7 docs(WGHook): documented class 2023-03-17 09:06:37 -04:00
Craftinators
3f8f84735f docs(HookPlaceholderAPI): documented class 2023-03-17 08:58:39 -04:00
Craftinators
2fb28dda32 docs(HookSuperVanish): documented class 2023-03-17 08:54:17 -04:00
Craftinators
6192515550 docs(HookPremiumVanish): documented class 2023-03-17 08:54:10 -04:00
Craftinators
6fcf893bac docs: fixed wording 2023-03-17 08:53:37 -04:00
Craftinators
d0dfa19f2d docs(HookHMCColor): documented class 2023-03-17 08:53:09 -04:00
Craftinators
c3b4abea40 docs(HookCMI): documented class 2023-03-17 08:53:00 -04:00
Craftinators
a030d1272b docs(HookOraxen): documented class 2023-03-17 08:44:10 -04:00
Craftinators
d6c4b51b98 docs(HookMythic): documented class 2023-03-17 08:42:05 -04:00
Craftinators
a306d76c19 Merge remote-tracking branch 'origin/hooks' into hooks
# Conflicts:
#	common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMythic.java
2023-03-17 08:40:08 -04:00
Craftinators
1d51ee0711 docs(HookMythic): documented class 2023-03-17 08:39:53 -04:00
Craftinators
e340874270 docs(HookMythic): documented class 2023-03-17 08:37:52 -04:00
Craftinators
093b01d7ff docs(HookLooty): documented class 2023-03-16 18:43:52 -04:00
Craftinators
5b129cc254 docs(HookItemAdder): documented class 2023-03-16 18:40:50 -04:00
Craftinators
7a32697906 docs(HookHMCCosmetics): documented class 2023-03-16 17:55:53 -04:00
Craftinators
2ea272ee4a fix(Hook): abstraction and documentation of Hook 2023-03-16 17:39:58 -04:00
LoJoSho
9ebfc9748d Merge pull request #81 from Craftinators/docs
Documentation of `/api` directory
2023-03-16 14:22:06 -05:00
Craftinators
d1a2b6a016 docs(HMCCosmeticSetupEvent): fix documentation 2023-03-15 17:11:41 -04:00
Craftinators
af78424b07 refactor(PlayerMenuCloseEvent): event no longer cancellable 2023-03-15 15:31:25 -04:00
LoJoSho
c35546e536 Merge pull request #82 from Craftinators/remapped
PR template
2023-03-15 09:16:39 -05:00
Craftinators
7db03a2f8a fix: add colon 2023-03-15 08:39:27 -04:00
Craftinators
99f3765e6e github: add PR template 2023-03-15 08:36:02 -04:00
Craftinators
fae001a48f fix: disallow empty issues 2023-03-15 08:35:41 -04:00
Craftinators
1ccb35ad62 refactor: abstraction of menu related events 2023-03-15 08:05:15 -04:00
Craftinators
2b4e570172 clean(UserEmoteManager): remove unused import 2023-03-15 08:04:53 -04:00
Craftinators
965b6cc740 fix(PlayerCosmeticEvent): rename to PlayerCosmeticEvent 2023-03-15 08:04:28 -04:00
Craftinators
ffda4ba6f5 feat: new PlayerMenuOpenEvent class 2023-03-15 04:44:18 -04:00
Craftinators
df2da4fc89 docs(PlayerMenuOpenEvent): add class documentation 2023-03-15 04:43:50 -04:00
Craftinators
cea40033f9 docs(PlayerWardrobeLeaveEvent): add class documentation 2023-03-15 04:43:36 -04:00
Craftinators
42a01a44aa docs(PlayerWardrobeEnterEvent): add class documentation 2023-03-15 04:43:23 -04:00
Craftinators
17c07d0e01 docs(PlayerWardrobeLeaveEvent): documented class 2023-03-15 04:05:50 -04:00
Craftinators
ea4d088b04 docs(PlayerWardrobeEnterEvent): documented class 2023-03-15 04:05:39 -04:00
Craftinators
591198175a docs(PlayerMenuOpenEvent): documented class 2023-03-15 04:05:17 -04:00
Craftinators
be93369a8b docs(PlayerEmoteStopEvent): add class documentation 2023-03-15 03:58:33 -04:00
Craftinators
fd6553a52a docs(PlayerEmoteStopEvent): documented class 2023-03-15 03:57:44 -04:00
Craftinators
961f460ffb docs(PlayerEmoteStartEvent): documented class 2023-03-15 03:57:28 -04:00
Craftinators
eb925d9022 docs(HMCCosmeticSetupEvent): documented class 2023-03-15 01:45:07 -04:00
Craftinators
d05072eb2c fix(PlayerCosmeticShowEvent): remove unused import 2023-03-15 01:40:06 -04:00
Craftinators
f456ddf8a4 docs(PlayerCosmeticShowEvent): documented class 2023-03-15 01:39:00 -04:00
Craftinators
c395b68d6a docs(PlayerCosmeticRemoveEvent): documented class 2023-03-15 01:38:33 -04:00
Craftinators
fddd5d0311 docs(PlayerCosmeticHideEvent): updated documentation 2023-03-15 01:37:46 -04:00
Craftinators
f08c38ff1a docs(PlayerCosmeticEquipEvent): updated documentation 2023-03-15 01:34:58 -04:00
Craftinators
a4bd9108b1 docs(PlayerCosmeticHideEvent): documented class 2023-03-14 18:26:22 -04:00
Craftinators
de1377dc8f docs(PlayerCosmeticEquipEvent): @see when referring to classes 2023-03-14 18:25:47 -04:00
Craftinators
00ce32c528 docs(PlayerCosmeticEquipEvent): documented class 2023-03-14 15:48:18 -04:00
Craftinators
0ddcb12b31 feat: abstraction of PlayerCosmetic... styled events 2023-03-14 15:47:27 -04:00
LoJoSho
adadecfa19 Merge pull request #79 from Craftinators/remapped
`CosmeticUser.getCosmetics()` changes
2023-03-14 14:36:56 -05:00
Craftinators
ac35ef8b5d feat(CosmeticUser): preferred getCosmetics method 2023-03-13 23:56:02 -04:00
LoJoSho
65f1c72b8e fix: restarting server while player is emoting causes player to be invisible 2023-03-13 21:23:19 -05:00
Craftinators
178bff37f5 feat(CosmeticUser): new getPlayerCosmetics() 2023-03-13 15:15:13 -04:00
Craftinators
48b9d4fb41 fix(CosmeticUser): add back getCosmetic() as deprecated method 2023-03-13 15:05:19 -04:00
Craftinators
81d6583430 fix(CosmeticUser): keep mutable collection 2023-03-13 09:02:17 -04:00
Craftinators
0304c9ff44 fix(CosmeticUser): getCosmetics() changes 2023-03-13 08:59:23 -04:00
LoJoSho
bf591e708d fix: check if backpack armorstand is a valid entity before update 2023-03-12 15:52:53 -05:00
LoJoSho
14bbd111f9 version bump (2.2.5) 2023-03-12 12:03:18 -05:00
LoJoSho
2185c27be5 feat: add PlayerEmote api events 2023-03-12 12:00:33 -05:00
LoJoSho
aef9e24d28 feat: config options for emotes (damage-leave and invincible) 2023-03-12 12:00:18 -05:00
LoJoSho
d1a35b721e feat: Enchantments can be passed to cosmetic items 2023-03-12 11:40:08 -05:00
LoJoSho
17abd0c8cc feat: Improvements to emote block checking 2023-03-11 20:48:09 -06:00
LoJoSho
a907cd51b9 feat: Add CMI vanish support 2023-03-11 20:07:01 -06:00
LoJoSho
9f6c7db8fd fix: kicking while interacting in emote/wardrobe #76 2023-03-11 19:20:35 -06:00
LoJoSho
2ba83d8cc5 fix: default color being white 2023-03-10 16:06:51 -06:00
LoJoSho
40bf0e173e version bump (2.2.5-DEV) 2023-03-10 16:06:46 -06:00
LoJoSho
a757292b4b version bump (2.2.4) 2023-03-09 19:14:33 -06:00
LoJoSho
b41d466546 fix: action menu not using debug method 2023-03-09 19:09:42 -06:00
LoJoSho
135fdc94d4 fix: sound debug was wrong level 2023-03-09 19:08:21 -06:00
LoJoSho
d0092a2ffe clean: refactor spelling mistake in isBackpackSpawned 2023-03-02 19:19:45 -06:00
LoJoSho
acf31009d5 feat: backpack improvements 2023-03-02 19:19:08 -06:00
LoJoSho
981c6155e7 feat: add all to unapply command 2023-03-01 10:45:06 -06:00
LoJoSho
2ecc86fc7b fix: same issue as before but with cosmetic wardrobe flag 2023-03-01 10:27:27 -06:00
LoJoSho
2682428354 fix: worldguard flag hiding cosmetics when on allow 2023-03-01 10:21:40 -06:00
LoJoSho
df8ad26684 fix: Flying with elytra and teleporting with backpack causing NPE 2023-03-01 10:14:05 -06:00
LoJoSho
1f714c0153 -1 in wardrobe static radius now returns true 2023-03-01 10:09:18 -06:00
LoJoSho
0bfadad222 Reload IA on change option (Legacy IA hook option) 2023-03-01 10:02:27 -06:00
LoJoSho
a1c719fc50 version bump (2.2.4-DEV) 2023-03-01 10:02:05 -06:00
Craftinators
fe9812cd69 clean: suppress warnings 2023-03-01 08:56:49 -05:00
Craftinators
b9699b27c7 fix: spelling errors 2023-03-01 00:52:13 -05:00
Craftinators
2c5ddb542e clean: remove unused import 2023-03-01 00:44:27 -05:00
Craftinators
461642d64b clean: make Type abstract 2023-03-01 00:44:00 -05:00
Craftinators
37a8a2379d clean: add @NotNull & remove import 2023-02-28 22:25:13 -05:00
LoJoSho
e698392e40 Merge pull request #74 from Craftinators/remapped
`Action` Abstraction
2023-02-28 18:54:02 -06:00
Craftinators
e1357b265f clean: use final 2023-02-28 14:50:16 -05:00
Craftinators
a5475b0268 clean: prefer not to use var 2023-02-28 14:50:03 -05:00
Craftinators
60dba9efa6 fix: use parseFloat instead of valueOf 2023-02-28 14:41:46 -05:00
Craftinators
e2d3391070 clean: reduce nesting 2023-02-28 14:40:58 -05:00
Craftinators
aed34ec28d clean: reduce nesting 2023-02-28 14:35:08 -05:00
Craftinators
ae6d88ab56 clean: make Action abstract 2023-02-28 14:34:03 -05:00
LoJoSho
35be7283e9 Merge pull request #72 from Craftinators/remapped
`CosmeticType` Abstraction
2023-02-28 09:32:30 -06:00
Craftinators
224fcb83d9 clean: config to local 2023-02-28 01:03:11 -05:00
Craftinators
98934536be clean: make Cosmetic abstract 2023-02-28 01:02:52 -05:00
LoJoSho
5ac3712e56 Merge pull request #71 from Craftinators/remapped
Database structure changes
2023-02-27 21:57:40 -06:00
Craftinators
2d2d4e6d44 clean: remove TODO 2023-02-27 22:55:33 -05:00
Craftinators
4b1921b754 clean: try-with-resource to SuppressWarnings 2023-02-27 22:55:12 -05:00
Craftinators
8ca1d44375 clean: add error message 2023-02-27 15:36:50 -05:00
Craftinators
23c82cc6ed fix: additional null checks 2023-02-27 15:34:42 -05:00
Craftinators
2bf5280827 fix: reorder null checks 2023-02-27 15:29:50 -05:00
Craftinators
475a1e0ef1 fix: add Class.forName(...) back 2023-02-27 13:06:23 -05:00
Craftinators
ef4d53eb85 fix: throw error if file isn't created 2023-02-27 12:57:12 -05:00
Craftinators
97da4f7809 feat: add SQLData class 2023-02-27 12:53:51 -05:00
Craftinators
1622dac67f clean: cleanup openConnection() 2023-02-27 12:26:43 -05:00
Craftinators
fce1ec5042 refactor: use try-with-resources 2023-02-27 12:23:30 -05:00
Craftinators
060bcc95e1 clean: reorganize MySQLData 2023-02-27 12:20:26 -05:00
Craftinators
5aca80609a feat: make Data abstract 2023-02-27 12:11:09 -05:00
LoJoSho
7c1da21026 Refactoring and Misc changes in UserWardrobeManager 2023-02-25 10:48:39 -06:00
LoJoSho
52329a6de5 Move wardrobe lists to singleton list 2023-02-25 10:34:23 -06:00
LoJoSho
8cdef228e3 Add HMCColor to the internal hook system 2023-02-25 10:27:31 -06:00
LoJoSho
432d6d837a check if user has cosmetic permissions on wardrobe leave 2023-02-25 09:43:19 -06:00
LoJoSho
f42e8b2298 Refactor custom Armorstands and add HMcParticleCloud Entity 2023-02-25 09:39:27 -06:00
LoJoSho
107f5b9215 Merge remote-tracking branch 'origin/remapped' into remapped 2023-02-24 20:31:50 -06:00
LoJoSho
d303fcc45b Merge pull request #70 from Craftinators/remapped
clean: use preferred method
2023-02-24 20:31:31 -06:00
Craftinators
147be9ab7c clean: use preferred method 2023-02-24 21:22:25 -05:00
LoJoSho
7f91f9dbad set default database to SQLite 2023-02-24 20:09:07 -06:00
LoJoSho
63e538511b Merge pull request #69 from Craftinators/remapped
Major consistency changes
2023-02-24 19:48:40 -06:00
Craftinators
d0c8abc38c clean: add annotations 2023-02-24 17:51:48 -05:00
Craftinators
97a28b9e0c clean: remove unused imports 2023-02-24 17:47:21 -05:00
Craftinators
b5ae6e65a1 clean: annotation & variable modifier changes 2023-02-24 17:46:39 -05:00
Craftinators
0c7e740d7a clean: annotation & variable modifier changes 2023-02-24 16:46:23 -05:00
Craftinators
1b7462becc clean: several annotation & naming changes 2023-02-24 13:33:45 -05:00
Craftinators
d508ecd4c0 clean: cosmetic annotation changes 2023-02-24 12:21:53 -05:00
Craftinators
601d6f8a53 fix: break once "-s" flag found 2023-02-24 12:11:22 -05:00
Craftinators
44be4eceb8 clean: comment delete 2023-02-24 12:02:28 -05:00
Craftinators
8bebd57169 fix: event annotation changes 2023-02-24 12:00:14 -05:00
LoJoSho
8f426cef31 version bump (2.2.3) 2023-02-24 10:19:52 -06:00
LoJoSho
abce477f0d add cosmetic playEmote command 2023-02-24 10:19:39 -06:00
LoJoSho
985e797f83 remove annoying space 2023-02-24 09:03:20 -06:00
LoJoSho
8bc84cbdd2 Fix balloon teleport fix not checking if player has balloon 2023-02-24 09:02:16 -06:00
LoJoSho
894e4eef26 update default with correct dye menu name 2023-02-21 17:08:27 -06:00
LoJoSho
5995dabf6f Fix clicking in emote kicking players 2023-02-21 17:05:02 -06:00
LoJoSho
ed647b7e5d Fix for invalid player on emote command 2023-02-21 10:20:42 -06:00
LoJoSho
e378732d44 Fixed backpack model engine in wardrobe 2023-02-20 19:06:25 -06:00
LoJoSho
74eb5dd85a version bump (2.2.2) 2023-02-20 18:48:27 -06:00
LoJoSho
c9ba396c33 remove debug messages 2023-02-20 18:47:52 -06:00
LoJoSho
3967ac4fa5 rename viewer in wardrobe manager 2023-02-20 18:47:25 -06:00
LoJoSho
b1a35df7b5 condense if statements 2023-02-20 18:45:52 -06:00
LoJoSho
0e1c9b3f7e Backpack no longer equipped on fly or swim 2023-02-20 18:41:11 -06:00
LoJoSho
0238ac8fc4 Merge pull request #60 from HibiscusMC/modelengine_backpack
Model Engine Backpacks
2023-02-20 14:17:13 -06:00
LoJoSho
4d6baf0b0c offset backpack for ME backpack 2023-02-20 14:16:40 -06:00
LoJoSho
157fab6309 Merge branch 'remapped' into modelengine_backpack 2023-02-20 14:11:46 -06:00
lucian929
0a488a6791 Add Explorer Backpack Cosmetic 2023-02-17 10:38:56 -05:00
LoJoSho
1c9989e64a readd paper repo 2023-02-16 21:23:45 -06:00
LoJoSho
fb8dcf53e3 Merge branch 'remapped' into modelengine_backpack 2023-02-16 14:50:03 -06:00
LoJoSho
17179cbe35 version bump (2.2.1) 2023-02-16 14:44:54 -06:00
LoJoSho
f589696d19 update paper userdev 2023-02-16 14:43:28 -06:00
LoJoSho
68e87cba6f Merge pull request #61 from HibiscusMC/papi_fix
Fix for PAPI in menus
2023-02-15 17:00:21 -06:00
LoJoSho
63a0bdd0d5 Fix for PAPI in menus 2023-02-15 16:58:47 -06:00
LoJoSho
a01f35c53d Model Engine Backpacks 2023-02-15 16:46:03 -06:00
LoJoSho
a607f2dcbd Merge pull request #59 from HibiscusMC/tweaks
make dye menu slots configurable
2023-02-15 11:00:23 -06:00
Boy
7a9a002e25 make dye menu slots configurable 2023-02-15 12:56:32 +01:00
LoJoSho
fd50cd058a Merge pull request #58 from HibiscusMC/fix_looty
add missing hook initializer for Looty
2023-02-13 13:55:05 -06:00
Boy
970ca8227b add missing hook initializer 2023-02-13 19:04:10 +01:00
LoJoSho
e7fd3ac288 Merge pull request #57 from HibiscusMC/emotes
HMCC Emotes with PlayerAnimator
2023-02-12 13:12:51 -06:00
lucian929
51214964c4 Update default files 2023-02-12 12:58:57 -05:00
LoJoSho
4d4be789ae Merge remote-tracking branch 'origin/emotes' into emotes 2023-02-12 10:56:05 -06:00
LoJoSho
f2b276a2ef Premium + Super Vanish hook 2023-02-12 10:55:54 -06:00
LoJoSho
cf54f2b487 Premium + Super Vanish hook 2023-02-12 10:53:04 -06:00
LoJoSho
bae13c2e3c Create emote folder 2023-02-12 10:40:06 -06:00
LoJoSho
004f9ebef5 Fix rogue wardrobe runnable 2023-02-11 19:48:39 -06:00
LoJoSho
ad956259d0 move event cancel check 2023-02-11 16:13:34 -06:00
LoJoSho
65cebc3154 stop players picking items in wardrobe 2023-02-11 16:05:17 -06:00
LoJoSho
fb79293902 version bump (2.2.0) 2023-02-11 10:19:03 -06:00
LoJoSho
b49cebdec8 command improvements + /cosmetic emote playerName 2023-02-10 16:34:40 -06:00
LoJoSho
00cc3eef2c improve command handling and add permissions 2023-02-10 16:28:42 -06:00
LoJoSho
42bae598a6 offhand switch cancel 2023-02-10 16:10:06 -06:00
LoJoSho
b182e46b28 update api to 1.17 2023-02-10 16:03:15 -06:00
LoJoSho
6b6b0e385e fixed armor showing in emotes 2023-02-10 16:01:11 -06:00
LoJoSho
db60046701 More checks and does not save invisibility from emote 2023-02-10 11:30:41 -06:00
LoJoSho
300e2cffba Emote settings and messages 2023-02-10 10:49:57 -06:00
LoJoSho
d5983d8834 Made player stand still + fixed other players viewing nothing 2023-02-10 09:28:44 -06:00
LoJoSho
9e07f728e1 it works 2023-02-09 13:32:28 -06:00
LoJoSho
dcd38d86c5 latest changes 2023-02-08 17:14:03 -06:00
LoJoSho
d39110af6c emo work 2023-02-08 15:28:04 -06:00
LoJoSho
0f6fa3db8a reimplement dependencies that got missing in merge 2023-02-07 15:55:15 -06:00
LoJoSho
5aef04dee0 Complete overhaul of hooks 2023-02-07 15:54:21 -06:00
LoJoSho
a096f6c684 Merge remote-tracking branch 'origin/remapped' into remapped 2023-02-07 15:34:50 -06:00
LoJoSho
89825659a6 more refactoring 2023-02-07 15:04:17 -06:00
LoJoSho
6ba078dcc4 removed toggle method (unused) 2023-02-07 15:02:27 -06:00
LoJoSho
2e32b8d9d5 move wardrobe to a manager 2023-02-07 14:55:54 -06:00
LoJoSho
941f57af35 Merge pull request #53 from MineInAbyss/mia
LootyHook
2023-02-06 15:30:11 -06:00
LoJoSho
bdb52c0a32 Merge remote-tracking branch 'origin/remapped' into remapped 2023-02-06 14:54:17 -06:00
LoJoSho
a7170e09cf Add force-permission-join option 2023-02-06 14:53:52 -06:00
LoJoSho
8456d6a7ae Fixed balloons applied in wardrobe not having leashes 2023-02-06 14:28:34 -06:00
LoJoSho
08b28bc254 Exiting wardrobe balloon fixes 2023-02-06 14:04:17 -06:00
LoJoSho
c27a9ab2ad Internal wardrobe rework 2023-02-06 13:48:29 -06:00
LoJoSho
2bf618d8d3 ItemFlag rework 2023-02-06 13:46:51 -06:00
LoJoSho
6eb7c9243d Better locked lore handling 2023-02-06 13:11:06 -06:00
LoJoSho
c2b4fade42 Merge pull request #56 from HibiscusMC/defaultmenu
getDefaultMenu method
2023-02-06 10:44:32 -06:00
Boy
382eed9982 requested changes 2023-02-06 17:42:15 +01:00
Boy
498370cc8e replace old methods 2023-02-06 17:23:21 +01:00
Boy
fef5769e31 getDefaultMenu method 2023-02-06 14:17:18 +01:00
Boy
4aa1f9451d tweak oraxen hook for nullchecks 2023-02-06 00:03:01 +01:00
Boy
c7730429de improve looty hook check 2023-02-06 00:03:01 +01:00
Boy
73ccddf628 add softdepend 2023-02-06 00:03:01 +01:00
Boy
26b5472924 add looty support 2023-02-06 00:03:01 +01:00
LoJoSho
5ecfb08412 Refactor entities into managers 2023-02-05 12:28:37 -06:00
LoJoSho
8b223228ce Or statement should be And 2023-02-05 10:40:17 -06:00
LoJoSho
eb03acd959 version bump (2.1.3-SNAPSHOT) 2023-02-04 18:15:28 -06:00
LoJoSho
8e5b3d098c placeholder current causing npe 2023-02-04 18:02:29 -06:00
LoJoSho
a869120b62 misspells 2023-02-04 17:51:03 -06:00
LoJoSho
614892500c Version bump (2.1.2) 2023-02-03 13:16:38 -06:00
LoJoSho
872282f77a Fix publishing 2023-02-03 13:16:26 -06:00
LoJoSho
c0483bfefe Action Menu can override target menu permission with "-o" 2023-02-03 12:35:12 -06:00
LoJoSho
aecd40ba5a Hidden reason now saved in database 2023-02-03 12:19:34 -06:00
LoJoSho
c3db45cfc4 update checker more in align with HMCWraps 2023-02-02 22:26:30 -06:00
LoJoSho
99bc0a0756 Add color to apply command 2023-02-02 21:30:07 -06:00
LoJoSho
e9afd6deb8 Add ability to silent messages in command with -s 2023-02-02 21:25:29 -06:00
lucian929
0770ac456d Delete publish.yml 2023-02-02 17:44:16 -05:00
lucian929
327d602491 Fix repository link 2023-02-02 22:33:19 +00:00
LoJoSho
65f162c89c Update publish.yml 2023-02-02 15:51:24 -06:00
LoJoSho
e96d1f505e Update publish.yml 2023-02-02 15:48:08 -06:00
LoJoSho
2af1deb4c1 Update publish.yml 2023-02-02 15:42:59 -06:00
LoJoSho
d740989a01 add ia hook comment 2023-02-02 15:42:28 -06:00
LoJoSho
fdc0004b75 Repo workflow 2023-02-02 15:23:05 -06:00
158 changed files with 5486 additions and 2505 deletions

13
.github/CONTRIBUTING.md vendored Normal file
View File

@@ -0,0 +1,13 @@
# Contributing
If you wish to contribute to the HMCCosmetics codebase, feel free to fork the repository and [submit a pull request](https://github.com/HibiscusMC/HMCCosmetics/compare).
> **Note** Contributions to the HMCCosmetics codebase should remain consistent with current code style. Remember to keep your code clean, documented and understandable, and to avoid messy or confusing code.
## Setup
To get ready to work on the codebase, please do the following:
1. Fork & clone the repository, and make sure you're on the **remapped** branch. (*This is the default branch*)
2. Code your heart out!
3. Run `./gradlew build` to ensure your project successfully builds. (*This may take a while*)
4. Finally, [submit a pull request](https://github.com/HibiscusMC/HMCCosmetics/compare)!

View File

@@ -0,0 +1,61 @@
name: Bug Report
description: Report an issue with HMCCosmetics
labels: [bug]
assignees: ["LoJoSho"]
body:
- type: markdown
attributes:
value: |
Thank you for filing an bug report! If you are here to ask a question, use our [Discord server](https://discord.gg/pcm8kWrdNt) instead!
- type: input
id: release_version
attributes:
label: Plugin Version
placeholder: vx.x.x
description: |
Insert the version of HMCCosmetics you are using (e.g. `v2.2.8`). Before continuing make sure you have the latest version of HMCCosmetics as
your issue may have already been resolved.
- type: input
id: server_version
attributes:
label: Server Version
placeholder: fork-x-x.x.x
description: |
Insert the version of your minecraft server in the format `fork-build-version` (e.g. `PAPER-521-1.19.4`, `PURPUR-1838-1.19.2`)
- type: textarea
id: description
attributes:
label: Issue description
description: Describe the issue in as much detail as possible (Include any error logs in a code block below)
- type: textarea
id: reproduce
attributes:
label: Steps to reproduce
description: Explain how to reproduce this issue step-by-step, in as much detail as possible.
placeholder: |
Steps to reproduce:
1. Do thing
2. Observe behavior
3. Post any error logs below
validations:
required: true
- type: dropdown
id: priority
attributes:
label: Issue priority
description: Please be realistic. If you need to elaborate on your reasoning, please use the issue description field above.
options:
- Low (slightly annoying)
- Medium (should be fixed somewhat soon)
- High (immediate attention needed)
validations:
required: true
- type: textarea
id: versions
attributes:
label: Other Versions
placeholder: |
- ModelEngine R3.0.1 (`/version ModelEngine`)
- Any other relevant version information such as depenedencies
description: |
List any necessary or relevant versions here.

View File

@@ -0,0 +1,28 @@
name: Feature Request
description: Request a new feature for HMCCosmetics
labels: [enhancement]
assignees: ["LoJoSho"]
body:
- type: markdown
attributes:
value: |
If you are here to ask a question, use our [Discord server](https://discord.gg/pcm8kWrdNt) instead!
- type: markdown
attributes:
value: |
Please check that the feature you are requesting does not already exist *and/or* hasn't already been requested by someone else.
- type: textarea
id: description
attributes:
label: Feature Description
description: A clear and concise description of what the problem is, or what feature you want to be implemented.
placeholder: A good addition would be...
validations:
required: true
- type: textarea
id: solution
attributes:
label: Implementation Description
description: A clear and concise description of what you want to happen, and any optional **configuration changes** that need to be made.
validations:
required: false

View File

@@ -1,62 +0,0 @@
name: Bug Report
description: Create a bug report to help us keep track of all bugs that have to be fixed
title: "[BUG] <name for bug>"
labels: [bug]
body:
- type: checkboxes
id: i-have-checked
attributes:
label: I have checked...
options:
- label: "I am using the latest version of HMCCosmetics"
required: true
- label: "I am using the latest version of any dependencies"
required: true
- label: "I have checked if any similar bug reports exist"
required: true
- type: textarea
id: description
attributes:
label: Description
description: A full description of the bug
validations:
required: true
- type: textarea
id: reproduce
attributes:
label: Steps to reproduce
description: Explain how to reproduce this issue step-by-step, in as much detail as possible.
validations:
required: true
- type: textarea
id: hmcc-version
attributes:
label: Plugin Version
description: Run `version HMCCosmetics` in your console and paste the output
validations:
required: true
- type: textarea
id: meg-version
attributes:
label: ModelEngine Version
description: "Run `version ModelEngine` in your console and paste the output. Optional if not using balloons."
validations:
required: false
- type: textarea
id: server-version
attributes:
label: Server Version
description: "Run `version` in your console and paste the output."
validations:
required: true
- type: "dropdown"
id: "type"
attributes:
label: "How breaking is the bug?"
options:
- "Breaking Bug - Plugin unusable"
- "Non-breaking Bug - Plugin still usable, but certain features unavailable"
- "Minor Bug - Plugin completely functional, but features have non-working aspects"
validations:
required: true

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

@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: General Questions and Help
url: https://discord.gg/pcm8kWrdNt
about: This issue tracker is not for support questions. Please refer to the Hibiscus community's help and discussion discord server.

View File

@@ -1,29 +0,0 @@
name: Feature Request
description: Create a feature request to help us keep track of all features you want to be added
title: "[FEATURE] <title>"
labels: [feature]
body:
- type: "checkboxes"
id: "i-have-checked"
attributes:
label: "I have checked that..."
options:
- label: "...such a feature does not exist already"
required: true
- label: "...such a feature request has not been submitted already"
required: true
- type: "textarea"
id: "description"
attributes:
label: "Description"
description: "A full description of the feature"
validations:
required: true
- type: "textarea"
id: "config-changes"
attributes:
label: "Config Changes"
description: "The configuration changes your feature should have"
validations:
required: false

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

@@ -0,0 +1,19 @@
#### Select the option(s) that best describes this PR:
- [ ] Major breaking change
- [ ] Minor change
- [ ] Feature implementation
- [ ] Bug fix
- [ ] Chore (Changes that don't fix or add new features *and don't* modify source files)
- [ ] Refactoring (Changes that dont't fix or add new features *but do* modify source files)
- [ ] Documentation (Changes to README files and/or JavaDocs)
- [ ] Style (Changes that don't affect the meaning of the code)
- [ ] Performance
- [ ] Other (Please specify below)
#### Please describe the changes this PR makes and why it should be merged:
#### Check that:
- [ ] *Any* new classes, public methods and/or properties are properly documented with `JavaDocs`
- [ ] Syntax and style are consistent with existing code
- [ ] *Any* replaced method isn't deleted, but rather labeled as deprecated
> **Note** In the case where the new method has the exact same signature as the method it's replacing, mention above that the old method *was* deleted.

1
.gitignore vendored
View File

@@ -23,7 +23,6 @@ atlassian-ide-plugin.xml
*.ctxt
# Package Files #
*.jar
*.war
*.nar
*.ear

View File

@@ -2,14 +2,13 @@ import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
plugins {
id("java")
id("maven-publish")
id("com.github.johnrengelman.shadow") version "7.1.2"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("xyz.jpenilla.run-paper") version "2.0.0"
id("net.minecrell.plugin-yml.bukkit") version "0.5.2"
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
}
group = "com.hibiscusmc"
version = "2.1.1"
version = "2.5.0"
allprojects {
apply(plugin = "java")
@@ -28,6 +27,7 @@ allprojects {
// ProtocolLib repo
maven("https://repo.dmulloy2.net/repository/public/") //ProtocolLib Repo, constantly down
maven("https://repo.mineinabyss.com/releases/")
maven("https://repo.mineinabyss.com/snapshots/")
// PlaceholderAPI
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
@@ -35,8 +35,8 @@ allprojects {
//Hikari
maven("https://mvnrepository.com/artifact/com.zaxxer/HikariCP")
// Citizens
maven("https://repo.citizensnpcs.co")
// Citizens & Denizen
maven("https://maven.citizensnpcs.co/repo")
// Worldguard
maven("https://maven.enginehub.org/repo/")
@@ -57,40 +57,51 @@ allprojects {
// ParticleHelper
maven("https://repo.bytecode.space/repository/maven-public/")
// PlayerAnimator
maven("https://mvn.lumine.io/repository/maven/")
// md-5 Repo
maven("https://repo.md-5.net/content/groups/public/")
}
dependencies {
compileOnly(fileTree("${project.rootDir}/lib") { include("*.jar") })
compileOnly("com.mojang:authlib:1.5.25")
compileOnly("org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT")
compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
compileOnly("org.jetbrains:annotations:23.0.0")
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0-SNAPSHOT")
compileOnly("me.clip:placeholderapi:2.11.1")
compileOnly("com.ticxo.modelengine:api:R3.0.1")
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0")
compileOnly("me.clip:placeholderapi:2.11.3")
compileOnly("com.ticxo:modelengine:R3.0.1")
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
compileOnly("com.mineinabyss:geary-papermc:0.24-SNAPSHOT")
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
compileOnly("it.unimi.dsi:fastutil:8.5.11")
compileOnly("com.github.LeonMangler:SuperVanish:6.2.17")
}
}
dependencies {
implementation(project(path = ":common"))
implementation(project(path = ":v1_17_R1", configuration = "reobf"))
implementation(project(path = ":v1_18_R2", configuration = "reobf"))
implementation(project(path = ":v1_19_R1", configuration = "reobf"))
implementation(project(path = ":v1_19_R2", configuration = "reobf"))
implementation(project(path = ":v1_19_R3", configuration = "reobf"))
implementation(project(path = ":v1_20_R1", configuration = "reobf"))
//compileOnly("com.github.Fisher2911:FisherLib:master-SNAPSHOT")
implementation("net.kyori:adventure-api:4.11.0")
implementation ("net.kyori:adventure-text-minimessage:4.11.0")
implementation("net.kyori:adventure-text-minimessage:4.11.0")
implementation("net.kyori:adventure-platform-bukkit:4.1.2")
implementation("dev.triumphteam:triumph-gui:3.1.3")
implementation("org.spongepowered:configurate-yaml:4.1.2")
implementation("org.bstats:bstats-bukkit:3.0.0")
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7")
implementation("com.github.BG-Software-LLC:CommentedConfiguration:-SNAPSHOT")
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
}
tasks {
@@ -110,14 +121,15 @@ tasks {
}
runServer {
minecraftVersion("1.19.2")
minecraftVersion("1.20.1")
}
shadowJar {
dependsOn(":v1_17_R1:reobfJar")
dependsOn(":v1_18_R2:reobfJar")
dependsOn(":v1_19_R1:reobfJar")
dependsOn(":v1_19_R2:reobfJar")
dependsOn(":v1_19_R3:reobfJar")
dependsOn(":v1_20_R1:reobfJar")
mergeServiceFiles()
relocate("dev.triumphteam.gui", "com.hisbiscusmc.hmccosmetics.gui")
@@ -128,7 +140,9 @@ tasks {
relocate("com.zaxxer.hikaricp", "com.hisbiscusmc.hmccosmetics.hikaricp")
relocate("com.j256.ormlite", "com.hisbiscusmc.hmccosmetics.ormlite")
relocate("com.jeff_media.updatechecker", "com.hisbiscusmc.hmccosmetics.updatechecker")
relocate("com.woen1212055.particlehelper", "com.hisbiscusmc.hmccosmetics.particlehelper")
relocate("com.owen1212055.particlehelper", "com.hisbiscusmc.hmccosmetics.particlehelper")
relocate("com.ticxo.playeranimator", "com.hisbiscusmc.hmccosmetics.playeranimator")
relocate("com.bgsoftware", "com.hisbiscusmc.hmccosmetics.configupdater")
archiveFileName.set("HMCCosmeticsRemapped-${project.version}.jar")
dependencies {
@@ -153,11 +167,14 @@ tasks {
bukkit {
load = BukkitPluginDescription.PluginLoadOrder.POSTWORLD
main = "com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin"
apiVersion = "1.16"
apiVersion = "1.18"
authors = listOf("LoJoSho")
depend = listOf("ProtocolLib", "PlaceholderAPI")
softDepend = listOf("ModelEngine", "Oraxen", "ItemsAdder", "HMCColor", "WorldGuard", "MythicMobs")
depend = listOf("ProtocolLib")
softDepend = listOf("ModelEngine", "Oraxen", "ItemsAdder", "Geary", "HMCColor", "WorldGuard", "MythicMobs", "PlaceholderAPI", "SuperVanish", "PremiumVanish", "LibsDisguises", "Denizen")
version = "${project.version}"
loadBefore = listOf(
"Cosmin" // Fixes an issue with Cosmin loading before and taking /cosmetic, when messing with what we do.
)
commands {
register("cosmetic") {
@@ -183,7 +200,22 @@ bukkit {
register("hmccosmetics.cmd.menu") {
default = BukkitPluginDescription.Permission.Default.TRUE
}
register("hmccosmetics.cmd.setlocation") {
register("hmccosmetics.emote.shiftrun") {
default = BukkitPluginDescription.Permission.Default.TRUE
}
register("hmccosmetics.cmd.emote") {
default = BukkitPluginDescription.Permission.Default.TRUE
}
register("hmccosmetics.cmd.playemote") {
default = BukkitPluginDescription.Permission.Default.OP
}
register("hmccosmetics.cmd.playemote.other") {
default = BukkitPluginDescription.Permission.Default.OP
}
register("hmccosmetics.cmd.emote.other") {
default = BukkitPluginDescription.Permission.Default.OP
}
register("hmccosmetics.cmd.setwardrobesetting") {
default = BukkitPluginDescription.Permission.Default.OP
}
register("hmccosmetics.cmd.dataclear") {
@@ -229,16 +261,3 @@ java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17
))
}
publishing {
publications {
create<MavenPublication>("maven") {
groupId = "${project.group}"
artifactId = "${project.name}"
version = "${project.version}"
from(components["java"])
}
}
}

View File

@@ -1,33 +1,109 @@
plugins {
id("java")
id("maven-publish")
}
dependencies {
compileOnly("com.mojang:authlib:1.5.25")
compileOnly("org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT")
compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
compileOnly("org.jetbrains:annotations:23.0.0")
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0-SNAPSHOT")
compileOnly("me.clip:placeholderapi:2.11.1")
compileOnly("com.ticxo.modelengine:api:R3.0.1")
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0")
compileOnly("me.clip:placeholderapi:2.11.3")
compileOnly("com.ticxo:modelengine:R3.0.1")
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
compileOnly("com.mineinabyss:geary-papermc:0.24-SNAPSHOT")
compileOnly("com.hibiscus:hmccolor:0.3-SNAPSHOT")
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
compileOnly("it.unimi.dsi:fastutil:8.5.11")
compileOnly("io.lumine:Mythic-Dist:5.2.1")
compileOnly("com.denizenscript:denizen:1.2.7-SNAPSHOT")
compileOnly("com.github.LeonMangler:SuperVanish:6.2.17")
compileOnlyApi("LibsDisguises:LibsDisguises:10.0.21") {
exclude("org.spigotmc", "spigot")
}
//compileOnly("com.github.Fisher2911:FisherLib:master-SNAPSHOT")
implementation("net.kyori:adventure-api:4.12.0")
implementation ("net.kyori:adventure-text-minimessage:4.12.0")
implementation("net.kyori:adventure-text-minimessage:4.12.0")
implementation("net.kyori:adventure-platform-bukkit:4.2.0")
implementation("dev.triumphteam:triumph-gui:3.1.3")
implementation("org.spongepowered:configurate-yaml:4.1.2")
implementation("org.bstats:bstats-bukkit:3.0.0")
implementation("com.jeff_media:SpigotUpdateChecker:3.0.0")
implementation("com.owen1212055:particlehelper:1.0.0-SNAPSHOT")
implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.7")
implementation("com.github.BG-Software-LLC:CommentedConfiguration:-SNAPSHOT")
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17
))
}
publishing {
val publishData = PublishData(project)
publications {
create<MavenPublication>("maven") {
groupId = "${rootProject.group}"
artifactId = "${rootProject.name}"
version = "${rootProject.version}"
from(components["java"])
}
}
repositories {
maven {
authentication {
credentials(PasswordCredentials::class) {
username = System.getenv("REPO_USERNAME")
password = System.getenv("REPO_PASSWORD")
}
}
name = "HibiscusMCRepository"
url = uri(publishData.getRepository())
}
}
}
class PublishData(private val project: Project) {
var type: Type = getReleaseType()
var hashLength: Int = 7
private fun getReleaseType(): Type {
val branch = getCheckedOutBranch()
return when {
branch.contentEquals("master") || branch.contentEquals("local") -> Type.RELEASE
branch.startsWith("dev") -> Type.DEV
else -> Type.SNAPSHOT
}
}
private fun getCheckedOutGitCommitHash(): String =
System.getenv("GITHUB_SHA")?.substring(0, hashLength) ?: "local"
private fun getCheckedOutBranch(): String =
System.getenv("GITHUB_REF")?.replace("refs/heads/", "") ?: "local"
fun getVersion(): String = getVersion(false)
fun getVersion(appendCommit: Boolean): String =
type.append(getVersionString(), appendCommit, getCheckedOutGitCommitHash())
private fun getVersionString(): String =
(rootProject.version as String).replace("-SNAPSHOT", "").replace("-DEV", "")
fun getRepository(): String = type.repo
enum class Type(private val append: String, val repo: String, private val addCommit: Boolean) {
RELEASE("", "https://repo.hibiscusmc.com/releases/", false),
DEV("-DEV", "https://repo.hibiscusmc.com/development/", true),
SNAPSHOT("-SNAPSHOT", "https://repo.hibiscusmc.com/snapshots/", true);
fun append(name: String, appendCommit: Boolean, commitHash: String): String =
name.plus(append).plus(if (appendCommit && addCommit) "-".plus(commitHash) else "")
}
}

View File

@@ -1,6 +1,7 @@
package com.hibiscusmc.hmccosmetics;
import com.hibiscusmc.hmccosmetics.api.HMCCosmeticSetupEvent;
import com.bgsoftware.common.config.CommentedConfiguration;
import com.hibiscusmc.hmccosmetics.api.events.HMCCosmeticSetupEvent;
import com.hibiscusmc.hmccosmetics.command.CosmeticCommand;
import com.hibiscusmc.hmccosmetics.command.CosmeticCommandTabComplete;
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
@@ -11,18 +12,22 @@ import com.hibiscusmc.hmccosmetics.config.serializer.LocationSerializer;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
import com.hibiscusmc.hmccosmetics.database.Database;
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
import com.hibiscusmc.hmccosmetics.gui.Menu;
import com.hibiscusmc.hmccosmetics.gui.Menus;
import com.hibiscusmc.hmccosmetics.hooks.PAPIHook;
import com.hibiscusmc.hmccosmetics.hooks.items.ItemHooks;
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGHook;
import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGListener;
import com.hibiscusmc.hmccosmetics.listener.PlayerConnectionListener;
import com.hibiscusmc.hmccosmetics.listener.PlayerGameListener;
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
import com.jeff_media.updatechecker.UpdateCheckSource;
import com.jeff_media.updatechecker.UpdateChecker;
import com.ticxo.playeranimator.PlayerAnimatorImpl;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@@ -45,7 +50,8 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
private static boolean disable = false;
private static YamlConfigurationLoader configLoader;
private static final int pluginId = 13873;
private static boolean hasModelEngine = false;
private static boolean onLatestVersion = true;
private static String latestVersion = "";
@Override
public void onEnable() {
@@ -62,20 +68,52 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
}
// Update Checker
new UpdateChecker(this, UpdateCheckSource.POLYMART, "1879")
.setDownloadLink("https://polymart.org/resource/1879")
UpdateChecker checker = new UpdateChecker(this, UpdateCheckSource.POLYMART, "1879")
.onSuccess((commandSenders, latestVersion) -> {
this.latestVersion = (String) latestVersion;
if (!this.latestVersion.equalsIgnoreCase(getDescription().getVersion())) {
getLogger().info("+++++++++++++++++++++++++++++++++++");
getLogger().info("There is a new update for HMCCosmetics!");
getLogger().info("Please download it as soon as possible for possible fixes and new features.");
getLogger().info("Current Version " + getDescription().getVersion() + " | Latest Version " + latestVersion);
getLogger().info("Spigot: https://www.spigotmc.org/resources/100107/");
getLogger().info("Polymart: https://polymart.org/resource/1879");
getLogger().info("+++++++++++++++++++++++++++++++++++");
}
})
.setNotifyRequesters(false)
.setNotifyOpsOnJoin(false)
.checkEveryXHours(24)
.checkNow();
onLatestVersion = checker.isUsingLatestVersion();
// File setup
if (!getDataFolder().exists()) {
saveDefaultConfig();
saveResource("translations.yml", false);
saveResource("messages.yml", false);
saveResource("cosmetics/defaultcosmetics.yml", false);
saveResource("menus/defaultmenu.yml", false);
saveDefaultConfig();
if (!Path.of(getDataFolder().getPath(), "messages.yml").toFile().exists()) saveResource("messages.yml", false);
if (!Path.of(getDataFolder().getPath(), "translations.yml").toFile().exists()) saveResource("translations.yml", false);
if (!Path.of(getDataFolder().getPath() + "/cosmetics/").toFile().exists()) saveResource("cosmetics/defaultcosmetics.yml", false);
if (!Path.of(getDataFolder().getPath() + "/menus/").toFile().exists()) saveResource("menus/defaultmenu.yml", false);
// Emote folder setup
File emoteFile = new File(getDataFolder().getPath() + "/emotes");
if (!emoteFile.exists()) emoteFile.mkdir();
// Player Animator
PlayerAnimatorImpl.initialize(this);
// Configuration Sync
final File configFile = Path.of(getInstance().getDataFolder().getPath(), "config.yml").toFile();
final File messageFile = Path.of(getInstance().getDataFolder().getPath(), "messages.yml").toFile();
final File translationFile = Path.of(getInstance().getDataFolder().getPath(), "translations.yml").toFile();
try {
CommentedConfiguration.loadConfiguration(configFile).syncWithConfig(configFile, getInstance().getResource("config.yml"),
"database-settings", "debug-mode", "wardrobe.viewer-location", "wardrobe.npc-location", "wardrobe.wardrobe-location", "wardrobe.leave-location");
CommentedConfiguration.loadConfiguration(messageFile).syncWithConfig(messageFile, getInstance().getResource("messages.yml"));
CommentedConfiguration.loadConfiguration(translationFile).syncWithConfig(translationFile, getInstance().getResource("translations.yml"));
} catch (Exception e) {
e.printStackTrace();
}
// Setup
setup();
// Commands
@@ -89,18 +127,8 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
// Database
new Database();
// PAPI
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new PAPIHook().register();
}
// ModelEngine
if (Bukkit.getPluginManager().getPlugin("ModelEngine") != null) {
hasModelEngine = true;
}
// WorldGuard
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null) {
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null && Settings.isWorldGuardMoveCheckEnabled()) {
getServer().getPluginManager().registerEvents(new WGListener(), this);
}
}
@@ -115,11 +143,16 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
@Override
public void onDisable() {
// Plugin shutdown logic
disable = true;
for (Player player : Bukkit.getOnlinePlayers()) {
Database.save(player);
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null) continue;
if (user.getUserEmoteManager().isPlayingEmote()) {
player.setInvisible(false);
}
Database.save(user);
}
// Plugin shutdown logic
}
public static HMCCosmeticsPlugin getInstance() {
@@ -146,7 +179,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
WardrobeSettings.load(loader.load().node("wardrobe"));
DatabaseSettings.load(loader.load().node("database-settings"));
configLoader = loader;
} catch (ConfigurateException e) {
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -181,8 +214,8 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
throw new RuntimeException(e);
}
// ItemHooks
ItemHooks.setup();
// Misc Hooks setup (like items)
Hooks.setup();
// Cosmetics setup
Cosmetics.setup();
@@ -212,10 +245,19 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
getInstance().getServer().getPluginManager().addPermission(new Permission(cosmetic.getPermission()));
}
}
for (Menu menu : Menus.values()) {
if (menu.getPermissionNode() != null) {
if (getInstance().getServer().getPluginManager().getPermission(menu.getPermissionNode()) != null) continue;
getInstance().getServer().getPluginManager().addPermission(new Permission(menu.getPermissionNode()));
}
}
EmoteManager.loadEmotes();
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
getInstance().getLogger().info(Cosmetics.values().size() + " Cosmetics Successfully Setup");
getInstance().getLogger().info(Menus.getMenuNames().size() + " Menus Successfully Setup");
getInstance().getLogger().info(WardrobeSettings.getWardrobes().size() + " Wardrobes Successfully Setup");
getInstance().getLogger().info("Data storage is set to " + DatabaseSettings.getDatabaseType());
Bukkit.getPluginManager().callEvent(new HMCCosmeticSetupEvent());
@@ -238,7 +280,10 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
}
}
public static boolean hasModelEngine() {
return hasModelEngine;
public static boolean isOnLatestVersion() {
return onLatestVersion;
}
public static String getLatestVersion() {
return latestVersion;
}
}

View File

@@ -0,0 +1,80 @@
package com.hibiscusmc.hmccosmetics.api;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
import com.hibiscusmc.hmccosmetics.gui.Menu;
import com.hibiscusmc.hmccosmetics.gui.Menus;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import org.bukkit.Color;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.UUID;
public class HMCCosmeticsAPI {
/**
* Attempts to get a cosmetic from HMCCosmetics
*
* @param cosmetic Cosmetic Id
* @return A {@link Cosmetic} if exists or null if it does not
*/
@Nullable
public static Cosmetic getCosmetic(String cosmetic) {
return Cosmetics.getCosmetic(cosmetic);
}
/**
* Attempts to get the CosmeticUser from an online user. If a player is offline it will return null.
* A player maybe online but not have a CosmeticUser attached to them, either from delay specified in the config
* or from a /reload. Always check if it's null!
*
* @param uuid Player Unique ID
* @return A {@link CosmeticUser} if exists or null if it does not
*/
@Nullable
public static CosmeticUser getUser(UUID uuid) {
return CosmeticUsers.getUser(uuid);
}
/**
* Attempts to get a HMCCosmetics Menu. Returns null if no menu exists under that id.
*
* @param id Menu ID
* @return A {@link Menu} if exists or null if it does not
*/
@Nullable
public static Menu getMenu(String id) {
return Menus.getMenu(id);
}
/**
* Equips a cosmetic to a player. You can use getUser and getCosmetic to get the CosmeticUser and Cosmetic to equip.
* @param user CosmeticUser to equip cosmetic to
* @param cosmetic Cosmetic to equip
*/
public static void equipCosmetic(@NotNull CosmeticUser user, @NotNull Cosmetic cosmetic) {
equipCosmetic(user, cosmetic, null);
}
/**
* Equips a cosmetic to a player with a color. You can use getUser and getCosmetic to get the CosmeticUser and Cosmetic to equip.
* @param user CosmeticUser to equip cosmetic to
* @param cosmetic Cosmetic to equip
* @param color Color to apply to cosmetic
*/
public static void equipCosmetic(@NotNull CosmeticUser user, @NotNull Cosmetic cosmetic, @Nullable Color color) {
user.addPlayerCosmetic(cosmetic, color);
}
/**
* Removes a cosmetic in cosmeticslot.
* @param user The user to remove the cosmetic from
* @param slot The slot to remove the cosmetic from
*/
public static void unequipCosmetic(CosmeticUser user, CosmeticSlot slot) {
user.removeCosmeticSlot(slot);
}
}

View File

@@ -1,53 +0,0 @@
package com.hibiscusmc.hmccosmetics.api;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class PlayerCosmeticEquipEvent extends Event implements Cancellable {
private CosmeticUser user;
private Cosmetic cosmetic;
private boolean isCancelled;
public PlayerCosmeticEquipEvent(CosmeticUser user, Cosmetic cosmetic) {
this.user = user;
this.cosmetic = cosmetic;
this.isCancelled = false;
}
@Override
public boolean isCancelled() {
return isCancelled;
}
@Override
public void setCancelled(boolean cancel) {
isCancelled = cancel;
}
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public CosmeticUser getUser() {
return user;
}
public Cosmetic getCosmetic() {
return cosmetic;
}
public void setCosmetic() {
this.cosmetic = cosmetic;
}
}

View File

@@ -1,47 +0,0 @@
package com.hibiscusmc.hmccosmetics.api;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class PlayerCosmeticHideEvent extends Event implements Cancellable {
private CosmeticUser user;
private CosmeticUser.HiddenReason reason;
private boolean isCancelled;
public PlayerCosmeticHideEvent(CosmeticUser user, CosmeticUser.HiddenReason reason) {
this.user = user;
this.reason = reason;
this.isCancelled = false;
}
@Override
public boolean isCancelled() {
return isCancelled;
}
@Override
public void setCancelled(boolean cancel) {
isCancelled = cancel;
}
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public CosmeticUser getUser() {
return user;
}
public CosmeticUser.HiddenReason getReason() {
return reason;
}
}

View File

@@ -1,49 +0,0 @@
package com.hibiscusmc.hmccosmetics.api;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class PlayerCosmeticRemoveEvent extends Event implements Cancellable {
private CosmeticUser user;
private Cosmetic cosmetic;
private boolean isCancelled;
public PlayerCosmeticRemoveEvent(CosmeticUser user, Cosmetic cosmetic) {
this.user = user;
this.cosmetic = cosmetic;
this.isCancelled = false;
}
@Override
public boolean isCancelled() {
return isCancelled;
}
@Override
public void setCancelled(boolean cancel) {
isCancelled = cancel;
}
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public CosmeticUser getUser() {
return user;
}
public Cosmetic getCosmetic() {
return cosmetic;
}
}

View File

@@ -1,42 +0,0 @@
package com.hibiscusmc.hmccosmetics.api;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class PlayerCosmeticShowEvent extends Event implements Cancellable {
private CosmeticUser user;
private boolean isCancelled;
public PlayerCosmeticShowEvent(CosmeticUser user) {
this.user = user;
this.isCancelled = false;
}
@Override
public boolean isCancelled() {
return isCancelled;
}
@Override
public void setCancelled(boolean cancel) {
isCancelled = cancel;
}
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public CosmeticUser getUser() {
return user;
}
}

View File

@@ -1,49 +0,0 @@
package com.hibiscusmc.hmccosmetics.api;
import com.hibiscusmc.hmccosmetics.gui.Menu;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class PlayerMenuOpenEvent extends Event implements Cancellable {
private CosmeticUser user;
private Menu menu;
private boolean isCancelled;
public PlayerMenuOpenEvent(CosmeticUser user, Menu menu) {
this.user = user;
this.menu = menu;
this.isCancelled = false;
}
@Override
public boolean isCancelled() {
return isCancelled;
}
@Override
public void setCancelled(boolean cancel) {
isCancelled = cancel;
}
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public CosmeticUser getUser() {
return user;
}
public Menu getMenu() {
return menu;
}
}

View File

@@ -1,42 +0,0 @@
package com.hibiscusmc.hmccosmetics.api;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class PlayerWardrobeEnterEvent extends Event implements Cancellable {
private CosmeticUser user;
private boolean isCancelled;
public PlayerWardrobeEnterEvent(CosmeticUser user) {
this.user = user;
this.isCancelled = false;
}
@Override
public boolean isCancelled() {
return isCancelled;
}
@Override
public void setCancelled(boolean cancel) {
isCancelled = cancel;
}
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public CosmeticUser getUser() {
return user;
}
}

View File

@@ -1,42 +0,0 @@
package com.hibiscusmc.hmccosmetics.api;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class PlayerWardrobeLeaveEvent extends Event implements Cancellable {
private CosmeticUser user;
private boolean isCancelled;
public PlayerWardrobeLeaveEvent(CosmeticUser user) {
this.user = user;
this.isCancelled = false;
}
@Override
public boolean isCancelled() {
return isCancelled;
}
@Override
public void setCancelled(boolean cancel) {
isCancelled = cancel;
}
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public CosmeticUser getUser() {
return user;
}
}

View File

@@ -1,21 +1,22 @@
package com.hibiscusmc.hmccosmetics.api;
package com.hibiscusmc.hmccosmetics.api.events;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when the plugin is set up and/or reloaded
*/
public class HMCCosmeticSetupEvent extends Event {
public HMCCosmeticSetupEvent() {
// Empty
}
private static final HandlerList handlers = new HandlerList();
@Override
@NotNull
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -0,0 +1,70 @@
package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player equips a cosmetic
*/
public class PlayerCosmeticEquipEvent extends PlayerCosmeticEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel = false;
private Cosmetic cosmetic;
public PlayerCosmeticEquipEvent(@NotNull CosmeticUser who, @NotNull Cosmetic cosmetic) {
super(who);
this.cosmetic = cosmetic;
}
/**
* Gets the {@link Cosmetic} being equipped in this event
*
* @return The {@link Cosmetic} which is being equipped in this event
*/
@NotNull
public Cosmetic getCosmetic() {
return cosmetic;
}
/**
* Sets the {@link Cosmetic} that the player will equip
*
* @param cosmetic The {@link Cosmetic} that the player will equip
*/
public void setCosmetic(@NotNull Cosmetic cosmetic) {
this.cosmetic = cosmetic;
}
@Override
public boolean isCancelled() {
return cancel;
}
/**
* Sets the cancellation state of this event
*
* <p>
* Canceling this event will prevent the player from equipping the cosmetic
* </p>
*
* @param cancel true if you wish to cancel this event
*/
@Override
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
@Override
@NotNull
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -0,0 +1,26 @@
package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
/**
* Represents a cosmetic user related event
*/
public abstract class PlayerCosmeticEvent extends Event {
protected CosmeticUser user;
public PlayerCosmeticEvent(@NotNull final CosmeticUser who) {
user = who;
}
/**
* Returns the user involved in this event
*
* @return User who is involved in this event
*/
@NotNull
public final CosmeticUser getUser() {
return user;
}
}

View File

@@ -0,0 +1,60 @@
package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when cosmetics are hidden from a player
*/
public class PlayerCosmeticHideEvent extends PlayerCosmeticEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel = false;
private final CosmeticUser.HiddenReason reason;
public PlayerCosmeticHideEvent(@NotNull CosmeticUser who, @NotNull CosmeticUser.HiddenReason reason) {
super(who);
this.reason = reason;
}
/**
* Gets the {@link CosmeticUser.HiddenReason} as to why cosmetics are being hidden for the player
*
* @return The {@link CosmeticUser.HiddenReason} why cosmetics are being hidden for the player
*/
@NotNull
public CosmeticUser.HiddenReason getReason() {
return reason;
}
@Override
public boolean isCancelled() {
return cancel;
}
/**
* Sets the cancellation state of this event
*
* <p>
* Canceling this event will prevent the player from hiding cosmetics
* </p>
*
* @param cancel true if you wish to cancel this event
*/
@Override
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
@Override
@NotNull
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -0,0 +1,46 @@
package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
public class PlayerCosmeticPostEquipEvent extends PlayerCosmeticEvent {
private static final HandlerList handlers = new HandlerList();
private Cosmetic cosmetic;
public PlayerCosmeticPostEquipEvent(@NotNull CosmeticUser who, @NotNull Cosmetic cosmetic) {
super(who);
this.cosmetic = cosmetic;
}
/**
* Gets the {@link Cosmetic} being equipped in this event
*
* @return The {@link Cosmetic} which is being equipped in this event
*/
@NotNull
public Cosmetic getCosmetic() {
return cosmetic;
}
/**
* Sets the {@link Cosmetic} that the player will equip
*
* @param cosmetic The {@link Cosmetic} that the player will equip
*/
public void setCosmetic(@NotNull Cosmetic cosmetic) {
this.cosmetic = cosmetic;
}
@Override
@NotNull
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -0,0 +1,59 @@
package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player removes a cosmetic
*/
public class PlayerCosmeticRemoveEvent extends PlayerCosmeticEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel = false;
private final Cosmetic cosmetic;
public PlayerCosmeticRemoveEvent(@NotNull CosmeticUser who, @NotNull Cosmetic cosmetic) {
super(who);
this.cosmetic = cosmetic;
}
/**
* Gets the {@link Cosmetic} being removed in this event
*
* @return The {@link Cosmetic} which is being removed in this event
*/
public Cosmetic getCosmetic() {
return cosmetic;
}
@Override
public boolean isCancelled() {
return cancel;
}
/**
* Sets the cancellation state of this event
*
* <p>
* Canceling this event will prevent the player from removing the cosmetic
* </p>
*
* @param cancel true if you wish to cancel this event
*/
@Override
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
@Override
@NotNull
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -0,0 +1,48 @@
package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when cosmetics are shown from a player
*/
public class PlayerCosmeticShowEvent extends PlayerCosmeticEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel = false;
public PlayerCosmeticShowEvent(@NotNull CosmeticUser who) {
super(who);
}
@Override
public boolean isCancelled() {
return cancel;
}
/**
* Sets the cancellation state of this event
*
* <p>
* Canceling this event will prevent the player from showing cosmetics
* </p>
*
* @param cancel true if you wish to cancel this event
*/
@Override
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
@Override
@NotNull
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -0,0 +1,61 @@
package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player starts playing an emote
*/
public class PlayerEmoteStartEvent extends PlayerCosmeticEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel = false;
private final String animationId;
public PlayerEmoteStartEvent(@NotNull CosmeticUser who, @NotNull String animationId) {
super(who);
this.animationId = animationId;
}
/**
* Gets the animation id of the emote the player started playing
* @implNote The returned string of this method may be an invalid animation id. Make sure to validate it before use
*
* @return The animation id of the emote which the player started playing
*/
@NotNull
public String getAnimationId() {
return animationId;
}
@Override
public boolean isCancelled() {
return cancel;
}
/**
* Sets the cancellation state of this event
*
* <p>
* Canceling this event will prevent the player from playing the emote
* </p>
*
* @param cancel true if you wish to cancel this event
*/
@Override
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
@Override
@NotNull
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -0,0 +1,74 @@
package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player stops playing an emote
*/
public class PlayerEmoteStopEvent extends PlayerCosmeticEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel = false;
private final UserEmoteManager.StopEmoteReason reason;
public PlayerEmoteStopEvent(@NotNull CosmeticUser who, @NotNull UserEmoteManager.StopEmoteReason reason) {
super(who);
this.reason = reason;
}
/**
* Gets the {@link UserEmoteManager.StopEmoteReason} as to why the emote has stopped playing
*
* @return The {@link UserEmoteManager.StopEmoteReason} why the emote has stopped playing
* @deprecated As of release 2.2.5+, replaced by {@link #getReason()}
*/
@Deprecated
@NotNull
public UserEmoteManager.StopEmoteReason getStopEmoteReason() {
return reason;
}
/**
* Gets the {@link UserEmoteManager.StopEmoteReason} as to why the emote has stopped playing
*
* @return The {@link UserEmoteManager.StopEmoteReason} why the emote has stopped playing
* @since 2.2.5
*/
@NotNull
public UserEmoteManager.StopEmoteReason getReason() {
return reason;
}
@Override
public boolean isCancelled() {
return cancel;
}
/**
* Sets the cancellation state of this event
*
* <p>
* Canceling this event will prevent the player from stopping the emote
* </p>
*
* @param cancel true if you wish to cancel this event
*/
@Override
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
@Override
@NotNull
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -0,0 +1,28 @@
package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.gui.Menu;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a menu is closed by a player
*/
public class PlayerMenuCloseEvent extends PlayerMenuEvent {
private static final HandlerList handlers = new HandlerList();
public PlayerMenuCloseEvent(@NotNull CosmeticUser who, @NotNull Menu menu) {
super(who, menu);
}
@Override
@NotNull
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -0,0 +1,27 @@
package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.gui.Menu;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.jetbrains.annotations.NotNull;
/**
* Represents a menu related event
*/
public abstract class PlayerMenuEvent extends PlayerCosmeticEvent {
protected Menu menu;
public PlayerMenuEvent(@NotNull CosmeticUser who, @NotNull Menu menu) {
super(who);
this.menu = menu;
}
/**
* Gets the {@link Menu} involved with this event
*
* @return The {@link Menu} which is involved with the event
*/
@NotNull
public final Menu getMenu() {
return menu;
}
}

View File

@@ -0,0 +1,49 @@
package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.gui.Menu;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a menu is opened by a player
*/
public class PlayerMenuOpenEvent extends PlayerMenuEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel = false;
public PlayerMenuOpenEvent(@NotNull CosmeticUser who, @NotNull Menu menu) {
super(who, menu);
}
@Override
public boolean isCancelled() {
return cancel;
}
/**
* Sets the cancellation state of this event
*
* <p>
* Canceling this event will prevent the player from opening a {@link Menu}
* </p>
*
* @param cancel true if you wish to cancel this event
*/
@Override
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
@Override
@NotNull
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -0,0 +1,59 @@
package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player enters their wardrobe
*/
public class PlayerWardrobeEnterEvent extends PlayerCosmeticEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel = false;
private Wardrobe wardrobe;
public PlayerWardrobeEnterEvent(@NotNull CosmeticUser who, @NotNull Wardrobe wardrobe) {
super(who);
this.wardrobe = wardrobe;
}
@Override
public boolean isCancelled() {
return cancel;
}
/**
* Sets the cancellation state of this event
*
* <p>
* Canceling this event will prevent the player from entering their wardrobe
* </p>
*
* @param cancel true if you wish to cancel this event
*/
@Override
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
@Override
@NotNull
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}
public void setWardrobe(Wardrobe wardrobe) {
this.wardrobe = wardrobe;
}
public Wardrobe getWardrobe() {
return wardrobe;
}
}

View File

@@ -0,0 +1,48 @@
package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player leaves their wardrobe
*/
public class PlayerWardrobeLeaveEvent extends PlayerCosmeticEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel = false;
public PlayerWardrobeLeaveEvent(@NotNull CosmeticUser who) {
super(who);
}
@Override
public boolean isCancelled() {
return cancel;
}
/**
* Sets the cancellation state of this event
*
* <p>
* Canceling this event will prevent the player from leaving their wardrobe
* </p>
*
* @param cancel true if you wish to cancel this event
*/
@Override
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
@Override
@NotNull
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -2,11 +2,15 @@ package com.hibiscusmc.hmccosmetics.command;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
import com.hibiscusmc.hmccosmetics.config.WardrobeLocation;
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
import com.hibiscusmc.hmccosmetics.database.Database;
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
import com.hibiscusmc.hmccosmetics.gui.Menu;
import com.hibiscusmc.hmccosmetics.gui.Menus;
import com.hibiscusmc.hmccosmetics.gui.special.DyeMenu;
@@ -26,13 +30,17 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
public class CosmeticCommand implements CommandExecutor {
// cosmetics apply cosmetics playerName
// 0 1 2
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String @NotNull [] args) {
boolean silent = false;
if (args.length == 0) {
if (!(sender instanceof Player)) {
// Console
@@ -44,7 +52,7 @@ public class CosmeticCommand implements CommandExecutor {
}
CosmeticUser user = CosmeticUsers.getUser(((Player) sender).getUniqueId());
Menu menu = Menus.getMenu(Settings.getDefaultMenu());
Menu menu = Menus.getDefaultMenu();
if (user == null) {
MessagesUtil.sendMessage(sender, "invalid-player");
@@ -62,49 +70,64 @@ public class CosmeticCommand implements CommandExecutor {
Player player = sender instanceof Player ? (Player) sender : null;
String firstArgs = args[0].toLowerCase();
if (sender.hasPermission("HMCCosmetics.cmd.silent") || sender.isOp()) {
for (String singleArg : args) {
if (singleArg.equalsIgnoreCase("-s")) {
silent = true;
break;
}
}
}
switch (firstArgs) {
case ("reload") -> {
if (!sender.hasPermission("HMCCosmetics.cmd.reload") || !sender.isOp()) {
MessagesUtil.sendMessage(sender, "no-permission");
if (!sender.hasPermission("HMCCosmetics.cmd.reload") && !sender.isOp()) {
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
HMCCosmeticsPlugin.setup();
MessagesUtil.sendMessage(sender, "reloaded");
if (!silent) MessagesUtil.sendMessage(sender, "reloaded");
return true;
}
case ("apply") -> {
if (!sender.hasPermission("hmccosmetics.cmd.apply")) {
MessagesUtil.sendMessage(sender, "no-permission");
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
Cosmetic cosmetic;
Color color = null;
if (sender instanceof Player) player = ((Player) sender).getPlayer();
if (sender.hasPermission("hmccosmetics.cmd.apply.other")) {
if (args.length >= 3) player = Bukkit.getPlayer(args[2]);
}
if (sender.hasPermission("hmccosmetics.cmd.apply.color")) {
if (args.length >= 4) color = ServerUtils.hex2Rgb(args[3]);
}
if (args.length == 1) {
MessagesUtil.sendMessage(player, "not-enough-args");
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
return true;
}
cosmetic = Cosmetics.getCosmetic(args[1]);
if (cosmetic == null) {
MessagesUtil.sendMessage(sender, "invalid-cosmetic");
if (!silent) MessagesUtil.sendMessage(sender, "invalid-cosmetic");
return true;
}
if (player == null) {
MessagesUtil.sendMessage(sender, "invalid-player");
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
return true;
}
CosmeticUser user = CosmeticUsers.getUser(player);
if (!user.canEquipCosmetic(cosmetic)) {
MessagesUtil.sendMessage(player, "no-cosmetic-permission");
if (!silent) MessagesUtil.sendMessage(player, "no-cosmetic-permission");
return true;
}
@@ -113,84 +136,106 @@ public class CosmeticCommand implements CommandExecutor {
TagResolver.resolver(Placeholder.parsed("player", player.getName())),
TagResolver.resolver(Placeholder.parsed("cosmeticslot", cosmetic.getSlot().name())));
MessagesUtil.sendMessage(player, "equip-cosmetic", placeholders);
if (!silent) MessagesUtil.sendMessage(player, "equip-cosmetic", placeholders);
user.addPlayerCosmetic(cosmetic);
user.addPlayerCosmetic(cosmetic, color);
user.updateCosmetic(cosmetic.getSlot());
return true;
}
case ("unapply") -> {
if (!sender.hasPermission("hmccosmetics.cmd.unapply")) {
MessagesUtil.sendMessage(sender, "no-permission");
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
if (args.length == 1) {
MessagesUtil.sendMessage(player, "not-enough-args");
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
return true;
}
CosmeticSlot cosmeticSlot = null;
if (sender instanceof Player) player = ((Player) sender).getPlayer();
if (sender.hasPermission("hmccosmetics.cmd.unapply.other")) {
if (args.length >= 3) player = Bukkit.getPlayer(args[2]);
}
if (!EnumUtils.isValidEnum(CosmeticSlot.class, args[1].toUpperCase())) {
MessagesUtil.sendMessage(sender, "invalid-slot");
return true;
}
cosmeticSlot = CosmeticSlot.valueOf(args[1].toUpperCase());
if (player == null) {
MessagesUtil.sendMessage(sender, "invalid-player");
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
return true;
}
CosmeticUser user = CosmeticUsers.getUser(player);
if (user.getCosmetic(cosmeticSlot) == null) {
MessagesUtil.sendMessage(sender, "no-cosmetic-slot");
return true;
Set<CosmeticSlot> cosmeticSlots;
if (args[1].equalsIgnoreCase("all")) {
cosmeticSlots = user.getSlotsWithCosmetics();
} else {
if (!EnumUtils.isValidEnum(CosmeticSlot.class, args[1].toUpperCase())) {
if (!silent) MessagesUtil.sendMessage(sender, "invalid-slot");
return true;
}
cosmeticSlots = Set.of(CosmeticSlot.valueOf(args[1].toUpperCase()));
}
TagResolver placeholders =
TagResolver.resolver(Placeholder.parsed("cosmetic", user.getCosmetic(cosmeticSlot).getId()),
TagResolver.resolver(Placeholder.parsed("player", player.getName())),
TagResolver.resolver(Placeholder.parsed("cosmeticslot", cosmeticSlot.name())));
for (CosmeticSlot cosmeticSlot : cosmeticSlots) {
if (user.getCosmetic(cosmeticSlot) == null) {
if (!silent) MessagesUtil.sendMessage(sender, "no-cosmetic-slot");
continue;
}
MessagesUtil.sendMessage(player, "unequip-cosmetic", placeholders);
TagResolver placeholders =
TagResolver.resolver(Placeholder.parsed("cosmetic", user.getCosmetic(cosmeticSlot).getId()),
TagResolver.resolver(Placeholder.parsed("player", player.getName())),
TagResolver.resolver(Placeholder.parsed("cosmeticslot", cosmeticSlot.name())));
user.removeCosmeticSlot(cosmeticSlot);
user.updateCosmetic(cosmeticSlot);
if (!silent) MessagesUtil.sendMessage(player, "unequip-cosmetic", placeholders);
user.removeCosmeticSlot(cosmeticSlot);
user.updateCosmetic(cosmeticSlot);
}
return true;
}
case ("wardrobe") -> {
if (sender instanceof Player) player = ((Player) sender).getPlayer();
if (args.length == 1) {
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
return true;
}
if (sender.hasPermission("hmccosmetics.cmd.wardrobe.other")) {
if (args.length >= 2) player = Bukkit.getPlayer(args[1]);
if (args.length >= 3) player = Bukkit.getPlayer(args[2]);
}
if (!sender.hasPermission("hmccosmetics.cmd.wardrobe")) {
MessagesUtil.sendMessage(sender, "no-permission");
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
if (player == null) {
MessagesUtil.sendMessage(sender, "invalid-player");
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
return true;
}
if (!WardrobeSettings.getWardrobeNames().contains(args[1])) {
if (!silent) MessagesUtil.sendMessage(sender, "no-wardrobes");
return true;
}
Wardrobe wardrobe = WardrobeSettings.getWardrobe(args[1]);
CosmeticUser user = CosmeticUsers.getUser(player);
user.toggleWardrobe();
if (user.isInWardrobe()) {
user.leaveWardrobe();
} else {
user.enterWardrobe(false, wardrobe);
}
return true;
}
// cosmetic menu exampleMenu playerName
case ("menu") -> {
if (args.length == 1) return true;
if (!sender.hasPermission("hmccosmetics.cmd.menu")) {
MessagesUtil.sendMessage(sender, "no-permission");
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
Menu menu = Menus.getMenu(args[1]);
@@ -202,12 +247,12 @@ public class CosmeticCommand implements CommandExecutor {
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null) {
MessagesUtil.sendMessage(sender, "invalid-player");
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
return true;
}
if (menu == null) {
MessagesUtil.sendMessage(sender, "invalid-menu");
if (!silent) MessagesUtil.sendMessage(sender, "invalid-menu");
return true;
}
@@ -219,7 +264,7 @@ public class CosmeticCommand implements CommandExecutor {
OfflinePlayer selectedPlayer = Bukkit.getOfflinePlayer(args[1]);
if (selectedPlayer == null) return true;
if (!sender.hasPermission("hmccosmetics.cmd.dataclear") && !sender.isOp()) {
MessagesUtil.sendMessage(sender, "no-permission");
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
Database.clearData(selectedPlayer.getUniqueId());
@@ -231,17 +276,17 @@ public class CosmeticCommand implements CommandExecutor {
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null) return true;
if (!sender.hasPermission("hmccosmetics.cmd.dye") && !sender.isOp()) {
MessagesUtil.sendMessage(sender, "no-permission");
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
if (args.length == 1) {
MessagesUtil.sendMessage(player, "not-enough-args");
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
return true;
}
if (!EnumUtils.isValidEnum(CosmeticSlot.class, args[1])) {
MessagesUtil.sendMessage(player, "invalid-slot");
if (!silent) MessagesUtil.sendMessage(player, "invalid-slot");
return true;
}
CosmeticSlot slot = CosmeticSlot.valueOf(args[1]);
@@ -249,12 +294,12 @@ public class CosmeticCommand implements CommandExecutor {
if (args.length >= 3) {
if (args[2].isEmpty()) {
MessagesUtil.sendMessage(player, "invalid-color");
if (!silent) MessagesUtil.sendMessage(player, "invalid-color");
return true;
}
Color color = ServerUtils.hex2Rgb(args[2]);
if (color == null) {
MessagesUtil.sendMessage(player, "invalid-color");
if (!silent) MessagesUtil.sendMessage(player, "invalid-color");
return true;
}
user.addPlayerCosmetic(cosmetic, color); // #FFFFFF
@@ -262,35 +307,55 @@ public class CosmeticCommand implements CommandExecutor {
DyeMenu.openMenu(user, cosmetic);
}
}
case ("setlocation") -> {
if (!sender.hasPermission("hmccosmetics.cmd.setlocation")) {
MessagesUtil.sendMessage(sender, "no-permission");
case ("setwardrobesetting") -> {
if (!sender.hasPermission("hmccosmetics.cmd.setwardrobesetting")) {
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
if (player == null) return true;
if (args.length < 2) {
MessagesUtil.sendMessage(player, "not-enough-args");
if (args.length < 3) {
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
return true;
}
Wardrobe wardrobe = WardrobeSettings.getWardrobe(args[1]);
if (wardrobe == null) {
wardrobe = new Wardrobe(args[1], new WardrobeLocation(null, null, null), null, -1);
WardrobeSettings.addWardrobe(wardrobe);
//MessagesUtil.sendMessage(player, "no-wardrobes");
//return true;
}
if (args[2].equalsIgnoreCase("npclocation")) {
WardrobeSettings.setNPCLocation(wardrobe, player.getLocation());
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-location");
return true;
}
if (args[1].equalsIgnoreCase("wardrobelocation")) {
WardrobeSettings.setWardrobeLocation(player.getLocation());
MessagesUtil.sendMessage(player, "set-wardrobe-location");
if (args[2].equalsIgnoreCase("viewerlocation")) {
WardrobeSettings.setViewerLocation(wardrobe, player.getLocation());
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-viewing");
return true;
}
if (args[1].equalsIgnoreCase("viewerlocation")) {
WardrobeSettings.setViewerLocation(player.getLocation());
MessagesUtil.sendMessage(player, "set-wardrobe-viewing");
if (args[2].equalsIgnoreCase("leavelocation")) {
WardrobeSettings.setLeaveLocation(wardrobe, player.getLocation());
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-leaving");
return true;
}
if (args[1].equalsIgnoreCase("leavelocation")) {
WardrobeSettings.setLeaveLocation(player.getLocation());
MessagesUtil.sendMessage(player, "set-wardrobe-leaving");
return true;
if (args.length >= 4) {
if (args[2].equalsIgnoreCase("permission")) {
WardrobeSettings.setWardrobePermission(wardrobe, args[3]);
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-permission");
return true;
}
if (args[2].equalsIgnoreCase("distance")) {
WardrobeSettings.setWardrobeDistance(wardrobe, Integer.valueOf(args[3]));
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-distance");
return true;
}
}
}
case ("dump") -> {
@@ -298,14 +363,14 @@ public class CosmeticCommand implements CommandExecutor {
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null) return true;
if (!sender.hasPermission("HMCCosmetic.cmd.dump") && !sender.isOp()) {
MessagesUtil.sendMessage(sender, "no-permission");
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
player.sendMessage("Passengers -> " + player.getPassengers());
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
player.sendMessage("Backpack Location -> " + user.getBackpackEntity().getLocation());
player.sendMessage("Backpack Location -> " + user.getUserBackpackManager().getArmorStand().getLocation());
}
player.sendMessage("Cosmetics -> " + user.getCosmetic());
player.sendMessage("Cosmetics -> " + user.getCosmetics());
player.sendMessage("EntityId -> " + player.getEntityId());
return true;
}
@@ -316,17 +381,17 @@ public class CosmeticCommand implements CommandExecutor {
}
if (!sender.hasPermission("hmccosmetics.cmd.hide")) {
MessagesUtil.sendMessage(sender, "no-permission");
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
if (player == null) {
MessagesUtil.sendMessage(sender, "invalid-player");
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
return true;
}
CosmeticUser user = CosmeticUsers.getUser(player);
MessagesUtil.sendMessage(sender, "hide-cosmetic");
if (!silent) MessagesUtil.sendMessage(sender, "hide-cosmetic");
user.hideCosmetics(CosmeticUser.HiddenReason.COMMAND);
return true;
}
@@ -337,36 +402,87 @@ public class CosmeticCommand implements CommandExecutor {
}
if (!sender.hasPermission("hmccosmetics.cmd.show")) {
MessagesUtil.sendMessage(sender, "no-permission");
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
if (player == null) {
MessagesUtil.sendMessage(sender, "invalid-player");
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
return true;
}
CosmeticUser user = CosmeticUsers.getUser(player);
MessagesUtil.sendMessage(sender, "show-cosmetic");
if (!silent) MessagesUtil.sendMessage(sender, "show-cosmetic");
user.showCosmetics();
return true;
}
case ("debug") -> {
if (!sender.hasPermission("hmccosmetics.cmd.debug")) {
MessagesUtil.sendMessage(sender, "no-permission");
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
if (Settings.getDebugMode()) {
Settings.setDebugMode(false);
MessagesUtil.sendMessage(sender, "debug-disabled");
if (!silent) MessagesUtil.sendMessage(sender, "debug-disabled");
} else {
Settings.setDebugMode(true);
MessagesUtil.sendMessage(sender, "debug-enabled");
if (!silent) MessagesUtil.sendMessage(sender, "debug-enabled");
}
}
case ("emote") -> {
if (!sender.hasPermission("hmccosmetics.cmd.emote")) {
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
if (sender.hasPermission("hmccosmetics.cmd.emote.other")) {
if (args.length >= 2) player = Bukkit.getPlayer(args[1]);
}
if (player == null) {
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
return true;
}
CosmeticUser user = CosmeticUsers.getUser(player);
if (!user.hasCosmeticInSlot(CosmeticSlot.EMOTE)) {
if (!silent) MessagesUtil.sendMessage(sender, "emote-none");
return true;
}
CosmeticEmoteType cosmeticEmoteType = (CosmeticEmoteType) user.getCosmetic(CosmeticSlot.EMOTE);
cosmeticEmoteType.run(user);
return true;
}
case ("playemote") -> {
// /cosmetic playEmote <emoteId> [playerName]
if (!sender.hasPermission("hmccosmetics.cmd.playemote")) {
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
if (args.length < 2) {
if (!silent) MessagesUtil.sendMessage(player, "not-enough-args");
return true;
}
if (!EmoteManager.has(args[1])) {
MessagesUtil.sendDebugMessages("Did not contain " + args[1]);
if (!silent) MessagesUtil.sendMessage(sender, "emote-invalid");
return true;
}
if (sender.hasPermission("hmccosmetics.cmd.playemote.other")) {
if (args.length >= 3) player = Bukkit.getPlayer(args[2]);
}
if (player == null) {
if (!silent) MessagesUtil.sendMessage(sender, "invalid-player");
return true;
}
CosmeticUser user = CosmeticUsers.getUser(player);
user.getUserEmoteManager().playEmote(args[1]);
return true;
}
}
return true;
}

View File

@@ -1,8 +1,11 @@
package com.hibiscusmc.hmccosmetics.command;
import com.hibiscusmc.hmccosmetics.config.Wardrobe;
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
import com.hibiscusmc.hmccosmetics.gui.Menu;
import com.hibiscusmc.hmccosmetics.gui.Menus;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
@@ -23,9 +26,9 @@ import java.util.List;
public class CosmeticCommandTabComplete implements TabCompleter {
@Nullable
@Override
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String @NotNull [] args) {
List<String> completions = new ArrayList<>();
List<String> finalCompletitons = new ArrayList<>();
List<String> finalCompletions = new ArrayList<>();
if (args.length == 1) {
if (hasPermission(sender, "hmccosmetics.cmd.apply")) completions.add("apply");
@@ -35,12 +38,14 @@ public class CosmeticCommandTabComplete implements TabCompleter {
if (hasPermission(sender, "hmccosmetics.cmd.wardrobe")) completions.add("wardrobe");
if (hasPermission(sender, "hmccosmetics.cmd.dataclear")) completions.add("dataclear");
if (hasPermission(sender, "hmccosmetics.cmd.dye")) completions.add("dye");
if (hasPermission(sender, "hmccosmetics.cmd.setlocation")) completions.add("setlocation");
if (hasPermission(sender, "hmccosmetics.cmd.setwardrobesetting")) completions.add("setwardrobesetting");
if (hasPermission(sender, "hmccosmetics.cmd.hide")) completions.add("hide");
if (hasPermission(sender, "hmccosmetics.cmd.show")) completions.add("show");
if (hasPermission(sender, "hmccosmetics.cmd.debug")) completions.add("debug");
if (hasPermission(sender, "hmccosmetics.cmd.emote")) completions.add("emote");
if (hasPermission(sender, "hmccosmetics.cmd.playemote")) completions.add("playemote");
StringUtil.copyPartialMatches(args[0], completions, finalCompletitons);
StringUtil.copyPartialMatches(args[0], completions, finalCompletions);
}
if (!(sender instanceof Player)) return completions;
@@ -53,32 +58,43 @@ public class CosmeticCommandTabComplete implements TabCompleter {
completions.addAll(applyCommandComplete(user, args));
}
case "unapply" -> {
for (Cosmetic cosmetic : user.getCosmetic()) {
for (Cosmetic cosmetic : user.getCosmetics()) {
completions.add(cosmetic.getSlot().toString().toUpperCase());
}
completions.add("ALL");
}
case "menu" -> {
for (Menu menu : Menus.getMenu()) {
if (menu.canOpen(user.getPlayer())) completions.add(menu.getId());
}
}
case "dataclear", "wardrobe", "hide", "show" -> {
case "dataclear", "hide", "show", "emote" -> {
for (Player player : Bukkit.getOnlinePlayers()) {
completions.add(player.getName());
}
}
case "wardrobe" -> {
for (Wardrobe wardrobe : WardrobeSettings.getWardrobes()) {
if (wardrobe.hasPermission()) {
if (user.getPlayer().hasPermission(wardrobe.getPermission())) completions.add(wardrobe.getId());
} else {
completions.add(wardrobe.getId());
}
}
}
case "dye" -> {
for (CosmeticSlot slot : user.getDyeableSlots()) {
completions.add(slot.name());
}
}
case "setlocation" -> {
completions.add("wardrobelocation");
completions.add("viewerlocation");
completions.add("leavelocation");
case "setwardrobesetting" -> {
for (Wardrobe wardrobe : WardrobeSettings.getWardrobes()) {
completions.add(wardrobe.getId());
}
}
case "playemote" -> completions.addAll(EmoteManager.getAllNames());
}
StringUtil.copyPartialMatches(args[1], completions, finalCompletitons);
StringUtil.copyPartialMatches(args[1], completions, finalCompletions);
}
if (args.length == 3) {
String subcommand = args[0].toLowerCase();
@@ -86,21 +102,38 @@ public class CosmeticCommandTabComplete implements TabCompleter {
case "dye" -> {
completions.add("#FFFFFF");
}
case "menu", "apply", "unapply" -> {
case "menu", "wardrobe", "apply", "unapply", "playemote" -> {
for (Player player : Bukkit.getOnlinePlayers()) {
completions.add(player.getName());
}
}
case "setwardrobesetting" -> {
completions.add("npclocation");
completions.add("viewerlocation");
completions.add("leavelocation");
completions.add("permission");
completions.add("distance");
}
}
StringUtil.copyPartialMatches(args[2], completions, finalCompletitons);
StringUtil.copyPartialMatches(args[2], completions, finalCompletions);
}
Collections.sort(finalCompletitons);
return finalCompletitons;
if (args.length == 4) {
String subcommand = args[0].toLowerCase();
switch (subcommand) {
case "apply" -> {
completions.add("#FFFFFF");
}
}
StringUtil.copyPartialMatches(args[3], completions, finalCompletions);
}
Collections.sort(finalCompletions);
return finalCompletions;
}
private static List<String> applyCommandComplete(CosmeticUser user, String[] args) {
@NotNull
private static List<String> applyCommandComplete(CosmeticUser user, String @NotNull [] args) {
List<String> completitions = new ArrayList<>();
if (args.length == 2) {
@@ -119,7 +152,7 @@ public class CosmeticCommandTabComplete implements TabCompleter {
return completitions;
}
private boolean hasPermission(CommandSender sender, String permission) {
private boolean hasPermission(@NotNull CommandSender sender, String permission) {
if (sender.isOp()) return true;
if (sender.hasPermission(permission)) return true;
return false;

View File

@@ -2,10 +2,13 @@ package com.hibiscusmc.hmccosmetics.config;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.util.Vector;
import org.spongepowered.configurate.ConfigurationNode;
import java.util.logging.Level;
public class Settings {
// General Settings
@@ -25,12 +28,34 @@ public class Settings {
private static final String PARTICLE_COUNT = "particle-count";
private static final String DYE_MENU_PATH = "dye-menu";
private static final String DYE_MENU_NAME = "title";
private static final String DYE_MENU_INPUT_SLOT = "input-slot";
private static final String DYE_MENU_OUTPUT_SLOT = "output-slot";
private static final String DEBUG_ENABLE_PETH = "debug-mode";
private static final String TICK_PERIOD_PATH = "tick-period";
private static final String UNAPPLY_DEATH_PATH = "unapply-on-death";
private static final String FORCE_PERMISSION_JOIN_PATH = "force-permission-join";
private static final String FORCE_SHOW_COSMETICS_PATH = "force-show-join";
private static final String EMOTE_DISTANCE_PATH = "emote-distance";
private static final String HOOK_SETTING_PATH = "hook-settings";
private static final String HOOK_ITEMADDER_PATH = "itemsadder";
private static final String HOOK_RELOAD_CHANGE_PATH = "reload-on-change";
private static final String HOOK_WORLDGUARD_PATH = "worldguard";
private static final String HOOK_WG_MOVE_CHECK_PATH = "player-move-check";
private static final String HOOK_WG_MOVE_CHECK_PATH_LEGACY = "player_move_check";
private static final String COSMETIC_EMOTE_CHECK_PATH = "emote-block-check";
private static final String COSMETIC_EMOTE_AIR_CHECK_PATH = "emote-air-check";
private static final String COSMETIC_EMOTE_DAMAGE_PATH = "emote-damage-leave";
private static final String COSMETIC_EMOTE_INVINCIBLE_PATH = "emote-invincible";
private static final String COSMETIC_ADD_ENCHANTS_HELMET_PATH = "helmet-add-enchantments";
private static final String COSMETIC_ADD_ENCHANTS_CHESTPLATE_PATH = "chest-add-enchantments";
private static final String COSMETIC_ADD_ENCHANTS_LEGGINGS_PATH = "leggings-add-enchantments";
private static final String COSMETIC_ADD_ENCHANTS_BOOTS_PATH = "boots-add-enchantments";
private static final String COSMETIC_DESTROY_LOOSE_COSMETIC_PATH = "destroy-loose-cosmetics";
private static String defaultMenu;
private static String dyeMenuName;
private static int dyeMenuInputSlot;
private static int dyeMenuOutputSlot;
private static int configVersion;
private static boolean requireEmptyHelmet;
private static boolean requireEmptyOffHand;
@@ -39,9 +64,23 @@ public class Settings {
private static boolean requireEmptyBoots;
private static boolean debugMode;
private static boolean unapplyOnDeath;
private static boolean forcePermissionJoin;
private static boolean forceShowOnJoin;
private static boolean itemsAdderChangeReload;
private static boolean worldGuardMoveCheck;
private static boolean cosmeticEmoteBlockCheck;
private static boolean addHelmetEnchants;
private static boolean addChestplateEnchants;
private static boolean addLeggingEnchants;
private static boolean addBootsEnchants;
private static boolean emoteAirCheck;
private static boolean emoteDamageLeave;
private static boolean emoteInvincible;
private static boolean destroyLooseCosmetics;
private static int lookDownPitch;
private static int viewDistance;
private static int tickPeriod;
private static double emoteDistance;
private static Vector balloonOffset;
public static void load(ConfigurationNode source) {
@@ -67,6 +106,18 @@ public class Settings {
requireEmptyPants = cosmeticSettings.node(REQUIRE_EMPTY_PANTS_PATH).getBoolean();
requireEmptyBoots = cosmeticSettings.node(REQUIRE_EMPTY_BOOTS_PATH).getBoolean();
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
forceShowOnJoin = cosmeticSettings.node(FORCE_SHOW_COSMETICS_PATH).getBoolean(false);
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3);
cosmeticEmoteBlockCheck = cosmeticSettings.node(COSMETIC_EMOTE_CHECK_PATH).getBoolean(true);
emoteAirCheck = cosmeticSettings.node(COSMETIC_EMOTE_AIR_CHECK_PATH).getBoolean(true);
emoteDamageLeave = cosmeticSettings.node(COSMETIC_EMOTE_DAMAGE_PATH).getBoolean(false);
emoteInvincible = cosmeticSettings.node(COSMETIC_EMOTE_INVINCIBLE_PATH).getBoolean(false);
destroyLooseCosmetics = cosmeticSettings.node(COSMETIC_DESTROY_LOOSE_COSMETIC_PATH).getBoolean(false);
addHelmetEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_HELMET_PATH).getBoolean(false);
addChestplateEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_CHESTPLATE_PATH).getBoolean(false);
addLeggingEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_LEGGINGS_PATH).getBoolean(false);
addBootsEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_BOOTS_PATH).getBoolean(false);
tickPeriod = cosmeticSettings.node(TICK_PERIOD_PATH).getInt(-1);
lookDownPitch = cosmeticSettings.node(LOOK_DOWN_PITCH_PATH).getInt();
@@ -79,6 +130,20 @@ public class Settings {
ConfigurationNode dyeMenuSettings = source.node(DYE_MENU_PATH);
dyeMenuName = dyeMenuSettings.node(DYE_MENU_NAME).getString("Dye Menu");
dyeMenuInputSlot = dyeMenuSettings.node(DYE_MENU_INPUT_SLOT).getInt(19);
dyeMenuOutputSlot = dyeMenuSettings.node(DYE_MENU_OUTPUT_SLOT).getInt(25);
ConfigurationNode hookSettings = source.node(HOOK_SETTING_PATH);
ConfigurationNode itemsAdderSettings = hookSettings.node(HOOK_ITEMADDER_PATH);
itemsAdderChangeReload = itemsAdderSettings.node(HOOK_RELOAD_CHANGE_PATH).getBoolean(false);
ConfigurationNode worldGuardSettings = hookSettings.node(HOOK_WORLDGUARD_PATH);
worldGuardMoveCheck = worldGuardSettings.node(HOOK_WG_MOVE_CHECK_PATH).getBoolean(true);
// I messed up in release 2.2.6 and forgot to change player_move_check to player-move-check.
if (!worldGuardSettings.node(HOOK_WG_MOVE_CHECK_PATH_LEGACY).virtual()) {
MessagesUtil.sendDebugMessages("There is a deprecated way of using WG hook setting. Change player_move_check to player-move-check in your configuration to prevent issues in the future. ", Level.WARNING);
worldGuardMoveCheck = worldGuardSettings.node(HOOK_WG_MOVE_CHECK_PATH_LEGACY).getBoolean(true);
}
}
private static Vector loadVector(final ConfigurationNode config) {
@@ -172,10 +237,15 @@ public class Settings {
public static String getDyeMenuName() {
return dyeMenuName;
}
public static int getDyeMenuInputSlot() { return dyeMenuInputSlot; }
public static int getDyeMenuOutputSlot() { return dyeMenuOutputSlot; }
public static boolean isDebugEnabled() {
return debugMode;
}
public static boolean getItemsAdderReloadChange() {
return itemsAdderChangeReload;
}
public static int getTickPeriod() {
return tickPeriod;
@@ -183,10 +253,66 @@ public class Settings {
public static boolean getUnapplyOnDeath() {
return unapplyOnDeath;
}
public static boolean getForcePermissionJoin() {
return forcePermissionJoin;
}
public static boolean isForceShowOnJoin() {
return forceShowOnJoin;
}
public static boolean getDebugMode() {
return debugMode;
}
public static double getEmoteDistance() {
return emoteDistance;
}
public static boolean getCosmeticEmoteBlockCheck() {
return cosmeticEmoteBlockCheck;
}
public static boolean getEmoteAirCheck() {
return emoteAirCheck;
}
public static boolean isEmoteDamageLeave() {
return emoteDamageLeave;
}
public static boolean isEmoteInvincible() {
return emoteInvincible;
}
public static boolean isWorldGuardMoveCheckEnabled() {
return worldGuardMoveCheck;
}
public static boolean isDestroyLooseCosmetics() {
return destroyLooseCosmetics;
}
public static boolean getShouldAddEnchants(EquipmentSlot slot) {
switch (slot) {
case HEAD -> {
return addHelmetEnchants;
}
case CHEST -> {
return addChestplateEnchants;
}
case LEGS -> {
return addLeggingEnchants;
}
case FEET -> {
return addBootsEnchants;
}
default -> {
return false;
}
}
}
public static void setDebugMode(boolean newSetting) {
debugMode = newSetting;

View File

@@ -0,0 +1,61 @@
package com.hibiscusmc.hmccosmetics.config;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.Location;
import javax.annotation.Nullable;
public class Wardrobe {
private String id;
private int distance = WardrobeSettings.getDefaultDistance();
private String permission;
private WardrobeLocation location;
public Wardrobe(String id, WardrobeLocation location, @Nullable String permission, int distance) {
this.id = id;
this.location = location;
if (permission != null) this.permission = permission;
if (distance != -1) this.distance = distance;
}
public String getId() {
return id;
}
public WardrobeLocation getLocation() {
return location;
}
public void setDistance(int distance) {
this.distance = distance;
}
public void setPermission(String permission) {
this.permission = permission;
}
public boolean hasPermission() {
return permission != null;
}
public int getDistance() {
return distance;
}
public String getPermission() {
return permission;
}
public void setLocation(WardrobeLocation location) {
this.location = location;
}
public boolean canEnter(CosmeticUser user) {
Location wardrobeLocation = location.getNpcLocation();
Location location = user.getEntity().getLocation();
if (wardrobeLocation == null) return false;
if (distance == -1) return true;
if (!wardrobeLocation.getWorld().equals(location.getWorld())) return false;
return wardrobeLocation.distanceSquared(location) <= distance * distance;
}
}

View File

@@ -0,0 +1,45 @@
package com.hibiscusmc.hmccosmetics.config;
import org.bukkit.Location;
public class WardrobeLocation {
private Location npcLocation;
private Location viewerLocation;
private Location leaveLocation;
public WardrobeLocation(Location npcLocation, Location viewerLocation, Location leaveLocation) {
this.npcLocation = npcLocation;
this.viewerLocation = viewerLocation;
this.leaveLocation = leaveLocation;
}
public Location getNpcLocation() {
return npcLocation.clone();
}
public Location getViewerLocation() {
return viewerLocation.clone();
}
public Location getLeaveLocation() {
return leaveLocation.clone();
}
public boolean hasAllLocations() {
if (npcLocation == null || viewerLocation == null || leaveLocation == null) return false;
return true;
}
public void setNPCLocation(Location wardrobeLocation) {
this.npcLocation = wardrobeLocation;
}
public void setViewerLocation(Location viewerLocation) {
this.viewerLocation = viewerLocation;
}
public void setLeaveLocation(Location leaveLocation) {
this.leaveLocation = leaveLocation;
}
}

View File

@@ -6,9 +6,14 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
import net.kyori.adventure.bossbar.BossBar;
import org.apache.commons.lang3.EnumUtils;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Set;
import java.util.logging.Level;
public class WardrobeSettings {
@@ -24,11 +29,22 @@ public class WardrobeSettings {
private static final String APPLY_COSMETICS_ON_CLOSE = "apply-cosmetics-on-close";
private static final String OPEN_SOUND = "open-sound";
private static final String CLOSE_SOUND = "close-sound";
private static final String STATIC_LOCATION_PATH = "wardrobe-location";
private static final String NPC_LOCATION_PATH = "npc-location";
private static final String VIEWER_LOCATION_PATH = "viewer-location";
private static final String LEAVE_LOCATION_PATH = "leave-location";
private static final String EQUIP_PUMPKIN_WARDROBE = "equip-pumpkin";
private static final String TRY_COSMETICS_WARDROBE = "unchecked-wardrobe-cosmetics";
private static final String RETURN_LAST_LOCATION = "return-last-location";
private static final String WARDROBE_MENU_OPTIONS = "menu-options";
private static final String WARDROBE_ENTER_OPEN_MENU_PATH = "enter-open-menu";
private static final String GAMEMODE_OPTIONS_PATH = "gamemode-options";
private static final String FORCE_EXIT_GAMEMODE_PATH = "exit-gamemode-enabled";
private static final String EXIT_GAMEMODE_PATH = "exit-gamemode";
private static final String WARDROBES_PATH = "wardrobes";
private static final String PERMISSION_PATH = "permission";
private static final String DISTANCE_PATH = "distance";
private static final String BOSSBAR_PATH = "bossbar";
private static final String BOSSBAR_ENABLE_PATH = "enabled";
private static final String BOSSBAR_TEXT_PATH = "text";
@@ -54,12 +70,14 @@ public class WardrobeSettings {
private static int despawnDelay;
private static float bossbarProgress;
private static boolean applyCosmeticsOnClose;
private static boolean tryCosmeticsInWardrobe;
private static boolean equipPumpkin;
private static boolean returnLastLocation;
private static boolean enabledBossbar;
private static Location wardrobeLocation;
private static Location viewerLocation;
private static Location leaveLocation;
private static boolean enterOpenMenu;
private static boolean forceExitGamemode;
private static GameMode exitGamemode;
private static HashMap<String, Wardrobe> wardrobes;
private static String bossbarMessage;
private static BossBar.Overlay bossbarOverlay;
private static BossBar.Color bossbarColor;
@@ -84,6 +102,14 @@ public class WardrobeSettings {
applyCosmeticsOnClose = source.node(APPLY_COSMETICS_ON_CLOSE).getBoolean();
equipPumpkin = source.node(EQUIP_PUMPKIN_WARDROBE).getBoolean();
returnLastLocation = source.node(RETURN_LAST_LOCATION).getBoolean(false);
tryCosmeticsInWardrobe = source.node(TRY_COSMETICS_WARDROBE).getBoolean(false);
ConfigurationNode menuOptionsNode = source.node(WARDROBE_MENU_OPTIONS);
enterOpenMenu = menuOptionsNode.node(WARDROBE_ENTER_OPEN_MENU_PATH).getBoolean(false);
ConfigurationNode gamemodeNode = source.node(GAMEMODE_OPTIONS_PATH);
forceExitGamemode = gamemodeNode.node(FORCE_EXIT_GAMEMODE_PATH).getBoolean(false);
exitGamemode = GameMode.valueOf(gamemodeNode.node(EXIT_GAMEMODE_PATH).getString("SURVIVAL"));
ConfigurationNode bossBarNode = source.node(BOSSBAR_PATH);
enabledBossbar = bossBarNode.node(BOSSBAR_ENABLE_PATH).getBoolean(false);
@@ -109,15 +135,35 @@ public class WardrobeSettings {
transitionStay = transitionNode.node(TRANSITION_STAY_PATH).getInt(2000);
transitionFadeOut = transitionNode.node(TRANSITION_FADE_OUT_PATH).getInt(2000);
try {
wardrobeLocation = LocationSerializer.INSTANCE.deserialize(Location.class, source.node(STATIC_LOCATION_PATH));
MessagesUtil.sendDebugMessages("Wardrobe Location: " + wardrobeLocation);
viewerLocation = LocationSerializer.INSTANCE.deserialize(Location.class, source.node(VIEWER_LOCATION_PATH));
MessagesUtil.sendDebugMessages("Viewer Location: " + viewerLocation);
leaveLocation = Utils.replaceIfNull(LocationSerializer.INSTANCE.deserialize(Location.class, source.node(LEAVE_LOCATION_PATH)), viewerLocation);
} catch (SerializationException e) {
throw new RuntimeException(e);
wardrobes = new HashMap<>();
for (ConfigurationNode wardrobesNode : source.node(WARDROBES_PATH).childrenMap().values()) {
String id = wardrobesNode.key().toString();
try {
Location npcLocation = LocationSerializer.INSTANCE.deserialize(Location.class, wardrobesNode.node(NPC_LOCATION_PATH));
MessagesUtil.sendDebugMessages("Wardrobe Location: " + npcLocation);
Location viewerLocation = LocationSerializer.INSTANCE.deserialize(Location.class, wardrobesNode.node(VIEWER_LOCATION_PATH));
MessagesUtil.sendDebugMessages("Viewer Location: " + viewerLocation);
Location leaveLocation = Utils.replaceIfNull(LocationSerializer.INSTANCE.deserialize(Location.class, wardrobesNode.node(LEAVE_LOCATION_PATH)), viewerLocation);
MessagesUtil.sendDebugMessages("Leave Location: " + leaveLocation);
WardrobeLocation wardrobeLocation = new WardrobeLocation(npcLocation, viewerLocation, leaveLocation);
String permission = null;
int distance = -1;
if (!wardrobesNode.node(PERMISSION_PATH).virtual()) permission = wardrobesNode.node(PERMISSION_PATH).getString();
if (!wardrobesNode.node(DISTANCE_PATH).virtual()) distance = wardrobesNode.node(DISTANCE_PATH).getInt();
Wardrobe wardrobe = new Wardrobe(id, wardrobeLocation, permission, distance);
addWardrobe(wardrobe);
} catch (Exception e) {
MessagesUtil.sendDebugMessages("Unable to create wardrobe " + id, Level.SEVERE);
}
}
//throw new RuntimeException(e);
}
public static int getDefaultDistance() {
return staticRadius;
}
public static boolean getDisableOnDamage() {
@@ -162,27 +208,38 @@ public class WardrobeSettings {
return returnLastLocation;
}
public static Location getWardrobeLocation() {
return wardrobeLocation.clone();
public static Wardrobe getWardrobe(String key) {
return wardrobes.get(key);
}
public static Location getViewerLocation() {
return viewerLocation;
public static Set<String> getWardrobeNames() {
return wardrobes.keySet();
}
public static Location getLeaveLocation() {
return leaveLocation;
public static Collection<Wardrobe> getWardrobes() {
return wardrobes.values();
}
public static void addWardrobe(Wardrobe wardrobe) {
wardrobes.put(wardrobe.getId(), wardrobe);
}
public static void removeWardrobe(String id) {
wardrobes.remove(id);
}
@Deprecated
public static boolean inDistanceOfWardrobe(final Location wardrobeLocation, final Location playerLocation) {
if (displayRadius == -1) return true;
if (!wardrobeLocation.getWorld().equals(playerLocation.getWorld())) return false;
return playerLocation.distanceSquared(wardrobeLocation) <= displayRadius * displayRadius;
}
public static boolean inDistanceOfStatic(final Location location) {
@Deprecated
public static boolean inDistanceOfStatic(Wardrobe wardrobe, final Location location) {
Location wardrobeLocation = wardrobe.getLocation().getNpcLocation();
if (wardrobeLocation == null) return false;
if (staticRadius == -1) return false;
if (staticRadius == -1) return true;
if (!wardrobeLocation.getWorld().equals(location.getWorld())) return false;
return wardrobeLocation.distanceSquared(location) <= staticRadius * staticRadius;
}
@@ -227,57 +284,96 @@ public class WardrobeSettings {
return transitionFadeOut;
}
public static void setWardrobeLocation(Location newLocation) {
wardrobeLocation = newLocation;
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
plugin.getConfig().set("wardrobe.wardrobe-location." + "world", newLocation.getWorld().getName());
plugin.getConfig().set("wardrobe.wardrobe-location." + "x", newLocation.getX());
plugin.getConfig().set("wardrobe.wardrobe-location." + "y", newLocation.getY());
plugin.getConfig().set("wardrobe.wardrobe-location." + "z", newLocation.getZ());
plugin.getConfig().set("wardrobe.wardrobe-location." + "yaw", newLocation.getYaw());
plugin.getConfig().set("wardrobe.wardrobe-location." + "pitch", newLocation.getPitch());
/* Configuration sets suck
source.node(WORLD).set(loc.getWorld().getName());
source.node(X).set(loc.getX());
source.node(Y).set(loc.getY());
source.node(Z).set(loc.getZ());
source.node(YAW).set(loc.getYaw());
source.node(PITCH).set(loc.getPitch());
*/
HMCCosmeticsPlugin.getInstance().saveConfig();
public static boolean isEnterOpenMenu() {
return enterOpenMenu;
}
public static void setViewerLocation(Location newLocation) {
viewerLocation = newLocation;
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
plugin.getConfig().set("wardrobe.viewer-location." + "world", newLocation.getWorld().getName());
plugin.getConfig().set("wardrobe.viewer-location." + "x", newLocation.getX());
plugin.getConfig().set("wardrobe.viewer-location." + "y", newLocation.getY());
plugin.getConfig().set("wardrobe.viewer-location." + "z", newLocation.getZ());
plugin.getConfig().set("wardrobe.viewer-location." + "yaw", newLocation.getYaw());
plugin.getConfig().set("wardrobe.viewer-location." + "pitch", newLocation.getPitch());
HMCCosmeticsPlugin.getInstance().saveConfig();
public static boolean isForceExitGamemode() {
return forceExitGamemode;
}
public static void setLeaveLocation(Location newLocation) {
leaveLocation = newLocation;
public static GameMode getExitGamemode() {
return exitGamemode;
}
public static boolean isTryCosmeticsInWardrobe() {
return tryCosmeticsInWardrobe;
}
/**
* Sets where the NPC/Mannequin will spawn in the wardrobe
* @param newLocation
*/
public static void setNPCLocation(Wardrobe wardrobe, Location newLocation) {
wardrobe.getLocation().setNPCLocation(newLocation);
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
plugin.getConfig().set("wardrobe.leave-location." + "world", newLocation.getWorld().getName());
plugin.getConfig().set("wardrobe.leave-location." + "x", newLocation.getX());
plugin.getConfig().set("wardrobe.leave-location." + "y", newLocation.getY());
plugin.getConfig().set("wardrobe.leave-location." + "z", newLocation.getZ());
plugin.getConfig().set("wardrobe.leave-location." + "yaw", newLocation.getYaw());
plugin.getConfig().set("wardrobe.leave-location." + "pitch", newLocation.getPitch());
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "world", newLocation.getWorld().getName());
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "x", newLocation.getX());
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "y", newLocation.getY());
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "z", newLocation.getZ());
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "yaw", newLocation.getYaw());
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".npc-location." + "pitch", newLocation.getPitch());
HMCCosmeticsPlugin.getInstance().saveConfig();
plugin.saveConfig();
}
/**
* Sets where the player will view the wardrobe
* @param newLocation
*/
public static void setViewerLocation(Wardrobe wardrobe, Location newLocation) {
wardrobe.getLocation().setViewerLocation(newLocation);
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".viewer-location.world", newLocation.getWorld().getName());
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".viewer-location.x", newLocation.getX());
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".viewer-location.y", newLocation.getY());
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".viewer-location.z", newLocation.getZ());
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".viewer-location.yaw", newLocation.getYaw());
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".viewer-location.pitch", newLocation.getPitch());
plugin.saveConfig();
}
/**
* Sets where a player will leave the wardrobe from
* @param newLocation
*/
public static void setLeaveLocation(Wardrobe wardrobe, Location newLocation) {
wardrobe.getLocation().setLeaveLocation(newLocation);
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".leave-location.world", newLocation.getWorld().getName());
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".leave-location.x", newLocation.getX());
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".leave-location.y", newLocation.getY());
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".leave-location.z", newLocation.getZ());
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".leave-location.yaw", newLocation.getYaw());
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".leave-location.pitch", newLocation.getPitch());
plugin.saveConfig();
}
public static void setWardrobePermission(Wardrobe wardrobe, String permission) {
wardrobe.setPermission(permission);
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".permission", permission);
plugin.saveConfig();
}
public static void setWardrobeDistance(Wardrobe wardrobe, int distance) {
wardrobe.setDistance(distance);
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
plugin.getConfig().set("wardrobe.wardrobes." + wardrobe.getId() + ".distance", distance);
plugin.saveConfig();
}
}

View File

@@ -1,15 +1,15 @@
package com.hibiscusmc.hmccosmetics.config.serializer;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.hooks.items.ItemHooks;
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
import com.hibiscusmc.hmccosmetics.util.builder.ColorBuilder;
import com.hibiscusmc.hmccosmetics.util.misc.StringUtils;
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.apache.commons.lang3.EnumUtils;
import org.bukkit.*;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
@@ -72,7 +72,7 @@ public class ItemSerializer implements TypeSerializer<ItemStack> {
String material = materialNode.getString();
ItemStack item = ItemHooks.getItem(material);
ItemStack item = Hooks.getItem(material);
if (item == null) {
HMCCosmeticsPlugin.getInstance().getLogger().severe("Invalid Material -> " + material);
return new ItemStack(Material.AIR);
@@ -81,15 +81,16 @@ public class ItemSerializer implements TypeSerializer<ItemStack> {
ItemMeta itemMeta = item.getItemMeta();
if (itemMeta == null) return item;
if (!nameNode.virtual()) itemMeta.setDisplayName(StringUtils.parseStringToString(Utils.replaceIfNull(nameNode.getString(), "")));
if (!nameNode.virtual())
itemMeta.setDisplayName(StringUtils.parseStringToString(Utils.replaceIfNull(nameNode.getString(), "")));
if (!unbreakableNode.virtual()) itemMeta.setUnbreakable(unbreakableNode.getBoolean());
if (!glowingNode.virtual()) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
itemMeta.addEnchant(Enchantment.LUCK, 1, true);
}
if (!loreNode.virtual()) itemMeta.setLore(Utils.replaceIfNull(loreNode.getList(String.class),
new ArrayList<String>()).
stream().map(StringUtils::parseStringToString).collect(Collectors.toList()));
new ArrayList<String>()).
stream().map(StringUtils::parseStringToString).collect(Collectors.toList()));
if (!modelDataNode.virtual()) itemMeta.setCustomModelData(modelDataNode.getInt());
if (!nbtNode.virtual()) {
@@ -105,22 +106,40 @@ public class ItemSerializer implements TypeSerializer<ItemStack> {
}
}
if (!itemFlagsNode.virtual()) {
for (ConfigurationNode flagNode : itemFlagsNode.childrenMap().values()) {
if (ItemFlag.valueOf(flagNode.key().toString()) == null) continue;
itemMeta.addItemFlags(ItemFlag.valueOf(flagNode.key().toString()));
try {
if (!itemFlagsNode.virtual()) {
for (String itemFlag : itemFlagsNode.getList(String.class)) {
if (!EnumUtils.isValidEnum(ItemFlag.class, itemFlag)) continue;
MessagesUtil.sendDebugMessages("Added " + itemFlag + " to the item!");
itemMeta.addItemFlags(ItemFlag.valueOf(itemFlag));
}
}
} catch (Exception e) {
e.printStackTrace();
}
if (item.getType() == Material.PLAYER_HEAD) {
SkullMeta skullMeta = (SkullMeta) itemMeta;
if (!ownerNode.virtual()) {
skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer(ownerNode.getString()));
String ownerString = ownerNode.getString();
if (ownerString.contains("%")) {
// This means it has PAPI placeholders in it
skullMeta.getPersistentDataContainer().set(InventoryUtils.getSkullOwner(), PersistentDataType.STRING, ownerString);
}
OfflinePlayer player = Bukkit.getOfflinePlayer(ownerString);
skullMeta.setOwningPlayer(player);
}
if (!textureNode.virtual()) {
String textureString = textureNode.getString();
if (textureString.contains("%")) {
// This means it has PAPI placeholders in it
skullMeta.getPersistentDataContainer().set(InventoryUtils.getSkullTexture(), PersistentDataType.STRING, textureString);
}
Bukkit.getUnsafe().modifyItemStack(item, "{SkullOwner:{Id:[I;0,0,0,0],Properties:{textures:[{Value:\""
+ textureNode.getString() + "\"}]}}}");
+ textureString + "\"}]}}}");
itemMeta = skullMeta;
}
}
@@ -135,13 +154,9 @@ public class ItemSerializer implements TypeSerializer<ItemStack> {
}
}
NamespacedKey key = new NamespacedKey(HMCCosmeticsPlugin.getInstance(), source.key().toString());
itemMeta.getPersistentDataContainer().set(key, PersistentDataType.STRING, source.key().toString());
item.setItemMeta(itemMeta);
return item;
}
@Override
public void serialize(final Type type, @Nullable final ItemStack obj, final ConfigurationNode node) throws SerializationException {

View File

@@ -5,45 +5,51 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
import java.util.logging.Level;
public class Cosmetic {
public abstract class Cosmetic {
private String id;
private String permission;
private ItemStack item;
private String material;
private CosmeticSlot slot;
private boolean dyable;
protected Cosmetic(String id, ConfigurationNode config) {
protected Cosmetic(String id, @NotNull ConfigurationNode config) {
this.id = id;
if (!config.node("permission").virtual()) {
this.permission = config.node("permission").getString();
} else {
this.permission = null;
}
if (!config.node("item").virtual()) this.item = generateItemStack(config.node("item"));
if (!config.node("item").virtual()) {
this.material = config.node("item", "material").getString();
this.item = generateItemStack(config.node("item"));
}
MessagesUtil.sendDebugMessages("Slot: " + config.node("slot").getString());
setSlot(CosmeticSlot.valueOf(config.node("slot").getString()));
setSlot(CosmeticSlot.valueOf(config.node("slot").getString()));
setDyable(config.node("dyeable").getBoolean(false));
MessagesUtil.sendDebugMessages("Dyeable " + dyable);
Cosmetics.addCosmetic(this);
}
public String getId() {
return this.id;
}
public String getPermission() {
return this.permission;
public void setId(String id) {
this.id = id;
}
public CosmeticSlot getSlot() {
@@ -53,17 +59,17 @@ public class Cosmetic {
public void setSlot(CosmeticSlot slot) {
this.slot = slot;
}
public String getPermission() {
return this.permission;
}
public void setPermission(String permission) {
this.permission = permission;
}
public boolean requiresPermission() {
if (permission == null) return false;
return true;
}
public void setId(String id) {
this.id = id;
return permission != null;
}
public void setDyable(boolean dyable) {
@@ -74,11 +80,12 @@ public class Cosmetic {
return this.dyable;
}
public void update(CosmeticUser user) {
// Override
public String getMaterial() {
return material;
}
public abstract void update(CosmeticUser user);
@Nullable
public ItemStack getItem() {
if (item == null) return null;

View File

@@ -8,5 +8,6 @@ public enum CosmeticSlot {
MAINHAND,
OFFHAND,
BACKPACK,
BALLOON
BALLOON,
EMOTE
}

View File

@@ -3,24 +3,27 @@ package com.hibiscusmc.hmccosmetics.cosmetic;
import com.google.common.collect.HashBiMap;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.*;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.apache.commons.lang3.EnumUtils;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.ConfigurateException;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Set;
import java.util.logging.Level;
import java.util.stream.Stream;
public class Cosmetics {
private static HashBiMap<String, Cosmetic> COSMETICS = HashBiMap.create();
private static final HashBiMap<String, Cosmetic> COSMETICS = HashBiMap.create();
public static void addCosmetic(Cosmetic cosmetic) {
COSMETICS.put(cosmetic.getId(), cosmetic);
@@ -34,14 +37,19 @@ public class Cosmetics {
COSMETICS.remove(cosmetic);
}
@Nullable
public static Cosmetic getCosmetic(String id) {
return COSMETICS.get(id);
}
@Contract(pure = true)
@NotNull
public static Set<Cosmetic> values() {
return COSMETICS.values();
}
@Contract(pure = true)
@NotNull
public static Set<String> keys() {
return COSMETICS.keySet();
}
@@ -63,23 +71,27 @@ public class Cosmetics {
File[] directoryListing = cosmeticFolder.listFiles();
if (directoryListing == null) return;
for (File child : directoryListing) {
if (child.toString().contains(".yml") || child.toString().contains(".yaml")) {
MessagesUtil.sendDebugMessages("Scanning " + child);
// Loads file
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child.toPath()).build();
CommentedConfigurationNode root;
try {
root = loader.load();
} catch (ConfigurateException e) {
throw new RuntimeException(e);
try (Stream<Path> walkStream = Files.walk(cosmeticFolder.toPath())) {
walkStream.filter(p -> p.toFile().isFile()).forEach(child -> {
if (child.toString().contains(".yml") || child.toString().contains(".yaml")) {
MessagesUtil.sendDebugMessages("Scanning " + child);
// Loads file
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child).build();
CommentedConfigurationNode root;
try {
root = loader.load();
} catch (ConfigurateException e) {
throw new RuntimeException(e);
}
setupCosmetics(root);
}
setupCosmetics(root);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
private static void setupCosmetics(CommentedConfigurationNode config) {
private static void setupCosmetics(@NotNull CommentedConfigurationNode config) {
for (ConfigurationNode cosmeticConfig : config.childrenMap().values()) {
try {
String id = cosmeticConfig.key().toString();
@@ -97,6 +109,7 @@ public class Cosmetics {
case BALLOON -> new CosmeticBalloonType(id, cosmeticConfig);
case BACKPACK -> new CosmeticBackpackType(id, cosmeticConfig);
case MAINHAND -> new CosmeticMainhandType(id, cosmeticConfig);
case EMOTE -> new CosmeticEmoteType(id, cosmeticConfig);
default -> new CosmeticArmorType(id, cosmeticConfig);
}
} catch (Exception e) {

View File

@@ -1,17 +1,22 @@
package com.hibiscusmc.hmccosmetics.cosmetic.types;
import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.entity.Entity;
import org.bukkit.entity.HumanEntity;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.configurate.ConfigurationNode;
public class CosmeticArmorType extends Cosmetic {
private EquipmentSlot equipSlot;
private final EquipmentSlot equipSlot;
public CosmeticArmorType(String id, ConfigurationNode config) {
super(id, config);
@@ -20,18 +25,25 @@ public class CosmeticArmorType extends Cosmetic {
}
@Override
public void update(CosmeticUser user) {
Player player = Bukkit.getPlayer(user.getUniqueId());
if (player == null) return;
public void update(@NotNull CosmeticUser user) {
Entity entity = Bukkit.getEntity(user.getUniqueId());
if (entity == null) return;
if (user.getUserEmoteManager().isPlayingEmote()) return; // There has to be a better way of doing this...
ItemStack cosmeticItem = user.getUserCosmeticItem(this);
if (!(entity instanceof HumanEntity humanEntity)) return;
if (equipSlot.equals(EquipmentSlot.OFF_HAND)) {
if (!player.getInventory().getItemInOffHand().getType().isAir()) return;
if (!humanEntity.getInventory().getItemInOffHand().getType().isAir()) return;
}
PacketManager.equipmentSlotUpdate(player, getSlot(), PacketManager.getViewers(player.getLocation()));
ItemStack equippedItem = humanEntity.getInventory().getItem(equipSlot);
if (Settings.getShouldAddEnchants(equipSlot)) {
cosmeticItem.addUnsafeEnchantments(equippedItem.getEnchantments());
}
NMSHandlers.getHandler().equipmentSlotUpdate(entity.getEntityId(), equipSlot, cosmeticItem, PacketManager.getViewers(entity.getLocation()));
//PacketManager.equipmentSlotUpdate(player, getSlot(), PacketManager.getViewers(player.getLocation())); Old method
}
public EquipmentSlot getEquipSlot() {
return this.equipSlot;
}
}

View File

@@ -1,39 +1,87 @@
package com.hibiscusmc.hmccosmetics.cosmetic.types;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.AreaEffectCloud;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.configurate.ConfigurationNode;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
public class CosmeticBackpackType extends Cosmetic {
ConfigurationNode config;
private final String modelName;
private ItemStack firstPersonBackpack;
public CosmeticBackpackType(String id, ConfigurationNode config) {
super(id, config);
this.config = config;
modelName = config.node("model").getString();
if (!config.node("firstperson-item").virtual()) {
this.firstPersonBackpack = generateItemStack(config.node("firstperson-item"));
}
//backpackType = UserBackpackManager.BackpackType.valueOf(config.node("type").getString("NORMAL").toUpperCase());
}
@Override
public void update(CosmeticUser user) {
Player player = Bukkit.getPlayer(user.getUniqueId());
Location loc = player.getLocation().clone();
public void update(@NotNull CosmeticUser user) {
Entity entity = Bukkit.getEntity(user.getUniqueId());
if (entity == null) return;
if (user.isInWardrobe()) return;
Location loc = entity.getLocation().clone().add(0, 2, 0);
if (loc.getWorld() != user.getBackpackEntity().getWorld()) {
user.getBackpackEntity().teleport(loc);
if (user.isInWardrobe() || !user.isBackpackSpawned()) return;
if (!user.getUserBackpackManager().IsValidBackpackEntity()) {
MessagesUtil.sendDebugMessages("Invalid Backpack Entity[owner=" + user.getUniqueId() + ",player_location=" + loc + "]!", Level.WARNING);
user.respawnBackpack();
return;
}
if (loc.getWorld() != user.getUserBackpackManager().getArmorStand().getWorld()) {
user.getUserBackpackManager().getArmorStand().teleport(loc);
}
user.getBackpackEntity().teleport(loc);
user.getUserBackpackManager().getArmorStand().teleport(loc);
user.getUserBackpackManager().getArmorStand().setRotation(loc.getYaw(), loc.getPitch());
PacketManager.sendRidingPacket(player.getEntityId(), user.getBackpackEntity().getEntityId(), loc);
List<Player> outsideViewers = user.getUserBackpackManager().getCloudManager().refreshViewers(loc);
if (!user.isInWardrobe() && isFirstPersonCompadible()) {
List<Player> owner = List.of(user.getPlayer());
user.getBackpackEntity().setRotation(loc.getYaw(), loc.getPitch());
user.showBackpack();
ArrayList<Integer> particleCloud = user.getUserBackpackManager().getAreaEffectEntityId();
for (int i = 0; i < particleCloud.size(); i++) {
if (i == 0) {
PacketManager.sendRidingPacket(entity.getEntityId(), particleCloud.get(i), owner);
} else {
PacketManager.sendRidingPacket(particleCloud.get(i - 1), particleCloud.get(i) , owner);
}
}
PacketManager.sendRidingPacket(particleCloud.get(particleCloud.size() - 1), user.getUserBackpackManager().getFirstArmorStandId(), owner);
if (!user.getHidden()) NMSHandlers.getHandler().equipmentSlotUpdate(user.getUserBackpackManager().getFirstArmorStandId(), EquipmentSlot.HEAD, firstPersonBackpack, owner);
MessagesUtil.sendDebugMessages("First Person Backpack Update[owner=" + user.getUniqueId() + ",player_location=" + loc + "]!", Level.INFO);
}
PacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), outsideViewers);
user.getUserBackpackManager().showBackpack();
}
public String getModelName() {
return modelName;
}
public boolean isFirstPersonCompadible() {
return firstPersonBackpack != null;
}
}

View File

@@ -2,43 +2,38 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.entities.BalloonEntity;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
import org.apache.commons.lang3.EnumUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
import java.util.HashMap;
import java.util.List;
public class CosmeticBalloonType extends Cosmetic {
private String modelName;
private final String modelName;
private List<String> dyableParts;
//private HashMap<Animations, String> animationBalloons;
private boolean showLead;
public CosmeticBalloonType(String id, ConfigurationNode config) {
super(id, config);
String modelId = config.node("model").getString();
showLead = config.node("show-lead").getBoolean(true);
try {
if (!config.node("dyable-parts").virtual()) dyableParts = config.node("dyable-parts").getList(String.class);
/*
if (!config.node("animations").virtual()) {
for (ConfigurationNode animationNode : config.node("animations").childrenMap().values()) {
if (EnumUtils.isValidEnum(Animations.class, animationNode.key().toString().toUpperCase())) continue;
animationBalloons.put(Animations.valueOf(animationNode.key().toString().toUpperCase()), animationNode.getString());
}
if (!config.node("dyable-parts").virtual()) {
dyableParts = config.node("dyable-parts").getList(String.class);
}
*/
} catch (SerializationException e) {
// Seriously?
throw new RuntimeException(e);
@@ -48,30 +43,46 @@ public class CosmeticBalloonType extends Cosmetic {
}
@Override
public void update(CosmeticUser user) {
Player player = Bukkit.getPlayer(user.getUniqueId());
Location currentLocation = user.getBalloonEntity().getLocation().clone();
Location newLocation = player.getLocation().clone().add(Settings.getBalloonOffset()).clone();
if (player == null) return;
public void update(@NotNull CosmeticUser user) {
Entity entity = Bukkit.getEntity(user.getUniqueId());
UserBalloonManager userBalloonManager = user.getBalloonManager();
if (entity == null || userBalloonManager == null) return;
if (user.isInWardrobe()) return;
List<Player> viewer = PacketManager.getViewers(player.getLocation());
viewer.add(player);
if (!userBalloonManager.getModelEntity().isValid()) {
user.respawnBalloon();
return;
}
BalloonEntity balloonEntity = user.getBalloonEntity();
Location newLocation = entity.getLocation();
Location currentLocation = user.getBalloonManager().getLocation();
newLocation = newLocation.clone().add(Settings.getBalloonOffset());
if (player.getLocation().getWorld() != balloonEntity.getLocation().getWorld()) {
balloonEntity.getModelEntity().teleport(newLocation);
PacketManager.sendTeleportPacket(balloonEntity.getPufferfishBalloonId(), newLocation, false, viewer);
List<Player> viewer = PacketManager.getViewers(entity.getLocation());
if (entity.getLocation().getWorld() != userBalloonManager.getLocation().getWorld()) {
userBalloonManager.getModelEntity().teleport(newLocation);
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
return;
}
Vector velocity = newLocation.toVector().subtract(currentLocation.toVector());
balloonEntity.setVelocity(velocity.multiply(1.1));
balloonEntity.setLocation(newLocation);
userBalloonManager.setVelocity(velocity.multiply(1.1));
userBalloonManager.setLocation(newLocation);
PacketManager.sendTeleportPacket(balloonEntity.getPufferfishBalloonId(), newLocation, false, viewer);
if (!user.getHidden()) PacketManager.sendLeashPacket(balloonEntity.getPufferfishBalloonId(), player.getEntityId(), viewer);
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
PacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), entity.getEntityId(), viewer);
if (user.getHidden()) {
userBalloonManager.getPufferfish().hidePufferfish();
return;
}
if (!user.getHidden() && showLead) {
List<Player> sendTo = userBalloonManager.getPufferfish().refreshViewers(newLocation);
if (sendTo.isEmpty()) return;
PacketManager.sendEntitySpawnPacket(newLocation, userBalloonManager.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager.getPufferfishBalloonUniqueId(), sendTo);
PacketManager.sendInvisibilityPacket(userBalloonManager.getPufferfishBalloonId(), sendTo);
}
}
public String getModelName() {
@@ -89,9 +100,7 @@ public class CosmeticBalloonType extends Cosmetic {
return dyableParts.contains(name);
}
/*
public String getAnimation(Animations animation) {
return animationBalloons.get(animation);
public boolean isShowLead() {
return showLead;
}
*/
}

View File

@@ -0,0 +1,38 @@
package com.hibiscusmc.hmccosmetics.cosmetic.types;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.configurate.ConfigurationNode;
public class CosmeticEmoteType extends Cosmetic {
private final String animationId;
private final String text;
public CosmeticEmoteType(String id, ConfigurationNode config) {
super(id, config);
animationId = config.node("animation").getString();
text = config.node("text").getString();
MessagesUtil.sendDebugMessages("CosmeticEmoteType Animation id " + animationId);
}
@Override
public void update(CosmeticUser user) {
// Nothing
}
public void run(@NotNull CosmeticUser user) {
user.getUserEmoteManager().playEmote(this);
}
public String getAnimationId() {
return animationId;
}
public String getText() {
return text;
}
}

View File

@@ -5,6 +5,7 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.configurate.ConfigurationNode;
public class CosmeticMainhandType extends Cosmetic {
@@ -14,10 +15,9 @@ public class CosmeticMainhandType extends Cosmetic {
}
@Override
public void update(CosmeticUser user) {
public void update(@NotNull CosmeticUser user) {
Player player = user.getPlayer();
PacketManager.equipmentSlotUpdate(player.getEntityId(), user, getSlot(), PlayerUtils.getNearbyPlayers(player));
}
}

View File

@@ -2,7 +2,6 @@ package com.hibiscusmc.hmccosmetics.database;
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
import com.hibiscusmc.hmccosmetics.database.types.Data;
import com.hibiscusmc.hmccosmetics.database.types.InternalData;
import com.hibiscusmc.hmccosmetics.database.types.MySQLData;
import com.hibiscusmc.hmccosmetics.database.types.SQLiteData;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
@@ -16,23 +15,20 @@ public class Database {
private static Data data;
private static InternalData INTERNAL_DATA = new InternalData();
private static MySQLData MYSQL_DATA = new MySQLData();
private static SQLiteData SQLITE_DATA = new SQLiteData();
private static final MySQLData MYSQL_DATA = new MySQLData();
private static final SQLiteData SQLITE_DATA = new SQLiteData();
public Database() {
String databaseType = DatabaseSettings.getDatabaseType();
data = INTERNAL_DATA; // default
if (databaseType.equalsIgnoreCase("INTERNAL")) {
data = INTERNAL_DATA;
}
data = SQLITE_DATA; // default
if (databaseType.equalsIgnoreCase("MySQL")) {
data = MYSQL_DATA;
}
/* SQLite is the default database. Might change in the future, so keep code here in case.
if (databaseType.equalsIgnoreCase("sqlite")) {
data = SQLITE_DATA;
}
*/
MessagesUtil.sendDebugMessages("Database is " + data);
setup();

View File

@@ -1,40 +1,43 @@
package com.hibiscusmc.hmccosmetics.database.types;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.apache.commons.lang3.EnumUtils;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class Data {
public abstract class Data {
public void setup() {
// Override
}
public abstract void setup();
public void save(CosmeticUser user) {
// Override
}
public abstract void save(CosmeticUser user);
@Nullable
public CosmeticUser get(UUID uniqueId) {
// Override
return null;
}
public abstract CosmeticUser get(UUID uniqueId);
public abstract void clear(UUID uniqueId);
public void clear(UUID uniqueId) {
// Override
}
// BACKPACK=colorfulbackpack&RRGGBB,HELMET=niftyhat,BALLOON=colorfulballoon,CHESTPLATE=niftychestplate
public String steralizeData(CosmeticUser user) {
@NotNull
public final String serializeData(@NotNull CosmeticUser user) {
String data = "";
for (Cosmetic cosmetic : user.getCosmetic()) {
if (user.getHidden()) {
if (shouldHiddenSave(user.getHiddenReason())) {
data = "HIDDEN=" + user.getHiddenReason();
}
}
for (Cosmetic cosmetic : user.getCosmetics()) {
Color color = user.getCosmeticColor(cosmetic.getSlot());
String input = cosmetic.getSlot() + "=" + cosmetic.getId();
if (color != null) input = input + "&" + color.asRGB();
@@ -47,7 +50,12 @@ public class Data {
return data;
}
public Map<CosmeticSlot, Map<Cosmetic, Color>> desteralizedata(String raw) {
public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUser user, @NotNull String raw) {
return deserializeData(user, raw, Settings.getForcePermissionJoin());
}
@NotNull
public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUser user, @NotNull String raw, boolean permissionCheck) {
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = new HashMap<>();
String[] rawData = raw.split(",");
@@ -57,16 +65,34 @@ public class Data {
CosmeticSlot slot = null;
Cosmetic cosmetic = null;
MessagesUtil.sendDebugMessages("First split (suppose slot) " + splitData[0]);
if (splitData[0].equalsIgnoreCase("HIDDEN")) {
if (EnumUtils.isValidEnum(CosmeticUser.HiddenReason.class, splitData[1])) {
if (Settings.isForceShowOnJoin()) continue;
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
user.hideCosmetics(CosmeticUser.HiddenReason.valueOf(splitData[1]));
});
}
continue;
}
if (CosmeticSlot.valueOf(splitData[0]) != null) slot = CosmeticSlot.valueOf(splitData[0]);
if (splitData[1].contains("&")) {
String[] colorSplitData = splitData[1].split("&");
if (Cosmetics.hasCosmetic(colorSplitData[0])) cosmetic = Cosmetics.getCosmetic(colorSplitData[0]);
if (slot == null || cosmetic == null) continue;
if (permissionCheck && cosmetic.requiresPermission()) {
if (user.getPlayer() != null && !user.getPlayer().hasPermission(cosmetic.getPermission())) {
continue;
}
}
cosmetics.put(slot, Map.of(cosmetic, Color.fromRGB(Integer.parseInt(colorSplitData[1]))));
} else {
if (Cosmetics.hasCosmetic(splitData[1])) cosmetic = Cosmetics.getCosmetic(splitData[1]);
if (slot == null || cosmetic == null) continue;
if (permissionCheck && cosmetic.requiresPermission()) {
if (user.getPlayer() != null && !user.getPlayer().hasPermission(cosmetic.getPermission())) {
continue;
}
}
HashMap<Cosmetic, Color> cosmeticColorHashMap = new HashMap<>();
cosmeticColorHashMap.put(cosmetic, null);
cosmetics.put(slot, cosmeticColorHashMap);
@@ -74,4 +100,15 @@ public class Data {
}
return cosmetics;
}
private boolean shouldHiddenSave(CosmeticUser.@NotNull HiddenReason reason) {
switch (reason) {
case EMOTE, NONE -> {
return false;
}
default -> {
return true;
}
}
}
}

View File

@@ -1,65 +0,0 @@
package com.hibiscusmc.hmccosmetics.database.types;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.NamespacedKey;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.persistence.PersistentDataType;
import java.util.Map;
import java.util.UUID;
public class InternalData extends Data {
NamespacedKey key = new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmetics");
@Override
public void setup() {
// Nothing
}
@Override
public void save(CosmeticUser user) {
Player player = Bukkit.getPlayer(user.getUniqueId());
player.getPersistentDataContainer().set(key, PersistentDataType.STRING, steralizeData(user));
}
@Override
public CosmeticUser get(UUID uniqueId) {
Player player = Bukkit.getPlayer(uniqueId);
CosmeticUser user = new CosmeticUser(uniqueId);
if (!player.getPersistentDataContainer().has(key, PersistentDataType.STRING)) return user;
String rawData = player.getPersistentDataContainer().get(key, PersistentDataType.STRING);
Map<CosmeticSlot, Map<Cosmetic, Color>> a = desteralizedata(rawData);
for (Map<Cosmetic, Color> cosmeticColors : a.values()) {
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
// This can not be async.
user.addPlayerCosmetic(cosmetic, cosmeticColors.get(cosmetic));
});
}
}
return user;
}
@Override
public void clear(UUID uniqueId) {
OfflinePlayer player = Bukkit.getOfflinePlayer(uniqueId);
if (player.isOnline()) {
Player onlinePlayer = player.getPlayer();
if (onlinePlayer.getPersistentDataContainer().has(key, PersistentDataType.STRING)) {
onlinePlayer.getPersistentDataContainer().remove(key);
}
return;
}
}
}

View File

@@ -2,18 +2,18 @@ package com.hibiscusmc.hmccosmetics.database.types;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.sql.*;
import java.util.Map;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Properties;
import java.util.UUID;
public class MySQLData extends Data {
public class MySQLData extends SQLData {
// Connection Information
private String host;
@@ -22,6 +22,7 @@ public class MySQLData extends Data {
private String password;
private int port;
@Nullable
private Connection connection;
@Override
@@ -35,11 +36,12 @@ public class MySQLData extends Data {
HMCCosmeticsPlugin plugin = HMCCosmeticsPlugin.getInstance();
try {
openConnection();
if (connection == null) throw new NullPointerException("Connection is null");
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `COSMETICDATABASE` " +
"(UUID varchar(36) PRIMARY KEY, " +
"COSMETICS MEDIUMTEXT " +
");").execute();
} catch (SQLException e) {
} catch (SQLException | NullPointerException e) {
plugin.getLogger().severe("");
plugin.getLogger().severe("");
plugin.getLogger().severe("MySQL DATABASE CAN NOT BE REACHED.");
@@ -52,104 +54,58 @@ public class MySQLData extends Data {
throw new RuntimeException(e);
}
}
@Override
public void save(CosmeticUser user) {
Runnable run = () -> {
try {
PreparedStatement preparedSt = preparedStatement("REPLACE INTO COSMETICDATABASE(UUID,COSMETICS) VALUES(?,?);");
preparedSt.setString(1, user.getUniqueId().toString());
preparedSt.setString(2, steralizeData(user));
preparedSt.executeUpdate();
} catch (SQLException e) {
throw new RuntimeException(e);
}
};
if (!HMCCosmeticsPlugin.isDisable()) {
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), run);
} else {
run.run();
}
}
@Override
public CosmeticUser get(UUID uniqueId) {
CosmeticUser user = new CosmeticUser(uniqueId);
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
try {
PreparedStatement preparedStatement = preparedStatement("SELECT * FROM COSMETICDATABASE WHERE UUID = ?;");
preparedStatement.setString(1, uniqueId.toString());
ResultSet rs = preparedStatement.executeQuery();
if (rs.next()) {
String rawData = rs.getString("COSMETICS");
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = desteralizedata(rawData);
for (Map<Cosmetic, Color> cosmeticColors : cosmetics.values()) {
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
// This can not be async.
user.addPlayerCosmetic(cosmetic, cosmeticColors.get(cosmetic));
});
}
}
}
} catch (SQLException e) {
e.printStackTrace();
}
});
return user;
}
@Override
public void clear(UUID unqiueId) {
public void clear(UUID uniqueId) {
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
try {
PreparedStatement preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;");
preparedSt.setString(1, unqiueId.toString());
preparedSt.setString(1, uniqueId.toString());
preparedSt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
});
// TODO
}
private void openConnection() throws SQLException {
if (connection != null && !connection.isClosed()) {
return;
// Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
// ...
// });
// connection = DriverManager.getConnection("jdbc:mysql://" + DatabaseSettings.getHost() + ":" + DatabaseSettings.getPort() + "/" + DatabaseSettings.getDatabase(), setupProperties());
// Connection isn't null AND Connection isn't closed :: return
try {
if (isConnectionOpen()) {
return;
} else if (connection != null) close(); // Close connection if still active
} catch (RuntimeException e) {
e.printStackTrace(); // If isConnectionOpen() throws error
}
//Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
//close Connection if still active
if (connection != null) {
close();
}
//connect to database host
try {
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, setupProperties());
} catch (SQLException e) {
System.out.println(e.getMessage());
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
//});
//connection = DriverManager.getConnection("jdbc:mysql://" + DatabaseSettings.getHost() + ":" + DatabaseSettings.getPort() + "/" + DatabaseSettings.getDatabase(), setupProperties());
// Connect to database host
try {
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, setupProperties());
} catch (SQLException e) {
System.out.println(e.getMessage());
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
public void close() {
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
try {
if (connection == null) throw new NullPointerException("Connection is null");
connection.close();
} catch (SQLException e) {
} catch (SQLException | NullPointerException e) {
System.out.println(e.getMessage());
}
});
}
@NotNull
private Properties setupProperties() {
Properties props = new Properties();
props.put("user", user);
@@ -158,28 +114,29 @@ public class MySQLData extends Data {
return props;
}
private boolean isConnectionOpen() {
private boolean isConnectionOpen() throws RuntimeException {
try {
if (connection == null || connection.isClosed()) {
return false;
} else {
return true;
}
return connection != null && !connection.isClosed();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
@Override
public PreparedStatement preparedStatement(String query) {
PreparedStatement ps = null;
if (!isConnectionOpen()) {
HMCCosmeticsPlugin.getInstance().getLogger().info("Connection is not open");
}
try {
if (connection == null) throw new NullPointerException("Connection is null");
ps = connection.prepareStatement(query);
} catch (SQLException e) {
} catch (SQLException | NullPointerException e) {
e.printStackTrace();
}
return ps;
}
}

View File

@@ -0,0 +1,68 @@
package com.hibiscusmc.hmccosmetics.database.types;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;
import java.util.UUID;
public abstract class SQLData extends Data {
@Override
@SuppressWarnings({"resource"}) // Duplicate is from deprecated InternalData
public CosmeticUser get(UUID uniqueId) {
CosmeticUser user = new CosmeticUser(uniqueId);
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
try {
PreparedStatement preparedStatement = preparedStatement("SELECT * FROM COSMETICDATABASE WHERE UUID = ?;");
preparedStatement.setString(1, uniqueId.toString());
ResultSet rs = preparedStatement.executeQuery();
if (rs.next()) {
String rawData = rs.getString("COSMETICS");
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = deserializeData(user, rawData);
for (Map<Cosmetic, Color> cosmeticColors : cosmetics.values()) {
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
// This can not be async.
user.addPlayerCosmetic(cosmetic, cosmeticColors.get(cosmetic));
});
}
}
}
} catch (SQLException e) {
e.printStackTrace();
}
});
return user;
}
@Override
@SuppressWarnings("resource")
public void save(CosmeticUser user) {
Runnable run = () -> {
try {
PreparedStatement preparedSt = preparedStatement("REPLACE INTO COSMETICDATABASE(UUID,COSMETICS) VALUES(?,?);");
preparedSt.setString(1, user.getUniqueId().toString());
preparedSt.setString(2, serializeData(user));
preparedSt.executeUpdate();
} catch (SQLException e) {
throw new RuntimeException(e);
}
};
if (!HMCCosmeticsPlugin.isDisable()) {
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), run);
} else {
run.run();
}
}
public abstract PreparedStatement preparedStatement(String query);
}

View File

@@ -1,31 +1,31 @@
package com.hibiscusmc.hmccosmetics.database.types;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import java.io.File;
import java.io.IOException;
import java.sql.*;
import java.util.Map;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.UUID;
import java.util.logging.Level;
public class SQLiteData extends Data {
public class SQLiteData extends SQLData {
private Connection connection;
@Override
public void setup() {
File dataFolder = new File(HMCCosmeticsPlugin.getInstance().getDataFolder(), "database.db");
boolean exists = dataFolder.exists();
if (!dataFolder.exists()){
if (!exists) {
try {
dataFolder.createNewFile();
boolean created = dataFolder.createNewFile();
if (!created) throw new IOException("File didn't exist but now does");
} catch (IOException e) {
MessagesUtil.sendDebugMessages("File write error. Database will not work properly", Level.SEVERE);
}
@@ -39,66 +39,18 @@ public class SQLiteData extends Data {
"(UUID varchar(36) PRIMARY KEY, " +
"COSMETICS MEDIUMTEXT " +
");").execute();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
@Override
public void save(CosmeticUser user) {
Runnable run = () -> {
try {
PreparedStatement preparedSt = preparedStatement("REPLACE INTO COSMETICDATABASE(UUID,COSMETICS) VALUES(?,?);");
preparedSt.setString(1, user.getUniqueId().toString());
preparedSt.setString(2, steralizeData(user));
preparedSt.executeUpdate();
} catch (SQLException e) {
throw new RuntimeException(e);
}
};
if (!HMCCosmeticsPlugin.isDisable()) {
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), run);
} else {
run.run();
}
}
@Override
public CosmeticUser get(UUID uniqueId) {
CosmeticUser user = new CosmeticUser(uniqueId);
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
try {
PreparedStatement preparedStatement = preparedStatement("SELECT * FROM COSMETICDATABASE WHERE UUID = ?;");
preparedStatement.setString(1, uniqueId.toString());
ResultSet rs = preparedStatement.executeQuery();
if (rs.next()) {
String rawData = rs.getString("COSMETICS");
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = desteralizedata(rawData);
for (Map<Cosmetic, Color> cosmeticColors : cosmetics.values()) {
for (Cosmetic cosmetic : cosmeticColors.keySet()) {
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
// This can not be async.
user.addPlayerCosmetic(cosmetic, cosmeticColors.get(cosmetic));
});
}
}
}
} catch (SQLException e) {
e.printStackTrace();
}
});
return user;
}
@Override
public void clear(UUID unqiueId) {
@SuppressWarnings("resource")
public void clear(UUID uniqueId) {
Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
try {
PreparedStatement preparedSt = preparedStatement("DELETE FROM COSMETICDATABASE WHERE UUID=?;");
preparedSt.setString(1, unqiueId.toString());
preparedSt.setString(1, uniqueId.toString());
preparedSt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
@@ -106,56 +58,47 @@ public class SQLiteData extends Data {
});
}
private void openConnection() throws SQLException {
if (connection != null && !connection.isClosed()) {
return;
}
//Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
// Bukkit.getScheduler().runTaskAsynchronously(HMCCosmeticsPlugin.getInstance(), () -> {
// ...
// });
// connection = DriverManager.getConnection("jdbc:mysql://" + DatabaseSettings.getHost() + ":" + DatabaseSettings.getPort() + "/" + DatabaseSettings.getDatabase(), setupProperties());
//close Connection if still active
if (connection != null) {
//close();
}
if (connection != null && !connection.isClosed()) return;
// Close Connection if still active
File dataFolder = new File(HMCCosmeticsPlugin.getInstance().getDataFolder(), "database.db");
//connect to database host
// Connect to database host
try {
Class.forName("org.sqlite.JDBC");
connection = DriverManager.getConnection("jdbc:sqlite:" + dataFolder);
} catch (SQLException e) {
System.out.println(e.getMessage());
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
//});
//connection = DriverManager.getConnection("jdbc:mysql://" + DatabaseSettings.getHost() + ":" + DatabaseSettings.getPort() + "/" + DatabaseSettings.getDatabase(), setupProperties());
}
@Override
public PreparedStatement preparedStatement(String query) {
PreparedStatement ps = null;
if (!isConnectionOpen()) {
HMCCosmeticsPlugin.getInstance().getLogger().info("Connection is not open");
}
try {
ps = connection.prepareStatement(query);
} catch (SQLException e) {
e.printStackTrace();
}
return ps;
}
private boolean isConnectionOpen() {
try {
if (connection == null || connection.isClosed()) {
return false;
} else {
return true;
}
return connection != null && !connection.isClosed();
} catch (SQLException e) {
throw new RuntimeException(e);
}

View File

@@ -0,0 +1,85 @@
package com.hibiscusmc.hmccosmetics.emotes;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.ticxo.playeranimator.api.PlayerAnimator;
import com.ticxo.playeranimator.api.animation.pack.AnimationPack;
import org.apache.commons.io.FilenameUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* Manages Emotes
*/
@SuppressWarnings("SpellCheckingInspection")
public class EmoteManager {
private static final @NotNull Map<String, String> emotes = new HashMap<>();
/**
* Loads all BlockBench animations from the emotes folder and puts it into the animation manager registry and local registry
*/
public static void loadEmotes() {
// Clear the PlayerAnimator and local registries
PlayerAnimator.api.getAnimationManager().clearRegistry();
emotes.clear();
// Get the emote directory and check if it exists
File emoteDir = new File(HMCCosmeticsPlugin.getInstance().getDataFolder().getPath() + "/emotes/");
if (!emoteDir.exists()) return;
// Get all the files inside the directory and check if it isn't 0
File[] emoteFiles = emoteDir.listFiles();
if (emoteFiles == null || emoteFiles.length == 0) return;
// Remove any files that don't have the file extension ".bbmodel" and check if there are still resulting files
emoteFiles = Arrays.stream(emoteFiles).filter(file -> file.getPath().endsWith(".bbmodel")).distinct().toArray(File[]::new);
if (emoteFiles.length == 0) return;
// Loop through all files, importing all block bench animations into the registry
for (File animationFile : emoteFiles) {
String animationKey = FilenameUtils.removeExtension(animationFile.getName());
PlayerAnimator.api.getAnimationManager().importAnimations(animationKey, animationFile);
}
// Loops through all the entries in the registries and unpacks any animation packs to ensure if there were multiple animations
// inside a singular file, that they are added to the local registry individually for tab completion
for (Map.Entry<String, AnimationPack> packEntry : PlayerAnimator.api.getAnimationManager().getRegistry().entrySet()) {
packEntry.getValue().getAnimations().keySet().forEach(animationName -> {
// API key is the format "animationKey.animationFileName.animationName"
String apiKey = packEntry.getKey().replace(":", ".") + "." + animationName;
emotes.put(animationName, apiKey);
});
}
}
/**
* Returns true if there is an animation with the specified name
* @param animationName Name whose presence is to be tested
* @return True if this registry contains a mapping for the specified name
*/
public static boolean has(@NotNull String animationName) {
return emotes.containsKey(animationName);
}
/**
* Returns the {@code API key} to which the specified name is mapped, or {@code null} if this map contains no mapping for the name.
* @param animationName Name whose {@code API key} is to be fetched
* @return The {@code API key} of the specified name or {@code null} if there was no animation name found
*/
public static @Nullable String get(@NotNull String animationName) {
return emotes.get(animationName);
}
/**
* Gets a set of all the laoded animation names
* @return A set of all loaded animation names
*/
public static @NotNull Set<String> getAllNames() {
return emotes.keySet();
}
}

View File

@@ -1,51 +1,102 @@
package com.hibiscusmc.hmccosmetics.gui;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.api.PlayerMenuOpenEvent;
import com.hibiscusmc.hmccosmetics.api.events.PlayerMenuOpenEvent;
import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
import com.hibiscusmc.hmccosmetics.gui.type.Type;
import com.hibiscusmc.hmccosmetics.gui.type.Types;
import com.hibiscusmc.hmccosmetics.hooks.PAPIHook;
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.misc.Adventure;
import com.hibiscusmc.hmccosmetics.util.misc.Placeholder;
import dev.triumphteam.gui.builder.item.ItemBuilder;
import dev.triumphteam.gui.guis.Gui;
import dev.triumphteam.gui.guis.GuiItem;
import me.clip.placeholderapi.PlaceholderAPI;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
public class Menu {
private String id;
private String title;
private int rows;
private ConfigurationNode config;
private String permissionNode;
private final String id;
private final String title;
private final int rows;
private final ConfigurationNode config;
private final String permissionNode;
private final ArrayList<MenuItem> items;
private final int refreshRate;
public Menu(String id, ConfigurationNode config) {
public Menu(String id, @NotNull ConfigurationNode config) {
this.id = id;
this.config = config;
title = config.node("title").getString("chest");
rows = config.node("rows").getInt(1);
permissionNode = config.node("permission").getString("");
refreshRate = config.node("refresh-rate").getInt(-1);
items = new ArrayList<>();
setupItems();
Menus.addMenu(this);
}
private void setupItems() {
for (ConfigurationNode config : config.node("items").childrenMap().values()) {
List<String> slotString;
try {
slotString = config.node("slots").getList(String.class);
} catch (SerializationException e) {
continue;
}
if (slotString == null) {
MessagesUtil.sendDebugMessages("Unable to get valid slot for " + config.key().toString());
continue;
}
List<Integer> slots = getSlots(slotString);
if (slots == null) {
MessagesUtil.sendDebugMessages("Slot is null for " + config.key().toString());
continue;
}
ItemStack item;
try {
item = ItemSerializer.INSTANCE.deserialize(ItemStack.class, config.node("item"));
} catch (SerializationException e) {
throw new RuntimeException(e);
}
if (item == null) {
MessagesUtil.sendDebugMessages("something went wrong! " + item);
continue;
}
Type type = null;
if (!config.node("type").virtual()) {
String typeId = config.node("type").getString();
if (Types.isType(typeId)) type = Types.getType(typeId);
}
items.add(new MenuItem(slots, item, type, config));
}
}
public String getId() {
return id;
}
@@ -62,7 +113,7 @@ public class Menu {
openMenu(user, false);
}
public void openMenu(CosmeticUser user, boolean ignorePermission) {
public void openMenu(@NotNull CosmeticUser user, boolean ignorePermission) {
Player player = user.getPlayer();
if (player == null) return;
if (!ignorePermission && !permissionNode.isEmpty()) {
@@ -71,7 +122,7 @@ public class Menu {
return;
}
}
final Component component = Adventure.MINI_MESSAGE.deserialize(Placeholder.applyPapiPlaceholders(player, this.title));
final Component component = Adventure.MINI_MESSAGE.deserialize(Hooks.processPlaceholders(player, this.title));
Gui gui = Gui.gui().
title(component).
rows(this.rows).
@@ -79,96 +130,64 @@ public class Menu {
gui.setDefaultClickAction(event -> event.setCancelled(true));
gui = getItems(user, gui);
AtomicInteger taskid = new AtomicInteger(-1);
gui.setOpenGuiAction(event -> {
Runnable run = new Runnable() {
@Override
public void run() {
if (gui.getInventory().getViewers().size() == 0 && taskid.get() != -1) {
Bukkit.getScheduler().cancelTask(taskid.get());
}
Gui finalGui = gui;
updateMenu(user, gui);
}
};
if (refreshRate != -1) {
taskid.set(Bukkit.getScheduler().scheduleSyncRepeatingTask(HMCCosmeticsPlugin.getInstance(), run, 0, refreshRate));
} else {
run.run();
}
});
gui.setCloseGuiAction(event -> {
if (taskid.get() != -1) Bukkit.getScheduler().cancelTask(taskid.get());
});
// API
PlayerMenuOpenEvent event = new PlayerMenuOpenEvent(user, this);
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
Bukkit.getPluginManager().callEvent(event);
});
if (event.isCancelled()) {
return;
}
if (event.isCancelled()) return;
// Internal
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
finalGui.open(player);
gui.open(player);
});
//gui.open(player);
}
private Gui getItems(CosmeticUser user, Gui gui) {
Player player = user.getPlayer();
private void updateMenu(CosmeticUser user, Gui gui) {
for (MenuItem item : items) {
Type type = item.getType();
for (int slot : item.getSlots()) {
ItemStack modifiedItem = getMenuItem(user, type, item.getItemConfig(), item.getItem().clone(), slot);
GuiItem guiItem = ItemBuilder.from(modifiedItem).asGuiItem();
guiItem.setAction(event -> {
MessagesUtil.sendDebugMessages("Selected slot " + slot);
final ClickType clickType = event.getClick();
if (type != null) type.run(user, item.getItemConfig(), clickType);
updateMenu(user, gui);
});
for (ConfigurationNode config : config.node("items").childrenMap().values()) {
List<String> slotString = null;
try {
slotString = config.node("slots").getList(String.class);
} catch (SerializationException e) {
continue;
MessagesUtil.sendDebugMessages("Added " + slot + " as " + guiItem + " in the menu");
gui.updateItem(slot, guiItem);
}
if (slotString == null) {
MessagesUtil.sendDebugMessages("Unable to get valid slot for " + config.key().toString());
continue;
}
List<Integer> slots = getSlots(slotString);
if (slots == null) {
MessagesUtil.sendDebugMessages("Slot is null for " + config.key().toString());
continue;
}
ItemStack item;
try {
item = ItemSerializer.INSTANCE.deserialize(ItemStack.class, config.node("item"));
//item = config.node("item").get(ItemStack.class);
} catch (SerializationException e) {
throw new RuntimeException(e);
}
if (item == null) {
MessagesUtil.sendDebugMessages("something went wrong! " + item);
continue;
}
Type type = null;
if (!config.node("type").virtual()) {
String typeId = config.node("type").getString();
if (Types.isType(typeId)) type = Types.getType(typeId);
}
ItemStack originalItem = item.clone();
item = updateLore(user, item, type, config);
GuiItem guiItem = ItemBuilder.from(item).asGuiItem();
Type finalType = type;
guiItem.setAction(event -> {
final ClickType clickType = event.getClick();
if (finalType != null) finalType.run(user, config, clickType);
for (int i : slots) {
gui.updateItem(i, updateLore(user, originalItem.clone(), finalType, config));
MessagesUtil.sendDebugMessages("Updated slot " + i);
}
});
MessagesUtil.sendDebugMessages("Added " + slots + " as " + guiItem + " in the menu");
gui.setItem(slots, guiItem);
}
return gui;
}
private List<Integer> getSlots(List<String> slotString) {
@NotNull
private List<Integer> getSlots(@NotNull List<String> slotString) {
List<Integer> slots = new ArrayList<>();
for (String a : slotString) {
@@ -185,6 +204,7 @@ public class Menu {
return slots;
}
@NotNull
private List<Integer> getSlots(int small, int max) {
List<Integer> slots = new ArrayList<>();
@@ -192,11 +212,11 @@ public class Menu {
return slots;
}
private ItemStack updateLore(CosmeticUser user, ItemStack itemStack, Type type, ConfigurationNode config) {
if (itemStack.hasItemMeta()) {
itemStack.setItemMeta(type.setLore(user, config, itemStack.getItemMeta()));
}
return itemStack;
@Contract("_, _, _, _ -> param2")
@NotNull
private ItemStack getMenuItem(CosmeticUser user, Type type, ConfigurationNode config, ItemStack itemStack, int slot) {
if (!itemStack.hasItemMeta()) return itemStack;
return type.setItem(user, config, itemStack, slot);
}
public String getPermissionNode() {
@@ -205,7 +225,6 @@ public class Menu {
public boolean canOpen(Player player) {
if (permissionNode.isEmpty()) return true;
if (player.isOp() || player.hasPermission(permissionNode)) return true;
return false;
return player.isOp() || player.hasPermission(permissionNode);
}
}

View File

@@ -0,0 +1,39 @@
package com.hibiscusmc.hmccosmetics.gui;
import com.hibiscusmc.hmccosmetics.gui.type.Type;
import org.bukkit.inventory.ItemStack;
import org.spongepowered.configurate.ConfigurationNode;
import java.util.List;
public class MenuItem {
private List<Integer> slots;
private ItemStack item;
private Type type;
private ConfigurationNode itemConfig;
public MenuItem(List<Integer> slots, ItemStack item, Type type, ConfigurationNode itemConfig) {
this.slots = slots;
this.item = item;
this.type = type;
this.itemConfig = itemConfig;
}
public List<Integer> getSlots() {
return slots;
}
public ItemStack getItem() {
return item;
}
public Type getType() {
return type;
}
public ConfigurationNode getItemConfig() {
return itemConfig;
}
}

View File

@@ -4,34 +4,41 @@ import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.apache.commons.io.FilenameUtils;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.ConfigurateException;
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
import java.util.stream.Stream;
public class Menus {
private static HashMap<String, Menu> MENUS = new HashMap<>();
private static final HashMap<String, Menu> MENUS = new HashMap<>();
public static void addMenu(Menu menu) {
MENUS.put(menu.getId().toUpperCase(), menu);
}
public static Menu getMenu(String id) {
public static Menu getMenu(@NotNull String id) {
return MENUS.get(id.toUpperCase());
}
@Contract(pure = true)
@NotNull
public static Collection<Menu> getMenu() {
return MENUS.values();
}
public static boolean hasMenu(String id) {
public static boolean hasMenu(@NotNull String id) {
return MENUS.containsKey(id.toUpperCase());
}
@@ -39,6 +46,9 @@ public class Menus {
return MENUS.containsValue(menu);
}
public static Menu getDefaultMenu() { return Menus.getMenu(Settings.getDefaultMenu()); }
@NotNull
public static List<String> getMenuNames() {
List<String> names = new ArrayList<>();
@@ -49,33 +59,39 @@ public class Menus {
return names;
}
public static Collection<Menu> values() {
return MENUS.values();
}
public static void setup() {
MENUS.clear();
File cosmeticFolder = new File(HMCCosmeticsPlugin.getInstance().getDataFolder() + "/menus");
if (!cosmeticFolder.exists()) cosmeticFolder.mkdir();
File[] directoryListing = cosmeticFolder.listFiles();
if (directoryListing == null) return;
for (File child : directoryListing) {
if (child.toString().contains(".yml") || child.toString().contains(".yaml")) {
MessagesUtil.sendDebugMessages("Scanning " + child);
// Loads file
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child.toPath()).build();
CommentedConfigurationNode root;
try {
root = loader.load();
} catch (ConfigurateException e) {
throw new RuntimeException(e);
// Recursive file lookup
try (Stream<Path> walkStream = Files.walk(cosmeticFolder.toPath())) {
walkStream.filter(p -> p.toFile().isFile()).forEach(child -> {
if (child.toString().endsWith("yml") || child.toString().endsWith("yaml")) {
MessagesUtil.sendDebugMessages("Scanning " + child);
// Loads file
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child).build();
CommentedConfigurationNode root;
try {
root = loader.load();
} catch (ConfigurateException e) {
throw new RuntimeException(e);
}
try {
new Menu(FilenameUtils.removeExtension(child.getFileName().toString()), root);
} catch (Exception e) {
MessagesUtil.sendDebugMessages("Unable to create menu in " + child.getFileName().toString(), Level.WARNING);
if (Settings.isDebugEnabled()) e.printStackTrace();
}
}
try {
new Menu(FilenameUtils.removeExtension(child.getName()), root);
} catch (Exception e) {
MessagesUtil.sendDebugMessages("Unable to create menu in " + child, Level.WARNING);
if (Settings.isDebugEnabled()) e.printStackTrace();
}
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -1,12 +1,13 @@
package com.hibiscusmc.hmccosmetics.gui.action;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.jetbrains.annotations.NotNull;
public class Action {
public abstract class Action {
private String id;
private final String id;
public Action(String id) {
public Action(@NotNull String id) {
this.id = id.toUpperCase();
Actions.addAction(this);
}
@@ -15,7 +16,5 @@ public class Action {
return this.id;
}
public void run(CosmeticUser user, String raw) {
// Override
}
public abstract void run(CosmeticUser user, String raw);
}

View File

@@ -4,34 +4,36 @@ import com.hibiscusmc.hmccosmetics.gui.action.actions.*;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.List;
@SuppressWarnings("unused")
public class Actions {
private static HashMap<String, Action> actions = new HashMap<>();
private static final HashMap<String, Action> actions = new HashMap<>();
// [ID]
private static ActionMessage ACTION_MESSAGE = new ActionMessage();
private static ActionMenu ACTION_MENU = new ActionMenu();
private static ActionPlayerCommand ACTION_CONSOLE_COMMAND = new ActionPlayerCommand();
private static ActionConsoleCommand ACTION_PLAYER_COMMAND = new ActionConsoleCommand();
private static ActionCloseMenu ACTION_EXIT_MENU = new ActionCloseMenu();
private static ActionSound ACTION_SOUND = new ActionSound();
private static ActionEquip ACTION_EQUIP = new ActionEquip();
private static ActionUnequip ACTION_UNEQUIP = new ActionUnequip();
private static ActionParticle ACTION_PARTICLE = new ActionParticle();
private static ActionCosmeticShow ACTION_SHOW = new ActionCosmeticShow();
private static ActionCosmeticHide ACTION_HIDE = new ActionCosmeticHide();
private static ActionCosmeticToggle ACTION_TOGGLE = new ActionCosmeticToggle();
private static final ActionMessage ACTION_MESSAGE = new ActionMessage();
private static final ActionMenu ACTION_MENU = new ActionMenu();
private static final ActionPlayerCommand ACTION_CONSOLE_COMMAND = new ActionPlayerCommand();
private static final ActionConsoleCommand ACTION_PLAYER_COMMAND = new ActionConsoleCommand();
private static final ActionCloseMenu ACTION_EXIT_MENU = new ActionCloseMenu();
private static final ActionSound ACTION_SOUND = new ActionSound();
private static final ActionEquip ACTION_EQUIP = new ActionEquip();
private static final ActionUnequip ACTION_UNEQUIP = new ActionUnequip();
private static final ActionParticle ACTION_PARTICLE = new ActionParticle();
private static final ActionCosmeticShow ACTION_SHOW = new ActionCosmeticShow();
private static final ActionCosmeticHide ACTION_HIDE = new ActionCosmeticHide();
private static final ActionCosmeticToggle ACTION_TOGGLE = new ActionCosmeticToggle();
public static Action getAction(String id) {
public static Action getAction(@NotNull String id) {
return actions.get(id.toUpperCase());
}
public static boolean isAction(String id) {
public static boolean isAction(@NotNull String id) {
return actions.containsKey(id.toUpperCase());
}
@@ -39,7 +41,7 @@ public class Actions {
actions.put(action.getId().toUpperCase(), action);
}
public static void runActions(CosmeticUser user, List<String> raw) {
public static void runActions(CosmeticUser user, @NotNull List<String> raw) {
for (String a : raw) {
String id = StringUtils.substringBetween(a, "[", "]").toUpperCase();
String message = StringUtils.substringAfter(a, "] ");

View File

@@ -2,6 +2,7 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
import com.hibiscusmc.hmccosmetics.gui.action.Action;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.jetbrains.annotations.NotNull;
public class ActionCloseMenu extends Action {
@@ -10,7 +11,7 @@ public class ActionCloseMenu extends Action {
}
@Override
public void run(CosmeticUser user, String raw) {
public void run(@NotNull CosmeticUser user, String raw) {
user.getPlayer().closeInventory();
}
}

View File

@@ -3,6 +3,7 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.gui.action.Action;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.jetbrains.annotations.NotNull;
public class ActionConsoleCommand extends Action {
@@ -11,8 +12,7 @@ public class ActionConsoleCommand extends Action {
}
@Override
public void run(CosmeticUser user, String raw) {
public void run(@NotNull CosmeticUser user, String raw) {
HMCCosmeticsPlugin.getInstance().getServer().dispatchCommand(user.getPlayer(), raw);
}
}

View File

@@ -2,6 +2,7 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
import com.hibiscusmc.hmccosmetics.gui.action.Action;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.jetbrains.annotations.NotNull;
public class ActionCosmeticHide extends Action {
@@ -10,10 +11,8 @@ public class ActionCosmeticHide extends Action {
}
@Override
public void run(CosmeticUser user, String raw) {
if (!user.getHidden()) {
user.hideCosmetics(CosmeticUser.HiddenReason.ACTION);
return;
}
public void run(@NotNull CosmeticUser user, String raw) {
if (user.getHidden()) return;
user.hideCosmetics(CosmeticUser.HiddenReason.ACTION);
}
}

View File

@@ -2,6 +2,7 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
import com.hibiscusmc.hmccosmetics.gui.action.Action;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.jetbrains.annotations.NotNull;
public class ActionCosmeticShow extends Action {
@@ -10,10 +11,11 @@ public class ActionCosmeticShow extends Action {
}
@Override
public void run(CosmeticUser user, String raw) {
if (user.getHidden()) {
if (user.getHiddenReason() != CosmeticUser.HiddenReason.ACTION && user.getHiddenReason() != CosmeticUser.HiddenReason.COMMAND) return; // Do not hide if its already off for WG
user.showCosmetics();
}
public void run(@NotNull CosmeticUser user, String raw) {
if (!user.getHidden()) return;
// Do not hide if it's already off for WG
if (user.getHiddenReason() != CosmeticUser.HiddenReason.ACTION && user.getHiddenReason() != CosmeticUser.HiddenReason.COMMAND) return;
user.showCosmetics();
}
}

View File

@@ -2,6 +2,7 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
import com.hibiscusmc.hmccosmetics.gui.action.Action;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.jetbrains.annotations.NotNull;
public class ActionCosmeticToggle extends Action {
@@ -10,13 +11,13 @@ public class ActionCosmeticToggle extends Action {
}
@Override
public void run(CosmeticUser user, String raw) {
public void run(@NotNull CosmeticUser user, String raw) {
if (user.getHidden()) {
if (user.getHiddenReason() != CosmeticUser.HiddenReason.ACTION && user.getHiddenReason() != CosmeticUser.HiddenReason.COMMAND) return;
user.showCosmetics();
return;
}
user.hideCosmetics(CosmeticUser.HiddenReason.ACTION);
return;
}
}

View File

@@ -14,9 +14,8 @@ public class ActionEquip extends Action {
@Override
public void run(CosmeticUser user, String raw) {
Cosmetic cosmetic = Cosmetics.getCosmetic(raw);
if (cosmetic == null) {
return;
}
if (cosmetic == null) return;
user.addPlayerCosmetic(cosmetic);
}
}

View File

@@ -1,10 +1,12 @@
package com.hibiscusmc.hmccosmetics.gui.action.actions;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.gui.Menu;
import com.hibiscusmc.hmccosmetics.gui.Menus;
import com.hibiscusmc.hmccosmetics.gui.action.Action;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import java.util.logging.Level;
public class ActionMenu extends Action {
@@ -14,11 +16,22 @@ public class ActionMenu extends Action {
@Override
public void run(CosmeticUser user, String raw) {
boolean ignorePermission = false;
raw = raw.replaceAll(" ", ""); // Removes all spaces
if (raw.contains("-o")) {
raw = raw.replaceAll("-o", "");
ignorePermission = true;
}
if (!Menus.hasMenu(raw)) {
HMCCosmeticsPlugin.getInstance().getLogger().info("Invalid Action Menu -> " + raw);
MessagesUtil.sendDebugMessages("Invalid Action Menu -> " + raw, Level.WARNING);
return;
}
Menu menu = Menus.getMenu(raw);
menu.openMenu(user, true);
MessagesUtil.sendDebugMessages(raw + " | " + ignorePermission);
menu.openMenu(user, ignorePermission);
}
}

View File

@@ -3,6 +3,7 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
import com.hibiscusmc.hmccosmetics.gui.action.Action;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.jetbrains.annotations.NotNull;
public class ActionMessage extends Action {
@@ -11,7 +12,7 @@ public class ActionMessage extends Action {
}
@Override
public void run(CosmeticUser user, String raw) {
public void run(@NotNull CosmeticUser user, String raw) {
MessagesUtil.sendMessageNoKey(user.getPlayer(), raw);
}
}

View File

@@ -5,15 +5,16 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
import com.owen1212055.particlehelper.api.particle.Particle;
import com.owen1212055.particlehelper.api.particle.types.BlockDataParticle;
import com.owen1212055.particlehelper.api.particle.types.DestinationParticle;
import com.owen1212055.particlehelper.api.particle.types.velocity.VelocityParticle;
import com.owen1212055.particlehelper.api.particle.types.vibration.VibrationParticle;
import com.owen1212055.particlehelper.api.type.ParticleType;
import com.owen1212055.particlehelper.api.type.Particles;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class ActionParticle extends Action {
@@ -22,17 +23,17 @@ public class ActionParticle extends Action {
}
@Override
public void run(CosmeticUser user, String raw) {
@SuppressWarnings("ConstantConditions")
public void run(CosmeticUser user, @NotNull String raw) {
String[] rawString = raw.split(" ");
var particleType = Particles.fromKey(NamespacedKey.minecraft(rawString[0].toLowerCase()));
ParticleType<?, ?> particleType = Particles.fromKey(NamespacedKey.minecraft(rawString[0].toLowerCase()));
if (particleType == null) {
MessagesUtil.sendDebugMessages("The particle " + rawString[0] + " does not exist!");
return;
}
boolean multi = false;
if (particleType.multi() != null) {
multi = true; // Should work?
}
// particleType.multi() should never be null, but particleType can be.
boolean multi = particleType.multi() != null;
var particle = multi ? particleType.multi() : particleType.single();
if (particle instanceof DestinationParticle || particle instanceof BlockDataParticle
@@ -40,6 +41,7 @@ public class ActionParticle extends Action {
MessagesUtil.sendDebugMessages("The particle " + rawString[0] + " is not supported by this action!");
return;
}
particle = ServerUtils.addParticleValues(particle, rawString);
Location location = user.getPlayer().getLocation();
for (Player player : PacketManager.getViewers(location)) {

View File

@@ -3,6 +3,7 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
import com.hibiscusmc.hmccosmetics.gui.action.Action;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.jetbrains.annotations.NotNull;
public class ActionPlayerCommand extends Action {
@@ -11,7 +12,7 @@ public class ActionPlayerCommand extends Action {
}
@Override
public void run(CosmeticUser user, String raw) {
public void run(@NotNull CosmeticUser user, String raw) {
user.getPlayer().performCommand(MessagesUtil.processStringNoKeyString(user.getPlayer(), raw));
}
}

View File

@@ -4,6 +4,7 @@ import com.hibiscusmc.hmccosmetics.gui.action.Action;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.logging.Level;
@@ -15,7 +16,7 @@ public class ActionSound extends Action {
}
@Override
public void run(CosmeticUser user, String raw) {
public void run(@NotNull CosmeticUser user, @NotNull String raw) {
Player player = user.getPlayer();
String[] processedString = raw.split(" ");
@@ -24,11 +25,11 @@ public class ActionSound extends Action {
float pitch = 1;
if (processedString.length > 2) {
volume = Float.valueOf(processedString[1]);
pitch = Float.valueOf(processedString[2]);
volume = Float.parseFloat(processedString[1]);
pitch = Float.parseFloat(processedString[2]);
}
MessagesUtil.sendDebugMessages("Attempting to play " + soundName, Level.WARNING);
MessagesUtil.sendDebugMessages("Attempting to play " + soundName, Level.INFO);
player.playSound(player.getLocation(), soundName, volume, pitch);
}

View File

@@ -13,9 +13,8 @@ public class ActionUnequip extends Action {
@Override
public void run(CosmeticUser user, String raw) {
if (!EnumUtils.isValidEnum(CosmeticSlot.class, raw)) {
return;
}
if (!EnumUtils.isValidEnum(CosmeticSlot.class, raw)) return;
CosmeticSlot slot = CosmeticSlot.valueOf(raw);
user.removeCosmeticSlot(slot);
}

View File

@@ -6,8 +6,8 @@ import com.hibiscusmc.hmccolor.gui.guis.GuiItem;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.misc.Placeholder;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Material;
@@ -17,23 +17,26 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.inventory.meta.MapMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.jetbrains.annotations.NotNull;
public class DyeMenu {
// Yes, I do know how tacted on this feels.
public static void openMenu(CosmeticUser user, Cosmetic cosmetic) {
public static void openMenu(@NotNull CosmeticUser user, Cosmetic cosmetic) {
Player player = user.getPlayer();
if (player == null) return;
if (!Hooks.isActiveHook("HMCColor")) {
addCosmetic(user, cosmetic, null);
return;
}
ItemStack originalItem = user.getUserCosmeticItem(cosmetic);
if (originalItem == null || !cosmetic.isDyable()) return;
Player player = user.getPlayer();
Gui gui = HMCColorApi.INSTANCE.colorMenu();
gui.updateTitle(Placeholder.applyPapiPlaceholders(player, Settings.getDyeMenuName()));
gui.setItem(19, new GuiItem(originalItem));
gui.updateTitle(Hooks.processPlaceholders(player, Settings.getDyeMenuName()));
gui.setItem(Settings.getDyeMenuInputSlot(), new GuiItem(originalItem));
gui.setDefaultTopClickAction(event -> {
if (event.getSlot() == 25) {
ItemStack item = event.getInventory().getItem(25);
if (event.getSlot() == Settings.getDyeMenuOutputSlot()) {
ItemStack item = event.getInventory().getItem(Settings.getDyeMenuOutputSlot());
if (item == null) return;
ItemMeta meta = item.getItemMeta();
if (meta == null) return;
@@ -43,13 +46,8 @@ public class DyeMenu {
meta instanceof MapMeta mapMeta ? mapMeta.getColor() : null;
if (color == null) return;
//user.removeCosmeticSlot(cosmetic);
user.addPlayerCosmetic(cosmetic, color);
player.setItemOnCursor(new ItemStack(Material.AIR));
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
player.closeInventory();
user.updateCosmetic(cosmetic.getSlot());
}, 2);
addCosmetic(user, cosmetic, color);
event.setCancelled(true);
} else event.setCancelled(true);
});
@@ -57,4 +55,14 @@ public class DyeMenu {
gui.setCloseGuiAction(event -> {});
gui.open(player);
}
private static void addCosmetic(@NotNull CosmeticUser user, Cosmetic cosmetic, Color color) {
Player player = user.getPlayer();
user.addPlayerCosmetic(cosmetic, color);
player.setItemOnCursor(new ItemStack(Material.AIR));
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
player.closeInventory();
user.updateCosmetic(cosmetic.getSlot());
}, 2);
}
}

View File

@@ -2,12 +2,12 @@ package com.hibiscusmc.hmccosmetics.gui.type;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.ItemStack;
import org.spongepowered.configurate.ConfigurationNode;
public class Type {
public abstract class Type {
private String id;
private final String id;
public Type(String id) {
this.id = id;
@@ -21,12 +21,8 @@ public class Type {
public void run(CosmeticUser user, ConfigurationNode config) {
run(user, config, null);
}
public void run(CosmeticUser user, ConfigurationNode config, ClickType clickType) {
// Override
}
public ItemMeta setLore(CosmeticUser user, ConfigurationNode config, ItemMeta itemMeta) {
//TODO: Finish this
return null; // Override
}
public abstract void run(CosmeticUser user, ConfigurationNode config, ClickType clickType);
public abstract ItemStack setItem(CosmeticUser user, ConfigurationNode config, ItemStack itemStack, int slot);
}

View File

@@ -2,21 +2,22 @@ package com.hibiscusmc.hmccosmetics.gui.type;
import com.hibiscusmc.hmccosmetics.gui.type.types.TypeCosmetic;
import com.hibiscusmc.hmccosmetics.gui.type.types.TypeEmpty;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
public class Types {
private static HashMap<String, Type> types = new HashMap<>();
private static final HashMap<String, Type> types = new HashMap<>();
private static TypeCosmetic TYPE_COSMETIC = new TypeCosmetic();
private static TypeEmpty TYPE_EMPTY = new TypeEmpty();
public static Type getType(String id) {
public static Type getType(@NotNull String id) {
return types.get(id.toUpperCase());
}
public static boolean isType(String id) {
public static boolean isType(@NotNull String id) {
return types.containsKey(id.toUpperCase());
}

View File

@@ -1,28 +1,29 @@
package com.hibiscusmc.hmccosmetics.gui.type.types;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
import com.hibiscusmc.hmccosmetics.gui.action.Actions;
import com.hibiscusmc.hmccosmetics.gui.special.DyeMenu;
import com.hibiscusmc.hmccosmetics.gui.type.Type;
import com.hibiscusmc.hmccosmetics.hooks.PAPIHook;
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.misc.StringUtils;
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class TypeCosmetic extends Type {
@@ -31,23 +32,32 @@ public class TypeCosmetic extends Type {
}
@Override
public void run(CosmeticUser user, ConfigurationNode config, ClickType clickType) {
if (config.node("cosmetic").virtual()) return;
public void run(CosmeticUser user, @NotNull ConfigurationNode config, ClickType clickType) {
MessagesUtil.sendDebugMessages("Running Cosmetic Click Type");
if (config.node("cosmetic").virtual()) {
MessagesUtil.sendDebugMessages("Cosmetic Config Field Virtual");
return;
}
String cosmeticName = config.node("cosmetic").getString();
Cosmetic cosmetic = Cosmetics.getCosmetic(cosmeticName);
Player player = user.getPlayer();
if (cosmetic == null) {
MessagesUtil.sendMessage(user.getPlayer(), "invalid-cosmetic");
MessagesUtil.sendDebugMessages("No Cosmetic Found");
MessagesUtil.sendMessage(player, "invalid-cosmetic");
return;
}
if (!user.canEquipCosmetic(cosmetic)) {
MessagesUtil.sendMessage(user.getPlayer(), "no-cosmetic-permission");
MessagesUtil.sendDebugMessages("No Cosmetic Permission");
MessagesUtil.sendMessage(player, "no-cosmetic-permission");
return;
}
List<String> actionStrings = new ArrayList<>();
ConfigurationNode actionConfig = config.node("actions");
MessagesUtil.sendDebugMessages("Running Actions");
try {
if (!actionConfig.node("any").virtual()) actionStrings.addAll(actionConfig.node("any").getList(String.class));
@@ -68,7 +78,7 @@ public class TypeCosmetic extends Type {
if (!actionConfig.node("on-equip").virtual()) actionStrings.addAll(actionConfig.node("on-equip").getList(String.class));
MessagesUtil.sendDebugMessages("on-equip");
// TODO: Redo this
if (cosmetic.isDyable()) {
if (cosmetic.isDyable() && Hooks.isActiveHook("HMCColor")) {
DyeMenu.openMenu(user, cosmetic);
} else {
user.addPlayerCosmetic(cosmetic);
@@ -78,74 +88,83 @@ public class TypeCosmetic extends Type {
Actions.runActions(user, actionStrings);
} catch (SerializationException e) {
throw new RuntimeException(e);
e.printStackTrace();
}
// Fixes issue with offhand cosmetics not appearing. Yes, I know this is dumb
Runnable run = () -> user.updateCosmetic(cosmetic.getSlot());
if (cosmetic instanceof CosmeticArmorType) {
if (((CosmeticArmorType) cosmetic).getEquipSlot().equals(EquipmentSlot.OFF_HAND)) {
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), run, 1);
return;
}
}
run.run();
MessagesUtil.sendDebugMessages("Finished Type Click Run");
}
@Override
public ItemMeta setLore(CosmeticUser user, ConfigurationNode config, ItemMeta itemMeta) {
List<String> processedLore = new ArrayList<>();
public ItemStack setItem(CosmeticUser user, @NotNull ConfigurationNode config, ItemStack itemStack, int slot) {
itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
if (config.node("cosmetic").virtual()) return processLoreLines(user, itemMeta);;
if (config.node("cosmetic").virtual()) {
return itemStack;
}
String cosmeticName = config.node("cosmetic").getString();
Cosmetic cosmetic = Cosmetics.getCosmetic(cosmeticName);
if (cosmetic == null) {
return processLoreLines(user, itemMeta);
return itemStack;
}
if (user.canEquipCosmetic(cosmetic)) {
return processLoreLines(user, itemMeta);
} else {
ConfigurationNode itemConfig = config.node("item");
if (itemConfig.virtual()) return itemMeta;
if (itemConfig.node("locked-name").virtual() && itemConfig.node("locked-name").virtual()) {
return processLoreLines(user, itemMeta);
if (user.hasCosmeticInSlot(cosmetic) && !config.node("equipped-item").virtual()) {
MessagesUtil.sendDebugMessages("GUI Equipped Item");
ConfigurationNode equippedItem = config.node("equipped-item");
try {
if (equippedItem.node("material").virtual()) equippedItem.node("material").set(config.node("item", "material").getString());
} catch (SerializationException e) {
// Nothing >:)
}
try {
itemMeta.getLore().clear();
List<String> lockedLore = Utils.replaceIfNull(itemConfig.node("locked-lore").getList(String.class),
new ArrayList<String>()).
stream().map(StringUtils::parseStringToString).collect(Collectors.toList());
if (PAPIHook.isPAPIEnabled()) {
String lockedName = StringUtils.parseStringToString(Utils.replaceIfNull(itemConfig.node("locked-name").getString(), ""));
itemMeta.setDisplayName(PlaceholderAPI.setPlaceholders(user.getPlayer(), lockedName));
if (itemMeta.hasLore()) {
for (String loreLine : lockedLore) {
processedLore.add(PlaceholderAPI.setPlaceholders(user.getPlayer(), loreLine));
}
}
}
} catch (Exception e) {
e.printStackTrace();
itemStack = ItemSerializer.INSTANCE.deserialize(ItemStack.class, equippedItem);
} catch (SerializationException e) {
throw new RuntimeException(e);
}
itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
return itemStack;
}
itemMeta.setLore(processedLore);
return itemMeta;
if (!user.canEquipCosmetic(cosmetic) && !config.node("locked-item").virtual()) {
MessagesUtil.sendDebugMessages("GUI Locked Item");
ConfigurationNode lockedItem = config.node("locked-item");
try {
if (lockedItem.node("material").virtual()) lockedItem.node("material").set(config.node("item", "material").getString());
} catch (SerializationException e) {
// Nothing >:)
}
try {
itemStack = ItemSerializer.INSTANCE.deserialize(ItemStack.class, lockedItem);
} catch (SerializationException e) {
throw new RuntimeException(e);
}
itemStack.setItemMeta(processLoreLines(user, itemStack.getItemMeta()));
return itemStack;
}
return itemStack;
}
private ItemMeta processLoreLines(CosmeticUser user, ItemMeta itemMeta) {
@Contract("_, _ -> param2")
@NotNull
@SuppressWarnings("Duplicates")
private ItemMeta processLoreLines(CosmeticUser user, @NotNull ItemMeta itemMeta) {
List<String> processedLore = new ArrayList<>();
if (PAPIHook.isPAPIEnabled()) {
if (itemMeta.hasLore()) {
for (String loreLine : itemMeta.getLore()) {
processedLore.add(PlaceholderAPI.setPlaceholders(user.getPlayer(), loreLine));
}
}
if (itemMeta.hasDisplayName()) {
itemMeta.setDisplayName(Hooks.processPlaceholders(user.getPlayer(), itemMeta.getDisplayName()));
}
if (itemMeta.hasLore()) {
for (String loreLine : itemMeta.getLore()) {
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
}
}
itemMeta.setLore(processedLore);
return itemMeta;
}

View File

@@ -2,11 +2,12 @@ package com.hibiscusmc.hmccosmetics.gui.type.types;
import com.hibiscusmc.hmccosmetics.gui.action.Actions;
import com.hibiscusmc.hmccosmetics.gui.type.Type;
import com.hibiscusmc.hmccosmetics.hooks.PAPIHook;
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
@@ -16,7 +17,6 @@ import java.util.List;
public class TypeEmpty extends Type {
// This can be used as an example for making your own types.
public TypeEmpty() {
super("empty");
// This is an empty type, meaning, when a menu item has a type of "empty" it will run the code in the method run.
@@ -24,7 +24,7 @@ public class TypeEmpty extends Type {
// This is the code that's run when the item is clicked.
@Override
public void run(CosmeticUser user, ConfigurationNode config, ClickType clickType) {
public void run(CosmeticUser user, @NotNull ConfigurationNode config, ClickType clickType) {
List<String> actionStrings = new ArrayList<>(); // List where we keep the actions the server will execute.
ConfigurationNode actionConfig = config.node("actions"); // Configuration node that actions are under.
@@ -32,7 +32,7 @@ public class TypeEmpty extends Type {
try {
// This gets the actions with the item. We can add more, such as with the Cosmetic type, an equip and unequip action set.
// We add that to a List of Strings, before running those actions through the server. This is not the area where we deal
// with actions, mearly what should be done for each item.
// with actions, merely what should be done for each item.
if (!actionConfig.node("any").virtual()) actionStrings.addAll(actionConfig.node("any").getList(String.class));
if (clickType != null) {
@@ -52,18 +52,22 @@ public class TypeEmpty extends Type {
}
@Override
public ItemMeta setLore(CosmeticUser user, ConfigurationNode config, ItemMeta itemMeta) {
@SuppressWarnings("Duplicates")
public ItemStack setItem(CosmeticUser user, ConfigurationNode config, @NotNull ItemStack itemStack, int slot) {
List<String> processedLore = new ArrayList<>();
ItemMeta itemMeta = itemStack.getItemMeta();
if (PAPIHook.isPAPIEnabled()) {
if (itemMeta.hasLore()) {
for (String loreLine : itemMeta.getLore()) {
processedLore.add(PlaceholderAPI.setPlaceholders(user.getPlayer(), loreLine));
}
}
if (itemMeta.hasDisplayName()) {
itemMeta.setDisplayName(Hooks.processPlaceholders(user.getPlayer(), itemMeta.getDisplayName()));
}
return itemMeta;
if (itemMeta.hasLore()) {
for (String loreLine : itemMeta.getLore()) {
processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
}
}
itemStack.setItemMeta(itemMeta);
return itemStack;
}
// That's it! Now, add it as a static in another one of your classes (such as your main class) and you are good to go.

View File

@@ -0,0 +1,93 @@
package com.hibiscusmc.hmccosmetics.hooks;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents a hook into other minecraft plugins
*/
public abstract class Hook implements Listener {
private final String id;
private boolean active = false;
private boolean itemHook = false;
public Hook(@NotNull String id) {
this.id = id;
Hooks.addHook(this);
}
/**
* Loads this hook
*
* @implNote By default, this method does nothing. It should be overridden by child classes to implement any necessary loading logic
*/
public void load() { }
/**
* Gets an {@link ItemStack} that is associated with the provided id from the hooked plugin
* @param itemId The id of the {@link ItemStack}
* @return The {@link ItemStack} with the id provided. If an invalid id was provided or if the hook doesn't have any related {@link ItemStack}s then this will return null
* @implNote By default, this method returns null. It should be overridden by child classes if you will to have your hook return a related {@link ItemStack}
*/
@Nullable
public ItemStack getItem(@NotNull String itemId) {
return null;
}
/**
* Gets the id of this hook
*
* @return The unique id for this hook
*/
@NotNull
public final String getId() {
return id;
}
/**
* Gets whether this hook has been activated
* @return true if this hook is active, false otherwise
* @deprecated As of release 2.2.5+, replaced by {@link #isActive()}
*/
@Deprecated
public boolean getActive() {
return this.active;
}
/**
* Gets whether this hook has been activated
* @return true if this hook is active, false otherwise
* @since 2.2.5
*/
public final boolean isActive() {
return this.active;
}
/**
* Sets whether this hook is active
* @param active true to activate the hook, false otherwise
*/
public final void setActive(boolean active) {
this.active = active;
}
/**
* Whether the method {@link #getItem(String)} should return a non-null value
* @return true if {@link #getItem(String)} should return a non-null value, false otherwise
*
* @apiNote Even though this method returns true does not mean that {@link #getItem(String)} won't return null, rather if this returns false then {@link #getItem(String)} should return false everytime
*/
public final boolean hasEnabledItemHook() {
return itemHook;
}
/**
* Sets whether the method {@link #getItem(String)} should return a non-null value
* @param enabled true if {@link #getItem(String)} should return a non-null value, false otherwise
*/
public final void setEnabledItemHook(boolean enabled) {
itemHook = enabled;
}
}

View File

@@ -0,0 +1,87 @@
package com.hibiscusmc.hmccosmetics.hooks;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.hooks.items.*;
import com.hibiscusmc.hmccosmetics.hooks.misc.*;
import com.hibiscusmc.hmccosmetics.hooks.placeholders.HookPlaceholderAPI;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
public class Hooks {
private static final HashMap<String, Hook> hooks = new HashMap<>();
private static HookOraxen ORAXEN_HOOK = new HookOraxen();
private static HookItemAdder ITEMADDER_HOOK = new HookItemAdder();
private static HookGeary GEARY_HOOK = new HookGeary();
private static HookMythic MYTHIC_HOOK = new HookMythic();
private static HookDenizen DENIZEN_HOOK = new HookDenizen();
private static HookHMCCosmetics HMCCOSMETIC_HOOK = new HookHMCCosmetics();
private static HookPlaceholderAPI PAPI_HOOK = new HookPlaceholderAPI();
private static HookPremiumVanish PREMIUM_VANISH_HOOK = new HookPremiumVanish();
private static HookSuperVanish SUPER_VANISH_HOOK = new HookSuperVanish();
private static HookHMCColor HMC_COLOR_HOOK = new HookHMCColor();
private static HookCMI CMI_HOOK = new HookCMI();
private static HookLibsDisguises LIBS_DISGUISES_HOOK = new HookLibsDisguises();
private static HookModelEngine MODEL_ENGINE_HOOK = new HookModelEngine();
public static Hook getHook(@NotNull String id) {
return hooks.get(id.toLowerCase());
}
public static boolean isItemHook(@NotNull String id) {
return hooks.containsKey(id.toLowerCase());
}
public static void addHook(Hook hook) {
hooks.put(hook.getId().toLowerCase(), hook);
}
public static void setup() {
for (Hook hook : hooks.values()) {
if (Bukkit.getPluginManager().getPlugin(hook.getId()) != null) {
HMCCosmeticsPlugin.getInstance().getServer().getPluginManager().registerEvents(hook, HMCCosmeticsPlugin.getInstance());
hook.setActive(true);
hook.load();
HMCCosmeticsPlugin.getInstance().getLogger().info("Successfully hooked into " + hook.getId());
}
}
}
@Nullable
public static ItemStack getItem(@NotNull String raw) {
if (!raw.contains(":")) {
Material mat = Material.getMaterial(raw.toUpperCase());
if (mat == null) return null;
return new ItemStack(mat);
}
// Ex. Oraxen:BigSword
// split[0] is the plugin name
// split[1] is the item name
String[] split = raw.split(":", 2);
if (!isItemHook(split[0])) return null;
Hook hook = getHook(split[0]);
if (!hook.hasEnabledItemHook()) return null;
if (!hook.isActive()) return null;
return hook.getItem(split[1]);
}
@NotNull
public static String processPlaceholders(OfflinePlayer player, String raw) {
if (getHook("PlaceholderAPI").isActive()) return PlaceholderAPI.setPlaceholders(player, raw);
return raw;
}
public static boolean isActiveHook(String id) {
Hook hook = getHook(id);
if (hook == null) return false;
return hook.isActive();
}
}

View File

@@ -1,166 +0,0 @@
package com.hibiscusmc.hmccosmetics.hooks;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.List;
public class PAPIHook extends PlaceholderExpansion {
private static boolean papiEnabled = false;
public PAPIHook() {
papiEnabled = true;
}
@Override
public @NotNull String getIdentifier() {
return "HMCCosmetics";
}
@Override
public @NotNull String getAuthor() {
return "HibiscusMC";
}
@Override
public @NotNull String getVersion() {
return HMCCosmeticsPlugin.getInstance().getDescription().getVersion();
}
@Override
public String onRequest(OfflinePlayer player, String params) {
if (!player.isOnline()) return null;
CosmeticUser user = CosmeticUsers.getUser(player.getPlayer());
if (user == null) return null;
List<String> placeholderArgs = Arrays.asList(params.split("_", 3));
switch (placeholderArgs.get(0).toLowerCase()) {
case "using":
if (placeholderArgs == null) {
return null;
}
if (placeholderArgs.get(1) != null) {
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
if (user.getCosmetic(cosmetic.getSlot()).getId() == cosmetic.getId()) return "true";
return "false";
}
case "current":
if (placeholderArgs == null) {
return null;
}
if (placeholderArgs.get(1) != null) {
CosmeticSlot slot = CosmeticSlot.valueOf(placeholderArgs.get(1).toUpperCase());
if (slot == null) return null;
if (placeholderArgs.size() == 2) return user.getCosmetic(slot).getId();
switch (placeholderArgs.get(2).toLowerCase()) {
case "material" -> {
return getMaterial(user.getCosmetic(slot));
}
case "custommodeldata" -> {
return getModelData(user.getCosmetic(slot));
}
case "name" -> {
return getItemName(user.getCosmetic(slot));
}
case "lore" -> {
return getItemLore(user.getCosmetic(slot));
}
case "permission" -> {
return user.getCosmetic(slot).getPermission();
}
default -> {
return user.getCosmetic(slot).getId();
}
}
}
case "unlocked":
if (placeholderArgs == null) {
return null;
}
if (placeholderArgs.get(1) != null) {
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
if (cosmetic == null) {
Cosmetic secondAttemptCosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1) + "_" + placeholderArgs.get(2));
if (secondAttemptCosmetic == null) {
return "INVALID_COSMETIC";
} else {
cosmetic = secondAttemptCosmetic;
}
}
return TranslationUtil.getTranslation("unlockedCosmetic", String.valueOf(user.canEquipCosmetic(cosmetic)));
}
case "equipped":
if (placeholderArgs == null) {
return null;
}
if (placeholderArgs.get(1) != null) {
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
if (cosmetic == null) {
Cosmetic secondAttemptCosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1) + "_" + placeholderArgs.get(2));
if (secondAttemptCosmetic == null) {
return "INVALID_COSMETIC";
} else {
cosmetic = secondAttemptCosmetic;
}
}
if (user.getCosmetic(cosmetic.getSlot()) == null) return "false";
if (cosmetic.getId() == user.getCosmetic(cosmetic.getSlot()).getId()) {
return "true";
} else {
return "false";
}
}
case "wardrobe-enabled":
return String.valueOf(user.isInWardrobe());
}
return null;
}
public String getMaterial(Cosmetic cosmetic) {
ItemStack item = cosmetic.getItem();
if (item == null) return null;
return cosmetic.getItem().getType().toString();
}
public String getModelData(Cosmetic cosmetic) {
ItemStack item = cosmetic.getItem();
if (item == null) return null;
if (!item.hasItemMeta()) return null;
ItemMeta itemMeta = item.getItemMeta();
return String.valueOf(itemMeta.getCustomModelData());
}
public String getItemName(Cosmetic cosmetic) {
ItemStack item = cosmetic.getItem();
if (item == null) return null;
if (!item.hasItemMeta()) return null;
ItemMeta itemMeta = item.getItemMeta();
return itemMeta.getDisplayName();
}
public String getItemLore(Cosmetic cosmetic) {
ItemStack item = cosmetic.getItem();
if (item == null) return null;
if (item.hasItemMeta()) {
return String.valueOf(item.getItemMeta().getLore());
}
return null;
}
public static boolean isPAPIEnabled() {
return papiEnabled;
}
}

View File

@@ -1,21 +0,0 @@
package com.hibiscusmc.hmccosmetics.hooks.items;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
public class HMCCosmeticsHook extends ItemHook implements Listener {
public HMCCosmeticsHook() {
super("HMCCosmetics");
}
@Override
public ItemStack get(String itemid) {
Cosmetic cosmetic = Cosmetics.getCosmetic(itemid);
if (cosmetic == null) return null;
return cosmetic.getItem();
}
}

View File

@@ -0,0 +1,27 @@
package com.hibiscusmc.hmccosmetics.hooks.items;
import com.denizenscript.denizen.objects.ItemTag;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import com.hibiscusmc.hmccosmetics.hooks.Hook;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* A hook that integrates the plugin {@link com.denizenscript.denizen.Denizen Denizen} to provide custom items
*/
@SuppressWarnings("SpellCheckingInspection")
public class HookDenizen extends Hook {
public HookDenizen() {
super("denizen");
setEnabledItemHook(true);
}
/**
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.denizenscript.denizen.Denizen Denizen}
*/
@Override
public ItemStack getItem(@NotNull String itemId) {
ItemTag item = ItemTag.valueOf(itemId, CoreUtilities.noDebugContext);
return item == null ? null : item.getItemStack();
}
}

View File

@@ -0,0 +1,45 @@
package com.hibiscusmc.hmccosmetics.hooks.items;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.hooks.Hook;
import com.mineinabyss.geary.addons.GearyPhase;
import com.mineinabyss.geary.modules.GearyModuleKt;
import com.mineinabyss.geary.papermc.tracking.items.ItemTrackingKt;
import com.mineinabyss.geary.prefabs.PrefabKey;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* A hook that integrates the plugin {@link com.mineinabyss.geary.papermc.GearyPlugin Geary} to provide custom items
*/
@SuppressWarnings("SpellCheckingInspection")
public class HookGeary extends Hook {
private boolean enabled = false;
public HookGeary() {
super("geary");
setEnabledItemHook(true);
}
@Override
public void load() {
GearyModuleKt.getGeary().getPipeline().intercept(GearyPhase.ENABLE, () -> {
enabled = true;
HMCCosmeticsPlugin.setup();
return null;
});
}
/**
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.mineinabyss.geary.papermc.GearyPlugin Geary}
*/
@Override
public ItemStack getItem(@NotNull String itemId) {
if (enabled) {
PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId);
if (prefabKey == null) return null;
return ItemTrackingKt.getGearyItems().createItem(prefabKey, null);
} else return new ItemStack(Material.AIR);
}
}

View File

@@ -0,0 +1,28 @@
package com.hibiscusmc.hmccosmetics.hooks.items;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
import com.hibiscusmc.hmccosmetics.hooks.Hook;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* A hook that integrates the plugin {@link com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin HMCCosmetics} to provide cosmetic items
*/
public class HookHMCCosmetics extends Hook {
public HookHMCCosmetics() {
super("HMCCosmetics");
setEnabledItemHook(true);
}
/**
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin HMCCosmetics}
*/
@Override
public ItemStack getItem(@NotNull String itemId) {
Cosmetic cosmetic = Cosmetics.getCosmetic(itemId);
if (cosmetic == null) return null;
return cosmetic.getItem();
}
}

View File

@@ -0,0 +1,46 @@
package com.hibiscusmc.hmccosmetics.hooks.items;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.hooks.Hook;
import dev.lone.itemsadder.api.CustomStack;
import dev.lone.itemsadder.api.Events.ItemsAdderLoadDataEvent;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* A hook that integrates the plugin {@link dev.lone.itemsadder.api.ItemsAdder ItemsAdder} to provide custom items
*/
@SuppressWarnings("SpellCheckingInspection")
public class HookItemAdder extends Hook {
private boolean enabled = false;
public HookItemAdder() {
super("itemsadder");
setEnabledItemHook(true);
}
/**
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link dev.lone.itemsadder.api.ItemsAdder ItemsAdder}
*/
@Override
public ItemStack getItem(@NotNull String itemId) {
if (enabled) {
CustomStack stack = CustomStack.getInstance(itemId);
if (stack == null) return null;
return stack.getItemStack();
} else {
return new ItemStack(Material.AIR);
}
}
@EventHandler
public void onItemAdderDataLoad(ItemsAdderLoadDataEvent event) {
// By default, it will only run once at startup, if hook setting is enabled
if (enabled && !Settings.getItemsAdderReloadChange()) return;
this.enabled = true;
HMCCosmeticsPlugin.setup();
}
}

View File

@@ -0,0 +1,25 @@
package com.hibiscusmc.hmccosmetics.hooks.items;
import com.hibiscusmc.hmccosmetics.hooks.Hook;
import io.lumine.mythic.bukkit.MythicBukkit;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* A hook that integrates the plugin {@link io.lumine.mythic.bukkit.MythicBukkit MythicBukkit} to provide custom items
*/
@SuppressWarnings("SpellCheckingInspection")
public class HookMythic extends Hook {
public HookMythic() {
super("mythicmobs");
setEnabledItemHook(true);
}
/**
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link io.lumine.mythic.bukkit.MythicBukkit MythicBukkit}
*/
@Override
public ItemStack getItem(@NotNull String itemId) {
return MythicBukkit.inst().getItemManager().getItemStack(itemId);
}
}

View File

@@ -0,0 +1,28 @@
package com.hibiscusmc.hmccosmetics.hooks.items;
import com.hibiscusmc.hmccosmetics.hooks.Hook;
import io.th0rgal.oraxen.api.OraxenItems;
import io.th0rgal.oraxen.items.ItemBuilder;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* A hook that integrates the plugin {@link io.th0rgal.oraxen.OraxenPlugin OraxenPlugin} to provide custom items
*/
@SuppressWarnings("SpellCheckingInspection")
public class HookOraxen extends Hook {
public HookOraxen() {
super("oraxen");
setEnabledItemHook(true);
}
/**
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link io.th0rgal.oraxen.OraxenPlugin OraxenPlugin}
*/
@Override
public ItemStack getItem(@NotNull String itemId) {
ItemBuilder builder = OraxenItems.getItemById(itemId);
if (builder == null) return null;
return builder.build();
}
}

View File

@@ -1,38 +0,0 @@
package com.hibiscusmc.hmccosmetics.hooks.items;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import dev.lone.itemsadder.api.CustomStack;
import dev.lone.itemsadder.api.Events.ItemsAdderLoadDataEvent;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
public class ItemAdderHook extends ItemHook implements Listener {
// I hate IA, this overcomplicate stuff is so unneeded if it just did its stuff when its needed.
private boolean enabled = false;
public ItemAdderHook() {
super("itemsadder");
}
@Override
public ItemStack get(String itemid) {
if (enabled) {
CustomStack stack = CustomStack.getInstance(itemid);
if (stack == null) return null;
return stack.getItemStack();
} else {
return new ItemStack(Material.AIR);
}
}
@EventHandler
public void onItemAdderDataLoad(ItemsAdderLoadDataEvent event) {
if (this.enabled) return;
this.enabled = true;
HMCCosmeticsPlugin.setup();
}
}

View File

@@ -1,33 +0,0 @@
package com.hibiscusmc.hmccosmetics.hooks.items;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
public class ItemHook implements Listener {
private String id;
private boolean active;
public ItemHook(String id) {
this.id = id;
active = false;
ItemHooks.addItemHook(this);
}
public ItemStack get(String itemid) {
return null;
// Override
}
public String getId() {
return id;
}
public void setActive(boolean active) {
this.active = active;
}
public boolean getActive() {
return this.active;
}
}

View File

@@ -1,57 +0,0 @@
package com.hibiscusmc.hmccosmetics.hooks.items;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
public class ItemHooks {
private static HashMap<String, ItemHook> itemHooks = new HashMap<>();
private static OraxenHook ORAXEN_HOOK = new OraxenHook();
private static ItemAdderHook ITEMADDER_HOOK = new ItemAdderHook();
private static MythicHook MYTHIC_HOOK = new MythicHook();
private static HMCCosmeticsHook HMCCOSMETIC_HOOK = new HMCCosmeticsHook();
public static ItemHook getItemHook(String id) {
return itemHooks.get(id.toLowerCase());
}
public static boolean isItemHook(String id) {
return itemHooks.containsKey(id.toLowerCase());
}
public static void addItemHook(ItemHook hook) {
itemHooks.put(hook.getId().toLowerCase(), hook);
}
public static void setup() {
for (ItemHook itemHook : itemHooks.values()) {
if (Bukkit.getPluginManager().getPlugin(itemHook.getId()) != null) {
HMCCosmeticsPlugin.getInstance().getServer().getPluginManager().registerEvents(itemHook, HMCCosmeticsPlugin.getInstance());
itemHook.setActive(true);
HMCCosmeticsPlugin.getInstance().getLogger().info("Successfully hooked into " + itemHook.getId());
}
}
}
public static ItemStack getItem(String raw) {
if (!raw.contains(":")) {
Material mat = Material.getMaterial(raw.toUpperCase());
if (mat == null) return null;
return new ItemStack(mat);
}
// Ex. Oraxen:BigSword
// split[0] is the plugin name
// split[1] is the item name
String[] split = raw.split(":", 2);
if (!isItemHook(split[0])) return null;
ItemHook itemHook = getItemHook(split[0]);
if (!itemHook.getActive()) return null;
ItemStack item = itemHook.get(split[1]);
return item;
}
}

View File

@@ -1,16 +0,0 @@
package com.hibiscusmc.hmccosmetics.hooks.items;
import io.lumine.mythic.bukkit.MythicBukkit;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
public class MythicHook extends ItemHook implements Listener {
public MythicHook() {
super("mythicmobs");
}
@Override
public ItemStack get(String itemid) {
return MythicBukkit.inst().getItemManager().getItemStack(itemid);
}
}

View File

@@ -1,17 +0,0 @@
package com.hibiscusmc.hmccosmetics.hooks.items;
import io.th0rgal.oraxen.api.OraxenItems;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
public class OraxenHook extends ItemHook implements Listener {
public OraxenHook() {
super("oraxen");
}
@Override
public ItemStack get(String itemid) {
return OraxenItems.getItemById(itemid).build();
}
}

View File

@@ -0,0 +1,35 @@
package com.hibiscusmc.hmccosmetics.hooks.misc;
import com.Zrips.CMI.events.CMIPlayerUnVanishEvent;
import com.Zrips.CMI.events.CMIPlayerVanishEvent;
import com.hibiscusmc.hmccosmetics.hooks.Hook;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.jetbrains.annotations.NotNull;
/**
* A hook that integrates the plugin {@link com.Zrips.CMI.CMI CMI}
*/
public class HookCMI extends Hook {
public HookCMI() {
super("CMI");
}
@EventHandler
public void onPlayerVanish(@NotNull CMIPlayerVanishEvent event) {
Player player = event.getPlayer();
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null) return;
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
}
@EventHandler
public void onPlayerShow(@NotNull CMIPlayerUnVanishEvent event) {
Player player = event.getPlayer();
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null) return;
user.showCosmetics();
}
}

View File

@@ -0,0 +1,12 @@
package com.hibiscusmc.hmccosmetics.hooks.misc;
import com.hibiscusmc.hmccosmetics.hooks.Hook;
/**
* A hook that integrates the plugin {@link com.hibiscusmc.hmccolor.HMCColor HMCColor}
*/
public class HookHMCColor extends Hook {
public HookHMCColor() {
super("HMCColor");
}
}

View File

@@ -0,0 +1,32 @@
package com.hibiscusmc.hmccosmetics.hooks.misc;
import com.hibiscusmc.hmccosmetics.hooks.Hook;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import me.libraryaddict.disguise.events.DisguiseEvent;
import me.libraryaddict.disguise.events.UndisguiseEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.jetbrains.annotations.NotNull;
public class HookLibsDisguises extends Hook {
public HookLibsDisguises() {
super("LibsDisguises");
}
@EventHandler
public void onPlayerVanish(@NotNull DisguiseEvent event) {
if (!(event.getEntity() instanceof Player player)) return;
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null) return;
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
}
@EventHandler
public void onPlayerShow(@NotNull UndisguiseEvent event) {
if (!(event.getEntity() instanceof Player player)) return;
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null) return;
user.showCosmetics();
}
}

View File

@@ -0,0 +1,10 @@
package com.hibiscusmc.hmccosmetics.hooks.misc;
import com.hibiscusmc.hmccosmetics.hooks.Hook;
public class HookModelEngine extends Hook {
public HookModelEngine() {
super("ModelEngine");
}
}

View File

@@ -0,0 +1,37 @@
package com.hibiscusmc.hmccosmetics.hooks.misc;
import com.hibiscusmc.hmccosmetics.hooks.Hook;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import de.myzelyam.api.vanish.PlayerHideEvent;
import de.myzelyam.api.vanish.PlayerShowEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.jetbrains.annotations.NotNull;
/**
* A hook that integrates the plugin {@link de.myzelyam.api.vanish.VanishAPI Supervanish}
*
* @implSpec Supervanish and Premium Vanish both use the same api
*/
public class HookPremiumVanish extends Hook {
public HookPremiumVanish() {
super("PremiumVanish");
}
@EventHandler
public void onPlayerVanish(@NotNull PlayerHideEvent event) {
Player player = event.getPlayer();
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null) return;
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
}
@EventHandler
public void onPlayerShow(@NotNull PlayerShowEvent event) {
Player player = event.getPlayer();
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null) return;
user.showCosmetics();
}
}

View File

@@ -0,0 +1,37 @@
package com.hibiscusmc.hmccosmetics.hooks.misc;
import com.hibiscusmc.hmccosmetics.hooks.Hook;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import de.myzelyam.api.vanish.PlayerHideEvent;
import de.myzelyam.api.vanish.PlayerShowEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.jetbrains.annotations.NotNull;
/**
* A hook that integrates the plugin {@link de.myzelyam.api.vanish.VanishAPI Supervanish}
*
* @implSpec Supervanish and Premium Vanish both use the same api
*/
public class HookSuperVanish extends Hook {
public HookSuperVanish() {
super("SuperVanish");
}
@EventHandler
public void onPlayerVanish(@NotNull PlayerHideEvent event) {
Player player = event.getPlayer();
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null) return;
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
}
@EventHandler
public void onPlayerShow(@NotNull PlayerShowEvent event) {
Player player = event.getPlayer();
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null) return;
user.showCosmetics();
}
}

View File

@@ -0,0 +1,237 @@
package com.hibiscusmc.hmccosmetics.hooks.placeholders;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.apache.commons.lang3.EnumUtils;
import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.List;
/**
* A hook that integrates the plugin {@link me.clip.placeholderapi.PlaceholderAPIPlugin PlaceholderAPIPlugin}
*/
public class HMCPlaceholderExpansion extends PlaceholderExpansion {
private static boolean papiEnabled = false;
public HMCPlaceholderExpansion() {
papiEnabled = true;
}
@Override
@NotNull
public String getIdentifier() {
return "HMCCosmetics";
}
@Override
@NotNull
public String getAuthor() {
return "HibiscusMC";
}
@Override
@NotNull
public String getVersion() {
return HMCCosmeticsPlugin.getInstance().getDescription().getVersion();
}
@Override
public boolean persist() {
return true;
}
@Override
public String onRequest(@NotNull OfflinePlayer player, @NotNull String params) {
if (!player.isOnline()) return null;
CosmeticUser user = CosmeticUsers.getUser(player.getPlayer());
if (user == null) return null;
List<String> placeholderArgs = Arrays.asList(params.split("_", 3));
switch (placeholderArgs.get(0).toLowerCase()) {
case "using":
if (placeholderArgs == null) {
return null;
}
if (placeholderArgs.get(1) != null) {
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
if (cosmetic == null) return "INVALID_COSMETIC";
Cosmetic currentCosmetic = user.getCosmetic(cosmetic.getSlot());
if (currentCosmetic == null) return TranslationUtil.getTranslation("using-cosmetic", String.valueOf(false)); // I hate this way of handling translations
if (currentCosmetic.getId() == cosmetic.getId()) return TranslationUtil.getTranslation("using-cosmetic", String.valueOf(true));
return TranslationUtil.getTranslation("using-cosmetic", String.valueOf(false));
}
case "current":
if (placeholderArgs == null) {
return null;
}
if (placeholderArgs.get(1) != null) {
CosmeticSlot slot = CosmeticSlot.valueOf(placeholderArgs.get(1).toUpperCase());
if (slot == null) return null;
if (user.getCosmetic(slot) == null) return null;
if (placeholderArgs.size() == 2) return user.getCosmetic(slot).getId();
String output;
switch (placeholderArgs.get(2).toLowerCase()) {
case "material" -> {
output = getMaterialName(user.getCosmetic(slot));
}
case "custommodeldata" -> {
output = getModelData(user.getCosmetic(slot));
}
case "name" -> {
output = getItemName(user.getCosmetic(slot));
}
case "lore" -> {
output = getItemLore(user.getCosmetic(slot));
}
case "permission" -> {
output = user.getCosmetic(slot).getPermission();
}
default -> {
output = user.getCosmetic(slot).getId();
}
}
return TranslationUtil.getTranslation("current-cosmetic", String.valueOf(output));
}
case "unlocked":
if (placeholderArgs == null) {
return null;
}
if (placeholderArgs.get(1) != null) {
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
if (cosmetic == null) {
if (placeholderArgs.size() >= 3) {
Cosmetic secondAttemptCosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1) + "_" + placeholderArgs.get(2));
if (secondAttemptCosmetic == null) {
return "INVALID_COSMETIC";
} else {
cosmetic = secondAttemptCosmetic;
}
} else {
return "INVALID_COSMETIC";
}
}
return TranslationUtil.getTranslation("unlocked-cosmetic", String.valueOf(user.canEquipCosmetic(cosmetic)));
}
case "equipped":
if (placeholderArgs == null) {
return null;
}
if (placeholderArgs.get(1) != null) {
String args1 = placeholderArgs.get(1);
if (EnumUtils.isValidEnum(CosmeticSlot.class, args1.toUpperCase())) {
return TranslationUtil.getTranslation("equipped-cosmetic", String.valueOf(user.getCosmetic(CosmeticSlot.valueOf(args1.toUpperCase())) != null));
}
MessagesUtil.sendDebugMessages(args1);
Cosmetic cosmetic = Cosmetics.getCosmetic(args1);
if (cosmetic == null) {
if (placeholderArgs.size() == 3) {
Cosmetic secondAttemptCosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1) + "_" + placeholderArgs.get(2));
if (secondAttemptCosmetic == null) {
return "INVALID_COSMETIC";
} else {
cosmetic = secondAttemptCosmetic;
}
} else {
return "INVALID_COSMETIC";
}
}
if (user.getCosmetic(cosmetic.getSlot()) == null) return "false";
return TranslationUtil.getTranslation("equipped-cosmetic", String.valueOf(cosmetic.getId() == user.getCosmetic(cosmetic.getSlot()).getId()));
}
case "wardrobe-enabled":
return TranslationUtil.getTranslation("in-wardrobe", String.valueOf(user.isInWardrobe()));
}
return null;
}
/**
* Gets the name of the cosmetic item {@link org.bukkit.Material Material}
* @param cosmetic The cosmetic to get its {@link org.bukkit.Material Material}s name
* @return The name of the cosmetic item {@link org.bukkit.Material Material}
* @deprecated As of release 2.2.5+, use {@link #getMaterialName(Cosmetic)} instead
*/
@Deprecated
@Nullable
public String getMaterial(@NotNull Cosmetic cosmetic) {
ItemStack item = cosmetic.getItem();
if (item == null) return null;
return item.getType().toString();
}
/**
* Gets the name of the cosmetic item {@link org.bukkit.Material Material}
* @param cosmetic The cosmetic to get its {@link org.bukkit.Material Material}s name
* @return The name of the cosmetic item {@link org.bukkit.Material Material}
* @since 2.2.5
*/
@Nullable
public String getMaterialName(@NotNull Cosmetic cosmetic) {
ItemStack item = cosmetic.getItem();
if (item == null) return null;
return item.getType().toString();
}
/**
* Gets the cosmetic items custom model data
* @param cosmetic The cosmetic to get its custom model data
* @return The cosmetic items custom model data
*/
@Nullable
public String getModelData(@NotNull Cosmetic cosmetic) {
ItemStack item = cosmetic.getItem();
if (item == null) return null;
if (!item.hasItemMeta()) return null;
ItemMeta itemMeta = item.getItemMeta();
if (itemMeta == null) return null;
return String.valueOf(itemMeta.getCustomModelData());
}
/**
* Gets the cosmetic items display name
* @param cosmetic The cosmetic to get its items display name
* @return The cosmetic items display name
*/
@Nullable
public String getItemName(@NotNull Cosmetic cosmetic) {
ItemStack item = cosmetic.getItem();
if (item == null) return null;
if (!item.hasItemMeta()) return null;
ItemMeta itemMeta = item.getItemMeta();
if (itemMeta == null) return null;
return itemMeta.getDisplayName();
}
/**
* Gets the cosmetic items lore
* @param cosmetic The cosmetic to get its items lore
* @return The cosmetic items lore
*/
@Nullable
public String getItemLore(@NotNull Cosmetic cosmetic) {
ItemStack item = cosmetic.getItem();
if (item == null) return null;
if (item.hasItemMeta()) {
ItemMeta itemMeta = item.getItemMeta();
if (itemMeta == null) return null;
return String.valueOf(itemMeta.getLore());
}
return null;
}
}

View File

@@ -0,0 +1,20 @@
package com.hibiscusmc.hmccosmetics.hooks.placeholders;
import com.hibiscusmc.hmccosmetics.hooks.Hook;
/**
* A hook that integrates the plugin {@link me.clip.placeholderapi.PlaceholderAPI PlaceholderAPI}
*/
public class HookPlaceholderAPI extends Hook {
public HookPlaceholderAPI() {
super("PlaceholderAPI");
}
/**
* Registers HMCCosmetics Placeholder Expansion
*/
@Override
public void load() {
new HMCPlaceholderExpansion().register();
}
}

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