From 65ee3ed186637165747874a3caf34776b578634c Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Fri, 15 May 2020 10:45:49 +1200 Subject: [PATCH] Add new config option to disable random values for disguises on creation --- .../java/me/libraryaddict/disguise/DisguiseConfig.java | 4 ++++ .../disguisetypes/watchers/AreaEffectCloudWatcher.java | 5 ++++- .../disguise/disguisetypes/watchers/CatWatcher.java | 5 ++++- .../disguise/disguisetypes/watchers/FoxWatcher.java | 5 ++++- .../disguise/disguisetypes/watchers/HorseWatcher.java | 7 +++++-- .../disguise/disguisetypes/watchers/PandaWatcher.java | 7 +++++-- .../disguise/disguisetypes/watchers/RabbitWatcher.java | 6 +++++- .../disguise/disguisetypes/watchers/SlimeWatcher.java | 7 ++++++- .../disguisetypes/watchers/TippedArrowWatcher.java | 3 ++- .../disguisetypes/watchers/TropicalFishWatcher.java | 9 ++++++--- .../disguise/disguisetypes/watchers/VillagerWatcher.java | 5 ++++- .../disguisetypes/watchers/ZombieVillagerWatcher.java | 5 ++++- src/main/resources/config.yml | 4 ++++ 13 files changed, 57 insertions(+), 15 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java b/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java index 82a2e4d6..22e80aa1 100644 --- a/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java +++ b/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java @@ -246,6 +246,9 @@ public class DisguiseConfig { @Getter @Setter private static boolean overrideCustomNames; + @Getter + @Setter + private static boolean randomDisguises; public static boolean isArmorstandsName() { return getPlayerNameType() == PlayerNameType.ARMORSTANDS; @@ -649,6 +652,7 @@ public class DisguiseConfig { setAutoUpdate(config.getBoolean("AutoUpdate")); setTallSelfDisguises(config.getBoolean("TallSelfDisguises")); setOverrideCustomNames(config.getBoolean("OverrideCustomNames")); + setRandomDisguises(config.getBoolean("RandomDisguiseOptions")); if (!LibsPremium.isPremium() && (isSavePlayerDisguises() || isSaveEntityDisguises())) { DisguiseUtilities.getLogger().warning("You must purchase the plugin to use saved disguises!"); diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.java index ca6c1f46..6db80661 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/AreaEffectCloudWatcher.java @@ -1,6 +1,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers; import com.comphenix.protocol.wrappers.WrappedParticle; +import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; import me.libraryaddict.disguise.disguisetypes.MetaIndex; @@ -19,7 +20,9 @@ public class AreaEffectCloudWatcher extends FlagWatcher { public AreaEffectCloudWatcher(Disguise disguise) { super(disguise); - setColor(Color.fromRGB(RandomUtils.nextInt(256), RandomUtils.nextInt(256), RandomUtils.nextInt(256))); + if (DisguiseConfig.isRandomDisguises()) { + setColor(Color.fromRGB(RandomUtils.nextInt(256), RandomUtils.nextInt(256), RandomUtils.nextInt(256))); + } } public float getRadius() { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CatWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CatWatcher.java index 3492be16..8121e75c 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CatWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/CatWatcher.java @@ -1,5 +1,6 @@ package me.libraryaddict.disguise.disguisetypes.watchers; +import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.disguisetypes.AnimalColor; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.MetaIndex; @@ -19,7 +20,9 @@ public class CatWatcher extends TameableWatcher { public CatWatcher(Disguise disguise) { super(disguise); - setType(Cat.Type.values()[new Random().nextInt(Cat.Type.values().length)]); + if (DisguiseConfig.isRandomDisguises()) { + setType(Cat.Type.values()[new Random().nextInt(Cat.Type.values().length)]); + } } public Cat.Type getType() { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FoxWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FoxWatcher.java index 06a1e01e..cb9c113d 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FoxWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/FoxWatcher.java @@ -1,5 +1,6 @@ package me.libraryaddict.disguise.disguisetypes.watchers; +import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue; @@ -17,7 +18,9 @@ public class FoxWatcher extends AgeableWatcher { public FoxWatcher(Disguise disguise) { super(disguise); - setType(Fox.Type.values()[new Random().nextInt(Fox.Type.values().length)]); + if (DisguiseConfig.isRandomDisguises()) { + setType(Fox.Type.values()[new Random().nextInt(Fox.Type.values().length)]); + } } public boolean isSitting() { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.java index 6a0bd25f..d3b33ca8 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.java @@ -1,5 +1,6 @@ package me.libraryaddict.disguise.disguisetypes.watchers; +import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.utilities.DisguiseUtilities; @@ -14,8 +15,10 @@ public class HorseWatcher extends AbstractHorseWatcher { public HorseWatcher(Disguise disguise) { super(disguise); - setStyle(Style.values()[DisguiseUtilities.random.nextInt(Style.values().length)]); - setColor(Color.values()[DisguiseUtilities.random.nextInt(Color.values().length)]); + if (DisguiseConfig.isRandomDisguises()) { + setStyle(Style.values()[DisguiseUtilities.random.nextInt(Style.values().length)]); + setColor(Color.values()[DisguiseUtilities.random.nextInt(Color.values().length)]); + } } public Color getColor() { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PandaWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PandaWatcher.java index b19debe3..11277284 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PandaWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/PandaWatcher.java @@ -1,5 +1,6 @@ package me.libraryaddict.disguise.disguisetypes.watchers; +import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue; @@ -17,8 +18,10 @@ public class PandaWatcher extends AgeableWatcher { public PandaWatcher(Disguise disguise) { super(disguise); - setMainGene(Panda.Gene.values()[new Random().nextInt(Panda.Gene.values().length)]); - setHiddenGene(Panda.Gene.values()[new Random().nextInt(Panda.Gene.values().length)]); + if (DisguiseConfig.isRandomDisguises()) { + setMainGene(Panda.Gene.values()[new Random().nextInt(Panda.Gene.values().length)]); + setHiddenGene(Panda.Gene.values()[new Random().nextInt(Panda.Gene.values().length)]); + } } public Panda.Gene getMainGene() { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/RabbitWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/RabbitWatcher.java index 27dc9e73..bf3bca2f 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/RabbitWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/RabbitWatcher.java @@ -1,5 +1,6 @@ package me.libraryaddict.disguise.disguisetypes.watchers; +import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.RabbitType; @@ -10,7 +11,10 @@ public class RabbitWatcher extends AgeableWatcher { public RabbitWatcher(Disguise disguise) { super(disguise); - setType(RabbitType.values()[DisguiseUtilities.random.nextInt(RabbitType.values().length)]); + + if (DisguiseConfig.isRandomDisguises()) { + setType(RabbitType.values()[DisguiseUtilities.random.nextInt(RabbitType.values().length)]); + } } public RabbitType getType() { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SlimeWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SlimeWatcher.java index 06a2a120..6661f456 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SlimeWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/SlimeWatcher.java @@ -1,5 +1,6 @@ package me.libraryaddict.disguise.disguisetypes.watchers; +import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.utilities.DisguiseUtilities; @@ -10,7 +11,11 @@ public class SlimeWatcher extends InsentientWatcher { public SlimeWatcher(Disguise disguise) { super(disguise); - setSize(DisguiseUtilities.random.nextInt(4) + 1); + if (DisguiseConfig.isRandomDisguises()) { + setSize(DisguiseUtilities.random.nextInt(4) + 1); + } else { + setSize(2); + } } public int getSize() { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TippedArrowWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TippedArrowWatcher.java index 690b4f5f..f03fb209 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TippedArrowWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TippedArrowWatcher.java @@ -1,5 +1,6 @@ package me.libraryaddict.disguise.disguisetypes.watchers; +import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.DisguiseType; import me.libraryaddict.disguise.disguisetypes.MetaIndex; @@ -15,7 +16,7 @@ public class TippedArrowWatcher extends ArrowWatcher { public TippedArrowWatcher(Disguise disguise) { super(disguise); - if (getDisguise().getType() != DisguiseType.ARROW) { + if (getDisguise().getType() != DisguiseType.ARROW && DisguiseConfig.isRandomDisguises()) { setColor(Color.fromRGB(RandomUtils.nextInt(256), RandomUtils.nextInt(256), RandomUtils.nextInt(256))); } } diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TropicalFishWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TropicalFishWatcher.java index 26e6fc77..25de3019 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TropicalFishWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/TropicalFishWatcher.java @@ -1,5 +1,6 @@ package me.libraryaddict.disguise.disguisetypes.watchers; +import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue; @@ -58,9 +59,11 @@ public class TropicalFishWatcher extends FishWatcher { public TropicalFishWatcher(Disguise disguise) { super(disguise); - this.setPattern(TropicalFish.Pattern.values()[RandomUtils.nextInt(TropicalFish.Pattern.values().length)]); - this.setBodyColor(DyeColor.values()[RandomUtils.nextInt(DyeColor.values().length)]); - this.setPatternColor(DyeColor.values()[RandomUtils.nextInt(DyeColor.values().length)]); + if (DisguiseConfig.isRandomDisguises()) { + this.setPattern(TropicalFish.Pattern.values()[RandomUtils.nextInt(TropicalFish.Pattern.values().length)]); + this.setBodyColor(DyeColor.values()[RandomUtils.nextInt(DyeColor.values().length)]); + this.setPatternColor(DyeColor.values()[RandomUtils.nextInt(DyeColor.values().length)]); + } } public DyeColor getPatternColor() { diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java index 20c1f5b2..6bfe3d28 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java @@ -1,5 +1,6 @@ package me.libraryaddict.disguise.disguisetypes.watchers; +import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.VillagerData; @@ -15,7 +16,9 @@ public class VillagerWatcher extends AbstractVillagerWatcher { public VillagerWatcher(Disguise disguise) { super(disguise); - setProfession(Profession.values()[DisguiseUtilities.random.nextInt(Profession.values().length)]); + if (DisguiseConfig.isRandomDisguises()) { + setProfession(Profession.values()[DisguiseUtilities.random.nextInt(Profession.values().length)]); + } } @NmsAddedIn(val = NmsVersion.v1_14) diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieVillagerWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieVillagerWatcher.java index 578ea5f5..2886fed7 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieVillagerWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/watchers/ZombieVillagerWatcher.java @@ -1,5 +1,6 @@ package me.libraryaddict.disguise.disguisetypes.watchers; +import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.VillagerData; @@ -16,7 +17,9 @@ public class ZombieVillagerWatcher extends ZombieWatcher { public ZombieVillagerWatcher(Disguise disguise) { super(disguise); - setProfession(Profession.values()[new Random().nextInt(Profession.values().length)]); + if (DisguiseConfig.isRandomDisguises()) { + setProfession(Profession.values()[new Random().nextInt(Profession.values().length)]); + } } public boolean isShaking() { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 3464459f..b9383c3f 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -29,6 +29,10 @@ Permissions: # NOT_OP = Only non operators can see this SeeCommands: TRUE +# Some disguises have randomized options on disguise, such as a fox type or a villager breed. +# This may be problematic for some server owners, so you can disable it below +RandomDisguiseOptions: true + # You can also get this information through /libsdisguises config # Should the plugin output missing config options instead of just counting them VerboseConfig: false