本文整理匯總了Java中org.bukkit.entity.Slime類的典型用法代碼示例。如果您正苦於以下問題:Java Slime類的具體用法?Java Slime怎麽用?Java Slime使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Slime類屬於org.bukkit.entity包,在下文中一共展示了Slime類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: change
import org.bukkit.entity.Slime; //導入依賴的package包/類
@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());
}
}
}
示例2: SizeMenu
import org.bukkit.entity.Slime; //導入依賴的package包/類
/**
* {@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);
}
示例3: getCreatureType
import org.bukkit.entity.Slime; //導入依賴的package包/類
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;
}
示例4: onSlimeSplit
import org.bukkit.entity.Slime; //導入依賴的package包/類
@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();
}
}
示例5: onMobSpawn
import org.bukkit.entity.Slime; //導入依賴的package包/類
/**
* 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);
}
}
}
示例6: onSlimeSplit
import org.bukkit.entity.Slime; //導入依賴的package包/類
@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;
}
}
示例7: slimeCheck
import org.bukkit.entity.Slime; //導入依賴的package包/類
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();
}
}
示例8: getState
import org.bukkit.entity.Slime; //導入依賴的package包/類
@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);
}
示例9: get
import org.bukkit.entity.Slime; //導入依賴的package包/類
@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;
}
示例10: onMobSpawn
import org.bukkit.entity.Slime; //導入依賴的package包/類
@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;
}
}
}
示例11: onCreatureSpawn
import org.bukkit.entity.Slime; //導入依賴的package包/類
/**
* 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);
}
}
示例12: effect
import org.bukkit.entity.Slime; //導入依賴的package包/類
@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;
}
示例13: doOnRightClick
import org.bukkit.entity.Slime; //導入依賴的package包/類
@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"));
}
示例14: applyMountData
import org.bukkit.entity.Slime; //導入依賴的package包/類
@Override
public void applyMountData(Entity npc) {
super.applyMountData(npc);
if (!(npc instanceof Slime)) {
return;
}
Slime slime = (Slime) npc;
slime.setSize(size);
}
示例15: onCritical
import org.bukkit.entity.Slime; //導入依賴的package包/類
@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);
}
}
}