This repository was archived by the owner on Nov 25, 2019. It is now read-only.
forked from OvercastNetwork/ProjectAres
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathMutation.java
More file actions
102 lines (84 loc) · 3.93 KB
/
Mutation.java
File metadata and controls
102 lines (84 loc) · 3.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package tc.oc.pgm.mutation;
import javax.annotation.Nullable;
import com.google.common.base.Function;
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.Material;
import tc.oc.commons.core.chat.Component;
import tc.oc.pgm.PGM;
import tc.oc.pgm.mutation.types.MutationModule;
import tc.oc.pgm.mutation.types.kit.*;
import tc.oc.pgm.mutation.types.other.BlitzMutation;
import tc.oc.pgm.mutation.types.other.RageMutation;
import tc.oc.pgm.mutation.types.targetable.ApocalypseMutation;
import tc.oc.pgm.mutation.types.targetable.BomberMutation;
import tc.oc.pgm.mutation.types.targetable.LightningMutation;
import java.util.stream.Stream;
public enum Mutation {
BLITZ (BlitzMutation.class, Material.IRON_FENCE, false),
RAGE (RageMutation.class, Material.SKULL_ITEM, false),
HARDCORE (HardcoreMutation.class, Material.GOLDEN_APPLE),
JUMP (JumpMutation.class, Material.FEATHER),
EXPLOSIVE (ExplosiveMutation.class, Material.FLINT_AND_STEEL),
ELYTRA (ElytraMutation.class, Material.ELYTRA),
PROJECTILE (ProjectileMutation.class, Material.TIPPED_ARROW),
ENCHANTMENT(EnchantmentMutation.class, Material.ENCHANTMENT_TABLE),
POTION (PotionMutation.class, Material.POTION),
EQUESTRIAN (EquestrianMutation.class, Material.SADDLE),
HEALTH (HealthMutation.class, Material.COOKED_BEEF),
GLOW (GlowMutation.class, Material.GLOWSTONE_DUST, false),
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),
TOOLS (ToolsMutation.class, Material.DIAMOND_PICKAXE),
APOCALYPSE (ApocalypseMutation.class, Material.NETHER_STAR),
TEAMCHEST (TeamChestMutation.class, Material.ENDER_CHEST);
public static final String TYPE_KEY = "mutation.type.";
public static final String DESCRIPTION_KEY = ".desc";
private final @Nullable Class<? extends MutationModule> loader;
private final Material guiDisplay;
private final boolean pollable;
Mutation(@Nullable Class<? extends MutationModule> loader, Material guiDisplay) {
this(loader, guiDisplay, true);
}
Mutation(@Nullable Class<? extends MutationModule> loader, Material guiDisplay, boolean pollable) {
this.loader = loader;
this.guiDisplay = guiDisplay;
this.pollable = pollable;
}
public Class<? extends MutationModule> loader() {
return loader;
}
public Material getGuiDisplay() {
return guiDisplay;
}
public boolean isPollable() {
return pollable;
}
public String getName() {
return TYPE_KEY + name().toLowerCase();
}
public String getDescription() {
return getName() + DESCRIPTION_KEY;
}
public BaseComponent getComponent(ChatColor color) {
return new Component(new TranslatableComponent(getName()), color).hoverEvent(HoverEvent.Action.SHOW_TEXT, new Component(new TranslatableComponent(getDescription()), ChatColor.GRAY));
}
public static Function<Mutation, BaseComponent> toComponent(final ChatColor color) {
return mutation -> mutation.getComponent(color);
}
public static Stream<Mutation> fromString(final String name) {
try {
return Stream.of(Mutation.valueOf(name));
} catch(IllegalArgumentException iae) {
PGM.get().getLogger().warning("Unable to find mutation named '" + name + "'");
return Stream.empty();
}
}
}