Add new config option to auto-hide tall disguises, also as a disguise option
This commit is contained in:
		| @@ -240,6 +240,9 @@ public class DisguiseConfig { | ||||
|     @Getter | ||||
|     private static boolean notifyUpdate; | ||||
|     private static BukkitTask updaterTask; | ||||
|     @Getter | ||||
|     @Setter | ||||
|     private static boolean hideTallSelfDisguises; | ||||
|  | ||||
|     public static void setAutoUpdate(boolean update) { | ||||
|         if (isAutoUpdate() == update) { | ||||
| @@ -566,6 +569,7 @@ public class DisguiseConfig { | ||||
|         setScoreboardDisguiseNames(config.getBoolean("ScoreboardNames")); | ||||
|         setTablistRemoveDelay(config.getInt("TablistRemoveDelay")); | ||||
|         setAutoUpdate(config.getBoolean("AutoUpdate")); | ||||
|         setHideTallSelfDisguises(config.getBoolean("HideTallSelfDisguises")); | ||||
|  | ||||
|         if (!LibsPremium.isPremium() && (isSavePlayerDisguises() || isSaveEntityDisguises())) { | ||||
|             DisguiseUtilities.getLogger().warning("You must purchase the plugin to use saved disguises!"); | ||||
|   | ||||
| @@ -20,7 +20,9 @@ import me.libraryaddict.disguise.disguisetypes.watchers.*; | ||||
| import me.libraryaddict.disguise.events.DisguiseEvent; | ||||
| import me.libraryaddict.disguise.events.UndisguiseEvent; | ||||
| import me.libraryaddict.disguise.utilities.DisguiseUtilities; | ||||
| import me.libraryaddict.disguise.utilities.DisguiseValues; | ||||
| import me.libraryaddict.disguise.utilities.LibsPremium; | ||||
| import me.libraryaddict.disguise.utilities.reflection.FakeBoundingBox; | ||||
| import me.libraryaddict.disguise.utilities.reflection.NmsVersion; | ||||
| import me.libraryaddict.disguise.utilities.reflection.ReflectionManager; | ||||
| import me.libraryaddict.disguise.utilities.translations.LibsMsg; | ||||
| @@ -95,6 +97,9 @@ public abstract class Disguise { | ||||
|     @Getter | ||||
|     @Setter | ||||
|     private boolean customName = true; | ||||
|     @Getter | ||||
|     @Setter | ||||
|     private boolean hideTallSelfDisguise = DisguiseConfig.isHideTallSelfDisguises(); | ||||
|  | ||||
|     public Disguise(DisguiseType disguiseType) { | ||||
|         this.disguiseType = disguiseType; | ||||
| @@ -119,6 +124,7 @@ public abstract class Disguise { | ||||
|     protected void clone(Disguise disguise) { | ||||
|         disguise.setDisguiseName(getDisguiseName()); | ||||
|         disguise.setCustomName(isCustomName()); | ||||
|         disguise.setHideTallSelfDisguise(isHideTallSelfDisguise()); | ||||
|  | ||||
|         disguise.setReplaceSounds(isSoundsReplaced()); | ||||
|         disguise.setViewSelfDisguise(isSelfDisguiseVisible()); | ||||
| @@ -543,6 +549,27 @@ public abstract class Disguise { | ||||
|             setupWatcher(); | ||||
|         } | ||||
|  | ||||
|         if (getEntity() instanceof Player && isSelfDisguiseVisible() && isHideTallSelfDisguise() && | ||||
|                 !getType().isCustom()) { | ||||
|             DisguiseValues values = DisguiseValues.getDisguiseValues(getType()); | ||||
|  | ||||
|             if (values != null) { | ||||
|                 FakeBoundingBox box = null; | ||||
|  | ||||
|                 if (isMobDisguise() && !((MobDisguise) this).isAdult()) { | ||||
|                     box = values.getBabyBox(); | ||||
|                 } | ||||
|  | ||||
|                 if (box == null) { | ||||
|                     box = values.getAdultBox(); | ||||
|                 } | ||||
|  | ||||
|                 if (box != null && box.getY() > 1.7D) { | ||||
|                     setSelfDisguiseVisible(false); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -25,7 +25,7 @@ public class DisguiseValues { | ||||
|     private double maxHealth; | ||||
|     private Class nmsEntityClass; | ||||
|  | ||||
|     public DisguiseValues(DisguiseType type, Class classType, int entitySize, double maxHealth) { | ||||
|     public DisguiseValues(DisguiseType type, Class classType, double maxHealth) { | ||||
|         values.put(type, this); | ||||
|         nmsEntityClass = classType; | ||||
|         this.maxHealth = maxHealth; | ||||
| @@ -35,10 +35,18 @@ public class DisguiseValues { | ||||
|         return adultBox; | ||||
|     } | ||||
|  | ||||
|     public void setAdultBox(FakeBoundingBox newBox) { | ||||
|         adultBox = newBox; | ||||
|     } | ||||
|  | ||||
|     public FakeBoundingBox getBabyBox() { | ||||
|         return babyBox; | ||||
|     } | ||||
|  | ||||
|     public void setBabyBox(FakeBoundingBox newBox) { | ||||
|         babyBox = newBox; | ||||
|     } | ||||
|  | ||||
|     public double getMaxHealth() { | ||||
|         return maxHealth; | ||||
|     } | ||||
| @@ -46,12 +54,4 @@ public class DisguiseValues { | ||||
|     public Class getNmsEntityClass() { | ||||
|         return nmsEntityClass; | ||||
|     } | ||||
|  | ||||
|     public void setAdultBox(FakeBoundingBox newBox) { | ||||
|         adultBox = newBox; | ||||
|     } | ||||
|  | ||||
|     public void setBabyBox(FakeBoundingBox newBox) { | ||||
|         babyBox = newBox; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -114,7 +114,7 @@ public class ParamInfoManager { | ||||
|         // Add these last as it's what we want to present to be called the least | ||||
|         for (String methodName : new String[]{"setSelfDisguiseVisible", "setHideHeldItemFromSelf", | ||||
|                 "setHideArmorFromSelf", "setHearSelfDisguise", "setHidePlayer", "setExpires", "setNotifyBar", | ||||
|                 "setBossBarColor", "setBossBarStyle"}) { | ||||
|                 "setBossBarColor", "setBossBarStyle", "setHideTallSelfDisguise"}) { | ||||
|             try { | ||||
|                 Class cl = boolean.class; | ||||
|  | ||||
|   | ||||
| @@ -1717,7 +1717,7 @@ public class ReflectionManager { | ||||
|  | ||||
|         try { | ||||
|             if (disguiseType == DisguiseType.UNKNOWN || disguiseType.isCustom()) { | ||||
|                 DisguiseValues disguiseValues = new DisguiseValues(disguiseType, null, 0, 0); | ||||
|                 DisguiseValues disguiseValues = new DisguiseValues(disguiseType, null, 0); | ||||
|  | ||||
|                 disguiseValues.setAdultBox(new FakeBoundingBox(0, 0, 0)); | ||||
|  | ||||
| @@ -1758,7 +1758,7 @@ public class ReflectionManager { | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             DisguiseValues disguiseValues = new DisguiseValues(disguiseType, nmsEntity.getClass(), entitySize, | ||||
|             DisguiseValues disguiseValues = new DisguiseValues(disguiseType, nmsEntity.getClass(), | ||||
|                     bukkitEntity instanceof Damageable ? ((Damageable) bukkitEntity).getMaxHealth() : 0); | ||||
|  | ||||
|             WrappedDataWatcher watcher = WrappedDataWatcher.getEntityWatcher(bukkitEntity); | ||||
|   | ||||
| @@ -328,7 +328,8 @@ public enum LibsMsg { | ||||
|     LD_COMMAND_RELOAD(ChatColor.BLUE + "/libsdisguises reload - " + ChatColor.AQUA + | ||||
|             "Reload's the plugin config and possibly blows disguises"), | ||||
|     LD_COMMAND_DEBUG(ChatColor.BLUE + "/libsdisguises debug - " + ChatColor.AQUA + | ||||
|             "Used to help debug scoreboard issues on a player disguise"); | ||||
|             "Used to help debug scoreboard issues on a player disguise"), | ||||
|     SELF_DISGUISE_HIDDEN(ChatColor.GREEN + "Self disguise hidden as it's too tall.."); | ||||
|  | ||||
|     private final String string; | ||||
|  | ||||
|   | ||||
| @@ -119,6 +119,9 @@ UndisguiseRadiusMax: 50 | ||||
| # Shall the players view their disguises? | ||||
| # Best used when viewing yourself in 3rd person | ||||
| ViewSelfDisguises: true | ||||
| # Some disguises are rather big and tall and block your vision | ||||
| # By default those disguises are disabled, such as zombies, players, etc. | ||||
| HideTallSelfDisguises: true | ||||
|  | ||||
| # Shall I disguise the sounds? | ||||
| # This turns your damage sound into a MOOOO | ||||
|   | ||||
		Reference in New Issue
	
	Block a user