diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index 80bd9982..bf224e9a 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -106,5 +106,15 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
deleted file mode 100644
index 797acea5..00000000
--- a/.idea/runConfigurations.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/1.16/build/libs/1.16.jar b/1.16/build/libs/1.16.jar
index c477ccb6..456d1bdd 100644
Binary files a/1.16/build/libs/1.16.jar and b/1.16/build/libs/1.16.jar differ
diff --git a/1.16/build/tmp/compileJava/previous-compilation-data.bin b/1.16/build/tmp/compileJava/previous-compilation-data.bin
index c3a9ed58..eae32342 100644
Binary files a/1.16/build/tmp/compileJava/previous-compilation-data.bin and b/1.16/build/tmp/compileJava/previous-compilation-data.bin differ
diff --git a/1.17/build/libs/1.17.jar b/1.17/build/libs/1.17.jar
index d9f2ca57..c5a33b8a 100644
Binary files a/1.17/build/libs/1.17.jar and b/1.17/build/libs/1.17.jar differ
diff --git a/1.17/build/tmp/compileJava/previous-compilation-data.bin b/1.17/build/tmp/compileJava/previous-compilation-data.bin
index eb007f33..380d6dd3 100644
Binary files a/1.17/build/tmp/compileJava/previous-compilation-data.bin and b/1.17/build/tmp/compileJava/previous-compilation-data.bin differ
diff --git a/1.18/build/libs/1.18.jar b/1.18/build/libs/1.18.jar
index 6ef03483..332fcbfe 100644
Binary files a/1.18/build/libs/1.18.jar and b/1.18/build/libs/1.18.jar differ
diff --git a/common/build.gradle.kts b/common/build.gradle.kts
index 0d9aaf71..f72c1e62 100644
--- a/common/build.gradle.kts
+++ b/common/build.gradle.kts
@@ -20,6 +20,7 @@ repositories {
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
maven("https://mvnrepository.com/artifact/com.zaxxer/HikariCP")
maven("https://repo.jeff-media.de/maven2/")
+ maven("https://repo.citizensnpcs.co");
}
dependencies {
@@ -34,6 +35,7 @@ dependencies {
compileOnly("me.clip:placeholderapi:2.11.1")
compileOnly("com.github.oraxen:oraxen:-SNAPSHOT")
compileOnly("com.github.LoneDev6:API-ItemsAdder:2.5.4")
+ compileOnly("net.citizensnpcs:citizens-main:2.0.29-SNAPSHOT")
implementation("net.kyori:adventure-api:4.9.3")
implementation ("net.kyori:adventure-text-minimessage:4.10.0-SNAPSHOT")
implementation("net.kyori:adventure-platform-bukkit:4.0.1")
diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/ActionSerializer.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/ActionSerializer.class
index f8580740..604f872d 100644
Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/ActionSerializer.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/ActionSerializer.class differ
diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/WardrobeSettings.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/WardrobeSettings.class
index 06691456..9334643b 100644
Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/WardrobeSettings.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/WardrobeSettings.class differ
diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/CosmeticGui.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/CosmeticGui.class
index b38dff38..e2b48ec2 100644
Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/CosmeticGui.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/CosmeticGui.class differ
diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/DyeSelectorGui.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/DyeSelectorGui.class
index 52b45b48..ece3b922 100644
Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/DyeSelectorGui.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/DyeSelectorGui.class differ
diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/user/User.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/user/User.class
index 09d158a0..c89b34c2 100644
Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/user/User.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/user/User.class differ
diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/user/Wardrobe.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/user/Wardrobe.class
index 0cdfb743..1c952ed5 100644
Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/user/Wardrobe.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/user/Wardrobe.class differ
diff --git a/common/build/libs/HMCCosmetics.jar b/common/build/libs/HMCCosmetics.jar
index 280cb2a5..565392d1 100644
Binary files a/common/build/libs/HMCCosmetics.jar and b/common/build/libs/HMCCosmetics.jar differ
diff --git a/common/build/resources/main/config.yml b/common/build/resources/main/config.yml
index 8ddeebc9..b796fd5b 100644
--- a/common/build/resources/main/config.yml
+++ b/common/build/resources/main/config.yml
@@ -26,6 +26,10 @@ wardrobe:
static-radius: 10
# how much yaw should change per tick, set to 0 for none
rotation-speed: 3
+ # how long in seconds until the wardrobe should be spawned
+ spawn-delay: 0
+ # how long in seconds until the wardrobe should be despawned
+ despawn-delay: 0
# location of static wardrobe, remove for none
wardrobe-location:
world: "World"
diff --git a/common/build/tmp/compileJava/previous-compilation-data.bin b/common/build/tmp/compileJava/previous-compilation-data.bin
index 3c7b0c71..259d1b58 100644
Binary files a/common/build/tmp/compileJava/previous-compilation-data.bin and b/common/build/tmp/compileJava/previous-compilation-data.bin differ
diff --git a/common/src/main/java/io/github/fisher2911/hmccosmetics/user/BaseUser.java b/common/src/main/java/io/github/fisher2911/hmccosmetics/user/BaseUser.java
new file mode 100644
index 00000000..c7828f4a
--- /dev/null
+++ b/common/src/main/java/io/github/fisher2911/hmccosmetics/user/BaseUser.java
@@ -0,0 +1,195 @@
+package io.github.fisher2911.hmccosmetics.user;
+
+import com.comphenix.protocol.events.PacketContainer;
+import com.comphenix.protocol.wrappers.EnumWrappers;
+import com.comphenix.protocol.wrappers.Pair;
+import io.github.fisher2911.hmccosmetics.config.CosmeticSettings;
+import io.github.fisher2911.hmccosmetics.config.Settings;
+import io.github.fisher2911.hmccosmetics.gui.ArmorItem;
+import io.github.fisher2911.hmccosmetics.inventory.PlayerArmor;
+import io.github.fisher2911.hmccosmetics.packet.PacketManager;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.entity.EntityType;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+import java.util.UUID;
+
+public abstract class BaseUser {
+
+ protected final UUID uuid;
+ protected final int entityId;
+ protected final PlayerArmor playerArmor;
+
+ protected ArmorItem lastSetItem = ArmorItem.empty(ArmorItem.Type.HAT);
+
+ protected boolean hasArmorStand;
+ protected final int armorStandId;
+
+ // List of players that are currently viewing the armor stand
+ protected final Set viewing = new HashSet<>();
+
+ public BaseUser(final UUID uuid, final int entityId, final PlayerArmor playerArmor, final int armorStandId) {
+ this.uuid = uuid;
+ this.entityId = entityId;
+ this.playerArmor = playerArmor;
+ this.armorStandId = armorStandId;
+ }
+
+ @Nullable
+ public abstract Location getLocation();
+
+ public UUID getUuid() {
+ return this.uuid;
+ }
+
+ public PlayerArmor getPlayerArmor() {
+ return playerArmor;
+ }
+
+ protected void setPlayerArmor(final PlayerArmor playerArmor) {
+ for (final ArmorItem armorItem : playerArmor.getArmorItems()) {
+ this.playerArmor.setItem(armorItem);
+ }
+ }
+
+ protected void removeAllCosmetics() {
+ for (final ArmorItem.Type type : ArmorItem.Type.values()) {
+ this.removeItem(type);
+ }
+ }
+
+ public int getArmorStandId() {
+ return armorStandId;
+ }
+
+ protected ArmorItem setItem(final ArmorItem armorItem) {
+ this.lastSetItem = armorItem;
+ return this.playerArmor.setItem(armorItem);
+ }
+
+ protected ArmorItem removeItem(final ArmorItem.Type type) {
+ return this.setItem(ArmorItem.empty(type));
+ }
+
+ public void spawnArmorStand(final Player other, final Location location, final CosmeticSettings settings) {
+ if (!this.isInViewDistance(this.getLocation(), other.getLocation(), settings) || !shouldShow(other)) return;
+
+ final PacketContainer packet = PacketManager.getEntitySpawnPacket(location, this.armorStandId, EntityType.ARMOR_STAND);
+ this.viewing.add(other.getUniqueId());
+ PacketManager.sendPacket(other, packet);
+ }
+
+ public void spawnArmorStand(final Settings settings) {
+ if (this.hasArmorStand) {
+ this.updateArmorStand(settings);
+ return;
+ }
+
+ for (final Player p : Bukkit.getOnlinePlayers()) {
+ this.spawnArmorStand(p, this.getLocation(), settings.getCosmeticSettings());
+ }
+
+ this.hasArmorStand = true;
+ }
+
+ public void updateArmorStand(final Settings settings) {
+ if (!this.hasArmorStand) {
+ this.spawnArmorStand(settings);
+ }
+ for (final Player player : Bukkit.getOnlinePlayers()) {
+ this.updateArmorStand(player, settings);
+ }
+ }
+
+ public void updateArmorStand(final Player other, final Settings settings) {
+ this.updateArmorStand(other, settings, this.getLocation());
+ }
+
+ public void updateArmorStand(final Player other, final Settings settings, final Location location) {
+ final boolean inViewDistance = this.isInViewDistance(this.getLocation(), other.getLocation(), settings.getCosmeticSettings());
+ if (!this.viewing.contains(other.getUniqueId())) {
+ if (!inViewDistance || !shouldShow(other)) return;
+ this.spawnArmorStand(other, location, settings.getCosmeticSettings());
+ } else if (!inViewDistance || !shouldShow(other)) {
+ this.despawnAttached(other);
+ this.viewing.remove(other.getUniqueId());
+ return;
+ }
+ final List> equipmentList = new ArrayList<>();
+ final boolean hidden = !this.shouldShow(other);
+ if (hidden) {
+ equipmentList.add(new Pair<>(EnumWrappers.ItemSlot.HEAD,
+ new ItemStack(Material.AIR)
+ ));
+ } else {
+ equipmentList.add(new Pair<>(EnumWrappers.ItemSlot.HEAD,
+ this.playerArmor.getBackpack().getColored()
+ ));
+ }
+
+ final PacketContainer armorPacket = PacketManager.getEquipmentPacket(equipmentList, this.armorStandId);
+ final PacketContainer rotationPacket = PacketManager.getRotationPacket(this.armorStandId, location);
+ final PacketContainer ridingPacket = PacketManager.getRidingPacket(this.getEntityId(), this.armorStandId);
+ final PacketContainer armorStandMetaContainer = PacketManager.getArmorStandMetaContainer(this.armorStandId);
+
+ PacketManager.sendPacket(other, armorPacket, armorStandMetaContainer, rotationPacket, ridingPacket);
+
+ if (hidden) return;
+
+ final int lookDownPitch = settings.getCosmeticSettings().getLookDownPitch();
+
+ if (lookDownPitch != -1 &&
+ this.isFacingDown(location, lookDownPitch)) {
+ equipmentList.set(0, new Pair<>(EnumWrappers.ItemSlot.HEAD,
+ new ItemStack(Material.AIR)
+ ));
+
+ if (!this.uuid.equals(other.getUniqueId())) return;
+ PacketManager.sendPacket(other, PacketManager.getEquipmentPacket(equipmentList, this.armorStandId));
+ }
+ }
+
+ public abstract boolean shouldShow(final Player other);
+
+ protected boolean isInViewDistance(final Location location, final Location other, final CosmeticSettings settings) {
+ if (!Objects.equals(other.getWorld(), location.getWorld())) return false;
+ return !(other.distanceSquared(location) > settings.getViewDistance() * settings.getViewDistance());
+ }
+
+ protected boolean isFacingDown(final Location location, final int pitchLimit) {
+ return location.getPitch() > pitchLimit;
+ }
+
+ public void despawnAttached(final Player other) {
+ PacketManager.sendPacket(other, PacketManager.getEntityDestroyPacket(this.armorStandId));
+ this.viewing.remove(other.getUniqueId());
+ this.hasArmorStand = false;
+ }
+
+ public void despawnAttached() {
+ PacketManager.sendPacketToOnline(PacketManager.getEntityDestroyPacket(this.armorStandId));
+ this.hasArmorStand = false;
+ }
+
+ public boolean hasArmorStand() {
+ return hasArmorStand;
+ }
+
+ public ArmorItem getLastSetItem() {
+ return lastSetItem;
+ }
+
+ public int getEntityId() {
+ return this.entityId;
+ }
+
+}
diff --git a/common/src/main/java/io/github/fisher2911/hmccosmetics/user/User.java b/common/src/main/java/io/github/fisher2911/hmccosmetics/user/User.java
index abf5294b..7b029bc4 100644
--- a/common/src/main/java/io/github/fisher2911/hmccosmetics/user/User.java
+++ b/common/src/main/java/io/github/fisher2911/hmccosmetics/user/User.java
@@ -1,198 +1,36 @@
package io.github.fisher2911.hmccosmetics.user;
-import com.comphenix.protocol.PacketType;
-import com.comphenix.protocol.events.PacketContainer;
-import com.comphenix.protocol.wrappers.EnumWrappers;
-import com.comphenix.protocol.wrappers.Pair;
-import com.comphenix.protocol.wrappers.WrappedDataWatcher;
-import com.comphenix.protocol.wrappers.WrappedDataWatcher.Serializer;
-import io.github.fisher2911.hmccosmetics.HMCCosmetics;
-import io.github.fisher2911.hmccosmetics.config.CosmeticSettings;
-import io.github.fisher2911.hmccosmetics.config.Settings;
import io.github.fisher2911.hmccosmetics.gui.ArmorItem;
import io.github.fisher2911.hmccosmetics.gui.CosmeticGui;
import io.github.fisher2911.hmccosmetics.inventory.PlayerArmor;
-import io.github.fisher2911.hmccosmetics.packet.PacketManager;
+import net.minecraft.server.v1_16_R3.PacketPlayInAbilities;
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;
-import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.Nullable;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
import java.util.UUID;
-public class User {
-
- private final UUID uuid;
- private final int entityId;
- private final PlayerArmor playerArmor;
+public class User extends BaseUser {
protected Wardrobe wardrobe;
-
- private ArmorItem lastSetItem = ArmorItem.empty(ArmorItem.Type.HAT);
-
- private boolean hasArmorStand;
- private final int armorStandId;
-
private CosmeticGui openGui;
- // List of players that are currently viewing the armorstand
- private final Set viewing = new HashSet<>();
-
- public User(final UUID uuid, final int entityId, final PlayerArmor playerArmor, final Wardrobe wardrobe, final int armorStandId) {
- this.uuid = uuid;
- this.entityId = entityId;
- this.playerArmor = playerArmor;
+ public User(final UUID uuid, final int entityId, final PlayerArmor playerArmor, final int armorStandId, final Wardrobe wardrobe) {
+ super(uuid, entityId, playerArmor, armorStandId);
this.wardrobe = wardrobe;
- this.armorStandId = armorStandId;
- }
-
- protected User(final UUID uuid, final int entityId, final PlayerArmor playerArmor, final int armorStandId) {
- this.uuid = uuid;
- this.entityId = entityId;
- this.playerArmor = playerArmor;
- this.armorStandId = armorStandId;
}
public @Nullable Player getPlayer() {
return Bukkit.getPlayer(this.uuid);
}
- public UUID getUuid() {
- return this.uuid;
- }
-
- public PlayerArmor getPlayerArmor() {
- return playerArmor;
- }
-
public Wardrobe getWardrobe() {
return wardrobe;
}
- protected void setPlayerArmor(final PlayerArmor playerArmor) {
- for (final ArmorItem armorItem : playerArmor.getArmorItems()) {
- this.playerArmor.setItem(armorItem);
- }
- }
-
- protected void removeAllCosmetics() {
- for (final ArmorItem.Type type : ArmorItem.Type.values()) {
- this.removeItem(type);
- }
- }
-
- public int getArmorStandId() {
- return armorStandId;
- }
-
- protected ArmorItem setItem(final ArmorItem armorItem) {
- this.lastSetItem = armorItem;
- return this.playerArmor.setItem(armorItem);
- }
-
- protected ArmorItem removeItem(final ArmorItem.Type type) {
- return this.setItem(ArmorItem.empty(type));
- }
-
- public void spawnArmorStand(final Player other, final Location location, final CosmeticSettings settings) {
- final Player player = this.getPlayer();
- if (player == null) return;
- if (!this.isInViewDistance(player, other, settings) || !shouldShow(other)) return;
-
- final PacketContainer packet = PacketManager.getEntitySpawnPacket(location, this.armorStandId, EntityType.ARMOR_STAND);
- this.viewing.add(other.getUniqueId());
- PacketManager.sendPacket(other, packet);
- }
-
- public void spawnArmorStand(final Settings settings) {
- if (this.hasArmorStand) {
- this.updateArmorStand(settings);
- return;
- }
-
- final Player player = this.getPlayer();
- if (player == null) return;
-
- for (final Player p : Bukkit.getOnlinePlayers()) {
- this.spawnArmorStand(p, player.getLocation(), settings.getCosmeticSettings());
- }
-
- this.hasArmorStand = true;
- }
-
- public void updateArmorStand(final Settings settings) {
- if (!this.hasArmorStand) {
- this.spawnArmorStand(settings);
- }
- for (final Player player : Bukkit.getOnlinePlayers()) {
- this.updateArmorStand(player, settings);
- }
- }
-
- public void updateArmorStand(final Player other, final Settings settings) {
- final Player player = this.getPlayer();
-
- if (player == null) return;
-
- this.updateArmorStand(other, settings, player.getLocation());
- }
-
- public void updateArmorStand(final Player other, final Settings settings, final Location location) {
- final Player player = this.getPlayer();
- if (player == null) return;
- final boolean inViewDistance = this.isInViewDistance(player, other, settings.getCosmeticSettings());
- if (!this.viewing.contains(other.getUniqueId())) {
- if (!inViewDistance || !shouldShow(other)) return;
- this.spawnArmorStand(other, location, settings.getCosmeticSettings());
- } else if (!inViewDistance || !shouldShow(other)) {
- this.despawnAttached(other);
- this.viewing.remove(other.getUniqueId());
- return;
- }
- final List> equipmentList = new ArrayList<>();
- final boolean hidden = !this.shouldShow(other);
- if (hidden) {
- equipmentList.add(new Pair<>(EnumWrappers.ItemSlot.HEAD,
- new ItemStack(Material.AIR)
- ));
- } else {
- equipmentList.add(new Pair<>(EnumWrappers.ItemSlot.HEAD,
- this.playerArmor.getBackpack().getColored()
- ));
- }
-
- final PacketContainer armorPacket = PacketManager.getEquipmentPacket(equipmentList, this.armorStandId);
- final PacketContainer rotationPacket = PacketManager.getRotationPacket(this.armorStandId, location);
- final PacketContainer ridingPacket = PacketManager.getRidingPacket(this.getEntityId(), this.armorStandId);
- final PacketContainer armorStandMetaContainer = PacketManager.getArmorStandMetaContainer(this.armorStandId);
-
- PacketManager.sendPacket(other, armorPacket, armorStandMetaContainer, rotationPacket, ridingPacket);
-
- if (hidden) return;
-
- final int lookDownPitch = settings.getCosmeticSettings().getLookDownPitch();
-
- if (lookDownPitch != -1 &&
- this.isFacingDown(location, lookDownPitch)) {
- equipmentList.set(0, new Pair<>(EnumWrappers.ItemSlot.HEAD,
- new ItemStack(Material.AIR)
- ));
-
- if (!this.uuid.equals(other.getUniqueId())) return;
- PacketManager.sendPacket(other, PacketManager.getEquipmentPacket(equipmentList, this.armorStandId));
- }
- }
-
public boolean shouldShow(final Player other) {
final Player player = this.getPlayer();
if (player == null) return false;
@@ -202,28 +40,6 @@ public class User {
!player.isSwimming());
}
- private boolean isInViewDistance(final Player player, final Player other, final CosmeticSettings settings) {
- final Location otherLocation = other.getLocation();
- final Location playerLocation = player.getLocation();
- if (!Objects.equals(otherLocation.getWorld(), playerLocation.getWorld())) return false;
- return !(otherLocation.distanceSquared(playerLocation) > settings.getViewDistance() * settings.getViewDistance());
- }
-
- private boolean isFacingDown(final Location location, final int pitchLimit) {
- return location.getPitch() > pitchLimit;
- }
-
- public void despawnAttached(final Player other) {
- PacketManager.sendPacket(other, PacketManager.getEntityDestroyPacket(this.armorStandId));
- this.viewing.remove(other.getUniqueId());
- this.hasArmorStand = false;
- }
-
- public void despawnAttached() {
- PacketManager.sendPacketToOnline(PacketManager.getEntityDestroyPacket(this.armorStandId));
- this.hasArmorStand = false;
- }
-
@Nullable
public CosmeticGui getOpenGui() {
return openGui;
@@ -233,21 +49,17 @@ public class User {
this.openGui = openGui;
}
- public boolean hasArmorStand() {
- return hasArmorStand;
- }
-
- public ArmorItem getLastSetItem() {
- return lastSetItem;
- }
-
- public int getEntityId() {
- return this.entityId;
- }
-
public boolean hasPermissionToUse(final ArmorItem armorItem) {
final Player player = this.getPlayer();
if (player == null) return false;
return player.hasPermission(armorItem.getPermission());
}
+
+ @Override
+ @Nullable
+ public Location getLocation() {
+ final Player player = this.getPlayer();
+ if (player == null) return null;
+ return player.getLocation();
+ }
}
diff --git a/nms/build/libs/nms.jar b/nms/build/libs/nms.jar
index fd89b416..71c8894e 100644
Binary files a/nms/build/libs/nms.jar and b/nms/build/libs/nms.jar differ