turt2live

Untitled

Oct 14th, 2013
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.19 KB | None | 0 0
  1. package net.shocknetwork.turt2live.kingofthehill.mob;
  2.  
  3. import java.util.Random;
  4.  
  5. import net.shocknetwork.gameapi.minigame.GameTeam;
  6. import net.shocknetwork.turt2live.kingofthehill.KOTH;
  7. import net.shocknetwork.turt2live.kingofthehill.KothTeam;
  8.  
  9. import org.bukkit.ChatColor;
  10. import org.bukkit.Location;
  11. import org.bukkit.Material;
  12. import org.bukkit.World;
  13. import org.bukkit.craftbukkit.v1_6_R3.CraftWorld;
  14. import org.bukkit.entity.Entity;
  15. import org.bukkit.entity.EntityType;
  16. import org.bukkit.entity.LivingEntity;
  17. import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
  18. import org.bukkit.inventory.EntityEquipment;
  19. import org.bukkit.inventory.ItemStack;
  20. import org.bukkit.metadata.FixedMetadataValue;
  21. import org.bukkit.potion.PotionEffect;
  22. import org.bukkit.potion.PotionEffectType;
  23.  
  24. public class KothMobSpawner{
  25.  
  26.     public static final String SPAWN_METADATA = "KOTH_Spawned";
  27.     public static final String SPAWN_PLAYER_METADATA = "KOTH_SpawnedByPlayer";
  28.     private static Random random = new Random();
  29.  
  30.     public static void spawn(EntityType type, GameTeam team, World world, Location spawn){
  31.         spawn(type, team, world, spawn, false);
  32.     }
  33.  
  34.     public static void spawn(EntityType type, GameTeam team, World world, Location spawn, boolean playerSpawned){
  35.         // NMS
  36.         net.minecraft.server.v1_6_R3.World nmsWorld = ((CraftWorld) world).getHandle();
  37.         KothZombie z = new KothZombie(nmsWorld, team.getTeamDyeColor());
  38.         boolean flag = nmsWorld.addEntity(z, SpawnReason.CUSTOM);
  39.         System.out.println(flag);
  40.         ((CraftWorld) world).spawn(spawn, CraftKothZombie.class);
  41.         // END NMS
  42.         Entity entity = z.getBukkitEntity();
  43.         if(entity instanceof LivingEntity){
  44.             LivingEntity le = (LivingEntity) entity;
  45.             EntityEquipment equip = le.getEquipment();
  46.             ItemStack chest = KothTeam.colorize(new ItemStack(Material.LEATHER_CHESTPLATE), team.getTeamDyeColor());
  47.             ItemStack head = KothTeam.colorize(new ItemStack(Material.LEATHER_HELMET), team.getTeamDyeColor());
  48.             ItemStack boots = KothTeam.colorize(new ItemStack(Material.LEATHER_BOOTS), team.getTeamDyeColor());
  49.             ItemStack pants = KothTeam.colorize(new ItemStack(Material.LEATHER_LEGGINGS), team.getTeamDyeColor());
  50.             equip.setBoots(boots);
  51.             equip.setHelmet(head);
  52.             equip.setChestplate(chest);
  53.             equip.setLeggings(pants);
  54.             equip.setItemInHand(new ItemStack(Material.WOOD_SWORD));
  55.             equip.setBootsDropChance(0);
  56.             equip.setLeggingsDropChance(0);
  57.             equip.setChestplateDropChance(0);
  58.             equip.setHelmetDropChance(0);
  59.             equip.setItemInHandDropChance(0);
  60.             le.setMaxHealth(10);
  61.             le.setHealth(10);
  62.             le.setCanPickupItems(false);
  63.             le.setMetadata(SPAWN_METADATA, new FixedMetadataValue(KOTH.getInstance(), true));
  64.             if(playerSpawned)
  65.                 le.setMetadata(SPAWN_PLAYER_METADATA, new FixedMetadataValue(KOTH.getInstance(), team.getTeamDyeColor()));
  66.             boolean spd = random.nextBoolean();
  67.             le.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, spd ? 1 : 0), true);
  68.             le.setCustomName((spd ? ChatColor.AQUA + ".." + ChatColor.RESET + ChatColor.GOLD + "+" : "") + ChatColor.RESET + team.getTeamChatColor() + "NPC" + (spd ? ChatColor.GOLD + "+" + ChatColor.AQUA + ".." : ""));
  69.             le.setCustomNameVisible(true);
  70.         }
  71.     }
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment