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

Moved lots of messages to debug mode

This commit is contained in:
LoJoSho
2022-12-27 13:32:48 -06:00
parent 0e40633e0d
commit 0aef8c9c3d
22 changed files with 151 additions and 73 deletions

View File

@@ -148,6 +148,10 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
user.updateCosmetic();
}
*/
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
getInstance().getLogger().info(Cosmetics.values().size() + " Cosmetics Successfully Setup");
getInstance().getLogger().info(Menus.getMenuNames().size() + " Menus Successfully Setup");
}
public static boolean isDisable() {

View File

@@ -24,6 +24,7 @@ public class Settings {
private static final String PARTICLE_COUNT = "particle-count";
private static final String DYE_MENU_PATH = "dye-menu";
private static final String DYE_MENU_NAME = "title";
private static final String DEBUG_ENABLE_PETH = "debug-mode";
private static String defaultMenu;
private static String dyeMenuName;
@@ -33,12 +34,14 @@ public class Settings {
private static boolean requireEmptyChestPlate;
private static boolean requireEmptyPants;
private static boolean requireEmptyBoots;
private static boolean debugMode;
private static int lookDownPitch;
private static int viewDistance;
private static Vector balloonOffset;
public static void load(ConfigurationNode source) {
debugMode = source.node(DEBUG_ENABLE_PETH).getBoolean(false);
defaultMenu = source.node(DEFAULT_MENU).getString();
configVersion = source.node(CONFIG_VERSION).getInt(0);
if (configVersion == 0) {
@@ -141,4 +144,8 @@ public class Settings {
public static String getDyeMenuName() {
return dyeMenuName;
}
public static boolean isDebugEnabled() {
return debugMode;
}
}

View File

@@ -2,6 +2,7 @@ package com.hibiscusmc.hmccosmetics.config;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.config.serializer.LocationSerializer;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
import org.bukkit.Location;
import org.spongepowered.configurate.ConfigurationNode;
@@ -57,9 +58,9 @@ public class WardrobeSettings {
returnLastLocation = source.node(RETURN_LAST_LOCATION).getBoolean();
try {
wardrobeLocation = LocationSerializer.INSTANCE.deserialize(Location.class, source.node(STATIC_LOCATION_PATH));
HMCCosmeticsPlugin.getInstance().getLogger().info("Wardrobe Location: " + wardrobeLocation);
MessagesUtil.sendDebugMessages("Wardrobe Location: " + wardrobeLocation);
viewerLocation = LocationSerializer.INSTANCE.deserialize(Location.class, source.node(VIEWER_LOCATION_PATH));
HMCCosmeticsPlugin.getInstance().getLogger().info("Viewer Location: " + viewerLocation);
MessagesUtil.sendDebugMessages("Viewer Location: " + viewerLocation);
leaveLocation = Utils.replaceIfNull(LocationSerializer.INSTANCE.deserialize(Location.class, source.node(LEAVE_LOCATION_PATH)), viewerLocation);
} catch (SerializationException e) {
throw new RuntimeException(e);

View File

@@ -1,7 +1,7 @@
package com.hibiscusmc.hmccosmetics.cosmetic;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.spongepowered.configurate.ConfigurationNode;
public class Cosmetic {
@@ -15,13 +15,13 @@ public class Cosmetic {
protected Cosmetic(String id, ConfigurationNode config) {
this.id = id;
//this.permission = config.node("permission").getString(null);
HMCCosmeticsPlugin.getInstance().getLogger().info("Slot: " + config.node("slot").getString());
MessagesUtil.sendDebugMessages("Slot: " + config.node("slot").getString());
setSlot(CosmeticSlot.valueOf(config.node("slot").getString()));
setEquipable(false);
setDyable(config.node("dyeable").getBoolean(false));
HMCCosmeticsPlugin.getInstance().getLogger().info("Dyeable " + dyable);
MessagesUtil.sendDebugMessages("Dyeable " + dyable);
Cosmetics.addCosmetic(this);
}

View File

@@ -6,6 +6,7 @@ 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.util.MessagesUtil;
import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.ConfigurateException;
import org.spongepowered.configurate.ConfigurationNode;
@@ -61,7 +62,7 @@ public class Cosmetics {
for (File child : directoryListing) {
if (child.toString().contains(".yml") || child.toString().contains(".yaml")) {
HMCCosmeticsPlugin.getInstance().getLogger().info("Scanning " + child);
MessagesUtil.sendDebugMessages("Scanning " + child);
// Loads file
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child.toPath()).build();
CommentedConfigurationNode root;
@@ -78,7 +79,7 @@ public class Cosmetics {
private static void setupCosmetics(CommentedConfigurationNode config) {
for (ConfigurationNode cosmeticConfig : config.childrenMap().values()) {
String id = cosmeticConfig.key().toString();
HMCCosmeticsPlugin.getInstance().getLogger().info("Attempting to add " + id);
MessagesUtil.sendDebugMessages("Attempting to add " + id);
switch (CosmeticSlot.valueOf(cosmeticConfig.node("slot").getString())) {
case BALLOON -> {
new CosmeticBalloonType(id, cosmeticConfig);

View File

@@ -5,6 +5,7 @@ import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
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 org.bukkit.Bukkit;
@@ -15,6 +16,8 @@ import org.bukkit.inventory.ItemStack;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
import java.util.logging.Level;
public class CosmeticArmorType extends Cosmetic {
private ItemStack itemStack;
@@ -47,12 +50,12 @@ public class CosmeticArmorType extends Cosmetic {
try {
ItemStack item = ItemSerializer.INSTANCE.deserialize(ItemStack.class, config);
if (item == null) {
HMCCosmeticsPlugin.getInstance().getLogger().severe("Unable to create item for " + getId());
MessagesUtil.sendDebugMessages("Unable to create item for " + getId(), Level.SEVERE);
return new ItemStack(Material.AIR);
}
return item;
} catch (SerializationException e) {
HMCCosmeticsPlugin.getInstance().getLogger().severe("Fatal error encountered for " + getId() + " regarding Serialization of item");
MessagesUtil.sendDebugMessages("Fatal error encountered for " + getId() + " regarding Serialization of item", Level.SEVERE);
throw new RuntimeException(e);
}
}

View File

@@ -4,6 +4,7 @@ import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -12,6 +13,8 @@ import org.bukkit.inventory.ItemStack;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
import java.util.logging.Level;
public class CosmeticBackpackType extends Cosmetic {
private ItemStack backpackItem;
@@ -56,7 +59,7 @@ public class CosmeticBackpackType extends Cosmetic {
public ItemStack getBackpackItem() {
if (this.backpackItem == null ) {
HMCCosmeticsPlugin.getInstance().getLogger().info("Backpack item was null for " + getId());
MessagesUtil.sendDebugMessages("Backpack item was null for " + getId());
this.backpackItem = generateItemStack(config.node("item"));
}
return this.backpackItem.clone();
@@ -66,12 +69,12 @@ public class CosmeticBackpackType extends Cosmetic {
try {
ItemStack item = ItemSerializer.INSTANCE.deserialize(ItemStack.class, config);
if (item == null) {
HMCCosmeticsPlugin.getInstance().getLogger().severe("Unable to create item for " + getId());
MessagesUtil.sendDebugMessages("Unable to create item for " + getId(), Level.SEVERE);
return new ItemStack(Material.AIR);
}
return item;
} catch (SerializationException e) {
HMCCosmeticsPlugin.getInstance().getLogger().severe("Fatal error encountered for " + getId() + " regarding Serialization of item");
MessagesUtil.sendDebugMessages("Fatal error encountered for " + getId() + " regarding Serialization of item", Level.SEVERE);
throw new RuntimeException(e);
}
}

View File

@@ -4,6 +4,7 @@ import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
import org.bukkit.Material;
@@ -12,6 +13,8 @@ import org.bukkit.inventory.ItemStack;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
import java.util.logging.Level;
public class CosmeticMainhandType extends Cosmetic {
private ItemStack itemStack;
@@ -36,12 +39,12 @@ public class CosmeticMainhandType extends Cosmetic {
try {
ItemStack item = ItemSerializer.INSTANCE.deserialize(ItemStack.class, config);
if (item == null) {
HMCCosmeticsPlugin.getInstance().getLogger().severe("Unable to create item for " + getId());
MessagesUtil.sendDebugMessages("Unable to create item for " + getId(), Level.SEVERE);
return new ItemStack(Material.AIR);
}
return item;
} catch (SerializationException e) {
HMCCosmeticsPlugin.getInstance().getLogger().severe("Fatal error encountered for " + getId() + " regarding Serialization of item");
MessagesUtil.sendDebugMessages("Fatal error encountered for " + getId() + " regarding Serialization of item", Level.SEVERE);
throw new RuntimeException(e);
}
}

View File

@@ -4,6 +4,7 @@ import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.nms.NMSHandler;
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
@@ -16,6 +17,7 @@ import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import java.util.UUID;
import java.util.logging.Level;
// This includes the Pufferfish (The Pufferfish that's what the player leashes to) and the model (MEGEntity)
public class BalloonEntity {
@@ -31,9 +33,9 @@ public class BalloonEntity {
}
public void spawnModel(final String id, Color color) {
HMCCosmeticsPlugin.getInstance().getLogger().info("Attempting Spawning for " + id);
MessagesUtil.sendDebugMessages("Attempting Spawning for " + id);
if (ModelEngineAPI.api.getModelRegistry().getBlueprint(id) == null) {
HMCCosmeticsPlugin.getInstance().getLogger().warning("Invalid Model Engine Blueprint " + id);
MessagesUtil.sendDebugMessages("Invalid Model Engine Blueprint " + id, Level.SEVERE);
return;
}
ModeledEntity modeledEntity = ModelEngineAPI.getOrCreateModeledEntity(modelEntity);
@@ -68,12 +70,12 @@ public class BalloonEntity {
final ModeledEntity model = ModelEngineAPI.api.getModeledEntity(modelEntity.getUniqueId());
if (model == null) {
spawnModel(id, color);
HMCCosmeticsPlugin.getInstance().getLogger().info("model is null");
MessagesUtil.sendDebugMessages("model is null");
return;
}
//if (model.getRangeManager().getPlayerInRange().contains(player)) return;
model.showToPlayer(player);
HMCCosmeticsPlugin.getInstance().getLogger().info("Show to player");
MessagesUtil.sendDebugMessages("Show to player");
}
public void removePlayerFromModel(final Player player) {
final ModeledEntity model = ModelEngineAPI.api.getModeledEntity(modelEntity.getUniqueId());
@@ -81,7 +83,7 @@ public class BalloonEntity {
if (model == null) return;
model.hideFromPlayer(player);
HMCCosmeticsPlugin.getInstance().getLogger().info("Hidden from player");
MessagesUtil.sendDebugMessages("Hidden from player");
}
public Entity getModelEntity() {

View File

@@ -4,6 +4,7 @@ import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.config.serializer.ItemSerializer;
import com.hibiscusmc.hmccosmetics.gui.type.Types;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.misc.Adventure;
import com.hibiscusmc.hmccosmetics.util.misc.Placeholder;
import dev.triumphteam.gui.builder.item.ItemBuilder;
@@ -83,7 +84,7 @@ public class Menu {
continue;
}
if (slotString == null) {
HMCCosmeticsPlugin.getInstance().getLogger().info("Unable to get valid slot for " + config.key().toString());
MessagesUtil.sendDebugMessages("Unable to get valid slot for " + config.key().toString());
continue;
}
@@ -91,7 +92,7 @@ public class Menu {
if (slots == null) {
HMCCosmeticsPlugin.getInstance().getLogger().info("Slot is null for " + config.key().toString());
MessagesUtil.sendDebugMessages("Slot is null for " + config.key().toString());
continue;
}
@@ -105,7 +106,7 @@ public class Menu {
}
if (item == null) {
HMCCosmeticsPlugin.getInstance().getLogger().info("something went wrong! " + item);
MessagesUtil.sendDebugMessages("something went wrong! " + item);
continue;
}
@@ -132,7 +133,7 @@ public class Menu {
gui.updateItem(i, guiItem);
}
});
HMCCosmeticsPlugin.getInstance().getLogger().info("Added " + slots + " as " + guiItem + " in the menu");
MessagesUtil.sendDebugMessages("Added " + slots + " as " + guiItem + " in the menu");
gui.setItem(slots, guiItem);
}
return gui;

View File

@@ -1,6 +1,7 @@
package com.hibiscusmc.hmccosmetics.gui;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.apache.commons.io.FilenameUtils;
import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.ConfigurateException;
@@ -57,7 +58,7 @@ public class Menus {
for (File child : directoryListing) {
if (child.toString().contains(".yml") || child.toString().contains(".yaml")) {
HMCCosmeticsPlugin.getInstance().getLogger().info("Scanning " + child);
MessagesUtil.sendDebugMessages("Scanning " + child);
// Loads file
YamlConfigurationLoader loader = YamlConfigurationLoader.builder().path(child.toPath()).build();
CommentedConfigurationNode root;

View File

@@ -1,12 +1,15 @@
package com.hibiscusmc.hmccosmetics.hooks.worldguard;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.sk89q.worldguard.protection.flags.registry.FlagConflictException;
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
import java.util.logging.Level;
public class WGHook {
public static StateFlag COSMETIC_ENABLE_FLAG;
@@ -22,7 +25,7 @@ public class WGHook {
if (existing instanceof StateFlag) {
COSMETIC_ENABLE_FLAG = (StateFlag) existing;
} else {
HMCCosmeticsPlugin.getInstance().getLogger().severe("WorldGuard Unable to be hooked!");
MessagesUtil.sendDebugMessages("WorldGuard Unable to be hooked!", Level.SEVERE);
// types don't match - this is bad news! some other plugin conflicts with you
// hopefully this never actually happens
}

View File

@@ -5,6 +5,7 @@ import com.hibiscusmc.hmccosmetics.config.DatabaseSettings;
import com.hibiscusmc.hmccosmetics.database.Database;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
@@ -21,12 +22,12 @@ public class PlayerConnectionListener implements Listener {
Runnable run = () -> {
CosmeticUser user = Database.get(event.getPlayer().getUniqueId());
CosmeticUsers.addUser(user);
HMCCosmeticsPlugin.getInstance().getLogger().info("Run User Join");
MessagesUtil.sendDebugMessages("Run User Join");
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> user.updateCosmetic(), 4);
};
if (DatabaseSettings.isEnabledDelay()) {
HMCCosmeticsPlugin.getInstance().getLogger().info("Delay Enabled with " + DatabaseSettings.getDelayLength() + " ticks");
MessagesUtil.sendDebugMessages("Delay Enabled with " + DatabaseSettings.getDelayLength() + " ticks");
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), run, DatabaseSettings.getDelayLength());
} else {
run.run();

View File

@@ -20,6 +20,7 @@ import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@@ -67,7 +68,7 @@ public class PlayerGameListener implements Listener {
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
user.updateCosmetic(cosmeticSlot);
}, 1);
HMCCosmeticsPlugin.getInstance().getLogger().info("Event fired, updated cosmetic " + cosmeticSlot);
MessagesUtil.sendDebugMessages("Event fired, updated cosmetic " + cosmeticSlot);
}
@EventHandler
@@ -85,9 +86,9 @@ public class PlayerGameListener implements Listener {
public void onPlayerTeleport(PlayerTeleportEvent event) {
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
HMCCosmeticsPlugin.getInstance().getLogger().info("Player Teleport Event");
MessagesUtil.sendDebugMessages("Player Teleport Event");
if (user == null) {
HMCCosmeticsPlugin.getInstance().getLogger().info("user is null");
MessagesUtil.sendDebugMessages("user is null");
return;
}
@@ -135,7 +136,7 @@ public class PlayerGameListener implements Listener {
// Possibly look into cancelling the event, then handling the damage on our own.
if (event.isCancelled()) return;
HMCCosmeticsPlugin.getInstance().getLogger().info("PlayerItemDamageEvent");
MessagesUtil.sendDebugMessages("PlayerItemDamageEvent");
int slot = -1;
int w = 36;
@@ -154,12 +155,12 @@ public class PlayerGameListener implements Listener {
CosmeticSlot cosmeticSlot = InventoryUtils.BukkitCosmeticSlot(slot);
if (!user.hasCosmeticInSlot(cosmeticSlot)) {
HMCCosmeticsPlugin.getInstance().getLogger().info("No cosmetic in " + cosmeticSlot);
MessagesUtil.sendDebugMessages("No cosmetic in " + cosmeticSlot);
return;
}
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
HMCCosmeticsPlugin.getInstance().getLogger().info("PlayerItemDamageEvent UpdateCosmetic " + cosmeticSlot);
MessagesUtil.sendDebugMessages("PlayerItemDamageEvent UpdateCosmetic " + cosmeticSlot);
user.updateCosmetic(cosmeticSlot);
}, 2);
}
@@ -198,7 +199,7 @@ public class PlayerGameListener implements Listener {
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
user.updateCosmetic(cosmeticSlot);
}, 1);
HMCCosmeticsPlugin.getInstance().getLogger().info("Packet fired, updated cosmetic " + cosmeticSlot);
MessagesUtil.sendDebugMessages("Packet fired, updated cosmetic " + cosmeticSlot);
}
});
}
@@ -207,7 +208,7 @@ public class PlayerGameListener implements Listener {
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(HMCCosmeticsPlugin.getInstance(), ListenerPriority.NORMAL, PacketType.Play.Server.WINDOW_ITEMS) {
@Override
public void onPacketSending(PacketEvent event) {
HMCCosmeticsPlugin.getInstance().getLogger().info("Menu Initial ");
MessagesUtil.sendDebugMessages("Menu Initial ");
Player player = event.getPlayer();
if (event.getPlayer() == null) return;
if (!(event.getPlayer() instanceof Player)) return;
@@ -224,7 +225,7 @@ public class PlayerGameListener implements Listener {
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
user.updateCosmetic(cosmetic);
}, 1);
HMCCosmeticsPlugin.getInstance().getLogger().info("Menu Fired, updated cosmetics " + cosmetic + " on slotdata " + windowID);
MessagesUtil.sendDebugMessages("Menu Fired, updated cosmetics " + cosmetic + " on slotdata " + windowID);
}
}
}
@@ -255,7 +256,7 @@ public class PlayerGameListener implements Listener {
}
event.getPacket().getSlotStackPairLists().write(0, armor);
HMCCosmeticsPlugin.getInstance().getLogger().info("Equipment for " + user.getPlayer().getName() + " has been updated for " + player.getName());
MessagesUtil.sendDebugMessages("Equipment for " + user.getPlayer().getName() + " has been updated for " + player.getName());
}
});
}

View File

@@ -11,6 +11,7 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticMainhandType;
import com.hibiscusmc.hmccosmetics.entities.BalloonEntity;
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
import org.bukkit.Bukkit;
@@ -81,11 +82,11 @@ public class CosmeticUser {
}
playerCosmetics.put(cosmetic.getSlot(), cosmetic);
if (color != null) colors.put(cosmetic.getSlot(), color);
HMCCosmeticsPlugin.getInstance().getLogger().info("addPlayerCosmetic " + cosmetic.getId());
MessagesUtil.sendDebugMessages("addPlayerCosmetic " + cosmetic.getId());
if (cosmetic.getSlot() == CosmeticSlot.BACKPACK) {
CosmeticBackpackType backpackType = (CosmeticBackpackType) cosmetic;
spawnBackpack(backpackType);
HMCCosmeticsPlugin.getInstance().getLogger().info("addPlayerCosmetic spawnBackpack " + cosmetic.getId());
MessagesUtil.sendDebugMessages("addPlayerCosmetic spawnBackpack " + cosmetic.getId());
}
if (cosmetic.getSlot() == CosmeticSlot.BALLOON) {
CosmeticBalloonType balloonType = (CosmeticBalloonType) cosmetic;
@@ -147,7 +148,7 @@ public class CosmeticUser {
if (cosmetic instanceof CosmeticArmorType) {
CosmeticArmorType cosmetic1 = (CosmeticArmorType) cosmetic;
item = cosmetic1.getCosmeticItem();
HMCCosmeticsPlugin.getInstance().getLogger().info("GetUserCosemticUser Armor");
MessagesUtil.sendDebugMessages("GetUserCosemticUser Armor");
}
if (cosmetic instanceof CosmeticMainhandType) {
CosmeticMainhandType cosmetic1 = (CosmeticMainhandType) cosmetic;
@@ -156,13 +157,13 @@ public class CosmeticUser {
if (cosmetic instanceof CosmeticBackpackType) {
CosmeticBackpackType cosmetic1 = (CosmeticBackpackType) cosmetic;
item = cosmetic1.getBackpackItem();
HMCCosmeticsPlugin.getInstance().getLogger().info("GetUserCosemticUser Backpack");
MessagesUtil.sendDebugMessages("GetUserCosemticUser Backpack");
}
if (cosmetic instanceof CosmeticBalloonType) {
item = new ItemStack(Material.LEATHER_HORSE_ARMOR);
}
if (item == null) {
HMCCosmeticsPlugin.getInstance().getLogger().info("GetUserCosemticUser Item is null");
MessagesUtil.sendDebugMessages("GetUserCosemticUser Item is null");
return null;
}
if (item.hasItemMeta()) {
@@ -209,7 +210,7 @@ public class CosmeticUser {
}
public void spawnBackpack(CosmeticBackpackType cosmeticBackpackType) {
HMCCosmeticsPlugin.getInstance().getLogger().info("spawnBackpack Bukkit - Start");
MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Start");
Player player = Bukkit.getPlayer(getUniqueId());
List<Player> sentTo = PlayerUtils.getNearbyPlayers(player.getLocation());
@@ -219,8 +220,7 @@ public class CosmeticUser {
player.addPassenger(invisibleArmorstand);
HMCCosmeticsPlugin.getInstance().getLogger().info("spawnBackpack Bukkit - Finish");
MessagesUtil.sendDebugMessages("spawnBackpack Bukkit - Finish");
}
public void spawnBalloon(CosmeticBalloonType cosmeticBalloonType) {
@@ -335,7 +335,7 @@ public class CosmeticUser {
invisibleArmorstand.getEquipment().clear();
}
updateCosmetic();
HMCCosmeticsPlugin.getInstance().getLogger().info("HideCosmetics");
MessagesUtil.sendDebugMessages("HideCosmetics");
}
public void showCosmetics() {
@@ -353,6 +353,6 @@ public class CosmeticUser {
invisibleArmorstand.getEquipment().setHelmet(item);
}
updateCosmetic();
HMCCosmeticsPlugin.getInstance().getLogger().info("ShowCosmetics");
MessagesUtil.sendDebugMessages("ShowCosmetics");
}
}

View File

@@ -5,6 +5,7 @@ import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
import org.bukkit.Bukkit;
@@ -39,9 +40,9 @@ public class Wardrobe {
public void start() {
Player player = VIEWER.getPlayer();
player.sendMessage("start");
player.sendMessage("NPC ID " + NPC_ID);
player.sendMessage("armorstand id " + ARMORSTAND_ID);
MessagesUtil.sendDebugMessages("start");
MessagesUtil.sendDebugMessages("NPC ID " + NPC_ID);
MessagesUtil.sendDebugMessages("armorstand id " + ARMORSTAND_ID);
this.originalGamemode = player.getGameMode();
if (WardrobeSettings.isReturnLastLocation()) {
@@ -67,7 +68,7 @@ public class Wardrobe {
// NPC 2
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
PacketManager.sendFakePlayerSpawnPacket(WardrobeSettings.getWardrobeLocation(), WARDROBE_UUID, NPC_ID, viewer);
HMCCosmeticsPlugin.getInstance().getLogger().info("Spawned Fake Player on " + WardrobeSettings.getWardrobeLocation());
MessagesUtil.sendDebugMessages("Spawned Fake Player on " + WardrobeSettings.getWardrobeLocation());
}, 4);
@@ -99,9 +100,9 @@ public class Wardrobe {
this.active = false;
Player player = VIEWER.getPlayer();
player.sendMessage("end");
player.sendMessage("NPC ID " + NPC_ID);
player.sendMessage("armorstand id " + ARMORSTAND_ID);
MessagesUtil.sendDebugMessages("end");
MessagesUtil.sendDebugMessages("NPC ID " + NPC_ID);
MessagesUtil.sendDebugMessages("armorstand id " + ARMORSTAND_ID);
List<Player> viewer = List.of(player);
@@ -145,11 +146,11 @@ public class Wardrobe {
@Override
public void run() {
if (active == false) {
HMCCosmeticsPlugin.getInstance().getLogger().info("Active is false");
MessagesUtil.sendDebugMessages("Active is false");
this.cancel();
return;
}
HMCCosmeticsPlugin.getInstance().getLogger().info("Update ");
MessagesUtil.sendDebugMessages("Update ");
List<Player> viewer = List.of(VIEWER.getPlayer());
Location location = WardrobeSettings.getWardrobeLocation().clone();

View File

@@ -0,0 +1,48 @@
package com.hibiscusmc.hmccosmetics.util;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.util.misc.Adventure;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player;
import org.spongepowered.configurate.ConfigurationNode;
import java.util.HashMap;
import java.util.logging.Level;
public class MessagesUtil {
private static String prefix;
private static HashMap<String, String> messages = new HashMap<>();
public static void setup(ConfigurationNode config) {
prefix = config.node("prefix").getString("");
for (ConfigurationNode node : config.childrenMap().values()) {
if (node.virtual()) continue;
if (node.empty()) continue;
messages.put(node.key().toString(), node.getString());
}
}
public static void sendMessage(Player player, String key) {
if (!messages.containsKey(key)) return;
if (messages.get(key).isEmpty()) return;
String message = messages.get(key);
message.replaceAll("%prefix%", prefix);
Component finalMessage = Adventure.MINI_MESSAGE.deserialize(message);
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).player(player);
target.sendMessage(finalMessage);
}
public static void sendDebugMessages(String message) {
sendDebugMessages(message, Level.INFO);
}
public static void sendDebugMessages(String message, Level level) {
if (!Settings.isDebugEnabled() && level != Level.SEVERE) return;
HMCCosmeticsPlugin.getInstance().getLogger().log(level, message);
}
}

View File

@@ -8,6 +8,7 @@ import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerNamedEntitySpawn;
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerPlayerInfo;
@@ -51,7 +52,7 @@ public class PacketManager extends BasePacket {
// Tells what event this is. This is a change gamemode event.
packet.getFloat().write(0, (float) gamemode);
sendPacket(player, packet);
HMCCosmeticsPlugin.getInstance().getLogger().info("Gamemode Change sent to " + player + " to be " + gamemode);
MessagesUtil.sendDebugMessages("Gamemode Change sent to " + player + " to be " + gamemode);
}
public static void ridingMountPacket(
@@ -112,13 +113,13 @@ public class PacketManager extends BasePacket {
int entityId,
List<Player> sendTo
) {
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
packet.getModifier().writeDefaults();
packet.getIntegers().write(0, entityId);
WrappedDataWatcher wrapper = new WrappedDataWatcher();
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20);
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
for (Player p : sendTo) sendPacket(p, packet);
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
packet.getModifier().writeDefaults();
packet.getIntegers().write(0, entityId);
WrappedDataWatcher wrapper = new WrappedDataWatcher();
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20);
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
for (Player p : sendTo) sendPacket(p, packet);
}
public static void sendLookPacket(