Java 类org.bukkit.entity.Ocelot 实例源码
项目:Kineticraft
文件:CommandKittyCannon.java
@Override
protected void onCommand(CommandSender sender, String[] args) {
Player p = (Player) sender;
Ocelot cat = (Ocelot) p.getWorld().spawnEntity(p.getLocation(), EntityType.OCELOT);
if (cat == null)
return; // Probably in a protected area.
cat.setCatType(Utils.randElement(Ocelot.Type.values()));
cat.setTamed(true);
cat.setBaby();
cat.setVelocity(p.getEyeLocation().getDirection().multiply(2));
Bukkit.getScheduler().runTaskLater(Core.getInstance(), () -> {
cat.getWorld().createExplosion(cat.getLocation(), 0F);
cat.remove();
}, 20L);
}
项目:PA
文件:KittyCMD.java
public void run(PAUser user, String label, String... args) {
final Ocelot o = (Ocelot) user.getLoc().getWorld().spawnEntity(user.getLoc(), EntityType.OCELOT);
o.setCatType(Ocelot.Type.values()[r.nextInt(Ocelot.Type.values().length)]);
o.setSitting(true);
o.setTamed(true);
o.setAge(r.nextInt(2));
o.setCustomName(Utils.colorize("&dGateteeeeeee"));
o.setCustomNameVisible(true);
o.setNoDamageTicks(Integer.MAX_VALUE);
o.setVelocity(user.getPlayer().getLocation().getDirection().multiply(2));
PAServer.users.forEach(u -> u.sendSound(Sounds.CAT_MEOW));
plugin.getServer().getScheduler().runTaskLater(plugin, () -> {
PAServer.users.forEach(u -> u.sendSound(Sounds.EXPLODE));
ParticleEffect.EXPLOSION_HUGE.send(plugin.getServer().getOnlinePlayers(), o.getLocation(), 0, 0, 0, 1, 20, 50);
o.remove();
}, 60);
}
项目:buildinggame
文件:OcelotMenu.java
/**
* {@inheritDoc}
*/
public OcelotMenu(Plot plot, Ocelot ocelot) {
super(plot, ocelot);
//type
ItemStack type = new ItemStack(Material.BONE);
ItemMeta typeMeta = type.getItemMeta();
typeMeta.setDisplayName(ChatColor.GREEN + "Change type");
type.setItemMeta(typeMeta);
insertItem(type, event -> {
new OcelotTypeMenu(ocelot).open((Player) event.getWhoClicked());
event.setCancelled(true);
}, 0);
}
项目:PetMaster
文件:PlayerInteractListener.java
/**
* Frees a pet; it will no longer be tamed.
*
* @param event
* @param oldOwner
*/
private void freePet(PlayerInteractEntityEvent event, AnimalTamer oldOwner) {
if (chargePrice(event.getPlayer(), freePetPrice)) {
Tameable tameableAnimal = (Tameable) event.getRightClicked();
// Free pet.
tameableAnimal.setTamed(false);
// Make freed pet stand up.
if (version >= 12 && tameableAnimal instanceof Sittable) {
((Sittable) tameableAnimal).setSitting(false);
} else if (tameableAnimal instanceof Wolf) {
((Wolf) tameableAnimal).setSitting(false);
} else if (tameableAnimal instanceof Ocelot) {
((Ocelot) tameableAnimal).setSitting(false);
}
event.getPlayer().sendMessage(plugin.getChatHeader()
+ plugin.getPluginLang().getString("pet-freed", "Say goodbye: this pet returned to the wild!"));
// Create new event to allow other plugins to be aware of the freeing.
PlayerChangeAnimalOwnershipEvent playerChangeAnimalOwnershipEvent = new PlayerChangeAnimalOwnershipEvent(
oldOwner, null, tameableAnimal);
Bukkit.getServer().getPluginManager().callEvent(playerChangeAnimalOwnershipEvent);
}
}
项目:UnexpectedFishing
文件:UnexpectedFishingListener.java
private void throwKittyCannon(final World world, Player player, Location hookLoc) {
int i = random.nextInt(Ocelot.Type.values().length);
final Ocelot cat = (Ocelot) throwMob(world, player, hookLoc, EntityType.OCELOT);
cat.setCatType(Ocelot.Type.values()[i]);
cat.setTamed(true);
cat.setBaby();
mainInstance.scheduleSyncDelayedTask(new Runnable() {
@Override
public void run() {
final Location catLoc = cat.getLocation();
cat.remove();
world.createExplosion(catLoc.getX(), catLoc.getY(), catLoc.getZ(), 2.0F, false, false);
}
}, 20);
}
项目:Essentials
文件:Commandkittycannon.java
@Override
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
final EntityType cat = EntityType.OCELOT;
final Ocelot ocelot = (Ocelot)user.getPlayer().getWorld().spawn(user.getPlayer().getEyeLocation(), cat.getEntityClass());
if (ocelot == null)
{
return;
}
final int i = random.nextInt(Ocelot.Type.values().length);
ocelot.setCatType(Ocelot.Type.values()[i]);
ocelot.setTamed(true);
ocelot.setVelocity(user.getPlayer().getEyeLocation().getDirection().multiply(2));
ess.getPlugin().scheduleSyncDelayedTask(
new Runnable()
{
@Override
public void run()
{
final Location loc = ocelot.getLocation();
ocelot.remove();
loc.getWorld().createExplosion(loc, 0F);
}
}, 20);
}
项目:GameBoxx
文件:OcelotTypes.java
@Override
public void onLoad() {
add(Ocelot.Type.WILD_OCELOT, "Wild Ocelot", "Wild", "WI", "W", "Untamed", "Default", "Def", "None");
add(Ocelot.Type.BLACK_CAT, "Black Cat", "Black", "BL", "B");
add(Ocelot.Type.RED_CAT, "Red Cat", "Red", "RE", "R");
add(Ocelot.Type.SIAMESE_CAT, "Siamese Cat", "Siamese", "SI", "S", "Siam");
}
项目:SonarPet
文件:EntityOcelotPet.java
@Override
public void initiateEntityPet() {
super.initiateEntityPet();
getBukkitEntity().setTamed(true);
getBukkitEntity().setCatType(Ocelot.Type.BLACK_CAT);
getBukkitEntity().setOwner(getPlayerOwner());
}
项目:RpgPlus
文件:OcelotEntityWrapper.java
@Override
public void rawset(LuaValue key, LuaValue value) {
if (key.isstring()) {
switch (key.checkjstring()) {
case "type":
getOcelotTrait().setCatType(ScriptUtil.enumValue(value, Ocelot.Type.class));
break;
}
}
super.rawset(key, value);
}
项目:McMMOPlus
文件:TamingManager.java
/**
* Handle the Call of the Wild ability.
*
* @param type The type of entity to summon.
* @param summonAmount The amount of material needed to summon the entity
*/
private void callOfTheWild(EntityType type, int summonAmount) {
Player player = getPlayer();
ItemStack heldItem = player.getItemInHand();
int heldItemAmount = heldItem.getAmount();
if (heldItemAmount < summonAmount) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(heldItem.getType())));
return;
}
if (!rangeCheck(type)) {
return;
}
int amount = Config.getInstance().getTamingCOTWAmount(type);
for (int i = 0; i < amount; i++) {
LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation(), type);
FakeEntityTameEvent event = new FakeEntityTameEvent(entity, player);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
continue;
}
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
((Tameable) entity).setOwner(player);
entity.setRemoveWhenFarAway(false);
switch (type) {
case OCELOT:
((Ocelot) entity).setCatType(Ocelot.Type.values()[1 + Misc.getRandom().nextInt(3)]);
break;
case WOLF:
entity.setMaxHealth(20.0);
entity.setHealth(entity.getMaxHealth());
break;
case HORSE:
Horse horse = (Horse) entity;
entity.setMaxHealth(15.0 + (Misc.getRandom().nextDouble() * 15));
entity.setHealth(entity.getMaxHealth());
horse.setColor(Horse.Color.values()[Misc.getRandom().nextInt(Horse.Color.values().length)]);
horse.setStyle(Horse.Style.values()[Misc.getRandom().nextInt(Horse.Style.values().length)]);
horse.setJumpStrength(Math.max(AdvancedConfig.getInstance().getMinHorseJumpStrength(), Math.min(Math.min(Misc.getRandom().nextDouble(), Misc.getRandom().nextDouble()) * 2, AdvancedConfig.getInstance().getMaxHorseJumpStrength())));
//TODO: setSpeed, once available
break;
default:
break;
}
if (Permissions.renamePets(player)) {
entity.setCustomName(LocaleLoader.getString("Taming.Summon.Name.Format", player.getName(), StringUtils.getPrettyEntityTypeString(type)));
entity.setCustomNameVisible(true);
}
}
player.setItemInHand(heldItemAmount == summonAmount ? null : new ItemStack(heldItem.getType(), heldItemAmount - summonAmount));
player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete"));
}
项目:NucleusFramework
文件:OcelotAnimal.java
public OcelotAnimal(Entity entity) {
PreCon.isValid(entity instanceof Ocelot, "org.bukkit.entity.Ocelot expected.");
Ocelot ocelot = (Ocelot)entity;
_type = ocelot.getCatType();
_isSitting = ocelot.isSitting();
}
项目:NucleusFramework
文件:OcelotAnimal.java
@Override
public boolean apply(Entity entity) {
PreCon.notNull(entity);
PreCon.isValid(entity instanceof Ocelot, "org.bukkit.entity.Ocelot expected.");
Ocelot ocelot = (Ocelot)entity;
ocelot.setCatType(_type);
ocelot.setSitting(_isSitting);
return true;
}
项目:Shopkeepers
文件:CatShop.java
@Override
protected void load(ConfigurationSection config) {
super.load(config);
String catTypeName = config.getString("catType");
try {
catType = Ocelot.Type.valueOf(catTypeName);
} catch (Exception e) {
}
}
项目:Shopkeepers
文件:CatShop.java
private short getSubItemData(Ocelot.Type catType) {
switch (catType) {
case BLACK_CAT:
return DyeColor.BLACK.getWoolData();
case RED_CAT:
return DyeColor.RED.getWoolData();
case SIAMESE_CAT:
return DyeColor.SILVER.getWoolData();
case WILD_OCELOT:
default:
return DyeColor.ORANGE.getWoolData();
}
}
项目:EntityAPI
文件:ControllableCreeperBase.java
@Override
public BehaviourItem[] getDefaultTargetingBehaviours() {
return new BehaviourItem[]{
new BehaviourItem(1, new BehaviourFloat(this)),
new BehaviourItem(2, new BehaviourSwell(this)),
new BehaviourItem(3, new BehaviourAvoidEntity(this, Ocelot.class, 6.0F, 1.0D, 1.2D)),
new BehaviourItem(4, new BehaviourMeleeAttack(this, false, 1.0D)),
new BehaviourItem(5, new BehaviourRandomStroll(this, 0.8D)),
new BehaviourItem(6, new BehaviourLookAtNearestEntity(this, HumanEntity.class, 8F)),
new BehaviourItem(7, new BehaviourLookAtRandom(this))
};
}
项目:GameBoxx
文件:OcelotTypes.java
public static Ocelot.Type get(String string) {
return instance()._get(string);
}
项目:GameBoxx
文件:OcelotTypes.java
public static String getName(Ocelot.Type key) {
return instance()._getName(key);
}
项目:GameBoxx
文件:OcelotTypes.java
public static String getDisplayName(Ocelot.Type key) {
return instance()._getDisplayName(key);
}
项目:GameBoxx
文件:OcelotTypes.java
public static List<String> getAliases(Ocelot.Type key) {
return instance()._getAliases(key);
}
项目:Skript
文件:OcelotData.java
@Override
protected boolean init(final @Nullable Class<? extends Ocelot> c, final @Nullable Ocelot e) {
tamed = e == null ? 0 : e.isTamed() ? 1 : -1;
return true;
}
项目:Skript
文件:OcelotData.java
@Override
public void set(final Ocelot entity) {
if (tamed != 0)
entity.setTamed(tamed == 1);
}
项目:Skript
文件:OcelotData.java
@Override
protected boolean match(final Ocelot entity) {
return tamed == 0 || entity.isTamed() == (tamed == 1);
}
项目:Skript
文件:OcelotData.java
@Override
public Class<? extends Ocelot> getType() {
return Ocelot.class;
}
项目:SonarPet
文件:EntityOcelotPet.java
@Override
public void setCatType(int type) {
getBukkitEntity().setCatType(Ocelot.Type.getType(type));
}
项目:SonarPet
文件:EntityOcelotPet.java
@Override
public Ocelot getBukkitEntity() {
return (Ocelot) super.getBukkitEntity();
}
项目:RpgPlus
文件:OcelotEntityWrapper.java
OcelotEntityWrapper(RpgPlusEntity<Ocelot> entity, EntityEventManager entityEventManager) {
super(entity, entityEventManager);
}
项目:RpgPlus
文件:OcelotTrait.java
@Override
public void onSpawn() {
Ocelot ocelot = (Ocelot) getNPC().getEntity();
if (catType != null) ocelot.setCatType(catType);
}
项目:RpgPlus
文件:OcelotTrait.java
@Override
public void load(DataKey key) throws NPCLoadException {
if (key.keyExists("catType")) catType = Ocelot.Type.valueOf(key.getString("catType"));
}
项目:RpgPlus
文件:OcelotTrait.java
public Ocelot.Type getCatType() {
return catType;
}
项目:RpgPlus
文件:OcelotTrait.java
public void setCatType(Ocelot.Type catType) {
this.catType = catType;
if (getNPC().isSpawned()) ((Ocelot) getNPC().getEntity()).setCatType(catType);
}
项目:CanaryBukkit
文件:CatTypeConverter.java
public static net.canarymod.api.entity.living.animal.Ocelot.SkinType of(Ocelot.Type type) {
return CatTypeConverter.map.get(type);
}
项目:CanaryBukkit
文件:CatTypeConverter.java
public static Ocelot.Type of(net.canarymod.api.entity.living.animal.Ocelot.SkinType skinType) {
return CatTypeConverter.map.inverse().get(skinType);
}
项目:CanaryBukkit
文件:CanaryOcelot.java
public CanaryOcelot(net.canarymod.api.entity.living.animal.Ocelot entity) {
super(entity);
}
项目:CanaryBukkit
文件:CanaryOcelot.java
@Override
protected net.canarymod.api.entity.living.animal.Ocelot getHandle() {
return (net.canarymod.api.entity.living.animal.Ocelot) super.getHandle();
}
项目:buildinggame
文件:OcelotTypeMenu.java
/**
* {@inheritDoc}
*/
OcelotTypeMenu(Ocelot ocelot) {
super(null, 9, ChatColor.GREEN + "Select the ocelot type", 1);
setStartingPoint(2);
//wild ocelot
ItemStack wildOcelot = new ItemStack(Material.RAW_FISH);
ItemMeta wildOcelotMeta = wildOcelot.getItemMeta();
wildOcelotMeta.setDisplayName(ChatColor.GREEN + "Wild ocelot");
wildOcelot.setItemMeta(wildOcelotMeta);
addItem(wildOcelot, event -> {
ocelot.setCatType(Ocelot.Type.WILD_OCELOT);
event.setCancelled(true);
});
//black cat
ItemStack blackCat = new Wool(DyeColor.BLACK).toItemStack(1);
ItemMeta blackCatMeta = blackCat.getItemMeta();
blackCatMeta.setDisplayName(ChatColor.GREEN + "Black cat");
blackCat.setItemMeta(blackCatMeta);
addItem(blackCat, event -> {
ocelot.setCatType(Ocelot.Type.BLACK_CAT);
event.setCancelled(true);
});
setStartingPoint(5);
//red cat
ItemStack redCat = new Wool(DyeColor.RED).toItemStack(1);
ItemMeta redCatMeta = redCat.getItemMeta();
redCatMeta.setDisplayName(ChatColor.GREEN + "Red cat");
redCat.setItemMeta(redCatMeta);
addItem(redCat, event -> {
ocelot.setCatType(Ocelot.Type.RED_CAT);
event.setCancelled(true);
});
//siamese cat
ItemStack siameseCat = new Wool(DyeColor.SILVER).toItemStack(1);
ItemMeta siameseCatMeta = siameseCat.getItemMeta();
siameseCatMeta.setDisplayName(ChatColor.GREEN + "Siamese cat");
siameseCat.setItemMeta(siameseCatMeta);
addItem(siameseCat, event -> {
ocelot.setCatType(Ocelot.Type.SIAMESE_CAT);
event.setCancelled(true);
});
}
项目:SimpleEgg
文件:LorePacker.java
/**
* Assembles an ArrayList of the properties for the specified Entity that
* is to be used for a spawn egg. All instanceof checks are done internally
* by the LorePackager, so no type checking is required prior to calling
* this method. Null Entities will throw an IllegalArgumentException. <b>The
* actual ArrayList is returned by {@link #getLore() LorePacker.getLore()}.
* </b>
* @param livingEntity - The Entity to assemble a lore for.
* @return An ArrayList of Strings
* @throws IllegalArgumentException If entity parameter is null
*/
public LorePacker(LivingEntity livingEntity) throws IllegalArgumentException {
if (livingEntity == null) {
throw new IllegalArgumentException("Can't assemble lore for a null entity!");
}
lore = new ArrayList<String>();
// This needs to always be on top of an egg's lore
lore.add("Identifier: SimpleEgg." + livingEntity.getType().getEntityClass().getSimpleName() + "." + Main.getSelf().getDescription().getVersion());
lore.addAll(livingEntity(livingEntity));
if (livingEntity instanceof Ageable) {
lore.addAll(ageable((Ageable) livingEntity));
if (livingEntity instanceof Sheep) {
lore.addAll(sheep((Sheep) livingEntity));
} else if (livingEntity instanceof Pig) {
lore.addAll(pig((Pig) livingEntity));
} else if (livingEntity instanceof Rabbit) {
lore.addAll(rabbit((Rabbit) livingEntity));
} else if (livingEntity instanceof Villager) {
lore.addAll(villager((Villager) livingEntity));
} else if (livingEntity instanceof Tameable) {
lore.addAll(tameable((Tameable) livingEntity));
if (livingEntity instanceof AbstractHorse) {
lore.addAll(abstractHorse((AbstractHorse) livingEntity));
if (livingEntity instanceof Horse) {
lore.addAll(horse((Horse) livingEntity));
} else if (livingEntity instanceof ChestedHorse) {
lore.addAll(chestedHorse((ChestedHorse) livingEntity));
if (livingEntity instanceof Llama) {
lore.addAll(llama((Llama) livingEntity));
}
}
} else if (livingEntity instanceof Sittable) {
lore.addAll(sittable((Sittable) livingEntity));
if (livingEntity instanceof Wolf) {
lore.addAll(wolf((Wolf) livingEntity));
} else if (livingEntity instanceof Ocelot) {
lore.addAll(ocelot((Ocelot) livingEntity));
} else if (livingEntity instanceof Parrot) {
lore.addAll(parrot((Parrot) livingEntity));
}
}
}
} else if (livingEntity instanceof Slime) {
lore.addAll(slime((Slime) livingEntity));
} else if (livingEntity instanceof Creeper) {
lore.addAll(creeper((Creeper) livingEntity));
} else if (livingEntity instanceof Zombie) {
lore.addAll(zombie((Zombie) livingEntity));
if (livingEntity instanceof PigZombie) {
lore.addAll(pigZombie((PigZombie) livingEntity));
} else if (livingEntity instanceof ZombieVillager) {
lore.addAll(zombieVillager((ZombieVillager) livingEntity));
}
} else if (livingEntity instanceof Spellcaster) {
lore.addAll(spellCaster((Spellcaster) livingEntity));
} else if (livingEntity instanceof IronGolem) {
lore.addAll(ironGolem((IronGolem) livingEntity));
} else if (livingEntity instanceof Snowman) {
lore.addAll(snowman((Snowman) livingEntity));
}
}
项目:AncientGates
文件:EntityUtil.java
public static String getEntityTypeData(final Entity entity) {
String data = "";
if (entity instanceof LivingEntity) {
data += String.valueOf(((LivingEntity) entity).getHealth()) + ",";
data += String.valueOf(((LivingEntity) entity).getMaxHealth()) + ",";
data += String.valueOf(((LivingEntity) entity).getCustomName()) + ",";
if (entity instanceof Animals) {
data += String.valueOf(((Animals) entity).getAge()) + ",";
if (entity instanceof Sheep) {
data += String.valueOf(((Sheep) entity).isSheared()) + ",";
data += ((Sheep) entity).getColor().name() + ",";
} else if (entity instanceof Wolf) {
data += String.valueOf(((Wolf) entity).isAngry()) + ",";
if (((Wolf) entity).isTamed()) {
data += ((Tameable) entity).getOwner().getName() + ",";
data += String.valueOf(((Wolf) entity).getCollarColor()) + ",";
}
} else if (entity instanceof Ocelot) {
if (((Ocelot) entity).isTamed()) {
data += ((Tameable) entity).getOwner().getName() + ",";
data += String.valueOf(((Ocelot) entity).getCatType().name()) + ",";
}
} else if (entity instanceof Pig) {
data += String.valueOf(((Pig) entity).hasSaddle()) + ",";
} else if (entity instanceof Horse) {
data += "deprecated" + ",";
data += String.valueOf(((Horse) entity).getStyle().name()) + ",";
data += String.valueOf(((Horse) entity).getColor().name()) + ",";
data += String.valueOf(((Horse) entity).getDomestication()) + ",";
data += String.valueOf(((Horse) entity).getMaxDomestication()) + ",";
data += String.valueOf(((Horse) entity).getJumpStrength()) + ",";
if (((Horse) entity).isTamed()) {
data += (((Tameable) entity).getOwner() != null ? ((Tameable) entity).getOwner().getName() : null) + ",";
data += ItemStackUtil.itemStackToString(((Horse) entity).getInventory().getSaddle()) + ",";
data += ItemStackUtil.itemStackToString(((Horse) entity).getInventory().getArmor()) + ",";
if (((Horse) entity).isCarryingChest()) {
data += ItemStackUtil.itemStackToString(((Horse) entity).getInventory().getContents()) + ",";
}
}
}
} else if (entity instanceof Villager) {
data += String.valueOf(((Villager) entity).getProfession().name()) + ",";
data += String.valueOf(((Villager) entity).getAge()) + ",";
} else if (entity instanceof Creeper) {
data += String.valueOf(((Creeper) entity).isPowered()) + ",";
} else if (entity instanceof Slime) {
data += String.valueOf(((Slime) entity).getSize()) + ",";
} else if (entity instanceof Skeleton) {
data += String.valueOf(((Skeleton) entity).getSkeletonType().name()) + ",";
}
}
return data;
}
项目:AncientGates
文件:EntityUtil.java
public static void setEntityTypeData(final Entity entity, final String data) {
if (data == "")
return;
final String parts[] = data.split(",");
if (entity instanceof LivingEntity) {
((LivingEntity) entity).setMaxHealth(Double.parseDouble(parts[1]));
((LivingEntity) entity).setHealth(Double.parseDouble(parts[0]));
if (!parts[2].equals("null"))
((LivingEntity) entity).setCustomName(parts[2]);
if (entity instanceof Animals) {
((Animals) entity).setAge(Integer.parseInt(parts[3]));
if (entity instanceof Sheep) {
((Sheep) entity).setSheared(Boolean.parseBoolean(parts[4]));
((Sheep) entity).setColor(sheepColors.get(parts[5]));
} else if (entity instanceof Wolf) {
if (Boolean.parseBoolean(parts[4])) {
((Wolf) entity).setAngry(Boolean.parseBoolean(parts[4]));
} else if (parts.length > 5) {
((Tameable) entity).setTamed(true);
((Tameable) entity).setOwner(getPlayer(parts[5]));
((Wolf) entity).setCollarColor(DyeColor.valueOf(parts[6]));
}
} else if (entity instanceof Ocelot) {
if (parts.length > 4) {
((Tameable) entity).setTamed(true);
((Tameable) entity).setOwner(getPlayer(parts[4]));
((Ocelot) entity).setCatType(catTypes.get(parts[5]));
}
} else if (entity instanceof Pig) {
((Pig) entity).setSaddle(Boolean.parseBoolean(parts[4]));
} else if (entity instanceof Horse) {
// ((Horse) entity).setVariant(horseVariants.get(parts[4]));
((Horse) entity).setStyle(horseStyles.get(parts[5]));
((Horse) entity).setColor(horseColors.get(parts[6]));
((Horse) entity).setDomestication(Integer.parseInt(parts[7]));
((Horse) entity).setMaxDomestication(Integer.parseInt(parts[8]));
((Horse) entity).setJumpStrength(Double.parseDouble(parts[9]));
if (parts.length > 10) {
((Tameable) entity).setTamed(true);
if (!parts[10].equals("null"))
((Tameable) entity).setOwner(getPlayer(parts[10]));
((Horse) entity).getInventory().setSaddle(ItemStackUtil.stringToItemStack(parts[11])[0]);
((Horse) entity).getInventory().setArmor(ItemStackUtil.stringToItemStack(parts[12])[0]);
if (parts.length > 13) {
((Horse) entity).setCarryingChest(true);
((Horse) entity).getInventory().setContents(ItemStackUtil.stringToItemStack(parts[13]));
}
}
}
} else if (entity instanceof Villager) {
((Villager) entity).setProfession(villagerProfessions.get(parts[3]));
((Villager) entity).setAge(Integer.parseInt(parts[4]));
} else if (entity instanceof Creeper) {
((Creeper) entity).setPowered(Boolean.parseBoolean(parts[3]));
} else if (entity instanceof Slime) {
((Slime) entity).setSize(Integer.parseInt(parts[3]));
} else if (entity instanceof Skeleton) {
((Skeleton) entity).setSkeletonType(skeletonTypes.get(parts[3]));
if (parts[3].equals("0")) {
((Skeleton) entity).getEquipment().setItemInHand(new ItemStack(Material.BOW));
} else {
((Skeleton) entity).getEquipment().setItemInHand(new ItemStack(Material.BOW));
}
} else if (entity instanceof PigZombie) {
((LivingEntity) entity).getEquipment().setItemInHand(new ItemStack(Material.GOLD_SWORD));
}
}
}
项目:PwnBreeding
文件:FeedListener.java
@EventHandler(ignoreCancelled = true)
public void onAnimalClick(PlayerInteractEntityEvent e)
{
// THIS EVENT FIRES TOO FAST WE NEED A TIMER
World eworld = e.getPlayer().getLocation().getWorld();
// If plugin is not enabled in this world, return
if (!PwnBreeding.isEnabledIn(eworld.getName())) return;
Player player = e.getPlayer();
String thisItem = player.getItemInHand().getType().toString();
if(e.getRightClicked() instanceof Chicken)
{
e.setCancelled(true);
player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
if (player.getItemInHand().getType() == Material.SEEDS)
{
if(player.getItemInHand().getAmount() > 1)
{
player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1);
}
else
{
player.getItemInHand().setAmount(0);
}
}
}
else if(e.getRightClicked() instanceof Cow)
{
player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
}
else if(e.getRightClicked() instanceof Sheep)
{
player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
}
else if(e.getRightClicked() instanceof Pig)
{
player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
}
else if(e.getRightClicked() instanceof Horse)
{
player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
}
else if(e.getRightClicked() instanceof Wolf)
{
player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
}
else if(e.getRightClicked() instanceof Ocelot)
{
player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
}
else if(e.getRightClicked() instanceof Rabbit)
{
player.sendMessage(ChatColor.GOLD + "Player has " + thisItem + " for a " + e.getRightClicked().getType().toString());
}
}
项目:Pore
文件:OcelotConverter.java
public static OcelotType of(Ocelot.Type type) {
return CONVERTER.convert(type);
}