diff --git a/Commons/core/src/main/i18n/templates/pgm/PGMMessages.properties b/Commons/core/src/main/i18n/templates/pgm/PGMMessages.properties index 8dcd4b7..fad6ab8 100644 --- a/Commons/core/src/main/i18n/templates/pgm/PGMMessages.properties +++ b/Commons/core/src/main/i18n/templates/pgm/PGMMessages.properties @@ -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 diff --git a/PGM/src/main/java/tc/oc/pgm/mutation/Mutation.java b/PGM/src/main/java/tc/oc/pgm/mutation/Mutation.java index ce6af74..5467b4c 100644 --- a/PGM/src/main/java/tc/oc/pgm/mutation/Mutation.java +++ b/PGM/src/main/java/tc/oc/pgm/mutation/Mutation.java @@ -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."; diff --git a/PGM/src/main/java/tc/oc/pgm/mutation/types/kit/BreadMutation.java b/PGM/src/main/java/tc/oc/pgm/mutation/types/kit/BreadMutation.java new file mode 100644 index 0000000..746e03a --- /dev/null +++ b/PGM/src/main/java/tc/oc/pgm/mutation/types/kit/BreadMutation.java @@ -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 BREADS_MAP = new ImmutableMap.Builder() + .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 BREADS = new ImmutableWeightedRandomChooser<>(BREADS_MAP); + + public BreadMutation(Match match) { + super(match, false); + } + + @Override + public void kits(MatchPlayer player, List kits) { + super.kits(player, kits); + kits.add(BREADS.choose(entropy())); + } +} diff --git a/Util/bukkit/src/main/java/tc/oc/commons/bukkit/item/ItemBuilder.java b/Util/bukkit/src/main/java/tc/oc/commons/bukkit/item/ItemBuilder.java index 29c5bdf..c5d767c 100644 --- a/Util/bukkit/src/main/java/tc/oc/commons/bukkit/item/ItemBuilder.java +++ b/Util/bukkit/src/main/java/tc/oc/commons/bukkit/item/ItemBuilder.java @@ -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> { 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();