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

clean: finish wardrobe location overhaul

This commit is contained in:
LoJoSho
2023-05-16 15:21:20 -05:00
parent cd3a9f1af4
commit f9465e8206
5 changed files with 36 additions and 17 deletions

View File

@@ -303,7 +303,7 @@ public class CosmeticCommand implements CommandExecutor {
}
if (args[1].equalsIgnoreCase("wardrobelocation")) {
WardrobeSettings.setWardrobeLocation(player.getLocation());
WardrobeSettings.setNPCLocation(player.getLocation());
if (!silent) MessagesUtil.sendMessage(player, "set-wardrobe-location");
return true;
}

View File

@@ -15,15 +15,15 @@ public class WardrobeLocation {
}
public Location getNpcLocation() {
return npcLocation;
return npcLocation.clone();
}
public Location getViewerLocation() {
return viewerLocation;
return viewerLocation.clone();
}
public Location getLeaveLocation() {
return leaveLocation;
return leaveLocation.clone();
}
public void setNPCLocation(Location wardrobeLocation) {

View File

@@ -172,18 +172,35 @@ public class WardrobeSettings {
return returnLastLocation;
}
/**
*
* @Deprecated use {@link #getLocation()}
*/
@Deprecated (since = "2.3.2", forRemoval = true)
public static Location getWardrobeLocation() {
return wardrobeLocation.getNpcLocation().clone();
}
/**
*
* @Deprecated use {@link #getLocation()}
*/
@Deprecated (since = "2.3.2", forRemoval = true)
public static Location getViewerLocation() {
return wardrobeLocation.getViewerLocation().clone();
}
/**
*
* @Deprecated use {@link #getLocation()}
*/
@Deprecated (since = "2.3.2", forRemoval = true)
public static Location getLeaveLocation() {
return wardrobeLocation.getLeaveLocation().clone();
}
public static WardrobeLocation getLocation() {
return wardrobeLocation;
}
public static boolean inDistanceOfWardrobe(final Location wardrobeLocation, final Location playerLocation) {
if (displayRadius == -1) return true;
if (!wardrobeLocation.getWorld().equals(playerLocation.getWorld())) return false;
@@ -248,7 +265,7 @@ public class WardrobeSettings {
/**
* Sets where the NPC will spawn in the wardrobe
*
* @Deprecated use {{@link #setNPCLocation(Location)}}
* @Deprecated use {@link #setNPCLocation(Location)}
* @param newLocation
*/
@Deprecated (since = "2.3.2", forRemoval = true)

View File

@@ -5,6 +5,7 @@ import com.google.common.collect.ImmutableList;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.api.*;
import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.config.WardrobeLocation;
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
@@ -247,10 +248,10 @@ public class CosmeticUser {
}
public void enterWardrobe(boolean ignoreDistance) {
enterWardrobe(ignoreDistance, WardrobeSettings.getLeaveLocation(), WardrobeSettings.getViewerLocation(), WardrobeSettings.getWardrobeLocation());
enterWardrobe(ignoreDistance, WardrobeSettings.getLocation());
}
public void enterWardrobe(boolean ignoreDistance, Location exitLocation, Location viewingLocation, Location npcLocation) {
public void enterWardrobe(boolean ignoreDistance, WardrobeLocation wardrobeLocation) {
if (!WardrobeSettings.inDistanceOfStatic(getPlayer().getLocation()) && !ignoreDistance) {
MessagesUtil.sendMessage(getPlayer(), "not-near-wardrobe");
return;
@@ -262,7 +263,7 @@ public class CosmeticUser {
}
if (userWardrobeManager == null) {
userWardrobeManager = new UserWardrobeManager(this, exitLocation, viewingLocation, npcLocation);
userWardrobeManager = new UserWardrobeManager(this, wardrobeLocation);
userWardrobeManager.start();
}
}

View File

@@ -2,6 +2,7 @@ package com.hibiscusmc.hmccosmetics.user.manager;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.config.Settings;
import com.hibiscusmc.hmccosmetics.config.WardrobeLocation;
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
@@ -45,15 +46,15 @@ public class UserWardrobeManager {
private boolean active;
private WardrobeStatus wardrobeStatus;
public UserWardrobeManager(CosmeticUser user, Location exitLocation, Location viewingLocation, Location npcLocation) {
public UserWardrobeManager(CosmeticUser user, WardrobeLocation location) {
NPC_ID = NMSHandlers.getHandler().getNextEntityId();
ARMORSTAND_ID = NMSHandlers.getHandler().getNextEntityId();
WARDROBE_UUID = UUID.randomUUID();
this.user = user;
this.exitLocation = exitLocation;
this.viewingLocation = viewingLocation;
this.npcLocation = npcLocation;
this.exitLocation = location.getLeaveLocation();
this.viewingLocation = location.getViewerLocation();
this.npcLocation = location.getNpcLocation();
wardrobeStatus = WardrobeStatus.SETUP;
}
@@ -235,7 +236,7 @@ public class UserWardrobeManager {
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
outsideViewers.remove(player);
Location location = WardrobeSettings.getWardrobeLocation().clone();
Location location = WardrobeSettings.getLocation().getNpcLocation();
int yaw = data.get();
location.setYaw(yaw);
@@ -259,8 +260,8 @@ 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.sendTeleportPacket(user.getBalloonManager().getPufferfishBalloonId(), WardrobeSettings.getLocation().getNpcLocation().add(Settings.getBalloonOffset()), false, viewer);
user.getBalloonManager().getModelEntity().teleport(WardrobeSettings.getLocation().getNpcLocation().add(Settings.getBalloonOffset()));
user.getBalloonManager().sendRemoveLeashPacket(outsideViewers);
PacketManager.sendEntityDestroyPacket(user.getBalloonManager().getModelId(), outsideViewers);
user.getBalloonManager().sendLeashPacket(NPC_ID);