本文整理了Java中org.bukkit.entity.Entity.hasMetadata()
方法的一些代码示例,展示了Entity.hasMetadata()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.hasMetadata()
方法的具体详情如下:
包路径:org.bukkit.entity.Entity
类名称:Entity
方法名:hasMetadata
暂无
代码示例来源:origin: EngineHub/WorldGuard
/**
* Test whether an entity is an NPC.
*
* @param entity the entity
* @return true if an NPC
*/
public static boolean isNPC(Entity entity) {
return entity instanceof NPC || entity.hasMetadata("NPC");
}
代码示例来源:origin: ProjectKorra/ProjectKorra
/**
* Checks if the entity is stopped by an instance of MovementHandler
*
* @param entity the entity in question of being stopped
* @return false if not stopped by an instance of MovementHandler
*/
public static boolean isStopped(final Entity entity) {
return entity.hasMetadata("movement:stop");
}
代码示例来源:origin: mcMMO-Dev/mcMMO
public static boolean hasPlayerDataKey(Entity entity) {
return entity != null && entity.hasMetadata(mcMMO.playerDataKey);
}
}
代码示例来源:origin: elBukkit/MagicPlugin
@Override
public boolean isStaticNPC(Entity entity) {
return entity.hasMetadata(metaKey);
}
}
代码示例来源:origin: NoCheatPlus/NoCheatPlus
public boolean hasAnyMetaDataKey(final Entity entity) {
if (metaDataKeys == null) {
return false;
}
else {
for (int i = 0; i < metaDataKeys.length; i++) {
if (entity.hasMetadata(metaDataKeys[i])) {
return true;
}
}
return false;
}
}
代码示例来源:origin: bergerkiller/BKCommonLib
@Override
public boolean hasMetadata(String arg0) {
return base.hasMetadata(arg0);
}
代码示例来源:origin: elBukkit/MagicPlugin
@Override
public boolean isNPC(Entity entity) {
return entity.hasMetadata(metaKey);
}
代码示例来源:origin: jiongjionger/NeverLag
public static boolean checkCustomNpc(Entity entity) {
return entity == null || entity.hasMetadata("NPC") || entity.hasMetadata("MyPet");
}
代码示例来源:origin: bergerkiller/BKCommonLib
public boolean hasMetadata(String arg0) {
return entity.hasMetadata(arg0);
}
代码示例来源:origin: mcMMO-Dev/mcMMO
public static boolean isNPCEntity(Entity entity) {
return (entity == null || entity.hasMetadata("NPC") || entity instanceof NPC || entity.getClass().getName().equalsIgnoreCase("cofh.entity.PlayerFake"));
}
代码示例来源:origin: TheBusyBiscuit/Slimefun4
@EventHandler
public void onEntityRemove(EntityRemoveEvent e) {
Iterator<Entity> iterator = e.getEntityList().iterator();
while (iterator.hasNext()) {
Entity n = iterator.next();
if (n instanceof Item) {
if (n.hasMetadata("no_pickup")) iterator.remove();
}
}
}
}
代码示例来源:origin: elBukkit/MagicPlugin
public static boolean checkTracking(Plugin plugin, Entity tracked, Entity target, Block block) {
if (tracked == null || !tracked.hasMetadata("tracking")) {
return false;
}
if (target != null) {
tracked.setMetadata("hit", new FixedMetadataValue(plugin, new WeakReference<>(target)));
} else if (!tracked.hasMetadata("hit")) {
tracked.setMetadata("hit", new FixedMetadataValue(plugin, block));
}
return true;
}
代码示例来源:origin: elBukkit/MagicPlugin
public void watch(Entity entity)
{
if (entity == null) return;
if (worldName != null && !entity.getWorld().getName().equals(worldName)) return;
if (worldName == null) worldName = entity.getWorld().getName();
if (!entity.hasMetadata("MagicBlockList")) {
setUndoList(plugin, entity, this);
}
modifiedTime = System.currentTimeMillis();
}
代码示例来源:origin: elBukkit/MagicPlugin
@EventHandler
public void onInventoryOpen(InventoryOpenEvent event)
{
HumanEntity player = event.getPlayer();
Entity mount = player.getVehicle();
if (mount != null && mount.hasMetadata("broom")) {
event.setCancelled(true);
}
}
代码示例来源:origin: mcMMO-Dev/mcMMO
/**
* Handle EntityExplode events that involve modifying the event.
*
* @param event
* The event to modify
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityExplodeMonitor(EntityExplodeEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
Entity entity = event.getEntity();
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntsafeMetadataKey)) {
return;
}
event.blockList().clear();
}
代码示例来源:origin: elBukkit/MagicPlugin
@EventHandler(priority = EventPriority.NORMAL)
public void onEntityTarget(EntityTargetEvent event) {
// TODO: Don't use metadata!
if (event.isCancelled() || !event.getEntity().hasMetadata("docile")) {
return;
}
if (event.getReason() == EntityTargetEvent.TargetReason.CLOSEST_PLAYER) {
event.setCancelled(true);
}
}
代码示例来源:origin: elBukkit/MagicPlugin
@EventHandler
public void onHorseJump(HorseJumpEvent event)
{
Entity horse = ((EntityEvent)event).getEntity();
if (horse.hasMetadata("broom"))
{
Entity passenger = horse.getPassenger();
Mage mage = controller.getMage(passenger);
Set<Spell> active = mage.getActiveSpells();
for (Spell spell : active) {
if (spell instanceof LevitateSpell) {
LevitateSpell levitate = (LevitateSpell)spell;
double amount = Math.max(0, (event.getPower() - mountBoostMinimum) / (1 - mountBoostMinimum));
levitate.boost(amount);
}
}
}
}
代码示例来源:origin: elBukkit/MagicPlugin
@EventHandler
public void onVehicleExit(VehicleExitEvent event)
{
Entity vehicle = event.getVehicle();
if (vehicle.hasMetadata("broom"))
{
event.setCancelled(true);
Entity passenger = vehicle.getPassenger();
Mage mage = controller.getMage(passenger);
Set<Spell> active = mage.getActiveSpells();
for (Spell spell : active) {
if (spell instanceof LevitateSpell) {
LevitateSpell levitate = (LevitateSpell)spell;
levitate.forceSneak(10);
}
}
}
}
}
代码示例来源:origin: TheBusyBiscuit/Slimefun4
@Override
public void tick(Block b, SlimefunItem item, Config data) {
if (b.getType() != Material.HOPPER) {
// we're no longer a hopper, we were probably destroyed. skipping this tick.
return;
}
ArmorStand hologram = InfusedHopper.getArmorStand(b, true);
boolean sound = false;
for (Entity n: hologram.getNearbyEntities(3.5D, 3.5D, 3.5D)) {
if (n instanceof Item && !n.hasMetadata("no_pickup") && n.getLocation().distance(hologram.getLocation()) > 0.4D) {
n.setVelocity(new Vector(0, 0.1, 0));
n.teleport(hologram);
sound = true;
}
}
if (sound) b.getWorld().playSound(b.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 5F, 2F);
}
代码示例来源:origin: TheBusyBiscuit/Slimefun4
@Override
public void run() {
if (Bukkit.getPlayer(uuid) == null) Bukkit.getScheduler().cancelTask(id);
else if (Bukkit.getPlayer(uuid).isDead()) Bukkit.getScheduler().cancelTask(id);
else if (!Bukkit.getPlayer(uuid).isSneaking()) Bukkit.getScheduler().cancelTask(id);
else {
for (Entity item: Bukkit.getPlayer(uuid).getNearbyEntities(6D, 6D, 6D)) {
if (item instanceof Item) {
if (!item.hasMetadata("no_pickup") && ((Item) item).getPickupDelay() <= 0) {
item.teleport(Bukkit.getPlayer(uuid).getEyeLocation());
Bukkit.getPlayer(uuid).getWorld().playSound(Bukkit.getPlayer(uuid).getEyeLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 5L, 2L);
}
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!