mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-24 09:29:16 +00:00
Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8962539e8 | ||
|
|
01db728b99 | ||
|
|
8525dda6f4 | ||
|
|
e8f7f57e0b | ||
|
|
8c62b47d5b | ||
|
|
2ab0b119e7 | ||
|
|
20d919c65e | ||
|
|
bd41c5b9ff | ||
|
|
60aaf0cff6 | ||
|
|
71c8f8171b | ||
|
|
2bc4e3dd3f | ||
|
|
302eaa13c9 | ||
|
|
23ff51bab8 | ||
|
|
96ee695521 | ||
|
|
a9a587495a | ||
|
|
0b69e20adc | ||
|
|
a08e531226 | ||
|
|
1e27933573 | ||
|
|
0b4815842f | ||
|
|
cc6aec99e0 | ||
|
|
b51bace9f5 | ||
|
|
c70223a800 | ||
|
|
36353b5693 | ||
|
|
d4fc903c14 | ||
|
|
980d2d89df | ||
|
|
c952a8ac08 | ||
|
|
a651c9b8da | ||
|
|
c695e8b2f9 | ||
|
|
ee72bc2ef5 | ||
|
|
ebd47e9b56 | ||
|
|
5cf5e7c543 | ||
|
|
7f2d62b5e5 | ||
|
|
8d07f7cf9f | ||
|
|
789db52b57 | ||
|
|
5fb3458a98 | ||
|
|
f6935ce60b | ||
|
|
913f8ccdf7 |
13
.github/CONTRIBUTING.md
vendored
Normal file
13
.github/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# Contributing
|
||||
|
||||
If you wish to contribute to the HMCCosmetics codebase, feel free to fork the repository and [submit a pull request](https://github.com/HibiscusMC/HMCCosmetics/compare).
|
||||
> **Note** Contributions to the HMCCosmetics codebase should remain consistent with current code style. Remember to keep your code clean, documented and understandable, and to avoid messy or confusing code.
|
||||
|
||||
## Setup
|
||||
|
||||
To get ready to work on the codebase, please do the following:
|
||||
|
||||
1. Fork & clone the repository, and make sure you're on the **remapped** branch. (*This is the default branch*)
|
||||
2. Code your heart out!
|
||||
3. Run `./gradlew build` to ensure your project successfully builds. (*This may take a while*)
|
||||
4. Finally, [submit a pull request](https://github.com/HibiscusMC/HMCCosmetics/compare)!
|
||||
2
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
2
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
@@ -1,7 +1,7 @@
|
||||
name: Feature Request
|
||||
description: Create a feature request to help us keep track of all features you want to be added
|
||||
title: "[FEATURE] <title>"
|
||||
labels: [feature]
|
||||
labels: [enhancement]
|
||||
|
||||
body:
|
||||
- type: "checkboxes"
|
||||
|
||||
@@ -8,7 +8,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "com.hibiscusmc"
|
||||
version = "2.2.6"
|
||||
version = "2.2.7"
|
||||
|
||||
allprojects {
|
||||
apply(plugin = "java")
|
||||
|
||||
@@ -247,14 +247,16 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
|
||||
File[] emotesFiles = emoteFolder.listFiles();
|
||||
for (File emoteFile : emotesFiles) {
|
||||
if (!emoteFile.getName().contains("bbmodel")) continue;
|
||||
String animationName = emoteFile.getName().replaceAll(".bbmodel", "");
|
||||
PlayerAnimator.api.getAnimationManager().importAnimations(FilenameUtils.removeExtension(emoteFile.getName()), emoteFile);
|
||||
String animationName = FilenameUtils.removeExtension(emoteFile.getName());
|
||||
PlayerAnimator.api.getAnimationManager().importAnimations(animationName, emoteFile);
|
||||
MessagesUtil.sendDebugMessages("Added '" + animationName + "' to Player Animator ");
|
||||
}
|
||||
|
||||
/*
|
||||
for (Map.Entry<String, AnimationPack> packEntry : PlayerAnimator.api.getAnimationManager().getRegistry().entrySet()) {
|
||||
//Set<String> animationNames = packEntry.getValue().getAnimations().keySet().stream().map(animation -> packEntry.getKey().replace(":", ".") + "." + animation).collect(Collectors.toSet());
|
||||
Set<String> animationNames = packEntry.getValue().getAnimations().keySet().stream().map(animation -> packEntry.getKey().replace(":", ".") + "." + animation).collect(Collectors.toSet());
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
getInstance().getLogger().info("Successfully Enabled HMCCosmetics");
|
||||
|
||||
@@ -2,10 +2,13 @@ package com.hibiscusmc.hmccosmetics.config;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Settings {
|
||||
|
||||
// General Settings
|
||||
@@ -36,7 +39,8 @@ public class Settings {
|
||||
private static final String HOOK_ITEMADDER_PATH = "itemsadder";
|
||||
private static final String HOOK_RELOAD_CHANGE_PATH = "reload-on-change";
|
||||
private static final String HOOK_WORLDGUARD_PATH = "worldguard";
|
||||
private static final String HOOK_WG_MOVE_CHECK_PATH = "player_move_check";
|
||||
private static final String HOOK_WG_MOVE_CHECK_PATH = "player-move-check";
|
||||
private static final String HOOK_WG_MOVE_CHECK_PATH_LEGACY = "player_move_check";
|
||||
private static final String COSMETIC_EMOTE_CHECK_PATH = "emote-block-check";
|
||||
private static final String COSMETIC_EMOTE_DAMAGE_PATH = "emote-damage-leave";
|
||||
private static final String COSMETIC_EMOTE_INVINCIBLE_PATH = "emote-invincible";
|
||||
@@ -44,6 +48,7 @@ public class Settings {
|
||||
private static final String COSMETIC_ADD_ENCHANTS_CHESTPLATE_PATH = "chest-add-enchantments";
|
||||
private static final String COSMETIC_ADD_ENCHANTS_LEGGINGS_PATH = "leggings-add-enchantments";
|
||||
private static final String COSMETIC_ADD_ENCHANTS_BOOTS_PATH = "boots-add-enchantments";
|
||||
private static final String COSMETIC_DESTROY_LOOSE_COSMETIC_PATH = "destroy-loose-cosmetics";
|
||||
|
||||
private static String defaultMenu;
|
||||
private static String dyeMenuName;
|
||||
@@ -67,6 +72,7 @@ public class Settings {
|
||||
private static boolean addBootsEnchants;
|
||||
private static boolean emoteDamageLeave;
|
||||
private static boolean emoteInvincible;
|
||||
private static boolean destroyLooseCosmetics;
|
||||
private static int lookDownPitch;
|
||||
private static int viewDistance;
|
||||
private static int tickPeriod;
|
||||
@@ -101,6 +107,7 @@ public class Settings {
|
||||
cosmeticEmoteBlockCheck = cosmeticSettings.node(COSMETIC_EMOTE_CHECK_PATH).getBoolean(true);
|
||||
emoteDamageLeave = cosmeticSettings.node(COSMETIC_EMOTE_DAMAGE_PATH).getBoolean(false);
|
||||
emoteInvincible = cosmeticSettings.node(COSMETIC_EMOTE_INVINCIBLE_PATH).getBoolean(false);
|
||||
destroyLooseCosmetics = cosmeticSettings.node(COSMETIC_DESTROY_LOOSE_COSMETIC_PATH).getBoolean(false);
|
||||
addHelmetEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_HELMET_PATH).getBoolean(false);
|
||||
addChestplateEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_CHESTPLATE_PATH).getBoolean(false);
|
||||
addLeggingEnchants = cosmeticSettings.node(COSMETIC_ADD_ENCHANTS_LEGGINGS_PATH).getBoolean(false);
|
||||
@@ -126,6 +133,11 @@ public class Settings {
|
||||
|
||||
ConfigurationNode worldGuardSettings = hookSettings.node(HOOK_WORLDGUARD_PATH);
|
||||
worldGuardMoveCheck = worldGuardSettings.node(HOOK_WG_MOVE_CHECK_PATH).getBoolean(true);
|
||||
// I messed up in release 2.2.6 and forgot to change player_move_check to player-move-check.
|
||||
if (!worldGuardSettings.node(HOOK_WG_MOVE_CHECK_PATH_LEGACY).virtual()) {
|
||||
MessagesUtil.sendDebugMessages("There is a deprecated way of using WG hook setting. Change player_move_check to player-move-check in your configuration to prevent issues in the future. ", Level.WARNING);
|
||||
worldGuardMoveCheck = worldGuardSettings.node(HOOK_WG_MOVE_CHECK_PATH_LEGACY).getBoolean(true);
|
||||
}
|
||||
}
|
||||
|
||||
private static Vector loadVector(final ConfigurationNode config) {
|
||||
@@ -263,6 +275,10 @@ public class Settings {
|
||||
return worldGuardMoveCheck;
|
||||
}
|
||||
|
||||
public static boolean isDestroyLooseCosmetics() {
|
||||
return destroyLooseCosmetics;
|
||||
}
|
||||
|
||||
public static boolean getShouldAddEnchants(EquipmentSlot slot) {
|
||||
switch (slot) {
|
||||
case HEAD -> {
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.misc.Utils;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
@@ -29,6 +30,9 @@ public class WardrobeSettings {
|
||||
private static final String LEAVE_LOCATION_PATH = "leave-location";
|
||||
private static final String EQUIP_PUMPKIN_WARDROBE = "equip-pumpkin";
|
||||
private static final String RETURN_LAST_LOCATION = "return-last-location";
|
||||
private static final String GAMEMODE_OPTIONS_PATH = "gamemode-options";
|
||||
private static final String FORCE_EXIT_GAMEMODE_PATH = "exit-gamemode-enabled";
|
||||
private static final String EXIT_GAMEMODE_PATH = "exit-gamemode";
|
||||
private static final String BOSSBAR_PATH = "bossbar";
|
||||
private static final String BOSSBAR_ENABLE_PATH = "enabled";
|
||||
private static final String BOSSBAR_TEXT_PATH = "text";
|
||||
@@ -57,6 +61,8 @@ public class WardrobeSettings {
|
||||
private static boolean equipPumpkin;
|
||||
private static boolean returnLastLocation;
|
||||
private static boolean enabledBossbar;
|
||||
private static boolean forceExitGamemode;
|
||||
private static GameMode exitGamemode;
|
||||
private static Location wardrobeLocation;
|
||||
private static Location viewerLocation;
|
||||
private static Location leaveLocation;
|
||||
@@ -85,6 +91,10 @@ public class WardrobeSettings {
|
||||
equipPumpkin = source.node(EQUIP_PUMPKIN_WARDROBE).getBoolean();
|
||||
returnLastLocation = source.node(RETURN_LAST_LOCATION).getBoolean(false);
|
||||
|
||||
ConfigurationNode gamemodeNode = source.node(GAMEMODE_OPTIONS_PATH);
|
||||
forceExitGamemode = gamemodeNode.node(FORCE_EXIT_GAMEMODE_PATH).getBoolean(false);
|
||||
exitGamemode = GameMode.valueOf(gamemodeNode.node(EXIT_GAMEMODE_PATH).getString("SURVIVAL"));
|
||||
|
||||
ConfigurationNode bossBarNode = source.node(BOSSBAR_PATH);
|
||||
enabledBossbar = bossBarNode.node(BOSSBAR_ENABLE_PATH).getBoolean(false);
|
||||
bossbarProgress = bossBarNode.node(BOSSBAR_PROGRESS_PATH).getFloat(1.0f);
|
||||
@@ -227,6 +237,14 @@ public class WardrobeSettings {
|
||||
return transitionFadeOut;
|
||||
}
|
||||
|
||||
public static boolean isForceExitGamemode() {
|
||||
return forceExitGamemode;
|
||||
}
|
||||
|
||||
public static GameMode getExitGamemode() {
|
||||
return exitGamemode;
|
||||
}
|
||||
|
||||
public static void setWardrobeLocation(Location newLocation) {
|
||||
wardrobeLocation = newLocation;
|
||||
|
||||
|
||||
@@ -19,12 +19,15 @@ public class CosmeticBalloonType extends Cosmetic {
|
||||
|
||||
private final String modelName;
|
||||
private List<String> dyableParts;
|
||||
private boolean showLead;
|
||||
|
||||
public CosmeticBalloonType(String id, ConfigurationNode config) {
|
||||
super(id, config);
|
||||
|
||||
String modelId = config.node("model").getString();
|
||||
|
||||
showLead = config.node("show-lead").getBoolean(true);
|
||||
|
||||
try {
|
||||
if (!config.node("dyable-parts").virtual()) {
|
||||
dyableParts = config.node("dyable-parts").getList(String.class);
|
||||
@@ -68,7 +71,7 @@ public class CosmeticBalloonType extends Cosmetic {
|
||||
userBalloonManager.setLocation(newLocation);
|
||||
|
||||
PacketManager.sendTeleportPacket(userBalloonManager.getPufferfishBalloonId(), newLocation, false, viewer);
|
||||
if (!user.getHidden()) PacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), player.getEntityId(), viewer);
|
||||
if (!user.getHidden() && showLead) PacketManager.sendLeashPacket(userBalloonManager.getPufferfishBalloonId(), player.getEntityId(), viewer);
|
||||
}
|
||||
|
||||
public String getModelName() {
|
||||
@@ -85,4 +88,8 @@ public class CosmeticBalloonType extends Cosmetic {
|
||||
if (dyableParts.isEmpty()) return true;
|
||||
return dyableParts.contains(name);
|
||||
}
|
||||
|
||||
public boolean isShowLead() {
|
||||
return showLead;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,10 @@ import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.TranslationUtil;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
@@ -116,13 +118,29 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion {
|
||||
return null;
|
||||
}
|
||||
if (placeholderArgs.get(1) != null) {
|
||||
Cosmetic cosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1));
|
||||
if (cosmetic == null) {
|
||||
Cosmetic secondAttemptCosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1) + "_" + placeholderArgs.get(2));
|
||||
if (secondAttemptCosmetic == null) {
|
||||
return "INVALID_COSMETIC";
|
||||
String args1 = placeholderArgs.get(1);
|
||||
|
||||
if (EnumUtils.isValidEnum(CosmeticSlot.class, args1.toUpperCase())) {
|
||||
if (user.getCosmetic(CosmeticSlot.valueOf(args1.toUpperCase())) != null) {
|
||||
return "true";
|
||||
} else {
|
||||
cosmetic = secondAttemptCosmetic;
|
||||
return "false";
|
||||
}
|
||||
}
|
||||
|
||||
MessagesUtil.sendDebugMessages(args1);
|
||||
|
||||
Cosmetic cosmetic = Cosmetics.getCosmetic(args1);
|
||||
if (cosmetic == null) {
|
||||
if (placeholderArgs.size() == 3) {
|
||||
Cosmetic secondAttemptCosmetic = Cosmetics.getCosmetic(placeholderArgs.get(1) + "_" + placeholderArgs.get(2));
|
||||
if (secondAttemptCosmetic == null) {
|
||||
return "INVALID_COSMETIC";
|
||||
} else {
|
||||
cosmetic = secondAttemptCosmetic;
|
||||
}
|
||||
} else {
|
||||
return "INVALID_COSMETIC";
|
||||
}
|
||||
}
|
||||
if (user.getCosmetic(cosmetic.getSlot()) == null) return "false";
|
||||
|
||||
@@ -58,6 +58,7 @@ public class PlayerConnectionListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (user.isInWardrobe()) user.leaveWardrobe();
|
||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.bukkit.entity.Pose;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
@@ -62,12 +61,20 @@ public class PlayerGameListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerClick(@NotNull InventoryClickEvent event) {
|
||||
if (event.getClick() != ClickType.SHIFT_LEFT && event.getClick() != ClickType.SHIFT_RIGHT) return;
|
||||
// || !event.getClickedInventory().getType().equals(InventoryType.PLAYER)
|
||||
if (event.getClick().isShiftClick()) return;
|
||||
MessagesUtil.sendDebugMessages("inventoryclickevent");
|
||||
//if (event.getSlotType() != InventoryType.SlotType.ARMOR) return;
|
||||
CosmeticUser user = CosmeticUsers.getUser(event.getWhoClicked().getUniqueId());
|
||||
if (user == null) return;
|
||||
ItemStack item = event.getCurrentItem();
|
||||
if (item == null) return;
|
||||
|
||||
if (Settings.isDestroyLooseCosmetics() && InventoryUtils.isCosmeticItem(event.getCurrentItem())) {
|
||||
MessagesUtil.sendDebugMessages("remvoe item");
|
||||
event.getWhoClicked().getInventory().removeItem(event.getCurrentItem());
|
||||
}
|
||||
|
||||
EquipmentSlot slot = getArmorSlot(item.getType());
|
||||
if (slot == null) return;
|
||||
CosmeticSlot cosmeticSlot = InventoryUtils.BukkitCosmeticSlot(slot);
|
||||
@@ -123,6 +130,9 @@ public class PlayerGameListener implements Listener {
|
||||
user.spawnBalloon(cosmeticBalloonType);
|
||||
}, 2);
|
||||
}
|
||||
if (user.getUserEmoteManager().isPlayingEmote()) {
|
||||
user.getUserEmoteManager().stopEmote(UserEmoteManager.StopEmoteReason.TELEPORT);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -198,10 +208,12 @@ public class PlayerGameListener implements Listener {
|
||||
if (pose.equals(Pose.STANDING)) {
|
||||
// #84, Riptides mess with backpacks
|
||||
ItemStack currentItem = player.getInventory().getItemInMainHand();
|
||||
if (currentItem == null) return;
|
||||
if (!currentItem.hasItemMeta()) return;
|
||||
if (currentItem.containsEnchantment(Enchantment.RIPTIDE)) {
|
||||
return;
|
||||
if (currentItem != null) {
|
||||
if (currentItem.hasItemMeta()) {
|
||||
if (currentItem.containsEnchantment(Enchantment.RIPTIDE)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!user.isBackpackSpawned()) {
|
||||
|
||||
@@ -18,13 +18,11 @@ import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.*;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.*;
|
||||
@@ -212,6 +210,8 @@ public class CosmeticUser {
|
||||
mapMeta.setColor(color);
|
||||
}
|
||||
}
|
||||
itemMeta.getPersistentDataContainer().set(InventoryUtils.getKey(), PersistentDataType.STRING, "true");
|
||||
|
||||
item.setItemMeta(itemMeta);
|
||||
}
|
||||
return item;
|
||||
@@ -322,8 +322,6 @@ public class CosmeticUser {
|
||||
|
||||
List<Player> viewer = PlayerUtils.getNearbyPlayers(player);
|
||||
viewer.add(player);
|
||||
|
||||
PacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), player.getEntityId(), viewer);
|
||||
}
|
||||
|
||||
public void despawnBalloon() {
|
||||
@@ -408,8 +406,7 @@ public class CosmeticUser {
|
||||
hiddenReason = reason;
|
||||
if (hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||
getBalloonManager().removePlayerFromModel(getPlayer());
|
||||
List<Player> viewer = PlayerUtils.getNearbyPlayers(getPlayer());
|
||||
PacketManager.sendLeashPacket(getBalloonManager().getPufferfishBalloonId(), -1, viewer);
|
||||
getBalloonManager().sendRemoveLeashPacket();
|
||||
}
|
||||
if (hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||
userBackpackManager.clearItems();
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticBalloonType;
|
||||
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
|
||||
import com.hibiscusmc.hmccosmetics.util.PlayerUtils;
|
||||
import com.hibiscusmc.hmccosmetics.util.packets.PacketManager;
|
||||
import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||
@@ -17,12 +19,14 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class UserBalloonManager {
|
||||
|
||||
private BalloonType balloonType;
|
||||
private CosmeticBalloonType cosmeticBalloonType;
|
||||
private final int balloonID;
|
||||
private final UUID uniqueID;
|
||||
private final ArmorStand modelEntity;
|
||||
@@ -44,6 +48,7 @@ public class UserBalloonManager {
|
||||
balloonType = BalloonType.NONE;
|
||||
}
|
||||
}
|
||||
this.cosmeticBalloonType = cosmeticBalloonType;
|
||||
MessagesUtil.sendDebugMessages("balloontype is " + balloonType);
|
||||
|
||||
if (balloonType == BalloonType.MODELENGINE) {
|
||||
@@ -85,6 +90,7 @@ public class UserBalloonManager {
|
||||
}
|
||||
|
||||
modelEntity.remove();
|
||||
cosmeticBalloonType = null;
|
||||
}
|
||||
|
||||
public void addPlayerToModel(final CosmeticUser user, final CosmeticBalloonType cosmeticBalloonType) {
|
||||
@@ -156,6 +162,19 @@ public class UserBalloonManager {
|
||||
this.getModelEntity().setVelocity(vector);
|
||||
}
|
||||
|
||||
public void sendRemoveLeashPacket(List<Player> viewer) {
|
||||
PacketManager.sendLeashPacket(getPufferfishBalloonId(), -1, viewer);
|
||||
}
|
||||
|
||||
public void sendRemoveLeashPacket() {
|
||||
PacketManager.sendLeashPacket(getPufferfishBalloonId(), -1, getLocation());
|
||||
}
|
||||
|
||||
public void sendLeashPacket(int entityId) {
|
||||
if (cosmeticBalloonType == null) return;
|
||||
if (cosmeticBalloonType.isShowLead()) PacketManager.sendLeashPacket(getPufferfishBalloonId(), entityId, getLocation());
|
||||
}
|
||||
|
||||
public enum BalloonType {
|
||||
MODELENGINE,
|
||||
ITEM,
|
||||
|
||||
@@ -60,6 +60,7 @@ public class UserEmoteManager {
|
||||
public enum StopEmoteReason {
|
||||
SNEAK,
|
||||
DAMAGE,
|
||||
CONNECTION
|
||||
CONNECTION,
|
||||
TELEPORT
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,8 +109,8 @@ public class UserWardrobeManager {
|
||||
}
|
||||
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||
PacketManager.sendLeashPacket(user.getBalloonManager().getPufferfishBalloonId(), -1, viewer);
|
||||
PacketManager.sendLeashPacket(user.getBalloonManager().getPufferfishBalloonId(), NPC_ID, viewer); // This needs a possible fix
|
||||
user.getBalloonManager().sendRemoveLeashPacket(viewer);
|
||||
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
||||
//PacketManager.sendLeashPacket(VIEWER.getBalloonEntity().getModelId(), NPC_ID, viewer);
|
||||
|
||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), npcLocation.clone().add(Settings.getBalloonOffset()), false, viewer);
|
||||
@@ -162,19 +162,26 @@ public class UserWardrobeManager {
|
||||
this.active = false;
|
||||
|
||||
// NPC
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) PacketManager.sendLeashPacket(user.getBalloonManager().getModelId(), -1, viewer);
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) user.getBalloonManager().sendRemoveLeashPacket();
|
||||
PacketManager.sendEntityDestroyPacket(NPC_ID, viewer); // Success
|
||||
PacketManager.sendRemovePlayerPacket(player, WARDROBE_UUID, viewer); // Success
|
||||
|
||||
// Player
|
||||
PacketManager.sendCameraPacket(player.getEntityId(), viewer);
|
||||
PacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(this.originalGamemode)); // Success
|
||||
|
||||
// Armorstand
|
||||
PacketManager.sendEntityDestroyPacket(ARMORSTAND_ID, viewer); // Sucess
|
||||
|
||||
//PacketManager.sendEntityDestroyPacket(player.getEntityId(), viewer); // Success
|
||||
player.setGameMode(this.originalGamemode);
|
||||
if (WardrobeSettings.isForceExitGamemode()) {
|
||||
MessagesUtil.sendDebugMessages("Force Exit Gamemode " + WardrobeSettings.getExitGamemode());
|
||||
player.setGameMode(WardrobeSettings.getExitGamemode());
|
||||
PacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(WardrobeSettings.getExitGamemode())); // Success
|
||||
} else {
|
||||
MessagesUtil.sendDebugMessages("Original Gamemode " + this.originalGamemode);
|
||||
player.setGameMode(this.originalGamemode);
|
||||
PacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(this.originalGamemode)); // Success
|
||||
}
|
||||
user.showPlayer();
|
||||
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) {
|
||||
@@ -254,9 +261,9 @@ public class UserWardrobeManager {
|
||||
if (user.hasCosmeticInSlot(CosmeticSlot.BALLOON)) {
|
||||
PacketManager.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()), false, viewer);
|
||||
user.getBalloonManager().getModelEntity().teleport(WardrobeSettings.getWardrobeLocation().add(Settings.getBalloonOffset()));
|
||||
PacketManager.sendLeashPacket(user.getBalloonManager().getPufferfishBalloonId(), -1, outsideViewers);
|
||||
user.getBalloonManager().sendRemoveLeashPacket(outsideViewers);
|
||||
PacketManager.sendEntityDestroyPacket(user.getBalloonManager().getModelId(), outsideViewers);
|
||||
PacketManager.sendLeashPacket(user.getBalloonManager().getPufferfishBalloonId(), NPC_ID, viewer); // Pufferfish goes away for some reason?
|
||||
user.getBalloonManager().sendLeashPacket(NPC_ID);
|
||||
}
|
||||
|
||||
if (WardrobeSettings.isEquipPumpkin()) {
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package com.hibiscusmc.hmccosmetics.util;
|
||||
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
|
||||
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -137,4 +141,14 @@ public class InventoryUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isCosmeticItem(ItemStack itemStack) {
|
||||
itemStack = itemStack.clone();
|
||||
if (!itemStack.hasItemMeta()) return false;
|
||||
return itemStack.getItemMeta().getPersistentDataContainer().has(getKey(), PersistentDataType.STRING);
|
||||
}
|
||||
|
||||
public static NamespacedKey getKey() {
|
||||
return new NamespacedKey(HMCCosmeticsPlugin.getInstance(), "cosmetic");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,10 @@ cosmetic-settings:
|
||||
leggings-add-enchantments: false # If the plugin should keep enchants on leggings. This is useful as some enchantments are client side only.
|
||||
boots-add-enchantments: false # If the plugin should keep enchants on boots. This is useful as some enchantments are client side only.
|
||||
|
||||
# This attempts to destroy cosmetics that get loose in the wild, such as through a player entering creative mode.
|
||||
# Most servers who don't use creative mode and have properly set up the plugin should have no need for this and can leave it disabled.
|
||||
destroy-loose-cosmetics: false
|
||||
|
||||
# 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.
|
||||
@@ -56,7 +60,7 @@ hook-settings:
|
||||
worldguard:
|
||||
# Checks worldguard regions for HMCC flags. If set to false, flags will not work properly.
|
||||
# Requires restart to apply changes.
|
||||
player_move_check: true
|
||||
player-move-check: true
|
||||
wardrobe:
|
||||
# spawn static wardrobe if in this radius of wardrobe-location
|
||||
static-radius: 10
|
||||
@@ -66,6 +70,11 @@ wardrobe:
|
||||
equip-pumpkin: false
|
||||
# Rather than having a set exit location, this will send the player back to where they entered the wardrobe. Not recommended for WG regions
|
||||
return-last-location: false
|
||||
|
||||
gamemode-options:
|
||||
exit-gamemode-enabled: false # Setting this to false will set the gamemode the player came in as. True sets to exit-gamemode gamemode
|
||||
exit-gamemode: "SURVIVAL" # Only activates if force-exit-gamemode is true, find gamemodes here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/GameMode.html
|
||||
|
||||
# Bossbar that shows when a player is in a wardrobe.
|
||||
bossbar:
|
||||
enabled: false
|
||||
|
||||
@@ -110,4 +110,23 @@ explorer_backpack:
|
||||
material: LEATHER_HORSE_ARMOR
|
||||
model-data: 3
|
||||
name: "<white>Explorer's Backpack"
|
||||
amount: 1
|
||||
garbage_truck_balloon:
|
||||
slot: BALLOON
|
||||
permission: "hmccosmetics.garbage_truck_balloon"
|
||||
model: garbage_truck_balloon
|
||||
item:
|
||||
material: PAPER
|
||||
model-data: 14
|
||||
name: "<green>Garbage Truck Balloon"
|
||||
amount: 1
|
||||
earth_day_grabber:
|
||||
slot: OFFHAND
|
||||
dyeable: true
|
||||
permission: "hmccosmetics.earth_day_grabber"
|
||||
model: earth_day_grabber
|
||||
item:
|
||||
material: LEATHER_HORSE_ARMOR
|
||||
model-data: 4
|
||||
name: "<green>Earth Day Grabber"
|
||||
amount: 1
|
||||
@@ -167,4 +167,26 @@ items:
|
||||
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_explorer_backpack%"
|
||||
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_explorer_backpack%"
|
||||
type: cosmetic
|
||||
cosmetic: explorer_backpack
|
||||
cosmetic: explorer_backpack
|
||||
garbage_truck_balloon:
|
||||
slots:
|
||||
- 16
|
||||
item:
|
||||
material: hmccosmetics:garbage_truck_balloon
|
||||
lore:
|
||||
- ""
|
||||
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_garbage_truck_balloon%"
|
||||
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_garbage_truck_balloon%"
|
||||
type: cosmetic
|
||||
cosmetic: garbage_truck_balloon
|
||||
earth_day_grabber:
|
||||
slots:
|
||||
- 17
|
||||
item:
|
||||
material: hmccosmetics:earth_day_grabber
|
||||
lore:
|
||||
- ""
|
||||
- "<gray>Enabled: <#6D9DC5>%HMCCosmetics_equipped_earth_day_grabber%"
|
||||
- "<gray>Allowed: <#6D9DC5>%HMCCosmetics_unlocked_earth_day_grabber%"
|
||||
type: cosmetic
|
||||
cosmetic: earth_day_grabber
|
||||
@@ -113,7 +113,7 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
|
||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||
PacketManager.sendLeashPacket(userBalloonManager1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
|
||||
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||
|
||||
return userBalloonManager1;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
|
||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||
PacketManager.sendLeashPacket(userBalloonManager1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
|
||||
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||
|
||||
return userBalloonManager1;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
|
||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||
PacketManager.sendLeashPacket(userBalloonManager1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
|
||||
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||
|
||||
return userBalloonManager1;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
|
||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||
PacketManager.sendLeashPacket(userBalloonManager1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
|
||||
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||
|
||||
return userBalloonManager1;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class NMSHandler implements com.hibiscusmc.hmccosmetics.nms.NMSHandler {
|
||||
|
||||
PacketManager.sendEntitySpawnPacket(newLoc, userBalloonManager1.getPufferfishBalloonId(), EntityType.PUFFERFISH, userBalloonManager1.getPufferfishBalloonUniqueId(), sentTo);
|
||||
PacketManager.sendInvisibilityPacket(userBalloonManager1.getPufferfishBalloonId(), sentTo);
|
||||
PacketManager.sendLeashPacket(userBalloonManager1.getPufferfishBalloonId(), player.getEntityId(), sentTo);
|
||||
userBalloonManager1.sendLeashPacket(player.getEntityId());
|
||||
|
||||
return userBalloonManager1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user