9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-26 18:39:07 +00:00

Compare commits

...

48 Commits

Author SHA1 Message Date
LoJoSho
5b7f75f7a0 version bump (2.4.10) 2023-07-09 17:53:13 -05:00
LoJoSho
3f7d010dfa clean: optimize imports 2023-07-08 22:48:28 -05:00
LoJoSho
4d84bd681d clean: optimize imports 2023-07-08 22:48:17 -05:00
LoJoSho
0daff3044d feat: move placeholder processing to one method 2023-07-08 22:47:42 -05:00
LoJoSho
ee87338cd4 fix: Cosmin taking up our command >:( 2023-07-08 22:27:06 -05:00
LoJoSho
2b467e63ce feat: remove internal data (deprecated) 2023-07-08 22:11:37 -05:00
LoJoSho
6000cf9c1b clean: clean 2 am coding 2023-07-08 12:04:42 -05:00
LoJoSho
f2b0fb29d3 fix: Leads not properly disappearing teleporting into WG region with hidden cosmetics 2023-07-08 11:40:08 -05:00
LoJoSho
d2962ba5ed version bump (2.4.10-DEV) 2023-07-08 11:39:41 -05:00
LoJoSho
b37083a298 version bump (2.4.9) 2023-06-29 10:00:24 -05:00
LoJoSho
e35a29a13b feat: empty cosmetic type item name go through PAPI 2023-06-29 09:57:08 -05:00
LoJoSho
344aaf32e0 fix: PAPI placeholders not being applied in displaynames in guis 2023-06-28 18:06:58 -05:00
LoJoSho
6498cb43ea version bump (2.4.9-DEV) 2023-06-28 18:06:41 -05:00
LoJoSho
0120720cc3 version bump (2.4.8) 2023-06-27 10:27:43 -05:00
LoJoSho
d1bfa5abbc feat: add force-show-join to show regardless of hidden in database 2023-06-27 10:16:30 -05:00
LoJoSho
71a080a3d5 feat: Option to open menu on wardrobe enter 2023-06-27 09:54:35 -05:00
LoJoSho
78f48703db fix: prevent kicking when message is null/empty 2023-06-27 09:44:11 -05:00
LoJoSho
b9e5096d33 feat: actionbar when player has hidden cosmetics 2023-06-27 09:43:56 -05:00
LoJoSho
d7603b5108 version bump (2.4.8-DEV) 2023-06-27 09:28:03 -05:00
LoJoSho
756e3390a1 clean: remove old code commented out 2023-06-24 20:45:59 -05:00
LoJoSho
8054a35f43 feat: add recursive file lookup 2023-06-23 14:45:27 -05:00
LoJoSho
3b863e6dde version bump (2.4.7) 2023-06-22 13:38:54 -05:00
LoJoSho
b682dd7c42 feat: optimize new packet pufferfish system 2023-06-22 13:15:44 -05:00
LoJoSho
f34f5f01aa version bump (2.4.7-DEV) 2023-06-22 12:56:04 -05:00
LoJoSho
cb9248db7a feat: Refactored CosmeticUser to accept other entities, not just players 2023-06-22 12:55:56 -05:00
LoJoSho
61ee228990 version bump (2.4.6) 2023-06-19 14:00:05 -05:00
LoJoSho
14e061e487 fix: exiting emote does not refresh armor 2023-06-19 13:26:33 -05:00
LoJoSho
9dc2c23d04 feat: create HMCCosmeticsAPI class 2023-06-19 13:19:24 -05:00
LoJoSho
684f8a4790 clean: move events to their own api package 2023-06-19 13:16:43 -05:00
LoJoSho
5d782bb6a3 fix: send empty equipment packet on emote for player 2023-06-19 13:03:19 -05:00
LoJoSho
988ec04a2e feat: remove 1.17 support 2023-06-19 12:37:34 -05:00
LoJoSho
ebf87f01b8 version bump (2.4.5) 2023-06-16 22:41:34 -05:00
LoJoSho
6032eb0782 fix: improve handling of invalid backpacks 2023-06-16 22:34:57 -05:00
LoJoSho
6d8c46783f feat: add PAPI support for display names 2023-06-16 22:33:59 -05:00
LoJoSho
407061d125 clean: remove previous todo 2023-06-16 22:15:47 -05:00
LoJoSho
f8192d734b feat: Cosmetics now support PAPI in lore and skull owners/textures 2023-06-16 22:15:25 -05:00
LoJoSho
190f8f776d feat: WorldGuard listens to PlayerTeleportEvent 2023-06-16 17:37:49 -05:00
LoJoSho
cd80bc746e fix: wrong index for 1.18.2 player info packet 2023-06-15 13:13:16 -05:00
LoJoSho
d96a8e5622 version bump (2.4.4) 2023-06-14 21:17:29 -05:00
LoJoSho
53091f102e feat: Readded Translations 2023-06-14 21:11:06 -05:00
LoJoSho
1d24881df1 version bump (2.4.4-DEV) 2023-06-14 20:30:06 -05:00
LoJoSho
ae0dc7bd14 fix: Geary Hook 2023-06-14 20:29:36 -05:00
LoJoSho
b9a57fc48f version bump (2.4.3) 2023-06-13 11:59:54 -05:00
LoJoSho
1e2db05e45 feat: equipping emote stops emote 2023-06-13 11:59:16 -05:00
LoJoSho
4e2291d16f clean: menu class cleaning 2023-06-13 11:51:38 -05:00
LoJoSho
2e95a9bf58 version bump (2.4.3-DEV) 2023-06-13 11:12:07 -05:00
LoJoSho
0de6c1416c fix: balloons causing NPC disappearance 2023-06-13 11:11:15 -05:00
LoJoSho
f8c2e0e605 feat: add PlayerCosmeticPostEquipEvent to api 2023-06-13 11:10:24 -05:00
72 changed files with 661 additions and 770 deletions

View File

@@ -8,7 +8,7 @@ plugins {
} }
group = "com.hibiscusmc" group = "com.hibiscusmc"
version = "2.4.2" version = "2.4.10"
allprojects { allprojects {
apply(plugin = "java") apply(plugin = "java")
@@ -68,7 +68,7 @@ allprojects {
dependencies { dependencies {
compileOnly(fileTree("${project.rootDir}/lib") { include("*.jar") }) compileOnly(fileTree("${project.rootDir}/lib") { include("*.jar") })
compileOnly("com.mojang:authlib:1.5.25") compileOnly("com.mojang:authlib:1.5.25")
compileOnly("org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT") compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
compileOnly("org.jetbrains:annotations:23.0.0") compileOnly("org.jetbrains:annotations:23.0.0")
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0") compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0")
compileOnly("me.clip:placeholderapi:2.11.1") compileOnly("me.clip:placeholderapi:2.11.1")
@@ -84,7 +84,6 @@ allprojects {
dependencies { dependencies {
implementation(project(path = ":common")) implementation(project(path = ":common"))
implementation(project(path = ":v1_17_R1", configuration = "reobf"))
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"))
@@ -126,7 +125,6 @@ tasks {
} }
shadowJar { shadowJar {
dependsOn(":v1_17_R1:reobfJar")
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")
@@ -169,11 +167,14 @@ tasks {
bukkit { bukkit {
load = BukkitPluginDescription.PluginLoadOrder.POSTWORLD load = BukkitPluginDescription.PluginLoadOrder.POSTWORLD
main = "com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin" main = "com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin"
apiVersion = "1.17" apiVersion = "1.18"
authors = listOf("LoJoSho") authors = listOf("LoJoSho")
depend = listOf("ProtocolLib") depend = listOf("ProtocolLib")
softDepend = listOf("ModelEngine", "Oraxen", "ItemsAdder", "Geary", "HMCColor", "WorldGuard", "MythicMobs", "PlaceholderAPI", "SuperVanish", "PremiumVanish", "LibsDisguises", "Denizen") softDepend = listOf("ModelEngine", "Oraxen", "ItemsAdder", "Geary", "HMCColor", "WorldGuard", "MythicMobs", "PlaceholderAPI", "SuperVanish", "PremiumVanish", "LibsDisguises", "Denizen")
version = "${project.version}" version = "${project.version}"
loadBefore = listOf(
"Cosmin" // Fixes an issue with Cosmin loading before and taking /cosmetic, when messing with what we do.
)
commands { commands {
register("cosmetic") { register("cosmetic") {

View File

@@ -5,7 +5,7 @@ plugins {
dependencies { dependencies {
compileOnly("com.mojang:authlib:1.5.25") compileOnly("com.mojang:authlib:1.5.25")
compileOnly("org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT") compileOnly("org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT")
compileOnly("org.jetbrains:annotations:23.0.0") compileOnly("org.jetbrains:annotations:23.0.0")
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0") compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0")
compileOnly("me.clip:placeholderapi:2.11.1") compileOnly("me.clip:placeholderapi:2.11.1")

View File

@@ -1,7 +1,7 @@
package com.hibiscusmc.hmccosmetics; package com.hibiscusmc.hmccosmetics;
import com.bgsoftware.common.config.CommentedConfiguration; import com.bgsoftware.common.config.CommentedConfiguration;
import com.hibiscusmc.hmccosmetics.api.HMCCosmeticSetupEvent; import com.hibiscusmc.hmccosmetics.api.events.HMCCosmeticSetupEvent;
import com.hibiscusmc.hmccosmetics.command.CosmeticCommand; import com.hibiscusmc.hmccosmetics.command.CosmeticCommand;
import com.hibiscusmc.hmccosmetics.command.CosmeticCommandTabComplete; import com.hibiscusmc.hmccosmetics.command.CosmeticCommandTabComplete;
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings; import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
@@ -89,8 +89,8 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
onLatestVersion = checker.isUsingLatestVersion(); onLatestVersion = checker.isUsingLatestVersion();
// File setup // File setup
saveDefaultConfig(); saveDefaultConfig();
//saveResource("translations.yml", false);
if (!Path.of(getDataFolder().getPath(), "messages.yml").toFile().exists()) saveResource("messages.yml", false); if (!Path.of(getDataFolder().getPath(), "messages.yml").toFile().exists()) saveResource("messages.yml", false);
if (!Path.of(getDataFolder().getPath(), "translations.yml").toFile().exists()) saveResource("translations.yml", false);
if (!Path.of(getDataFolder().getPath() + "/cosmetics/").toFile().exists()) saveResource("cosmetics/defaultcosmetics.yml", false); if (!Path.of(getDataFolder().getPath() + "/cosmetics/").toFile().exists()) saveResource("cosmetics/defaultcosmetics.yml", false);
if (!Path.of(getDataFolder().getPath() + "/menus/").toFile().exists()) saveResource("menus/defaultmenu.yml", false); if (!Path.of(getDataFolder().getPath() + "/menus/").toFile().exists()) saveResource("menus/defaultmenu.yml", false);
@@ -104,11 +104,15 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
// Configuration Sync // Configuration Sync
final File configFile = Path.of(getInstance().getDataFolder().getPath(), "config.yml").toFile(); final File configFile = Path.of(getInstance().getDataFolder().getPath(), "config.yml").toFile();
final File messageFile = Path.of(getInstance().getDataFolder().getPath(), "messages.yml").toFile(); final File messageFile = Path.of(getInstance().getDataFolder().getPath(), "messages.yml").toFile();
final File translationFile = Path.of(getInstance().getDataFolder().getPath(), "translations.yml").toFile();
try { try {
CommentedConfiguration.loadConfiguration(configFile).syncWithConfig(configFile, getInstance().getResource("config.yml"), CommentedConfiguration.loadConfiguration(configFile).syncWithConfig(configFile, getInstance().getResource("config.yml"),
"database-settings", "debug-mode", "wardrobe.viewer-location", "wardrobe.npc-location", "wardrobe.wardrobe-location", "wardrobe.leave-location"); "database-settings", "debug-mode", "wardrobe.viewer-location", "wardrobe.npc-location", "wardrobe.wardrobe-location", "wardrobe.leave-location");
CommentedConfiguration.loadConfiguration(messageFile).syncWithConfig(messageFile, getInstance().getResource("messages.yml")); CommentedConfiguration.loadConfiguration(messageFile).syncWithConfig(messageFile, getInstance().getResource("messages.yml"));
} catch (Exception e) {} CommentedConfiguration.loadConfiguration(translationFile).syncWithConfig(translationFile, getInstance().getResource("translations.yml"));
} catch (Exception e) {
e.printStackTrace();
}
// Setup // Setup
setup(); setup();

View File

@@ -0,0 +1,49 @@
package com.hibiscusmc.hmccosmetics.api;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
import com.hibiscusmc.hmccosmetics.gui.Menu;
import com.hibiscusmc.hmccosmetics.gui.Menus;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import org.jetbrains.annotations.Nullable;
import java.util.UUID;
public class HMCCosmeticsAPI {
/**
* Attempts to get a cosmetic from HMCCosmetics
*
* @param cosmetic Cosmetic Id
* @return A {@link Cosmetic} if exists or null if it does not
*/
@Nullable
public static Cosmetic getCosmetic(String cosmetic) {
return Cosmetics.getCosmetic(cosmetic);
}
/**
* Attempts to get the CosmeticUser from an online user. If a player is offline it will return null.
* A player maybe online but not have a CosmeticUser attached to them, either from delay specified in the config
* or from a /reload. Always check if it's null!
*
* @param uuid Player Unique ID
* @return A {@link CosmeticUser} if exists or null if it does not
*/
@Nullable
public static CosmeticUser getUser(UUID uuid) {
return CosmeticUsers.getUser(uuid);
}
/**
* Attempts to get a HMCCosmetics Menu. Returns null if no menu exists under that id.
*
* @param id Menu ID
* @return A {@link Menu} if exists or null if it does not
*/
@Nullable
public static Menu getMenu(String id) {
return Menus.getMenu(id);
}
}

View File

@@ -1,4 +1,4 @@
package com.hibiscusmc.hmccosmetics.api; package com.hibiscusmc.hmccosmetics.api.events;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;

View File

@@ -1,4 +1,4 @@
package com.hibiscusmc.hmccosmetics.api; package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;

View File

@@ -1,4 +1,4 @@
package com.hibiscusmc.hmccosmetics.api; package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.Event; import org.bukkit.event.Event;

View File

@@ -1,4 +1,4 @@
package com.hibiscusmc.hmccosmetics.api; package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;

View File

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

View File

@@ -1,4 +1,4 @@
package com.hibiscusmc.hmccosmetics.api; package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;

View File

@@ -1,4 +1,4 @@
package com.hibiscusmc.hmccosmetics.api; package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;

View File

@@ -1,4 +1,4 @@
package com.hibiscusmc.hmccosmetics.api; package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;

View File

@@ -1,4 +1,4 @@
package com.hibiscusmc.hmccosmetics.api; package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager; import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;

View File

@@ -1,4 +1,4 @@
package com.hibiscusmc.hmccosmetics.api; package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.gui.Menu; import com.hibiscusmc.hmccosmetics.gui.Menu;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;

View File

@@ -1,4 +1,4 @@
package com.hibiscusmc.hmccosmetics.api; package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.gui.Menu; import com.hibiscusmc.hmccosmetics.gui.Menu;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;

View File

@@ -1,4 +1,4 @@
package com.hibiscusmc.hmccosmetics.api; package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.gui.Menu; import com.hibiscusmc.hmccosmetics.gui.Menu;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;

View File

@@ -1,7 +1,6 @@
package com.hibiscusmc.hmccosmetics.api; package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.config.Wardrobe; import com.hibiscusmc.hmccosmetics.config.Wardrobe;
import com.hibiscusmc.hmccosmetics.config.WardrobeLocation;
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.HandlerList; import org.bukkit.event.HandlerList;

View File

@@ -1,4 +1,4 @@
package com.hibiscusmc.hmccosmetics.api; package com.hibiscusmc.hmccosmetics.api.events;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;

View File

@@ -34,6 +34,7 @@ public class Settings {
private static final String TICK_PERIOD_PATH = "tick-period"; private static final String TICK_PERIOD_PATH = "tick-period";
private static final String UNAPPLY_DEATH_PATH = "unapply-on-death"; private static final String UNAPPLY_DEATH_PATH = "unapply-on-death";
private static final String FORCE_PERMISSION_JOIN_PATH = "force-permission-join"; private static final String FORCE_PERMISSION_JOIN_PATH = "force-permission-join";
private static final String FORCE_SHOW_COSMETICS_PATH = "force-show-join";
private static final String EMOTE_DISTANCE_PATH = "emote-distance"; private static final String EMOTE_DISTANCE_PATH = "emote-distance";
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";
@@ -64,6 +65,7 @@ public class Settings {
private static boolean debugMode; private static boolean debugMode;
private static boolean unapplyOnDeath; private static boolean unapplyOnDeath;
private static boolean forcePermissionJoin; private static boolean forcePermissionJoin;
private static boolean forceShowOnJoin;
private static boolean itemsAdderChangeReload; private static boolean itemsAdderChangeReload;
private static boolean worldGuardMoveCheck; private static boolean worldGuardMoveCheck;
private static boolean cosmeticEmoteBlockCheck; private static boolean cosmeticEmoteBlockCheck;
@@ -105,6 +107,7 @@ public class Settings {
requireEmptyBoots = cosmeticSettings.node(REQUIRE_EMPTY_BOOTS_PATH).getBoolean(); requireEmptyBoots = cosmeticSettings.node(REQUIRE_EMPTY_BOOTS_PATH).getBoolean();
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false); unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false); forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
forceShowOnJoin = cosmeticSettings.node(FORCE_SHOW_COSMETICS_PATH).getBoolean(false);
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3); 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);
emoteAirCheck = cosmeticSettings.node(COSMETIC_EMOTE_AIR_CHECK_PATH).getBoolean(true); emoteAirCheck = cosmeticSettings.node(COSMETIC_EMOTE_AIR_CHECK_PATH).getBoolean(true);
@@ -254,6 +257,10 @@ public class Settings {
return forcePermissionJoin; return forcePermissionJoin;
} }
public static boolean isForceShowOnJoin() {
return forceShowOnJoin;
}
public static boolean getDebugMode() { public static boolean getDebugMode() {
return debugMode; return debugMode;
} }

View File

@@ -52,7 +52,7 @@ public class Wardrobe {
public boolean canEnter(CosmeticUser user) { public boolean canEnter(CosmeticUser user) {
Location wardrobeLocation = location.getNpcLocation(); Location wardrobeLocation = location.getNpcLocation();
Location location = user.getPlayer().getLocation(); Location location = user.getEntity().getLocation();
if (wardrobeLocation == null) return false; if (wardrobeLocation == null) return false;
if (distance == -1) return true; if (distance == -1) return true;
if (!wardrobeLocation.getWorld().equals(location.getWorld())) return false; if (!wardrobeLocation.getWorld().equals(location.getWorld())) return false;

View File

@@ -10,7 +10,9 @@ import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.spongepowered.configurate.ConfigurationNode; import org.spongepowered.configurate.ConfigurationNode;
import java.util.*; import java.util.Collection;
import java.util.HashMap;
import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
public class WardrobeSettings { public class WardrobeSettings {
@@ -33,6 +35,10 @@ public class WardrobeSettings {
private static final String EQUIP_PUMPKIN_WARDROBE = "equip-pumpkin"; private static final String EQUIP_PUMPKIN_WARDROBE = "equip-pumpkin";
private static final String TRY_COSMETICS_WARDROBE = "unchecked-wardrobe-cosmetics"; private static final String TRY_COSMETICS_WARDROBE = "unchecked-wardrobe-cosmetics";
private static final String RETURN_LAST_LOCATION = "return-last-location"; private static final String RETURN_LAST_LOCATION = "return-last-location";
private static final String WARDROBE_MENU_OPTIONS = "menu-options";
private static final String WARDROBE_ENTER_OPEN_MENU_PATH = "enter-open-menu";
private static final String GAMEMODE_OPTIONS_PATH = "gamemode-options"; private static final String GAMEMODE_OPTIONS_PATH = "gamemode-options";
private static final String FORCE_EXIT_GAMEMODE_PATH = "exit-gamemode-enabled"; private static final String FORCE_EXIT_GAMEMODE_PATH = "exit-gamemode-enabled";
private static final String EXIT_GAMEMODE_PATH = "exit-gamemode"; private static final String EXIT_GAMEMODE_PATH = "exit-gamemode";
@@ -68,6 +74,7 @@ public class WardrobeSettings {
private static boolean equipPumpkin; private static boolean equipPumpkin;
private static boolean returnLastLocation; private static boolean returnLastLocation;
private static boolean enabledBossbar; private static boolean enabledBossbar;
private static boolean enterOpenMenu;
private static boolean forceExitGamemode; private static boolean forceExitGamemode;
private static GameMode exitGamemode; private static GameMode exitGamemode;
private static HashMap<String, Wardrobe> wardrobes; private static HashMap<String, Wardrobe> wardrobes;
@@ -97,6 +104,9 @@ public class WardrobeSettings {
returnLastLocation = source.node(RETURN_LAST_LOCATION).getBoolean(false); returnLastLocation = source.node(RETURN_LAST_LOCATION).getBoolean(false);
tryCosmeticsInWardrobe = source.node(TRY_COSMETICS_WARDROBE).getBoolean(false); tryCosmeticsInWardrobe = source.node(TRY_COSMETICS_WARDROBE).getBoolean(false);
ConfigurationNode menuOptionsNode = source.node(WARDROBE_MENU_OPTIONS);
enterOpenMenu = menuOptionsNode.node(WARDROBE_ENTER_OPEN_MENU_PATH).getBoolean(false);
ConfigurationNode gamemodeNode = source.node(GAMEMODE_OPTIONS_PATH); ConfigurationNode gamemodeNode = source.node(GAMEMODE_OPTIONS_PATH);
forceExitGamemode = gamemodeNode.node(FORCE_EXIT_GAMEMODE_PATH).getBoolean(false); forceExitGamemode = gamemodeNode.node(FORCE_EXIT_GAMEMODE_PATH).getBoolean(false);
exitGamemode = GameMode.valueOf(gamemodeNode.node(EXIT_GAMEMODE_PATH).getString("SURVIVAL")); exitGamemode = GameMode.valueOf(gamemodeNode.node(EXIT_GAMEMODE_PATH).getString("SURVIVAL"));
@@ -274,6 +284,10 @@ public class WardrobeSettings {
return transitionFadeOut; return transitionFadeOut;
} }
public static boolean isEnterOpenMenu() {
return enterOpenMenu;
}
public static boolean isForceExitGamemode() { public static boolean isForceExitGamemode() {
return forceExitGamemode; return forceExitGamemode;
} }

View File

@@ -2,16 +2,14 @@ package com.hibiscusmc.hmccosmetics.config.serializer;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin; import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.hooks.Hooks; import com.hibiscusmc.hmccosmetics.hooks.Hooks;
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.ServerUtils; import com.hibiscusmc.hmccosmetics.util.ServerUtils;
import com.hibiscusmc.hmccosmetics.util.builder.ColorBuilder; import com.hibiscusmc.hmccosmetics.util.builder.ColorBuilder;
import com.hibiscusmc.hmccosmetics.util.misc.StringUtils; import com.hibiscusmc.hmccosmetics.util.misc.StringUtils;
import com.hibiscusmc.hmccosmetics.util.misc.Utils; import com.hibiscusmc.hmccosmetics.util.misc.Utils;
import org.apache.commons.lang3.EnumUtils; import org.apache.commons.lang3.EnumUtils;
import org.bukkit.Bukkit; import org.bukkit.*;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@@ -123,12 +121,25 @@ public class ItemSerializer implements TypeSerializer<ItemStack> {
if (item.getType() == Material.PLAYER_HEAD) { if (item.getType() == Material.PLAYER_HEAD) {
SkullMeta skullMeta = (SkullMeta) itemMeta; SkullMeta skullMeta = (SkullMeta) itemMeta;
if (!ownerNode.virtual()) { if (!ownerNode.virtual()) {
skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer(ownerNode.getString())); String ownerString = ownerNode.getString();
if (ownerString.contains("%")) {
// This means it has PAPI placeholders in it
skullMeta.getPersistentDataContainer().set(InventoryUtils.getSkullOwner(), PersistentDataType.STRING, ownerString);
}
OfflinePlayer player = Bukkit.getOfflinePlayer(ownerString);
skullMeta.setOwningPlayer(player);
} }
if (!textureNode.virtual()) { if (!textureNode.virtual()) {
String textureString = textureNode.getString();
if (textureString.contains("%")) {
// This means it has PAPI placeholders in it
skullMeta.getPersistentDataContainer().set(InventoryUtils.getSkullTexture(), PersistentDataType.STRING, textureString);
}
Bukkit.getUnsafe().modifyItemStack(item, "{SkullOwner:{Id:[I;0,0,0,0],Properties:{textures:[{Value:\"" Bukkit.getUnsafe().modifyItemStack(item, "{SkullOwner:{Id:[I;0,0,0,0],Properties:{textures:[{Value:\""
+ textureNode.getString() + "\"}]}}}"); + textureString + "\"}]}}}");
itemMeta = skullMeta; itemMeta = skullMeta;
} }
} }

View File

@@ -15,8 +15,11 @@ import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.yaml.YamlConfigurationLoader; import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
import java.io.File; import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Set; import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Stream;
public class Cosmetics { public class Cosmetics {
@@ -68,19 +71,23 @@ public class Cosmetics {
File[] directoryListing = cosmeticFolder.listFiles(); File[] directoryListing = cosmeticFolder.listFiles();
if (directoryListing == null) return; if (directoryListing == null) return;
for (File child : directoryListing) { try (Stream<Path> walkStream = Files.walk(cosmeticFolder.toPath())) {
if (child.toString().contains(".yml") || child.toString().contains(".yaml")) { walkStream.filter(p -> p.toFile().isFile()).forEach(child -> {
MessagesUtil.sendDebugMessages("Scanning " + child); if (child.toString().contains(".yml") || child.toString().contains(".yaml")) {
// Loads file MessagesUtil.sendDebugMessages("Scanning " + child);
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child.toPath()).build(); // Loads file
CommentedConfigurationNode root; YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child).build();
try { CommentedConfigurationNode root;
root = loader.load(); try {
} catch (ConfigurateException e) { root = loader.load();
throw new RuntimeException(e); } catch (ConfigurateException e) {
throw new RuntimeException(e);
}
setupCosmetics(root);
} }
setupCosmetics(root); });
} } catch (Exception e) {
e.printStackTrace();
} }
} }

View File

@@ -5,10 +5,10 @@ import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers; import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.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.Entity;
import org.bukkit.entity.HumanEntity;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -26,19 +26,20 @@ public class CosmeticArmorType extends Cosmetic {
@Override @Override
public void update(@NotNull CosmeticUser user) { public void update(@NotNull CosmeticUser user) {
Player player = Bukkit.getPlayer(user.getUniqueId()); Entity entity = Bukkit.getEntity(user.getUniqueId());
if (player == null) return; if (entity == null) return;
if (user.getUserEmoteManager().isPlayingEmote()) return; // There has to be a better way of doing this... if (user.getUserEmoteManager().isPlayingEmote()) return; // There has to be a better way of doing this...
ItemStack cosmeticItem = user.getUserCosmeticItem(this); ItemStack cosmeticItem = user.getUserCosmeticItem(this);
if (!(entity instanceof HumanEntity humanEntity)) return;
if (equipSlot.equals(EquipmentSlot.OFF_HAND)) { if (equipSlot.equals(EquipmentSlot.OFF_HAND)) {
if (!player.getInventory().getItemInOffHand().getType().isAir()) return; if (!humanEntity.getInventory().getItemInOffHand().getType().isAir()) return;
} }
ItemStack equippedItem = player.getInventory().getItem(equipSlot); ItemStack equippedItem = humanEntity.getInventory().getItem(equipSlot);
if (Settings.getShouldAddEnchants(equipSlot)) { if (Settings.getShouldAddEnchants(equipSlot)) {
cosmeticItem.addUnsafeEnchantments(equippedItem.getEnchantments()); cosmeticItem.addUnsafeEnchantments(equippedItem.getEnchantments());
} }
NMSHandlers.getHandler().equipmentSlotUpdate(player.getEntityId(), equipSlot, cosmeticItem, PacketManager.getViewers(player.getLocation())); NMSHandlers.getHandler().equipmentSlotUpdate(entity.getEntityId(), equipSlot, cosmeticItem, PacketManager.getViewers(entity.getLocation()));
//PacketManager.equipmentSlotUpdate(player, getSlot(), PacketManager.getViewers(player.getLocation())); Old method //PacketManager.equipmentSlotUpdate(player, getSlot(), PacketManager.getViewers(player.getLocation())); Old method
} }

View File

@@ -7,7 +7,7 @@ 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;
import org.bukkit.entity.Player; import org.bukkit.entity.Entity;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.spongepowered.configurate.ConfigurationNode; import org.spongepowered.configurate.ConfigurationNode;
@@ -27,13 +27,13 @@ public class CosmeticBackpackType extends Cosmetic {
@Override @Override
public void update(@NotNull CosmeticUser user) { public void update(@NotNull CosmeticUser user) {
Player player = Bukkit.getPlayer(user.getUniqueId()); Entity entity = Bukkit.getEntity(user.getUniqueId());
if (player == null) return; if (entity == null) return;
Location loc = player.getLocation().clone().add(0, 2, 0); Location loc = entity.getLocation().clone().add(0, 2, 0);
if (user.isInWardrobe() || !user.isBackpackSpawned()) return; if (user.isInWardrobe() || !user.isBackpackSpawned()) return;
if (!user.getUserBackpackManager().getArmorStand().isValid()) { if (!user.getUserBackpackManager().IsValidBackpackEntity()) {
MessagesUtil.sendDebugMessages("Invalid Backpack Entity[owner=" + user.getUniqueId() + ",player_location=" + loc + "]!", Level.WARNING); MessagesUtil.sendDebugMessages("Invalid Backpack Entity[owner=" + user.getUniqueId() + ",player_location=" + loc + "]!", Level.WARNING);
user.respawnBackpack(); user.respawnBackpack();
return; return;
@@ -46,10 +46,10 @@ public class CosmeticBackpackType extends Cosmetic {
if (user.getUserBackpackManager().getBackpackType().equals(UserBackpackManager.BackpackType.FIRST_PERSON)) { if (user.getUserBackpackManager().getBackpackType().equals(UserBackpackManager.BackpackType.FIRST_PERSON)) {
user.getUserBackpackManager().teleportEffectEntity(loc); user.getUserBackpackManager().teleportEffectEntity(loc);
PacketManager.sendRidingPacket(player.getEntityId(), user.getUserBackpackManager().getAreaEffectEntityId(), loc); PacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getAreaEffectEntityId(), loc);
PacketManager.sendRidingPacket(user.getUserBackpackManager().getAreaEffectEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), loc); PacketManager.sendRidingPacket(user.getUserBackpackManager().getAreaEffectEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), loc);
} else { } else {
PacketManager.sendRidingPacket(player.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), loc); PacketManager.sendRidingPacket(entity.getEntityId(), user.getUserBackpackManager().getFirstArmorStandId(), loc);
} }
user.getUserBackpackManager().getArmorStand().setRotation(loc.getYaw(), loc.getPitch()); user.getUserBackpackManager().getArmorStand().setRotation(loc.getYaw(), loc.getPitch());

View File

@@ -2,11 +2,13 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
import com.hibiscusmc.hmccosmetics.config.Settings; import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
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;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -42,10 +44,10 @@ public class CosmeticBalloonType extends Cosmetic {
@Override @Override
public void update(@NotNull CosmeticUser user) { public void update(@NotNull CosmeticUser user) {
Player player = Bukkit.getPlayer(user.getUniqueId()); Entity entity = Bukkit.getEntity(user.getUniqueId());
UserBalloonManager userBalloonManager = user.getBalloonManager(); UserBalloonManager userBalloonManager = user.getBalloonManager();
if (player == null || userBalloonManager == null) return; if (entity == null || userBalloonManager == null) return;
if (user.isInWardrobe()) return; if (user.isInWardrobe()) return;
if (!userBalloonManager.getModelEntity().isValid()) { if (!userBalloonManager.getModelEntity().isValid()) {
@@ -53,14 +55,13 @@ public class CosmeticBalloonType extends Cosmetic {
return; return;
} }
Location newLocation = player.getLocation(); Location newLocation = entity.getLocation();
Location currentLocation = user.getBalloonManager().getLocation(); Location currentLocation = user.getBalloonManager().getLocation();
newLocation = newLocation.clone().add(Settings.getBalloonOffset()); newLocation = newLocation.clone().add(Settings.getBalloonOffset());
List<Player> viewer = PacketManager.getViewers(player.getLocation()); List<Player> viewer = PacketManager.getViewers(entity.getLocation());
viewer.add(player);
if (player.getLocation().getWorld() != userBalloonManager.getLocation().getWorld()) { if (entity.getLocation().getWorld() != userBalloonManager.getLocation().getWorld()) {
userBalloonManager.getModelEntity().teleport(newLocation); userBalloonManager.getModelEntity().teleport(newLocation);
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer); PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
return; return;
@@ -71,7 +72,17 @@ public class CosmeticBalloonType extends Cosmetic {
userBalloonManager.setLocation(newLocation); userBalloonManager.setLocation(newLocation);
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer); PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
if (!user.getHidden() && showLead) PacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), player.getEntityId(), viewer); PacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), entity.getEntityId(), viewer);
if (user.getHidden()) {
userBalloonManager.getPufferfish().hidePufferfish();
return;
}
if (!user.getHidden() && showLead) {
List<Player> sendTo = userBalloonManager.getPufferfish().refreshViewers(newLocation);
if (sendTo.isEmpty()) return;
PacketManager.sendEntitySpawnPacket(newLocation, userBalloonManager.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager.getPufferfishBalloonUniqueId(), sendTo);
PacketManager.sendInvisibilityPacket(userBalloonManager.getPufferfishBalloonId(), sendTo);
}
} }
public String getModelName() { public String getModelName() {

View File

@@ -2,7 +2,6 @@ package com.hibiscusmc.hmccosmetics.database;
import com.hibiscusmc.hmccosmetics.config.DatabaseSettings; import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
import com.hibiscusmc.hmccosmetics.database.types.Data; import com.hibiscusmc.hmccosmetics.database.types.Data;
import com.hibiscusmc.hmccosmetics.database.types.InternalData;
import com.hibiscusmc.hmccosmetics.database.types.MySQLData; import com.hibiscusmc.hmccosmetics.database.types.MySQLData;
import com.hibiscusmc.hmccosmetics.database.types.SQLiteData; import com.hibiscusmc.hmccosmetics.database.types.SQLiteData;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
@@ -16,9 +15,6 @@ public class Database {
private static Data data; private static Data data;
@Deprecated
private static InternalData INTERNAL_DATA = new InternalData();
private static final MySQLData MYSQL_DATA = new MySQLData(); private static final MySQLData MYSQL_DATA = new MySQLData();
private static final SQLiteData SQLITE_DATA = new SQLiteData(); private static final SQLiteData SQLITE_DATA = new SQLiteData();

View File

@@ -50,10 +50,13 @@ public abstract class Data {
return data; return data;
} }
@NotNull
public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUser user, @NotNull String raw) { public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUser user, @NotNull String raw) {
return deserializeData(user, raw, Settings.getForcePermissionJoin());
}
@NotNull
public final Map<CosmeticSlot, Map<Cosmetic, Color>> deserializeData(CosmeticUser user, @NotNull String raw, boolean permissionCheck) {
Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = new HashMap<>(); Map<CosmeticSlot, Map<Cosmetic, Color>> cosmetics = new HashMap<>();
boolean checkPermission = Settings.getForcePermissionJoin();
String[] rawData = raw.split(","); String[] rawData = raw.split(",");
for (String a : rawData) { for (String a : rawData) {
@@ -64,6 +67,7 @@ public abstract class Data {
MessagesUtil.sendDebugMessages("First split (suppose slot) " + splitData[0]); MessagesUtil.sendDebugMessages("First split (suppose slot) " + splitData[0]);
if (splitData[0].equalsIgnoreCase("HIDDEN")) { if (splitData[0].equalsIgnoreCase("HIDDEN")) {
if (EnumUtils.isValidEnum(CosmeticUser.HiddenReason.class, splitData[1])) { if (EnumUtils.isValidEnum(CosmeticUser.HiddenReason.class, splitData[1])) {
if (Settings.isForceShowOnJoin()) continue;
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> { Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
user.hideCosmetics(CosmeticUser.HiddenReason.valueOf(splitData[1])); user.hideCosmetics(CosmeticUser.HiddenReason.valueOf(splitData[1]));
}); });
@@ -75,8 +79,8 @@ public abstract class Data {
String[] colorSplitData = splitData[1].split("&"); String[] colorSplitData = splitData[1].split("&");
if (Cosmetics.hasCosmetic(colorSplitData[0])) cosmetic = Cosmetics.getCosmetic(colorSplitData[0]); if (Cosmetics.hasCosmetic(colorSplitData[0])) cosmetic = Cosmetics.getCosmetic(colorSplitData[0]);
if (slot == null || cosmetic == null) continue; if (slot == null || cosmetic == null) continue;
if (cosmetic.requiresPermission() && checkPermission) { if (permissionCheck && cosmetic.requiresPermission()) {
if (!user.getPlayer().hasPermission(cosmetic.getPermission())) { if (user.getPlayer() != null && !user.getPlayer().hasPermission(cosmetic.getPermission())) {
continue; continue;
} }
} }
@@ -84,8 +88,8 @@ public abstract class Data {
} else { } else {
if (Cosmetics.hasCosmetic(splitData[1])) cosmetic = Cosmetics.getCosmetic(splitData[1]); if (Cosmetics.hasCosmetic(splitData[1])) cosmetic = Cosmetics.getCosmetic(splitData[1]);
if (slot == null || cosmetic == null) continue; if (slot == null || cosmetic == null) continue;
if (cosmetic.requiresPermission() && checkPermission) { if (permissionCheck && cosmetic.requiresPermission()) {
if (!user.getPlayer().hasPermission(cosmetic.getPermission())) { if (user.getPlayer() != null && !user.getPlayer().hasPermission(cosmetic.getPermission())) {
continue; continue;
} }
} }

View File

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

View File

@@ -6,7 +6,10 @@ import org.bukkit.Bukkit;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.sql.*; import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Properties; import java.util.Properties;
import java.util.UUID; import java.util.UUID;

View File

@@ -15,7 +15,7 @@ import java.util.UUID;
public abstract class SQLData extends Data { public abstract class SQLData extends Data {
@Override @Override
@SuppressWarnings({"Duplicates", "resource"}) // Duplicate is from deprecated InternalData @SuppressWarnings({"resource"}) // Duplicate is from deprecated InternalData
public CosmeticUser get(UUID uniqueId) { public CosmeticUser get(UUID uniqueId) {
CosmeticUser user = new CosmeticUser(uniqueId); CosmeticUser user = new CosmeticUser(uniqueId);

View File

@@ -6,7 +6,10 @@ import org.bukkit.Bukkit;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.sql.*; import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;

View File

@@ -1,7 +1,7 @@
package com.hibiscusmc.hmccosmetics.gui; package com.hibiscusmc.hmccosmetics.gui;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin; import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.api.PlayerMenuOpenEvent; import com.hibiscusmc.hmccosmetics.api.events.PlayerMenuOpenEvent;
import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer; import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
import com.hibiscusmc.hmccosmetics.gui.type.Type; import com.hibiscusmc.hmccosmetics.gui.type.Type;
import com.hibiscusmc.hmccosmetics.gui.type.Types; import com.hibiscusmc.hmccosmetics.gui.type.Types;
@@ -77,26 +77,21 @@ public class Menu {
gui.setDefaultClickAction(event -> event.setCancelled(true)); gui.setDefaultClickAction(event -> event.setCancelled(true));
// TODO: Redo this whole gui creation process to allow for all items, possibly implement caching
gui = getItems(user, gui); gui = getItems(user, gui);
final Gui finalGui = gui; // Need to make it final for the runtask
Gui finalGui = gui; // API
PlayerMenuOpenEvent event = new PlayerMenuOpenEvent(user, this); PlayerMenuOpenEvent event = new PlayerMenuOpenEvent(user, this);
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> { Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
}); });
if (event.isCancelled()) return;
if (event.isCancelled()) { // Internal
return;
}
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> { Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
finalGui.open(player); finalGui.open(player);
}); });
//gui.open(player);
} }
@Contract("_, _ -> param2") @Contract("_, _ -> param2")

View File

@@ -11,11 +11,14 @@ import org.spongepowered.configurate.ConfigurateException;
import org.spongepowered.configurate.yaml.YamlConfigurationLoader; import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
import java.io.File; import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Stream;
public class Menus { public class Menus {
@@ -66,27 +69,29 @@ public class Menus {
File cosmeticFolder = new File(HMCCosmeticsPlugin.getInstance().getDataFolder() + "/menus"); File cosmeticFolder = new File(HMCCosmeticsPlugin.getInstance().getDataFolder() + "/menus");
if (!cosmeticFolder.exists()) cosmeticFolder.mkdir(); if (!cosmeticFolder.exists()) cosmeticFolder.mkdir();
File[] directoryListing = cosmeticFolder.listFiles(); // Recursive file lookup
if (directoryListing == null) return; try (Stream<Path> walkStream = Files.walk(cosmeticFolder.toPath())) {
walkStream.filter(p -> p.toFile().isFile()).forEach(child -> {
for (File child : directoryListing) { if (child.toString().endsWith("yml") || child.toString().endsWith("yaml")) {
if (child.toString().contains(".yml") || child.toString().contains(".yaml")) { MessagesUtil.sendDebugMessages("Scanning " + child);
MessagesUtil.sendDebugMessages("Scanning " + child); // Loads file
// Loads file YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child).build();
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child.toPath()).build(); CommentedConfigurationNode root;
CommentedConfigurationNode root; try {
try { root = loader.load();
root = loader.load(); } catch (ConfigurateException e) {
} catch (ConfigurateException e) { throw new RuntimeException(e);
throw new RuntimeException(e); }
try {
new Menu(FilenameUtils.removeExtension(child.getFileName().toString()), root);
} catch (Exception e) {
MessagesUtil.sendDebugMessages("Unable to create menu in " + child.getFileName().toString(), Level.WARNING);
if (Settings.isDebugEnabled()) e.printStackTrace();
}
} }
try { });
new Menu(FilenameUtils.removeExtension(child.getName()), root); } catch (Exception e) {
} catch (Exception e) { e.printStackTrace();
MessagesUtil.sendDebugMessages("Unable to create menu in " + child, Level.WARNING);
if (Settings.isDebugEnabled()) e.printStackTrace();
}
}
} }
} }
} }

View File

@@ -1,6 +1,5 @@
package com.hibiscusmc.hmccosmetics.gui.action.actions; package com.hibiscusmc.hmccosmetics.gui.action.actions;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.gui.Menu; import com.hibiscusmc.hmccosmetics.gui.Menu;
import com.hibiscusmc.hmccosmetics.gui.Menus; import com.hibiscusmc.hmccosmetics.gui.Menus;
import com.hibiscusmc.hmccosmetics.gui.action.Action; import com.hibiscusmc.hmccosmetics.gui.action.Action;

View File

@@ -3,7 +3,6 @@ package com.hibiscusmc.hmccosmetics.gui.type;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.spongepowered.configurate.ConfigurationNode; import org.spongepowered.configurate.ConfigurationNode;
public abstract class Type { public abstract class Type {

View File

@@ -11,9 +11,6 @@ import com.hibiscusmc.hmccosmetics.gui.type.Type;
import com.hibiscusmc.hmccosmetics.hooks.Hooks; import com.hibiscusmc.hmccosmetics.hooks.Hooks;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.misc.StringUtils;
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
@@ -25,10 +22,8 @@ import org.jetbrains.annotations.NotNull;
import org.spongepowered.configurate.ConfigurationNode; import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException; import org.spongepowered.configurate.serialize.SerializationException;
import java.lang.invoke.TypeDescriptor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
public class TypeCosmetic extends Type { public class TypeCosmetic extends Type {
@@ -152,10 +147,13 @@ public class TypeCosmetic extends Type {
private ItemMeta processLoreLines(CosmeticUser user, @NotNull ItemMeta itemMeta) { private ItemMeta processLoreLines(CosmeticUser user, @NotNull ItemMeta itemMeta) {
List<String> processedLore = new ArrayList<>(); List<String> processedLore = new ArrayList<>();
if (itemMeta.hasDisplayName()) {
itemMeta.setDisplayName(Hooks.processPlaceholders(user.getPlayer(), itemMeta.getDisplayName()));
}
if (itemMeta.hasLore()) { if (itemMeta.hasLore()) {
for (String loreLine : itemMeta.getLore()) { for (String loreLine : itemMeta.getLore()) {
if (Hooks.isActiveHook("PlaceholderAPI")) loreLine = PlaceholderAPI.setPlaceholders(user.getPlayer(), loreLine); processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
processedLore.add(loreLine);
} }
} }
itemMeta.setLore(processedLore); itemMeta.setLore(processedLore);

View File

@@ -4,7 +4,6 @@ import com.hibiscusmc.hmccosmetics.gui.action.Actions;
import com.hibiscusmc.hmccosmetics.gui.type.Type; import com.hibiscusmc.hmccosmetics.gui.type.Type;
import com.hibiscusmc.hmccosmetics.hooks.Hooks; import com.hibiscusmc.hmccosmetics.hooks.Hooks;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
@@ -58,11 +57,13 @@ public class TypeEmpty extends Type {
List<String> processedLore = new ArrayList<>(); List<String> processedLore = new ArrayList<>();
ItemMeta itemMeta = itemStack.getItemMeta(); ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta.hasDisplayName()) {
itemMeta.setDisplayName(Hooks.processPlaceholders(user.getPlayer(), itemMeta.getDisplayName()));
}
if (itemMeta.hasLore()) { if (itemMeta.hasLore()) {
for (String loreLine : itemMeta.getLore()) { for (String loreLine : itemMeta.getLore()) {
if (Hooks.isActiveHook("PlaceholderAPI")) processedLore.add(Hooks.processPlaceholders(user.getPlayer(), loreLine));
loreLine = PlaceholderAPI.setPlaceholders(user.getPlayer(), loreLine);
processedLore.add(loreLine);
} }
} }
itemStack.setItemMeta(itemMeta); itemStack.setItemMeta(itemMeta);

View File

@@ -4,8 +4,10 @@ import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.hooks.items.*; import com.hibiscusmc.hmccosmetics.hooks.items.*;
import com.hibiscusmc.hmccosmetics.hooks.misc.*; import com.hibiscusmc.hmccosmetics.hooks.misc.*;
import com.hibiscusmc.hmccosmetics.hooks.placeholders.HookPlaceholderAPI; import com.hibiscusmc.hmccosmetics.hooks.placeholders.HookPlaceholderAPI;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -70,6 +72,12 @@ public class Hooks {
return hook.getItem(split[1]); return hook.getItem(split[1]);
} }
@NotNull
public static String processPlaceholders(OfflinePlayer player, String raw) {
if (getHook("PlaceholderAPI").isActive()) return PlaceholderAPI.setPlaceholders(player, raw);
return raw;
}
public static boolean isActiveHook(String id) { public static boolean isActiveHook(String id) {
Hook hook = getHook(id); Hook hook = getHook(id);
if (hook == null) return false; if (hook == null) return false;

View File

@@ -39,7 +39,7 @@ public class HookGeary extends Hook {
if (enabled) { if (enabled) {
PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId); PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId);
if (prefabKey == null) return null; if (prefabKey == null) return null;
return ItemTrackingKt.getItemTracking().createItem(prefabKey, null); return ItemTrackingKt.getGearyItems().createItem(prefabKey, null);
} else return new ItemStack(Material.AIR); } else return new ItemStack(Material.AIR);
} }
} }

View File

@@ -69,9 +69,9 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1)); Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
if (cosmetic == null) return "INVALID_COSMETIC"; if (cosmetic == null) return "INVALID_COSMETIC";
Cosmetic currentCosmetic = user.getCosmetic(cosmetic.getSlot()); Cosmetic currentCosmetic = user.getCosmetic(cosmetic.getSlot());
if (currentCosmetic == null) return "false"; if (currentCosmetic == null) return TranslationUtil.getTranslation("using-cosmetic", String.valueOf(false)); // I hate this way of handling translations
if (currentCosmetic.getId() == cosmetic.getId()) return "true"; if (currentCosmetic.getId() == cosmetic.getId()) return TranslationUtil.getTranslation("using-cosmetic", String.valueOf(true));
return "false"; return TranslationUtil.getTranslation("using-cosmetic", String.valueOf(false));
} }
case "current": case "current":
if (placeholderArgs == null) { if (placeholderArgs == null) {
@@ -82,26 +82,29 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
if (slot == null) return null; if (slot == null) return null;
if (user.getCosmetic(slot) == null) return null; if (user.getCosmetic(slot) == null) return null;
if (placeholderArgs.size() == 2) return user.getCosmetic(slot).getId(); if (placeholderArgs.size() == 2) return user.getCosmetic(slot).getId();
String output;
switch (placeholderArgs.get(2).toLowerCase()) { switch (placeholderArgs.get(2).toLowerCase()) {
case "material" -> { case "material" -> {
return getMaterialName(user.getCosmetic(slot)); output = getMaterialName(user.getCosmetic(slot));
} }
case "custommodeldata" -> { case "custommodeldata" -> {
return getModelData(user.getCosmetic(slot)); output = getModelData(user.getCosmetic(slot));
} }
case "name" -> { case "name" -> {
return getItemName(user.getCosmetic(slot)); output = getItemName(user.getCosmetic(slot));
} }
case "lore" -> { case "lore" -> {
return getItemLore(user.getCosmetic(slot)); output = getItemLore(user.getCosmetic(slot));
} }
case "permission" -> { case "permission" -> {
return user.getCosmetic(slot).getPermission(); output = user.getCosmetic(slot).getPermission();
} }
default -> { default -> {
return user.getCosmetic(slot).getId(); output = user.getCosmetic(slot).getId();
} }
} }
return TranslationUtil.getTranslation("current-cosmetic", String.valueOf(output));
} }
case "unlocked": case "unlocked":
if (placeholderArgs == null) { if (placeholderArgs == null) {
@@ -121,7 +124,7 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
return "INVALID_COSMETIC"; return "INVALID_COSMETIC";
} }
} }
return TranslationUtil.getTranslation("unlockedCosmetic", String.valueOf(user.canEquipCosmetic(cosmetic))); return TranslationUtil.getTranslation("unlocked-cosmetic", String.valueOf(user.canEquipCosmetic(cosmetic)));
} }
case "equipped": case "equipped":
if (placeholderArgs == null) { if (placeholderArgs == null) {
@@ -131,11 +134,7 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
String args1 = placeholderArgs.get(1); String args1 = placeholderArgs.get(1);
if (EnumUtils.isValidEnum(CosmeticSlot.class, args1.toUpperCase())) { if (EnumUtils.isValidEnum(CosmeticSlot.class, args1.toUpperCase())) {
if (user.getCosmetic(CosmeticSlot.valueOf(args1.toUpperCase())) != null) { return TranslationUtil.getTranslation("equipped-cosmetic", String.valueOf(user.getCosmetic(CosmeticSlot.valueOf(args1.toUpperCase())) != null));
return "true";
} else {
return "false";
}
} }
MessagesUtil.sendDebugMessages(args1); MessagesUtil.sendDebugMessages(args1);
@@ -154,14 +153,10 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
} }
} }
if (user.getCosmetic(cosmetic.getSlot()) == null) return "false"; if (user.getCosmetic(cosmetic.getSlot()) == null) return "false";
if (cosmetic.getId() == user.getCosmetic(cosmetic.getSlot()).getId()) { return TranslationUtil.getTranslation("equipped-cosmetic", String.valueOf(cosmetic.getId() == user.getCosmetic(cosmetic.getSlot()).getId()));
return "true";
} else {
return "false";
}
} }
case "wardrobe-enabled": case "wardrobe-enabled":
return String.valueOf(user.isInWardrobe()); return TranslationUtil.getTranslation("in-wardrobe", String.valueOf(user.isInWardrobe()));
} }
return null; return null;
} }

View File

@@ -4,7 +4,6 @@ import com.hibiscusmc.hmccosmetics.config.Wardrobe;
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings; import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers; import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.WorldGuard; import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.ApplicableRegionSet;
@@ -15,6 +14,7 @@ import org.bukkit.Location;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
@@ -51,4 +51,35 @@ public class WGListener implements Listener {
} }
} }
} }
@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent event) {
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
if (user == null) return;
Location location = event.getTo();
com.sk89q.worldedit.util.Location loc = BukkitAdapter.adapt(location);
RegionContainer region = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionQuery query = region.createQuery();
ApplicableRegionSet set = query.getApplicableRegions(loc);
if (user.getHidden()) {
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD && set.getRegions().size() == 0) {
user.showCosmetics();
}
}
for (ProtectedRegion protectedRegion : set.getRegions()) {
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticEnableFlag())) {
if (protectedRegion.getFlags().get(WGHook.getCosmeticEnableFlag()).toString().equalsIgnoreCase("ALLOW")) {
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD) user.showCosmetics();
return;
}
user.hideCosmetics(CosmeticUser.HiddenReason.WORLDGUARD);
return;
}
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticWardrobeFlag())) {
if (!WardrobeSettings.getWardrobeNames().contains(protectedRegion.getFlags().get(WGHook.getCosmeticWardrobeFlag()).toString())) return;
Wardrobe wardrobe = WardrobeSettings.getWardrobe(protectedRegion.getFlags().get(WGHook.getCosmeticWardrobeFlag()).toString());
user.enterWardrobe(true, wardrobe);
}
}
}
} }

