Add potion bread
This commit is contained in:
parent
46f05069c6
commit
4a74697de4
|
@ -1,9 +1,18 @@
|
|||
package tc.oc.pgm.mutation.types.kit;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Range;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import tc.oc.commons.bukkit.item.ItemBuilder;
|
||||
import tc.oc.commons.core.random.ImmutableWeightedRandomChooser;
|
||||
import tc.oc.commons.core.random.WeightedRandomChooser;
|
||||
|
@ -17,14 +26,18 @@ import java.util.List;
|
|||
|
||||
public class BreadMutation extends KitMutation {
|
||||
|
||||
final static private ItemStack potionBread = new ItemBuilder(item(Material.BREAD)).name("Potion Bread").unbreakable(true).get();
|
||||
|
||||
final static ImmutableMap<FreeItemKit, Integer> BREADS_MAP = new ImmutableMap.Builder<FreeItemKit, Integer>()
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.FIRE_ASPECT, 1).name("Hot Bread").get()), 30)
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.FIRE_ASPECT, 1).name("Hot Bread").get()), 20)
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.DAMAGE_ALL, 5).name("Sharp Bread").get()), 20)
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.KNOCKBACK, 2).name("Bouncy Bread").get()), 20)
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).knockBackRestistance(1, EquipmentSlot.OFF_HAND).name("Iron Bread").get()), 10)
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).speed(1,EquipmentSlot.OFF_HAND).name("Fast Bread").get()), 10)
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).armor(10,EquipmentSlot.OFF_HAND).name("Armored Bread").get()), 10)
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).knockBackRestistance(1, EquipmentSlot.OFF_HAND).knockBackRestistance(1, EquipmentSlot.HAND).name("Iron Bread").get()), 10)
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).speed(0.3,EquipmentSlot.OFF_HAND).speed(0.3,EquipmentSlot.HAND).name("Fast Bread").get()), 10)
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).armor(10,EquipmentSlot.OFF_HAND).armor(10,EquipmentSlot.HAND).name("Armored Bread").get()), 10)
|
||||
.put(new FreeItemKit(potionBread), 10)
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.DAMAGE_ALL, 10).name("Very Sharp Bread").get()), 6)
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).speed(1,EquipmentSlot.OFF_HAND).speed(1,EquipmentSlot.HAND).name("Very Fast Bread").get()), 3)
|
||||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.FIRE_ASPECT, 10).name("Very Hot Bread").get()), 3)
|
||||
.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.DAMAGE_ALL, 100).name("Insanely Sharp Bread").get()), 1)
|
||||
|
@ -32,8 +45,12 @@ public class BreadMutation extends KitMutation {
|
|||
.put(new FreeItemKit(new ItemBuilder(item(Material.BREAD)).enchant(Enchantment.FIRE_ASPECT, 100).name("Insanely Hot Bread").get()), 1)
|
||||
.build();
|
||||
|
||||
final static WeightedRandomChooser<PotionEffectType, Integer> POTIONS = new ImmutableWeightedRandomChooser<>(PotionMutation.BAD_MAP);
|
||||
final static WeightedRandomChooser<FreeItemKit, Integer> BREADS = new ImmutableWeightedRandomChooser<>(BREADS_MAP);
|
||||
|
||||
final static Range<Integer> AMPLIFIER_RANGE = Range.closed(0, 3);
|
||||
final static Range<Integer> DURATION_RANGE = Range.closed(3, 10);
|
||||
|
||||
public BreadMutation(Match match) {
|
||||
super(match, false);
|
||||
}
|
||||
|
@ -43,4 +60,14 @@ public class BreadMutation extends KitMutation {
|
|||
super.kits(player, kits);
|
||||
kits.add(BREADS.choose(entropy()));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerDamage(EntityDamageByEntityEvent event) {
|
||||
if(event.getDamager() instanceof Player && (((Player) event.getDamager()).getItemInHand()).isSimilar(potionBread)) {
|
||||
if (event.getEntity() instanceof LivingEntity) {
|
||||
((LivingEntity)event.getEntity()).addPotionEffect(new PotionEffect(POTIONS.choose(entropy()), 20 * entropy().randomInt(DURATION_RANGE), entropy().randomInt(AMPLIFIER_RANGE)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,11 +20,12 @@ import java.util.List;
|
|||
public class PotionMutation extends KitMutation {
|
||||
|
||||
final static ImmutableMap<PotionEffectType, Integer> BAD_MAP = new ImmutableMap.Builder<PotionEffectType, Integer>()
|
||||
.put(PotionEffectType.WEAKNESS, 15)
|
||||
.put(PotionEffectType.WEAKNESS, 10)
|
||||
.put(PotionEffectType.SLOW, 10)
|
||||
.put(PotionEffectType.POISON, 10)
|
||||
.put(PotionEffectType.BLINDNESS, 3)
|
||||
.put(PotionEffectType.LEVITATION, 1)
|
||||
.put(PotionEffectType.WITHER, 10)
|
||||
.put(PotionEffectType.BLINDNESS, 5)
|
||||
.put(PotionEffectType.LEVITATION, 3)
|
||||
.build();
|
||||
|
||||
final static ImmutableMap<PotionEffectType, Integer> GOOD_MAP = new ImmutableMap.Builder<PotionEffectType, Integer>()
|
||||
|
|
Loading…
Reference in New Issue