9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-30 12:29:16 +00:00

Emote settings and messages

This commit is contained in:
LoJoSho
2023-02-10 10:49:57 -06:00
parent d5983d8834
commit 300e2cffba
7 changed files with 39 additions and 19 deletions

View File

@@ -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;

View File

@@ -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();

View File

@@ -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();

View File

@@ -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;
}

View File

@@ -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;
}
}