mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-26 10:29:06 +00:00
Compare commits
109 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8962539e8 | ||
|
|
01db728b99 | ||
|
|
8525dda6f4 | ||
|
|
e8f7f57e0b | ||
|
|
8c62b47d5b | ||
|
|
2ab0b119e7 | ||
|
|
20d919c65e | ||
|
|
bd41c5b9ff | ||
|
|
60aaf0cff6 | ||
|
|
71c8f8171b | ||
|
|
2bc4e3dd3f | ||
|
|
302eaa13c9 | ||
|
|
23ff51bab8 | ||
|
|
96ee695521 | ||
|
|
a9a587495a | ||
|
|
0b69e20adc | ||
|
|
a08e531226 | ||
|
|
1e27933573 | ||
|
|
0b4815842f | ||
|
|
cc6aec99e0 | ||
|
|
b51bace9f5 | ||
|
|
c70223a800 | ||
|
|
36353b5693 | ||
|
|
d4fc903c14 | ||
|
|
980d2d89df | ||
|
|
c952a8ac08 | ||
|
|
a651c9b8da | ||
|
|
c695e8b2f9 | ||
|
|
ee72bc2ef5 | ||
|
|
ebd47e9b56 | ||
|
|
5cf5e7c543 | ||
|
|
7f2d62b5e5 | ||
|
|
8d07f7cf9f | ||
|
|
789db52b57 | ||
|
|
5fb3458a98 | ||
|
|
f6935ce60b | ||
|
|
b1eb592137 | ||
|
|
913f8ccdf7 | ||
|
|
3f951263b9 | ||
|
|
744fc87491 | ||
|
|
ca01a94502 | ||
|
|
879a58d1f4 | ||
|
|
aab40b68a7 | ||
|
|
9533e2ec46 | ||
|
|
7b2e767cac | ||
|
|
4bdd000917 | ||
|
|
b397ae52f9 | ||
|
|
40620f1daa | ||
|
|
4d8d43ee2a | ||
|
|
4f8a32c3e8 | ||
|
|
1d303dee71 | ||
|
|
e9659ab1e8 | ||
|
|
ee917dbf32 | ||
|
|
2a275fe503 | ||
|
|
a5631cd2e4 | ||
|
|
1ed1a2c41d | ||
|
|
c2bf0322a7 | ||
|
|
3f8f84735f | ||
|
|
2fb28dda32 | ||
|
|
6192515550 | ||
|
|
6fcf893bac | ||
|
|
d0dfa19f2d | ||
|
|
c3b4abea40 | ||
|
|
a030d1272b | ||
|
|
d6c4b51b98 | ||
|
|
a306d76c19 | ||
|
|
1d51ee0711 | ||
|
|
e340874270 | ||
|
|
093b01d7ff | ||
|
|
5b129cc254 | ||
|
|
7a32697906 | ||
|
|
2ea272ee4a | ||
|
|
9ebfc9748d | ||
|
|
d1a2b6a016 | ||
|
|
af78424b07 | ||
|
|
c35546e536 | ||
|
|
7db03a2f8a | ||
|
|
99f3765e6e | ||
|
|
fae001a48f | ||
|
|
1ccb35ad62 | ||
|
|
2b4e570172 | ||
|
|
965b6cc740 | ||
|
|
ffda4ba6f5 | ||
|
|
df2da4fc89 | ||
|
|
cea40033f9 | ||
|
|
42a01a44aa | ||
|
|
17c07d0e01 | ||
|
|
ea4d088b04 | ||
|
|
591198175a | ||
|
|
be93369a8b | ||
|
|
fd6553a52a | ||
|
|
961f460ffb | ||
|
|
eb925d9022 | ||
|
|
d05072eb2c | ||
|
|
f456ddf8a4 | ||
|
|
c395b68d6a | ||
|
|
fddd5d0311 | ||
|
|
f08c38ff1a | ||
|
|
a4bd9108b1 | ||
|
|
de1377dc8f | ||
|
|
00ce32c528 | ||
|
|
0ddcb12b31 | ||
|
|
adadecfa19 | ||
|
|
ac35ef8b5d | ||
|
|
65f1c72b8e | ||
|
|
178bff37f5 | ||
|
|
48b9d4fb41 | ||
|
|
81d6583430 | ||
|
|
0304c9ff44 |
13
.github/CONTRIBUTING.md
vendored
Normal file
13
.github/CONTRIBUTING.md
vendored
Normal 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)!
|
||||||
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
2
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
2
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
@@ -1,7 +1,7 @@
|
|||||||
name: Feature Request
|
name: Feature Request
|
||||||
description: Create a feature request to help us keep track of all features you want to be added
|
description: Create a feature request to help us keep track of all features you want to be added
|
||||||
title: "[FEATURE] <title>"
|
title: "[FEATURE] <title>"
|
||||||
labels: [feature]
|
labels: [enhancement]
|
||||||
|
|
||||||
body:
|
body:
|
||||||
- type: "checkboxes"
|
- type: "checkboxes"
|
||||||
|
|||||||
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
16
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#### Select the option(s) that best describes this PR:
|
||||||
|
- [ ] Major breaking change
|
||||||
|
- [ ] Minor change
|
||||||
|
- [ ] Bug fix
|
||||||
|
- [ ] Feature implementation
|
||||||
|
- [ ] Documentation
|
||||||
|
- [ ] Cleaning
|
||||||
|
- [ ] Refactoring
|
||||||
|
|
||||||
|
#### 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.
|
||||||
@@ -8,7 +8,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "com.hibiscusmc"
|
group = "com.hibiscusmc"
|
||||||
version = "2.2.5"
|
version = "2.2.7"
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
@@ -59,6 +59,9 @@ allprojects {
|
|||||||
|
|
||||||
// PlayerAnimator
|
// PlayerAnimator
|
||||||
maven("https://mvn.lumine.io/repository/maven/")
|
maven("https://mvn.lumine.io/repository/maven/")
|
||||||
|
|
||||||
|
// md-5 Repo
|
||||||
|
maven("https://repo.md-5.net/content/groups/public/")
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -86,6 +89,7 @@ dependencies {
|
|||||||
implementation(project(path = ":v1_18_R2", configuration = "reobf"))
|
implementation(project(path = ":v1_18_R2", configuration = "reobf"))
|
||||||
implementation(project(path = ":v1_19_R1", configuration = "reobf"))
|
implementation(project(path = ":v1_19_R1", configuration = "reobf"))
|
||||||
implementation(project(path = ":v1_19_R2", 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")
|
//compileOnly("com.github.Fisher2911:FisherLib:master-SNAPSHOT")
|
||||||
implementation("net.kyori:adventure-api:4.11.0")
|
implementation("net.kyori:adventure-api:4.11.0")
|
||||||
@@ -116,7 +120,7 @@ tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runServer {
|
runServer {
|
||||||
minecraftVersion("1.19.2")
|
minecraftVersion("1.19.4")
|
||||||
}
|
}
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
@@ -124,6 +128,7 @@ tasks {
|
|||||||
dependsOn(":v1_18_R2:reobfJar")
|
dependsOn(":v1_18_R2:reobfJar")
|
||||||
dependsOn(":v1_19_R1:reobfJar")
|
dependsOn(":v1_19_R1:reobfJar")
|
||||||
dependsOn(":v1_19_R2:reobfJar")
|
dependsOn(":v1_19_R2:reobfJar")
|
||||||
|
dependsOn(":v1_19_R3:reobfJar")
|
||||||
mergeServiceFiles()
|
mergeServiceFiles()
|
||||||
|
|
||||||
relocate("dev.triumphteam.gui", "com.hisbiscusmc.hmccosmetics.gui")
|
relocate("dev.triumphteam.gui", "com.hisbiscusmc.hmccosmetics.gui")
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGListener;
|
|||||||
import com.hibiscusmc.hmccosmetics.listener.PlayerConnectionListener;
|
import com.hibiscusmc.hmccosmetics.listener.PlayerConnectionListener;
|
||||||
import com.hibiscusmc.hmccosmetics.listener.PlayerGameListener;
|
import com.hibiscusmc.hmccosmetics.listener.PlayerGameListener;
|
||||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||||
|
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 com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
|
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
|
||||||
import com.jeff_media.updatechecker.UpdateCheckSource;
|
import com.jeff_media.updatechecker.UpdateCheckSource;
|
||||||
@@ -120,7 +123,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WorldGuard
|
// WorldGuard
|
||||||
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null) {
|
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null && Settings.isWorldGuardMoveCheckEnabled()) {
|
||||||
getServer().getPluginManager().registerEvents(new WGListener(), this);
|
getServer().getPluginManager().registerEvents(new WGListener(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,11 +138,16 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
// Plugin shutdown logic
|
||||||
disable = true;
|
disable = true;
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
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() {
|
public static HMCCosmeticsPlugin getInstance() {
|
||||||
@@ -239,14 +247,16 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
|||||||
File[] emotesFiles = emoteFolder.listFiles();
|
File[] emotesFiles = emoteFolder.listFiles();
|
||||||
for (File emoteFile : emotesFiles) {
|
for (File emoteFile : emotesFiles) {
|
||||||
if (!emoteFile.getName().contains("bbmodel")) continue;
|
if (!emoteFile.getName().contains("bbmodel")) continue;
|
||||||
String animationName = emoteFile.getName().replaceAll(".bbmodel", "");
|
String animationName = FilenameUtils.removeExtension(emoteFile.getName());
|
||||||
PlayerAnimator.api.getAnimationManager().importAnimations(FilenameUtils.removeExtension(emoteFile.getName()), emoteFile);
|
PlayerAnimator.api.getAnimationManager().importAnimations(animationName, emoteFile);
|
||||||
MessagesUtil.sendDebugMessages("Added '" + animationName + "' to Player Animator ");
|
MessagesUtil.sendDebugMessages("Added '" + animationName + "' to Player Animator ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
for (Map.Entry<String, AnimationPack> packEntry : PlayerAnimator.api.getAnimationManager().getRegistry().entrySet()) {
|
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());
|
Set<String> animationNames = packEntry.getValue().getAnimations().keySet().stream().map(animation -> packEntry.getKey().replace(":", ".") + "." + animation).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
|
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
|
||||||
|
|||||||
@@ -4,12 +4,10 @@ import org.bukkit.event.Event;
|
|||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the plugin is set up and/or reloaded
|
||||||
|
*/
|
||||||
public class HMCCosmeticSetupEvent extends Event {
|
public class HMCCosmeticSetupEvent extends Event {
|
||||||
|
|
||||||
public HMCCosmeticSetupEvent() {
|
|
||||||
// Empty
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -18,6 +16,7 @@ public class HMCCosmeticSetupEvent extends Event {
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,53 +3,68 @@ package com.hibiscusmc.hmccosmetics.api;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class PlayerCosmeticEquipEvent extends Event implements Cancellable {
|
/**
|
||||||
|
* Called when a player equips a cosmetic
|
||||||
private final CosmeticUser user;
|
*/
|
||||||
|
public class PlayerCosmeticEquipEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
private Cosmetic cosmetic;
|
private Cosmetic cosmetic;
|
||||||
private boolean isCancelled;
|
|
||||||
|
|
||||||
public PlayerCosmeticEquipEvent(CosmeticUser user, Cosmetic cosmetic) {
|
public PlayerCosmeticEquipEvent(@NotNull CosmeticUser who, @NotNull Cosmetic cosmetic) {
|
||||||
this.user = user;
|
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.cosmetic = cosmetic;
|
||||||
this.isCancelled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
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
|
@Override
|
||||||
public void setCancelled(boolean cancel) {
|
public void setCancelled(boolean cancel) {
|
||||||
isCancelled = cancel;
|
this.cancel = cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CosmeticUser getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Cosmetic getCosmetic() {
|
|
||||||
return cosmetic;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCosmetic(Cosmetic cosmetic) {
|
|
||||||
this.cosmetic = cosmetic;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,48 +2,59 @@ package com.hibiscusmc.hmccosmetics.api;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class PlayerCosmeticHideEvent extends Event implements Cancellable {
|
/**
|
||||||
|
* Called when cosmetics are hidden from a player
|
||||||
private final CosmeticUser user;
|
*/
|
||||||
|
public class PlayerCosmeticHideEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
private final CosmeticUser.HiddenReason reason;
|
private final CosmeticUser.HiddenReason reason;
|
||||||
private boolean isCancelled;
|
|
||||||
|
|
||||||
public PlayerCosmeticHideEvent(CosmeticUser user, CosmeticUser.HiddenReason reason) {
|
public PlayerCosmeticHideEvent(@NotNull CosmeticUser who, @NotNull CosmeticUser.HiddenReason reason) {
|
||||||
this.user = user;
|
super(who);
|
||||||
this.reason = reason;
|
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
|
@Override
|
||||||
public boolean isCancelled() {
|
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
|
@Override
|
||||||
public void setCancelled(boolean cancel) {
|
public void setCancelled(boolean cancel) {
|
||||||
isCancelled = cancel;
|
this.cancel = cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CosmeticUser getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
public CosmeticUser.HiddenReason getReason() {
|
|
||||||
return reason;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,34 +3,50 @@ package com.hibiscusmc.hmccosmetics.api;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class PlayerCosmeticRemoveEvent extends Event implements Cancellable {
|
/**
|
||||||
|
* Called when a player removes a cosmetic
|
||||||
private final CosmeticUser user;
|
*/
|
||||||
|
public class PlayerCosmeticRemoveEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
private final Cosmetic cosmetic;
|
private final Cosmetic cosmetic;
|
||||||
private boolean isCancelled;
|
|
||||||
|
|
||||||
public PlayerCosmeticRemoveEvent(CosmeticUser user, Cosmetic cosmetic) {
|
public PlayerCosmeticRemoveEvent(@NotNull CosmeticUser who, @NotNull Cosmetic cosmetic) {
|
||||||
this.user = user;
|
super(who);
|
||||||
this.cosmetic = cosmetic;
|
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
|
@Override
|
||||||
public boolean isCancelled() {
|
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
|
@Override
|
||||||
public void setCancelled(boolean cancel) {
|
public void setCancelled(boolean cancel) {
|
||||||
isCancelled = cancel;
|
this.cancel = cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
@@ -40,12 +56,4 @@ public class PlayerCosmeticRemoveEvent extends Event implements Cancellable {
|
|||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CosmeticUser getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Cosmetic getCosmetic() {
|
|
||||||
return cosmetic;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,43 +2,47 @@ package com.hibiscusmc.hmccosmetics.api;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
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;
|
public PlayerCosmeticShowEvent(@NotNull CosmeticUser who) {
|
||||||
private boolean isCancelled;
|
super(who);
|
||||||
|
|
||||||
public PlayerCosmeticShowEvent(CosmeticUser user) {
|
|
||||||
this.user = user;
|
|
||||||
this.isCancelled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
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
|
@Override
|
||||||
public void setCancelled(boolean cancel) {
|
public void setCancelled(boolean cancel) {
|
||||||
isCancelled = cancel;
|
this.cancel = cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CosmeticUser getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,49 +2,60 @@ package com.hibiscusmc.hmccosmetics.api;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class PlayerEmoteStartEvent extends Event implements Cancellable {
|
/**
|
||||||
|
* 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;
|
||||||
|
|
||||||
private final CosmeticUser user;
|
public PlayerEmoteStartEvent(@NotNull CosmeticUser who, @NotNull String animationId) {
|
||||||
private String animationId; // Animation id can be invalid!
|
super(who);
|
||||||
private boolean isCancelled;
|
|
||||||
|
|
||||||
public PlayerEmoteStartEvent(CosmeticUser user, String animationId) {
|
|
||||||
this.user = user;
|
|
||||||
this.animationId = animationId;
|
this.animationId = animationId;
|
||||||
this.isCancelled = false;
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return 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
|
@Override
|
||||||
public void setCancelled(boolean cancel) {
|
public void setCancelled(boolean cancel) {
|
||||||
isCancelled = cancel;
|
this.cancel = cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CosmeticUser getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAnimationId() {
|
|
||||||
return animationId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -3,49 +3,72 @@ package com.hibiscusmc.hmccosmetics.api;
|
|||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class PlayerEmoteStopEvent extends Event implements Cancellable {
|
/**
|
||||||
|
* 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;
|
||||||
|
|
||||||
private final CosmeticUser user;
|
public PlayerEmoteStopEvent(@NotNull CosmeticUser who, @NotNull UserEmoteManager.StopEmoteReason reason) {
|
||||||
private final UserEmoteManager.StopEmoteReason stopEmoteReason;
|
super(who);
|
||||||
private boolean isCancelled;
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
public PlayerEmoteStopEvent(CosmeticUser user, UserEmoteManager.StopEmoteReason reason) {
|
/**
|
||||||
this.user = user;
|
* Gets the {@link UserEmoteManager.StopEmoteReason} as to why the emote has stopped playing
|
||||||
this.stopEmoteReason = reason;
|
*
|
||||||
this.isCancelled = false;
|
* @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
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return 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
|
@Override
|
||||||
public void setCancelled(boolean cancel) {
|
public void setCancelled(boolean cancel) {
|
||||||
isCancelled = cancel;
|
this.cancel = cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CosmeticUser getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserEmoteManager.StopEmoteReason getStopEmoteReason() {
|
|
||||||
return stopEmoteReason;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,49 +3,47 @@ package com.hibiscusmc.hmccosmetics.api;
|
|||||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
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;
|
public PlayerMenuOpenEvent(@NotNull CosmeticUser who, @NotNull Menu menu) {
|
||||||
private final Menu menu;
|
super(who, menu);
|
||||||
private boolean isCancelled;
|
|
||||||
|
|
||||||
public PlayerMenuOpenEvent(CosmeticUser user, Menu menu) {
|
|
||||||
this.user = user;
|
|
||||||
this.menu = menu;
|
|
||||||
this.isCancelled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
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
|
@Override
|
||||||
public void setCancelled(boolean cancel) {
|
public void setCancelled(boolean cancel) {
|
||||||
isCancelled = cancel;
|
this.cancel = cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CosmeticUser getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Menu getMenu() {
|
|
||||||
return menu;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,43 +2,47 @@ package com.hibiscusmc.hmccosmetics.api;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
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;
|
public PlayerWardrobeEnterEvent(@NotNull CosmeticUser who) {
|
||||||
private boolean isCancelled;
|
super(who);
|
||||||
|
|
||||||
public PlayerWardrobeEnterEvent(CosmeticUser user) {
|
|
||||||
this.user = user;
|
|
||||||
this.isCancelled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
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
|
@Override
|
||||||
public void setCancelled(boolean cancel) {
|
public void setCancelled(boolean cancel) {
|
||||||
isCancelled = cancel;
|
this.cancel = cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CosmeticUser getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,43 +2,47 @@ package com.hibiscusmc.hmccosmetics.api;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
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;
|
public PlayerWardrobeLeaveEvent(@NotNull CosmeticUser who) {
|
||||||
private boolean isCancelled;
|
super(who);
|
||||||
|
|
||||||
public PlayerWardrobeLeaveEvent(CosmeticUser user) {
|
|
||||||
this.user = user;
|
|
||||||
this.isCancelled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
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
|
@Override
|
||||||
public void setCancelled(boolean cancel) {
|
public void setCancelled(boolean cancel) {
|
||||||
isCancelled = cancel;
|
this.cancel = cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CosmeticUser getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class CosmeticCommand implements CommandExecutor {
|
public class CosmeticCommand implements CommandExecutor {
|
||||||
@@ -333,7 +332,7 @@ public class CosmeticCommand implements CommandExecutor {
|
|||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||||
player.sendMessage("Backpack Location -> " + user.getUserBackpackManager().getArmorStand().getLocation());
|
player.sendMessage("Backpack Location -> " + user.getUserBackpackManager().getArmorStand().getLocation());
|
||||||
}
|
}
|
||||||
player.sendMessage("Cosmetics -> " + user.getCosmetic());
|
player.sendMessage("Cosmetics -> " + user.getCosmetics());
|
||||||
player.sendMessage("EntityId -> " + player.getEntityId());
|
player.sendMessage("EntityId -> " + player.getEntityId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class CosmeticCommandTabComplete implements TabCompleter {
|
|||||||
completions.addAll(applyCommandComplete(user, args));
|
completions.addAll(applyCommandComplete(user, args));
|
||||||
}
|
}
|
||||||
case "unapply" -> {
|
case "unapply" -> {
|
||||||
for (Cosmetic cosmetic : user.getCosmetic()) {
|
for (Cosmetic cosmetic : user.getCosmetics()) {
|
||||||
completions.add(cosmetic.getSlot().toString().toUpperCase());
|
completions.add(cosmetic.getSlot().toString().toUpperCase());
|
||||||
}
|
}
|
||||||
completions.add("ALL");
|
completions.add("ALL");
|
||||||
|
|||||||
@@ -2,10 +2,13 @@ package com.hibiscusmc.hmccosmetics.config;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Settings {
|
public class Settings {
|
||||||
|
|
||||||
// General Settings
|
// General Settings
|
||||||
@@ -35,6 +38,9 @@ public class Settings {
|
|||||||
private static final String HOOK_SETTING_PATH = "hook-settings";
|
private static final String HOOK_SETTING_PATH = "hook-settings";
|
||||||
private static final String HOOK_ITEMADDER_PATH = "itemsadder";
|
private static final String HOOK_ITEMADDER_PATH = "itemsadder";
|
||||||
private static final String HOOK_RELOAD_CHANGE_PATH = "reload-on-change";
|
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_CHECK_PATH = "emote-block-check";
|
||||||
private static final String COSMETIC_EMOTE_DAMAGE_PATH = "emote-damage-leave";
|
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_EMOTE_INVINCIBLE_PATH = "emote-invincible";
|
||||||
@@ -42,6 +48,7 @@ public class Settings {
|
|||||||
private static final String COSMETIC_ADD_ENCHANTS_CHESTPLATE_PATH = "chest-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_LEGGINGS_PATH = "leggings-add-enchantments";
|
||||||
private static final String COSMETIC_ADD_ENCHANTS_BOOTS_PATH = "boots-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 defaultMenu;
|
||||||
private static String dyeMenuName;
|
private static String dyeMenuName;
|
||||||
@@ -57,6 +64,7 @@ public class Settings {
|
|||||||
private static boolean unapplyOnDeath;
|
private static boolean unapplyOnDeath;
|
||||||
private static boolean forcePermissionJoin;
|
private static boolean forcePermissionJoin;
|
||||||
private static boolean itemsAdderChangeReload;
|
private static boolean itemsAdderChangeReload;
|
||||||
|
private static boolean worldGuardMoveCheck;
|
||||||
private static boolean cosmeticEmoteBlockCheck;
|
private static boolean cosmeticEmoteBlockCheck;
|
||||||
private static boolean addHelmetEnchants;
|
private static boolean addHelmetEnchants;
|
||||||
private static boolean addChestplateEnchants;
|
private static boolean addChestplateEnchants;
|
||||||
@@ -64,6 +72,7 @@ public class Settings {
|
|||||||
private static boolean addBootsEnchants;
|
private static boolean addBootsEnchants;
|
||||||
private static boolean emoteDamageLeave;
|
private static boolean emoteDamageLeave;
|
||||||
private static boolean emoteInvincible;
|
private static boolean emoteInvincible;
|
||||||
|
private static boolean destroyLooseCosmetics;
|
||||||
private static int lookDownPitch;
|
private static int lookDownPitch;
|
||||||
private static int viewDistance;
|
private static int viewDistance;
|
||||||
private static int tickPeriod;
|
private static int tickPeriod;
|
||||||
@@ -98,6 +107,7 @@ public class Settings {
|
|||||||
cosmeticEmoteBlockCheck = cosmeticSettings.node(COSMETIC_EMOTE_CHECK_PATH).getBoolean(true);
|
cosmeticEmoteBlockCheck = cosmeticSettings.node(COSMETIC_EMOTE_CHECK_PATH).getBoolean(true);
|
||||||
emoteDamageLeave = cosmeticSettings.node(COSMETIC_EMOTE_DAMAGE_PATH).getBoolean(false);
|
emoteDamageLeave = cosmeticSettings.node(COSMETIC_EMOTE_DAMAGE_PATH).getBoolean(false);
|
||||||
emoteInvincible = cosmeticSettings.node(COSMETIC_EMOTE_INVINCIBLE_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);
|
addHelmetEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_HELMET_PATH).getBoolean(false);
|
||||||
addChestplateEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_CHESTPLATE_PATH).getBoolean(false);
|
addChestplateEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_CHESTPLATE_PATH).getBoolean(false);
|
||||||
addLeggingEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_LEGGINGS_PATH).getBoolean(false);
|
addLeggingEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_LEGGINGS_PATH).getBoolean(false);
|
||||||
@@ -120,6 +130,14 @@ public class Settings {
|
|||||||
ConfigurationNode hookSettings = source.node(HOOK_SETTING_PATH);
|
ConfigurationNode hookSettings = source.node(HOOK_SETTING_PATH);
|
||||||
ConfigurationNode itemsAdderSettings = hookSettings.node(HOOK_ITEMADDER_PATH);
|
ConfigurationNode itemsAdderSettings = hookSettings.node(HOOK_ITEMADDER_PATH);
|
||||||
itemsAdderChangeReload = itemsAdderSettings.node(HOOK_RELOAD_CHANGE_PATH).getBoolean(false);
|
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) {
|
private static Vector loadVector(final ConfigurationNode config) {
|
||||||
@@ -253,6 +271,14 @@ public class Settings {
|
|||||||
return emoteInvincible;
|
return emoteInvincible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isWorldGuardMoveCheckEnabled() {
|
||||||
|
return worldGuardMoveCheck;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isDestroyLooseCosmetics() {
|
||||||
|
return destroyLooseCosmetics;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean getShouldAddEnchants(EquipmentSlot slot) {
|
public static boolean getShouldAddEnchants(EquipmentSlot slot) {
|
||||||
switch (slot) {
|
switch (slot) {
|
||||||
case HEAD -> {
|
case HEAD -> {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|||||||
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
|
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
|
||||||
import net.kyori.adventure.bossbar.BossBar;
|
import net.kyori.adventure.bossbar.BossBar;
|
||||||
import org.apache.commons.lang3.EnumUtils;
|
import org.apache.commons.lang3.EnumUtils;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
import org.spongepowered.configurate.serialize.SerializationException;
|
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 LEAVE_LOCATION_PATH = "leave-location";
|
||||||
private static final String EQUIP_PUMPKIN_WARDROBE = "equip-pumpkin";
|
private static final String EQUIP_PUMPKIN_WARDROBE = "equip-pumpkin";
|
||||||
private static final String RETURN_LAST_LOCATION = "return-last-location";
|
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_PATH = "bossbar";
|
||||||
private static final String BOSSBAR_ENABLE_PATH = "enabled";
|
private static final String BOSSBAR_ENABLE_PATH = "enabled";
|
||||||
private static final String BOSSBAR_TEXT_PATH = "text";
|
private static final String BOSSBAR_TEXT_PATH = "text";
|
||||||
@@ -57,6 +61,8 @@ public class WardrobeSettings {
|
|||||||
private static boolean equipPumpkin;
|
private static boolean equipPumpkin;
|
||||||
private static boolean returnLastLocation;
|
private static boolean returnLastLocation;
|
||||||
private static boolean enabledBossbar;
|
private static boolean enabledBossbar;
|
||||||
|
private static boolean forceExitGamemode;
|
||||||
|
private static GameMode exitGamemode;
|
||||||
private static Location wardrobeLocation;
|
private static Location wardrobeLocation;
|
||||||
private static Location viewerLocation;
|
private static Location viewerLocation;
|
||||||
private static Location leaveLocation;
|
private static Location leaveLocation;
|
||||||
@@ -85,6 +91,10 @@ public class WardrobeSettings {
|
|||||||
equipPumpkin = source.node(EQUIP_PUMPKIN_WARDROBE).getBoolean();
|
equipPumpkin = source.node(EQUIP_PUMPKIN_WARDROBE).getBoolean();
|
||||||
returnLastLocation = source.node(RETURN_LAST_LOCATION).getBoolean(false);
|
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);
|
ConfigurationNode bossBarNode = source.node(BOSSBAR_PATH);
|
||||||
enabledBossbar = bossBarNode.node(BOSSBAR_ENABLE_PATH).getBoolean(false);
|
enabledBossbar = bossBarNode.node(BOSSBAR_ENABLE_PATH).getBoolean(false);
|
||||||
bossbarProgress = bossBarNode.node(BOSSBAR_PROGRESS_PATH).getFloat(1.0f);
|
bossbarProgress = bossBarNode.node(BOSSBAR_PROGRESS_PATH).getFloat(1.0f);
|
||||||
@@ -227,6 +237,14 @@ public class WardrobeSettings {
|
|||||||
return transitionFadeOut;
|
return transitionFadeOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isForceExitGamemode() {
|
||||||
|
return forceExitGamemode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GameMode getExitGamemode() {
|
||||||
|
return exitGamemode;
|
||||||
|
}
|
||||||
|
|
||||||
public static void setWardrobeLocation(Location newLocation) {
|
public static void setWardrobeLocation(Location newLocation) {
|
||||||
wardrobeLocation = newLocation;
|
wardrobeLocation = newLocation;
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|||||||
import org.apache.commons.lang3.EnumUtils;
|
import org.apache.commons.lang3.EnumUtils;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||||
import org.spongepowered.configurate.ConfigurateException;
|
import org.spongepowered.configurate.ConfigurateException;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
@@ -33,6 +34,7 @@ public class Cosmetics {
|
|||||||
COSMETICS.remove(cosmetic);
|
COSMETICS.remove(cosmetic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public static Cosmetic getCosmetic(String id) {
|
public static Cosmetic getCosmetic(String id) {
|
||||||
return COSMETICS.get(id);
|
return COSMETICS.get(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,12 +19,15 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
|
|
||||||
private final String modelName;
|
private final String modelName;
|
||||||
private List<String> dyableParts;
|
private List<String> dyableParts;
|
||||||
|
private boolean showLead;
|
||||||
|
|
||||||
public CosmeticBalloonType(String id, ConfigurationNode config) {
|
public CosmeticBalloonType(String id, ConfigurationNode config) {
|
||||||
super(id, config);
|
super(id, config);
|
||||||
|
|
||||||
String modelId = config.node("model").getString();
|
String modelId = config.node("model").getString();
|
||||||
|
|
||||||
|
showLead = config.node("show-lead").getBoolean(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!config.node("dyable-parts").virtual()) {
|
if (!config.node("dyable-parts").virtual()) {
|
||||||
dyableParts = config.node("dyable-parts").getList(String.class);
|
dyableParts = config.node("dyable-parts").getList(String.class);
|
||||||
@@ -45,6 +48,11 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
if (player == null || userBalloonManager == null) return;
|
if (player == null || userBalloonManager == null) return;
|
||||||
if (user.isInWardrobe()) return;
|
if (user.isInWardrobe()) return;
|
||||||
|
|
||||||
|
if (!userBalloonManager.getModelEntity().isValid()) {
|
||||||
|
user.respawnBalloon();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Location newLocation = player.getLocation();
|
Location newLocation = player.getLocation();
|
||||||
Location currentLocation = user.getBalloonManager().getLocation();
|
Location currentLocation = user.getBalloonManager().getLocation();
|
||||||
newLocation = newLocation.clone().add(Settings.getBalloonOffset());
|
newLocation = newLocation.clone().add(Settings.getBalloonOffset());
|
||||||
@@ -63,7 +71,7 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
userBalloonManager.setLocation(newLocation);
|
userBalloonManager.setLocation(newLocation);
|
||||||
|
|
||||||
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
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() {
|
public String getModelName() {
|
||||||
@@ -80,4 +88,8 @@ public class CosmeticBalloonType extends Cosmetic {
|
|||||||
if (dyableParts.isEmpty()) return true;
|
if (dyableParts.isEmpty()) return true;
|
||||||
return dyableParts.contains(name);
|
return dyableParts.contains(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isShowLead() {
|
||||||
|
return showLead;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public abstract class Data {
|
|||||||
data = "HIDDEN=" + user.getHiddenReason();
|
data = "HIDDEN=" + user.getHiddenReason();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Cosmetic cosmetic : user.getCosmetic()) {
|
for (Cosmetic cosmetic : user.getCosmetics()) {
|
||||||
Color color = user.getCosmeticColor(cosmetic.getSlot());
|
Color color = user.getCosmeticColor(cosmetic.getSlot());
|
||||||
String input = cosmetic.getSlot() + "=" + cosmetic.getId();
|
String input = cosmetic.getSlot() + "=" + cosmetic.getId();
|
||||||
if (color != null) input = input + "&" + color.asRGB();
|
if (color != null) input = input + "&" + color.asRGB();
|
||||||
|
|||||||
@@ -2,45 +2,92 @@ package com.hibiscusmc.hmccosmetics.hooks;
|
|||||||
|
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.inventory.ItemStack;
|
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 final String id;
|
||||||
private boolean active;
|
private boolean active = false;
|
||||||
private boolean itemHook;
|
private boolean itemHook = false;
|
||||||
|
|
||||||
public Hook(String id) {
|
public Hook(@NotNull String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
active = false;
|
|
||||||
Hooks.addHook(this);
|
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;
|
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;
|
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() {
|
public boolean getActive() {
|
||||||
return this.active;
|
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;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,13 +67,13 @@ public class Hooks {
|
|||||||
if (!isItemHook(split[0])) return null;
|
if (!isItemHook(split[0])) return null;
|
||||||
Hook hook = getHook(split[0]);
|
Hook hook = getHook(split[0]);
|
||||||
if (!hook.hasEnabledItemHook()) return null;
|
if (!hook.hasEnabledItemHook()) return null;
|
||||||
if (!hook.getActive()) return null;
|
if (!hook.isActive()) return null;
|
||||||
return hook.getItem(split[1]);
|
return hook.getItem(split[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isActiveHook(String id) {
|
public static boolean isActiveHook(String id) {
|
||||||
Hook hook = getHook(id);
|
Hook hook = getHook(id);
|
||||||
if (hook == null) return false;
|
if (hook == null) return false;
|
||||||
return hook.getActive();
|
return hook.isActive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,23 @@ package com.hibiscusmc.hmccosmetics.hooks.items;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
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() {
|
public HookHMCCosmetics() {
|
||||||
super("HMCCosmetics");
|
super("HMCCosmetics");
|
||||||
setEnabledItemHook(true);
|
setEnabledItemHook(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin HMCCosmetics}
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(String itemId) {
|
public ItemStack getItem(@NotNull String itemId) {
|
||||||
Cosmetic cosmetic = Cosmetics.getCosmetic(itemId);
|
Cosmetic cosmetic = Cosmetics.getCosmetic(itemId);
|
||||||
if (cosmetic == null) return null;
|
if (cosmetic == null) return null;
|
||||||
return cosmetic.getItem();
|
return cosmetic.getItem();
|
||||||
|
|||||||
@@ -7,11 +7,14 @@ import dev.lone.itemsadder.api.CustomStack;
|
|||||||
import dev.lone.itemsadder.api.Events.ItemsAdderLoadDataEvent;
|
import dev.lone.itemsadder.api.Events.ItemsAdderLoadDataEvent;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
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;
|
private boolean enabled = false;
|
||||||
|
|
||||||
public HookItemAdder() {
|
public HookItemAdder() {
|
||||||
@@ -19,8 +22,11 @@ public class HookItemAdder extends Hook implements Listener {
|
|||||||
setEnabledItemHook(true);
|
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
|
@Override
|
||||||
public ItemStack getItem(String itemId) {
|
public ItemStack getItem(@NotNull String itemId) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
CustomStack stack = CustomStack.getInstance(itemId);
|
CustomStack stack = CustomStack.getInstance(itemId);
|
||||||
if (stack == null) return null;
|
if (stack == null) return null;
|
||||||
@@ -32,7 +38,8 @@ public class HookItemAdder extends Hook implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onItemAdderDataLoad(ItemsAdderLoadDataEvent event) {
|
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;
|
this.enabled = true;
|
||||||
HMCCosmeticsPlugin.setup();
|
HMCCosmeticsPlugin.setup();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,24 @@ package com.hibiscusmc.hmccosmetics.hooks.items;
|
|||||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
import com.mineinabyss.geary.prefabs.PrefabKey;
|
import com.mineinabyss.geary.prefabs.PrefabKey;
|
||||||
import com.mineinabyss.looty.LootyFactory;
|
import com.mineinabyss.looty.LootyFactory;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
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() {
|
public HookLooty() {
|
||||||
super("looty");
|
super("looty");
|
||||||
setEnabledItemHook(true);
|
setEnabledItemHook(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.mineinabyss.looty.LootyPlugin Looty}
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(String itemId) {
|
public ItemStack getItem(@NotNull String itemId) {
|
||||||
PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId);
|
PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId);
|
||||||
if (prefabKey == null) return null;
|
if (prefabKey == null) return null;
|
||||||
return LootyFactory.INSTANCE.createFromPrefab(prefabKey);
|
return LootyFactory.INSTANCE.createFromPrefab(prefabKey);
|
||||||
|
|||||||
@@ -2,17 +2,24 @@ package com.hibiscusmc.hmccosmetics.hooks.items;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
import io.lumine.mythic.bukkit.MythicBukkit;
|
import io.lumine.mythic.bukkit.MythicBukkit;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
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() {
|
public HookMythic() {
|
||||||
super("mythicmobs");
|
super("mythicmobs");
|
||||||
setEnabledItemHook(true);
|
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
|
@Override
|
||||||
public ItemStack getItem(String itemId) {
|
public ItemStack getItem(@NotNull String itemId) {
|
||||||
return MythicBukkit.inst().getItemManager().getItemStack(itemId);
|
return MythicBukkit.inst().getItemManager().getItemStack(itemId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,24 @@ package com.hibiscusmc.hmccosmetics.hooks.items;
|
|||||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
import io.th0rgal.oraxen.api.OraxenItems;
|
import io.th0rgal.oraxen.api.OraxenItems;
|
||||||
import io.th0rgal.oraxen.items.ItemBuilder;
|
import io.th0rgal.oraxen.items.ItemBuilder;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
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() {
|
public HookOraxen() {
|
||||||
super("oraxen");
|
super("oraxen");
|
||||||
setEnabledItemHook(true);
|
setEnabledItemHook(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link io.th0rgal.oraxen.OraxenPlugin OraxenPlugin}
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(String itemId) {
|
public ItemStack getItem(@NotNull String itemId) {
|
||||||
ItemBuilder builder = OraxenItems.getItemById(itemId);
|
ItemBuilder builder = OraxenItems.getItemById(itemId);
|
||||||
if (builder == null) return null;
|
if (builder == null) return null;
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
|||||||
@@ -7,11 +7,12 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
|||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
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() {
|
public HookCMI() {
|
||||||
super("CMI");
|
super("CMI");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.hooks.misc;
|
package com.hibiscusmc.hmccosmetics.hooks.misc;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
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() {
|
public HookHMCColor() {
|
||||||
super("HMCColor");
|
super("HMCColor");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,13 +7,14 @@ import de.myzelyam.api.vanish.PlayerHideEvent;
|
|||||||
import de.myzelyam.api.vanish.PlayerShowEvent;
|
import de.myzelyam.api.vanish.PlayerShowEvent;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class HookPremiumVanish extends Hook implements Listener {
|
/**
|
||||||
|
* A hook that integrates the plugin {@link de.myzelyam.api.vanish.VanishAPI Supervanish}
|
||||||
// NOTE: Supervanish and Premium Vanish both use the same api
|
*
|
||||||
|
* @implSpec Supervanish and Premium Vanish both use the same api
|
||||||
|
*/
|
||||||
|
public class HookPremiumVanish extends Hook {
|
||||||
public HookPremiumVanish() {
|
public HookPremiumVanish() {
|
||||||
super("PremiumVanish");
|
super("PremiumVanish");
|
||||||
}
|
}
|
||||||
@@ -33,5 +34,4 @@ public class HookPremiumVanish extends Hook implements Listener {
|
|||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
user.showCosmetics();
|
user.showCosmetics();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,13 +7,14 @@ import de.myzelyam.api.vanish.PlayerHideEvent;
|
|||||||
import de.myzelyam.api.vanish.PlayerShowEvent;
|
import de.myzelyam.api.vanish.PlayerShowEvent;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class HookSuperVanish extends Hook implements Listener {
|
/**
|
||||||
|
* A hook that integrates the plugin {@link de.myzelyam.api.vanish.VanishAPI Supervanish}
|
||||||
// NOTE: Supervanish and Premium Vanish both use the same api
|
*
|
||||||
|
* @implSpec Supervanish and Premium Vanish both use the same api
|
||||||
|
*/
|
||||||
|
public class HookSuperVanish extends Hook {
|
||||||
public HookSuperVanish() {
|
public HookSuperVanish() {
|
||||||
super("SuperVanish");
|
super("SuperVanish");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,18 +6,23 @@ import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
|||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
|
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
|
import org.apache.commons.lang3.EnumUtils;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A hook that integrates the plugin {@link me.clip.placeholderapi.PlaceholderAPIPlugin PlaceholderAPIPlugin}
|
||||||
|
*/
|
||||||
public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
||||||
|
|
||||||
private static boolean papiEnabled = false;
|
private static boolean papiEnabled = false;
|
||||||
|
|
||||||
public HMCPlaceholderExpansion() {
|
public HMCPlaceholderExpansion() {
|
||||||
@@ -73,7 +78,7 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
if (placeholderArgs.size() == 2) return user.getCosmetic(slot).getId();
|
if (placeholderArgs.size() == 2) return user.getCosmetic(slot).getId();
|
||||||
switch (placeholderArgs.get(2).toLowerCase()) {
|
switch (placeholderArgs.get(2).toLowerCase()) {
|
||||||
case "material" -> {
|
case "material" -> {
|
||||||
return getMaterial(user.getCosmetic(slot));
|
return getMaterialName(user.getCosmetic(slot));
|
||||||
}
|
}
|
||||||
case "custommodeldata" -> {
|
case "custommodeldata" -> {
|
||||||
return getModelData(user.getCosmetic(slot));
|
return getModelData(user.getCosmetic(slot));
|
||||||
@@ -113,13 +118,29 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (placeholderArgs.get(1) != null) {
|
if (placeholderArgs.get(1) != null) {
|
||||||
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
String args1 = placeholderArgs.get(1);
|
||||||
if (cosmetic == null) {
|
|
||||||
Cosmetic secondAttemptCosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1) + "_" + placeholderArgs.get(2));
|
if (EnumUtils.isValidEnum(CosmeticSlot.class, args1.toUpperCase())) {
|
||||||
if (secondAttemptCosmetic == null) {
|
if (user.getCosmetic(CosmeticSlot.valueOf(args1.toUpperCase())) != null) {
|
||||||
return "INVALID_COSMETIC";
|
return "true";
|
||||||
} else {
|
} else {
|
||||||
cosmetic = secondAttemptCosmetic;
|
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 (user.getCosmetic(cosmetic.getSlot()) == null) return "false";
|
||||||
@@ -135,33 +156,76 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
|||||||
return null;
|
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) {
|
public String getMaterial(@NotNull Cosmetic cosmetic) {
|
||||||
ItemStack item = cosmetic.getItem();
|
ItemStack item = cosmetic.getItem();
|
||||||
if (item == null) return null;
|
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) {
|
public String getModelData(@NotNull Cosmetic cosmetic) {
|
||||||
ItemStack item = cosmetic.getItem();
|
ItemStack item = cosmetic.getItem();
|
||||||
if (item == null) return null;
|
if (item == null) return null;
|
||||||
if (!item.hasItemMeta()) return null;
|
if (!item.hasItemMeta()) return null;
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
if (itemMeta == null) return null;
|
||||||
return String.valueOf(itemMeta.getCustomModelData());
|
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) {
|
public String getItemName(@NotNull Cosmetic cosmetic) {
|
||||||
ItemStack item = cosmetic.getItem();
|
ItemStack item = cosmetic.getItem();
|
||||||
if (item == null) return null;
|
if (item == null) return null;
|
||||||
if (!item.hasItemMeta()) return null;
|
if (!item.hasItemMeta()) return null;
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
if (itemMeta == null) return null;
|
||||||
return itemMeta.getDisplayName();
|
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) {
|
public String getItemLore(@NotNull Cosmetic cosmetic) {
|
||||||
ItemStack item = cosmetic.getItem();
|
ItemStack item = cosmetic.getItem();
|
||||||
if (item == null) return null;
|
if (item == null) return null;
|
||||||
if (item.hasItemMeta()) {
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,17 @@ package com.hibiscusmc.hmccosmetics.hooks.placeholders;
|
|||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
import com.hibiscusmc.hmccosmetics.hooks.Hook;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A hook that integrates the plugin {@link me.clip.placeholderapi.PlaceholderAPI PlaceholderAPI}
|
||||||
|
*/
|
||||||
public class HookPlaceholderAPI extends Hook {
|
public class HookPlaceholderAPI extends Hook {
|
||||||
|
|
||||||
public HookPlaceholderAPI() {
|
public HookPlaceholderAPI() {
|
||||||
super("PlaceholderAPI");
|
super("PlaceholderAPI");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers HMCCosmetics Placeholder Expansion
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void load() {
|
public void load() {
|
||||||
new HMCPlaceholderExpansion().register();
|
new HMCPlaceholderExpansion().register();
|
||||||
|
|||||||
@@ -9,9 +9,18 @@ import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
|
|||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A hook that integrates the plugin {@link com.sk89q.worldguard.WorldGuard WorldGuard}
|
||||||
|
*/
|
||||||
public class WGHook {
|
public class WGHook {
|
||||||
|
/**
|
||||||
|
* @implNote Please use {@link #getCosmeticEnableFlag()} instead
|
||||||
|
*/
|
||||||
public static StateFlag COSMETIC_ENABLE_FLAG;
|
public static StateFlag COSMETIC_ENABLE_FLAG;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implNote Please use {@link #getCosmeticWardrobeFlag()} instead
|
||||||
|
*/
|
||||||
public static StateFlag COSMETIC_WARDROBE_FLAG;
|
public static StateFlag COSMETIC_WARDROBE_FLAG;
|
||||||
|
|
||||||
public WGHook() {
|
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() {
|
public static StateFlag getCosmeticEnableFlag() {
|
||||||
return COSMETIC_ENABLE_FLAG;
|
return COSMETIC_ENABLE_FLAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the cosmetic wardrobe {@link StateFlag}
|
||||||
|
* @return The cosmetic wardrobe {@link StateFlag}
|
||||||
|
*/
|
||||||
public static StateFlag getCosmeticWardrobeFlag() {
|
public static StateFlag getCosmeticWardrobeFlag() {
|
||||||
return COSMETIC_WARDROBE_FLAG;
|
return COSMETIC_WARDROBE_FLAG;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,10 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains {@link com.sk89q.worldguard.WorldGuard WorldGuard} related event listeners
|
||||||
|
*/
|
||||||
public class WGListener implements Listener {
|
public class WGListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerMove(@NotNull PlayerMoveEvent event) {
|
public void onPlayerMove(@NotNull PlayerMoveEvent event) {
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ public class PlayerConnectionListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (user.isInWardrobe()) user.leaveWardrobe();
|
if (user.isInWardrobe()) user.leaveWardrobe();
|
||||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -33,7 +34,6 @@ import org.bukkit.entity.Pose;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.*;
|
import org.bukkit.event.entity.*;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.player.*;
|
import org.bukkit.event.player.*;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
@@ -61,12 +61,20 @@ public class PlayerGameListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerClick(@NotNull InventoryClickEvent event) {
|
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;
|
//if (event.getSlotType() != InventoryType.SlotType.ARMOR) return;
|
||||||
CosmeticUser user = CosmeticUsers.getUser(event.getWhoClicked().getUniqueId());
|
CosmeticUser user = CosmeticUsers.getUser(event.getWhoClicked().getUniqueId());
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
ItemStack item = event.getCurrentItem();
|
ItemStack item = event.getCurrentItem();
|
||||||
if (item == null) return;
|
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());
|
EquipmentSlot slot = getArmorSlot(item.getType());
|
||||||
if (slot == null) return;
|
if (slot == null) return;
|
||||||
CosmeticSlot cosmeticSlot = InventoryUtils.BukkitCosmeticSlot(slot);
|
CosmeticSlot cosmeticSlot = InventoryUtils.BukkitCosmeticSlot(slot);
|
||||||
@@ -122,6 +130,9 @@ public class PlayerGameListener implements Listener {
|
|||||||
user.spawnBalloon(cosmeticBalloonType);
|
user.spawnBalloon(cosmeticBalloonType);
|
||||||
}, 2);
|
}, 2);
|
||||||
}
|
}
|
||||||
|
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||||
|
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.TELEPORT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -195,12 +206,22 @@ public class PlayerGameListener implements Listener {
|
|||||||
if (!user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return;
|
if (!user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return;
|
||||||
Pose pose = event.getPose();
|
Pose pose = event.getPose();
|
||||||
if (pose.equals(Pose.STANDING)) {
|
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()) {
|
if (!user.isBackpackSpawned()) {
|
||||||
user.spawnBackpack((CosmeticBackpackType) user.getCosmetic(CosmeticSlot.BACKPACK));
|
user.spawnBackpack((CosmeticBackpackType) user.getCosmetic(CosmeticSlot.BACKPACK));
|
||||||
}
|
}
|
||||||
return;
|
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();
|
user.despawnBackpack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -292,6 +313,14 @@ public class PlayerGameListener implements Listener {
|
|||||||
user.updateCosmetic(CosmeticSlot.MAINHAND);
|
user.updateCosmetic(CosmeticSlot.MAINHAND);
|
||||||
user.updateCosmetic(CosmeticSlot.OFFHAND);
|
user.updateCosmetic(CosmeticSlot.OFFHAND);
|
||||||
}, 2);
|
}, 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
|
@EventHandler
|
||||||
@@ -347,7 +376,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
|
|
||||||
HashMap<Integer, ItemStack> items = new HashMap<>();
|
HashMap<Integer, ItemStack> items = new HashMap<>();
|
||||||
|
|
||||||
for (Cosmetic cosmetic : user.getCosmetic()) {
|
for (Cosmetic cosmetic : user.getCosmetics()) {
|
||||||
if ((cosmetic instanceof CosmeticArmorType cosmeticArmorType)) {
|
if ((cosmetic instanceof CosmeticArmorType cosmeticArmorType)) {
|
||||||
items.put(InventoryUtils.getPacketArmorSlot(cosmeticArmorType.getEquipSlot()), user.getUserCosmeticItem(cosmeticArmorType));
|
items.put(InventoryUtils.getPacketArmorSlot(cosmeticArmorType.getEquipSlot()), user.getUserCosmeticItem(cosmeticArmorType));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
public class NMSHandlers {
|
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 NMSHandler handler;
|
||||||
private static String version;
|
private static String version;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user;
|
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.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.api.*;
|
import com.hibiscusmc.hmccosmetics.api.*;
|
||||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
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.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.*;
|
||||||
import org.bukkit.Color;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.*;
|
import org.bukkit.inventory.meta.*;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -77,10 +77,15 @@ public class CosmeticUser {
|
|||||||
return playerCosmetics.get(slot);
|
return playerCosmetics.get(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public Collection<Cosmetic> getCosmetic() {
|
public Collection<Cosmetic> getCosmetic() {
|
||||||
return playerCosmetics.values();
|
return playerCosmetics.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ImmutableCollection<Cosmetic> getCosmetics() {
|
||||||
|
return ImmutableList.copyOf(playerCosmetics.values());
|
||||||
|
}
|
||||||
|
|
||||||
public void addPlayerCosmetic(Cosmetic cosmetic) {
|
public void addPlayerCosmetic(Cosmetic cosmetic) {
|
||||||
addPlayerCosmetic(cosmetic, null);
|
addPlayerCosmetic(cosmetic, null);
|
||||||
}
|
}
|
||||||
@@ -205,6 +210,8 @@ public class CosmeticUser {
|
|||||||
mapMeta.setColor(color);
|
mapMeta.setColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
itemMeta.getPersistentDataContainer().set(InventoryUtils.getKey(), PersistentDataType.STRING, "true");
|
||||||
|
|
||||||
item.setItemMeta(itemMeta);
|
item.setItemMeta(itemMeta);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
@@ -315,8 +322,6 @@ public class CosmeticUser {
|
|||||||
|
|
||||||
List<Player> viewer = PlayerUtils.getNearbyPlayers(player);
|
List<Player> viewer = PlayerUtils.getNearbyPlayers(player);
|
||||||
viewer.add(player);
|
viewer.add(player);
|
||||||
|
|
||||||
PacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), player.getEntityId(), viewer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void despawnBalloon() {
|
public void despawnBalloon() {
|
||||||
@@ -358,7 +363,7 @@ public class CosmeticUser {
|
|||||||
public List<CosmeticSlot> getDyeableSlots() {
|
public List<CosmeticSlot> getDyeableSlots() {
|
||||||
ArrayList<CosmeticSlot> dyableSlots = new ArrayList();
|
ArrayList<CosmeticSlot> dyableSlots = new ArrayList();
|
||||||
|
|
||||||
for (Cosmetic cosmetic : getCosmetic()) {
|
for (Cosmetic cosmetic : getCosmetics()) {
|
||||||
if (cosmetic.isDyable()) dyableSlots.add(cosmetic.getSlot());
|
if (cosmetic.isDyable()) dyableSlots.add(cosmetic.getSlot());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,8 +406,7 @@ public class CosmeticUser {
|
|||||||
hiddenReason = reason;
|
hiddenReason = reason;
|
||||||
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||||
getBalloonManager().removePlayerFromModel(getPlayer());
|
getBalloonManager().removePlayerFromModel(getPlayer());
|
||||||
List<Player> viewer = PlayerUtils.getNearbyPlayers(getPlayer());
|
getBalloonManager().sendRemoveLeashPacket();
|
||||||
PacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), -1, viewer);
|
|
||||||
}
|
}
|
||||||
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||||
userBackpackManager.clearItems();
|
userBackpackManager.clearItems();
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
|||||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
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.ModelEngineAPI;
|
||||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||||
@@ -17,12 +19,14 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class UserBalloonManager {
|
public class UserBalloonManager {
|
||||||
|
|
||||||
private BalloonType balloonType;
|
private BalloonType balloonType;
|
||||||
|
private CosmeticBalloonType cosmeticBalloonType;
|
||||||
private final int balloonID;
|
private final int balloonID;
|
||||||
private final UUID uniqueID;
|
private final UUID uniqueID;
|
||||||
private final ArmorStand modelEntity;
|
private final ArmorStand modelEntity;
|
||||||
@@ -44,6 +48,7 @@ public class UserBalloonManager {
|
|||||||
balloonType = BalloonType.NONE;
|
balloonType = BalloonType.NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.cosmeticBalloonType = cosmeticBalloonType;
|
||||||
MessagesUtil.sendDebugMessages("balloontype is " + balloonType);
|
MessagesUtil.sendDebugMessages("balloontype is " + balloonType);
|
||||||
|
|
||||||
if (balloonType == BalloonType.MODELENGINE) {
|
if (balloonType == BalloonType.MODELENGINE) {
|
||||||
@@ -85,6 +90,7 @@ public class UserBalloonManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
modelEntity.remove();
|
modelEntity.remove();
|
||||||
|
cosmeticBalloonType = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayerToModel(final CosmeticUser user, final CosmeticBalloonType cosmeticBalloonType) {
|
public void addPlayerToModel(final CosmeticUser user, final CosmeticBalloonType cosmeticBalloonType) {
|
||||||
@@ -156,6 +162,19 @@ public class UserBalloonManager {
|
|||||||
this.getModelEntity().setVelocity(vector);
|
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 {
|
public enum BalloonType {
|
||||||
MODELENGINE,
|
MODELENGINE,
|
||||||
ITEM,
|
ITEM,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||||
|
|
||||||
import com.hibiscusmc.hmccosmetics.api.PlayerCosmeticRemoveEvent;
|
|
||||||
import com.hibiscusmc.hmccosmetics.api.PlayerEmoteStartEvent;
|
import com.hibiscusmc.hmccosmetics.api.PlayerEmoteStartEvent;
|
||||||
import com.hibiscusmc.hmccosmetics.api.PlayerEmoteStopEvent;
|
import com.hibiscusmc.hmccosmetics.api.PlayerEmoteStopEvent;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
||||||
@@ -61,6 +60,7 @@ public class UserEmoteManager {
|
|||||||
public enum StopEmoteReason {
|
public enum StopEmoteReason {
|
||||||
SNEAK,
|
SNEAK,
|
||||||
DAMAGE,
|
DAMAGE,
|
||||||
CONNECTION
|
CONNECTION,
|
||||||
|
TELEPORT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,8 +109,8 @@ public class UserWardrobeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||||
PacketManager.sendLeashPacket(user.getBalloonManager().getPufferfishBalloonId(), -1, viewer);
|
user.getBalloonManager().sendRemoveLeashPacket(viewer);
|
||||||
PacketManager.sendLeashPacket(user.getBalloonManager().getPufferfishBalloonId(), NPC_ID, viewer); // This needs a possible fix
|
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
||||||
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer);
|
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer);
|
||||||
|
|
||||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.clone().add(Settings.getBalloonOffset()), false, 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);
|
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
|
||||||
outsideViewers.remove(player);
|
outsideViewers.remove(player);
|
||||||
|
|
||||||
MessagesUtil.sendMessage(player, "closed-wardrobe");
|
if (player != null) MessagesUtil.sendMessage(player, "closed-wardrobe");
|
||||||
|
|
||||||
Runnable run = () -> {
|
Runnable run = () -> {
|
||||||
this.active = false;
|
this.active = false;
|
||||||
|
|
||||||
// NPC
|
// 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.sendEntityDestroyPacket(NPC_ID, viewer); // Success
|
||||||
PacketManager.sendRemovePlayerPacket(player, WARDROBE_UUID, viewer); // Success
|
PacketManager.sendRemovePlayerPacket(player, WARDROBE_UUID, viewer); // Success
|
||||||
|
|
||||||
// Player
|
// Player
|
||||||
PacketManager.sendCameraPacket(player.getEntityId(), viewer);
|
PacketManager.sendCameraPacket(player.getEntityId(), viewer);
|
||||||
PacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(this.originalGamemode)); // Success
|
|
||||||
|
|
||||||
// Armorstand
|
// Armorstand
|
||||||
PacketManager.sendEntityDestroyPacket(ARMORSTAND_ID, viewer); // Sucess
|
PacketManager.sendEntityDestroyPacket(ARMORSTAND_ID, viewer); // Sucess
|
||||||
|
|
||||||
//PacketManager.sendEntityDestroyPacket(player.getEntityId(), viewer); // Success
|
//PacketManager.sendEntityDestroyPacket(player.getEntityId(), viewer); // Success
|
||||||
player.setGameMode(this.originalGamemode);
|
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();
|
user.showPlayer();
|
||||||
|
|
||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||||
@@ -200,7 +207,7 @@ public class UserWardrobeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For Wardrobe Temp Cosmetics
|
// For Wardrobe Temp Cosmetics
|
||||||
for (Cosmetic cosmetic : user.getCosmetic()) {
|
for (Cosmetic cosmetic : user.getCosmetics()) {
|
||||||
if (cosmetic.requiresPermission()) {
|
if (cosmetic.requiresPermission()) {
|
||||||
if (!player.hasPermission(cosmetic.getPermission())) user.removeCosmeticSlot(cosmetic.getSlot());
|
if (!player.hasPermission(cosmetic.getPermission())) user.removeCosmeticSlot(cosmetic.getSlot());
|
||||||
}
|
}
|
||||||
@@ -254,9 +261,9 @@ public class UserWardrobeManager {
|
|||||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()), false, viewer);
|
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()), false, viewer);
|
||||||
user.getBalloonManager().getModelEntity().teleport(WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()));
|
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.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()) {
|
if (WardrobeSettings.isEquipPumpkin()) {
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.util;
|
package com.hibiscusmc.hmccosmetics.util;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||||
|
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
import org.jetbrains.annotations.Contract;
|
import org.jetbrains.annotations.Contract;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -137,4 +141,14 @@ public class InventoryUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isCosmeticItem(ItemStack itemStack) {
|
||||||
|
itemStack = itemStack.clone();
|
||||||
|
if (!itemStack.hasItemMeta()) return false;
|
||||||
|
return itemStack.getItemMeta().getPersistentDataContainer().has(getKey(), PersistentDataType.STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NamespacedKey getKey() {
|
||||||
|
return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmetic");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
|
|||||||
public class BasePacket {
|
public class BasePacket {
|
||||||
|
|
||||||
public static void sendPacket(Player player, PacketContainer packet) {
|
public static void sendPacket(Player player, PacketContainer packet) {
|
||||||
|
if (player == null) return;
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,7 +135,8 @@ public class PacketManager extends BasePacket {
|
|||||||
packet.getModifier().writeDefaults();
|
packet.getModifier().writeDefaults();
|
||||||
packet.getIntegers().write(0, entityId);
|
packet.getIntegers().write(0, entityId);
|
||||||
WrappedDataWatcher wrapper = new WrappedDataWatcher();
|
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);
|
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20);
|
||||||
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
|
||||||
} else {
|
} else {
|
||||||
@@ -305,19 +306,17 @@ public class PacketManager extends BasePacket {
|
|||||||
WrappedGameProfile wrappedGameProfile = new WrappedGameProfile(uuid, name);
|
WrappedGameProfile wrappedGameProfile = new WrappedGameProfile(uuid, name);
|
||||||
WrappedSignedProperty skinData = PlayerUtils.getSkin(skinnedPlayer);
|
WrappedSignedProperty skinData = PlayerUtils.getSkin(skinnedPlayer);
|
||||||
if (skinData != null) wrappedGameProfile.getProperties().put("textures", skinData);
|
if (skinData != null) wrappedGameProfile.getProperties().put("textures", skinData);
|
||||||
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") || NMSHandlers.getVersion().contains("v1_19_R3")) {
|
||||||
info.setData(List.of(new PlayerInfoData(wrappedGameProfile, 0, EnumWrappers.NativeGameMode.CREATIVE, WrappedChatComponent.fromText(name))));
|
|
||||||
} else {
|
|
||||||
info.getHandle().getPlayerInfoDataLists().write(1, Collections.singletonList(new PlayerInfoData(
|
info.getHandle().getPlayerInfoDataLists().write(1, Collections.singletonList(new PlayerInfoData(
|
||||||
wrappedGameProfile,
|
wrappedGameProfile,
|
||||||
0,
|
0,
|
||||||
EnumWrappers.NativeGameMode.CREATIVE,
|
EnumWrappers.NativeGameMode.CREATIVE,
|
||||||
WrappedChatComponent.fromText(name)
|
WrappedChatComponent.fromText(name)
|
||||||
)));
|
)));
|
||||||
|
} else {
|
||||||
|
info.setData(List.of(new PlayerInfoData(wrappedGameProfile, 0, EnumWrappers.NativeGameMode.CREATIVE, WrappedChatComponent.fromText(name))));
|
||||||
}
|
}
|
||||||
for (final Player p : sendTo) sendPacket(p, info.getHandle());
|
for (final Player p : sendTo) sendPacket(p, info.getHandle());
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -364,7 +363,7 @@ public class PacketManager extends BasePacket {
|
|||||||
final UUID uuid,
|
final UUID uuid,
|
||||||
final List<Player> sendTo
|
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();
|
WrapperPlayServerPlayerInfo info = new WrapperPlayServerPlayerInfo();
|
||||||
info.setAction(EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);
|
info.setAction(EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);
|
||||||
|
|
||||||
@@ -377,6 +376,7 @@ public class PacketManager extends BasePacket {
|
|||||||
for (final Player p : sendTo) sendPacket(p, info.getHandle());
|
for (final Player p : sendTo) sendPacket(p, info.getHandle());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO_REMOVE);
|
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO_REMOVE);
|
||||||
packet.getUUIDLists().write(0, List.of(uuid));
|
packet.getUUIDLists().write(0, List.of(uuid));
|
||||||
for (final Player p : sendTo) sendPacket(p, packet);
|
for (final Player p : sendTo) sendPacket(p, packet);
|
||||||
|
|||||||
@@ -26,11 +26,12 @@ public class WrapperPlayServerPlayerInfo extends AbstractPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setAction(PlayerInfoAction value) {
|
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);
|
handle.getPlayerInfoAction().write(0, value);
|
||||||
} else {
|
return;
|
||||||
handle.getPlayerInfoActions().write(0, Set.of(value));
|
|
||||||
}
|
}
|
||||||
|
// New way of handling it 1.19.3+
|
||||||
|
handle.getPlayerInfoActions().write(0, Set.of(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PlayerInfoData> getData() {
|
public List<PlayerInfoData> getData() {
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ cosmetic-settings:
|
|||||||
leggings-add-enchantments: false # If the plugin should keep enchants on leggings. 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.
|
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
|
# 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
|
# setting this to lower than the server player view distance should fix the
|
||||||
# bug where players see random backpacks. Put -1 to ignore and send packets to everyone.
|
# bug where players see random backpacks. Put -1 to ignore and send packets to everyone.
|
||||||
@@ -53,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
|
# 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.
|
# could cause console spam as HMCCosmetics has to reload itself as well.
|
||||||
reload-on-change: false
|
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:
|
wardrobe:
|
||||||
# spawn static wardrobe if in this radius of wardrobe-location
|
# spawn static wardrobe if in this radius of wardrobe-location
|
||||||
static-radius: 10
|
static-radius: 10
|
||||||
@@ -62,6 +70,11 @@ wardrobe:
|
|||||||
equip-pumpkin: false
|
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
|
# 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
|
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 force-exit-gamemode 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 that shows when a player is in a wardrobe.
|
||||||
bossbar:
|
bossbar:
|
||||||
enabled: false
|
enabled: false
|
||||||
@@ -71,6 +84,8 @@ wardrobe:
|
|||||||
color: BLUE
|
color: BLUE
|
||||||
transition:
|
transition:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
# If you use ItemsAdder, set this to "<black>%img_title%
|
||||||
|
# If you use Oraxen, set this to "<black><glyph:title>"
|
||||||
text: "<black>"
|
text: "<black>"
|
||||||
delay: 40
|
delay: 40
|
||||||
title-fade-in: 1000 # milliseconds
|
title-fade-in: 1000 # milliseconds
|
||||||
|
|||||||
@@ -110,4 +110,23 @@ explorer_backpack:
|
|||||||
material: LEATHER_HORSE_ARMOR
|
material: LEATHER_HORSE_ARMOR
|
||||||
model-data: 3
|
model-data: 3
|
||||||
name: "<white>Explorer's Backpack"
|
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"
|
||||||
|
model: earth_day_grabber
|
||||||
|
item:
|
||||||
|
material: LEATHER_HORSE_ARMOR
|
||||||
|
model-data: 4
|
||||||
|
name: "<green>Earth Day Grabber"
|
||||||
amount: 1
|
amount: 1
|
||||||
@@ -167,4 +167,26 @@ items:
|
|||||||
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_explorer_backpack%"
|
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_explorer_backpack%"
|
||||||
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_explorer_backpack%"
|
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_explorer_backpack%"
|
||||||
type: cosmetic
|
type: cosmetic
|
||||||
cosmetic: explorer_backpack
|
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
|
||||||
@@ -11,5 +11,6 @@ include(
|
|||||||
"v1_17_R1",
|
"v1_17_R1",
|
||||||
"v1_18_R2",
|
"v1_18_R2",
|
||||||
"v1_19_R1",
|
"v1_19_R1",
|
||||||
"v1_19_R2"
|
"v1_19_R2",
|
||||||
|
"v1_19_R3",
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
|
|
||||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||||
PacketManager.sendLeashPacket(userBalloonManager1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
|
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||||
|
|
||||||
return userBalloonManager1;
|
return userBalloonManager1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
|
|
||||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||||
PacketManager.sendLeashPacket(userBalloonManager1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
|
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||||
|
|
||||||
return userBalloonManager1;
|
return userBalloonManager1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
|
|
||||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||||
PacketManager.sendLeashPacket(userBalloonManager1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
|
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||||
|
|
||||||
return userBalloonManager1;
|
return userBalloonManager1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
|||||||
|
|
||||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||||
PacketManager.sendLeashPacket(userBalloonManager1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
|
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||||
|
|
||||||
return userBalloonManager1;
|
return userBalloonManager1;
|
||||||
}
|
}
|
||||||
|
|||||||
27
v1_19_R3/build.gradle.kts
Normal file
27
v1_19_R3/build.gradle.kts
Normal 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()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user