Java 类org.bukkit.entity.Slime 实例源码
项目:Skellett
文件:ExprSlimeSize.java
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode){
if (entity.getSingle(e) == null) {
return;
}
Number num = (Number)delta[0];
Number numNow = ((Slime)entity.getSingle(e)).getSize();
if (entity.getSingle(e).toString().equals("CraftSlime") || entity.getSingle(e).toString().equals("CraftMagmaCube")) {
if (mode == ChangeMode.SET) {
((Slime)entity.getSingle(e)).setSize(num.intValue());
} else if (mode == ChangeMode.ADD) {
((Slime)entity.getSingle(e)).setSize(numNow.intValue() + num.intValue());
} else if (mode == ChangeMode.REMOVE) {
((Slime)entity.getSingle(e)).setSize(numNow.intValue() - num.intValue());
}
}
}
项目:buildinggame
文件:SizeMenu.java
/**
* {@inheritDoc}
*/
public SizeMenu(Plot plot, Slime slime) {
super(plot, slime);
//size
ItemStack size = new ItemStack(Material.RED_MUSHROOM);
ItemMeta sizeMeta = size.getItemMeta();
sizeMeta.setDisplayName(ChatColor.GREEN + "Change size");
size.setItemMeta(sizeMeta);
insertItem(size, event -> {
new SizeSelectionMenu(slime).open((Player) event.getWhoClicked());
event.setCancelled(true);
}, 0);
}
项目:uSkyBlock
文件:LimitLogic.java
public CreatureType getCreatureType(EntityType entityType) {
if (Monster.class.isAssignableFrom(entityType.getEntityClass())
|| WaterMob.class.isAssignableFrom(entityType.getEntityClass())
|| Slime.class.isAssignableFrom(entityType.getEntityClass())
|| Ghast.class.isAssignableFrom(entityType.getEntityClass())
) {
return CreatureType.MONSTER;
} else if (Animals.class.isAssignableFrom(entityType.getEntityClass())) {
return CreatureType.ANIMAL;
} else if (Villager.class.isAssignableFrom(entityType.getEntityClass())) {
return CreatureType.VILLAGER;
} else if (Golem.class.isAssignableFrom(entityType.getEntityClass())) {
return CreatureType.GOLEM;
}
return CreatureType.UNKNOWN;
}
项目:SwornCritters
文件:EntityListener.java
@EventHandler
public void onSlimeSplit(SlimeSplitEvent event)
{
Slime slime = event.getEntity();
if (plugin.getLegendaryEntityId() != null && plugin.getLegendaryEntityId().equals(slime.getUniqueId()))
{
event.setCount(0);
Player killer = slime.getKiller();
if (killer != null)
{
Material mat = MaterialUtil.getMaterial(plugin.getConfig().getString("slimeDropsType"));
slime.getWorld().dropItem(slime.getLocation(), new ItemStack(mat, plugin.getConfig().getInt("slimeDropsAmount")));
killer.sendMessage(ChatColor.GREEN + "You have killed a legendary monster!");
}
slime.remove();
plugin.removeLegendary();
}
}
项目:bskyblock
文件:IslandGuard.java
/**
* Prevents mobs spawning at spawn or in an island
*
* @param e
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onMobSpawn(final CreatureSpawnEvent e) {
if (DEBUG2) {
plugin.getLogger().info("on Mob spawn" + e.getEventName());
}
// if grid is not loaded yet, return.
if (plugin.getIslands() == null) {
return;
}
// If not in the right world, return
if (!Util.inWorld(e.getEntity())) {
return;
}
// Deal with natural spawning
if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime) {
if (!actionAllowed(e.getLocation(), SettingsFlag.MONSTER_SPAWN)) {
if (DEBUG2)
plugin.getLogger().info("Natural monster spawn cancelled.");
// Mobs not allowed to spawn
e.setCancelled(true);
return;
}
}
if (e.getEntity() instanceof Animals) {
if (!actionAllowed(e.getLocation(), SettingsFlag.ANIMAL_SPAWN)) {
// Animals are not allowed to spawn
if (DEBUG2)
plugin.getLogger().info("Natural animal spawn cancelled.");
e.setCancelled(true);
}
}
}
项目:ProjectAres
文件:OwnedMobTracker.java
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSlimeSplit(CreatureSpawnEvent event) {
switch(event.getSpawnReason()) {
case SLIME_SPLIT:
Slime parent = splitter.get();
if(parent != null) {
MobInfo info = resolveEntity(parent);
if(info != null) {
entities().trackEntity(event.getEntity(), info);
}
}
break;
}
}
项目:True-Custom-Drops
文件:MobListener.java
void slimeCheck () {
if (en.getType().name().equals("SLIME")) {
if (((Slime)en).getSize() == config.getInt(path+".size"))
checkPrelims();
} else if (en.getType().toString().equals("MAGMA_CUBE")) {
if (((MagmaCube)en).getSize() == config.getInt(path+".size"))
checkPrelims();
}
}
项目:QuestManager
文件:VanquishRequirement.java
@Override
public RequirementState getState() {
YamlConfiguration myState = new YamlConfiguration();
myState.set("type", "vr");
ConfigurationSection foeSection = myState.createSection("foe");
foeSection.set("type", foe.getType().name());
foeSection.set("maxhp", foe.getMaxHealth());
foeSection.set("hp", foe.getHealth());
foeSection.set("name", foe.getCustomName());
foeSection.set("location", foe.getLocation());
if (foe instanceof Guardian) {
foeSection.set("elder", ((Guardian) foe).isElder());
}
if (foe instanceof Slime) {
foeSection.set("size", ((Slime) foe).getSize());
}
if (foe instanceof Skeleton) {
foeSection.set("wither", ((Skeleton) foe).getSkeletonType() == SkeletonType.WITHER);
}
EquipmentConfiguration econ = new EquipmentConfiguration(foe.getEquipment());
foeSection.set("equipment", econ.getConfiguration());
return new RequirementState(myState);
}
项目:Skellett
文件:ExprSlimeSize.java
@Override
@Nullable
protected Number[] get(Event e) {
if (entity.getSingle(e) == null) {
return null;
}
if (entity.getSingle(e).toString().equals("CraftSlime") || entity.getSingle(e).toString().equals("CraftMagmaCube")) {
return new Number[]{((Slime)entity.getSingle(e)).getSize()};
}
return null;
}
项目:beaconz
文件:LobbyListener.java
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onMobSpawn(final CreatureSpawnEvent e) {
if (DEBUG) {
getLogger().info(e.getEventName());
}
// If not at spawn, return, or if grid is not loaded yet.
if (!getGameMgr().getLobby().contains(e.getLocation())) {
return;
}
if (!Settings.allowLobbyEggs && (e.getSpawnReason().equals(SpawnReason.SPAWNER_EGG) || e.getSpawnReason().equals(SpawnReason.EGG))) {
e.setCancelled(true);
return;
}
// Deal with mobs
if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime) {
if (!Settings.allowLobbyMobSpawn) {
// Mobs not allowed to spawn
e.setCancelled(true);
return;
}
}
// If animals can spawn, check if the spawning is natural, or
// egg-induced
if (e.getEntity() instanceof Animals) {
if (!Settings.allowLobbyAnimalSpawn) {
// Animals are not allowed to spawn
e.setCancelled(true);
return;
}
}
}
项目:uSkyBlock
文件:LimitLogic.java
public CreatureType getCreatureType(LivingEntity creature) {
if (creature instanceof Monster
|| creature instanceof WaterMob
|| creature instanceof Slime
|| creature instanceof Ghast) {
return CreatureType.MONSTER;
} else if (creature instanceof Animals) {
return CreatureType.ANIMAL;
} else if (creature instanceof Villager) {
return CreatureType.VILLAGER;
} else if (creature instanceof Golem) {
return CreatureType.GOLEM;
}
return CreatureType.UNKNOWN;
}
项目:Factoid
文件:WorldListener.java
/**
* On creature spawn.
*
* @param event the event
*/
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
IDummyLand land = Factoid.getThisPlugin().iLands().getLandOrOutsideArea(event.getEntity().getLocation());
if ((event.getEntity() instanceof Animals
&& land.getFlagAndInherit(FlagList.ANIMAL_SPAWN.getFlagType()).getValueBoolean() == false)
|| ((event.getEntity() instanceof Monster
|| event.getEntity() instanceof Slime
|| event.getEntity() instanceof Flying)
&& land.getFlagAndInherit(FlagList.MOB_SPAWN.getFlagType()).getValueBoolean() == false)) {
event.setCancelled(true);
}
}
项目:ce
文件:BeastmastersBow.java
@Override
public boolean effect(Event event, Player player) {
// List<String> lore = e.getBow().getItemMeta().getLore();
// if(!lore.contains(placeHolder)) {
// for(int i = descriptionSize; i != 0; i--)
// lore.remove(i);
// e.getProjectile().setMetadata("ce." + this.getOriginalName(), new FixedMetadataValue(main, writeType(lore)));
// player.setMetadata("ce.CanUnleashBeasts", null);
// } else
// e.getProjectile().setMetadata("ce." + this.getOriginalName(), null);
if(event instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
if(e.getDamager() != player)
return false;
Entity ent = e.getEntity();
Location loc = ent.getLocation();
World w = ent.getWorld();
if(ent instanceof Silverfish || ent instanceof EnderDragon || ent instanceof Spider || ent instanceof Slime || ent instanceof Ghast || ent instanceof MagmaCube || ent instanceof CaveSpider || (ent instanceof Wolf && ((Wolf) ent).isAngry()) || ent instanceof PigZombie) {
e.setDamage(e.getDamage()*DamageMultiplication);
w.playEffect(loc, Effect.SMOKE, 50);
w.playEffect(loc, Effect.MOBSPAWNER_FLAMES, 50);
EffectManager.playSound(loc, "BLOCK_PISTON_RETRACT", 1.3f, 3f);
return true;
} else if (ent instanceof Player) {
for(int i = 0; i < MaximumMobs; i++) {
if(rand.nextInt(100) < MobAppearanceChance) {
w.spawnEntity(loc, rand.nextInt(2) == 1 ? EntityType.SPIDER : EntityType.SLIME);
w.playEffect(loc, Effect.MOBSPAWNER_FLAMES, 30);
w.playEffect(loc, Effect.SMOKE, 30);
EffectManager.playSound(loc, "BLOCK_ANVIL_BREAK", 0.3f, 0.1f);
}
}
}
}
return false;
}
项目:Equestrian-Dash
文件:SlimePowerup.java
@Override
public void doOnRightClick(Racer racer, Action action)
{
Player p = racer.getPlayer();
p.sendMessage(getMessage());
Location l1 = new Location(p.getWorld(), p.getLocation().getBlockX() + 1, p.getLocation().getBlockY(), p.getLocation().getBlockZ());
Location l2 = new Location(p.getWorld(), p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ() - 1);
final Slime s1 = (Slime) p.getWorld().spawnEntity(l1, EntityType.SLIME);
final Slime s2 = (Slime) p.getWorld().spawnEntity(l2, EntityType.SLIME);
final Slime s3 = (Slime) p.getWorld().spawnEntity(l1, EntityType.SLIME);
final Slime s4 = (Slime) p.getWorld().spawnEntity(l2, EntityType.SLIME);
s1.setMetadata("Creator", new FixedMetadataValue(EquestrianDash.plugin, p.getName()));
s2.setMetadata("Creator", new FixedMetadataValue(EquestrianDash.plugin, p.getName()));
s3.setMetadata("Creator", new FixedMetadataValue(EquestrianDash.plugin, p.getName()));
s4.setMetadata("Creator", new FixedMetadataValue(EquestrianDash.plugin, p.getName()));
p.getInventory().clear();
Bukkit.getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("EquestrianDash"), new Runnable()
{
@Override
public void run()
{
s1.remove();
s2.remove();
s3.remove();
s4.remove();
s1.getWorld().createExplosion(s1.getLocation(), (float) 0.0);
s2.getWorld().createExplosion(s2.getLocation(), (float) 0.0);
s3.getWorld().createExplosion(s3.getLocation(), (float) 0.0);
s4.getWorld().createExplosion(s4.getLocation(), (float) 0.0);
}
}, EquestrianDash.plugin.getConfig().getLong("Powerups.Slime.RemoveAfter"));
}
项目:MineKart
文件:SizeMountData.java
@Override
public void applyMountData(Entity npc) {
super.applyMountData(npc);
if (!(npc instanceof Slime)) {
return;
}
Slime slime = (Slime) npc;
slime.setSize(size);
}
项目:xEssentials_old_Source
文件:criticalEvent.java
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCritical(EntityDamageByEntityEvent e) {
if(e.getDamager() instanceof Player) {
if(e.getEntity() instanceof LivingEntity) {
LivingEntity attackedEntity = (LivingEntity) e.getEntity();
final Slime entity = (Slime) e.getDamager().getWorld().spawnEntity(attackedEntity.getEyeLocation(), EntityType.SLIME);
entity.setSize(1);
entity.setCustomName(ChatColor.translateAlternateColorCodes('&', "&e"+attackedEntity.getHealth() + "!"));
entity.getWorld().playEffect(entity.getLocation(), Effect.MOBSPAWNER_FLAMES, 100);
entitys.add(entity);
entity.damage(1);
}
}
}
项目:bskyblock
文件:IslandGuard1_9.java
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onLingeringPotionDamage(final EntityDamageByEntityEvent e) {
if (DEBUG) {
plugin.getLogger().info("1.9 lingering potion damage " + e.getEventName());
plugin.getLogger().info("1.9 lingering potion entity = " + e.getEntity());
plugin.getLogger().info("1.9 lingering potion entity type = " + e.getEntityType());
plugin.getLogger().info("1.9 lingering potion cause = " + e.getCause());
plugin.getLogger().info("1.9 lingering potion damager = " + e.getDamager());
}
if (!Util.inWorld(e.getEntity().getLocation())) {
return;
}
if (e.getEntity() == null || e.getEntity().getUniqueId() == null) {
return;
}
if (e.getCause().equals(DamageCause.ENTITY_ATTACK) && thrownPotions.containsKey(e.getDamager().getEntityId())) {
UUID attacker = thrownPotions.get(e.getDamager().getEntityId());
// Self damage
if (attacker.equals(e.getEntity().getUniqueId())) {
if (DEBUG)
plugin.getLogger().info("DEBUG: Self damage from lingering potion!");
return;
}
Island island = plugin.getIslands().getIslandAt(e.getEntity().getLocation());
boolean inNether = false;
if (e.getEntity().getWorld().equals(IslandWorld.getNetherWorld())) {
inNether = true;
}
// Monsters being hurt
if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime || e.getEntity() instanceof Squid) {
// Normal island check
if (island != null && island.getMembers().contains(attacker)) {
// Members always allowed
return;
}
if (actionAllowed(attacker, e.getEntity().getLocation(), SettingsFlag.HURT_MONSTERS)) {
return;
}
// Not allowed
e.setCancelled(true);
return;
}
// Mobs being hurt
if (e.getEntity() instanceof Animals || e.getEntity() instanceof IronGolem || e.getEntity() instanceof Snowman
|| e.getEntity() instanceof Villager) {
if (island != null && (island.getFlag(SettingsFlag.HURT_ANIMALS) || island.getMembers().contains(attacker))) {
return;
}
if (DEBUG)
plugin.getLogger().info("DEBUG: Mobs not allowed to be hurt. Blocking");
e.setCancelled(true);
return;
}
// Establish whether PVP is allowed or not.
boolean pvp = false;
if ((inNether && island != null && island.getFlag(SettingsFlag.PVP_NETHER) || (!inNether && island != null && island.getFlag(SettingsFlag.PVP_OVERWORLD)))) {
if (DEBUG) plugin.getLogger().info("DEBUG: PVP allowed");
pvp = true;
}
// Players being hurt PvP
if (e.getEntity() instanceof Player) {
if (!pvp) {
if (DEBUG) plugin.getLogger().info("DEBUG: PVP not allowed");
e.setCancelled(true);
}
}
}
}
项目:SurvivalPlus
文件:LivingSlime.java
private Runnable initRunnable(Item i)
{
final Item f_i = i;
Runnable run = new Runnable()
{
public void run()
{
List<Block> slimeBlocks = new ArrayList<Block>();
slimeBlocks.add(f_i.getLocation().add(0, -1, 0).getBlock());
slimeBlocks.add(f_i.getLocation().add(0, -1, 1).getBlock());
slimeBlocks.add(f_i.getLocation().add(0, -1, -1).getBlock());
slimeBlocks.add(f_i.getLocation().add(1, -1, 0).getBlock());
slimeBlocks.add(f_i.getLocation().add(-1, -1, 0).getBlock());
slimeBlocks.add(f_i.getLocation().add(0, 0, 1).getBlock());
slimeBlocks.add(f_i.getLocation().add(0, 0, -1).getBlock());
slimeBlocks.add(f_i.getLocation().add(1, 0, 0).getBlock());
slimeBlocks.add(f_i.getLocation().add(-1, 0, 0).getBlock());
slimeBlocks.add(f_i.getLocation().add(1, 0, 1).getBlock());
slimeBlocks.add(f_i.getLocation().add(1, 0, -1).getBlock());
slimeBlocks.add(f_i.getLocation().add(-1, 0, 1).getBlock());
slimeBlocks.add(f_i.getLocation().add(-1, 0, -1).getBlock());
ItemStack i_f_i = ((Item)f_i).getItemStack();
Iterator<Block> it = slimeBlocks.iterator();
Block slimeBlock = null;
while(it.hasNext())
{
slimeBlock = it.next();
if(slimeBlock != null && slimeBlock.getType() == Material.SLIME_BLOCK && f_i.isOnGround())
{
if(i_f_i.getAmount() > 1)
i_f_i.setAmount(i_f_i.getAmount() - 1);
else
f_i.remove();
if(i_f_i.getAmount() <= 0)
f_i.remove();
slimeBlock.setType(Material.AIR);
Slime slime = (Slime)f_i.getWorld().spawnEntity(slimeBlock.getLocation(), EntityType.SLIME);
slime.setSize(2);
ParticleEffect.CLOUD.display(0.5f, 0.5f, 0.5f, 0.1f, 20, slimeBlock.getLocation().add(0.5, 0.5, 0.5), 64);
break;
}
}
}
};
return run;
}
项目:Thermos-Bukkit
文件:SlimeSplitEvent.java
public SlimeSplitEvent(final Slime slime, final int count) {
super(slime);
this.count = count;
}
项目:Thermos-Bukkit
文件:SlimeSplitEvent.java
@Override
public Slime getEntity() {
return (Slime) entity;
}
项目:QuestManager
文件:TitleEffect.java
public void run(Location loc) {
Location l = loc.clone();
l.add(rand.nextDouble(), 0, rand.nextDouble());
Slime s = (Slime) l.getWorld().spawnEntity(loc, EntityType.SLIME);
s.setSize(1);
}
项目:QuestManager
文件:VanquishRequirement.java
@Override
public void activate() {
ConfigurationSection myState = foeStateRecord.getConfig();
//get rid of any entities we already have
if (foe != null && !foe.isDead()) {
foe.remove();
}
ConfigurationSection foeState = myState.getConfigurationSection("foe");
Location loc = ((LocationState) foeState.get("location")).getLocation();
//load chunk before creating foe
loc.getChunk();
foe = (LivingEntity) loc.getWorld().spawnEntity(loc, EntityType.valueOf(foeState.getString("type")));
this.id = foe.getUniqueId();
foe.setMaxHealth(foeState.getDouble("maxhp"));
foe.setHealth(foeState.getDouble("hp"));
foe.setCustomName(foeState.getString("name"));
foe.setRemoveWhenFarAway(false);
EntityEquipment equipment = foe.getEquipment();
EquipmentConfiguration econ = new EquipmentConfiguration();
try {
econ.load( foeState.getConfigurationSection("equipment"));
} catch (InvalidConfigurationException e) {
e.printStackTrace();
}
equipment.setHelmet(econ.getHead());
equipment.setChestplate(econ.getChest());
equipment.setLeggings(econ.getLegs());
equipment.setBoots(econ.getBoots());
equipment.setItemInMainHand(econ.getHeldMain());
equipment.setItemInOffHand(econ.getHeldOff());
//special checks
if (foe instanceof Guardian) {
if (foeState.getBoolean("elder", false)) {
((Guardian) foe).setElder(true);
}
}
if (foe instanceof Slime) {
if (foeState.getInt("size", 1) > 1) {
((Slime) foe).setSize(foeState.getInt("size"));
}
}
if (foe instanceof Skeleton) {
if (foeState.getBoolean("wither", false)) {
((Skeleton) foe).setSkeletonType(SkeletonType.WITHER);
}
}
if (desc == null) {
desc = foeState.getString("description", "Slay " + foe.getCustomName());
}
//add as NPC for non-removal
foeNPC = new QuestMonsterNPC();
foeNPC.setEntity(foe);
QuestManagerPlugin.questManagerPlugin.getManager().registerNPC(foeNPC);
update();
Bukkit.getPluginManager().registerEvents(this, QuestManagerPlugin.questManagerPlugin);
}
项目:SonarPet
文件:AbstractEntitySlimePet.java
@Override
public Slime getBukkitEntity() {
return (Slime) super.getBukkitEntity();
}
项目:CauldronGit
文件:SlimeSplitEvent.java
public SlimeSplitEvent(final Slime slime, final int count) {
super(slime);
this.count = count;
}
项目:CauldronGit
文件:SlimeSplitEvent.java
@Override
public Slime getEntity() {
return (Slime) entity;
}
项目:CanaryBukkit
文件:CanarySlime.java
public CanarySlime(net.canarymod.api.entity.living.monster.Slime entity) {
super(entity);
}
项目:CanaryBukkit
文件:CanarySlime.java
public void setSize(int size) {
getHandle().setSize(net.canarymod.api.entity.living.monster.Slime.Size.fromByte((byte) size));
}
项目:CanaryBukkit
文件:CanarySlime.java
@Override
protected net.canarymod.api.entity.living.monster.Slime getHandle() {
return (net.canarymod.api.entity.living.monster.Slime) super.getHandle();
}
项目:buildinggame
文件:SizeSelectionMenu.java
/**
* {@inheritDoc}
*/
SizeSelectionMenu(Slime slime) {
super(null, 9, ChatColor.GREEN + "Change size", 1);
setStartingPoint(3);
//small
ItemStack goldNugget = new ItemStack(Material.GOLD_NUGGET);
ItemMeta goldNuggetMeta = goldNugget.getItemMeta();
goldNuggetMeta.setDisplayName(ChatColor.GREEN + "Small");
goldNugget.setItemMeta(goldNuggetMeta);
addItem(goldNugget, event -> {
slime.setSize(1);
event.setCancelled(true);
});
//medium
ItemStack goldIngot = new ItemStack(Material.GOLD_INGOT);
ItemMeta goldIngotMeta = goldIngot.getItemMeta();
goldIngotMeta.setDisplayName(ChatColor.GREEN + "Medium");
goldIngot.setItemMeta(goldIngotMeta);
addItem(goldIngot, event -> {
slime.setSize(2);
event.setCancelled(true);
});
//large
ItemStack goldBlock = new ItemStack(Material.GOLD_BLOCK);
ItemMeta goldBlockMeta = goldBlock.getItemMeta();
goldBlockMeta.setDisplayName(ChatColor.GREEN + "Large");
goldBlock.setItemMeta(goldBlockMeta);
addItem(goldBlock, event -> {
slime.setSize(4);
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));
}
}
}
项目:acidisland
文件:IslandGuard1_9.java
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onLingeringPotionDamage(final EntityDamageByEntityEvent e) {
if (DEBUG) {
plugin.getLogger().info("1.9 lingering potion damage " + e.getEventName());
plugin.getLogger().info("1.9 lingering potion entity = " + e.getEntity());
plugin.getLogger().info("1.9 lingering potion entity type = " + e.getEntityType());
plugin.getLogger().info("1.9 lingering potion cause = " + e.getCause());
plugin.getLogger().info("1.9 lingering potion damager = " + e.getDamager());
}
if (!IslandGuard.inWorld(e.getEntity().getLocation())) {
return;
}
if (e.getEntity() == null || e.getEntity().getUniqueId() == null) {
return;
}
if (e.getCause().equals(DamageCause.ENTITY_ATTACK) && thrownPotions.containsKey(e.getDamager().getEntityId())) {
UUID attacker = thrownPotions.get(e.getDamager().getEntityId());
// Self damage
if (attacker.equals(e.getEntity().getUniqueId())) {
if (DEBUG)
plugin.getLogger().info("DEBUG: Self damage from lingering potion!");
return;
}
Island island = plugin.getGrid().getIslandAt(e.getEntity().getLocation());
boolean inNether = false;
if (e.getEntity().getWorld().equals(ASkyBlock.getNetherWorld())) {
inNether = true;
}
// Monsters being hurt
if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime || e.getEntity() instanceof Squid) {
// Normal island check
if (island != null && island.getMembers().contains(attacker)) {
// Members always allowed
return;
}
if (actionAllowed(attacker, e.getEntity().getLocation(), SettingsFlag.HURT_MONSTERS)) {
return;
}
// Not allowed
e.setCancelled(true);
return;
}
// Mobs being hurt
if (e.getEntity() instanceof Animals || e.getEntity() instanceof IronGolem || e.getEntity() instanceof Snowman
|| e.getEntity() instanceof Villager) {
if (island != null && (island.getIgsFlag(SettingsFlag.HURT_MOBS) || island.getMembers().contains(attacker))) {
return;
}
if (DEBUG)
plugin.getLogger().info("DEBUG: Mobs not allowed to be hurt. Blocking");
e.setCancelled(true);
return;
}
// Establish whether PVP is allowed or not.
boolean pvp = false;
if ((inNether && island != null && island.getIgsFlag(SettingsFlag.NETHER_PVP) || (!inNether && island != null && island.getIgsFlag(SettingsFlag.PVP)))) {
if (DEBUG) plugin.getLogger().info("DEBUG: PVP allowed");
pvp = true;
}
// Players being hurt PvP
if (e.getEntity() instanceof Player) {
if (pvp) {
if (DEBUG) plugin.getLogger().info("DEBUG: PVP allowed");
return;
} else {
if (DEBUG) plugin.getLogger().info("DEBUG: PVP not allowed");
e.setCancelled(true);
return;
}
}
}
}
项目:acidisland
文件:EntityLimits.java
/**
* Prevents mobs spawning naturally at spawn or in an island
*
* @param e
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onNaturalMobSpawn(final CreatureSpawnEvent e) {
// if grid is not loaded yet, return.
if (plugin.getGrid() == null) {
return;
}
// If not in the right world, return
if (!IslandGuard.inWorld(e.getEntity())) {
return;
}
// Deal with natural spawning
if (e.getSpawnReason().equals(SpawnReason.NATURAL) || e.getSpawnReason().equals(SpawnReason.JOCKEY)
|| e.getSpawnReason().equals(SpawnReason.CHUNK_GEN)
|| e.getSpawnReason().equals(SpawnReason.DEFAULT)
|| e.getSpawnReason().equals(SpawnReason.MOUNT)
|| e.getSpawnReason().equals(SpawnReason.JOCKEY)
|| e.getSpawnReason().equals(SpawnReason.NETHER_PORTAL)) {
if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime) {
if (!actionAllowed(e.getLocation(), SettingsFlag.MONSTER_SPAWN)) {
if (DEBUG3)
plugin.getLogger().info("Natural monster spawn cancelled.");
// Mobs not allowed to spawn
e.setCancelled(true);
return;
}
} else if (e.getEntity() instanceof Animals) {
if (!actionAllowed(e.getLocation(), SettingsFlag.MOB_SPAWN)) {
// Animals are not allowed to spawn
if (DEBUG2)
plugin.getLogger().info("Natural animal spawn cancelled.");
e.setCancelled(true);
return;
}
}
}
if (DEBUG2) {
plugin.getLogger().info("Mob spawn allowed " + e.getEventName());
plugin.getLogger().info(e.getSpawnReason().toString());
plugin.getLogger().info(e.getEntityType().toString());
}
}
项目:askyblock
文件:IslandGuard1_9.java
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onLingeringPotionDamage(final EntityDamageByEntityEvent e) {
if (DEBUG) {
plugin.getLogger().info("1.9 lingering potion damage " + e.getEventName());
plugin.getLogger().info("1.9 lingering potion entity = " + e.getEntity());
plugin.getLogger().info("1.9 lingering potion entity type = " + e.getEntityType());
plugin.getLogger().info("1.9 lingering potion cause = " + e.getCause());
plugin.getLogger().info("1.9 lingering potion damager = " + e.getDamager());
}
if (!IslandGuard.inWorld(e.getEntity().getLocation())) {
return;
}
if (e.getEntity() == null || e.getEntity().getUniqueId() == null) {
return;
}
if (e.getCause().equals(DamageCause.ENTITY_ATTACK) && thrownPotions.containsKey(e.getDamager().getEntityId())) {
UUID attacker = thrownPotions.get(e.getDamager().getEntityId());
// Self damage
if (attacker.equals(e.getEntity().getUniqueId())) {
if (DEBUG)
plugin.getLogger().info("DEBUG: Self damage from lingering potion!");
return;
}
Island island = plugin.getGrid().getIslandAt(e.getEntity().getLocation());
boolean inNether = false;
if (e.getEntity().getWorld().equals(ASkyBlock.getNetherWorld())) {
inNether = true;
}
// Monsters being hurt
if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime || e.getEntity() instanceof Squid) {
// Normal island check
if (island != null && island.getMembers().contains(attacker)) {
// Members always allowed
return;
}
if (actionAllowed(attacker, e.getEntity().getLocation(), SettingsFlag.HURT_MONSTERS)) {
return;
}
// Not allowed
e.setCancelled(true);
return;
}
// Mobs being hurt
if (e.getEntity() instanceof Animals || e.getEntity() instanceof IronGolem || e.getEntity() instanceof Snowman
|| e.getEntity() instanceof Villager) {
if (island != null && (island.getIgsFlag(SettingsFlag.HURT_MOBS) || island.getMembers().contains(attacker))) {
return;
}
if (DEBUG)
plugin.getLogger().info("DEBUG: Mobs not allowed to be hurt. Blocking");
e.setCancelled(true);
return;
}
// Establish whether PVP is allowed or not.
boolean pvp = false;
if ((inNether && island != null && island.getIgsFlag(SettingsFlag.NETHER_PVP) || (!inNether && island != null && island.getIgsFlag(SettingsFlag.PVP)))) {
if (DEBUG) plugin.getLogger().info("DEBUG: PVP allowed");
pvp = true;
}
// Players being hurt PvP
if (e.getEntity() instanceof Player) {
if (pvp) {
if (DEBUG) plugin.getLogger().info("DEBUG: PVP allowed");
return;
} else {
if (DEBUG) plugin.getLogger().info("DEBUG: PVP not allowed");
e.setCancelled(true);
return;
}
}
}
}
项目:askyblock
文件:EntityLimits.java
/**
* Prevents mobs spawning naturally at spawn or in an island
*
* @param e
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onNaturalMobSpawn(final CreatureSpawnEvent e) {
// if grid is not loaded yet, return.
if (plugin.getGrid() == null) {
return;
}
// If not in the right world, return
if (!IslandGuard.inWorld(e.getEntity())) {
return;
}
// Deal with natural spawning
if (e.getSpawnReason().equals(SpawnReason.NATURAL) || e.getSpawnReason().equals(SpawnReason.JOCKEY)
|| e.getSpawnReason().equals(SpawnReason.CHUNK_GEN)
|| e.getSpawnReason().equals(SpawnReason.DEFAULT)
|| e.getSpawnReason().equals(SpawnReason.MOUNT)
|| e.getSpawnReason().equals(SpawnReason.JOCKEY)
|| e.getSpawnReason().equals(SpawnReason.NETHER_PORTAL)) {
if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime) {
if (!actionAllowed(e.getLocation(), SettingsFlag.MONSTER_SPAWN)) {
if (DEBUG3)
plugin.getLogger().info("Natural monster spawn cancelled.");
// Mobs not allowed to spawn
e.setCancelled(true);
return;
}
} else if (e.getEntity() instanceof Animals) {
if (!actionAllowed(e.getLocation(), SettingsFlag.MOB_SPAWN)) {
// Animals are not allowed to spawn
if (DEBUG2)
plugin.getLogger().info("Natural animal spawn cancelled.");
e.setCancelled(true);
return;
}
}
}
if (DEBUG2) {
plugin.getLogger().info("Mob spawn allowed " + e.getEventName());
plugin.getLogger().info(e.getSpawnReason().toString());
plugin.getLogger().info(e.getEntityType().toString());
}
}
项目:PvPTeleport
文件:WorldCommand.java
/** Checks that player is not trying to combatlog/is allowed to teleport
* Returns an error message to be displayed if the player is not allowed
* to teleport
* Returns null if the player is allowed to teleport
*/
private static String teleportCheck(Player player) {
Location pLoc = player.getLocation();
World world = player.getWorld();
/* Check if there are any players within 50 blocks */
for (Player p : world.getPlayers()) {
if (!p.equals(player)
&& p.getLocation().distance(pLoc) < 50
&& player.canSee(p)
&& !p.isDead()) {
return ChatColor.RED + "You cannot use this command while within 50 blocks of any other players.";
}
}
/* Check if there are any hostile mobs within 5 blocks */
for (Entity entity : world.getEntitiesByClasses(
Blaze.class,
CaveSpider.class,
Creeper.class,
Enderman.class,
Ghast.class,
MagmaCube.class,
PigZombie.class,
Skeleton.class,
Silverfish.class,
Slime.class,
Spider.class,
Witch.class,
Zombie.class)) {
if (entity.getLocation().distance(pLoc) < 5) {
return ChatColor.RED + "You cannot use this command while within 5 blocks of any hostile mobs.";
}
}
/* Check if the player is falling */
if (player.getVelocity().getY() < -0.079
|| player.getVelocity().getY() > 0.08) {
return ChatColor.RED + "You cannot use this command while falling.";
}
/* Check if the player is burning */
if (player.getFireTicks() > 0
&& !player.hasPotionEffect(
PotionEffectType.FIRE_RESISTANCE)) {
return ChatColor.RED + "You cannot use this command while on fire.";
}
/* Default to allow teleport */
return null;
}
项目:Cauldron
文件:SlimeSplitEvent.java
public SlimeSplitEvent(final Slime slime, final int count) {
super(slime);
this.count = count;
}
项目:Cauldron
文件:SlimeSplitEvent.java
@Override
public Slime getEntity() {
return (Slime) entity;
}
项目:Cauldron
文件:SlimeSplitEvent.java
public SlimeSplitEvent(final Slime slime, final int count) {
super(slime);
this.count = count;
}