9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-23 17:09:24 +00:00

Changed location of armor stand spawn

This commit is contained in:
HeroBrineGoat
2022-01-17 23:22:30 -05:00
parent 3c8c585634
commit 7bb8fd79c2
3 changed files with 39 additions and 3 deletions

View File

@@ -64,6 +64,7 @@ public class HMCCosmetics extends JavaPlugin {
this.messageHandler.close(); this.messageHandler.close();
this.userManager.cancelTeleportTask(); this.userManager.cancelTeleportTask();
this.userManager.removeAll(); this.userManager.removeAll();
this.database.close();
} }
private void registerListeners() { private void registerListeners() {

View File

@@ -179,9 +179,9 @@ public class User {
packet.getIntegers().write(4, (int) location.getPitch()); packet.getIntegers().write(4, (int) location.getPitch());
packet.getIntegers().write(5, (int) location.getYaw()); packet.getIntegers().write(5, (int) location.getYaw());
// Set location // Set location
packet.getDoubles().write(0, 0d); packet.getDoubles().write(0, location.getX());
packet.getDoubles().write(1, -5d); packet.getDoubles().write(1, location.getY());
packet.getDoubles().write(2, 0d); packet.getDoubles().write(2, location.getZ());
// Set UUID // Set UUID
packet.getUUIDs().write(0, UUID.randomUUID()); packet.getUUIDs().write(0, UUID.randomUUID());
@@ -308,4 +308,9 @@ public class User {
public void setDye(final int dye) { public void setDye(final int dye) {
this.playerArmor.setDye(dye); this.playerArmor.setDye(dye);
} }
public boolean hasArmorStand() {
return hasArmorStand;
}
} }

View File

@@ -33,6 +33,7 @@ public class UserManager {
private final HMCCosmetics plugin; private final HMCCosmetics plugin;
private final Map<UUID, User> userMap = new HashMap<>(); private final Map<UUID, User> userMap = new HashMap<>();
private final Map<Integer, User> armorStandIdMap = new HashMap<>();
private BukkitTask teleportTask; private BukkitTask teleportTask;
@@ -43,6 +44,7 @@ public class UserManager {
public void add(final User user) { public void add(final User user) {
this.userMap.put(user.getUuid(), user); this.userMap.put(user.getUuid(), user);
this.armorStandIdMap.put(user.getArmorStandId(), user);
this.setFakeHelmet(user); this.setFakeHelmet(user);
} }
@@ -59,6 +61,8 @@ public class UserManager {
if (user == null) return; if (user == null) return;
this.armorStandIdMap.remove(user.getArmorStandId());
user.removeAllCosmetics(); user.removeAllCosmetics();
this.setFakeHelmet(user); this.setFakeHelmet(user);
user.despawnAttached(); user.despawnAttached();
@@ -124,6 +128,32 @@ public class UserManager {
} }
} }
}); });
// not sure if this fixes anything, removed for now
// protocolManager.addPacketListener(new PacketAdapter(
// this.plugin,
// ListenerPriority.NORMAL,
// PacketType.Play.Server.ENTITY_DESTROY) {
// @Override
// public void onPacketReceiving(PacketEvent event) {
//
// }
//
// @Override
// public void onPacketSending(final PacketEvent event) {
// if (event.getPacketType() == PacketType.Play.Server.ENTITY_DESTROY) {
// final int id = event.getPacket().getIntegers().read(0);
//
// final User user = armorStandIdMap.get(id);
//
// if (user == null) return;
//
// if (!user.hasArmorStand()) return;
//
// user.spawnArmorStand();
// }
// }
// });
} }
public void setFakeHelmet(final User user) { public void setFakeHelmet(final User user) {