use of org.bukkit.entity.Ocelot in project Denizen-For-Bukkit by DenizenScript.
the class SitCommand method execute.
@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
dLocation location = (dLocation) scriptEntry.getObject("location");
if (((BukkitScriptEntryData) scriptEntry.entryData).getNPC().getEntityType() != EntityType.PLAYER && ((BukkitScriptEntryData) scriptEntry.entryData).getNPC().getEntityType() != EntityType.OCELOT && ((BukkitScriptEntryData) scriptEntry.entryData).getNPC().getEntityType() != EntityType.WOLF) {
dB.echoError(scriptEntry.getResidingQueue(), "...only Player, ocelot, or wolf type NPCs can sit!");
return;
}
dB.report(scriptEntry, getName(), aH.debugObj("npc", ((BukkitScriptEntryData) scriptEntry.entryData).getNPC()) + (location != null ? location.debug() : ""));
if (((BukkitScriptEntryData) scriptEntry.entryData).getNPC().getEntityType() == EntityType.OCELOT) {
((Ocelot) ((BukkitScriptEntryData) scriptEntry.entryData).getNPC().getEntity()).setSitting(true);
} else if (((BukkitScriptEntryData) scriptEntry.entryData).getNPC().getEntityType() == EntityType.WOLF) {
((Wolf) ((BukkitScriptEntryData) scriptEntry.entryData).getNPC().getEntity()).setSitting(true);
} else {
SittingTrait trait = ((BukkitScriptEntryData) scriptEntry.entryData).getNPC().getCitizen().getTrait(SittingTrait.class);
if (!((BukkitScriptEntryData) scriptEntry.entryData).getNPC().getCitizen().hasTrait(SittingTrait.class)) {
((BukkitScriptEntryData) scriptEntry.entryData).getNPC().getCitizen().addTrait(SittingTrait.class);
dB.echoDebug(scriptEntry, "...added sitting trait");
}
if (location != null) {
trait.sit(location);
} else {
trait.sit();
}
}
}
use of org.bukkit.entity.Ocelot in project Essentials by drtshock.
the class Commandkittycannon method run.
@Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
final Mob cat = Mob.OCELOT;
final Ocelot ocelot = (Ocelot) cat.spawn(user.getWorld(), server, user.getBase().getEyeLocation());
if (ocelot == null) {
return;
}
final int i = random.nextInt(Ocelot.Type.values().length);
ocelot.setCatType(Ocelot.Type.values()[i]);
ocelot.setTamed(true);
ocelot.setBaby();
ocelot.setVelocity(user.getBase().getEyeLocation().getDirection().multiply(2));
class KittyCannonExplodeTask implements Runnable {
@Override
public void run() {
final Location loc = ocelot.getLocation();
ocelot.remove();
loc.getWorld().createExplosion(loc, 0F);
}
}
ess.scheduleSyncDelayedTask(new KittyCannonExplodeTask(), 20);
}
use of org.bukkit.entity.Ocelot in project EliteMobs by MagmaGuy.
the class ZombieTeamRocket method onHit.
@EventHandler
public void onHit(EntityDamageEvent event) {
if (event.getEntity().hasMetadata(powerMetadata) && event.getEntity() instanceof Zombie && !event.getEntity().hasMetadata(MetadataHandler.TEAM_ROCKET_ACTIVATED) && random.nextDouble() < 0.5) {
Entity entity = event.getEntity();
entity.setMetadata(MetadataHandler.TEAM_ROCKET_ACTIVATED, new FixedMetadataValue(plugin, true));
int assistMobLevel = (int) Math.floor(entity.getMetadata(MetadataHandler.ELITE_MOB_MD).get(0).asInt() / 4);
if (assistMobLevel < 1) {
assistMobLevel = 1;
}
LeatherArmorMeta teamRocketChestpieceMeta = (LeatherArmorMeta) TEAM_ROCKET_CHESTPIECE.getItemMeta();
teamRocketChestpieceMeta.setColor(Color.WHITE);
TEAM_ROCKET_CHESTPIECE.setItemMeta(teamRocketChestpieceMeta);
LeatherArmorMeta teamRocketLeggingsMeta = (LeatherArmorMeta) TEAM_ROCKET_CHESTPIECE.getItemMeta();
teamRocketLeggingsMeta.setColor(Color.WHITE);
TEAM_ROCKET_LEGGINGS.setItemMeta(teamRocketLeggingsMeta);
LeatherArmorMeta teamRocketBootsMeta = (LeatherArmorMeta) TEAM_ROCKET_BOOTS.getItemMeta();
teamRocketBootsMeta.setColor(Color.BLACK);
TEAM_ROCKET_BOOTS.setItemMeta(teamRocketBootsMeta);
ItemStack jesseHelmet = TEAM_ROCKET_HELMET.clone();
LeatherArmorMeta jesseHelmetMeta = (LeatherArmorMeta) jesseHelmet.getItemMeta();
jesseHelmetMeta.setColor(Color.PURPLE);
jesseHelmet.setItemMeta(jesseHelmetMeta);
ItemStack jamesHelmet = TEAM_ROCKET_HELMET.clone();
LeatherArmorMeta jamesHelmetMeta = (LeatherArmorMeta) jamesHelmet.getItemMeta();
jamesHelmetMeta.setColor(Color.BLUE);
jamesHelmet.setItemMeta(jamesHelmetMeta);
Zombie jesse = (Zombie) entity.getWorld().spawnEntity(entity.getLocation(), EntityType.ZOMBIE);
jesse.setMetadata(MetadataHandler.ELITE_MOB_MD, new FixedMetadataValue(plugin, assistMobLevel));
jesse.setMetadata(MetadataHandler.CUSTOM_NAME, new FixedMetadataValue(plugin, true));
jesse.setMetadata(MetadataHandler.CUSTOM_ARMOR, new FixedMetadataValue(plugin, true));
jesse.setMetadata(MetadataHandler.FORBIDDEN_MD, new FixedMetadataValue(plugin, true));
jesse.setMetadata(MetadataHandler.CUSTOM_POWERS_MD, new FixedMetadataValue(plugin, true));
jesse.setMetadata(MetadataHandler.TEAM_ROCKET_MEMBER, new FixedMetadataValue(plugin, true));
jesse.setCustomName("Jesse");
jesse.getEquipment().setHelmet(jesseHelmet);
jesse.getEquipment().setChestplate(TEAM_ROCKET_CHESTPIECE);
jesse.getEquipment().setLeggings(TEAM_ROCKET_LEGGINGS);
jesse.getEquipment().setBoots(TEAM_ROCKET_BOOTS);
Zombie james = (Zombie) entity.getWorld().spawnEntity(entity.getLocation(), EntityType.ZOMBIE);
james.setMetadata(MetadataHandler.ELITE_MOB_MD, new FixedMetadataValue(plugin, assistMobLevel));
james.setMetadata(MetadataHandler.CUSTOM_NAME, new FixedMetadataValue(plugin, true));
james.setMetadata(MetadataHandler.CUSTOM_ARMOR, new FixedMetadataValue(plugin, true));
james.setMetadata(MetadataHandler.FORBIDDEN_MD, new FixedMetadataValue(plugin, true));
james.setMetadata(MetadataHandler.CUSTOM_POWERS_MD, new FixedMetadataValue(plugin, true));
james.setMetadata(MetadataHandler.TEAM_ROCKET_MEMBER, new FixedMetadataValue(plugin, true));
james.setCustomName("James");
james.getEquipment().setHelmet(jamesHelmet);
james.getEquipment().setChestplate(TEAM_ROCKET_CHESTPIECE);
james.getEquipment().setLeggings(TEAM_ROCKET_LEGGINGS);
james.getEquipment().setBoots(TEAM_ROCKET_BOOTS);
Ocelot meowth = (Ocelot) entity.getWorld().spawnEntity(entity.getLocation(), EntityType.OCELOT);
meowth.setMetadata(MetadataHandler.TEAM_ROCKET_MEMBER, new FixedMetadataValue(plugin, true));
meowth.setCustomName("Meowth");
((Zombie) entity).getEquipment().setChestplate(TEAM_ROCKET_CHESTPIECE);
((Zombie) entity).getEquipment().setLeggings(TEAM_ROCKET_LEGGINGS);
((Zombie) entity).getEquipment().setBoots(TEAM_ROCKET_BOOTS);
entity.setMetadata(MetadataHandler.CUSTOM_ARMOR, new FixedMetadataValue(plugin, true));
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
int counter = 1;
@Override
public void run() {
switch(counter) {
case 1:
jesse.setCustomNameVisible(true);
jesse.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(0)));
break;
case 2:
jesse.setCustomNameVisible(false);
james.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(1)));
james.setCustomNameVisible(true);
break;
case 3:
james.setCustomNameVisible(false);
jesse.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(2)));
jesse.setCustomNameVisible(true);
break;
case 4:
jesse.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(3)));
break;
case 5:
jesse.setCustomNameVisible(false);
james.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(4)));
james.setCustomNameVisible(true);
break;
case 6:
james.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(5)));
break;
case 7:
james.setCustomNameVisible(false);
jesse.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(6)));
jesse.setCustomNameVisible(true);
break;
case 8:
jesse.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(7)));
break;
case 9:
jesse.setCustomNameVisible(false);
james.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(8)));
james.setCustomNameVisible(true);
break;
case 10:
james.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(9)));
break;
case 11:
james.setCustomNameVisible(false);
jesse.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(10)));
jesse.setCustomNameVisible(true);
break;
case 12:
jesse.setCustomNameVisible(false);
james.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(11)));
james.setCustomNameVisible(true);
break;
case 13:
james.setCustomNameVisible(false);
jesse.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(12)));
jesse.setCustomNameVisible(true);
break;
case 14:
jesse.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(13)));
break;
case 15:
jesse.setCustomNameVisible(false);
james.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(14)));
james.setCustomNameVisible(true);
break;
case 16:
james.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(15)));
break;
case 17:
james.setCustomNameVisible(false);
meowth.setCustomName(chatColorConverter(configuration.getStringList("ZombieTeamRocket.Intro").get(16)));
meowth.setCustomNameVisible(true);
break;
default:
jesse.setCustomName(chatColorConverter(configuration.getString("ZombieTeamRocket.Jesse name")));
jesse.setCustomNameVisible(true);
james.setCustomName(chatColorConverter(configuration.getString("ZombieTeamRocket.James name")));
james.setCustomNameVisible(true);
meowth.setCustomName(chatColorConverter(configuration.getString("ZombieTeamRocket.Meowth name")));
Bukkit.getScheduler().cancelTask(processID);
break;
}
counter++;
}
}, 1, 15 * 2);
}
}
Aggregations