Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.shocknetwork.turt2live.kingofthehill.mob;
- import java.util.Random;
- import net.shocknetwork.gameapi.minigame.GameTeam;
- import net.shocknetwork.turt2live.kingofthehill.KOTH;
- import net.shocknetwork.turt2live.kingofthehill.KothTeam;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.World;
- import org.bukkit.craftbukkit.v1_6_R3.CraftWorld;
- import org.bukkit.entity.Entity;
- import org.bukkit.entity.EntityType;
- import org.bukkit.entity.LivingEntity;
- import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
- import org.bukkit.inventory.EntityEquipment;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.metadata.FixedMetadataValue;
- import org.bukkit.potion.PotionEffect;
- import org.bukkit.potion.PotionEffectType;
- public class KothMobSpawner{
- public static final String SPAWN_METADATA = "KOTH_Spawned";
- public static final String SPAWN_PLAYER_METADATA = "KOTH_SpawnedByPlayer";
- private static Random random = new Random();
- public static void spawn(EntityType type, GameTeam team, World world, Location spawn){
- spawn(type, team, world, spawn, false);
- }
- public static void spawn(EntityType type, GameTeam team, World world, Location spawn, boolean playerSpawned){
- // NMS
- net.minecraft.server.v1_6_R3.World nmsWorld = ((CraftWorld) world).getHandle();
- KothZombie z = new KothZombie(nmsWorld, team.getTeamDyeColor());
- boolean flag = nmsWorld.addEntity(z, SpawnReason.CUSTOM);
- System.out.println(flag);
- ((CraftWorld) world).spawn(spawn, CraftKothZombie.class);
- // END NMS
- Entity entity = z.getBukkitEntity();
- if(entity instanceof LivingEntity){
- LivingEntity le = (LivingEntity) entity;
- EntityEquipment equip = le.getEquipment();
- ItemStack chest = KothTeam.colorize(new ItemStack(Material.LEATHER_CHESTPLATE), team.getTeamDyeColor());
- ItemStack head = KothTeam.colorize(new ItemStack(Material.LEATHER_HELMET), team.getTeamDyeColor());
- ItemStack boots = KothTeam.colorize(new ItemStack(Material.LEATHER_BOOTS), team.getTeamDyeColor());
- ItemStack pants = KothTeam.colorize(new ItemStack(Material.LEATHER_LEGGINGS), team.getTeamDyeColor());
- equip.setBoots(boots);
- equip.setHelmet(head);
- equip.setChestplate(chest);
- equip.setLeggings(pants);
- equip.setItemInHand(new ItemStack(Material.WOOD_SWORD));
- equip.setBootsDropChance(0);
- equip.setLeggingsDropChance(0);
- equip.setChestplateDropChance(0);
- equip.setHelmetDropChance(0);
- equip.setItemInHandDropChance(0);
- le.setMaxHealth(10);
- le.setHealth(10);
- le.setCanPickupItems(false);
- le.setMetadata(SPAWN_METADATA, new FixedMetadataValue(KOTH.getInstance(), true));
- if(playerSpawned)
- le.setMetadata(SPAWN_PLAYER_METADATA, new FixedMetadataValue(KOTH.getInstance(), team.getTeamDyeColor()));
- boolean spd = random.nextBoolean();
- le.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, spd ? 1 : 0), true);
- le.setCustomName((spd ? ChatColor.AQUA + ".." + ChatColor.RESET + ChatColor.GOLD + "+" : "") + ChatColor.RESET + team.getTeamChatColor() + "NPC" + (spd ? ChatColor.GOLD + "+" + ChatColor.AQUA + ".." : ""));
- le.setCustomNameVisible(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment