Add new options to disable collisions and see friendly invisibles for scoreboards in config, fixed a minor bug where create scoreboard would override settings
This commit is contained in:
		| @@ -39,6 +39,13 @@ Translations: false | |||||||
| # CREATE_SCOREBOARD - Creates a new team which copies the attributes of their previous scoreboard team which they are then assigned to. This means they keep nametag color and other options. | # CREATE_SCOREBOARD - Creates a new team which copies the attributes of their previous scoreboard team which they are then assigned to. This means they keep nametag color and other options. | ||||||
| SelfDisguisesScoreboard: MODIFY_SCOREBOARD | SelfDisguisesScoreboard: MODIFY_SCOREBOARD | ||||||
|  |  | ||||||
|  | # More options incase you want to disable a specific setting of the scoreboard | ||||||
|  | Scoreboard: | ||||||
|  |   # Should it modify the scoreboard to turn collisions off? | ||||||
|  |   Collisions: true | ||||||
|  |   # Should it modify the scoreboard teams to disable seeing friendly invisibles? | ||||||
|  |   SeeFriendlyInvisibles: true | ||||||
|  |  | ||||||
| # Whats the permission to get the notification? | # Whats the permission to get the notification? | ||||||
| Permission: 'libsdisguises.update' | Permission: 'libsdisguises.update' | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,19 +1,18 @@ | |||||||
| package me.libraryaddict.disguise; | package me.libraryaddict.disguise; | ||||||
|  |  | ||||||
| import java.io.File; | import me.libraryaddict.disguise.disguisetypes.Disguise; | ||||||
| import java.util.HashMap; | import me.libraryaddict.disguise.utilities.DisguiseParser; | ||||||
| import java.util.Map.Entry; | import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException; | ||||||
|  |  | ||||||
| import me.libraryaddict.disguise.utilities.LibsPremium; | import me.libraryaddict.disguise.utilities.LibsPremium; | ||||||
|  | import me.libraryaddict.disguise.utilities.PacketsManager; | ||||||
| import me.libraryaddict.disguise.utilities.TranslateType; | import me.libraryaddict.disguise.utilities.TranslateType; | ||||||
| import org.bukkit.Bukkit; | import org.bukkit.Bukkit; | ||||||
| import org.bukkit.configuration.ConfigurationSection; | import org.bukkit.configuration.ConfigurationSection; | ||||||
| import org.bukkit.configuration.file.YamlConfiguration; | import org.bukkit.configuration.file.YamlConfiguration; | ||||||
|  |  | ||||||
| import me.libraryaddict.disguise.disguisetypes.Disguise; | import java.io.File; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser; | import java.util.HashMap; | ||||||
| import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException; | import java.util.Map.Entry; | ||||||
| import me.libraryaddict.disguise.utilities.PacketsManager; |  | ||||||
|  |  | ||||||
| public class DisguiseConfig { | public class DisguiseConfig { | ||||||
|     public static enum DisguisePushing { // This enum has a really bad name.. |     public static enum DisguisePushing { // This enum has a really bad name.. | ||||||
| @@ -63,11 +62,13 @@ public class DisguiseConfig { | |||||||
|     private static boolean savePlayerDisguises; |     private static boolean savePlayerDisguises; | ||||||
|     private static boolean saveEntityDisguises; |     private static boolean saveEntityDisguises; | ||||||
|     private static boolean useTranslations; |     private static boolean useTranslations; | ||||||
|  |     private static boolean modifyCollisions; | ||||||
|  |     private static boolean modifySeeFriendlyInvisibles; | ||||||
|  |  | ||||||
|     public static Entry<String, Disguise> getCustomDisguise(String disguise) { |     public static Entry<String, Disguise> getCustomDisguise(String disguise) { | ||||||
|         for (Entry<String, Disguise> entry : customDisguises.entrySet()) { |         for (Entry<String, Disguise> entry : customDisguises.entrySet()) { | ||||||
|             if (!entry.getKey().equalsIgnoreCase(disguise) && !entry.getKey().replaceAll("_", "") |             if (!entry.getKey().equalsIgnoreCase(disguise) && | ||||||
|                     .equalsIgnoreCase(disguise)) |                     !entry.getKey().replaceAll("_", "").equalsIgnoreCase(disguise)) | ||||||
|                 continue; |                 continue; | ||||||
|  |  | ||||||
|             return entry; |             return entry; | ||||||
| @@ -76,6 +77,22 @@ public class DisguiseConfig { | |||||||
|         return null; |         return null; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     public static boolean isModifyCollisions() { | ||||||
|  |         return modifyCollisions; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public static boolean isModifySeeFriendlyInvisibles() { | ||||||
|  |         return modifySeeFriendlyInvisibles; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public static void setModifyCollisions(boolean isModifyCollisions) { | ||||||
|  |         modifyCollisions = isModifyCollisions; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public static void setModifySeeFriendlyInvisibles(boolean isModifySeeFriendlyInvisibles) { | ||||||
|  |         modifySeeFriendlyInvisibles = isModifySeeFriendlyInvisibles; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     public static boolean isSavePlayerDisguises() { |     public static boolean isSavePlayerDisguises() { | ||||||
|         return savePlayerDisguises; |         return savePlayerDisguises; | ||||||
|     } |     } | ||||||
| @@ -188,6 +205,8 @@ public class DisguiseConfig { | |||||||
|         setSavePlayerDisguises(config.getBoolean("SaveDisguises.Players")); |         setSavePlayerDisguises(config.getBoolean("SaveDisguises.Players")); | ||||||
|         setSaveEntityDisguises(config.getBoolean("SaveDisguises.Entities")); |         setSaveEntityDisguises(config.getBoolean("SaveDisguises.Entities")); | ||||||
|         setUseTranslations(config.getBoolean("Translations")); |         setUseTranslations(config.getBoolean("Translations")); | ||||||
|  |         setModifyCollisions(config.getBoolean("Scoreboard.Collisions")); | ||||||
|  |         setModifySeeFriendlyInvisibles(config.getBoolean("Scoreboard.SeeFriendlyInvisibles")); | ||||||
|  |  | ||||||
|         if (!LibsPremium.isPremium() && (isSavePlayerDisguises() || isSaveEntityDisguises())) { |         if (!LibsPremium.isPremium() && (isSavePlayerDisguises() || isSaveEntityDisguises())) { | ||||||
|             System.out.println("[LibsDisguises] You must purchase the plugin to use saved disguises!"); |             System.out.println("[LibsDisguises] You must purchase the plugin to use saved disguises!"); | ||||||
| @@ -203,8 +222,8 @@ public class DisguiseConfig { | |||||||
|             disablePushing = DisguisePushing.valueOf(option); |             disablePushing = DisguisePushing.valueOf(option); | ||||||
|         } |         } | ||||||
|         catch (Exception ex) { |         catch (Exception ex) { | ||||||
|             System.out.println("[LibsDisguises] Cannot parse '" + config |             System.out.println("[LibsDisguises] Cannot parse '" + config.getString("SelfDisguisesScoreboard") + | ||||||
|                     .getString("SelfDisguisesScoreboard") + "' to a valid option for SelfDisguisesTeam"); |                     "' to a valid option for SelfDisguisesTeam"); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         customDisguises.clear(); |         customDisguises.clear(); | ||||||
| @@ -241,9 +260,8 @@ public class DisguiseConfig { | |||||||
|                 System.out.println("[LibsDisguises] Loaded custom disguise " + key); |                 System.out.println("[LibsDisguises] Loaded custom disguise " + key); | ||||||
|             } |             } | ||||||
|             catch (DisguiseParseException e) { |             catch (DisguiseParseException e) { | ||||||
|                 System.err.println( |                 System.err.println("[LibsDisguises] Error while loading custom disguise '" + key + "'" + | ||||||
|                         "[LibsDisguises] Error while loading custom disguise '" + key + "'" + (e.getMessage() == null ? |                         (e.getMessage() == null ? "" : ": " + e.getMessage())); | ||||||
|                                 "" : ": " + e.getMessage())); |  | ||||||
|  |  | ||||||
|                 if (e.getMessage() == null) |                 if (e.getMessage() == null) | ||||||
|                     e.printStackTrace(); |                     e.printStackTrace(); | ||||||
| @@ -253,9 +271,8 @@ public class DisguiseConfig { | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         System.out.println( |         System.out.println("[LibsDisguises] Loaded " + customDisguises.size() + " custom disguise" + | ||||||
|                 "[LibsDisguises] Loaded " + customDisguises.size() + " custom disguise" + (customDisguises.size() == 1 ? |                 (customDisguises.size() == 1 ? "" : "s")); | ||||||
|                         "" : "s")); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static boolean isAnimationPacketsEnabled() { |     public static boolean isAnimationPacketsEnabled() { | ||||||
| @@ -299,14 +316,16 @@ public class DisguiseConfig { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Is the plugin modifying the inventory packets so that players when self disguised, do not see their armor floating around |      * Is the plugin modifying the inventory packets so that players when self disguised, do not see their armor | ||||||
|  |      * floating around | ||||||
|      */ |      */ | ||||||
|     public static boolean isHidingArmorFromSelf() { |     public static boolean isHidingArmorFromSelf() { | ||||||
|         return hidingArmor; |         return hidingArmor; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Does the plugin appear to remove the item they are holding, to prevent a floating sword when they are viewing self disguise |      * Does the plugin appear to remove the item they are holding, to prevent a floating sword when they are viewing | ||||||
|  |      * self disguise | ||||||
|      */ |      */ | ||||||
|     public static boolean isHidingHeldItemFromSelf() { |     public static boolean isHidingHeldItemFromSelf() { | ||||||
|         return hidingHeldItem; |         return hidingHeldItem; | ||||||
| @@ -490,7 +509,8 @@ public class DisguiseConfig { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Does the plugin appear to remove the item they are holding, to prevent a floating sword when they are viewing self disguise |      * Does the plugin appear to remove the item they are holding, to prevent a floating sword when they are viewing | ||||||
|  |      * self disguise | ||||||
|      */ |      */ | ||||||
|     public static void setHideHeldItemFromSelf(boolean hideHelditem) { |     public static void setHideHeldItemFromSelf(boolean hideHelditem) { | ||||||
|         if (hidingHeldItem != hideHelditem) { |         if (hidingHeldItem != hideHelditem) { | ||||||
|   | |||||||
| @@ -491,7 +491,7 @@ public abstract class Disguise { | |||||||
|  |  | ||||||
|         Bukkit.getPluginManager().callEvent(event); |         Bukkit.getPluginManager().callEvent(event); | ||||||
|  |  | ||||||
|         // If this disguise is not in use, and the entity isnt a player |         // If this disguise is not in use, and the entity isnt a player that's offline | ||||||
|         if (event.isCancelled() && (!(getEntity() instanceof Player) || ((Player) getEntity()).isOnline())) |         if (event.isCancelled() && (!(getEntity() instanceof Player) || ((Player) getEntity()).isOnline())) | ||||||
|             return false; |             return false; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1357,14 +1357,6 @@ public class DisguiseUtilities { | |||||||
|                     ldTeam = scoreboard.registerNewTeam(ldTeamName); |                     ldTeam = scoreboard.registerNewTeam(ldTeamName); | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 if (ldTeam.getOption(Option.COLLISION_RULE) != OptionStatus.NEVER) { |  | ||||||
|                     ldTeam.setOption(Option.COLLISION_RULE, OptionStatus.NEVER); |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 if (ldTeam.canSeeFriendlyInvisibles()) { |  | ||||||
|                     ldTeam.setCanSeeFriendlyInvisibles(false); |  | ||||||
|                 } |  | ||||||
|  |  | ||||||
|                 if (!ldTeam.hasEntry(player.getName())) |                 if (!ldTeam.hasEntry(player.getName())) | ||||||
|                     ldTeam.addEntry(player.getName()); |                     ldTeam.addEntry(player.getName()); | ||||||
|  |  | ||||||
| @@ -1379,6 +1371,15 @@ public class DisguiseUtilities { | |||||||
|                         ldTeam.setOption(option, prevTeam.getOption(option)); |                         ldTeam.setOption(option, prevTeam.getOption(option)); | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|  |                 if (ldTeam.getOption(Option.COLLISION_RULE) != OptionStatus.NEVER && | ||||||
|  |                         DisguiseConfig.isModifyCollisions()) { | ||||||
|  |                     ldTeam.setOption(Option.COLLISION_RULE, OptionStatus.NEVER); | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |                 if (ldTeam.canSeeFriendlyInvisibles() && DisguiseConfig.isModifySeeFriendlyInvisibles()) { | ||||||
|  |                     ldTeam.setCanSeeFriendlyInvisibles(false); | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             // Add himself to his own entity tracker |             // Add himself to his own entity tracker | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user