mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-26 18:39:07 +00:00
Emote settings and messages
This commit is contained in:
@@ -29,6 +29,7 @@ public class Settings {
|
||||
private static final String TICK_PERIOD_PATH = "tick-period";
|
||||
private static final String UNAPPLY_DEATH_PATH = "unapply-on-death";
|
||||
private static final String FORCE_PERMISSION_JOIN_PATH = "force-permission-join";
|
||||
private static final String EMOTE_DISTANCE_PATH = "emote-distance";
|
||||
|
||||
private static String defaultMenu;
|
||||
private static String dyeMenuName;
|
||||
@@ -44,6 +45,7 @@ public class Settings {
|
||||
private static int lookDownPitch;
|
||||
private static int viewDistance;
|
||||
private static int tickPeriod;
|
||||
private static double emoteDistance;
|
||||
private static Vector balloonOffset;
|
||||
|
||||
public static void load(ConfigurationNode source) {
|
||||
@@ -70,6 +72,7 @@ public class Settings {
|
||||
requireEmptyBoots = cosmeticSettings.node(REQUIRE_EMPTY_BOOTS_PATH).getBoolean();
|
||||
unapplyOnDeath = cosmeticSettings.node(UNAPPLY_DEATH_PATH).getBoolean(false);
|
||||
forcePermissionJoin = cosmeticSettings.node(FORCE_PERMISSION_JOIN_PATH).getBoolean(false);
|
||||
emoteDistance = cosmeticSettings.node(EMOTE_DISTANCE_PATH).getDouble(-3);
|
||||
|
||||
tickPeriod = cosmeticSettings.node(TICK_PERIOD_PATH).getInt(-1);
|
||||
lookDownPitch = cosmeticSettings.node(LOOK_DOWN_PITCH_PATH).getInt();
|
||||
@@ -193,6 +196,10 @@ public class Settings {
|
||||
public static boolean getDebugMode() {
|
||||
return debugMode;
|
||||
}
|
||||
|
||||
public static double getEmoteDistance() {
|
||||
return emoteDistance;
|
||||
}
|
||||
public static void setDebugMode(boolean newSetting) {
|
||||
debugMode = newSetting;
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ public class UserEmoteManager {
|
||||
|
||||
public void playEmote(CosmeticEmoteType cosmeticEmoteType) {
|
||||
MessagesUtil.sendDebugMessages("playEmote " + cosmeticEmoteType.getAnimationId());
|
||||
model = new UserEmoteModel(user);
|
||||
try {
|
||||
model = new UserEmoteModel(user);
|
||||
model.playAnimation(cosmeticEmoteType.getAnimationId());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.ticxo.playeranimator.api.model.player.PlayerModel;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -36,19 +37,25 @@ public class UserEmoteModel extends PlayerModel {
|
||||
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.hideCosmetics(CosmeticUser.HiddenReason.EMOTE);
|
||||
|
||||
// Add config option that either allows player to move or forces them into a spot.
|
||||
Player player = user.getPlayer();
|
||||
List<Player> viewer = List.of(user.getPlayer());
|
||||
|
||||
Location newLocation = player.getLocation().clone();
|
||||
newLocation.setPitch(0);
|
||||
Location behindPlayerLoc = player.getLocation().add(newLocation.getDirection().normalize().multiply(-3));
|
||||
double DISTANCE = Settings.getEmoteDistance();
|
||||
Location thirdPersonLocation = newLocation.add(newLocation.getDirection().normalize().multiply(DISTANCE));
|
||||
if (thirdPersonLocation.getBlock().getType() != Material.AIR) {
|
||||
stopAnimation();
|
||||
MessagesUtil.sendMessage(player, "emote-blocked");
|
||||
return;
|
||||
}
|
||||
user.getPlayer().setInvisible(true);
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.EMOTE);
|
||||
|
||||
originalGamemode = player.getGameMode();
|
||||
|
||||
PacketManager.sendEntitySpawnPacket(behindPlayerLoc, armorstandId, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer);
|
||||
PacketManager.sendEntitySpawnPacket(thirdPersonLocation, armorstandId, EntityType.ARMOR_STAND, UUID.randomUUID(), viewer);
|
||||
PacketManager.sendInvisibilityPacket(armorstandId, viewer);
|
||||
PacketManager.sendLookPacket(armorstandId, player.getLocation(), viewer);
|
||||
|
||||
@@ -78,8 +85,10 @@ public class UserEmoteModel extends PlayerModel {
|
||||
Bukkit.getScheduler().runTask(HMCCosmeticsPlugin.getInstance(), () -> {
|
||||
PacketManager.sendCameraPacket(user.getPlayer().getEntityId(), viewer);
|
||||
PacketManager.sendEntityDestroyPacket(armorstandId, viewer);
|
||||
PacketManager.gamemodeChangePacket(user.getPlayer(), ServerUtils.convertGamemode(this.originalGamemode));
|
||||
user.getPlayer().setGameMode(this.originalGamemode);
|
||||
if (this.originalGamemode != null) {
|
||||
PacketManager.gamemodeChangePacket(user.getPlayer(), ServerUtils.convertGamemode(this.originalGamemode));
|
||||
user.getPlayer().setGameMode(this.originalGamemode);
|
||||
}
|
||||
|
||||
if (user.getPlayer() != null) user.getPlayer().setInvisible(false);
|
||||
user.showPlayer();
|
||||
|
||||
@@ -240,9 +240,9 @@ public class UserWardrobeManager {
|
||||
PacketManager.sendLookPacket(NPC_ID, location, viewer);
|
||||
VIEWER.hidePlayer();
|
||||
int rotationSpeed = WardrobeSettings.getRotationSpeed();
|
||||
location.setYaw(getNextYaw(yaw - 30, rotationSpeed));
|
||||
location.setYaw(ServerUtils.getNextYaw(yaw - 30, rotationSpeed));
|
||||
PacketManager.sendRotationPacket(NPC_ID, location, true, viewer);
|
||||
int nextyaw = getNextYaw(yaw, rotationSpeed);
|
||||
int nextyaw = ServerUtils.getNextYaw(yaw, rotationSpeed);
|
||||
data.set(nextyaw);
|
||||
|
||||
for (CosmeticSlot slot : CosmeticSlot.values()) {
|
||||
@@ -273,15 +273,6 @@ public class UserWardrobeManager {
|
||||
runnable.runTaskTimer(HMCCosmeticsPlugin.getInstance(), 0, 2);
|
||||
}
|
||||
|
||||
private static int getNextYaw(final int current, final int rotationSpeed) {
|
||||
int nextYaw = current + rotationSpeed;
|
||||
if (nextYaw > 179) {
|
||||
nextYaw = (current + rotationSpeed) - 358;
|
||||
return nextYaw;
|
||||
}
|
||||
return nextYaw;
|
||||
}
|
||||
|
||||
public int getArmorstandId() {
|
||||
return ARMORSTAND_ID;
|
||||
}
|
||||
|
||||
@@ -137,4 +137,13 @@ public class ServerUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int getNextYaw(final int current, final int rotationSpeed) {
|
||||
int nextYaw = current + rotationSpeed;
|
||||
if (nextYaw > 179) {
|
||||
nextYaw = (current + rotationSpeed) - 358;
|
||||
return nextYaw;
|
||||
}
|
||||
return nextYaw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ cosmetic-settings:
|
||||
unapply-on-death: false # If when a player dies, their cosmetics should be unapplied. If this is true, use hmccosmetics.unapplydeath.bypass to bypass
|
||||
force-permission-join: true # Checks a player permission if they can have a cosmetic when they join the server.
|
||||
|
||||
emote-distance: -3 # This shows how far away the camera should be while a player is doing an emote. Negative is behind player.
|
||||
|
||||
# view distance in blocks that other players will see the backpack cosmetic
|
||||
# setting this to lower than the server player view distance should fix the
|
||||
# bug where players see random backpacks. Put -1 to ignore and send packets to everyone.
|
||||
|
||||
@@ -17,6 +17,8 @@ unequip-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>You have unequipped <cosme
|
||||
hide-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>Hidden cosmetics"
|
||||
show-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>Revealed cosmetics!"
|
||||
|
||||
emote-blocked: "%prefix% <red>You can not use your emote here!"
|
||||
|
||||
invalid-slot: "%prefix% <red>Invalid cosmetic slot!"
|
||||
invalid-player: "%prefix% <red>Invalid Player!"
|
||||
invalid-menu: "%prefix% <red>Invalid Menu!"
|
||||
|
||||
Reference in New Issue
Block a user