mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-26 02:19:25 +00:00
Compare commits
77 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1eb592137 | ||
|
|
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 | ||
|
|
bf591e708d | ||
|
|
14bbd111f9 | ||
|
|
2185c27be5 | ||
|
|
aef9e24d28 | ||
|
|
d1a35b721e |
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
|
||||||
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-DEV"
|
version = "2.2.6"
|
||||||
|
|
||||||
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() {
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player starts playing an emote
|
||||||
|
*/
|
||||||
|
public class PlayerEmoteStartEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
|
private final String animationId;
|
||||||
|
|
||||||
|
public PlayerEmoteStartEvent(@NotNull CosmeticUser who, @NotNull String animationId) {
|
||||||
|
super(who);
|
||||||
|
this.animationId = animationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the animation id of the emote the player started playing
|
||||||
|
* @implNote The returned string of this method may be an invalid animation id. Make sure to validate it before use
|
||||||
|
*
|
||||||
|
* @return The animation id of the emote which the player started playing
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public String getAnimationId() {
|
||||||
|
return animationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Canceling this event will prevent the player from playing the emote
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package com.hibiscusmc.hmccosmetics.api;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
|
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player stops playing an emote
|
||||||
|
*/
|
||||||
|
public class PlayerEmoteStopEvent extends PlayerCosmeticEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
|
private final UserEmoteManager.StopEmoteReason reason;
|
||||||
|
|
||||||
|
public PlayerEmoteStopEvent(@NotNull CosmeticUser who, @NotNull UserEmoteManager.StopEmoteReason reason) {
|
||||||
|
super(who);
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link UserEmoteManager.StopEmoteReason} as to why the emote has stopped playing
|
||||||
|
*
|
||||||
|
* @return The {@link UserEmoteManager.StopEmoteReason} why the emote has stopped playing
|
||||||
|
* @deprecated As of release 2.2.5+, replaced by {@link #getReason()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@NotNull
|
||||||
|
public UserEmoteManager.StopEmoteReason getStopEmoteReason() {
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link UserEmoteManager.StopEmoteReason} as to why the emote has stopped playing
|
||||||
|
*
|
||||||
|
* @return The {@link UserEmoteManager.StopEmoteReason} why the emote has stopped playing
|
||||||
|
* @since 2.2.5
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public UserEmoteManager.StopEmoteReason getReason() {
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the cancellation state of this event
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* Canceling this event will prevent the player from stopping the emote
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param cancel true if you wish to cancel this event
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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");
|
||||||
|
|||||||
@@ -35,7 +35,15 @@ 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 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_INVINCIBLE_PATH = "emote-invincible";
|
||||||
|
private static final String COSMETIC_ADD_ENCHANTS_HELMET_PATH = "helmet-add-enchantments";
|
||||||
|
private static final String COSMETIC_ADD_ENCHANTS_CHESTPLATE_PATH = "chest-add-enchantments";
|
||||||
|
private static final String COSMETIC_ADD_ENCHANTS_LEGGINGS_PATH = "leggings-add-enchantments";
|
||||||
|
private static final String COSMETIC_ADD_ENCHANTS_BOOTS_PATH = "boots-add-enchantments";
|
||||||
|
|
||||||
private static String defaultMenu;
|
private static String defaultMenu;
|
||||||
private static String dyeMenuName;
|
private static String dyeMenuName;
|
||||||
@@ -51,7 +59,14 @@ 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 addChestplateEnchants;
|
||||||
|
private static boolean addLeggingEnchants;
|
||||||
|
private static boolean addBootsEnchants;
|
||||||
|
private static boolean emoteDamageLeave;
|
||||||
|
private static boolean emoteInvincible;
|
||||||
private static int lookDownPitch;
|
private static int lookDownPitch;
|
||||||
private static int viewDistance;
|
private static int viewDistance;
|
||||||
private static int tickPeriod;
|
private static int tickPeriod;
|
||||||
@@ -84,6 +99,12 @@ public class Settings {
|
|||||||
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
||||||
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3);
|
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3);
|
||||||
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);
|
||||||
|
emoteInvincible = cosmeticSettings.node(COSMETIC_EMOTE_INVINCIBLE_PATH).getBoolean(false);
|
||||||
|
addHelmetEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_HELMET_PATH).getBoolean(false);
|
||||||
|
addChestplateEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_CHESTPLATE_PATH).getBoolean(false);
|
||||||
|
addLeggingEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_LEGGINGS_PATH).getBoolean(false);
|
||||||
|
addBootsEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_BOOTS_PATH).getBoolean(false);
|
||||||
|
|
||||||
tickPeriod = cosmeticSettings.node(TICK_PERIOD_PATH).getInt(-1);
|
tickPeriod = cosmeticSettings.node(TICK_PERIOD_PATH).getInt(-1);
|
||||||
lookDownPitch = cosmeticSettings.node(LOOK_DOWN_PITCH_PATH).getInt();
|
lookDownPitch = cosmeticSettings.node(LOOK_DOWN_PITCH_PATH).getInt();
|
||||||
@@ -102,6 +123,9 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Vector loadVector(final ConfigurationNode config) {
|
private static Vector loadVector(final ConfigurationNode config) {
|
||||||
@@ -227,6 +251,38 @@ public class Settings {
|
|||||||
return cosmeticEmoteBlockCheck;
|
return cosmeticEmoteBlockCheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isEmoteDamageLeave() {
|
||||||
|
return emoteDamageLeave;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isEmoteInvincible() {
|
||||||
|
return emoteInvincible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isWorldGuardMoveCheckEnabled() {
|
||||||
|
return worldGuardMoveCheck;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean getShouldAddEnchants(EquipmentSlot slot) {
|
||||||
|
switch (slot) {
|
||||||
|
case HEAD -> {
|
||||||
|
return addHelmetEnchants;
|
||||||
|
}
|
||||||
|
case CHEST -> {
|
||||||
|
return addChestplateEnchants;
|
||||||
|
}
|
||||||
|
case LEGS -> {
|
||||||
|
return addLeggingEnchants;
|
||||||
|
}
|
||||||
|
case FEET -> {
|
||||||
|
return addBootsEnchants;
|
||||||
|
}
|
||||||
|
default -> {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void setDebugMode(boolean newSetting) {
|
public static void setDebugMode(boolean newSetting) {
|
||||||
debugMode = newSetting;
|
debugMode = newSetting;
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||||
|
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
@@ -24,10 +28,17 @@ public class CosmeticArmorType extends Cosmetic {
|
|||||||
public void update(@NotNull CosmeticUser user) {
|
public void update(@NotNull CosmeticUser user) {
|
||||||
Player player = Bukkit.getPlayer(user.getUniqueId());
|
Player player = Bukkit.getPlayer(user.getUniqueId());
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
ItemStack cosmeticItem = user.getUserCosmeticItem(this);
|
||||||
if (equipSlot.equals(EquipmentSlot.OFF_HAND)) {
|
if (equipSlot.equals(EquipmentSlot.OFF_HAND)) {
|
||||||
if (!player.getInventory().getItemInOffHand().getType().isAir()) return;
|
if (!player.getInventory().getItemInOffHand().getType().isAir()) return;
|
||||||
}
|
}
|
||||||
PacketManager.equipmentSlotUpdate(player, getSlot(), PacketManager.getViewers(player.getLocation()));
|
ItemStack equippedItem = player.getInventory().getItem(equipSlot);
|
||||||
|
if (Settings.getShouldAddEnchants(equipSlot)) {
|
||||||
|
cosmeticItem.addUnsafeEnchantments(equippedItem.getEnchantments());
|
||||||
|
}
|
||||||
|
|
||||||
|
NMSHandlers.getHandler().equipmentSlotUpdate(player.getEntityId(), equipSlot, cosmeticItem, PacketManager.getViewers(player.getLocation()));
|
||||||
|
//PacketManager.equipmentSlotUpdate(player, getSlot(), PacketManager.getViewers(player.getLocation())); Old method
|
||||||
}
|
}
|
||||||
|
|
||||||
public EquipmentSlot getEquipSlot() {
|
public EquipmentSlot getEquipSlot() {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
|||||||
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 com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
||||||
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -10,6 +11,8 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.configurate.ConfigurationNode;
|
import org.spongepowered.configurate.ConfigurationNode;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class CosmeticBackpackType extends Cosmetic {
|
public class CosmeticBackpackType extends Cosmetic {
|
||||||
|
|
||||||
private final String modelName;
|
private final String modelName;
|
||||||
@@ -30,6 +33,11 @@ public class CosmeticBackpackType extends Cosmetic {
|
|||||||
Location loc = player.getLocation().clone().add(0, 2, 0);
|
Location loc = player.getLocation().clone().add(0, 2, 0);
|
||||||
|
|
||||||
if (user.isInWardrobe() || !user.isBackpackSpawned()) return;
|
if (user.isInWardrobe() || !user.isBackpackSpawned()) return;
|
||||||
|
if (!user.getUserBackpackManager().getArmorStand().isValid()) {
|
||||||
|
MessagesUtil.sendDebugMessages("Invalid Backpack detected! Respawning backpack, report this on the discord if this happens often!", Level.WARNING);
|
||||||
|
user.respawnBackpack();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (loc.getWorld() != user.getUserBackpackManager().getArmorStand().getWorld()) {
|
if (loc.getWorld() != user.getUserBackpackManager().getArmorStand().getWorld()) {
|
||||||
user.getUserBackpackManager().getArmorStand().teleport(loc);
|
user.getUserBackpackManager().getArmorStand().teleport(loc);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,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());
|
||||||
|
|||||||
@@ -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");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,12 +12,15 @@ 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 +76,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));
|
||||||
@@ -135,33 +138,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());
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
|
|||||||
import com.hibiscusmc.hmccosmetics.database.Database;
|
import com.hibiscusmc.hmccosmetics.database.Database;
|
||||||
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.user.manager.UserEmoteManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@@ -60,7 +61,7 @@ public class PlayerConnectionListener implements Listener {
|
|||||||
}
|
}
|
||||||
if (user.isInWardrobe()) user.leaveWardrobe();
|
if (user.isInWardrobe()) user.leaveWardrobe();
|
||||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||||
user.getUserEmoteManager().stopEmote();
|
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.CONNECTION);
|
||||||
event.getPlayer().setInvisible(false);
|
event.getPlayer().setInvisible(false);
|
||||||
}
|
}
|
||||||
Database.save(user);
|
Database.save(user);
|
||||||
|
|||||||
@@ -20,11 +20,13 @@ import com.hibiscusmc.hmccosmetics.gui.Menu;
|
|||||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||||
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.user.manager.UserEmoteManager;
|
||||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
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;
|
||||||
@@ -83,7 +85,7 @@ public class PlayerGameListener implements Listener {
|
|||||||
|
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
if (event.isSneaking()) {
|
if (event.isSneaking()) {
|
||||||
user.getUserEmoteManager().stopEmote();
|
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.SNEAK);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!event.isSneaking()) return;
|
if (!event.isSneaking()) return;
|
||||||
@@ -153,6 +155,26 @@ public class PlayerGameListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerDamaged(EntityDamageEvent event) {
|
||||||
|
if (event.isCancelled()) return;
|
||||||
|
if (!(event.getEntity() instanceof Player)) return;
|
||||||
|
Player player = ((Player) event.getEntity()).getPlayer();
|
||||||
|
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||||
|
if (user == null) return;
|
||||||
|
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||||
|
if (Settings.isEmoteInvincible()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
if (Settings.isEmoteDamageLeave()) {
|
||||||
|
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.DAMAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (user.isInWardrobe()) {
|
||||||
|
user.leaveWardrobe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerLook(PlayerMoveEvent event) {
|
public void onPlayerLook(PlayerMoveEvent event) {
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
@@ -174,12 +196,20 @@ 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) return;
|
||||||
|
if (!currentItem.hasItemMeta()) return;
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -271,6 +301,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
|
||||||
@@ -326,7 +364,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;
|
||||||
@@ -77,10 +79,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);
|
||||||
}
|
}
|
||||||
@@ -358,7 +365,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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||||
|
|
||||||
|
import com.hibiscusmc.hmccosmetics.api.PlayerEmoteStartEvent;
|
||||||
|
import com.hibiscusmc.hmccosmetics.api.PlayerEmoteStopEvent;
|
||||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
||||||
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 org.bukkit.Bukkit;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class UserEmoteManager {
|
public class UserEmoteManager {
|
||||||
@@ -22,6 +25,13 @@ public class UserEmoteManager {
|
|||||||
public void playEmote(String animationId) {
|
public void playEmote(String animationId) {
|
||||||
if (isPlayingEmote()) return;
|
if (isPlayingEmote()) return;
|
||||||
if (user.isInWardrobe()) return;
|
if (user.isInWardrobe()) return;
|
||||||
|
// API
|
||||||
|
PlayerEmoteStartEvent event = new PlayerEmoteStartEvent(user, animationId);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Internal
|
||||||
try {
|
try {
|
||||||
model = new UserEmoteModel(user);
|
model = new UserEmoteModel(user);
|
||||||
model.playAnimation(animationId);
|
model.playAnimation(animationId);
|
||||||
@@ -35,8 +45,21 @@ public class UserEmoteManager {
|
|||||||
return model.isPlayingAnimation();
|
return model.isPlayingAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopEmote() {
|
public void stopEmote(StopEmoteReason emoteReason) {
|
||||||
if (!isPlayingEmote()) return;
|
if (!isPlayingEmote()) return;
|
||||||
|
// API
|
||||||
|
PlayerEmoteStopEvent event = new PlayerEmoteStopEvent(user, emoteReason);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Internal
|
||||||
model.stopAnimation();
|
model.stopAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum StopEmoteReason {
|
||||||
|
SNEAK,
|
||||||
|
DAMAGE,
|
||||||
|
CONNECTION
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ 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;
|
||||||
@@ -200,7 +200,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());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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() {
|
||||||
|
|||||||
@@ -24,7 +24,14 @@ cosmetic-settings:
|
|||||||
force-permission-join: true # Checks a player permission if they can have a cosmetic when they join the server.
|
force-permission-join: true # Checks a player permission if they can have a cosmetic when they join the server.
|
||||||
|
|
||||||
emote-distance: -3 # This shows how far away the camera should be while a player is doing an emote. Negative is behind player.
|
emote-distance: -3 # This shows how far away the camera should be while a player is doing an emote. Negative is behind player.
|
||||||
emote-block-check: true # If the server should check if the block is open (prevents players viewing through blocks)
|
emote-block-check: true # If the server should check if the block is open where the camera is placed (prevents players viewing through blocks)
|
||||||
|
emote-damage-leave: true # If the player should leave the emote when they take damage
|
||||||
|
emote-invincible: false # If the player should not take damage while doing an emote
|
||||||
|
|
||||||
|
helmet-add-enchantments: false # If the plugin should keep enchants on helmets. This is useful as some enchantments are client side only.
|
||||||
|
chest-add-enchantments: false # If the plugin should keep enchants on chestplate. This is useful as some enchantments are client side only.
|
||||||
|
leggings-add-enchantments: false # If the plugin should keep enchants on leggings. This is useful as some enchantments are client side only.
|
||||||
|
boots-add-enchantments: false # If the plugin should keep enchants on boots. This is useful as some enchantments are client side only.
|
||||||
|
|
||||||
# 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
|
||||||
@@ -46,6 +53,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
|
||||||
@@ -64,6 +75,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
|
||||||
|
|||||||
@@ -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",
|
||||||
)
|
)
|
||||||
|
|||||||
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);
|
||||||
|
PacketManager.sendLeashPacket(userBalloonManager1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
|
||||||
|
|
||||||
|
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