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,8 +20,10 @@ public class AreaEffectCloudWatcher extends FlagWatcher {
public AreaEffectCloudWatcher(Disguise disguise) {
super(disguise);
if (DisguiseConfig.isRandomDisguises()) {
setColor(Color.fromRGB(RandomUtils.nextInt(256), RandomUtils.nextInt(256), RandomUtils.nextInt(256)));
}
}
public float getRadius() {
return getData(MetaIndex.AREA_EFFECT_RADIUS);

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,8 +20,10 @@ public class CatWatcher extends TameableWatcher {
public CatWatcher(Disguise disguise) {
super(disguise);
if (DisguiseConfig.isRandomDisguises()) {
setType(Cat.Type.values()[new Random().nextInt(Cat.Type.values().length)]);
}
}
public Cat.Type getType() {
return Cat.Type.values()[getData(MetaIndex.CAT_TYPE)];

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 FoxWatcher extends AgeableWatcher {
public FoxWatcher(Disguise disguise) {
super(disguise);
if (DisguiseConfig.isRandomDisguises()) {
setType(Fox.Type.values()[new Random().nextInt(Fox.Type.values().length)]);
}
}
public boolean isSitting() {
return getFoxFlag(1);

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,9 +15,11 @@ public class HorseWatcher extends AbstractHorseWatcher {
public HorseWatcher(Disguise disguise) {
super(disguise);
if (DisguiseConfig.isRandomDisguises()) {
setStyle(Style.values()[DisguiseUtilities.random.nextInt(Style.values().length)]);
setColor(Color.values()[DisguiseUtilities.random.nextInt(Color.values().length)]);
}
}
public Color getColor() {
return Color.values()[(getData(MetaIndex.HORSE_COLOR) & 0xFF)];

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,9 +18,11 @@ public class PandaWatcher extends AgeableWatcher {
public PandaWatcher(Disguise disguise) {
super(disguise);
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() {
int id = getData(MetaIndex.PANDA_MAIN_GENE);

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,8 +11,11 @@ public class RabbitWatcher extends AgeableWatcher {
public RabbitWatcher(Disguise disguise) {
super(disguise);
if (DisguiseConfig.isRandomDisguises()) {
setType(RabbitType.values()[DisguiseUtilities.random.nextInt(RabbitType.values().length)]);
}
}
public RabbitType getType() {
return RabbitType.getType(getData(MetaIndex.RABBIT_TYPE));

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);
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,10 +59,12 @@ public class TropicalFishWatcher extends FishWatcher {
public TropicalFishWatcher(Disguise disguise) {
super(disguise);
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() {
return DyeColor.getByWoolData((byte) (getVariant() >> 24 & 0xFF));

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,8 +16,10 @@ public class VillagerWatcher extends AbstractVillagerWatcher {
public VillagerWatcher(Disguise disguise) {
super(disguise);
if (DisguiseConfig.isRandomDisguises()) {
setProfession(Profession.values()[DisguiseUtilities.random.nextInt(Profession.values().length)]);
}
}
@NmsAddedIn(val = NmsVersion.v1_14)
public VillagerData getVillagerData() {

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,8 +17,10 @@ public class ZombieVillagerWatcher extends ZombieWatcher {
public ZombieVillagerWatcher(Disguise disguise) {
super(disguise);
if (DisguiseConfig.isRandomDisguises()) {
setProfession(Profession.values()[new Random().nextInt(Profession.values().length)]);
}
}
public boolean isShaking() {
return getData(MetaIndex.ZOMBIE_VILLAGER_SHAKING);

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