9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-20 23:49:18 +00:00

Compare commits

..

9 Commits

Author SHA1 Message Date
LoJoSho
1804e4691b version bump (2.0.3) 2023-01-19 17:10:06 -06:00
LoJoSho
223f8bdb9c invalid menus now do not disable plugin on startup 2023-01-19 15:03:01 -06:00
LoJoSho
c757752038 invalid cosmetics now do not disable plugin on startup 2023-01-19 14:59:03 -06:00
LoJoSho
243644301a debug message now ignore only info and message null check 2023-01-19 14:58:19 -06:00
LoJoSho
652b20c148 move dependencies to all projects 2023-01-19 14:39:04 -06:00
LoJoSho
6c3ffbb71e fix ItemAdder hook being error after invalid item 2023-01-16 20:18:13 -06:00
LoJoSho
fb6e5abb8b Backpack don't produce sounds 2023-01-16 19:53:29 -06:00
LoJoSho
f546500f1e Wardrobe internal improvements 2023-01-16 19:51:32 -06:00
LoJoSho
044528188d Fix for external entities showing in wardrobe to others 2023-01-16 18:49:50 -06:00
10 changed files with 116 additions and 47 deletions

View File

@@ -9,7 +9,7 @@ plugins {
} }
group = "com.hibiscusmc" group = "com.hibiscusmc"
version = "2.0.2" version = "2.0.3"
allprojects { allprojects {
apply(plugin = "java") apply(plugin = "java")
@@ -58,15 +58,6 @@ allprojects {
dependencies { dependencies {
}
}
dependencies {
implementation(project(path = ":common"))
implementation(project(path = ":v1_19_R1", configuration = "reobf"))
implementation(project(path = ":v1_19_R2", configuration = "reobf"))
//implementation(files("v1_19_R1/build/libs/1_19_R1-unspecified.jar"))
compileOnly("com.mojang:authlib:1.5.25") compileOnly("com.mojang:authlib:1.5.25")
compileOnly("org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT") compileOnly("org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT")
compileOnly("org.jetbrains:annotations:23.0.0") compileOnly("org.jetbrains:annotations:23.0.0")
@@ -78,6 +69,14 @@ dependencies {
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT") compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
compileOnly("it.unimi.dsi:fastutil:8.5.11") compileOnly("it.unimi.dsi:fastutil:8.5.11")
}
}
dependencies {
implementation(project(path = ":common"))
implementation(project(path = ":v1_19_R1", configuration = "reobf"))
implementation(project(path = ":v1_19_R2", configuration = "reobf"))
//compileOnly("com.github.Fisher2911:FisherLib:master-SNAPSHOT") //compileOnly("com.github.Fisher2911:FisherLib:master-SNAPSHOT")
implementation("net.kyori:adventure-api:4.11.0") implementation("net.kyori:adventure-api:4.11.0")
implementation ("net.kyori:adventure-text-minimessage:4.11.0") implementation ("net.kyori:adventure-text-minimessage:4.11.0")

View File

@@ -2,11 +2,13 @@ package com.hibiscusmc.hmccosmetics.cosmetic;
import com.google.common.collect.HashBiMap; import com.google.common.collect.HashBiMap;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin; import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType; 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.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.apache.commons.lang3.EnumUtils;
import org.spongepowered.configurate.CommentedConfigurationNode; import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.ConfigurateException; import org.spongepowered.configurate.ConfigurateException;
import org.spongepowered.configurate.ConfigurationNode; import org.spongepowered.configurate.ConfigurationNode;
@@ -14,6 +16,7 @@ import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
import java.io.File; import java.io.File;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
public class Cosmetics { public class Cosmetics {
@@ -78,23 +81,27 @@ public class Cosmetics {
private static void setupCosmetics(CommentedConfigurationNode config) { private static void setupCosmetics(CommentedConfigurationNode config) {
for (ConfigurationNode cosmeticConfig : config.childrenMap().values()) { for (ConfigurationNode cosmeticConfig : config.childrenMap().values()) {
try {
String id = cosmeticConfig.key().toString(); String id = cosmeticConfig.key().toString();
MessagesUtil.sendDebugMessages("Attempting to add " + id); MessagesUtil.sendDebugMessages("Attempting to add " + id);
ConfigurationNode slotNode = cosmeticConfig.node("slot");
if (slotNode.virtual()) {
MessagesUtil.sendDebugMessages("Unable to create " + id + " because there is no slot defined!", Level.WARNING);
continue;
}
if (!EnumUtils.isValidEnum(CosmeticSlot.class, slotNode.getString())) {
MessagesUtil.sendDebugMessages("Unable to create " + id + " because " + slotNode.getString() + " is not a valid slot!", Level.WARNING);
continue;
}
switch (CosmeticSlot.valueOf(cosmeticConfig.node("slot").getString())) { switch (CosmeticSlot.valueOf(cosmeticConfig.node("slot").getString())) {
case BALLOON -> { case BALLOON -> new CosmeticBalloonType(id, cosmeticConfig);
new CosmeticBalloonType(id, cosmeticConfig); case BACKPACK -> new CosmeticBackpackType(id, cosmeticConfig);
case MAINHAND -> new CosmeticMainhandType(id, cosmeticConfig);
default -> new CosmeticArmorType(id, cosmeticConfig);
} }
case BACKPACK -> { } catch (Exception e) {
new CosmeticBackpackType(id, cosmeticConfig); if (Settings.isDebugEnabled()) e.printStackTrace();
} }
case MAINHAND -> {
new CosmeticMainhandType(id, cosmeticConfig);
}
default -> {
new CosmeticArmorType(id, cosmeticConfig);
}
}
//new Cosmetic(id, cosmeticConfig);
} }
} }
} }

View File

@@ -23,6 +23,8 @@ public class CosmeticBackpackType extends Cosmetic {
Player player = Bukkit.getPlayer(user.getUniqueId()); Player player = Bukkit.getPlayer(user.getUniqueId());
Location loc = player.getLocation().clone(); Location loc = player.getLocation().clone();
if (user.isInWardrobe()) return;
if (loc.getWorld() != user.getBackpackEntity().getWorld()) { if (loc.getWorld() != user.getBackpackEntity().getWorld()) {
user.getBackpackEntity().teleport(loc); user.getBackpackEntity().teleport(loc);
} }

View File

@@ -1,6 +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.config.Settings;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.spongepowered.configurate.CommentedConfigurationNode; import org.spongepowered.configurate.CommentedConfigurationNode;
@@ -12,6 +13,7 @@ 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;
public class Menus { public class Menus {
@@ -67,7 +69,12 @@ public class Menus {
} catch (ConfigurateException e) { } catch (ConfigurateException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
try {
new Menu(FilenameUtils.removeExtension(child.getName()), root); new Menu(FilenameUtils.removeExtension(child.getName()), root);
} catch (Exception e) {
MessagesUtil.sendDebugMessages("Unable to create menu in " + child, Level.WARNING);
if (Settings.isDebugEnabled()) e.printStackTrace();
}
} }
} }
} }

View File

@@ -21,7 +21,9 @@ public class ItemAdderHook extends ItemHook implements Listener {
@Override @Override
public ItemStack get(String itemid) { public ItemStack get(String itemid) {
if (enabled) { if (enabled) {
return CustomStack.getInstance(itemid).getItemStack(); CustomStack stack = CustomStack.getInstance(itemid);
if (stack == null) return null;
return stack.getItemStack();
} else { } else {
return new ItemStack(Material.AIR); return new ItemStack(Material.AIR);
} }

View File

@@ -246,9 +246,25 @@ public class CosmeticUser {
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
} }
if (!getWardrobe().getWardrobeStatus().equals(Wardrobe.WardrobeStatus.RUNNING)) return;
getWardrobe().setWardrobeStatus(Wardrobe.WardrobeStatus.STOPPING);
if (WardrobeSettings.isEnabledTransition()) {
MessagesUtil.sendTitle(
getPlayer(),
WardrobeSettings.getTransitionText(),
WardrobeSettings.getTransitionFadeIn(),
WardrobeSettings.getTransitionStay(),
WardrobeSettings.getTransitionFadeOut()
);
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
wardrobe.end(); wardrobe.end();
wardrobe = null; wardrobe = null;
}, WardrobeSettings.getTransitionDelay());
} else {
}
} }
public boolean isInWardrobe() { public boolean isInWardrobe() {
@@ -306,6 +322,20 @@ public class CosmeticUser {
this.invisibleArmorstand = null; this.invisibleArmorstand = null;
} }
public void respawnBackpack() {
if (!hasCosmeticInSlot(CosmeticSlot.BACKPACK)) return;
final Cosmetic cosmetic = getCosmetic(CosmeticSlot.BACKPACK);
despawnBackpack();
spawnBackpack((CosmeticBackpackType) cosmetic);
}
public void respawnBalloon() {
if (!hasCosmeticInSlot(CosmeticSlot.BALLOON)) return;
final Cosmetic cosmetic = getCosmetic(CosmeticSlot.BALLOON);
despawnBalloon();
spawnBalloon((CosmeticBalloonType) cosmetic);
}
public void removeArmor(CosmeticSlot slot) { public void removeArmor(CosmeticSlot slot) {
PacketManager.equipmentSlotUpdate(getPlayer().getEntityId(), this, slot, PlayerUtils.getNearbyPlayers(getPlayer())); PacketManager.equipmentSlotUpdate(getPlayer().getEntityId(), this, slot, PlayerUtils.getNearbyPlayers(getPlayer()));
} }

View File

@@ -39,15 +39,18 @@ public class Wardrobe {
private Location exitLocation; private Location exitLocation;
private BossBar bossBar; private BossBar bossBar;
private boolean active; private boolean active;
private WardrobeStatus wardrobeStatus;
public Wardrobe(CosmeticUser user) { public Wardrobe(CosmeticUser user) {
NPC_ID = NMSHandlers.getHandler().getNextEntityId(); NPC_ID = NMSHandlers.getHandler().getNextEntityId();
ARMORSTAND_ID = NMSHandlers.getHandler().getNextEntityId(); ARMORSTAND_ID = NMSHandlers.getHandler().getNextEntityId();
WARDROBE_UUID = UUID.randomUUID(); WARDROBE_UUID = UUID.randomUUID();
VIEWER = user; VIEWER = user;
wardrobeStatus = WardrobeStatus.SETUP;
} }
public void start() { public void start() {
setWardrobeStatus(WardrobeStatus.STARTING);
Player player = VIEWER.getPlayer(); Player player = VIEWER.getPlayer();
this.originalGamemode = player.getGameMode(); this.originalGamemode = player.getGameMode();
@@ -62,6 +65,8 @@ public class Wardrobe {
VIEWER.hidePlayer(); VIEWER.hidePlayer();
List<Player> viewer = List.of(player); List<Player> viewer = List.of(player);
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
outsideViewers.remove(player);
MessagesUtil.sendMessage(player, "opened-wardrobe"); MessagesUtil.sendMessage(player, "opened-wardrobe");
@@ -119,6 +124,7 @@ public class Wardrobe {
this.active = true; this.active = true;
update(); update();
setWardrobeStatus(WardrobeStatus.RUNNING);
}; };
@@ -138,9 +144,12 @@ public class Wardrobe {
} }
public void end() { public void end() {
setWardrobeStatus(WardrobeStatus.STOPPING);
Player player = VIEWER.getPlayer(); Player player = VIEWER.getPlayer();
List<Player> viewer = List.of(player); List<Player> viewer = List.of(player);
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
outsideViewers.remove(player);
MessagesUtil.sendMessage(player, "closed-wardrobe"); MessagesUtil.sendMessage(player, "closed-wardrobe");
@@ -164,11 +173,13 @@ public class Wardrobe {
VIEWER.showPlayer(); VIEWER.showPlayer();
if (VIEWER.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) { if (VIEWER.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
PacketManager.ridingMountPacket(player.getEntityId(), VIEWER.getBackpackEntity().getEntityId(), viewer); VIEWER.respawnBackpack();
//PacketManager.ridingMountPacket(player.getEntityId(), VIEWER.getBackpackEntity().getEntityId(), viewer);
} }
if (VIEWER.hasCosmeticInSlot(CosmeticSlot.BALLOON)) { if (VIEWER.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getPufferfishBalloonId(), player.getEntityId(), viewer); VIEWER.respawnBalloon();
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getPufferfishBalloonId(), player.getEntityId(), viewer);
} }
if (exitLocation == null) { if (exitLocation == null) {
@@ -189,20 +200,8 @@ public class Wardrobe {
VIEWER.updateCosmetic(); VIEWER.updateCosmetic();
}; };
if (WardrobeSettings.isEnabledTransition()) {
MessagesUtil.sendTitle(
VIEWER.getPlayer(),
WardrobeSettings.getTransitionText(),
WardrobeSettings.getTransitionFadeIn(),
WardrobeSettings.getTransitionStay(),
WardrobeSettings.getTransitionFadeOut()
);
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), run, WardrobeSettings.getTransitionDelay());
} else {
run.run(); run.run();
} }
}
public void update() { public void update() {
final AtomicInteger data = new AtomicInteger(); final AtomicInteger data = new AtomicInteger();
@@ -217,13 +216,15 @@ public class Wardrobe {
} }
MessagesUtil.sendDebugMessages("Update "); MessagesUtil.sendDebugMessages("Update ");
List<Player> viewer = List.of(VIEWER.getPlayer()); List<Player> viewer = List.of(VIEWER.getPlayer());
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
outsideViewers.remove(VIEWER.getPlayer());
Location location = WardrobeSettings.getWardrobeLocation().clone(); Location location = WardrobeSettings.getWardrobeLocation().clone();
int yaw = data.get(); int yaw = data.get();
location.setYaw(yaw); location.setYaw(yaw);
PacketManager.sendLookPacket(NPC_ID, location, viewer); PacketManager.sendLookPacket(NPC_ID, location, viewer);
//VIEWER.updateCosmetic(); VIEWER.hidePlayer();
int rotationSpeed = WardrobeSettings.getRotationSpeed(); int rotationSpeed = WardrobeSettings.getRotationSpeed();
location.setYaw(getNextYaw(yaw - 30, rotationSpeed)); location.setYaw(getNextYaw(yaw - 30, rotationSpeed));
PacketManager.sendRotationPacket(NPC_ID, location, true, viewer); PacketManager.sendRotationPacket(NPC_ID, location, true, viewer);
@@ -238,11 +239,14 @@ public class Wardrobe {
PacketManager.sendTeleportPacket(VIEWER.getArmorstandId(), location, false, viewer); PacketManager.sendTeleportPacket(VIEWER.getArmorstandId(), location, false, viewer);
PacketManager.ridingMountPacket(NPC_ID, VIEWER.getBackpackEntity().getEntityId(), viewer); PacketManager.ridingMountPacket(NPC_ID, VIEWER.getBackpackEntity().getEntityId(), viewer);
VIEWER.getBackpackEntity().setRotation(nextyaw, 0); VIEWER.getBackpackEntity().setRotation(nextyaw, 0);
PacketManager.sendEntityDestroyPacket(VIEWER.getArmorstandId(), outsideViewers);
} }
if (VIEWER.hasCosmeticInSlot(CosmeticSlot.BALLOON)) { if (VIEWER.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
PacketManager.sendTeleportPacket(VIEWER.getBalloonEntity().getPufferfishBalloonId(), WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()), false, viewer); PacketManager.sendTeleportPacket(VIEWER.getBalloonEntity().getPufferfishBalloonId(), WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()), false, viewer);
VIEWER.getBalloonEntity().getModelEntity().teleport(WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset())); VIEWER.getBalloonEntity().getModelEntity().teleport(WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()));
PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getPufferfishBalloonId(), -1, outsideViewers);
PacketManager.sendEntityDestroyPacket(VIEWER.getBalloonEntity().getModelId(), outsideViewers);
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer); // Pufferfish goes away for some reason? //PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer); // Pufferfish goes away for some reason?
} }
@@ -267,4 +271,19 @@ public class Wardrobe {
public int getArmorstandId() { public int getArmorstandId() {
return ARMORSTAND_ID; return ARMORSTAND_ID;
} }
public WardrobeStatus getWardrobeStatus() {
return wardrobeStatus;
}
public void setWardrobeStatus(WardrobeStatus status) {
this.wardrobeStatus = status;
}
public enum WardrobeStatus {
SETUP,
STARTING,
RUNNING,
STOPPING,
}
} }

