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

feat: PlayerWardrobeEnterEvent now passes wardrobe location that is modifiable

This commit is contained in:
LoJoSho
2023-05-16 15:24:26 -05:00
parent f9465e8206
commit 4590bdcde1
2 changed files with 14 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
package com.hibiscusmc.hmccosmetics.api;
import com.hibiscusmc.hmccosmetics.config.WardrobeLocation;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@@ -11,9 +12,11 @@ import org.jetbrains.annotations.NotNull;
public class PlayerWardrobeEnterEvent extends PlayerCosmeticEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancel = false;
private WardrobeLocation wardrobeLocation;
public PlayerWardrobeEnterEvent(@NotNull CosmeticUser who) {
public PlayerWardrobeEnterEvent(@NotNull CosmeticUser who, @NotNull WardrobeLocation wardrobeLocation) {
super(who);
this.wardrobeLocation = wardrobeLocation;
}
@Override
@@ -45,4 +48,12 @@ public class PlayerWardrobeEnterEvent extends PlayerCosmeticEvent implements Can
public static HandlerList getHandlerList() {
return handlers;
}
public void setWardrobeLocation(WardrobeLocation wardrobeLocation) {
this.wardrobeLocation = wardrobeLocation;
}
public WardrobeLocation getWardrobeLocation() {
return wardrobeLocation;
}
}

View File

@@ -256,11 +256,12 @@ public class CosmeticUser {
MessagesUtil.sendMessage(getPlayer(), "not-near-wardrobe");
return;
}
PlayerWardrobeEnterEvent event = new PlayerWardrobeEnterEvent(this);
PlayerWardrobeEnterEvent event = new PlayerWardrobeEnterEvent(this, wardrobeLocation);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
wardrobeLocation = event.getWardrobeLocation();
if (userWardrobeManager == null) {
userWardrobeManager = new UserWardrobeManager(this, wardrobeLocation);