View File

@@ -9,6 +9,7 @@ import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.EnumWrappers; import com.comphenix.protocol.wrappers.EnumWrappers;
import com.comphenix.protocol.wrappers.Pair; import com.comphenix.protocol.wrappers.Pair;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin; import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.api.events.PlayerCosmeticPostEquipEvent;
import com.hibiscusmc.hmccosmetics.config.Settings; import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot; import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
@@ -23,7 +24,9 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager; 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 com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
@@ -111,22 +114,17 @@ public class PlayerGameListener implements Listener {
return; return;
} }
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) { Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> { if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK) && user.getUserBackpackManager() != null) {
user.respawnBackpack(); user.respawnBackpack();
user.updateCosmetic(); }
}, 1); if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
} user.respawnBalloon();
}
user.updateCosmetic();
}, 1);
if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL) || event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)) return; if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.NETHER_PORTAL) || event.getCause().equals(PlayerTeleportEvent.TeleportCause.END_PORTAL)) return;
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
final CosmeticBalloonType cosmeticBalloonType = (CosmeticBalloonType) user.getCosmetic(CosmeticSlot.BALLOON);
user.despawnBalloon();
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
user.spawnBalloon(cosmeticBalloonType);
}, 2);
}
if (user.getUserEmoteManager().isPlayingEmote()) { if (user.getUserEmoteManager().isPlayingEmote()) {
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.TELEPORT); user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.TELEPORT);
} }
@@ -346,6 +344,16 @@ public class PlayerGameListener implements Listener {
} }
} }
@EventHandler
public void onPlayerCosemticEquip(PlayerCosmeticPostEquipEvent event) {
CosmeticUser user = event.getUser();
if (user.isInWardrobe() && event.getCosmetic().getSlot().equals(CosmeticSlot.BALLOON)) {
Location NPCLocation = user.getWardrobeManager().getNpcLocation();
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), NPCLocation.add(Settings.getBalloonOffset()), false, List.of(event.getUser().getPlayer()));
user.getBalloonManager().getModelEntity().teleport(NPCLocation.add(Settings.getBalloonOffset()));
}
}
private void registerInventoryClickListener() { private void registerInventoryClickListener() {
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.WINDOW_CLICK) { ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Client.WINDOW_CLICK) {
@Override @Override

View File

@@ -3,9 +3,8 @@ package com.hibiscusmc.hmccosmetics.nms;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot; import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import net.kyori.adventure.text.Component; import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;

View File

@@ -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", "v1_19_R3", "v1_20_R1"}; private static final String[] SUPPORTED_VERSION = new String[]{"v1_18_R2", "v1_19_R1", "v1_19_R2", "v1_19_R3", "v1_20_R1"};
private static NMSHandler handler; private static NMSHandler handler;
private static String version; private static String version;

View File

@@ -3,28 +3,36 @@ package com.hibiscusmc.hmccosmetics.user;
import com.google.common.collect.ImmutableCollection; import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList; 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.events.*;
import com.hibiscusmc.hmccosmetics.config.Settings; import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.config.Wardrobe; import com.hibiscusmc.hmccosmetics.config.Wardrobe;
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings; import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot; import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.cosmetic.types.*; 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.hooks.Hooks;
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager; import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager; import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager; import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager; import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
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 com.hibiscusmc.hmccosmetics.util.PlayerUtils; import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager; import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
import org.bukkit.*; import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.*; import org.bukkit.inventory.meta.*;
import org.bukkit.persistence.PersistentDataType; import org.bukkit.persistence.PersistentDataType;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import org.jetbrains.annotations.Nullable;
import java.util.*; import java.util.*;
import java.util.logging.Level; import java.util.logging.Level;
@@ -55,6 +63,7 @@ public class CosmeticUser {
Runnable run = () -> { Runnable run = () -> {
MessagesUtil.sendDebugMessages("Tick[uuid=" + uniqueId + "]", Level.INFO); MessagesUtil.sendDebugMessages("Tick[uuid=" + uniqueId + "]", Level.INFO);
updateCosmetic(); updateCosmetic();
if (getHidden()) MessagesUtil.sendActionBar(getPlayer(), "hidden-cosmetics");
}; };
int tickPeriod = Settings.getTickPeriod(); int tickPeriod = Settings.getTickPeriod();
@@ -116,6 +125,9 @@ public class CosmeticUser {
CosmeticBalloonType balloonType = (CosmeticBalloonType) cosmetic; CosmeticBalloonType balloonType = (CosmeticBalloonType) cosmetic;
spawnBalloon(balloonType); spawnBalloon(balloonType);
} }
// API
PlayerCosmeticPostEquipEvent postEquipEvent = new PlayerCosmeticPostEquipEvent(this, cosmetic);
Bukkit.getPluginManager().callEvent(postEquipEvent);
} }
public void removeCosmetics() { public void removeCosmetics() {
@@ -141,7 +153,7 @@ public class CosmeticUser {
despawnBalloon(); despawnBalloon();
} }
if (slot == CosmeticSlot.EMOTE) { if (slot == CosmeticSlot.EMOTE) {
if (getUserEmoteManager().isPlayingEmote()) getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.UNEQUIP);
} }
colors.remove(slot); colors.remove(slot);
playerCosmetics.remove(slot); playerCosmetics.remove(slot);
@@ -206,6 +218,43 @@ public class CosmeticUser {
} }
if (item.hasItemMeta()) { if (item.hasItemMeta()) {
ItemMeta itemMeta = item.getItemMeta(); ItemMeta itemMeta = item.getItemMeta();
if (item.getType() == Material.PLAYER_HEAD) {
SkullMeta skullMeta = (SkullMeta) itemMeta;
if (skullMeta.getPersistentDataContainer().has(InventoryUtils.getSkullOwner(), PersistentDataType.STRING)) {
String owner = skullMeta.getPersistentDataContainer().get(InventoryUtils.getSkullOwner(), PersistentDataType.STRING);
owner = Hooks.processPlaceholders(getPlayer(), owner);
skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer(owner));
//skullMeta.getPersistentDataContainer().remove(InventoryUtils.getSkullOwner()); // Don't really need this?
}
if (skullMeta.getPersistentDataContainer().has(InventoryUtils.getSkullTexture(), PersistentDataType.STRING)) {
String texture = skullMeta.getPersistentDataContainer().get(InventoryUtils.getSkullTexture(), PersistentDataType.STRING);
texture = Hooks.processPlaceholders(getPlayer(), texture);
Bukkit.getUnsafe().modifyItemStack(item, "{SkullOwner:{Id:[I;0,0,0,0],Properties:{textures:[{Value:\""
+ texture + "\"}]}}}");
//skullMeta.getPersistentDataContainer().remove(InventoryUtils.getSkullTexture()); // Don't really need this?
}
itemMeta = skullMeta;
}
List<String> processedLore = new ArrayList<>();
if (itemMeta.hasLore()) {
for (String loreLine : itemMeta.getLore()) {
processedLore.add(Hooks.processPlaceholders(getPlayer(), loreLine));
}
}
if (itemMeta.hasDisplayName()) {
String displayName = itemMeta.getDisplayName();
itemMeta.setDisplayName(Hooks.processPlaceholders(getPlayer(), displayName));
}
itemMeta.setLore(processedLore);
if (colors.containsKey(cosmetic.getSlot())) { if (colors.containsKey(cosmetic.getSlot())) {
Color color = colors.get(cosmetic.getSlot()); Color color = colors.get(cosmetic.getSlot());
if (itemMeta instanceof LeatherArmorMeta leatherMeta) { if (itemMeta instanceof LeatherArmorMeta leatherMeta) {
@@ -217,7 +266,7 @@ public class CosmeticUser {
} }
} }
itemMeta.getPersistentDataContainer().set(InventoryUtils.getCosmeticKey(), PersistentDataType.STRING, cosmetic.getId()); itemMeta.getPersistentDataContainer().set(InventoryUtils.getCosmeticKey(), PersistentDataType.STRING, cosmetic.getId());
itemMeta.getPersistentDataContainer().set(InventoryUtils.getOwnerKey(), PersistentDataType.STRING, getPlayer().getUniqueId().toString()); itemMeta.getPersistentDataContainer().set(InventoryUtils.getOwnerKey(), PersistentDataType.STRING, getEntity().getUniqueId().toString());
item.setItemMeta(itemMeta); item.setItemMeta(itemMeta);
} }
@@ -316,19 +365,14 @@ public class CosmeticUser {
} }
public void spawnBalloon(CosmeticBalloonType cosmeticBalloonType) { public void spawnBalloon(CosmeticBalloonType cosmeticBalloonType) {
Player player = Bukkit.getPlayer(getUniqueId());
if (this.userBalloonManager != null) return; if (this.userBalloonManager != null) return;
this.userBalloonManager = NMSHandlers.getHandler().spawnBalloon(this, cosmeticBalloonType); this.userBalloonManager = NMSHandlers.getHandler().spawnBalloon(this, cosmeticBalloonType);
updateCosmetic(cosmeticBalloonType);
List<Player> viewer = PlayerUtils.getNearbyPlayers(player);
viewer.add(player);
} }
public void despawnBalloon() { public void despawnBalloon() {
if (this.userBalloonManager == null) return; if (this.userBalloonManager == null) return;
List<Player> sentTo = PlayerUtils.getNearbyPlayers(getPlayer().getLocation()); List<Player> sentTo = PlayerUtils.getNearbyPlayers(getEntity().getLocation());
PacketManager.sendEntityDestroyPacket(userBalloonManager.getPufferfishBalloonId(), sentTo); PacketManager.sendEntityDestroyPacket(userBalloonManager.getPufferfishBalloonId(), sentTo);
@@ -351,13 +395,27 @@ public class CosmeticUser {
} }
public void removeArmor(CosmeticSlot slot) { public void removeArmor(CosmeticSlot slot) {
PacketManager.equipmentSlotUpdate(getPlayer().getEntityId(), this, slot, PlayerUtils.getNearbyPlayers(getPlayer())); PacketManager.equipmentSlotUpdate(getEntity().getEntityId(), this, slot, PlayerUtils.getNearbyPlayers(getEntity().getLocation()));
} }
/**
* This returns the player associated with the user. Some users may not have a player attached, ie, they are npcs
* wearing cosmetics through an addon. If you need to get locations, use getEntity instead.
* @return Player
*/
@Nullable
public Player getPlayer() { public Player getPlayer() {
return Bukkit.getPlayer(uniqueId); return Bukkit.getPlayer(uniqueId);
} }
/**
* This gets the entity associated with the user.
* @return Entity
*/
public Entity getEntity() {
return Bukkit.getEntity(uniqueId);
}
public Color getCosmeticColor(CosmeticSlot slot) { public Color getCosmeticColor(CosmeticSlot slot) {
return colors.get(slot); return colors.get(slot);
} }
@@ -420,7 +478,7 @@ public class CosmeticUser {
} }
public void showCosmetics() { public void showCosmetics() {
if (hideCosmetics == false) return; if (!hideCosmetics) return;
PlayerCosmeticShowEvent event = new PlayerCosmeticShowEvent(this); PlayerCosmeticShowEvent event = new PlayerCosmeticShowEvent(this);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);

View File

@@ -39,6 +39,14 @@ public class UserBackpackManager {
return invisibleArmorStand; return invisibleArmorStand;
} }
public boolean IsValidBackpackEntity() {
if (invisibleArmorStand == null) {
MessagesUtil.sendDebugMessages("InvisibleArmorStand is Null!");
return false;
}
return getArmorStand().isValid();
}
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) { public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Start"); MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Start");

