mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-19 15:09:19 +00:00
Added command to open other player's wardrobe
This commit is contained in:
@@ -114,5 +114,9 @@ bukkit {
|
||||
default = BukkitPluginDescription.Permission.Default.OP
|
||||
description = "Permission to view the wardrobe"
|
||||
}
|
||||
register("hmccosmetics.cmd.wardrobe.other") {
|
||||
default = BukkitPluginDescription.Permission.Default.OP
|
||||
description = "Permission to open another player's wardrobe"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import me.mattstudios.mf.annotations.Permission;
|
||||
import me.mattstudios.mf.annotations.SubCommand;
|
||||
import me.mattstudios.mf.base.CommandBase;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -214,7 +215,22 @@ public class CosmeticsCommand extends CommandBase {
|
||||
|
||||
@SubCommand("wardrobe")
|
||||
@Permission(io.github.fisher2911.hmccosmetics.message.Permission.WARDROBE)
|
||||
public void openWardrobe(final Player player) {
|
||||
public void openWardrobe(Player player, @me.mattstudios.mf.annotations.Optional final Player other) {
|
||||
if (other != null) {
|
||||
if (!player.hasPermission(io.github.fisher2911.hmccosmetics.message.Permission.OPEN_OTHER_WARDROBE)) {
|
||||
this.messageHandler.sendMessage(
|
||||
player,
|
||||
Messages.NO_PERMISSION
|
||||
);
|
||||
return;
|
||||
}
|
||||
this.messageHandler.sendMessage(
|
||||
player,
|
||||
Messages.OPENED_OTHER_WARDROBE,
|
||||
Map.of(Placeholder.PLAYER, other.getName())
|
||||
);
|
||||
player = other;
|
||||
}
|
||||
final Optional<User> optionalUser = this.plugin.getUserManager().get(player.getUniqueId());
|
||||
if (optionalUser.isEmpty()) return;
|
||||
|
||||
@@ -254,9 +270,10 @@ public class CosmeticsCommand extends CommandBase {
|
||||
|
||||
wardrobe.setActive(true);
|
||||
|
||||
final Player finalPlayer = player;
|
||||
Bukkit.getScheduler().runTaskAsynchronously(
|
||||
this.plugin,
|
||||
() -> wardrobe.spawnFakePlayer(player)
|
||||
() -> wardrobe.spawnFakePlayer(finalPlayer)
|
||||
);
|
||||
|
||||
this.cosmeticsMenu.openDefault(player);
|
||||
|
||||
@@ -55,9 +55,9 @@ public class WardrobeSettings {
|
||||
@Nullable
|
||||
private Location loadLocation(final ConfigurationSection section) {
|
||||
final String worldName = section.getString(WORLD_PATH);
|
||||
final int x = section.getInt(X_PATH);
|
||||
final int y = section.getInt(Y_PATH);
|
||||
final int z = section.getInt(Z_PATH);
|
||||
final double x = section.getDouble(X_PATH);
|
||||
final double y = section.getDouble(Y_PATH);
|
||||
final double z = section.getDouble(Z_PATH);
|
||||
final float yaw = (float) section.getDouble(YAW_PATH);
|
||||
final float pitch = (float) section.getDouble(PITCH_PATH);
|
||||
|
||||
|
||||
@@ -60,6 +60,8 @@ public class Messages {
|
||||
new Message("not-near-wardrobe", ChatColor.RED + "You are not near the wardrobe!");
|
||||
public static final Message CANNOT_USE_PORTABLE_WARDROBE =
|
||||
new Message("cannot-use-portable-wardrobe", ChatColor.RED + "You cannot use the portable wardrobe!");
|
||||
public static final Message OPENED_OTHER_WARDROBE =
|
||||
new Message("opened-other-wardrobe", ChatColor.GREEN + "Opening " + Placeholder.PLAYER + "'s wardrobe.");
|
||||
|
||||
public static final Message SET_OTHER_BACKPACK = new Message(
|
||||
"set-other-backpack", ChatColor.GREEN + "You have set the backpack of " +
|
||||
|
||||
@@ -9,5 +9,6 @@ public class Permission {
|
||||
public static final String SET_COSMETIC_COMMAND = "hmccosmetics.cmd.set";
|
||||
public static final String PORTABLE_WARDROBE = "hmccosmetics.cmd.wardrobe.portable";
|
||||
public static final String WARDROBE = "hmccosmetics.cmd.wardrobe";
|
||||
public static final String OPEN_OTHER_WARDROBE = "hmccosmetics.cmd.wardrobe.other";
|
||||
|
||||
}
|
||||
|
||||
@@ -172,6 +172,7 @@ public class User {
|
||||
new ItemStack(Material.AIR)
|
||||
));
|
||||
|
||||
if (!this.uuid.equals(other.getUniqueId())) return;
|
||||
PacketManager.sendPacket(other, PacketManager.getEquipmentPacket(equipmentList, this.armorStandId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ closed-wardrobe: "%prefix% <gradient:#6D9DC5:#45CDE9>Closed wardrobe!"
|
||||
wardrobe-already-open: "%prefix% <gradient:#6D9DC5:#45CDE9><red>The wardrobe is already open!"
|
||||
not-near-wardrobe: "%prefix% <gradient:#6D9DC5:#45CDE9><red>You are not near the wardrobe!"
|
||||
cannot-use-portable-wardrobe: "%prefix% <gradient:#6D9DC5:#45CDE9><red>You cannot use the portable wardrobe!"
|
||||
opened-other-wardrobe: "%prefix% <gradient:#6D9DC5:#45CDE9><red>Opening %player%'s wardrobe."
|
||||
help-command: "<#6D9DC5><st> </st> %prefix% <gradient:#40B7D6:#6D9DC5>HMCCosmetics - Help</gradient> %prefix% <#6D9DC5> <st> </st>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user