mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-19 15:09:19 +00:00
clean: refactor overlapping Hibiscus Commons util class names
This commit is contained in:
@@ -19,7 +19,7 @@ import com.hibiscusmc.hmccosmetics.gui.special.DyeMenu;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
@@ -114,11 +114,11 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
HMCColorConfig.Colors colors = HMCColorContextKt.getHmcColor().getConfig().getColors().get(textColor);
|
||||
if (colors != null) {
|
||||
String hmccolor = colors.getBaseColor().getColor();
|
||||
if (hmccolor.contains("#")) color = ServerUtils.hex2Rgb(hmccolor);
|
||||
else color = ServerUtils.rgbToRgb(hmccolor);
|
||||
if (hmccolor.contains("#")) color = HMCCServerUtils.hex2Rgb(hmccolor);
|
||||
else color = HMCCServerUtils.rgbToRgb(hmccolor);
|
||||
}
|
||||
} else {
|
||||
color = ServerUtils.hex2Rgb(textColor);
|
||||
color = HMCCServerUtils.hex2Rgb(textColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -312,7 +312,7 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
if (!silent) MessagesUtil.sendMessage(player, "invalid-color");
|
||||
return true;
|
||||
}
|
||||
Color color = ServerUtils.hex2Rgb(args[2]);
|
||||
Color color = HMCCServerUtils.hex2Rgb(args[2]);
|
||||
if (color == null) {
|
||||
if (!silent) MessagesUtil.sendMessage(player, "invalid-color");
|
||||
return true;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import me.lojosho.shaded.configurate.ConfigurationNode;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -18,6 +18,6 @@ public class CosmeticMainhandType extends Cosmetic {
|
||||
public void update(@NotNull CosmeticUser user) {
|
||||
Player player = user.getPlayer();
|
||||
|
||||
HMCCPacketManager.equipmentSlotUpdate(player.getEntityId(), user, getSlot(), PlayerUtils.getNearbyPlayers(player));
|
||||
HMCCPacketManager.equipmentSlotUpdate(player.getEntityId(), user, getSlot(), HMCCPlayerUtils.getNearbyPlayers(player));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import com.owen1212055.particlehelper.api.particle.types.BlockDataParticle;
|
||||
import com.owen1212055.particlehelper.api.particle.types.DestinationParticle;
|
||||
@@ -42,7 +42,7 @@ public class ActionParticle extends Action {
|
||||
return;
|
||||
}
|
||||
|
||||
particle = ServerUtils.addParticleValues(particle, rawString);
|
||||
particle = HMCCServerUtils.addParticleValues(particle, rawString);
|
||||
Location location = user.getPlayer().getLocation();
|
||||
for (Player player : HMCCPacketManager.getViewers(location)) {
|
||||
particle.compile().send(player, location);
|
||||
|
||||
@@ -19,7 +19,7 @@ import com.hibiscusmc.hmccosmetics.user.manager.UserEmoteManager;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserWardrobeManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import lombok.Getter;
|
||||
import me.lojosho.hibiscuscommons.hooks.Hooks;
|
||||
@@ -204,7 +204,7 @@ public class CosmeticUser {
|
||||
updateCosmetic(cosmetic.getSlot());
|
||||
}
|
||||
if (items.isEmpty()) return;
|
||||
PacketManager.equipmentSlotUpdate(getEntity().getEntityId(), items, PlayerUtils.getNearbyPlayers(getEntity().getLocation()));
|
||||
PacketManager.equipmentSlotUpdate(getEntity().getEntityId(), items, HMCCPlayerUtils.getNearbyPlayers(getEntity().getLocation()));
|
||||
MessagesUtil.sendDebugMessages("updateCosmetic (All) - end - " + items.size());
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ public class CosmeticUser {
|
||||
|
||||
public void despawnBalloon() {
|
||||
if (this.userBalloonManager == null) return;
|
||||
List<Player> sentTo = PlayerUtils.getNearbyPlayers(getEntity().getLocation());
|
||||
List<Player> sentTo = HMCCPlayerUtils.getNearbyPlayers(getEntity().getLocation());
|
||||
|
||||
HMCCPacketManager.sendEntityDestroyPacket(userBalloonManager.getPufferfishBalloonId(), sentTo);
|
||||
|
||||
@@ -427,9 +427,9 @@ public class CosmeticUser {
|
||||
EquipmentSlot equipmentSlot = HMCCInventoryUtils.getEquipmentSlot(slot);
|
||||
if (equipmentSlot == null) return;
|
||||
if (getPlayer() != null) {
|
||||
PacketManager.equipmentSlotUpdate(getEntity().getEntityId(), equipmentSlot, getPlayer().getInventory().getItem(equipmentSlot), PlayerUtils.getNearbyPlayers(getEntity().getLocation()));
|
||||
PacketManager.equipmentSlotUpdate(getEntity().getEntityId(), equipmentSlot, getPlayer().getInventory().getItem(equipmentSlot), HMCCPlayerUtils.getNearbyPlayers(getEntity().getLocation()));
|
||||
} else {
|
||||
HMCCPacketManager.equipmentSlotUpdate(getEntity().getEntityId(), this, slot, PlayerUtils.getNearbyPlayers(getEntity().getLocation()));
|
||||
HMCCPacketManager.equipmentSlotUpdate(getEntity().getEntityId(), this, slot, HMCCPlayerUtils.getNearbyPlayers(getEntity().getLocation()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -530,7 +530,7 @@ public class CosmeticUser {
|
||||
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||
CosmeticBalloonType balloonType = (CosmeticBalloonType) getCosmetic(CosmeticSlot.BALLOON);
|
||||
getBalloonManager().addPlayerToModel(this, balloonType);
|
||||
List<Player> viewer = PlayerUtils.getNearbyPlayers(getEntity().getLocation());
|
||||
List<Player> viewer = HMCCPlayerUtils.getNearbyPlayers(getEntity().getLocation());
|
||||
HMCCPacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), getPlayer().getEntityId(), viewer);
|
||||
}
|
||||
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK) && isBackpackSpawned()) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.hibiscusmc.hmccosmetics.user;
|
||||
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -38,7 +38,7 @@ public class CosmeticUsers {
|
||||
|
||||
@Nullable
|
||||
public static CosmeticUser getUser(int entityId) {
|
||||
Entity entity = ServerUtils.getEntity(entityId);
|
||||
Entity entity = HMCCServerUtils.getEntity(entityId);
|
||||
if (entity == null) return null;
|
||||
if (!(entity instanceof Player player)) return null;
|
||||
return COSMETIC_USERS.get(player.getUniqueId());
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.hibiscusmc.hmccosmetics.user.manager;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -46,7 +46,7 @@ public class UserBalloonPufferfish extends UserEntity {
|
||||
if (System.currentTimeMillis() - getViewerLastUpdate() <= 1000) return List.of(); //Prevents mass refreshes
|
||||
ArrayList<Player> newPlayers = new ArrayList<>();
|
||||
ArrayList<Player> removePlayers = new ArrayList<>();
|
||||
List<Player> players = PlayerUtils.getNearbyPlayers(location);
|
||||
List<Player> players = HMCCPlayerUtils.getNearbyPlayers(location);
|
||||
|
||||
for (Player player : players) {
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.hibiscusmc.hmccosmetics.user.manager;
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import com.ticxo.playeranimator.api.model.player.PlayerModel;
|
||||
@@ -116,7 +117,7 @@ public class UserEmoteModel extends PlayerModel {
|
||||
HMCCPacketManager.sendCameraPacket(entityId, viewer);
|
||||
HMCCPacketManager.sendEntityDestroyPacket(armorStandId, viewer);
|
||||
if (this.originalGamemode != null) {
|
||||
HMCCPacketManager.gamemodeChangePacket(player, com.hibiscusmc.hmccosmetics.util.ServerUtils.convertGamemode(this.originalGamemode));
|
||||
HMCCPacketManager.gamemodeChangePacket(player, HMCCServerUtils.convertGamemode(this.originalGamemode));
|
||||
player.setGameMode(this.originalGamemode);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.hibiscusmc.hmccosmetics.user.manager;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -41,7 +41,7 @@ public class UserEntity {
|
||||
if (System.currentTimeMillis() - viewerLastUpdate <= 1000) return List.of(); //Prevents mass refreshes
|
||||
ArrayList<Player> newPlayers = new ArrayList<>();
|
||||
ArrayList<Player> removePlayers = new ArrayList<>();
|
||||
List<Player> players = PlayerUtils.getNearbyPlayers(location);
|
||||
List<Player> players = HMCCPlayerUtils.getNearbyPlayers(location);
|
||||
|
||||
for (Player player : players) {
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.ServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCServerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.HMCCPacketManager;
|
||||
import lombok.Getter;
|
||||
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||
@@ -227,11 +227,11 @@ public class UserWardrobeManager {
|
||||
if (WardrobeSettings.isForceExitGamemode()) {
|
||||
MessagesUtil.sendDebugMessages("Force Exit Gamemode " + WardrobeSettings.getExitGamemode());
|
||||
player.setGameMode(WardrobeSettings.getExitGamemode());
|
||||
HMCCPacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(WardrobeSettings.getExitGamemode())); // Success
|
||||
HMCCPacketManager.gamemodeChangePacket(player, HMCCServerUtils.convertGamemode(WardrobeSettings.getExitGamemode())); // Success
|
||||
} else {
|
||||
MessagesUtil.sendDebugMessages("Original Gamemode " + this.originalGamemode);
|
||||
player.setGameMode(this.originalGamemode);
|
||||
HMCCPacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(this.originalGamemode)); // Success
|
||||
HMCCPacketManager.gamemodeChangePacket(player, HMCCServerUtils.convertGamemode(this.originalGamemode)); // Success
|
||||
}
|
||||
user.showPlayer();
|
||||
|
||||
@@ -286,9 +286,9 @@ public class UserWardrobeManager {
|
||||
HMCCPacketManager.sendLookPacket(NPC_ID, location, viewer);
|
||||
user.hidePlayer();
|
||||
int rotationSpeed = WardrobeSettings.getRotationSpeed();
|
||||
location.setYaw(ServerUtils.getNextYaw(yaw - 30, rotationSpeed));
|
||||
location.setYaw(HMCCServerUtils.getNextYaw(yaw - 30, rotationSpeed));
|
||||
HMCCPacketManager.sendRotationPacket(NPC_ID, location, true, viewer);
|
||||
int nextyaw = ServerUtils.getNextYaw(yaw, rotationSpeed);
|
||||
int nextyaw = HMCCServerUtils.getNextYaw(yaw, rotationSpeed);
|
||||
data.set(nextyaw);
|
||||
|
||||
for (CosmeticSlot slot : CosmeticSlot.values()) {
|
||||
|
||||
@@ -11,7 +11,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerUtils {
|
||||
public class HMCCPlayerUtils {
|
||||
|
||||
@Nullable
|
||||
public static WrappedSignedProperty getSkin(Player player) {
|
||||
@@ -14,7 +14,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ServerUtils {
|
||||
public class HMCCServerUtils {
|
||||
|
||||
private static String COLOR_CHAR = "&";
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.HMCCPlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerNamedEntitySpawn;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerPlayerInfo;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.wrappers.WrapperPlayServerRelEntityMove;
|
||||
@@ -301,7 +301,7 @@ public class HMCCPacketManager extends PacketManager {
|
||||
}
|
||||
|
||||
WrappedGameProfile wrappedGameProfile = new WrappedGameProfile(uuid, name);
|
||||
WrappedSignedProperty skinData = PlayerUtils.getSkin(skinnedPlayer);
|
||||
WrappedSignedProperty skinData = HMCCPlayerUtils.getSkin(skinnedPlayer);
|
||||
if (skinData != null) wrappedGameProfile.getProperties().put("textures", skinData);
|
||||
// For sor some reason <1.19.2 handles it on the 0 field index, newer versions handles it on the 1
|
||||
if (HMCCosmeticsAPI.getNMSVersion().contains("v1_18_R2") || HMCCosmeticsAPI.getNMSVersion().contains("v1_19_R1")) {
|
||||
@@ -435,7 +435,7 @@ public class HMCCPacketManager extends PacketManager {
|
||||
if (Settings.getViewDistance() <= 0) {
|
||||
viewers.addAll(location.getWorld().getPlayers());
|
||||
} else {
|
||||
viewers.addAll(PlayerUtils.getNearbyPlayers(location));
|
||||
viewers.addAll(HMCCPlayerUtils.getNearbyPlayers(location));
|
||||
}
|
||||
return viewers;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user