View File

@@ -6,7 +6,6 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers; import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager; import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
import com.ticxo.modelengine.api.ModelEngineAPI; import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ActiveModel; import com.ticxo.modelengine.api.model.ActiveModel;
@@ -27,13 +26,11 @@ public class UserBalloonManager {
private BalloonType balloonType; private BalloonType balloonType;
private CosmeticBalloonType cosmeticBalloonType; private CosmeticBalloonType cosmeticBalloonType;
private final int balloonID; private UserBalloonPufferfish pufferfish;
private final UUID uniqueID;
private final ArmorStand modelEntity; private final ArmorStand modelEntity;
public UserBalloonManager(@NotNull Location location) { public UserBalloonManager(@NotNull Location location) {
this.uniqueID = UUID.randomUUID(); this.pufferfish = new UserBalloonPufferfish(NMSHandlers.getHandler().getNextEntityId(), UUID.randomUUID());
this.balloonID = NMSHandlers.getHandler().getNextEntityId();
this.modelEntity = NMSHandlers.getHandler().getMEGEntity(location.add(Settings.getBalloonOffset())); this.modelEntity = NMSHandlers.getHandler().getMEGEntity(location.add(Settings.getBalloonOffset()));
} }
@@ -136,10 +133,10 @@ public class UserBalloonManager {
public int getPufferfishBalloonId() { public int getPufferfishBalloonId() {
return balloonID; return pufferfish.getId();
} }
public UUID getPufferfishBalloonUniqueId() { public UUID getPufferfishBalloonUniqueId() {
return uniqueID; return pufferfish.getUuid();
} }
public UUID getModelUnqiueId() { public UUID getModelUnqiueId() {
@@ -172,7 +169,13 @@ public class UserBalloonManager {
public void sendLeashPacket(int entityId) { public void sendLeashPacket(int entityId) {
if (cosmeticBalloonType == null) return; if (cosmeticBalloonType == null) return;
if (cosmeticBalloonType.isShowLead()) PacketManager.sendLeashPacket(getPufferfishBalloonId(), entityId, getLocation()); if (cosmeticBalloonType.isShowLead()) {
PacketManager.sendLeashPacket(getPufferfishBalloonId(), entityId, getLocation());
}
}
public UserBalloonPufferfish getPufferfish() {
return pufferfish;
} }
public enum BalloonType { public enum BalloonType {

View File

@@ -0,0 +1,62 @@
package com.hibiscusmc.hmccosmetics.user.manager;
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class UserBalloonPufferfish {
private int id;
private UUID uuid;
private List<Player> viewers = new ArrayList<>();
private Long lastUpdate;
public UserBalloonPufferfish(int id, UUID uuid) {
this.id = id;
this.uuid = uuid;
this.lastUpdate = 0L;
}
public int getId() {
return id;
}
public UUID getUuid() {
return uuid;
}
public List<Player> refreshViewers(Location location) {
if (System.currentTimeMillis() - lastUpdate <= 1000) return List.of(); //Prevents mass refreshes
ArrayList<Player> newPlayers = new ArrayList<>();
ArrayList<Player> removePlayers = new ArrayList<>();
List<Player> players = PlayerUtils.getNearbyPlayers(location);
for (Player player : players) {
if (!viewers.contains(player)) {
viewers.add(player);
newPlayers.add(player);
continue;
}
// bad loopdy loops
for (Player viewerPlayer : viewers) {
if (!players.contains(viewerPlayer)) {
removePlayers.add(viewerPlayer);
PacketManager.sendEntityDestroyPacket(id, List.of(viewerPlayer)); // prevents random leashes
}
}
}
viewers.removeAll(removePlayers);
lastUpdate = System.currentTimeMillis();
return newPlayers;
}
public void hidePufferfish() {
PacketManager.sendEntityDestroyPacket(id, viewers);
viewers.clear();
}
}

View File

@@ -1,7 +1,7 @@
package com.hibiscusmc.hmccosmetics.user.manager; package com.hibiscusmc.hmccosmetics.user.manager;
import com.hibiscusmc.hmccosmetics.api.PlayerEmoteStartEvent; import com.hibiscusmc.hmccosmetics.api.events.PlayerEmoteStartEvent;
import com.hibiscusmc.hmccosmetics.api.PlayerEmoteStopEvent; import com.hibiscusmc.hmccosmetics.api.events.PlayerEmoteStopEvent;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
import com.hibiscusmc.hmccosmetics.emotes.EmoteManager; import com.hibiscusmc.hmccosmetics.emotes.EmoteManager;
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers; import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
@@ -88,6 +88,7 @@ public class UserEmoteManager {
SNEAK, SNEAK,
DAMAGE, DAMAGE,
CONNECTION, CONNECTION,
TELEPORT TELEPORT,
UNEQUIP
} }
} }

View File

@@ -11,7 +11,6 @@ import com.ticxo.playeranimator.api.model.player.PlayerModel;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -44,9 +43,9 @@ public class UserEmoteModel extends PlayerModel {
Player player = user.getPlayer(); Player player = user.getPlayer();
List<Player> viewer = Collections.singletonList(user.getPlayer()); List<Player> viewer = Collections.singletonList(user.getPlayer());
List<Player> outsideViewers = PacketManager.getViewers(player.getLocation()); List<Player> outsideViewers = PacketManager.getViewers(player.getLocation());
outsideViewers.remove(player); // Send equipment packet to the player as well (Fixes Optifine still rendering armor when emoting)
PacketManager.equipmentSlotUpdate(player, true, outsideViewers); PacketManager.equipmentSlotUpdate(player, true, outsideViewers);
outsideViewers.remove(player);
Location newLocation = player.getLocation().clone(); Location newLocation = player.getLocation().clone();
newLocation.setPitch(0); newLocation.setPitch(0);
@@ -107,6 +106,8 @@ public class UserEmoteModel extends PlayerModel {
List<Player> viewer = Collections.singletonList(player); List<Player> viewer = Collections.singletonList(player);
List<Player> outsideViewers = PacketManager.getViewers(player.getLocation()); List<Player> outsideViewers = PacketManager.getViewers(player.getLocation());
// Send Equipment packet to all (Fixes Optifine Issue)
PacketManager.equipmentSlotUpdate(player, false, outsideViewers);
outsideViewers.remove(player); outsideViewers.remove(player);
int entityId = player.getEntityId(); int entityId = player.getEntityId();
@@ -118,7 +119,6 @@ public class UserEmoteModel extends PlayerModel {
} }
if (user.getPlayer() != null) player.setInvisible(false); if (user.getPlayer() != null) player.setInvisible(false);
PacketManager.equipmentSlotUpdate(player, false, outsideViewers);
user.getUserEmoteManager().despawnTextEntity(); user.getUserEmoteManager().despawnTextEntity();
user.showPlayer(); user.showPlayer();
user.showCosmetics(); user.showCosmetics();

View File

@@ -7,6 +7,8 @@ import com.hibiscusmc.hmccosmetics.config.WardrobeLocation;
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings; import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot; import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.gui.Menu;
import com.hibiscusmc.hmccosmetics.gui.Menus;
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers; import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
@@ -120,8 +122,9 @@ public class UserWardrobeManager {
user.getBalloonManager().sendLeashPacket(NPC_ID); user.getBalloonManager().sendLeashPacket(NPC_ID);
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer); //PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer);
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.clone().add(Settings.getBalloonOffset()), false, viewer); Location balloonLocation = npcLocation.clone().add(Settings.getBalloonOffset());
user.getBalloonManager().getModelEntity().teleport(npcLocation.clone().add(Settings.getBalloonOffset())); PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), balloonLocation , false, viewer);
user.getBalloonManager().getModelEntity().teleport(balloonLocation);
} }
if (WardrobeSettings.getEnabledBossbar()) { if (WardrobeSettings.getEnabledBossbar()) {
@@ -134,6 +137,11 @@ public class UserWardrobeManager {
target.showBossBar(bossBar); target.showBossBar(bossBar);
} }
if (WardrobeSettings.isEnterOpenMenu()) {
Menu menu = Menus.getDefaultMenu();
if (menu != null) menu.openMenu(user);
}
this.active = true; this.active = true;
update(); update();
setWardrobeStatus(WardrobeStatus.RUNNING); setWardrobeStatus(WardrobeStatus.RUNNING);
@@ -268,8 +276,9 @@ public class UserWardrobeManager {
} }
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) { if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.add(Settings.getBalloonOffset()), false, viewer); // The two lines below broke, solved by listening to PlayerCosmeticPostEquipEvent
user.getBalloonManager().getModelEntity().teleport(npcLocation.add(Settings.getBalloonOffset())); //PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.add(Settings.getBalloonOffset()), false, viewer);
//user.getBalloonManager().getModelEntity().teleport(npcLocation.add(Settings.getBalloonOffset()));
user.getBalloonManager().sendRemoveLeashPacket(outsideViewers); user.getBalloonManager().sendRemoveLeashPacket(outsideViewers);
PacketManager.sendEntityDestroyPacket(user.getBalloonManager().getModelId(), outsideViewers); PacketManager.sendEntityDestroyPacket(user.getBalloonManager().getModelId(), outsideViewers);
user.getBalloonManager().sendLeashPacket(NPC_ID); user.getBalloonManager().sendLeashPacket(NPC_ID);
@@ -302,4 +311,8 @@ public class UserWardrobeManager {
RUNNING, RUNNING,
STOPPING, STOPPING,
} }
public Location getNpcLocation() {
return npcLocation;
}
} }

