9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-31 12:56:39 +00:00

improve command handling and add permissions

This commit is contained in:
LoJoSho
2023-02-10 16:28:42 -06:00
parent 42bae598a6
commit 00cc3eef2c
4 changed files with 17 additions and 1 deletions

View File

@@ -382,10 +382,19 @@ public class CosmeticCommand implements CommandExecutor {
}
}
case ("emote") -> {
if (!sender.hasPermission("hmccosmetics.cmd.emote")) {
if (!silent) MessagesUtil.sendMessage(sender, "no-permission");
return true;
}
CosmeticUser user = CosmeticUsers.getUser(player);
if (!user.hasCosmeticInSlot(CosmeticSlot.EMOTE)) {
if (!silent) MessagesUtil.sendMessage(sender, "emote-none");
return true;
}
CosmeticEmoteType cosmeticEmoteType = (CosmeticEmoteType) user.getCosmetic(CosmeticSlot.EMOTE);
cosmeticEmoteType.run(user);
return true;
}
}
return true;

View File

@@ -202,7 +202,7 @@ public class PlayerGameListener implements Listener {
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer().getUniqueId());
if (user == null) return;
// Really need to look into optimization of this
if (user.hasCosmeticInSlot(CosmeticSlot.EMOTE) && event.getPlayer().isSneaking()) {
if (user.hasCosmeticInSlot(CosmeticSlot.EMOTE) && event.getPlayer().isSneaking() && event.getPlayer().hasPermission("hmccosmetics.emote.shiftrun")) {
CosmeticEmoteType cosmeticEmoteType = (CosmeticEmoteType) user.getCosmetic(CosmeticSlot.EMOTE);
cosmeticEmoteType.run(user);
event.setCancelled(true);

View File

@@ -18,6 +18,7 @@ hide-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>Hidden cosmetics"
show-cosmetic: "%prefix% <gradient:#6D9DC5:#45CDE9>Revealed cosmetics!"
emote-blocked: "%prefix% <red>You can not use your emote here!"
emote-none: "%prefix% <red>You have no emote equipped!"
invalid-slot: "%prefix% <red>Invalid cosmetic slot!"
invalid-player: "%prefix% <red>Invalid Player!"