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

Compare commits

...

165 Commits

Author SHA1 Message Date
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
82 changed files with 1788 additions and 465 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.

View File

@@ -8,7 +8,7 @@ plugins {
}
group = "com.hibiscusmc"
version = "2.2.5-DEV"
version = "2.3.0"
allprojects {
apply(plugin = "java")
@@ -34,8 +34,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/")
@@ -59,6 +59,9 @@ allprojects {
// PlayerAnimator
maven("https://mvn.lumine.io/repository/maven/")
// md-5 Repo
maven("https://repo.md-5.net/content/groups/public/")
}
dependencies {
@@ -86,6 +89,7 @@ dependencies {
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"))
//compileOnly("com.github.Fisher2911:FisherLib:master-SNAPSHOT")
implementation("net.kyori:adventure-api:4.11.0")
@@ -96,7 +100,8 @@ dependencies {
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.5")
implementation("com.ticxo:PlayerAnimator:R1.2.6")
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
}
tasks {
@@ -116,7 +121,7 @@ tasks {
}
runServer {
minecraftVersion("1.19.2")
minecraftVersion("1.19.4")
}
shadowJar {
@@ -124,6 +129,7 @@ tasks {
dependsOn(":v1_18_R2:reobfJar")
dependsOn(":v1_19_R1:reobfJar")
dependsOn(":v1_19_R2:reobfJar")
dependsOn(":v1_19_R3:reobfJar")
mergeServiceFiles()
relocate("dev.triumphteam.gui", "com.hisbiscusmc.hmccosmetics.gui")
@@ -163,7 +169,7 @@ bukkit {
apiVersion = "1.17"
authors = listOf("LoJoSho")
depend = listOf("ProtocolLib")
softDepend = listOf("ModelEngine", "Oraxen", "ItemsAdder", "Looty", "HMCColor", "WorldGuard", "MythicMobs", "PlaceholderAPI", "SuperVanish", "PremiumVanish")
softDepend = listOf("ModelEngine", "Oraxen", "ItemsAdder", "Looty", "HMCColor", "WorldGuard", "MythicMobs", "PlaceholderAPI", "SuperVanish", "PremiumVanish", "LibsDisguises", "Denizen")
version = "${project.version}"
commands {

View File

@@ -18,7 +18,11 @@ dependencies {
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.6-4")
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")
@@ -29,7 +33,8 @@ dependencies {
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.5")
implementation("com.ticxo:PlayerAnimator:R1.2.6")
//implementation("com.ticxo.playeranimator:PlayerAnimator:R1.2.5")
}
java {

View File

@@ -11,6 +11,7 @@ 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.Menus;
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGHook;
@@ -18,14 +19,13 @@ 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 com.ticxo.playeranimator.api.PlayerAnimator;
import com.ticxo.playeranimator.api.animation.pack.AnimationPack;
import org.apache.commons.io.FilenameUtils;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@@ -41,7 +41,6 @@ import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
import java.io.File;
import java.nio.file.Path;
import java.util.Map;
public final class HMCCosmeticsPlugin extends JavaPlugin {
@@ -120,7 +119,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
}
// WorldGuard
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null) {
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null && Settings.isWorldGuardMoveCheckEnabled()) {
getServer().getPluginManager().registerEvents(new WGListener(), this);
}
}
@@ -135,11 +134,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() {
@@ -233,21 +237,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
}
}
File emoteFolder = new File(getInstance().getDataFolder().getPath() + "/emotes/");
if (emoteFolder.exists()) {
PlayerAnimator.api.getAnimationManager().clearRegistry();
File[] emotesFiles = emoteFolder.listFiles();
for (File emoteFile : emotesFiles) {
if (!emoteFile.getName().contains("bbmodel")) continue;
String animationName = emoteFile.getName().replaceAll(".bbmodel", "");
PlayerAnimator.api.getAnimationManager().importAnimations(FilenameUtils.removeExtension(emoteFile.getName()), emoteFile);
MessagesUtil.sendDebugMessages("Added '" + animationName + "' to Player Animator ");
}
for (Map.Entry<String, AnimationPack> packEntry : PlayerAnimator.api.getAnimationManager().getRegistry().entrySet()) {
//Set<String> animationNames = packEntry.getValue().getAnimations().keySet().stream().map(animation -> packEntry.getKey().replace(":", ".") + "." + animation).collect(Collectors.toSet());
}
}
EmoteManager.loadEmotes();
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
getInstance().getLogger().info(Cosmetics.values().size() + " Cosmetics Successfully Setup");

View File

@@ -4,12 +4,10 @@ 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
@@ -18,6 +16,7 @@ public class HMCCosmeticSetupEvent extends Event {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}

View File

@@ -3,53 +3,68 @@ 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;
import org.jetbrains.annotations.NotNull;
public class PlayerCosmeticEquipEvent extends Event implements Cancellable {
private final CosmeticUser user;
/**
* 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;
private boolean isCancelled;
public PlayerCosmeticEquipEvent(CosmeticUser user, Cosmetic cosmetic) {
this.user = user;
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;
this.isCancelled = false;
}
@Override
public boolean isCancelled() {
return 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) {
isCancelled = cancel;
this.cancel = cancel;
}
private static final HandlerList handlers = new HandlerList();
@Override
@NotNull
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}
public CosmeticUser getUser() {
return user;
}
public Cosmetic getCosmetic() {
return cosmetic;
}
public void setCosmetic(Cosmetic cosmetic) {
this.cosmetic = cosmetic;
}
}

View File

@@ -0,0 +1,26 @@
package com.hibiscusmc.hmccosmetics.api;
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

@@ -2,48 +2,59 @@ 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;
import org.jetbrains.annotations.NotNull;
public class PlayerCosmeticHideEvent extends Event implements Cancellable {
private final CosmeticUser user;
/**
* 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;
private boolean isCancelled;
public PlayerCosmeticHideEvent(CosmeticUser user, CosmeticUser.HiddenReason reason) {
this.user = user;
public PlayerCosmeticHideEvent(@NotNull CosmeticUser who, @NotNull CosmeticUser.HiddenReason reason) {
super(who);
this.reason = reason;
this.isCancelled = false;
}
/**
* 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 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) {
isCancelled = cancel;
this.cancel = cancel;
}
private static final HandlerList handlers = new HandlerList();
@Override
@NotNull
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}
public CosmeticUser getUser() {
return user;
}
public CosmeticUser.HiddenReason getReason() {
return reason;
}
}

View File

@@ -3,34 +3,50 @@ 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;
import org.jetbrains.annotations.NotNull;
public class PlayerCosmeticRemoveEvent extends Event implements Cancellable {
private final CosmeticUser user;
/**
* 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;
private boolean isCancelled;
public PlayerCosmeticRemoveEvent(CosmeticUser user, Cosmetic cosmetic) {
this.user = user;
public PlayerCosmeticRemoveEvent(@NotNull CosmeticUser who, @NotNull Cosmetic cosmetic) {
super(who);
this.cosmetic = cosmetic;
this.isCancelled = false;
}
/**
* 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 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) {
isCancelled = cancel;
this.cancel = cancel;
}
private static final HandlerList handlers = new HandlerList();
@Override
@NotNull
public HandlerList getHandlers() {
@@ -40,12 +56,4 @@ public class PlayerCosmeticRemoveEvent extends Event implements Cancellable {
public static HandlerList getHandlerList() {
return handlers;
}
public CosmeticUser getUser() {
return user;
}
public Cosmetic getCosmetic() {
return cosmetic;
}
}

View File

@@ -2,43 +2,47 @@ 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;
import org.jetbrains.annotations.NotNull;
public class PlayerCosmeticShowEvent extends Event implements Cancellable {
/**
* 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;
private final CosmeticUser user;
private boolean isCancelled;
public PlayerCosmeticShowEvent(CosmeticUser user) {
this.user = user;
this.isCancelled = false;
public PlayerCosmeticShowEvent(@NotNull CosmeticUser who) {
super(who);
}
@Override
public boolean isCancelled() {
return 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) {
isCancelled = cancel;
this.cancel = cancel;
}
private static final HandlerList handlers = new HandlerList();
@Override
@NotNull
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}
public CosmeticUser getUser() {
return user;
}
}

View File

@@ -0,0 +1,61 @@
package com.hibiscusmc.hmccosmetics.api;
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;
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;
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;
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

@@ -3,49 +3,47 @@ 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;
import org.jetbrains.annotations.NotNull;
public class PlayerMenuOpenEvent extends Event implements Cancellable {
/**
* 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;
private final CosmeticUser user;
private final Menu menu;
private boolean isCancelled;
public PlayerMenuOpenEvent(CosmeticUser user, Menu menu) {
this.user = user;
this.menu = menu;
this.isCancelled = false;
public PlayerMenuOpenEvent(@NotNull CosmeticUser who, @NotNull Menu menu) {
super(who, menu);
}
@Override
public boolean isCancelled() {
return 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) {
isCancelled = cancel;
this.cancel = cancel;
}
private static final HandlerList handlers = new HandlerList();
@Override
@NotNull
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}
public CosmeticUser getUser() {
return user;
}
public Menu getMenu() {
return menu;
}
}

View File

@@ -2,43 +2,47 @@ 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;
import org.jetbrains.annotations.NotNull;
public class PlayerWardrobeEnterEvent extends Event implements Cancellable {
/**
* 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 final CosmeticUser user;
private boolean isCancelled;
public PlayerWardrobeEnterEvent(CosmeticUser user) {
this.user = user;
this.isCancelled = false;
public PlayerWardrobeEnterEvent(@NotNull CosmeticUser who) {
super(who);
}
@Override
public boolean isCancelled() {
return 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) {
isCancelled = cancel;
this.cancel = cancel;
}
private static final HandlerList handlers = new HandlerList();
@Override
@NotNull
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}
public CosmeticUser getUser() {
return user;
}
}

View File

@@ -2,43 +2,47 @@ 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;
import org.jetbrains.annotations.NotNull;
public class PlayerWardrobeLeaveEvent extends Event implements Cancellable {
/**
* 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;
private final CosmeticUser user;
private boolean isCancelled;
public PlayerWardrobeLeaveEvent(CosmeticUser user) {
this.user = user;
this.isCancelled = false;
public PlayerWardrobeLeaveEvent(@NotNull CosmeticUser who) {
super(who);
}
@Override
public boolean isCancelled() {
return 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) {
isCancelled = cancel;
this.cancel = cancel;
}
private static final HandlerList handlers = new HandlerList();
@Override
@NotNull
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}
public CosmeticUser getUser() {
return user;
}
}

View File

@@ -8,6 +8,7 @@ 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;
@@ -15,7 +16,6 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
import com.ticxo.playeranimator.api.PlayerAnimator;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.apache.commons.lang3.EnumUtils;
@@ -28,7 +28,6 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.Set;
public class CosmeticCommand implements CommandExecutor {
@@ -333,7 +332,7 @@ public class CosmeticCommand implements CommandExecutor {
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
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;
}
@@ -429,13 +428,11 @@ public class CosmeticCommand implements CommandExecutor {
return true;
}
if (args.length >= 2) {
if (!PlayerAnimator.api.getAnimationManager().getRegistry().keySet().contains(args[1])) {
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]);
@@ -445,7 +442,7 @@ public class CosmeticCommand implements CommandExecutor {
return true;
}
CosmeticUser user = CosmeticUsers.getUser(player);
user.getUserEmoteManager().playEmote(args[1]);
user.getUserEmoteManager().playEmote(EmoteManager.get(args[1]));
return true;
}
}

View File

@@ -3,11 +3,11 @@ package com.hibiscusmc.hmccosmetics.command;
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;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import com.ticxo.playeranimator.api.PlayerAnimator;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -56,7 +56,7 @@ 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");
@@ -81,9 +81,7 @@ public class CosmeticCommandTabComplete implements TabCompleter {
completions.add("viewerlocation");
completions.add("leavelocation");
}
case "playemote" -> {
completions.addAll(PlayerAnimator.api.getAnimationManager().getRegistry().keySet());
}
case "playemote" -> completions.addAll(EmoteManager.getAllNames());
}
StringUtil.copyPartialMatches(args[1], completions, finalCompletions);
}

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
@@ -35,7 +38,17 @@ public class Settings {
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_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;
@@ -51,7 +64,15 @@ public class Settings {
private static boolean unapplyOnDeath;
private static boolean forcePermissionJoin;
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 emoteDamageLeave;
private static boolean emoteInvincible;
private static boolean destroyLooseCosmetics;
private static int lookDownPitch;
private static int viewDistance;
private static int tickPeriod;
@@ -84,6 +105,13 @@ public class Settings {
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3);
cosmeticEmoteBlockCheck = cosmeticSettings.node(COSMETIC_EMOTE_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();
@@ -102,6 +130,14 @@ public class Settings {
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) {
@@ -227,6 +263,42 @@ public class Settings {
return cosmeticEmoteBlockCheck;
}
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

@@ -6,6 +6,7 @@ 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;
@@ -29,6 +30,9 @@ public class WardrobeSettings {
private static final String LEAVE_LOCATION_PATH = "leave-location";
private static final String EQUIP_PUMPKIN_WARDROBE = "equip-pumpkin";
private static final String RETURN_LAST_LOCATION = "return-last-location";
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 BOSSBAR_PATH = "bossbar";
private static final String BOSSBAR_ENABLE_PATH = "enabled";
private static final String BOSSBAR_TEXT_PATH = "text";
@@ -57,6 +61,8 @@ public class WardrobeSettings {
private static boolean equipPumpkin;
private static boolean returnLastLocation;
private static boolean enabledBossbar;
private static boolean forceExitGamemode;
private static GameMode exitGamemode;
private static Location wardrobeLocation;
private static Location viewerLocation;
private static Location leaveLocation;
@@ -85,6 +91,10 @@ public class WardrobeSettings {
equipPumpkin = source.node(EQUIP_PUMPKIN_WARDROBE).getBoolean();
returnLastLocation = source.node(RETURN_LAST_LOCATION).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);
bossbarProgress = bossBarNode.node(BOSSBAR_PROGRESS_PATH).getFloat(1.0f);
@@ -227,6 +237,14 @@ public class WardrobeSettings {
return transitionFadeOut;
}
public static boolean isForceExitGamemode() {
return forceExitGamemode;
}
public static GameMode getExitGamemode() {
return exitGamemode;
}
public static void setWardrobeLocation(Location newLocation) {
wardrobeLocation = newLocation;

View File

@@ -143,9 +143,6 @@ 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;
}

View File

@@ -17,6 +17,7 @@ public abstract class Cosmetic {
private String id;
private String permission;
private ItemStack item;
private String material;
private CosmeticSlot slot;
private boolean dyable;
@@ -29,7 +30,10 @@ public abstract class Cosmetic {
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());
@@ -76,6 +80,10 @@ public abstract class Cosmetic {
return this.dyable;
}
public String getMaterial() {
return material;
}
public abstract void update(CosmeticUser user);
@Nullable

View File

@@ -8,6 +8,7 @@ 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;
@@ -33,6 +34,7 @@ public class Cosmetics {
COSMETICS.remove(cosmetic);
}
@Nullable
public static Cosmetic getCosmetic(String id) {
return COSMETICS.get(id);
}

View File

@@ -1,12 +1,16 @@
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.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
import org.bukkit.Bukkit;
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;
@@ -24,10 +28,17 @@ public class CosmeticArmorType extends Cosmetic {
public void update(@NotNull CosmeticUser user) {
Player player = Bukkit.getPlayer(user.getUniqueId());
if (player == null) return;
ItemStack cosmeticItem = user.getUserCosmeticItem(this);
if (equipSlot.equals(EquipmentSlot.OFF_HAND)) {
if (!player.getInventory().getItemInOffHand().getType().isAir()) return;
}
PacketManager.equipmentSlotUpdate(player, getSlot(), PacketManager.getViewers(player.getLocation()));
ItemStack equippedItem = player.getInventory().getItem(equipSlot);
if (Settings.getShouldAddEnchants(equipSlot)) {
cosmeticItem.addUnsafeEnchantments(equippedItem.getEnchantments());
}
NMSHandlers.getHandler().equipmentSlotUpdate(player.getEntityId(), equipSlot, cosmeticItem, PacketManager.getViewers(player.getLocation()));
//PacketManager.equipmentSlotUpdate(player, getSlot(), PacketManager.getViewers(player.getLocation())); Old method
}
public EquipmentSlot getEquipSlot() {

View File

@@ -3,6 +3,7 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
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;
@@ -10,6 +11,8 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.configurate.ConfigurationNode;
import java.util.logging.Level;
public class CosmeticBackpackType extends Cosmetic {
private final String modelName;
@@ -30,6 +33,11 @@ public class CosmeticBackpackType extends Cosmetic {
Location loc = player.getLocation().clone().add(0, 2, 0);
if (user.isInWardrobe() || !user.isBackpackSpawned()) return;
if (!user.getUserBackpackManager().getArmorStand().isValid()) {
MessagesUtil.sendDebugMessages("Invalid Backpack detected! Respawning backpack, report this on the discord if this happens often!", Level.WARNING);
user.respawnBackpack();
return;
}
if (loc.getWorld() != user.getUserBackpackManager().getArmorStand().getWorld()) {
user.getUserBackpackManager().getArmorStand().teleport(loc);
}

View File

@@ -19,12 +19,15 @@ public class CosmeticBalloonType extends Cosmetic {
private final String modelName;
private List<String> dyableParts;
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);
@@ -45,6 +48,11 @@ public class CosmeticBalloonType extends Cosmetic {
if (player == null || userBalloonManager == null) return;
if (user.isInWardrobe()) return;
if (!userBalloonManager.getModelEntity().isValid()) {
user.respawnBalloon();
return;
}
Location newLocation = player.getLocation();
Location currentLocation = user.getBalloonManager().getLocation();
newLocation = newLocation.clone().add(Settings.getBalloonOffset());
@@ -63,7 +71,7 @@ public class CosmeticBalloonType extends Cosmetic {
userBalloonManager.setLocation(newLocation);
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
if (!user.getHidden()) PacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), player.getEntityId(), viewer);
if (!user.getHidden() && showLead) PacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), player.getEntityId(), viewer);
}
public String getModelName() {
@@ -80,4 +88,8 @@ public class CosmeticBalloonType extends Cosmetic {
if (dyableParts.isEmpty()) return true;
return dyableParts.contains(name);
}
public boolean isShowLead() {
return showLead;
}
}

View File

@@ -37,7 +37,7 @@ public abstract class Data {
data = "HIDDEN=" + user.getHiddenReason();
}
}
for (Cosmetic cosmetic : user.getCosmetic()) {
for (Cosmetic cosmetic : user.getCosmetics()) {
Color color = user.getCosmeticColor(cosmetic.getSlot());
String input = cosmetic.getSlot() + "=" + cosmetic.getId();
if (color != null) input = input + "&" + color.asRGB();

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<@NotNull String, @NotNull 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

@@ -118,14 +118,12 @@ public class Menu {
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);
@@ -145,24 +143,25 @@ public class Menu {
if (Types.isType(typeId)) type = Types.getType(typeId);
}
ItemStack originalItem = item.clone();
item = updateLore(user, item, type, config);
GuiItem guiItem = ItemBuilder.from(item).asGuiItem();
for (int slot : slots) {
ItemStack originalItem = updateItem(user, item, type, config, slot).clone();
GuiItem guiItem = ItemBuilder.from(originalItem).asGuiItem();
Type finalType = type;
guiItem.setAction(event -> {
MessagesUtil.sendDebugMessages("Selected slot " + slot);
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);
for (int guiSlot : slots) {
gui.updateItem(guiSlot, updateItem(user, originalItem.clone(), finalType, config, guiSlot));
}
MessagesUtil.sendDebugMessages("Updated slot " + slot);
});
MessagesUtil.sendDebugMessages("Added " + slots + " as " + guiItem + " in the menu");
gui.setItem(slots, guiItem);
gui.setItem(slot, guiItem);
}
}
return gui;
}
@@ -195,9 +194,9 @@ public class Menu {
@Contract("_, _, _, _ -> param2")
@NotNull
private ItemStack updateLore(CosmeticUser user, @NotNull ItemStack itemStack, Type type, ConfigurationNode config) {
private ItemStack updateItem(CosmeticUser user, @NotNull ItemStack itemStack, Type type, ConfigurationNode config, int slot) {
if (itemStack.hasItemMeta()) {
itemStack.setItemMeta(type.setLore(user, config, itemStack.getItemMeta()));
itemStack = type.setItem(user, config, itemStack, slot);
}
return itemStack;
}

View File

@@ -48,6 +48,7 @@ public class DyeMenu {
if (color == null) return;
addCosmetic(user, cosmetic, color);
event.setCancelled(true);
} else event.setCancelled(true);
});

View File

@@ -2,6 +2,7 @@ package com.hibiscusmc.hmccosmetics.gui.type;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.spongepowered.configurate.ConfigurationNode;
@@ -24,5 +25,5 @@ public abstract class Type {
public abstract void run(CosmeticUser user, ConfigurationNode config, ClickType clickType);
public abstract ItemMeta setLore(CosmeticUser user, ConfigurationNode config, ItemMeta itemMeta);
public abstract ItemStack setItem(CosmeticUser user, ConfigurationNode config, ItemStack itemStack, int slot);
}

View File

@@ -1,6 +1,7 @@
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;
@@ -17,12 +18,14 @@ 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.lang.invoke.TypeDescriptor;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@@ -96,55 +99,51 @@ public class TypeCosmetic extends Type {
}
@Override
public ItemMeta setLore(CosmeticUser user, @NotNull ConfigurationNode config, ItemMeta itemMeta) {
List<String> processedLore = new ArrayList<>();
public ItemStack setItem(CosmeticUser user, @NotNull ConfigurationNode config, ItemStack itemStack, int slot) {
ItemMeta itemMeta = itemStack.getItemMeta();
if (config.node("cosmetic").virtual()) return processLoreLines(user, itemMeta);;
if (config.node("cosmetic").virtual()) {
itemStack.setItemMeta(processLoreLines(user, itemMeta));
return itemStack;
};
String cosmeticName = config.node("cosmetic").getString();
Cosmetic cosmetic = Cosmetics.getCosmetic(cosmeticName);
if (cosmetic == null) {
return processLoreLines(user, itemMeta);
itemStack.setItemMeta(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-lore").virtual()) {
return processLoreLines(user, itemMeta);
if (user.hasCosmeticInSlot(cosmetic) && !config.node("equipped-item").virtual()) {
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 {
List<String> lockedLore = itemMeta.getLore();
String lockedName = itemMeta.getDisplayName();
if (!itemConfig.node("locked-lore").virtual()) {
lockedLore = Utils.replaceIfNull(itemConfig.node("locked-lore").getList(String.class),
new ArrayList<String>()).
stream().map(StringUtils::parseStringToString).collect(Collectors.toList());
itemStack = ItemSerializer.INSTANCE.deserialize(ItemStack.class, equippedItem);
} catch (SerializationException e) {
throw new RuntimeException(e);
}
if (!itemConfig.node("locked-name").virtual()) {
lockedName = StringUtils.parseStringToString(Utils.replaceIfNull(itemConfig.node("locked-name").getString(), ""));
return itemStack;
}
if (Hooks.isActiveHook("PlaceHolderAPI")) {
lockedName = PlaceholderAPI.setPlaceholders(user.getPlayer(), lockedName);
if (!user.canEquipCosmetic(cosmetic) && !config.node("locked-item").virtual()) {
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 >:)
}
itemMeta.setDisplayName(lockedName);
if (itemMeta.hasLore()) {
itemMeta.getLore().clear();
for (String loreLine : lockedLore) {
if (Hooks.isActiveHook("PlaceHolderAPI")) loreLine = PlaceholderAPI.setPlaceholders(user.getPlayer(), loreLine);
processedLore.add(loreLine);
try {
itemStack = ItemSerializer.INSTANCE.deserialize(ItemStack.class, lockedItem);
//item = config.node("item").get(ItemStack.class);
} catch (SerializationException e) {
throw new RuntimeException(e);
}
return itemStack;
}
} catch (Exception e) {
e.printStackTrace();
}
}
itemMeta.setLore(processedLore);
return itemMeta;
return itemStack;
}
@Contract("_, _ -> param2")

View File

@@ -6,6 +6,7 @@ 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;
@@ -53,8 +54,9 @@ public class TypeEmpty extends Type {
@Override
@SuppressWarnings("Duplicates")
public ItemMeta setLore(CosmeticUser user, ConfigurationNode config, @NotNull ItemMeta itemMeta) {
public ItemStack setItem(CosmeticUser user, ConfigurationNode config, @NotNull ItemStack itemStack, int slot) {
List<String> processedLore = new ArrayList<>();
ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta.hasLore()) {
for (String loreLine : itemMeta.getLore()) {
@@ -63,8 +65,8 @@ public class TypeEmpty extends Type {
processedLore.add(loreLine);
}
}
return itemMeta;
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

@@ -2,45 +2,92 @@ 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;
public class Hook implements Listener {
/**
* Represents a hook into other minecraft plugins
*/
public abstract class Hook implements Listener {
private final String id;
private boolean active;
private boolean itemHook;
private boolean active = false;
private boolean itemHook = false;
public Hook(String id) {
public Hook(@NotNull String id) {
this.id = id;
active = false;
Hooks.addHook(this);
}
public void load() {
// Override
}
/**
* 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() { }
public ItemStack getItem(String itemId) {
/**
* 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;
// Override
}
public String getId() {
/**
* Gets the id of this hook
*
* @return The unique id for this hook
*/
@NotNull
public final String getId() {
return id;
}
public void setActive(boolean active) {
this.active = active;
}
/**
* 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;
}
public void setEnabledItemHook(boolean enabled) {
itemHook = enabled;
/**
* 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;
}
public boolean hasEnabledItemHook() {
/**
* 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

@@ -2,10 +2,7 @@ package com.hibiscusmc.hmccosmetics.hooks;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.hooks.items.*;
import com.hibiscusmc.hmccosmetics.hooks.misc.HookCMI;
import com.hibiscusmc.hmccosmetics.hooks.misc.HookHMCColor;
import com.hibiscusmc.hmccosmetics.hooks.misc.HookPremiumVanish;
import com.hibiscusmc.hmccosmetics.hooks.misc.HookSuperVanish;
import com.hibiscusmc.hmccosmetics.hooks.misc.*;
import com.hibiscusmc.hmccosmetics.hooks.placeholders.HookPlaceholderAPI;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@@ -22,12 +19,14 @@ public class Hooks {
private static HookItemAdder ITEMADDER_HOOK = new HookItemAdder();
private static HookLooty LOOTY_HOOK = new HookLooty();
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();
public static Hook getHook(@NotNull String id) {
return hooks.get(id.toLowerCase());
@@ -67,13 +66,13 @@ public class Hooks {
if (!isItemHook(split[0])) return null;
Hook hook = getHook(split[0]);
if (!hook.hasEnabledItemHook()) return null;
if (!hook.getActive()) return null;
if (!hook.isActive()) return null;
return hook.getItem(split[1]);
}
public static boolean isActiveHook(String id) {
Hook hook = getHook(id);
if (hook == null) return false;
return hook.getActive();
return hook.isActive();
}
}

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

@@ -3,18 +3,23 @@ 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.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
public class HookHMCCosmetics extends Hook implements Listener {
/**
* 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(String itemId) {
public ItemStack getItem(@NotNull String itemId) {
Cosmetic cosmetic = Cosmetics.getCosmetic(itemId);
if (cosmetic == null) return null;
return cosmetic.getItem();

View File

@@ -7,11 +7,14 @@ 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;
import org.jetbrains.annotations.NotNull;
public class HookItemAdder extends Hook implements Listener {
/**
* 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() {
@@ -19,8 +22,11 @@ public class HookItemAdder extends Hook implements Listener {
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(String itemId) {
public ItemStack getItem(@NotNull String itemId) {
if (enabled) {
CustomStack stack = CustomStack.getInstance(itemId);
if (stack == null) return null;
@@ -32,7 +38,8 @@ public class HookItemAdder extends Hook implements Listener {
@EventHandler
public void onItemAdderDataLoad(ItemsAdderLoadDataEvent event) {
if (enabled && !Settings.getItemsAdderReloadChange()) return; // Defaultly it will only run once at startup. If hook setting is enable
// 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

@@ -3,18 +3,24 @@ package com.hibiscusmc.hmccosmetics.hooks.items;
import com.hibiscusmc.hmccosmetics.hooks.Hook;
import com.mineinabyss.geary.prefabs.PrefabKey;
import com.mineinabyss.looty.LootyFactory;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
public class HookLooty extends Hook implements Listener {
/**
* A hook that integrates the plugin {@link com.mineinabyss.looty.LootyPlugin Looty} to provide custom items
*/
@SuppressWarnings("SpellCheckingInspection")
public class HookLooty extends Hook {
public HookLooty() {
super("looty");
setEnabledItemHook(true);
}
/**
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.mineinabyss.looty.LootyPlugin Looty}
*/
@Override
public ItemStack getItem(String itemId) {
public ItemStack getItem(@NotNull String itemId) {
PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId);
if (prefabKey == null) return null;
return LootyFactory.INSTANCE.createFromPrefab(prefabKey);

View File

@@ -2,17 +2,24 @@ package com.hibiscusmc.hmccosmetics.hooks.items;
import com.hibiscusmc.hmccosmetics.hooks.Hook;
import io.lumine.mythic.bukkit.MythicBukkit;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
public class HookMythic extends Hook implements Listener {
/**
* 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(String itemId) {
public ItemStack getItem(@NotNull String itemId) {
return MythicBukkit.inst().getItemManager().getItemStack(itemId);
}
}

View File

@@ -3,18 +3,24 @@ 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.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
public class HookOraxen extends Hook implements Listener {
/**
* 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(String itemId) {
public ItemStack getItem(@NotNull String itemId) {
ItemBuilder builder = OraxenItems.getItemById(itemId);
if (builder == null) return null;
return builder.build();

View File

@@ -7,11 +7,12 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.jetbrains.annotations.NotNull;
public class HookCMI extends Hook implements Listener {
/**
* A hook that integrates the plugin {@link com.Zrips.CMI.CMI CMI}
*/
public class HookCMI extends Hook {
public HookCMI() {
super("CMI");
}

View File

@@ -1,10 +1,11 @@
package com.hibiscusmc.hmccosmetics.hooks.misc;
import com.hibiscusmc.hmccosmetics.hooks.Hook;
import org.bukkit.event.Listener;
public class HookHMCColor extends Hook implements Listener {
/**
* 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

@@ -7,13 +7,14 @@ import de.myzelyam.api.vanish.PlayerHideEvent;
import de.myzelyam.api.vanish.PlayerShowEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.jetbrains.annotations.NotNull;
public class HookPremiumVanish extends Hook implements Listener {
// NOTE: Supervanish and Premium Vanish both use the same api
/**
* 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");
}
@@ -33,5 +34,4 @@ public class HookPremiumVanish extends Hook implements Listener {
if (user == null) return;
user.showCosmetics();
}
}

View File

@@ -7,13 +7,14 @@ import de.myzelyam.api.vanish.PlayerHideEvent;
import de.myzelyam.api.vanish.PlayerShowEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.jetbrains.annotations.NotNull;
public class HookSuperVanish extends Hook implements Listener {
// NOTE: Supervanish and Premium Vanish both use the same api
/**
* 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");
}

View File

@@ -6,18 +6,23 @@ 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() {
@@ -42,6 +47,11 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
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;
@@ -57,8 +67,9 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
}
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 (cosmetic == null || currentCosmetic == null) return "false";
if (currentCosmetic == null) return "false";
if (currentCosmetic.getId() == cosmetic.getId()) return "true";
return "false";
}
@@ -73,7 +84,7 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
if (placeholderArgs.size() == 2) return user.getCosmetic(slot).getId();
switch (placeholderArgs.get(2).toLowerCase()) {
case "material" -> {
return getMaterial(user.getCosmetic(slot));
return getMaterialName(user.getCosmetic(slot));
}
case "custommodeldata" -> {
return getModelData(user.getCosmetic(slot));
@@ -113,14 +124,30 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
return null;
}
if (placeholderArgs.get(1) != null) {
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
String args1 = placeholderArgs.get(1);
if (EnumUtils.isValidEnum(CosmeticSlot.class, args1.toUpperCase())) {
if (user.getCosmetic(CosmeticSlot.valueOf(args1.toUpperCase())) != null) {
return "true";
} else {
return "false";
}
}
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";
if (cosmetic.getId() == user.getCosmetic(cosmetic.getSlot()).getId()) {
@@ -135,33 +162,76 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
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 cosmetic.getItem().getType().toString();
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()) {
return String.valueOf(item.getItemMeta().getLore());
ItemMeta itemMeta = item.getItemMeta();
if (itemMeta == null) return null;
return String.valueOf(itemMeta.getLore());
}
return null;
}

View File

@@ -2,12 +2,17 @@ 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();

View File

@@ -9,9 +9,18 @@ import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
import java.util.logging.Level;
/**
* A hook that integrates the plugin {@link com.sk89q.worldguard.WorldGuard WorldGuard}
*/
public class WGHook {
/**
* @implNote Please use {@link #getCosmeticEnableFlag()} instead
*/
public static StateFlag COSMETIC_ENABLE_FLAG;
/**
* @implNote Please use {@link #getCosmeticWardrobeFlag()} instead
*/
public static StateFlag COSMETIC_WARDROBE_FLAG;
public WGHook() {
@@ -35,10 +44,18 @@ public class WGHook {
}
}
/**
* Gets the cosmetic enable {@link StateFlag}
* @return The cosmetic enable {@link StateFlag}
*/
public static StateFlag getCosmeticEnableFlag() {
return COSMETIC_ENABLE_FLAG;
}
/**
* Gets the cosmetic wardrobe {@link StateFlag}
* @return The cosmetic wardrobe {@link StateFlag}
*/
public static StateFlag getCosmeticWardrobeFlag() {
return COSMETIC_WARDROBE_FLAG;
}

View File

@@ -14,8 +14,10 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.jetbrains.annotations.NotNull;
/**
* Contains {@link com.sk89q.worldguard.WorldGuard WorldGuard} related event listeners
*/
public class WGListener implements Listener {
@EventHandler
public void onPlayerMove(@NotNull PlayerMoveEvent event) {
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());

View File

@@ -5,6 +5,7 @@ import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
import com.hibiscusmc.hmccosmetics.database.Database;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
@@ -57,10 +58,11 @@ public class PlayerConnectionListener implements Listener {
}
}
}
return;
}
if (user.isInWardrobe()) user.leaveWardrobe();
if (user.getUserEmoteManager().isPlayingEmote()) {
user.getUserEmoteManager().stopEmote();
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.CONNECTION);
event.getPlayer().setInvisible(false);
}
Database.save(user);

View File

@@ -20,11 +20,13 @@ 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 com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@@ -32,7 +34,6 @@ import org.bukkit.entity.Pose;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.*;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.*;
import org.bukkit.inventory.EquipmentSlot;
@@ -60,12 +61,20 @@ public class PlayerGameListener implements Listener {
@EventHandler
public void onPlayerClick(@NotNull InventoryClickEvent event) {
if (event.getClick() != ClickType.SHIFT_LEFT && event.getClick() != ClickType.SHIFT_RIGHT) return;
// || !event.getClickedInventory().getType().equals(InventoryType.PLAYER)
if (event.getClick().isShiftClick()) return;
MessagesUtil.sendDebugMessages("inventoryclickevent");
//if (event.getSlotType() != InventoryType.SlotType.ARMOR) return;
CosmeticUser user = CosmeticUsers.getUser(event.getWhoClicked().getUniqueId());
if (user == null) return;
ItemStack item = event.getCurrentItem();
if (item == null) return;
if (Settings.isDestroyLooseCosmetics() && InventoryUtils.isCosmeticItem(event.getCurrentItem())) {
MessagesUtil.sendDebugMessages("remvoe item");
event.getWhoClicked().getInventory().removeItem(event.getCurrentItem());
}
EquipmentSlot slot = getArmorSlot(item.getType());
if (slot == null) return;
CosmeticSlot cosmeticSlot = InventoryUtils.BukkitCosmeticSlot(slot);
@@ -83,7 +92,7 @@ public class PlayerGameListener implements Listener {
if (user == null) return;
if (event.isSneaking()) {
user.getUserEmoteManager().stopEmote();
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.SNEAK);
}
if (!event.isSneaking()) return;
@@ -121,6 +130,9 @@ public class PlayerGameListener implements Listener {
user.spawnBalloon(cosmeticBalloonType);
}, 2);
}
if (user.getUserEmoteManager().isPlayingEmote()) {
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.TELEPORT);
}
}
@EventHandler
@@ -153,6 +165,26 @@ public class PlayerGameListener implements Listener {
event.setCancelled(true);
}
@EventHandler
public void onPlayerDamaged(EntityDamageEvent event) {
if (event.isCancelled()) return;
if (!(event.getEntity() instanceof Player)) return;
Player player = ((Player) event.getEntity()).getPlayer();
CosmeticUser user = CosmeticUsers.getUser(player);
if (user == null) return;
if (user.getUserEmoteManager().isPlayingEmote()) {
if (Settings.isEmoteInvincible()) {
event.setCancelled(true);
}
if (Settings.isEmoteDamageLeave()) {
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.DAMAGE);
}
}
if (user.isInWardrobe()) {
user.leaveWardrobe();
}
}
@EventHandler
public void onPlayerLook(PlayerMoveEvent event) {
if (event.isCancelled()) return;
@@ -174,12 +206,22 @@ public class PlayerGameListener implements Listener {
if (!user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return;
Pose pose = event.getPose();
if (pose.equals(Pose.STANDING)) {
// #84, Riptides mess with backpacks
ItemStack currentItem = player.getInventory().getItemInMainHand();
if (currentItem != null) {
if (currentItem.hasItemMeta()) {
if (currentItem.containsEnchantment(Enchantment.RIPTIDE)) {
return;
}
}
}
if (!user.isBackpackSpawned()) {
user.spawnBackpack((CosmeticBackpackType) user.getCosmetic(CosmeticSlot.BACKPACK));
}
return;
}
if (pose.equals(Pose.SLEEPING) || pose.equals(Pose.SWIMMING) || pose.equals(Pose.FALL_FLYING)) {
if (pose.equals(Pose.SLEEPING) || pose.equals(Pose.SWIMMING) || pose.equals(Pose.FALL_FLYING) || pose.equals(Pose.SPIN_ATTACK)) {
user.despawnBackpack();
}
}
@@ -271,6 +313,14 @@ public class PlayerGameListener implements Listener {
user.updateCosmetic(CosmeticSlot.MAINHAND);
user.updateCosmetic(CosmeticSlot.OFFHAND);
}, 2);
// #84, Riptides mess with backpacks
ItemStack currentItem = event.getPlayer().getInventory().getItem(event.getNewSlot());
if (currentItem == null) return;
if (!currentItem.hasItemMeta()) return;
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && currentItem.containsEnchantment(Enchantment.RIPTIDE)) {
user.despawnBackpack();
}
}
@EventHandler
@@ -278,11 +328,27 @@ public class PlayerGameListener implements Listener {
CosmeticUser user = CosmeticUsers.getUser(event.getEntity());
if (user == null) return;
if (user.isInWardrobe()) user.leaveWardrobe();
if (Settings.getUnapplyOnDeath() && !event.getEntity().hasPermission("hmccosmetics.unapplydeath.bypass")) {
user.removeCosmetics();
}
}
@EventHandler
public void onPlayerGamemodeSwitch(PlayerGameModeChangeEvent event) {
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
if (user == null) return;
if (Settings.isDestroyLooseCosmetics()) {
ItemStack[] equippedArmor = event.getPlayer().getInventory().getArmorContents();
if (equippedArmor.length == 0) return;
for (ItemStack armor : equippedArmor) {
if (InventoryUtils.isCosmeticItem(armor)) armor.setAmount(0);
}
}
}
private void registerInventoryClickListener() {
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.WINDOW_CLICK) {
@Override
@@ -326,7 +392,7 @@ public class PlayerGameListener implements Listener {
HashMap<Integer, ItemStack> items = new HashMap<>();
for (Cosmetic cosmetic : user.getCosmetic()) {
for (Cosmetic cosmetic : user.getCosmetics()) {
if ((cosmetic instanceof CosmeticArmorType cosmeticArmorType)) {
items.put(InventoryUtils.getPacketArmorSlot(cosmeticArmorType.getEquipSlot()), user.getUserCosmeticItem(cosmeticArmorType));
}

View File

@@ -8,7 +8,7 @@ import java.util.logging.Level;
public class NMSHandlers {
private static final String[] SUPPORTED_VERSION = new String[]{"v1_17_R1", "v1_18_R2", "v1_19_R1", "v1_19_R2"};
private static final String[] SUPPORTED_VERSION = new String[]{"v1_17_R1", "v1_18_R2", "v1_19_R1", "v1_19_R2", "v1_19_R3"};
private static NMSHandler handler;
private static String version;

View File

@@ -1,5 +1,7 @@
package com.hibiscusmc.hmccosmetics.user;
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.api.*;
import com.hibiscusmc.hmccosmetics.config.Settings;
@@ -16,13 +18,11 @@ import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.*;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.*;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.scheduler.BukkitTask;
import java.util.*;
@@ -52,7 +52,7 @@ public class CosmeticUser {
private void tick() {
// Occasionally updates the entity cosmetics
Runnable run = () -> {
MessagesUtil.sendDebugMessages("tick " + uniqueId, Level.INFO);
MessagesUtil.sendDebugMessages("Tick[uuid=" + uniqueId + "]", Level.INFO);
updateCosmetic();
};
@@ -77,10 +77,15 @@ public class CosmeticUser {
return playerCosmetics.get(slot);
}
@Deprecated
public Collection<Cosmetic> getCosmetic() {
return playerCosmetics.values();
}
public ImmutableCollection<Cosmetic> getCosmetics() {
return ImmutableList.copyOf(playerCosmetics.values());
}
public void addPlayerCosmetic(Cosmetic cosmetic) {
addPlayerCosmetic(cosmetic, null);
}
@@ -100,11 +105,11 @@ public class CosmeticUser {
playerCosmetics.put(cosmetic.getSlot(), cosmetic);
if (color != null) colors.put(cosmetic.getSlot(), color);
MessagesUtil.sendDebugMessages("addPlayerCosmetic " + cosmetic.getId());
MessagesUtil.sendDebugMessages("addPlayerCosmetic[id=" + cosmetic.getId() + "]");
if (cosmetic.getSlot() == CosmeticSlot.BACKPACK) {
CosmeticBackpackType backpackType = (CosmeticBackpackType) cosmetic;
spawnBackpack(backpackType);
MessagesUtil.sendDebugMessages("addPlayerCosmetic spawnBackpack " + cosmetic.getId());
MessagesUtil.sendDebugMessages("addPlayerCosmetic[spawnBackpack,id=" + cosmetic.getId() + "]");
}
if (cosmetic.getSlot() == CosmeticSlot.BALLOON) {
CosmeticBalloonType balloonType = (CosmeticBalloonType) cosmetic;
@@ -151,6 +156,14 @@ public class CosmeticUser {
return playerCosmetics.containsKey(slot);
}
public boolean hasCosmeticInSlot(Cosmetic cosmetic) {
if (getCosmetic(cosmetic.getSlot()) == null) return false;
if (cosmetic.getId() == getCosmetic(cosmetic.getSlot()).getId()) {
return true;
}
return false;
}
public Set<CosmeticSlot> getSlotsWithCosmetics() {
return Set.copyOf(playerCosmetics.keySet());
}
@@ -205,6 +218,9 @@ public class CosmeticUser {
mapMeta.setColor(color);
}
}
itemMeta.getPersistentDataContainer().set(InventoryUtils.getCosmeticKey(), PersistentDataType.STRING, cosmetic.getId());
itemMeta.getPersistentDataContainer().set(InventoryUtils.getOwnerKey(), PersistentDataType.STRING, getPlayer().getUniqueId().toString());
item.setItemMeta(itemMeta);
}
return item;
@@ -257,6 +273,7 @@ public class CosmeticUser {
if (event.isCancelled()) {
return;
}
MessagesUtil.sendDebugMessages("Leaving Wardrobe");
if (!getWardrobeManager().getWardrobeStatus().equals(UserWardrobeManager.WardrobeStatus.RUNNING)) return;
getWardrobeManager().setWardrobeStatus(UserWardrobeManager.WardrobeStatus.STOPPING);
@@ -273,6 +290,9 @@ public class CosmeticUser {
userWardrobeManager.end();
userWardrobeManager = null;
}, WardrobeSettings.getTransitionDelay());
} else {
userWardrobeManager.end();
userWardrobeManager = null;
}
}
@@ -315,8 +335,6 @@ public class CosmeticUser {
List<Player> viewer = PlayerUtils.getNearbyPlayers(player);
viewer.add(player);
PacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), player.getEntityId(), viewer);
}
public void despawnBalloon() {
@@ -358,7 +376,7 @@ public class CosmeticUser {
public List<CosmeticSlot> getDyeableSlots() {
ArrayList<CosmeticSlot> dyableSlots = new ArrayList();
for (Cosmetic cosmetic : getCosmetic()) {
for (Cosmetic cosmetic : getCosmetics()) {
if (cosmetic.isDyable()) dyableSlots.add(cosmetic.getSlot());
}
@@ -401,8 +419,7 @@ public class CosmeticUser {
hiddenReason = reason;
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
getBalloonManager().removePlayerFromModel(getPlayer());
List<Player> viewer = PlayerUtils.getNearbyPlayers(getPlayer());
PacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), -1, viewer);
getBalloonManager().sendRemoveLeashPacket();
}
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
userBackpackManager.clearItems();

View File

@@ -6,6 +6,8 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
@@ -17,12 +19,14 @@ import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.UUID;
import java.util.logging.Level;
public class UserBalloonManager {
private BalloonType balloonType;
private CosmeticBalloonType cosmeticBalloonType;
private final int balloonID;
private final UUID uniqueID;
private final ArmorStand modelEntity;
@@ -44,6 +48,7 @@ public class UserBalloonManager {
balloonType = BalloonType.NONE;
}
}
this.cosmeticBalloonType = cosmeticBalloonType;
MessagesUtil.sendDebugMessages("balloontype is " + balloonType);
if (balloonType == BalloonType.MODELENGINE) {
@@ -85,6 +90,7 @@ public class UserBalloonManager {
}
modelEntity.remove();
cosmeticBalloonType = null;
}
public void addPlayerToModel(final CosmeticUser user, final CosmeticBalloonType cosmeticBalloonType) {
@@ -156,6 +162,19 @@ public class UserBalloonManager {
this.getModelEntity().setVelocity(vector);
}
public void sendRemoveLeashPacket(List<Player> viewer) {
PacketManager.sendLeashPacket(getPufferfishBalloonId(), -1, viewer);
}
public void sendRemoveLeashPacket() {
PacketManager.sendLeashPacket(getPufferfishBalloonId(), -1, getLocation());
}
public void sendLeashPacket(int entityId) {
if (cosmeticBalloonType == null) return;
if (cosmeticBalloonType.isShowLead()) PacketManager.sendLeashPacket(getPufferfishBalloonId(), entityId, getLocation());
}
public enum BalloonType {
MODELENGINE,
ITEM,

View File

@@ -1,8 +1,11 @@
package com.hibiscusmc.hmccosmetics.user.manager;
import com.hibiscusmc.hmccosmetics.api.PlayerEmoteStartEvent;
import com.hibiscusmc.hmccosmetics.api.PlayerEmoteStopEvent;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.bukkit.Bukkit;
import org.jetbrains.annotations.NotNull;
public class UserEmoteManager {
@@ -22,6 +25,13 @@ public class UserEmoteManager {
public void playEmote(String animationId) {
if (isPlayingEmote()) return;
if (user.isInWardrobe()) return;
// API
PlayerEmoteStartEvent event = new PlayerEmoteStartEvent(user, animationId);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
// Internal
try {
model = new UserEmoteModel(user);
model.playAnimation(animationId);
@@ -35,8 +45,22 @@ public class UserEmoteManager {
return model.isPlayingAnimation();
}
public void stopEmote() {
public void stopEmote(StopEmoteReason emoteReason) {
if (!isPlayingEmote()) return;
// API
PlayerEmoteStopEvent event = new PlayerEmoteStopEvent(user, emoteReason);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
// Internal
model.stopAnimation();
}
public enum StopEmoteReason {
SNEAK,
DAMAGE,
CONNECTION,
TELEPORT
}
}

View File

@@ -57,6 +57,11 @@ public class UserEmoteModel extends PlayerModel {
double DISTANCE = Settings.getEmoteDistance();
Location thirdPersonLocation = newLocation.add(newLocation.getDirection().normalize().multiply(DISTANCE));
if (DISTANCE > 0) {
MessagesUtil.sendDebugMessages("Yaw " + (int) thirdPersonLocation.getYaw());
MessagesUtil.sendDebugMessages("New Yaw " + ServerUtils.getNextYaw((int) thirdPersonLocation.getYaw(), 180));
thirdPersonLocation.setYaw(ServerUtils.getNextYaw((int) thirdPersonLocation.getYaw(), 180));
}
if (Settings.getCosmeticEmoteBlockCheck() && thirdPersonLocation.getBlock().getType().isOccluding()) {
stopAnimation();
MessagesUtil.sendMessage(player, "emote-blocked");
@@ -70,7 +75,7 @@ public class UserEmoteModel extends PlayerModel {
PacketManager.sendEntitySpawnPacket(thirdPersonLocation, armorStandId, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer);
PacketManager.sendInvisibilityPacket(armorStandId, viewer);
PacketManager.sendLookPacket(armorStandId, player.getLocation(), viewer);
PacketManager.sendLookPacket(armorStandId, thirdPersonLocation, viewer);
PacketManager.gamemodeChangePacket(player, 3);
PacketManager.sendCameraPacket(armorStandId, viewer);

View File

@@ -109,8 +109,8 @@ public class UserWardrobeManager {
}
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
PacketManager.sendLeashPacket(user.getBalloonManager().getPufferfishBalloonId(), -1, viewer);
PacketManager.sendLeashPacket(user.getBalloonManager().getPufferfishBalloonId(), NPC_ID, viewer); // This needs a possible fix
user.getBalloonManager().sendRemoveLeashPacket(viewer);
user.getBalloonManager().sendLeashPacket(NPC_ID);
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer);
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.clone().add(Settings.getBalloonOffset()), false, viewer);
@@ -156,25 +156,32 @@ public class UserWardrobeManager {
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
outsideViewers.remove(player);
MessagesUtil.sendMessage(player, "closed-wardrobe");
if (player != null) MessagesUtil.sendMessage(player, "closed-wardrobe");
Runnable run = () -> {
this.active = false;
// NPC
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) PacketManager.sendLeashPacket(user.getBalloonManager().getModelId(), -1, viewer);
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) user.getBalloonManager().sendRemoveLeashPacket();
PacketManager.sendEntityDestroyPacket(NPC_ID, viewer); // Success
PacketManager.sendRemovePlayerPacket(player, WARDROBE_UUID, viewer); // Success
// Player
PacketManager.sendCameraPacket(player.getEntityId(), viewer);
PacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(this.originalGamemode)); // Success
// Armorstand
PacketManager.sendEntityDestroyPacket(ARMORSTAND_ID, viewer); // Sucess
//PacketManager.sendEntityDestroyPacket(player.getEntityId(), viewer); // Success
if (WardrobeSettings.isForceExitGamemode()) {
MessagesUtil.sendDebugMessages("Force Exit Gamemode " + WardrobeSettings.getExitGamemode());
player.setGameMode(WardrobeSettings.getExitGamemode());
PacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(WardrobeSettings.getExitGamemode())); // Success
} else {
MessagesUtil.sendDebugMessages("Original Gamemode " + this.originalGamemode);
player.setGameMode(this.originalGamemode);
PacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(this.originalGamemode)); // Success
}
user.showPlayer();
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
@@ -200,7 +207,7 @@ public class UserWardrobeManager {
}
// For Wardrobe Temp Cosmetics
for (Cosmetic cosmetic : user.getCosmetic()) {
for (Cosmetic cosmetic : user.getCosmetics()) {
if (cosmetic.requiresPermission()) {
if (!player.hasPermission(cosmetic.getPermission())) user.removeCosmeticSlot(cosmetic.getSlot());
}
@@ -219,11 +226,11 @@ public class UserWardrobeManager {
public void run() {
Player player = user.getPlayer();
if (!active || player == null) {
MessagesUtil.sendDebugMessages("Active is false");
MessagesUtil.sendDebugMessages("WardrobeEnd[user=" + user.getUniqueId() + ",reason=Active is false]");
this.cancel();
return;
}
MessagesUtil.sendDebugMessages("Update ");
MessagesUtil.sendDebugMessages("WardrobeUpdate[user= " + user.getUniqueId() + ",status=" + getWardrobeStatus() + "]");
List<Player> viewer = Collections.singletonList(player);
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
outsideViewers.remove(player);
@@ -254,9 +261,9 @@ public class UserWardrobeManager {
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()), false, viewer);
user.getBalloonManager().getModelEntity().teleport(WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()));
PacketManager.sendLeashPacket(user.getBalloonManager().getPufferfishBalloonId(), -1, outsideViewers);
user.getBalloonManager().sendRemoveLeashPacket(outsideViewers);
PacketManager.sendEntityDestroyPacket(user.getBalloonManager().getModelId(), outsideViewers);
PacketManager.sendLeashPacket(user.getBalloonManager().getPufferfishBalloonId(), NPC_ID, viewer); // Pufferfish goes away for some reason?
user.getBalloonManager().sendLeashPacket(NPC_ID);
}
if (WardrobeSettings.isEquipPumpkin()) {

View File

@@ -1,8 +1,12 @@
package com.hibiscusmc.hmccosmetics.util;
import com.comphenix.protocol.wrappers.EnumWrappers;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataType;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -137,4 +141,19 @@ public class InventoryUtils {
}
}
}
public static boolean isCosmeticItem(ItemStack itemStack) {
if (itemStack == null) return false;
itemStack = itemStack.clone();
if (!itemStack.hasItemMeta()) return false;
return itemStack.getItemMeta().getPersistentDataContainer().has(getCosmeticKey(), PersistentDataType.STRING);
}
public static NamespacedKey getCosmeticKey() {
return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmetic");
}
public static NamespacedKey getOwnerKey() {
return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "owner");
}
}

View File

@@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
public class BasePacket {
public static void sendPacket(Player player, PacketContainer packet) {
if (player == null) return;
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false);
}
}

View File

@@ -135,7 +135,8 @@ public class PacketManager extends BasePacket {
packet.getModifier().writeDefaults();
packet.getIntegers().write(0, entityId);
WrappedDataWatcher wrapper = new WrappedDataWatcher();
if (!NMSHandlers.getVersion().contains("v1_19_R2")) {
if (NMSHandlers.getVersion().contains("v1_17_R1") || NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20);
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
} else {
@@ -305,8 +306,14 @@ public class PacketManager extends BasePacket {
WrappedGameProfile wrappedGameProfile = new WrappedGameProfile(uuid, name);
WrappedSignedProperty skinData = PlayerUtils.getSkin(skinnedPlayer);
if (skinData != null) wrappedGameProfile.getProperties().put("textures", skinData);
if (!NMSHandlers.getVersion().contains("v1_19_R2")) {
info.setData(List.of(new PlayerInfoData(wrappedGameProfile, 0, EnumWrappers.NativeGameMode.CREATIVE, WrappedChatComponent.fromText(name))));
// For sor some reason 1.19.2 handles it on the 0 field index, every other verison handles it on the 1
if (NMSHandlers.getVersion().contains("v1_19_R1")) {
info.getHandle().getPlayerInfoDataLists().write(0, Collections.singletonList(new PlayerInfoData(
wrappedGameProfile,
0,
EnumWrappers.NativeGameMode.CREATIVE,
WrappedChatComponent.fromText(name)
)));
} else {
info.getHandle().getPlayerInfoDataLists().write(1, Collections.singletonList(new PlayerInfoData(
wrappedGameProfile,
@@ -316,8 +323,6 @@ public class PacketManager extends BasePacket {
)));
}
for (final Player p : sendTo) sendPacket(p, info.getHandle());
return;
}
/**
@@ -364,7 +369,7 @@ public class PacketManager extends BasePacket {
final UUID uuid,
final List<Player> sendTo
) {
if (!NMSHandlers.getVersion().contains("v1_19_R2")) {
if (NMSHandlers.getVersion().contains("v1_17_R1") || NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
WrapperPlayServerPlayerInfo info = new WrapperPlayServerPlayerInfo();
info.setAction(EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);
@@ -377,6 +382,7 @@ public class PacketManager extends BasePacket {
for (final Player p : sendTo) sendPacket(p, info.getHandle());
return;
}
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO_REMOVE);
packet.getUUIDLists().write(0, List.of(uuid));
for (final Player p : sendTo) sendPacket(p, packet);

View File

@@ -26,11 +26,12 @@ public class WrapperPlayServerPlayerInfo extends AbstractPacket {
}
public void setAction(PlayerInfoAction value) {
if (!NMSHandlers.getVersion().contains("v1_19_R2")) {
if (NMSHandlers.getVersion().contains("v1_17_R1") || NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
handle.getPlayerInfoAction().write(0, value);
} else {
handle.getPlayerInfoActions().write(0, Set.of(value));
return;
}
// New way of handling it 1.19.3+
handle.getPlayerInfoActions().write(0, Set.of(value));
}
public List<PlayerInfoData> getData() {

View File

@@ -24,7 +24,18 @@ cosmetic-settings:
force-permission-join: true # Checks a player permission if they can have a cosmetic when they join the server.
emote-distance: -3 # This shows how far away the camera should be while a player is doing an emote. Negative is behind player.
emote-block-check: true # If the server should check if the block is open (prevents players viewing through blocks)
emote-block-check: true # If the server should check if the block is open where the camera is placed (prevents players viewing through blocks)
emote-damage-leave: true # If the player should leave the emote when they take damage
emote-invincible: false # If the player should not take damage while doing an emote
helmet-add-enchantments: false # If the plugin should keep enchants on helmets. This is useful as some enchantments are client side only.
chest-add-enchantments: false # If the plugin should keep enchants on chestplate. This is useful as some enchantments are client side only.
leggings-add-enchantments: false # If the plugin should keep enchants on leggings. This is useful as some enchantments are client side only.
boots-add-enchantments: false # If the plugin should keep enchants on boots. This is useful as some enchantments are client side only.
# This attempts to destroy cosmetics that get loose in the wild, such as through a player entering creative mode.
# Most servers who don't use creative mode and have properly set up the plugin should have no need for this and can leave it disabled.
destroy-loose-cosmetics: false
# view distance in blocks that other players will see the backpack cosmetic
# setting this to lower than the server player view distance should fix the
@@ -46,6 +57,10 @@ hook-settings:
# This causes the plugin to reload itself after any ItemsAdder change. This keeps the plugin fully up to date with IA, but
# could cause console spam as HMCCosmetics has to reload itself as well.
reload-on-change: false
worldguard:
# Checks worldguard regions for HMCC flags. If set to false, flags will not work properly.
# Requires restart to apply changes.
player-move-check: true
wardrobe:
# spawn static wardrobe if in this radius of wardrobe-location
static-radius: 10
@@ -55,6 +70,11 @@ wardrobe:
equip-pumpkin: false
# Rather than having a set exit location, this will send the player back to where they entered the wardrobe. Not recommended for WG regions
return-last-location: false
gamemode-options:
exit-gamemode-enabled: false # Setting this to false will set the gamemode the player came in as. True sets to exit-gamemode gamemode
exit-gamemode: "SURVIVAL" # Only activates if exit-gamemode-enabled is true, find gamemodes here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/GameMode.html
# Bossbar that shows when a player is in a wardrobe.
bossbar:
enabled: false
@@ -64,6 +84,8 @@ wardrobe:
color: BLUE
transition:
enabled: true
# If you use ItemsAdder, set this to "<black>%img_title%
# If you use Oraxen, set this to "<black><glyph:title>"
text: "<black>"
delay: 40
title-fade-in: 1000 # milliseconds

View File

@@ -111,3 +111,21 @@ explorer_backpack:
model-data: 3
name: "<white>Explorer's Backpack"
amount: 1
garbage_truck_balloon:
slot: BALLOON
permission: "hmccosmetics.garbage_truck_balloon"
model: garbage_truck_balloon
item:
material: PAPER
model-data: 14
name: "<green>Garbage Truck Balloon"
amount: 1
earth_day_grabber:
slot: OFFHAND
dyeable: true
permission: "hmccosmetics.earth_day_grabber"
item:
material: LEATHER_HORSE_ARMOR
model-data: 4
name: "<green>Earth Day Grabber"
amount: 1

View File

@@ -168,3 +168,25 @@ items:
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_explorer_backpack%"
type: cosmetic
cosmetic: explorer_backpack
garbage_truck_balloon:
slots:
- 16
item:
material: hmccosmetics:garbage_truck_balloon
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_garbage_truck_balloon%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_garbage_truck_balloon%"
type: cosmetic
cosmetic: garbage_truck_balloon
earth_day_grabber:
slots:
- 17
item:
material: hmccosmetics:earth_day_grabber
lore:
- ""
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_earth_day_grabber%"
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_earth_day_grabber%"
type: cosmetic
cosmetic: earth_day_grabber

View File

@@ -11,5 +11,6 @@ include(
"v1_17_R1",
"v1_18_R2",
"v1_19_R1",
"v1_19_R2"
"v1_19_R2",
"v1_19_R3",
)

View File

@@ -113,7 +113,7 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
PacketManager.sendLeashPacket(userBalloonManager1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
userBalloonManager1.sendLeashPacket(player.getEntityId());
return userBalloonManager1;
}

View File

@@ -115,7 +115,7 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
PacketManager.sendLeashPacket(userBalloonManager1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
userBalloonManager1.sendLeashPacket(player.getEntityId());
return userBalloonManager1;
}

View File

@@ -115,7 +115,7 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
PacketManager.sendLeashPacket(userBalloonManager1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
userBalloonManager1.sendLeashPacket(player.getEntityId());
return userBalloonManager1;
}

View File

@@ -115,7 +115,7 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
PacketManager.sendLeashPacket(userBalloonManager1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
userBalloonManager1.sendLeashPacket(player.getEntityId());
return userBalloonManager1;
}

27
v1_19_R3/build.gradle.kts Normal file
View File

@@ -0,0 +1,27 @@
plugins {
id("java")
id("io.papermc.paperweight.userdev") version "1.5.1"
}
dependencies {
paperDevBundle("1.19.4-R0.1-SNAPSHOT")
implementation(project(":common"))
}
tasks {
build {
dependsOn(reobfJar)
}
compileJava {
options.encoding = Charsets.UTF_8.name()
options.release.set(17)
}
javadoc {
options.encoding = Charsets.UTF_8.name()
}
processResources {
filteringCharset = Charsets.UTF_8.name()
}
}

View File

@@ -0,0 +1,24 @@
package com.hibiscusmc.hmccosmetics.nms.v1_19_R3;
import net.minecraft.world.entity.decoration.ArmorStand;
import net.minecraft.world.level.Level;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
public class HMCArmorStand extends ArmorStand {
public HMCArmorStand(Level world, double x, double y, double z) {
super(world, x, y, z);
}
public HMCArmorStand(Location loc) {
super(((CraftWorld) loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ());
this.setPos(loc.getX(), loc.getY(), loc.getZ());
setInvisible(true);
setInvulnerable(true);
setMarker(true);
setSilent(true);
getBukkitLivingEntity().setCollidable(false);
persist = false;
}
}

View File

@@ -0,0 +1,24 @@
package com.hibiscusmc.hmccosmetics.nms.v1_19_R3;
import net.minecraft.world.entity.AreaEffectCloud;
import net.minecraft.world.level.Level;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
public class HMCParticleCloud extends AreaEffectCloud {
public HMCParticleCloud(Level world, double x, double y, double z) {
super(world, x, y, z);
}
public HMCParticleCloud(Location loc) {
super(((CraftWorld) loc.getWorld()).getHandle(), loc.getX(), loc.getY(), loc.getZ());
this.setPos(loc.getX(), loc.getY(), loc.getZ());
setInvisible(true);
setInvulnerable(true);
setSilent(true);
setNoGravity(true);
persist = false;
}
}

View File

@@ -0,0 +1,30 @@
package com.hibiscusmc.hmccosmetics.nms.v1_19_R3;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.decoration.ArmorStand;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
import org.bukkit.persistence.PersistentDataType;
public class MEGEntity extends ArmorStand {
public MEGEntity(Location loc) {
super(EntityType.ARMOR_STAND, ((CraftWorld) loc.getWorld()).getHandle());
this.setPos(loc.getX(), loc.getY(), loc.getZ());
MessagesUtil.sendDebugMessages("Spawned MEGEntity at " + loc);
setInvisible(true);
setNoGravity(true);
setSilent(true);
setInvulnerable(true);
setSmall(true);
setMarker(true);
persist = false;
getBukkitEntity().getPersistentDataContainer().set(new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmeticMob"), PersistentDataType.SHORT, Short.valueOf("1"));
((CraftWorld) loc.getWorld()).getHandle().addFreshEntity(this);
}
}

View File

@@ -0,0 +1,250 @@
package com.hibiscusmc.hmccosmetics.nms.v1_19_R3;
import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
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.user.manager.UserBalloonManager;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
import com.mojang.datafixers.util.Pair;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerPlayerConnection;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.scores.PlayerTeam;
import net.minecraft.world.scores.Team;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_19_R3.CraftEquipmentSlot;
import org.bukkit.craftbukkit.v1_19_R3.CraftServer;
import org.bukkit.craftbukkit.v1_19_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_19_R3.scoreboard.CraftScoreboard;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
@Override
public int getNextEntityId() {
return Entity.nextEntityId();
}
@Override
public org.bukkit.entity.Entity getEntity(int entityId) {
net.minecraft.world.entity.Entity entity = getNMSEntity(entityId);
if (entity == null) return null;
return entity.getBukkitEntity();
}
private net.minecraft.world.entity.Entity getNMSEntity(int entityId) {
for (ServerLevel world : ((CraftServer) Bukkit.getServer()).getHandle().getServer().getAllLevels()) {
net.minecraft.world.entity.Entity entity = world.getEntity(entityId);
if (entity == null) return null;
return entity;
}
return null;
}
@Override
public org.bukkit.entity.Entity getHMCArmorStand(Location loc) {
HMCArmorStand hmcArmorStand = new HMCArmorStand(loc);
return hmcArmorStand.getBukkitEntity();
}
@Override
public org.bukkit.entity.Entity spawnHMCParticleCloud(Location location) {
HMCParticleCloud hmcParticleCloud = new HMCParticleCloud(location);
return hmcParticleCloud.getBukkitEntity();
}
@Override
public ArmorStand getMEGEntity(Location loc) {
return (ArmorStand) new MEGEntity(loc).getBukkitEntity();
}
@Override
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getPlayer().getLocation());
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
((CraftWorld) user.getPlayer().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
MessagesUtil.sendDebugMessages("spawnBackpack NMS");
return invisibleArmorstand.getBukkitLivingEntity();
//PacketManager.armorStandMetaPacket(invisibleArmorstand.getBukkitEntity(), sentTo);
//PacketManager.ridingMountPacket(player.getEntityId(), invisibleArmorstand.getId(), sentTo);
}
@Override
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
Player player = user.getPlayer();
Location newLoc = player.getLocation().clone().add(Settings.getBalloonOffset());
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user.getPlayer().getLocation());
List<Player> sentTo = PlayerUtils.getNearbyPlayers(player.getLocation());
userBalloonManager1.getModelEntity().teleport(user.getPlayer().getLocation().add(Settings.getBalloonOffset()));
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
userBalloonManager1.sendLeashPacket(player.getEntityId());
return userBalloonManager1;
}
@Override
public void equipmentSlotUpdate(
int entityId,
CosmeticUser user,
CosmeticSlot cosmeticSlot,
List<Player> sendTo
) {
EquipmentSlot nmsSlot = null;
net.minecraft.world.item.ItemStack nmsItem = null;
if (!(user.getCosmetic(cosmeticSlot) instanceof CosmeticArmorType)) {
if (user.getCosmetic(cosmeticSlot) instanceof CosmeticMainhandType) {
CosmeticMainhandType cosmeticMainhandType = (CosmeticMainhandType) user.getCosmetic(CosmeticSlot.MAINHAND);
nmsItem = CraftItemStack.asNMSCopy(user.getUserCosmeticItem(cosmeticMainhandType));
} else {
nmsItem = CraftItemStack.asNMSCopy(user.getPlayer().getInventory().getItem(InventoryUtils.getEquipmentSlot(cosmeticSlot)));
}
nmsSlot = CraftEquipmentSlot.getNMS(InventoryUtils.getEquipmentSlot(cosmeticSlot));
if (nmsSlot == null) return;
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = Collections.singletonList(pair);
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
for (Player p : sendTo) sendPacket(p, packet);
return;
}
CosmeticArmorType cosmeticArmor = (CosmeticArmorType) user.getCosmetic(cosmeticSlot);
// Converting EquipmentSlot and ItemStack to NMS ones.
nmsSlot = CraftEquipmentSlot.getNMS(cosmeticArmor.getEquipSlot());
nmsItem = CraftItemStack.asNMSCopy(user.getUserCosmeticItem(cosmeticArmor));
if (nmsSlot == null) return;
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = Collections.singletonList(pair);
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
for (Player p : sendTo) sendPacket(p, packet);
}
@Override
public void equipmentSlotUpdate(
int entityId,
org.bukkit.inventory.EquipmentSlot slot,
ItemStack item,
List<Player> sendTo
) {
EquipmentSlot nmsSlot = null;
net.minecraft.world.item.ItemStack nmsItem = null;
// Converting EquipmentSlot and ItemStack to NMS ones.
nmsSlot = CraftEquipmentSlot.getNMS(slot);
nmsItem = CraftItemStack.asNMSCopy(item);
if (nmsSlot == null) return;
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = Collections.singletonList(pair);
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
for (Player p : sendTo) sendPacket(p, packet);
}
@Override
public void slotUpdate(
Player player,
int slot
) {
int index = 0;
ServerPlayer player1 = ((CraftPlayer) player).getHandle();
if (index < Inventory.getSelectionSize()) {
index += 36;
} else if (index > 39) {
index += 5; // Off hand
} else if (index > 35) {
index = 8 - (index - 36);
}
ItemStack item = player.getInventory().getItem(slot);
Packet packet = new ClientboundContainerSetSlotPacket(player1.inventoryMenu.containerId, player1.inventoryMenu.incrementStateId(), index, CraftItemStack.asNMSCopy(item));
sendPacket(player, packet);
}
public void hideNPCName(Player player, String NPCName) {
//Creating the team
PlayerTeam team = new PlayerTeam(((CraftScoreboard) Bukkit.getScoreboardManager().getMainScoreboard()).getHandle(), NPCName);
//Setting name visibility
team.setNameTagVisibility(Team.Visibility.NEVER);
//Remove the Team (i assume so if it exists)
ClientboundSetPlayerTeamPacket removeTeamPacket = ClientboundSetPlayerTeamPacket.createRemovePacket(team);
sendPacket(player, removeTeamPacket);
//Creating the Team
ClientboundSetPlayerTeamPacket createTeamPacket = ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, true);
sendPacket(player, createTeamPacket);
//Adding players to the team (You have to use the NPC's name, and add it to a list)
ClientboundSetPlayerTeamPacket createPlayerTeamPacket = ClientboundSetPlayerTeamPacket.createMultiplePlayerPacket(team, new ArrayList<String>() {{
add(NPCName);
}}, ClientboundSetPlayerTeamPacket.Action.ADD);
sendPacket(player, createPlayerTeamPacket);
}
public void sendPacket(Player player, Packet packet) {
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
ServerPlayerConnection connection = serverPlayer.connection;
connection.send(packet);
}
@Override
public boolean getSupported() {
return true;
}
}