View File

@@ -156,4 +156,12 @@ public class InventoryUtils {
public static NamespacedKey getOwnerKey() { public static NamespacedKey getOwnerKey() {
return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "owner"); return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "owner");
} }
public static NamespacedKey getSkullOwner() {
return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "skullowner");
}
public static NamespacedKey getSkullTexture() {
return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "skulltexture");
}
} }

View File

@@ -4,10 +4,8 @@ import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.config.Settings; import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings; import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
import com.hibiscusmc.hmccosmetics.hooks.Hooks; import com.hibiscusmc.hmccosmetics.hooks.Hooks;
import com.hibiscusmc.hmccosmetics.hooks.placeholders.HMCPlaceholderExpansion;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.misc.Adventure; import com.hibiscusmc.hmccosmetics.util.misc.Adventure;
import me.clip.placeholderapi.PlaceholderAPI;
import net.kyori.adventure.audience.Audience; import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
@@ -26,14 +24,16 @@ import java.util.logging.Level;
public class MessagesUtil { public class MessagesUtil {
private static String prefix; private static String prefix;
private static final HashMap<String, String> messages = new HashMap<>(); private static final HashMap<String, String> MESSAGES = new HashMap<>();
public static void setup(@NotNull ConfigurationNode config) { public static void setup(@NotNull ConfigurationNode config) {
MESSAGES.clear();
prefix = config.node("prefix").getString(""); prefix = config.node("prefix").getString("");
for (ConfigurationNode node : config.childrenMap().values()) { for (ConfigurationNode node : config.childrenMap().values()) {
if (node.virtual()) continue; if (node.virtual()) continue;
if (node.empty()) continue; if (node.empty()) continue;
messages.put(node.key().toString(), node.getString()); MESSAGES.put(node.key().toString(), node.getString());
} }
} }
@@ -43,6 +43,7 @@ public class MessagesUtil {
public static void sendMessage(Player player, String key) { public static void sendMessage(Player player, String key) {
Component finalMessage = processString(player, key); Component finalMessage = processString(player, key);
if (finalMessage == null) return;
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player); Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
target.sendMessage(finalMessage); target.sendMessage(finalMessage);
@@ -58,6 +59,7 @@ public class MessagesUtil {
public static void sendMessage(Player player, String key, TagResolver placeholder) { public static void sendMessage(Player player, String key, TagResolver placeholder) {
Component finalMessage = processString(player, key, placeholder); Component finalMessage = processString(player, key, placeholder);
if (finalMessage == null) return;
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player); Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
target.sendMessage(finalMessage); target.sendMessage(finalMessage);
@@ -65,6 +67,7 @@ public class MessagesUtil {
public static void sendMessageNoKey(Player player, String message) { public static void sendMessageNoKey(Player player, String message) {
Component finalMessage = processStringNoKey(player, message); Component finalMessage = processStringNoKey(player, message);
if (finalMessage == null) return;
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player); Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
target.sendMessage(finalMessage); target.sendMessage(finalMessage);
@@ -72,6 +75,7 @@ public class MessagesUtil {
public static void sendActionBar(Player player, String key) { public static void sendActionBar(Player player, String key) {
Component finalMessage = processString(player, key); Component finalMessage = processString(player, key);
if (finalMessage == null) return;
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player); Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
target.sendActionBar(finalMessage); target.sendActionBar(finalMessage);
@@ -96,10 +100,10 @@ public class MessagesUtil {
@Nullable @Nullable
public static Component processString(Player player, String key, TagResolver placeholders) { public static Component processString(Player player, String key, TagResolver placeholders) {
if (!messages.containsKey(key)) return null; if (!MESSAGES.containsKey(key)) return null;
if (messages.get(key) == null) return null; if (MESSAGES.get(key) == null) return null;
String message = messages.get(key); String message = MESSAGES.get(key);
if (Hooks.isActiveHook("PlaceholderAPI") && player != null) message = PlaceholderAPI.setPlaceholders(player, message); if (player != null) message = Hooks.processPlaceholders(player, message);
message = message.replaceAll("%prefix%", prefix); message = message.replaceAll("%prefix%", prefix);
if (placeholders != null ) { if (placeholders != null ) {
return Adventure.MINI_MESSAGE.deserialize(message, placeholders); return Adventure.MINI_MESSAGE.deserialize(message, placeholders);
@@ -120,7 +124,7 @@ public class MessagesUtil {
@NotNull @NotNull
public static Component processStringNoKey(Player player, String message, TagResolver placeholders) { public static Component processStringNoKey(Player player, String message, TagResolver placeholders) {
message = message.replaceAll("%prefix%", prefix); message = message.replaceAll("%prefix%", prefix);
if (Hooks.isActiveHook("PlaceholderAPI") && player != null) message = PlaceholderAPI.setPlaceholders(player, message); if (player != null) message = Hooks.processPlaceholders(player, message);
if (placeholders != null ) { if (placeholders != null ) {
return Adventure.MINI_MESSAGE.deserialize(message, placeholders); return Adventure.MINI_MESSAGE.deserialize(message, placeholders);
} }
@@ -129,7 +133,7 @@ public class MessagesUtil {
public static String processStringNoKeyString(Player player, String message) { public static String processStringNoKeyString(Player player, String message) {
message = message.replaceAll("%prefix%", prefix); message = message.replaceAll("%prefix%", prefix);
if (Hooks.isActiveHook("PlaceholderAPI") && player != null) message = PlaceholderAPI.setPlaceholders(player, message); if (player != null) message = Hooks.processPlaceholders(player, message);
return message; return message;
} }

View File

@@ -46,16 +46,6 @@ public class ServerUtils {
} }
return Color.WHITE; return Color.WHITE;
/* Old method
try {
return Color.fromRGB(
Integer.valueOf(colorStr.substring(1, 3), 16),
Integer.valueOf(colorStr.substring(3, 5), 16),
Integer.valueOf(colorStr.substring(5, 7), 16));
} catch (StringIndexOutOfBoundsException e) {
return null;
}
*/
} }
// particle amount offsetxyz // particle amount offsetxyz

View File

@@ -0,0 +1,20 @@
package com.hibiscusmc.hmccosmetics.util;
public class TranslationPair {
private String key;
private String value;
public TranslationPair(String key, String value) {
this.key = key;
this.value = value;
}
public String getKey() {
return key;
}
public String getValue() {
return value;
}
}

View File

@@ -2,38 +2,37 @@ package com.hibiscusmc.hmccosmetics.util;
import org.spongepowered.configurate.ConfigurationNode; import org.spongepowered.configurate.ConfigurationNode;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
public class TranslationUtil { public class TranslationUtil {
private static HashMap<String, String> keys = new HashMap<>(); // unlocked-cosmetic -> true -> True
private static HashMap<String, List<TranslationPair>> keys = new HashMap<>();
public static void setup(ConfigurationNode config) { public static void setup(ConfigurationNode config) {
// TODO: Finish this
/*
for (ConfigurationNode node : config.childrenMap().values()) { for (ConfigurationNode node : config.childrenMap().values()) {
HashMap<Pair> translableMessages = new HashMap<>(); ArrayList<TranslationPair> pairs = new ArrayList<>();
for (ConfigurationNode translatableMessage : node.childrenMap().values()) { for (ConfigurationNode translatableMessage : node.childrenMap().values()) {
translableMessages.put( new Pair<>(translatableMessage.key().toString(), translatableMessage.getString())) String key = translatableMessage.key().toString();
key.replaceAll("'", ""); // Autoupdater adds ' to it? Removes it from the key
TranslationPair pair = new TranslationPair(key, translatableMessage.getString());
pairs.add(pair);
MessagesUtil.sendDebugMessages("setupTranslation key:" + node.key().toString() + " | " + node); MessagesUtil.sendDebugMessages("setupTranslation key:" + node.key().toString() + " | " + node);
MessagesUtil.sendDebugMessages("Overall Key " + node.key().toString());
MessagesUtil.sendDebugMessages("Key '" + pair.getKey() + "' Value '" + pair.getValue() + "'");
} }
keys.put(node.key().toString().toLowerCase(), HashMap); keys.put(node.key().toString().toLowerCase(), pairs);
} }
*/
} }
public static String getTranslation(String key, String message) { public static String getTranslation(String key, String message) {
// TODO: Finish this List<TranslationPair> pairs = keys.get(key);
return message; for (TranslationPair pair : pairs) {
/* if (pair.getKey() == message) return pair.getValue();
key = key.toLowerCase();
MessagesUtil.sendDebugMessages("getTranslation key:" + key + " | " + message);
if (!keys.containsKey(key)) return message;
List<Pair> config = keys.get(key);
if (config.getFirst() == message) {
return config.getSecond().toString();
} }
return message; return message;
*/
} }
} }

View File

@@ -97,7 +97,7 @@ public class PacketManager extends BasePacket {
CosmeticSlot cosmeticSlot, CosmeticSlot cosmeticSlot,
List<Player> sendTo List<Player> sendTo
) { ) {
equipmentSlotUpdate(user.getPlayer().getEntityId(), user, cosmeticSlot, sendTo); equipmentSlotUpdate(user.getEntity().getEntityId(), user, cosmeticSlot, sendTo);
} }
public static void equipmentSlotUpdate( public static void equipmentSlotUpdate(
@@ -136,7 +136,7 @@ public class PacketManager extends BasePacket {
packet.getIntegers().write(0, entityId); packet.getIntegers().write(0, entityId);
WrappedDataWatcher wrapper = new WrappedDataWatcher(); WrappedDataWatcher wrapper = new WrappedDataWatcher();
if (NMSHandlers.getVersion().contains("v1_17_R1") || NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) { if (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 {
@@ -306,8 +306,8 @@ 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);
// For sor some reason 1.19.2 handles it on the 0 field index, every other verison handles it on the 1 // For sor some reason <1.19.2 handles it on the 0 field index, newer versions handles it on the 1
if (NMSHandlers.getVersion().contains("v1_19_R1")) { if (NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
info.getHandle().getPlayerInfoDataLists().write(0, Collections.singletonList(new PlayerInfoData( info.getHandle().getPlayerInfoDataLists().write(0, Collections.singletonList(new PlayerInfoData(
wrappedGameProfile, wrappedGameProfile,
0, 0,
@@ -369,7 +369,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_17_R1") || NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) { if (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);

View File

@@ -6,7 +6,7 @@ config-version: 1
default-menu: defaultmenu default-menu: defaultmenu
debug-mode: false debug-mode: false
database-settings: database-settings:
type: sqlite #MYSQL, SQLite, INTERNAL (not recommended!) type: sqlite #MYSQL, SQLite
mysql: mysql:
database: database database: database
password: cherryBomb password: cherryBomb
@@ -22,6 +22,7 @@ cosmetic-settings:
unapply-on-death: false # If when a player dies, their cosmetics should be unapplied. If this is true, use hmccosmetics.unapplydeath.bypass to bypass unapply-on-death: false # If when a player dies, their cosmetics should be unapplied. If this is true, use hmccosmetics.unapplydeath.bypass to bypass
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.
force-show-join: false # If the plugin should force show a player's cosmetics 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 where the camera is placed (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)
@@ -74,6 +75,9 @@ wardrobe:
# If players in wardrobes should be able to equip any cosmetic, regardless of permission (Cosmetics they do not have access to will be removed when they leave the wardrobe) # If players in wardrobes should be able to equip any cosmetic, regardless of permission (Cosmetics they do not have access to will be removed when they leave the wardrobe)
unchecked-wardrobe-cosmetics: false unchecked-wardrobe-cosmetics: false
menu-options:
enter-open-menu: false # If the menu should open when a player enters a wardrobe
gamemode-options: gamemode-options:
exit-gamemode-enabled: false # Setting this to false will set the gamemode the player came in as. True sets to exit-gamemode gamemode exit-gamemode-enabled: false # Setting this to false will set the gamemode the player came in as. True sets to exit-gamemode gamemode
exit-gamemode: "SURVIVAL" # Only activates if exit-gamemode-enabled is true, find gamemodes here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/GameMode.html exit-gamemode: "SURVIVAL" # Only activates if exit-gamemode-enabled is true, find gamemodes here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/GameMode.html

View File

@@ -1,3 +1,8 @@
#
# Messages.yml File
# If you don't wish for a message to be sent, simply make it blank.
#
prefix: "<gradient:#f368ec:#f39cef>HMCCosmetics <GRAY>»<WHITE>" prefix: "<gradient:#f368ec:#f39cef>HMCCosmetics <GRAY>»<WHITE>"
reloaded: "%prefix% <gradient:#6D9DC5:#45CDE9>Config files reloaded!" reloaded: "%prefix% <gradient:#6D9DC5:#45CDE9>Config files reloaded!"
not-enough-args: "%prefix% <red>Improper amount of arguments" not-enough-args: "%prefix% <red>Improper amount of arguments"
@@ -20,6 +25,7 @@ equip-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>You have equipped <cosmetic>
unequip-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>You have unequipped <cosmetic>!" unequip-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>You have unequipped <cosmetic>!"
hide-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>Hidden cosmetics" hide-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>Hidden cosmetics"
show-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>Revealed cosmetics!" show-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>Revealed cosmetics!"
hidden-cosmetics: "%prefix% <red>Your cosmetics are hidden!"
emote-blocked: "%prefix% <red>You can not use your emote here!" emote-blocked: "%prefix% <red>You can not use your emote here!"
emote-none: "%prefix% <red>You have no emote equipped!" emote-none: "%prefix% <red>You have no emote equipped!"

View File

@@ -1,3 +1,15 @@
unlockedCosmetic: unlocked-cosmetic:
true: "True" true: "true"
false: "false" false: "false"
equipped-cosmetic:
true: "true"
false: "false"
in-wardrobe:
true: "true"
false: "false"
using-cosmetic:
true: "true"
false: "false"
current-cosmetic:
true: "true"
false: "false"

View File

@@ -8,7 +8,6 @@ pluginManagement {
rootProject.name = "HMCCosmetics" rootProject.name = "HMCCosmetics"
include( include(
"common", "common",
"v1_17_R1",
"v1_18_R2", "v1_18_R2",
"v1_19_R1", "v1_19_R1",
"v1_19_R2", "v1_19_R2",

View File

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

View File

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

View File

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

View File

@@ -1,31 +0,0 @@
package com.hibiscusmc.hmccosmetics.nms.v1_17_R1;
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_17_R1.CraftWorld;
import org.bukkit.persistence.PersistentDataType;
public class MEGEntity extends ArmorStand {
public MEGEntity(Location loc) {
super(EntityType.ARMOR_STAND, ((CraftWorld) loc.getWorld()).getHandle());
this.setPos(loc.getX(), loc.getY(), loc.getZ());
MessagesUtil.sendDebugMessages("Spawned MEGEntity at " + loc);
setInvisible(true);
setNoGravity(true);
setSilent(true);
setInvulnerable(true);
setSmall(true);
setMarker(true);
persist = false;
getBukkitEntity().getPersistentDataContainer().set(new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmeticMob"), PersistentDataType.SHORT, Short.valueOf("1"));
((CraftWorld) loc.getWorld()).getHandle().addFreshEntity(this);
}
}

View File

@@ -1,253 +0,0 @@
package com.hibiscusmc.hmccosmetics.nms.v1_17_R1;
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.kyori.adventure.text.Component;
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_17_R1.CraftEquipmentSlot;
import org.bukkit.craftbukkit.v1_17_R1.CraftServer;
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_17_R1.scoreboard.CraftScoreboard;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
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);
MessagesUtil.sendDebugMessages("spawnBackpack NMS");
return invisibleArmorstand.getBukkitLivingEntity();
//PacketManager.armorStandMetaPacket(invisibleArmorstand.getBukkitEntity(), sentTo);
//PacketManager.ridingMountPacket(player.getEntityId(), invisibleArmorstand.getId(), sentTo);
}
@Override
public org.bukkit.entity.Entity spawnDisplayEntity(Location location, String text) {
return null;
}
@Override
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
Player player = user.getPlayer();
Location newLoc = player.getLocation().clone().add(Settings.getBalloonOffset());
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user.getPlayer().getLocation());
List<Player> sentTo = PlayerUtils.getNearbyPlayers(player.getLocation());
userBalloonManager1.getModelEntity().teleport(user.getPlayer().getLocation().add(Settings.getBalloonOffset()));
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
userBalloonManager1.sendLeashPacket(player.getEntityId());
return userBalloonManager1;
}
@Override
public void equipmentSlotUpdate(
int entityId,
CosmeticUser user,
CosmeticSlot cosmeticSlot,
List<Player> sendTo
) {
EquipmentSlot nmsSlot = null;
net.minecraft.world.item.ItemStack nmsItem = null;
if (!(user.getCosmetic(cosmeticSlot) instanceof CosmeticArmorType)) {
if (user.getCosmetic(cosmeticSlot) instanceof CosmeticMainhandType) {
CosmeticMainhandType cosmeticMainhandType = (CosmeticMainhandType) user.getCosmetic(CosmeticSlot.MAINHAND);
nmsItem = CraftItemStack.asNMSCopy(user.getUserCosmeticItem(cosmeticMainhandType));
} else {
nmsItem = CraftItemStack.asNMSCopy(user.getPlayer().getInventory().getItem(InventoryUtils.getEquipmentSlot(cosmeticSlot)));
}
nmsSlot = CraftEquipmentSlot.getNMS(InventoryUtils.getEquipmentSlot(cosmeticSlot));
if (nmsSlot == null) return;
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = Collections.singletonList(pair);
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
for (Player p : sendTo) sendPacket(p, packet);
return;
}
CosmeticArmorType cosmeticArmor = (CosmeticArmorType) user.getCosmetic(cosmeticSlot);
// Converting EquipmentSlot and ItemStack to NMS ones.
nmsSlot = CraftEquipmentSlot.getNMS(cosmeticArmor.getEquipSlot());
nmsItem = CraftItemStack.asNMSCopy(user.getUserCosmeticItem(cosmeticArmor));
if (nmsSlot == null) return;
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = Collections.singletonList(pair);
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
for (Player p : sendTo) sendPacket(p, packet);
}
@Override
public void equipmentSlotUpdate(
int entityId,
org.bukkit.inventory.EquipmentSlot slot,
ItemStack item,
List<Player> sendTo
) {
EquipmentSlot nmsSlot = null;
net.minecraft.world.item.ItemStack nmsItem = null;
// Converting EquipmentSlot and ItemStack to NMS ones.
nmsSlot = CraftEquipmentSlot.getNMS(slot);
nmsItem = CraftItemStack.asNMSCopy(item);
if (nmsSlot == null) return;
Pair<EquipmentSlot, net.minecraft.world.item.ItemStack> pair = new Pair<>(nmsSlot, nmsItem);
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> pairs = Collections.singletonList(pair);
ClientboundSetEquipmentPacket packet = new ClientboundSetEquipmentPacket(entityId, pairs);
for (Player p : sendTo) sendPacket(p, packet);
}
@Override
public void slotUpdate(
Player player,
int slot
) {
int index = 0;
ServerPlayer player1 = ((CraftPlayer) player).getHandle();
if (index < Inventory.getSelectionSize()) {
index += 36;
} else if (index > 39) {
index += 5; // Off hand
} else if (index > 35) {
index = 8 - (index - 36);
}
ItemStack item = player.getInventory().getItem(slot);
Packet packet = new ClientboundContainerSetSlotPacket(player1.inventoryMenu.containerId, player1.inventoryMenu.incrementStateId(), index, CraftItemStack.asNMSCopy(item));
sendPacket(player, packet);
}
public void hideNPCName(Player player, String NPCName) {
//Creating the team
PlayerTeam team = new PlayerTeam(((CraftScoreboard) Bukkit.getScoreboardManager().getMainScoreboard()).getHandle(), NPCName);
//Setting name visibility
team.setNameTagVisibility(Team.Visibility.NEVER);
//Remove the Team (i assume so if it exists)
ClientboundSetPlayerTeamPacket removeTeamPacket = ClientboundSetPlayerTeamPacket.createRemovePacket(team);
sendPacket(player, removeTeamPacket);
//Creating the Team
ClientboundSetPlayerTeamPacket createTeamPacket = ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(team, true);
sendPacket(player, createTeamPacket);
//Adding players to the team (You have to use the NPC's name, and add it to a list)
ClientboundSetPlayerTeamPacket createPlayerTeamPacket = ClientboundSetPlayerTeamPacket.createPlayerPacket(team, 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;
}
}

View File

@@ -6,14 +6,11 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
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 com.hibiscusmc.hmccosmetics.util.PlayerUtils;
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
import com.mojang.datafixers.util.Pair; import com.mojang.datafixers.util.Pair;
import net.kyori.adventure.text.Component;
import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
@@ -21,7 +18,6 @@ import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerPlayerConnection; import net.minecraft.server.network.ServerPlayerConnection;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.scores.PlayerTeam; import net.minecraft.world.scores.PlayerTeam;
@@ -35,7 +31,6 @@ import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_18_R2.scoreboard.CraftScoreboard; import org.bukkit.craftbukkit.v1_18_R2.scoreboard.CraftScoreboard;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@@ -47,7 +42,7 @@ import java.util.List;
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler { public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
@Override @Override
public int getNextEntityId() { public int getNextEntityId() {
return Entity.nextEntityId(); return net.minecraft.world.entity.Entity.nextEntityId();
} }
@Override @Override
@@ -85,19 +80,16 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
@Override @Override
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) { public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getPlayer().getLocation()); HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getEntity().getLocation());
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType); ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item)); invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
((CraftWorld) user.getPlayer().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM); ((CraftWorld) user.getEntity().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
MessagesUtil.sendDebugMessages("spawnBackpack NMS"); MessagesUtil.sendDebugMessages("spawnBackpack NMS");
return invisibleArmorstand.getBukkitLivingEntity(); return invisibleArmorstand.getBukkitLivingEntity();
//PacketManager.armorStandMetaPacket(invisibleArmorstand.getBukkitEntity(), sentTo);
//PacketManager.ridingMountPacket(player.getEntityId(), invisibleArmorstand.getId(), sentTo);
} }
@Override @Override
@@ -106,24 +98,16 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
} }
@Override @Override
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) { public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
Player player = user.getPlayer(); org.bukkit.entity.Entity entity = user.getEntity();
Location newLoc = player.getLocation().clone().add(Settings.getBalloonOffset());
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user.getPlayer().getLocation()); UserBalloonManager userBalloonManager1 = new UserBalloonManager(entity.getLocation());
List<Player> sentTo = PlayerUtils.getNearbyPlayers(player.getLocation()); userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(Settings.getBalloonOffset()));
userBalloonManager1.getModelEntity().teleport(user.getPlayer().getLocation().add(Settings.getBalloonOffset()));
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot())); userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot())); userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
userBalloonManager1.sendLeashPacket(player.getEntityId());
return userBalloonManager1; return userBalloonManager1;
} }

View File

@@ -6,14 +6,11 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
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 com.hibiscusmc.hmccosmetics.util.PlayerUtils;
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
import com.mojang.datafixers.util.Pair; import com.mojang.datafixers.util.Pair;
import net.kyori.adventure.text.Component;
import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
@@ -21,7 +18,6 @@ import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerPlayerConnection; import net.minecraft.server.network.ServerPlayerConnection;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.scores.PlayerTeam; import net.minecraft.world.scores.PlayerTeam;
@@ -35,7 +31,6 @@ import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_19_R1.scoreboard.CraftScoreboard; import org.bukkit.craftbukkit.v1_19_R1.scoreboard.CraftScoreboard;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@@ -47,7 +42,7 @@ import java.util.List;
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler { public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
@Override @Override
public int getNextEntityId() { public int getNextEntityId() {
return Entity.nextEntityId(); return net.minecraft.world.entity.Entity.nextEntityId();
} }
@Override @Override
@@ -85,19 +80,16 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
@Override @Override
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) { public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
HMCArmorStand HMCArmorStand = new HMCArmorStand(user.getPlayer().getLocation()); HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getEntity().getLocation());
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType); ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
HMCArmorStand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item)); invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
((CraftWorld) user.getPlayer().getWorld()).getHandle().addFreshEntity(HMCArmorStand, CreatureSpawnEvent.SpawnReason.CUSTOM); ((CraftWorld) user.getEntity().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
MessagesUtil.sendDebugMessages("spawnBackpack NMS"); MessagesUtil.sendDebugMessages("spawnBackpack NMS");
return HMCArmorStand.getBukkitLivingEntity(); return invisibleArmorstand.getBukkitLivingEntity();
//PacketManager.armorStandMetaPacket(invisibleArmorstand.getBukkitEntity(), sentTo);
//PacketManager.ridingMountPacket(player.getEntityId(), invisibleArmorstand.getId(), sentTo);
} }
@Override @Override
@@ -110,20 +102,14 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
@Override @Override
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) { public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
Player player = user.getPlayer(); org.bukkit.entity.Entity entity = user.getEntity();
Location newLoc = player.getLocation().clone().add(Settings.getBalloonOffset());
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user.getPlayer().getLocation()); UserBalloonManager userBalloonManager1 = new UserBalloonManager(entity.getLocation());
List<Player> sentTo = PlayerUtils.getNearbyPlayers(player.getLocation()); userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(Settings.getBalloonOffset()));
userBalloonManager1.getModelEntity().teleport(user.getPlayer().getLocation().add(Settings.getBalloonOffset()));
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot())); userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot())); userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
userBalloonManager1.sendLeashPacket(player.getEntityId());
return userBalloonManager1; return userBalloonManager1;
} }

View File

@@ -6,14 +6,11 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
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 com.hibiscusmc.hmccosmetics.util.PlayerUtils;
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
import com.mojang.datafixers.util.Pair; import com.mojang.datafixers.util.Pair;
import net.kyori.adventure.text.Component;
import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
@@ -21,7 +18,6 @@ import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerPlayerConnection; import net.minecraft.server.network.ServerPlayerConnection;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.scores.PlayerTeam; import net.minecraft.world.scores.PlayerTeam;
@@ -35,7 +31,6 @@ import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_19_R2.scoreboard.CraftScoreboard; import org.bukkit.craftbukkit.v1_19_R2.scoreboard.CraftScoreboard;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@@ -47,7 +42,7 @@ import java.util.List;
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler { public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
@Override @Override
public int getNextEntityId() { public int getNextEntityId() {
return Entity.nextEntityId(); return net.minecraft.world.entity.Entity.nextEntityId();
} }
@Override @Override
@@ -85,19 +80,16 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
@Override @Override
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) { public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getPlayer().getLocation()); HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getEntity().getLocation());
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType); ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item)); invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
((CraftWorld) user.getPlayer().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM); ((CraftWorld) user.getEntity().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
MessagesUtil.sendDebugMessages("spawnBackpack NMS"); MessagesUtil.sendDebugMessages("spawnBackpack NMS");
return invisibleArmorstand.getBukkitLivingEntity(); return invisibleArmorstand.getBukkitLivingEntity();
//PacketManager.armorStandMetaPacket(invisibleArmorstand.getBukkitEntity(), sentTo);
//PacketManager.ridingMountPacket(player.getEntityId(), invisibleArmorstand.getId(), sentTo);
} }
@Override @Override
@@ -109,20 +101,14 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
@Override @Override
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) { public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
Player player = user.getPlayer(); org.bukkit.entity.Entity entity = user.getEntity();
Location newLoc = player.getLocation().clone().add(Settings.getBalloonOffset());
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user.getPlayer().getLocation()); UserBalloonManager userBalloonManager1 = new UserBalloonManager(entity.getLocation());
List<Player> sentTo = PlayerUtils.getNearbyPlayers(player.getLocation()); userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(Settings.getBalloonOffset()));
userBalloonManager1.getModelEntity().teleport(user.getPlayer().getLocation().add(Settings.getBalloonOffset()));
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot())); userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot())); userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
userBalloonManager1.sendLeashPacket(player.getEntityId());
return userBalloonManager1; return userBalloonManager1;
} }

