Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.raptor.mob.allies.vikings;
- import java.io.File;
- import java.util.HashMap;
- import java.util.Random;
- import org.bukkit.Bukkit;
- import org.bukkit.Color;
- import org.bukkit.Material;
- import org.bukkit.NamespacedKey;
- import org.bukkit.Particle.DustOptions;
- import org.bukkit.attribute.Attribute;
- import org.bukkit.entity.Damageable;
- import org.bukkit.entity.LivingEntity;
- import org.bukkit.entity.Skeleton;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.entity.EntityDamageByEntityEvent;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.plugin.Plugin;
- import org.bukkit.potion.PotionEffect;
- import org.bukkit.potion.PotionEffectType;
- import org.bukkit.scheduler.BukkitRunnable;
- import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobSpawnEvent;
- import me.raptor.main.ParticleUtils;
- import me.raptor.merchant.AbstractEntityListener;
- import me.raptor.merchant.MerchantConversation;
- public class VikingArcher extends AbstractEntityListener{
- Plugin plugin;
- private static NamespacedKey key;
- HashMap<Integer, String> sounds = new HashMap<>();
- //skin file
- File file;
- Random r = new Random();
- public VikingArcher(Plugin plugin, String path) {
- this.plugin = plugin;
- Bukkit.getServer().getPluginManager().registerEvents(this, plugin);
- key = new NamespacedKey(plugin, "VikingArcher");
- file = new File(path + "viking_archer.png");
- }
- public static NamespacedKey getKey() {
- return key;
- }
- @EventHandler
- public void onArcherSpawn(MythicMobSpawnEvent e) {
- new BukkitRunnable() {
- @Override
- public void run() {
- if (e.getEntity() instanceof Skeleton) {
- Skeleton z = (Skeleton) e.getEntity();
- if (checkName(z, "VikingArcher")) {
- setKey(z, "VikingArcher", key);
- VArcherEquipments(z);
- //Give it a name, why not?
- String name = MerchantConversation.chooseRandomName("VikingArcher");
- z.setCustomName(name);
- z.setCustomNameVisible(true);
- MerchantConversation.activateSpeakingAbility(z, "VikingArcher", 15, 7, name + ": ");
- z.teleport(z.getWorld().getHighestBlockAt(z.getLocation()).getLocation().add(0, 2, 0));
- z.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.3);
- setSkin(z, file, name);
- }
- }
- }
- }.runTaskLater(plugin, 1);
- }
- @EventHandler
- public void onArcherShoot(EntityDamageByEntityEvent e) {
- if (e.getDamager() instanceof Skeleton && e.getEntity() instanceof LivingEntity) {
- Skeleton z = (Skeleton) e.getDamager();
- if (checkKey(z, "VikingArcher", key)) {
- FrostbiteArrow(z, (LivingEntity) e.getEntity(), 15);
- }
- }
- }
- public void FrostbiteArrow(Skeleton z, LivingEntity le, int percent) {
- if (!(r.nextInt(101) <= percent)) {
- le.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 30, 1));
- } else {
- if(le instanceof Damageable) {
- ((Damageable) le).damage(3, z);
- }
- le.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20, 2));
- le.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20, 1));
- le.addPotionEffect(new PotionEffect(PotionEffectType.HUNGER, 40, 1));
- ParticleUtils.SoulSpiralUp(le.getLocation(), 3, 1.5f, 1, 3, 10, 1, new DustOptions(Color.fromRGB(230, 0, 0), (float) 0.75));
- }
- }
- public void VArcherEquipments(Skeleton z) {
- z.setCanPickupItems(false);
- z.getEquipment().setItemInMainHand(new ItemStack(Material.BOW));
- z.getEquipment().setHelmet(new ItemStack(Material.IRON_HELMET));
- if (r.nextInt(2) == 0) {
- z.getEquipment().setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement