@Override public MCMetadataValue GetMetadataValue(Object value, MCPlugin plugin) { return new BukkitMCMetadataValue(new FixedMetadataValue(((BukkitMCPlugin) plugin).getHandle(), value)); }
public static void track(Plugin plugin, Entity tracked) { tracked.setMetadata("tracking", new FixedMetadataValue(plugin, true)); }
private void setPlanter(Metadatable tnt, Player planter) { tnt.setMetadata("mobarena-planter", new FixedMetadataValue(plugin, planter)); }
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; }
/** * Track a new user. * * @param mcMMOPlayer the player profile to start tracking */ public static void track(McMMOPlayer mcMMOPlayer) { mcMMOPlayer.getPlayer().setMetadata(mcMMO.playerDataKey, new FixedMetadataValue(mcMMO.p, mcMMOPlayer)); }
/** * Add some metadata to a target. * * @param target the target * @param key the key * @param value the value */ public static void put(Metadatable target, String key, Object value) { target.setMetadata(key, new FixedMetadataValue(WorldGuardPlugin.inst(), value)); }
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); } } }
/** * Enable god mode for a player. * * @param player The player to enable godmode for */ public void enableGodMode(Player player) { if (!hasGodMode(player)) { player.setMetadata(METADATA_KEY, new FixedMetadataValue(CommandBook.inst(), true)); } }
public TempArmorStand(final Location loc) { this.stand = loc.getWorld().spawn(loc, ArmorStand.class); this.stand.setMetadata("temparmorstand", new FixedMetadataValue(ProjectKorra.plugin, 0)); }
@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())); }
public static boolean canBlockBeBroken(Block block, Player breaker) { List<Sign> attachedSigns = getAttachedSigns(block); List<Sign> brokenBlocks = new LinkedList<Sign>(); boolean canBeBroken = true; for (Sign sign : attachedSigns) { if (!canBeBroken || !ChestShopSign.isValid(sign)) { continue; } if (Properties.TURN_OFF_SIGN_PROTECTION || canDestroyShop(breaker, sign.getLine(NAME_LINE))) { brokenBlocks.add(sign); } else { canBeBroken = false; } } if (!canBeBroken) { return false; } for (Sign sign : brokenBlocks) { sign.setMetadata(METADATA_NAME, new FixedMetadataValue(ChestShop.getPlugin(), breaker)); } return true; }
@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; }
this.entity.setMetadata("movement:stop", new FixedMetadataValue(ProjectKorra.plugin, this.ability)); if (this.entity instanceof Player) { final Player player = (Player) this.entity;
playerMetadata = new FixedMetadataValue(mcMMO.p, playerName); this.profile = profile;
@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)); } } };
@Override public SpellResult perform(CastContext context) { Player player = context.getMage().getPlayer(); if (player == null) { return SpellResult.PLAYER_REQUIRED; } List<MetadataValue> meta = player .getMetadata(INITIAL_MOVEMENT_SPEED_META); final SpeedDataStack stack; if (meta.isEmpty()) { stack = new SpeedDataStack(); stack.initialSpeed = player.getWalkSpeed(); player.setMetadata(INITIAL_MOVEMENT_SPEED_META, new FixedMetadataValue(context.getPlugin(), stack)); } else { stack = (SpeedDataStack) meta.get(0).value(); } stack.map.put(this, speed); player.setWalkSpeed(speed); return SpellResult.CAST; }
@SuppressWarnings("unchecked") public static void addDamageToEntity(LivingEntity damager, LivingEntity victim, double damage) { Map<UUID, Double> damageMap; if (victim.hasMetadata("DamageCount")) { for (MetadataValue value : victim.getMetadata("DamageCount")) { if (value.getOwningPlugin().getName().equals("MyPet")) { damageMap = (Map<UUID, Double>) value.value(); if (damageMap.containsKey(damager)) { double oldDamage = damageMap.get(damager); damageMap.put(damager.getUniqueId(), victim.getHealth() < damage ? victim.getHealth() + oldDamage : damage + oldDamage); } else { damageMap.put(damager.getUniqueId(), victim.getHealth() < damage ? victim.getHealth() : damage); } break; } } } else { damageMap = new WeakHashMap<>(); damageMap.put(damager.getUniqueId(), victim.getHealth() < damage ? victim.getHealth() : damage); victim.setMetadata("DamageCount", new FixedMetadataValue(MyPetApi.getPlugin(), damageMap)); } }