View File

@@ -6,12 +6,10 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
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 com.hibiscusmc.hmccosmetics.util.PlayerUtils;
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
import com.mojang.datafixers.util.Pair; import com.mojang.datafixers.util.Pair;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.Packet;
@@ -22,7 +20,6 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerPlayerConnection; import net.minecraft.server.network.ServerPlayerConnection;
import net.minecraft.world.entity.Display; import net.minecraft.world.entity.Display;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.scores.PlayerTeam; import net.minecraft.world.scores.PlayerTeam;
@@ -36,7 +33,7 @@ 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.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_19_R3.scoreboard.CraftScoreboard; import org.bukkit.craftbukkit.v1_19_R3.scoreboard.CraftScoreboard;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@@ -48,7 +45,7 @@ import java.util.List;
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler { public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
@Override @Override
public int getNextEntityId() { public int getNextEntityId() {
return Entity.nextEntityId(); return net.minecraft.world.entity.Entity.nextEntityId();
} }
@Override @Override
@@ -86,18 +83,16 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
@Override @Override
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) { public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getPlayer().getLocation()); HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getEntity().getLocation());
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType); ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item)); invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
((CraftWorld) user.getPlayer().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM); ((CraftWorld) user.getEntity().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
MessagesUtil.sendDebugMessages("spawnBackpack NMS"); MessagesUtil.sendDebugMessages("spawnBackpack NMS");
return invisibleArmorstand.getBukkitLivingEntity(); return invisibleArmorstand.getBukkitLivingEntity();
//PacketManager.armorStandMetaPacket(invisibleArmorstand.getBukkitEntity(), sentTo);
//PacketManager.ridingMountPacket(player.getEntityId(), invisibleArmorstand.getId(), sentTo);
} }
@Override @Override
@@ -115,20 +110,14 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
@Override @Override
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) { public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
Player player = user.getPlayer(); Entity entity = user.getEntity();
Location newLoc = player.getLocation().clone().add(Settings.getBalloonOffset());
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user.getPlayer().getLocation()); UserBalloonManager userBalloonManager1 = new UserBalloonManager(entity.getLocation());
List<Player> sentTo = PlayerUtils.getNearbyPlayers(player.getLocation()); userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(Settings.getBalloonOffset()));
userBalloonManager1.getModelEntity().teleport(user.getPlayer().getLocation().add(Settings.getBalloonOffset()));
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot())); userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot())); userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
userBalloonManager1.sendLeashPacket(player.getEntityId());
return userBalloonManager1; return userBalloonManager1;
} }

View File

@@ -6,12 +6,10 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBackpackType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType; import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.manager.UserBalloonManager;
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 com.hibiscusmc.hmccosmetics.util.PlayerUtils;
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
import com.mojang.datafixers.util.Pair; import com.mojang.datafixers.util.Pair;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.Packet;
@@ -22,7 +20,6 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerPlayerConnection; import net.minecraft.server.network.ServerPlayerConnection;
import net.minecraft.world.entity.Display; import net.minecraft.world.entity.Display;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.scores.PlayerTeam; import net.minecraft.world.scores.PlayerTeam;
@@ -36,7 +33,6 @@ import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_20_R1.scoreboard.CraftScoreboard; import org.bukkit.craftbukkit.v1_20_R1.scoreboard.CraftScoreboard;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@@ -48,7 +44,7 @@ import java.util.List;
public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler { public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
@Override @Override
public int getNextEntityId() { public int getNextEntityId() {
return Entity.nextEntityId(); return net.minecraft.world.entity.Entity.nextEntityId();
} }
@Override @Override
@@ -86,12 +82,12 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
@Override @Override
public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) { public org.bukkit.entity.Entity spawnBackpack(CosmeticUser user, CosmeticBackpackType cosmeticBackpackType) {
HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getPlayer().getLocation()); HMCArmorStand invisibleArmorstand = new HMCArmorStand(user.getEntity().getLocation());
ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType); ItemStack item = user.getUserCosmeticItem(cosmeticBackpackType);
invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item)); invisibleArmorstand.setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(item));
((CraftWorld) user.getPlayer().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM); ((CraftWorld) user.getEntity().getWorld()).getHandle().addFreshEntity(invisibleArmorstand, CreatureSpawnEvent.SpawnReason.CUSTOM);
MessagesUtil.sendDebugMessages("spawnBackpack NMS"); MessagesUtil.sendDebugMessages("spawnBackpack NMS");
@@ -115,20 +111,14 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
@Override @Override
public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) { public UserBalloonManager spawnBalloon(CosmeticUser user, CosmeticBalloonType cosmeticBalloonType) {
Player player = user.getPlayer(); org.bukkit.entity.Entity entity = user.getEntity();
Location newLoc = player.getLocation().clone().add(Settings.getBalloonOffset());
UserBalloonManager userBalloonManager1 = new UserBalloonManager(user.getPlayer().getLocation()); UserBalloonManager userBalloonManager1 = new UserBalloonManager(entity.getLocation());
List<Player> sentTo = PlayerUtils.getNearbyPlayers(player.getLocation()); userBalloonManager1.getModelEntity().teleport(entity.getLocation().add(Settings.getBalloonOffset()));
userBalloonManager1.getModelEntity().teleport(user.getPlayer().getLocation().add(Settings.getBalloonOffset()));
userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot())); userBalloonManager1.spawnModel(cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot())); userBalloonManager1.addPlayerToModel(user, cosmeticBalloonType, user.getCosmeticColor(cosmeticBalloonType.getSlot()));
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
userBalloonManager1.sendLeashPacket(player.getEntityId());
return userBalloonManager1; return userBalloonManager1;
} }