mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-31 21:06:38 +00:00
Add more hidden reasons & show, hide, and toggle actions
This commit is contained in:
@@ -327,7 +327,7 @@ public class CosmeticCommand implements CommandExecutor {
|
||||
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
MessagesUtil.sendMessage(sender, "hide-cosmetic");
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.COMMAND);
|
||||
return true;
|
||||
}
|
||||
case ("show") -> {
|
||||
|
||||
@@ -22,6 +22,9 @@ public class Actions {
|
||||
private static ActionEquip ACTION_EQUIP = new ActionEquip();
|
||||
private static ActionUnequip ACTION_UNEQUIP = new ActionUnequip();
|
||||
private static ActionParticle ACTION_PARTICLE = new ActionParticle();
|
||||
private static ActionCosmeticShow ACTION_SHOW = new ActionCosmeticShow();
|
||||
private static ActionCosmeticHide ACTION_HIDE = new ActionCosmeticHide();
|
||||
private static ActionCosmeticToggle ACTION_TOGGLE = new ActionCosmeticToggle();
|
||||
|
||||
|
||||
public static Action getAction(String id) {
|
||||
@@ -40,7 +43,7 @@ public class Actions {
|
||||
for (String a : raw) {
|
||||
String id = StringUtils.substringBetween(a, "[", "]").toUpperCase();
|
||||
String message = StringUtils.substringAfter(a, "] ");
|
||||
MessagesUtil.sendDebugMessages("ID is " + id + " // Message is " + message);
|
||||
MessagesUtil.sendDebugMessages("ID is " + id + " // Raw Data is " + message);
|
||||
if (isAction(id)) {
|
||||
getAction(id).run(user, message);
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
|
||||
public class ActionCosmeticHide extends Action {
|
||||
|
||||
public ActionCosmeticHide() {
|
||||
super("hide");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(CosmeticUser user, String raw) {
|
||||
if (!user.getHidden()) {
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.ACTION);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
|
||||
public class ActionCosmeticShow extends Action {
|
||||
|
||||
public ActionCosmeticShow() {
|
||||
super("show");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(CosmeticUser user, String raw) {
|
||||
if (user.getHidden()) {
|
||||
if (user.getHiddenReason() != CosmeticUser.HiddenReason.ACTION && user.getHiddenReason() != CosmeticUser.HiddenReason.COMMAND) return; // Do not hide if its already off for WG
|
||||
user.showCosmetics();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.hibiscusmc.hmccosmetics.gui.action.actions;
|
||||
|
||||
import com.hibiscusmc.hmccosmetics.gui.action.Action;
|
||||
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
|
||||
|
||||
public class ActionCosmeticToggle extends Action {
|
||||
|
||||
public ActionCosmeticToggle() {
|
||||
super("toggle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(CosmeticUser user, String raw) {
|
||||
if (user.getHidden()) {
|
||||
if (user.getHiddenReason() != CosmeticUser.HiddenReason.ACTION && user.getHiddenReason() != CosmeticUser.HiddenReason.COMMAND) return;
|
||||
user.showCosmetics();
|
||||
return;
|
||||
}
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.ACTION);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -24,9 +24,10 @@ public class WGListener implements Listener {
|
||||
RegionContainer region = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionQuery query = region.createQuery();
|
||||
ApplicableRegionSet set = query.getApplicableRegions(loc);
|
||||
// TODO: Add more cosmetics
|
||||
if (set.getRegions().size() == 0) {
|
||||
user.showCosmetics();
|
||||
if (user.getHidden()) {
|
||||
if (user.getHiddenReason() == CosmeticUser.HiddenReason.WORLDGUARD && set.getRegions().size() == 0) {
|
||||
user.showCosmetics();
|
||||
}
|
||||
}
|
||||
for (ProtectedRegion protectedRegion : set.getRegions()) {
|
||||
if (protectedRegion.getFlags().containsKey(WGHook.getCosmeticEnableFlag())) {
|
||||
|
||||
@@ -207,7 +207,7 @@ public class PlayerGameListener implements Listener {
|
||||
Player player = (Player) event.getEntity();
|
||||
CosmeticUser user = CosmeticUsers.getUser(player);
|
||||
if (event.getAction().equals(EntityPotionEffectEvent.Action.ADDED)) {
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.PLUGIN);
|
||||
user.hideCosmetics(CosmeticUser.HiddenReason.POTION);
|
||||
return;
|
||||
}
|
||||
if (event.getAction().equals(EntityPotionEffectEvent.Action.CLEARED) || event.getAction().equals(EntityPotionEffectEvent.Action.REMOVED)) {
|
||||
|
||||
@@ -460,6 +460,9 @@ public class CosmeticUser {
|
||||
public enum HiddenReason {
|
||||
NONE,
|
||||
WORLDGUARD,
|
||||
PLUGIN
|
||||
PLUGIN,
|
||||
POTION,
|
||||
ACTION,
|
||||
COMMAND
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user