9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-30 12:29:16 +00:00
This commit is contained in:
LoJoSho
2023-02-09 13:32:28 -06:00
parent dcd38d86c5
commit 9e07f728e1
3 changed files with 31 additions and 11 deletions

View File

@@ -13,7 +13,6 @@ import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
import com.hibiscusmc.hmccosmetics.database.Database;
import com.hibiscusmc.hmccosmetics.gui.Menus;
import com.hibiscusmc.hmccosmetics.hooks.Hooks;
import com.hibiscusmc.hmccosmetics.hooks.placeholders.HMCPlaceholderExpansion;
import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGHook;
import com.hibiscusmc.hmccosmetics.hooks.worldguard.WGListener;
import com.hibiscusmc.hmccosmetics.listener.PlayerConnectionListener;
@@ -26,6 +25,7 @@ import com.jeff_media.updatechecker.UpdateChecker;
import com.ticxo.playeranimator.PlayerAnimatorImpl;
import com.ticxo.playeranimator.api.PlayerAnimator;
import com.ticxo.playeranimator.api.animation.pack.AnimationPack;
import org.apache.commons.io.FilenameUtils;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@@ -239,7 +239,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
for (File emoteFile : emotesFiles) {
if (!emoteFile.getName().contains("bbmodel")) continue;
String animationName = emoteFile.getName().replaceAll(".bbmodel", "");
PlayerAnimator.api.getAnimationManager().importAnimations(emoteFile.getName(), emoteFile);
PlayerAnimator.api.getAnimationManager().importAnimations(FilenameUtils.removeExtension(emoteFile.getName()), emoteFile);
MessagesUtil.sendDebugMessages("Added '" + animationName + "' to Player Animator ");
}

View File

@@ -16,7 +16,11 @@ public class UserEmoteManager {
public void playEmote(CosmeticEmoteType cosmeticEmoteType) {
MessagesUtil.sendDebugMessages("playEmote " + cosmeticEmoteType.getAnimationId());
model = new UserEmoteModel(user);
model.playAnimation(cosmeticEmoteType.getAnimationId());
try {
model.playAnimation(cosmeticEmoteType.getAnimationId());
} catch (Exception e) {
e.printStackTrace();
}
}
public boolean isPlayingEmote() {

View File

@@ -1,9 +1,10 @@
package com.hibiscusmc.hmccosmetics.user.manager;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import com.ticxo.playeranimator.api.PlayerAnimator;
import com.ticxo.playeranimator.api.model.player.PlayerModel;
import org.bukkit.Bukkit;
public class UserEmoteModel extends PlayerModel {
@@ -17,24 +18,39 @@ public class UserEmoteModel extends PlayerModel {
@Override
public void playAnimation(String id) {
id = id + "\\bbmodel\\" + id;
MessagesUtil.sendDebugMessages("playAnimation " + id);
id = id + "." + id + "." + id; // Make into a format that playerAnimator works with. Requires 3 splits.
super.playAnimation(id);
emotePlaying = id;
user.getPlayer().setInvisible(true);
user.hidePlayer();
user.hideCosmetics(CosmeticUser.HiddenReason.EMOTE);
emotePlaying = id;
MessagesUtil.sendDebugMessages("playAnimation run");
}
@Override
public boolean update() {
if (super.getAnimationProperty() == null) {
stopAnimation();
return false;
}
boolean update = (super.update() && isPlayingAnimation());
if (!update) {
stopAnimation();
}
return update;
}
public void stopAnimation() {
user.showPlayer();
user.showCosmetics();
emotePlaying = null;
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
if (user.getPlayer() != null) user.getPlayer().setInvisible(false);
user.showPlayer();
user.showCosmetics();
});
}
public boolean isPlayingAnimation() {
if (emotePlaying == null) return false;
return true;
}
}