Add the bread mutation
This commit is contained in:
parent
be0853fea8
commit
9da64d8372
|
@ -225,6 +225,8 @@ mutation.type.lightning = Lightning
|
|||
mutation.type.lightning.desc = lightning strikes from the sky
|
||||
mutation.type.bomber = Bomber
|
||||
mutation.type.bomber.desc = tnt rain
|
||||
mutation.type.bread = Bread
|
||||
mutation.type.bread.desc = bread with enchantments
|
||||
mutation.type.apocalypse = Apocalypse
|
||||
mutation.type.apocalypse.desc = mob spawning chaos
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ 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.kit.BreadMutation;
|
||||
import tc.oc.pgm.mutation.types.targetable.LightningMutation;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
@ -51,6 +52,7 @@ public enum Mutation {
|
|||
MOBS (MobsMutation.class, Material.MONSTER_EGG),
|
||||
LIGHTNING (LightningMutation.class, Material.JACK_O_LANTERN),
|
||||
BOMBER (BomberMutation.class, Material.TNT),
|
||||
BREAD (BreadMutation.class, Material.BREAD, false),
|
||||
APOCALYPSE (ApocalypseMutation.class, Material.NETHER_STAR);
|
||||
|
||||
public static final String TYPE_KEY = "mutation.type.";
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package tc.oc.pgm.mutation.types.kit;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import tc.oc.commons.bukkit.item.ItemBuilder;
|
||||
import tc.oc.commons.core.random.ImmutableWeightedRandomChooser;
|
||||
import tc.oc.commons.core.random.WeightedRandomChooser;
|
||||
import tc.oc.pgm.kits.FreeItemKit;
|
||||
import tc.oc.pgm.kits.Kit;
|
||||
import tc.oc.pgm.match.Match;
|
||||
import tc.oc.pgm.match.MatchPlayer;
|
||||
import tc.oc.pgm.mutation.types.KitMutation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BreadMutation extends KitMutation {
|
||||
|
||||
final static ImmutableMap<FreeItemKit, Integer> BREADS_MAP = new ImmutableMap.Builder<FreeItemKit, Integer>()
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.DAMAGE_ALL, 3).name("Sharp Bread").get()), 15)
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.KNOCKBACK, 2).name("Bouncy Bread").get()), 10)
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).knockBackRestistance(1, EquipmentSlot.HAND).name("Iron Bread").get()), 5)
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.FIRE_ASPECT, 1).name("Hot Bread").get()), 5)
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).knockBackRestistance(1, EquipmentSlot.HAND).speed(1,EquipmentSlot.HAND).name("Fast Iron Bread").get()), 2)
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.DAMAGE_ALL, 10).name("Very Sharp Bread").get()), 2)
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.KNOCKBACK, 10).name("Very Bouncy Bread").get()), 2)
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.FIRE_ASPECT, 10).name("Very Hot Bread").get()), 2)
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.DAMAGE_ALL, 100).name("Insanely Sharp Bread").get()), 1)
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.KNOCKBACK, 100).name("Insanely Bouncy Bread").get()), 1)
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.FIRE_ASPECT, 100).name("Insanely Hot Bread").get()), 1)
|
||||
.build();
|
||||
|
||||
final static WeightedRandomChooser<FreeItemKit, Integer> BREADS = new ImmutableWeightedRandomChooser<>(BREADS_MAP);
|
||||
|
||||
public BreadMutation(Match match) {
|
||||
super(match, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kits(MatchPlayer player, List<Kit> kits) {
|
||||
super.kits(player, kits);
|
||||
kits.add(BREADS.choose(entropy()));
|
||||
}
|
||||
}
|
|
@ -8,7 +8,11 @@ import org.bukkit.Bukkit;
|
|||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Skin;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeModifier;
|
||||
import org.bukkit.attribute.ItemAttributeModifier;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
@ -113,6 +117,22 @@ public class ItemBuilder<S extends ItemBuilder<?>> {
|
|||
return self();
|
||||
}
|
||||
|
||||
public S knockBackRestistance(double amount, EquipmentSlot slot) {
|
||||
meta().addAttributeModifier(Attribute.GENERIC_KNOCKBACK_RESISTANCE,
|
||||
new ItemAttributeModifier(slot,
|
||||
new AttributeModifier(Attribute.GENERIC_KNOCKBACK_RESISTANCE.getName(),
|
||||
amount, AttributeModifier.Operation.ADD_NUMBER)));
|
||||
return self();
|
||||
}
|
||||
|
||||
public S speed(double amount, EquipmentSlot slot) {
|
||||
meta().addAttributeModifier(Attribute.GENERIC_MOVEMENT_SPEED,
|
||||
new ItemAttributeModifier(slot,
|
||||
new AttributeModifier(Attribute.GENERIC_MOVEMENT_SPEED.getName(),
|
||||
amount, AttributeModifier.Operation.ADD_SCALAR)));
|
||||
return self();
|
||||
}
|
||||
|
||||
public S name(String name) {
|
||||
meta().setDisplayName(name);
|
||||
return self();
|
||||
|
|
Loading…
Reference in New Issue