mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-20 15:39:16 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1804e4691b | ||
|
|
223f8bdb9c | ||
|
|
c757752038 | ||
|
|
243644301a | ||
|
|
652b20c148 | ||
|
|
6c3ffbb71e | ||
|
|
fb6e5abb8b | ||
|
|
f546500f1e | ||
|
|
044528188d |
@@ -9,7 +9,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "com.hibiscusmc"
|
||||
version = "2.0.2"
|
||||
version = "2.0.3"
|
||||
|
||||
allprojects {
|
||||
apply(plugin = "java")
|
||||
@@ -58,6 +58,17 @@ allprojects {
|
||||
|
||||
dependencies {
|
||||
|
||||
compileOnly("com.mojang:authlib:1.5.25")
|
||||
compileOnly("org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT")
|
||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0-SNAPSHOT")
|
||||
compileOnly("me.clip:placeholderapi:2.11.1")
|
||||
compileOnly("com.ticxo.modelengine:api:R3.0.1")
|
||||
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
|
||||
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
||||
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,18 +76,6 @@ 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("org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT")
|
||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0-SNAPSHOT")
|
||||
compileOnly("me.clip:placeholderapi:2.11.1")
|
||||
compileOnly("com.ticxo.modelengine:api:R3.0.1")
|
||||
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
|
||||
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.2.5")
|
||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT")
|
||||
compileOnly("it.unimi.dsi:fastutil:8.5.11")
|
||||
|
||||
//compileOnly("com.github.Fisher2911:FisherLib:master-SNAPSHOT")
|
||||
implementation("net.kyori:adventure-api:4.11.0")
|
||||
|
||||
@@ -2,11 +2,13 @@ package com.hibiscusmc.hmccosmetics.cosmetic;
|
||||
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
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.apache.commons.lang3.EnumUtils;
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
@@ -14,6 +16,7 @@ import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Cosmetics {
|
||||
|
||||
@@ -78,23 +81,27 @@ public class Cosmetics {
|
||||
|
||||
private static void setupCosmetics(CommentedConfigurationNode config) {
|
||||
for (ConfigurationNode cosmeticConfig : config.childrenMap().values()) {
|
||||
String id = cosmeticConfig.key().toString();
|
||||
MessagesUtil.sendDebugMessages("Attempting to add " + id);
|
||||
switch (CosmeticSlot.valueOf(cosmeticConfig.node("slot").getString())) {
|
||||
case BALLOON -> {
|
||||
new CosmeticBalloonType(id, cosmeticConfig);
|
||||
try {
|
||||
String id = cosmeticConfig.key().toString();
|
||||
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;
|
||||
}
|
||||
case BACKPACK -> {
|
||||
new CosmeticBackpackType(id, cosmeticConfig);
|
||||
if (!EnumUtils.isValidEnum(CosmeticSlot.class, slotNode.getString())) {
|
||||
MessagesUtil.sendDebugMessages("Unable to create " + id + " because " + slotNode.getString() + " is not a valid slot!", Level.WARNING);
|
||||
continue;
|
||||
}
|
||||
case MAINHAND -> {
|
||||
new CosmeticMainhandType(id, cosmeticConfig);
|
||||
}
|
||||
default -> {
|
||||
new CosmeticArmorType(id, cosmeticConfig);
|
||||
switch (CosmeticSlot.valueOf(cosmeticConfig.node("slot").getString())) {
|
||||
case BALLOON -> new CosmeticBalloonType(id, cosmeticConfig);
|
||||
case BACKPACK -> new CosmeticBackpackType(id, cosmeticConfig);
|
||||
case MAINHAND -> new CosmeticMainhandType(id, cosmeticConfig);
|
||||
default -> new CosmeticArmorType(id, cosmeticConfig);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (Settings.isDebugEnabled()) e.printStackTrace();
|
||||
}
|
||||
//new Cosmetic(id, cosmeticConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,8 @@ public class CosmeticBackpackType extends Cosmetic {
|
||||
Player player = Bukkit.getPlayer(user.getUniqueId());
|
||||
Location loc = player.getLocation().clone();
|
||||
|
||||
if (user.isInWardrobe()) return;
|
||||
|
||||
if (loc.getWorld() != user.getBackpackEntity().getWorld()) {
|
||||
user.getBackpackEntity().teleport(loc);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
@@ -12,6 +13,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Menus {
|
||||
|
||||
@@ -67,7 +69,12 @@ public class Menus {
|
||||
} catch (ConfigurateException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
new Menu(FilenameUtils.removeExtension(child.getName()), root);
|
||||
try {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,9 @@ public class ItemAdderHook extends ItemHook implements Listener {
|
||||
@Override
|
||||
public ItemStack get(String itemid) {
|
||||
if (enabled) {
|
||||
return CustomStack.getInstance(itemid).getItemStack();
|
||||
CustomStack stack = CustomStack.getInstance(itemid);
|
||||
if (stack == null) return null;
|
||||
return stack.getItemStack();
|
||||
} else {
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
|
||||
@@ -246,9 +246,25 @@ public class CosmeticUser {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
if (!getWardrobe().getWardrobeStatus().equals(Wardrobe.WardrobeStatus.RUNNING)) return;
|
||||
|
||||
wardrobe.end();
|
||||
wardrobe = null;
|
||||
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 = null;
|
||||
}, WardrobeSettings.getTransitionDelay());
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInWardrobe() {
|
||||
@@ -306,6 +322,20 @@ public class CosmeticUser {
|
||||
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) {
|
||||
PacketManager.equipmentSlotUpdate(getPlayer().getEntityId(), this, slot, PlayerUtils.getNearbyPlayers(getPlayer()));
|
||||
}
|
||||
|
||||
@@ -39,15 +39,18 @@ public class Wardrobe {
|
||||
private Location exitLocation;
|
||||
private BossBar bossBar;
|
||||
private boolean active;
|
||||
private WardrobeStatus wardrobeStatus;
|
||||
|
||||
public Wardrobe(CosmeticUser user) {
|
||||
NPC_ID = NMSHandlers.getHandler().getNextEntityId();
|
||||
ARMORSTAND_ID = NMSHandlers.getHandler().getNextEntityId();
|
||||
WARDROBE_UUID = UUID.randomUUID();
|
||||
VIEWER = user;
|
||||
wardrobeStatus = WardrobeStatus.SETUP;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
setWardrobeStatus(WardrobeStatus.STARTING);
|
||||
Player player = VIEWER.getPlayer();
|
||||
|
||||
this.originalGamemode = player.getGameMode();
|
||||
@@ -62,6 +65,8 @@ public class Wardrobe {
|
||||
|
||||
VIEWER.hidePlayer();
|
||||
List<Player> viewer = List.of(player);
|
||||
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
|
||||
outsideViewers.remove(player);
|
||||
|
||||
MessagesUtil.sendMessage(player, "opened-wardrobe");
|
||||
|
||||
@@ -119,6 +124,7 @@ public class Wardrobe {
|
||||
|
||||
this.active = true;
|
||||
update();
|
||||
setWardrobeStatus(WardrobeStatus.RUNNING);
|
||||
};
|
||||
|
||||
|
||||
@@ -138,9 +144,12 @@ public class Wardrobe {
|
||||
}
|
||||
|
||||
public void end() {
|
||||
setWardrobeStatus(WardrobeStatus.STOPPING);
|
||||
Player player = VIEWER.getPlayer();
|
||||
|
||||
List<Player> viewer = List.of(player);
|
||||
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
|
||||
outsideViewers.remove(player);
|
||||
|
||||
MessagesUtil.sendMessage(player, "closed-wardrobe");
|
||||
|
||||
@@ -164,11 +173,13 @@ public class Wardrobe {
|
||||
VIEWER.showPlayer();
|
||||
|
||||
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)) {
|
||||
PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getPufferfishBalloonId(), player.getEntityId(), viewer);
|
||||
VIEWER.respawnBalloon();
|
||||
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getPufferfishBalloonId(), player.getEntityId(), viewer);
|
||||
}
|
||||
|
||||
if (exitLocation == null) {
|
||||
@@ -189,19 +200,7 @@ public class Wardrobe {
|
||||
|
||||
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() {
|
||||
@@ -217,13 +216,15 @@ public class Wardrobe {
|
||||
}
|
||||
MessagesUtil.sendDebugMessages("Update ");
|
||||
List<Player> viewer = List.of(VIEWER.getPlayer());
|
||||
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
|
||||
outsideViewers.remove(VIEWER.getPlayer());
|
||||
|
||||
Location location = WardrobeSettings.getWardrobeLocation().clone();
|
||||
int yaw = data.get();
|
||||
location.setYaw(yaw);
|
||||
|
||||
PacketManager.sendLookPacket(NPC_ID, location, viewer);
|
||||
//VIEWER.updateCosmetic();
|
||||
VIEWER.hidePlayer();
|
||||
int rotationSpeed = WardrobeSettings.getRotationSpeed();
|
||||
location.setYaw(getNextYaw(yaw - 30, rotationSpeed));
|
||||
PacketManager.sendRotationPacket(NPC_ID, location, true, viewer);
|
||||
@@ -238,11 +239,14 @@ public class Wardrobe {
|
||||
PacketManager.sendTeleportPacket(VIEWER.getArmorstandId(), location, false, viewer);
|
||||
PacketManager.ridingMountPacket(NPC_ID, VIEWER.getBackpackEntity().getEntityId(), viewer);
|
||||
VIEWER.getBackpackEntity().setRotation(nextyaw, 0);
|
||||
PacketManager.sendEntityDestroyPacket(VIEWER.getArmorstandId(), outsideViewers);
|
||||
}
|
||||
|
||||
if (VIEWER.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||
PacketManager.sendTeleportPacket(VIEWER.getBalloonEntity().getPufferfishBalloonId(), WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()), false, viewer);
|
||||
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?
|
||||
}
|
||||
|
||||
@@ -267,4 +271,19 @@ public class Wardrobe {
|
||||
public int getArmorstandId() {
|
||||
return ARMORSTAND_ID;
|
||||
}
|
||||
|
||||
public WardrobeStatus getWardrobeStatus() {
|
||||
return wardrobeStatus;
|
||||
}
|
||||
|
||||
public void setWardrobeStatus(WardrobeStatus status) {
|
||||
this.wardrobeStatus = status;
|
||||
}
|
||||
|
||||
public enum WardrobeStatus {
|
||||
SETUP,
|
||||
STARTING,
|
||||
RUNNING,
|
||||
STOPPING,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ public class MessagesUtil {
|
||||
|
||||
public static void sendMessage(CommandSender sender, String key) {
|
||||
Component finalMessage = processString(null, key);
|
||||
if (finalMessage == null) return;
|
||||
Audience target = BukkitAudiences.create(HMCCosmeticsPlugin.getInstance()).sender(sender);
|
||||
|
||||
target.sendMessage(finalMessage);
|
||||
@@ -130,7 +131,7 @@ public class MessagesUtil {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ public class InvisibleArmorstand extends ArmorStand {
|
||||
setInvisible(true);
|
||||
setInvulnerable(true);
|
||||
setMarker(true);
|
||||
setSilent(true);
|
||||
getBukkitLivingEntity().setCollidable(false);
|
||||
persist = false;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ public class InvisibleArmorstand extends ArmorStand {
|
||||
setInvisible(true);
|
||||
setInvulnerable(true);
|
||||
setMarker(true);
|
||||
setSilent(true);
|
||||
getBukkitLivingEntity().setCollidable(false);
|
||||
persist = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user