mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-30 12:29:16 +00:00
emo work
This commit is contained in:
@@ -23,6 +23,8 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
|
||||
import com.jeff_media.updatechecker.UpdateCheckSource;
|
||||
import com.jeff_media.updatechecker.UpdateChecker;
|
||||
import com.ticxo.playeranimator.PlayerAnimatorImpl;
|
||||
import com.ticxo.playeranimator.api.PlayerAnimator;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@@ -91,6 +93,9 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
saveResource("menus/defaultmenu.yml", false);
|
||||
}
|
||||
|
||||
// Player Animator
|
||||
PlayerAnimatorImpl.initialize(this);
|
||||
|
||||
setup();
|
||||
|
||||
// Commands
|
||||
@@ -223,6 +228,17 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
File emoteFolder = new File(getInstance().getDataFolder().getPath() + "/emotes/");
|
||||
if (emoteFolder.exists()) {
|
||||
PlayerAnimator.api.getAnimationManager().clearRegistry();
|
||||
File[] emotesFiles = emoteFolder.listFiles();
|
||||
for (File emoteFile : emotesFiles) {
|
||||
if (!emoteFile.getName().contains("bbmodel")) continue;
|
||||
String animationName = emoteFile.getName().replaceAll("bbmodel", "");
|
||||
PlayerAnimator.api.getAnimationManager().importAnimations(animationName, emoteFile);
|
||||
}
|
||||
}
|
||||
|
||||
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
|
||||
getInstance().getLogger().info(Cosmetics.values().size() + " Cosmetics Successfully Setup");
|
||||
getInstance().getLogger().info(Menus.getMenuNames().size() + " Menus Successfully Setup");
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
||||
import com.hibiscusmc.hmccosmetics.database.Database;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menu;
|
||||
import com.hibiscusmc.hmccosmetics.gui.Menus;
|
||||
@@ -380,7 +381,12 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
if (!silent) MessagesUtil.sendMessage(sender, "debug-enabled");
|
||||
}
|
||||
}
|
||||
case ("emote") -> {
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
|
||||
CosmeticEmoteType cosmeticEmoteType = (CosmeticEmoteType) user.getCosmetic(CosmeticSlot.EMOTE);
|
||||
cosmeticEmoteType.run(user);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -8,5 +8,6 @@ public enum CosmeticSlot {
|
||||
MAINHAND,
|
||||
OFFHAND,
|
||||
BACKPACK,
|
||||
BALLOON
|
||||
BALLOON,
|
||||
EMOTE
|
||||
}
|
||||
|
||||
@@ -3,10 +3,7 @@ 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.cosmetic.types.*;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
@@ -97,6 +94,7 @@ public class Cosmetics {
|
||||
case BALLOON -> new CosmeticBalloonType(id, cosmeticConfig);
|
||||
case BACKPACK -> new CosmeticBackpackType(id, cosmeticConfig);
|
||||
case MAINHAND -> new CosmeticMainhandType(id, cosmeticConfig);
|
||||
case EMOTE -> new CosmeticEmoteType(id, cosmeticConfig);
|
||||
default -> new CosmeticArmorType(id, cosmeticConfig);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.hibiscusmc.hmccosmetics.cosmetic.types;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
public class CosmeticEmoteType extends Cosmetic {
|
||||
|
||||
private String animationId;
|
||||
|
||||
public CosmeticEmoteType(String id, ConfigurationNode config) {
|
||||
super(id, config);
|
||||
|
||||
animationId = config.node("animation").getString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(CosmeticUser user) {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
public void run(CosmeticUser user) {
|
||||
user.getUserEmoteManager().playEmote(this);
|
||||
}
|
||||
|
||||
public String getAnimationId() {
|
||||
return animationId;
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,7 @@ public class PlayerConnectionListener implements Listener {
|
||||
}
|
||||
}
|
||||
if (user.isInWardrobe()) user.leaveWardrobe();
|
||||
if (user.getUserEmoteManager().isPlayingEmote()) user.getUserEmoteManager().stopEmote();
|
||||
Database.save(user);
|
||||
user.destroy();
|
||||
CosmeticUsers.removeUser(user.getUniqueId());
|
||||
|
||||
@@ -6,13 +6,11 @@ import com.hibiscusmc.hmccosmetics.config.Settings;
|
||||
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
|
||||
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.cosmetic.types.*;
|
||||
import com.hibiscusmc.hmccosmetics.user.manager.UserBackpackManager;
|
||||
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.UserWardrobeManager;
|
||||
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
@@ -38,6 +36,7 @@ public class CosmeticUser {
|
||||
private UserWardrobeManager userWardrobeManager;
|
||||
private UserBalloonManager userBalloonManager;
|
||||
private UserBackpackManager userBackpackManager;
|
||||
private UserEmoteManager userEmoteManager;
|
||||
|
||||
// Cosmetic Settings/Toggles
|
||||
private boolean hideCosmetics;
|
||||
@@ -46,6 +45,7 @@ public class CosmeticUser {
|
||||
|
||||
public CosmeticUser(UUID uuid) {
|
||||
this.uniqueId = uuid;
|
||||
userEmoteManager = new UserEmoteManager(this);
|
||||
tick();
|
||||
}
|
||||
|
||||
@@ -215,6 +215,10 @@ public class CosmeticUser {
|
||||
return userWardrobeManager;
|
||||
}
|
||||
|
||||
public UserEmoteManager getUserEmoteManager() {
|
||||
return userEmoteManager;
|
||||
}
|
||||
|
||||
public void enterWardrobe() {
|
||||
enterWardrobe(false);
|
||||
}
|
||||
@@ -436,6 +440,7 @@ public class CosmeticUser {
|
||||
PLUGIN,
|
||||
POTION,
|
||||
ACTION,
|
||||
COMMAND
|
||||
COMMAND,
|
||||
EMOTE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticEmoteType;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
|
||||
public class UserEmoteManager {
|
||||
|
||||
CosmeticUser user;
|
||||
private UserEmoteModel model;
|
||||
|
||||
public UserEmoteManager(CosmeticUser user) {
|
||||
this.user = user;
|
||||
model = new UserEmoteModel(user);
|
||||
}
|
||||
|
||||
public void playEmote(CosmeticEmoteType cosmeticEmoteType) {
|
||||
model.playAnimation(cosmeticEmoteType.getAnimationId());
|
||||
}
|
||||
|
||||
public boolean isPlayingEmote() {
|
||||
return model.isPlayingAnimation();
|
||||
}
|
||||
|
||||
public void stopEmote() {
|
||||
model.stopAnimation();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.hibiscusmc.hmccosmetics.user.manager;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.ticxo.playeranimator.api.model.player.PlayerModel;
|
||||
|
||||
public class UserEmoteModel extends PlayerModel {
|
||||
|
||||
private CosmeticUser user;
|
||||
private String emotePlaying;
|
||||
|
||||
public UserEmoteModel(CosmeticUser user) {
|
||||
super(user.getPlayer());
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playAnimation(String id) {
|
||||
super.playAnimation(id);
|
||||
user.hidePlayer();
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.EMOTE);
|
||||
emotePlaying = id;
|
||||
}
|
||||
|
||||
public void stopAnimation() {
|
||||
user.showPlayer();
|
||||
user.showCosmetics();
|
||||
emotePlaying = null;
|
||||
}
|
||||
|
||||
public boolean isPlayingAnimation() {
|
||||
if (emotePlaying == null) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user