mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-30 12:29:16 +00:00
Internal wardrobe rework
This commit is contained in:
@@ -48,10 +48,11 @@ public class CosmeticBalloonType extends Cosmetic {
|
||||
@Override
|
||||
public void update(CosmeticUser user) {
|
||||
Player player = Bukkit.getPlayer(user.getUniqueId());
|
||||
Location currentLocation = user.getBalloonEntity().getLocation().clone();
|
||||
Location newLocation = player.getLocation().clone().add(Settings.getBalloonOffset()).clone();
|
||||
if (player == null) return;
|
||||
Location currentLocation = user.getBalloonEntity().getLocation();
|
||||
Location newLocation = player.getLocation();
|
||||
if (player == null || currentLocation == null || newLocation == null) return;
|
||||
if (user.isInWardrobe()) return;
|
||||
newLocation = newLocation.clone().add(Settings.getBalloonOffset());
|
||||
|
||||
List<Player> viewer = PacketManager.getViewers(player.getLocation());
|
||||
viewer.add(player);
|
||||
|
||||
@@ -19,6 +19,7 @@ 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.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -214,7 +215,15 @@ public class CosmeticUser {
|
||||
}
|
||||
|
||||
public void enterWardrobe() {
|
||||
if (!WardrobeSettings.inDistanceOfStatic(getPlayer().getLocation())) {
|
||||
enterWardrobe(false);
|
||||
}
|
||||
|
||||
public void enterWardrobe(boolean ignoreDistance) {
|
||||
enterWardrobe(ignoreDistance, WardrobeSettings.getLeaveLocation(), WardrobeSettings.getViewerLocation(), WardrobeSettings.getWardrobeLocation());
|
||||
}
|
||||
|
||||
public void enterWardrobe(boolean ignoreDistance, Location exitLocation, Location viewingLocation, Location npcLocation) {
|
||||
if (!WardrobeSettings.inDistanceOfStatic(getPlayer().getLocation()) && !ignoreDistance) {
|
||||
MessagesUtil.sendMessage(getPlayer(), "not-near-wardrobe");
|
||||
return;
|
||||
}
|
||||
@@ -225,7 +234,7 @@ public class CosmeticUser {
|
||||
}
|
||||
|
||||
if (wardrobe == null) {
|
||||
wardrobe = new Wardrobe(this);
|
||||
wardrobe = new Wardrobe(this, exitLocation, viewingLocation, npcLocation);
|
||||
wardrobe.start();
|
||||
}
|
||||
}
|
||||
@@ -256,8 +265,6 @@ public class CosmeticUser {
|
||||
wardrobe.end();
|
||||
wardrobe = null;
|
||||
}, WardrobeSettings.getTransitionDelay());
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,24 @@ public class Wardrobe {
|
||||
ARMORSTAND_ID = NMSHandlers.getHandler().getNextEntityId();
|
||||
WARDROBE_UUID = UUID.randomUUID();
|
||||
VIEWER = user;
|
||||
|
||||
exitLocation = WardrobeSettings.getLeaveLocation();
|
||||
viewingLocation = WardrobeSettings.getViewerLocation();
|
||||
npcLocation = WardrobeSettings.getWardrobeLocation();
|
||||
|
||||
wardrobeStatus = WardrobeStatus.SETUP;
|
||||
}
|
||||
|
||||
public Wardrobe(CosmeticUser user, Location exitLocation, Location viewingLocation, Location npcLocation) {
|
||||
NPC_ID = NMSHandlers.getHandler().getNextEntityId();
|
||||
ARMORSTAND_ID = NMSHandlers.getHandler().getNextEntityId();
|
||||
WARDROBE_UUID = UUID.randomUUID();
|
||||
VIEWER = user;
|
||||
|
||||
this.exitLocation = exitLocation;
|
||||
this.viewingLocation = viewingLocation;
|
||||
this.npcLocation = npcLocation;
|
||||
|
||||
wardrobeStatus = WardrobeStatus.SETUP;
|
||||
}
|
||||
|
||||
@@ -56,13 +74,8 @@ public class Wardrobe {
|
||||
this.originalGamemode = player.getGameMode();
|
||||
if (WardrobeSettings.isReturnLastLocation()) {
|
||||
this.exitLocation = player.getLocation().clone();
|
||||
} else {
|
||||
this.exitLocation = WardrobeSettings.getLeaveLocation();
|
||||
}
|
||||
|
||||
viewingLocation = WardrobeSettings.getViewerLocation();
|
||||
npcLocation = WardrobeSettings.getWardrobeLocation();
|
||||
|
||||
VIEWER.hidePlayer();
|
||||
List<Player> viewer = List.of(player);
|
||||
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
|
||||
|
||||
Reference in New Issue
Block a user