Add minumum version requirements to mutations
This commit is contained in:
parent
c4b22575f9
commit
45d0ff46ae
|
@ -7,8 +7,11 @@ import net.md_5.bungee.api.ChatColor;
|
|||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TranslatableComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import tc.oc.commons.core.chat.Component;
|
||||
import tc.oc.minecraft.protocol.MinecraftVersion;
|
||||
import tc.oc.pgm.PGM;
|
||||
import tc.oc.pgm.mutation.types.MutationModule;
|
||||
import tc.oc.pgm.mutation.types.kit.*;
|
||||
|
@ -27,22 +30,22 @@ public enum Mutation {
|
|||
HARDCORE (HardcoreMutation.class, Material.GOLDEN_APPLE),
|
||||
JUMP (JumpMutation.class, Material.FEATHER),
|
||||
EXPLOSIVE (ExplosiveMutation.class, Material.FLINT_AND_STEEL),
|
||||
ELYTRA (ElytraMutation.class, Material.ELYTRA),
|
||||
ELYTRA (ElytraMutation.class, Material.ELYTRA, MinecraftVersion.MINECRAFT_1_9),
|
||||
PROJECTILE (ProjectileMutation.class, Material.TIPPED_ARROW),
|
||||
ENCHANTMENT(EnchantmentMutation.class, Material.ENCHANTMENT_TABLE),
|
||||
POTION (PotionMutation.class, Material.POTION),
|
||||
EQUESTRIAN (EquestrianMutation.class, Material.SADDLE),
|
||||
EQUESTRIAN (EquestrianMutation.class, Material.SADDLE, MinecraftVersion.MINECRAFT_1_9),
|
||||
HEALTH (HealthMutation.class, Material.COOKED_BEEF),
|
||||
GLOW (GlowMutation.class, Material.GLOWSTONE_DUST, false),
|
||||
GLOW (GlowMutation.class, Material.GLOWSTONE_DUST, MinecraftVersion.MINECRAFT_1_9),
|
||||
STEALTH (StealthMutation.class, Material.THIN_GLASS),
|
||||
ARMOR (ArmorMutation.class, Material.DIAMOND_CHESTPLATE),
|
||||
MOBS (MobsMutation.class, Material.MONSTER_EGG),
|
||||
LIGHTNING (LightningMutation.class, Material.JACK_O_LANTERN),
|
||||
BOMBER (BomberMutation.class, Material.TNT),
|
||||
BREAD (BreadMutation.class, Material.BREAD),
|
||||
BOAT (BoatMutation.class, Material.BOAT, false),
|
||||
BOAT (BoatMutation.class, Material.BOAT, MinecraftVersion.MINECRAFT_1_9),
|
||||
TOOLS (ToolsMutation.class, Material.DIAMOND_PICKAXE),
|
||||
APOCALYPSE (ApocalypseMutation.class, Material.NETHER_STAR);
|
||||
APOCALYPSE (ApocalypseMutation.class, Material.NETHER_STAR, false);
|
||||
|
||||
public static final String TYPE_KEY = "mutation.type.";
|
||||
public static final String DESCRIPTION_KEY = ".desc";
|
||||
|
@ -50,15 +53,25 @@ public enum Mutation {
|
|||
private final @Nullable Class<? extends MutationModule> loader;
|
||||
private final Material guiDisplay;
|
||||
private final boolean pollable;
|
||||
private final MinecraftVersion minimumVersion;
|
||||
|
||||
Mutation(@Nullable Class<? extends MutationModule> loader, Material guiDisplay, MinecraftVersion minimumVersion) {
|
||||
this(loader, guiDisplay, true, minimumVersion);
|
||||
}
|
||||
|
||||
Mutation(@Nullable Class<? extends MutationModule> loader, Material guiDisplay) {
|
||||
this(loader, guiDisplay, true);
|
||||
}
|
||||
|
||||
Mutation(@Nullable Class<? extends MutationModule> loader, Material guiDisplay, boolean pollable) {
|
||||
this(loader, guiDisplay, pollable, MinecraftVersion.MINECRAFT_1_4_7);
|
||||
}
|
||||
|
||||
Mutation(@Nullable Class<? extends MutationModule> loader, Material guiDisplay, boolean pollable, MinecraftVersion minimumVersion) {
|
||||
this.loader = loader;
|
||||
this.guiDisplay = guiDisplay;
|
||||
this.pollable = pollable;
|
||||
this.minimumVersion = minimumVersion;
|
||||
}
|
||||
|
||||
public Class<? extends MutationModule> loader() {
|
||||
|
@ -70,7 +83,16 @@ public enum Mutation {
|
|||
}
|
||||
|
||||
public boolean isPollable() {
|
||||
return pollable;
|
||||
if (!pollable) return false;
|
||||
|
||||
double total = Bukkit.getOnlinePlayers().size();
|
||||
double withSupport = 0;
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (MinecraftVersion.atLeast(minimumVersion, player.getProtocolVersion()))
|
||||
withSupport++;
|
||||
}
|
||||
|
||||
return (withSupport / total) > .75;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
|
Loading…
Reference in New Issue