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
@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!");

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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)));
}
}

View File

@ -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() {

View File

@ -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)

View File

@ -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() {

View File

@ -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