@Override public void setMetadata(String arg0, MetadataValue arg1) { base.setMetadata(arg0, arg1); }
public void setMetadata(String arg0, MetadataValue arg1) { entity.setMetadata(arg0, arg1); }
public static void track(Plugin plugin, Entity tracked) { tracked.setMetadata("tracking", new FixedMetadataValue(plugin, true)); }
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; }
public static void setUndoList(Plugin plugin, Entity entity, com.elmakers.mine.bukkit.api.block.UndoList list) { if (entity != null) { if (list != null) { entity.setMetadata("MagicBlockList", new FixedMetadataValue(plugin, list)); } else { entity.removeMetadata("MagicBlockList", plugin); } } }
@Override public void add(Entity entity) { if (entity == null) return; if (entities == null) entities = new HashSet<>(); if (worldName != null && !entity.getWorld().getName().equals(worldName)) return; entities.add(entity); if (this.isScheduled()) { entity.setMetadata("temporary", new FixedMetadataValue(plugin, true)); } watch(entity); contain(entity.getLocation().toVector()); modifiedTime = System.currentTimeMillis(); }
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onFallingBlockEnterPortal(EntityPortalEnterEvent event) { if (event.getEntityType() != EntityType.FALLING_BLOCK) return; event.getEntity().setMetadata("GP_FELLTHROUGHPORTAL", new FixedMetadataValue(GriefPrevention.instance, true)); }
@EventHandler public void onBowShoot(EntityShootBowEvent e) { e.getProjectile().setMetadata("rpgitems.force", new FixedMetadataValue(plugin, e.getForce())); }
@Nullable @Override public Entity undo() { Entity entity = this.getEntity(); // Re-spawn if dead or missing if (respawn && !isTemporary && uuid != null && (entity == null || !entity.isValid() || entity.isDead()) && !(entity instanceof Player)) { // Avoid re-re-spawning an entity WeakReference<Entity> respawnedEntity = respawned.get(uuid); if (respawnedEntity != null) { entity = respawnedEntity.get(); } else { entity = trySpawn(null, null); if (entity != null) { respawned.put(uuid, new WeakReference<>(entity)); // Undo'ing an entity won't drop loot entity.setMetadata("nodrops", new FixedMetadataValue(MagicPlugin.getAPI().getPlugin(), true)); } } setEntity(entity); } else if (entity != null) { modify(entity); } return entity; }
@Override public void set(String key, Object data) { super.set(key, data); if (getEntity() != null) { getEntity().setMetadata(key, new FixedMetadataValue(CitizensAPI.getPlugin(), data)); } }
@Override public void setPersistent(String key, Object data) { super.setPersistent(key, data); if (getEntity() != null) { getEntity().setMetadata(key, new FixedMetadataValue(CitizensAPI.getPlugin(), data)); } } };
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onEntityShootBow(EntityShootBowEvent event) { /* WORLD BLACKLIST CHECK */ if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) return; if(event.getEntity() instanceof Player) { Player player = (Player) event.getEntity(); /* WORLD GUARD MAIN FLAG CHECK */ if(WorldGuardUtils.isWorldGuardLoaded()) { if(!WorldGuardManager.getInstance().hasMainFlag(player)) return; } } Entity projectile = event.getProjectile(); if (!(projectile instanceof Arrow)) { return; } ItemStack bow = event.getBow(); if (bow != null && bow.containsEnchantment(Enchantment.ARROW_INFINITE)) { projectile.setMetadata(mcMMO.infiniteArrowKey, mcMMO.metadataValue); } projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(plugin, Math.min(event.getForce() * AdvancedConfig.getInstance().getForceMultiplier(), 1.0))); projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, projectile.getLocation())); }
mount.setMetadata("notarget", new FixedMetadataValue(context.getController().getPlugin(), true)); entity.setMetadata("notarget", new FixedMetadataValue(context.getController().getPlugin(), true));
/** * Monitor CreatureSpawn events. * * @param event * The event to watch */ @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onCreatureSpawn(CreatureSpawnEvent event) { /* WORLD BLACKLIST CHECK */ if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) return; LivingEntity entity = event.getEntity(); switch (event.getSpawnReason()) { case NETHER_PORTAL: case SPAWNER: case SPAWNER_EGG: entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); Entity passenger = entity.getPassenger(); if (passenger != null) { passenger.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); } return; case BREEDING: entity.setMetadata(mcMMO.bredMetadataKey, mcMMO.metadataValue); return; default: return; } }
/** * Monitor falling blocks. * * @param event The event to watch */ @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onFallingBlock(EntityChangeBlockEvent event) { /* WORLD BLACKLIST CHECK */ if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) return; if (BlockUtils.shouldBeWatched(event.getBlock().getState()) && event.getEntityType().equals(EntityType.FALLING_BLOCK)) { if (event.getTo().equals(Material.AIR) && mcMMO.getPlaceStore().isTrue(event.getBlock())) { event.getEntity().setMetadata("mcMMOBlockFall", new FixedMetadataValue( plugin, event.getBlock().getLocation())); } else { List<MetadataValue> values = event.getEntity().getMetadata( "mcMMOBlockFall" ); if (!values.isEmpty()) { if (values.get(0).value() == null) return; Block spawn = ((org.bukkit.Location) values.get(0).value()).getBlock(); mcMMO.getPlaceStore().setTrue( event.getBlock() ); mcMMO.getPlaceStore().setFalse( spawn ); } } } }
if (e != player) { if (e instanceof ItemFrame || e instanceof Painting) { e.setMetadata("RPGItems.Rumble", new FixedMetadataValue(RPGItems.plugin, null)); // Add metadata to protect hanging entities from the explosion continue;
itemFrameUUIDs[x1][y1] = entity.getUniqueId(); entity.setMetadata("ANIMATED_FRAMES_META", new FixedMetadataValue(plugin, AnimatedFrame.this));
entity.setMetadata("betonquest-drops-" + j, new FixedMetadataValue(BetonQuest.getInstance(), item.getID().getFullID() + ":" + item.getAmount().getInt(playerID))); entity.setMetadata("betonquest-marked", new FixedMetadataValue(BetonQuest.getInstance(), marked));
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) private void physicalBlock(EntityChangeBlockEvent event) { if(hasRegenArea() && blockInRegenArea(event.getBlock().getLocation())) { if(minigame.isRegenerating()){ event.setCancelled(true); return; } if(event.getTo() == Material.SAND || event.getTo() == Material.GRAVEL || event.getTo() == Material.DRAGON_EGG || event.getTo() == Material.ANVIL) { if(minigame.hasPlayers() || event.getEntity().hasMetadata("FellInMinigame")) { addEntity(event.getEntity(), null, true); } } else if(event.getEntityType() == EntityType.FALLING_BLOCK && minigame.hasPlayers()) { event.getEntity().setMetadata("FellInMinigame", new FixedMetadataValue(Minigames.getPlugin(), true)); addEntity(event.getEntity(), null, true); } } }
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);