View File

@@ -47,6 +47,7 @@ public class MessagesUtil {
public static void sendMessage(CommandSender sender, String key) { public static void sendMessage(CommandSender sender, String key) {
Component finalMessage = processString(null, key); Component finalMessage = processString(null, key);
if (finalMessage == null) return;
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).sender(sender); Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).sender(sender);
target.sendMessage(finalMessage); target.sendMessage(finalMessage);
@@ -130,7 +131,7 @@ public class MessagesUtil {
} }
public static void sendDebugMessages(String message, Level level) { public static void sendDebugMessages(String message, Level level) {
if (!Settings.isDebugEnabled() && level != Level.SEVERE) return; if (!Settings.isDebugEnabled() && level == Level.INFO) return;
HMCCosmeticsPlugin.getInstance().getLogger().log(level, message); HMCCosmeticsPlugin.getInstance().getLogger().log(level, message);
} }
} }

View File

@@ -17,6 +17,7 @@ public class InvisibleArmorstand extends ArmorStand {
setInvisible(true); setInvisible(true);
setInvulnerable(true); setInvulnerable(true);
setMarker(true); setMarker(true);
setSilent(true);
getBukkitLivingEntity().setCollidable(false); getBukkitLivingEntity().setCollidable(false);
persist = false; persist = false;
} }

View File

@@ -17,6 +17,7 @@ public class InvisibleArmorstand extends ArmorStand {
setInvisible(true); setInvisible(true);
setInvulnerable(true); setInvulnerable(true);
setMarker(true); setMarker(true);
setSilent(true);
getBukkitLivingEntity().setCollidable(false); getBukkitLivingEntity().setCollidable(false);
persist = false; persist = false;
} }