Add new config option to disable random values for disguises on creation

This commit is contained in:
libraryaddict 2020-05-15 10:45:49 +12:00
parent acce02a1b7
commit 65ee3ed186
No known key found for this signature in database
GPG Key ID: 052E4FBCD257AEA4
13 changed files with 57 additions and 15 deletions

View File

@ -246,6 +246,9 @@ public class DisguiseConfig {
@Getter @Getter
@Setter @Setter
private static boolean overrideCustomNames; private static boolean overrideCustomNames;
@Getter
@Setter
private static boolean randomDisguises;
public static boolean isArmorstandsName() { public static boolean isArmorstandsName() {
return getPlayerNameType() == PlayerNameType.ARMORSTANDS; return getPlayerNameType() == PlayerNameType.ARMORSTANDS;
@ -649,6 +652,7 @@ public class DisguiseConfig {
setAutoUpdate(config.getBoolean("AutoUpdate")); setAutoUpdate(config.getBoolean("AutoUpdate"));
setTallSelfDisguises(config.getBoolean("TallSelfDisguises")); setTallSelfDisguises(config.getBoolean("TallSelfDisguises"));
setOverrideCustomNames(config.getBoolean("OverrideCustomNames")); setOverrideCustomNames(config.getBoolean("OverrideCustomNames"));
setRandomDisguises(config.getBoolean("RandomDisguiseOptions"));
if (!LibsPremium.isPremium() && (isSavePlayerDisguises() || isSaveEntityDisguises())) { if (!LibsPremium.isPremium() && (isSavePlayerDisguises() || isSaveEntityDisguises())) {
DisguiseUtilities.getLogger().warning("You must purchase the plugin to use saved disguises!"); DisguiseUtilities.getLogger().warning("You must purchase the plugin to use saved disguises!");

View File

@ -1,6 +1,7 @@
package me.libraryaddict.disguise.disguisetypes.watchers; package me.libraryaddict.disguise.disguisetypes.watchers;
import com.comphenix.protocol.wrappers.WrappedParticle; import com.comphenix.protocol.wrappers.WrappedParticle;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.FlagWatcher; import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.MetaIndex;
@ -19,7 +20,9 @@ public class AreaEffectCloudWatcher extends FlagWatcher {
public AreaEffectCloudWatcher(Disguise disguise) { public AreaEffectCloudWatcher(Disguise disguise) {
super(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() { public float getRadius() {

View File

@ -1,5 +1,6 @@
package me.libraryaddict.disguise.disguisetypes.watchers; package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.AnimalColor; import me.libraryaddict.disguise.disguisetypes.AnimalColor;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.MetaIndex;
@ -19,7 +20,9 @@ public class CatWatcher extends TameableWatcher {
public CatWatcher(Disguise disguise) { public CatWatcher(Disguise disguise) {
super(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() { public Cat.Type getType() {

View File

@ -1,5 +1,6 @@
package me.libraryaddict.disguise.disguisetypes.watchers; package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue; import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue;
@ -17,7 +18,9 @@ public class FoxWatcher extends AgeableWatcher {
public FoxWatcher(Disguise disguise) { public FoxWatcher(Disguise disguise) {
super(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() { public boolean isSitting() {

View File

@ -1,5 +1,6 @@
package me.libraryaddict.disguise.disguisetypes.watchers; package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
@ -14,8 +15,10 @@ public class HorseWatcher extends AbstractHorseWatcher {
public HorseWatcher(Disguise disguise) { public HorseWatcher(Disguise disguise) {
super(disguise); super(disguise);
setStyle(Style.values()[DisguiseUtilities.random.nextInt(Style.values().length)]); if (DisguiseConfig.isRandomDisguises()) {
setColor(Color.values()[DisguiseUtilities.random.nextInt(Color.values().length)]); setStyle(Style.values()[DisguiseUtilities.random.nextInt(Style.values().length)]);
setColor(Color.values()[DisguiseUtilities.random.nextInt(Color.values().length)]);
}
} }
public Color getColor() { public Color getColor() {

View File

@ -1,5 +1,6 @@
package me.libraryaddict.disguise.disguisetypes.watchers; package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue; import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue;
@ -17,8 +18,10 @@ public class PandaWatcher extends AgeableWatcher {
public PandaWatcher(Disguise disguise) { public PandaWatcher(Disguise disguise) {
super(disguise); super(disguise);
setMainGene(Panda.Gene.values()[new Random().nextInt(Panda.Gene.values().length)]); if (DisguiseConfig.isRandomDisguises()) {
setHiddenGene(Panda.Gene.values()[new Random().nextInt(Panda.Gene.values().length)]); 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() { public Panda.Gene getMainGene() {

View File

@ -1,5 +1,6 @@
package me.libraryaddict.disguise.disguisetypes.watchers; package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import me.libraryaddict.disguise.disguisetypes.RabbitType; import me.libraryaddict.disguise.disguisetypes.RabbitType;
@ -10,7 +11,10 @@ public class RabbitWatcher extends AgeableWatcher {
public RabbitWatcher(Disguise disguise) { public RabbitWatcher(Disguise disguise) {
super(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() { public RabbitType getType() {

View File

@ -1,5 +1,6 @@
package me.libraryaddict.disguise.disguisetypes.watchers; package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
@ -10,7 +11,11 @@ public class SlimeWatcher extends InsentientWatcher {
public SlimeWatcher(Disguise disguise) { public SlimeWatcher(Disguise disguise) {
super(disguise); super(disguise);
setSize(DisguiseUtilities.random.nextInt(4) + 1); if (DisguiseConfig.isRandomDisguises()) {
setSize(DisguiseUtilities.random.nextInt(4) + 1);
} else {
setSize(2);
}
} }
public int getSize() { public int getSize() {

View File

@ -1,5 +1,6 @@
package me.libraryaddict.disguise.disguisetypes.watchers; package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.DisguiseType; import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.MetaIndex;
@ -15,7 +16,7 @@ public class TippedArrowWatcher extends ArrowWatcher {
public TippedArrowWatcher(Disguise disguise) { public TippedArrowWatcher(Disguise disguise) {
super(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))); setColor(Color.fromRGB(RandomUtils.nextInt(256), RandomUtils.nextInt(256), RandomUtils.nextInt(256)));
} }
} }

View File

@ -1,5 +1,6 @@
package me.libraryaddict.disguise.disguisetypes.watchers; package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue; import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue;
@ -58,9 +59,11 @@ public class TropicalFishWatcher extends FishWatcher {
public TropicalFishWatcher(Disguise disguise) { public TropicalFishWatcher(Disguise disguise) {
super(disguise); super(disguise);
this.setPattern(TropicalFish.Pattern.values()[RandomUtils.nextInt(TropicalFish.Pattern.values().length)]); if (DisguiseConfig.isRandomDisguises()) {
this.setBodyColor(DyeColor.values()[RandomUtils.nextInt(DyeColor.values().length)]); this.setPattern(TropicalFish.Pattern.values()[RandomUtils.nextInt(TropicalFish.Pattern.values().length)]);
this.setPatternColor(DyeColor.values()[RandomUtils.nextInt(DyeColor.values().length)]); this.setBodyColor(DyeColor.values()[RandomUtils.nextInt(DyeColor.values().length)]);
this.setPatternColor(DyeColor.values()[RandomUtils.nextInt(DyeColor.values().length)]);
}
} }
public DyeColor getPatternColor() { public DyeColor getPatternColor() {

View File

@ -1,5 +1,6 @@
package me.libraryaddict.disguise.disguisetypes.watchers; package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import me.libraryaddict.disguise.disguisetypes.VillagerData; import me.libraryaddict.disguise.disguisetypes.VillagerData;
@ -15,7 +16,9 @@ public class VillagerWatcher extends AbstractVillagerWatcher {
public VillagerWatcher(Disguise disguise) { public VillagerWatcher(Disguise disguise) {
super(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) @NmsAddedIn(val = NmsVersion.v1_14)

View File

@ -1,5 +1,6 @@
package me.libraryaddict.disguise.disguisetypes.watchers; package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import me.libraryaddict.disguise.disguisetypes.VillagerData; import me.libraryaddict.disguise.disguisetypes.VillagerData;
@ -16,7 +17,9 @@ public class ZombieVillagerWatcher extends ZombieWatcher {
public ZombieVillagerWatcher(Disguise disguise) { public ZombieVillagerWatcher(Disguise disguise) {
super(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() { public boolean isShaking() {

View File

@ -29,6 +29,10 @@ Permissions:
# NOT_OP = Only non operators can see this # NOT_OP = Only non operators can see this
SeeCommands: TRUE 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 # You can also get this information through /libsdisguises config
# Should the plugin output missing config options instead of just counting them # Should the plugin output missing config options instead of just counting them
VerboseConfig: false VerboseConfig: false