public static String getDisplayName(Entity entity) { if (entity instanceof Player) { return ((Player)entity).getDisplayName(); } String customName = entity.getCustomName(); if (customName != null && !customName.isEmpty()) { return customName; } return getName(entity.getType()); }
public static boolean setBlockFast(Chunk chunk, int x, int y, int z, Material material, int data) { if (class_Block_fromLegacyData == null || class_CraftMagicNumbers_getBlockMethod == null || class_Chunk_setBlockMethod == null || class_BlockPosition_Constructor == null) { DeprecatedUtils.setTypeAndData(chunk.getWorld().getBlockAt(x, y, z), material, (byte)data, false); return true; } try { Object chunkHandle = getHandle(chunk); Object nmsBlock = class_CraftMagicNumbers_getBlockMethod.invoke(null, material); nmsBlock = class_Block_fromLegacyData.invoke(nmsBlock, data); Object blockLocation = class_BlockPosition_Constructor.newInstance(x, y, z); class_Chunk_setBlockMethod.invoke(chunkHandle, blockLocation, nmsBlock); } catch (Throwable ex) { ex.printStackTrace(); return false; } return true; }
public boolean hasBreakPermission(Player player, Block block) { if (block != null && towny != null && player != null) { if (controller.wildernessBypass && TownyUniverse.isWilderness(block)) { return true; } return PlayerCacheUtil.getCachePermission(player, block.getLocation(), DeprecatedUtils.getTypeId(block), DeprecatedUtils.getData(block), TownyPermission.ActionType.DESTROY); } return true; }
if (targetEntity == DeprecatedUtils.getPassenger(source) || source == DeprecatedUtils.getPassenger(targetEntity)) { return SpellResult.NO_TARGET; targetEntity = ((ComplexEntityPart)targetEntity).getParent(); DeprecatedUtils.setPassenger(targetEntity, source);
DeprecatedUtils.setTypeAndData(block, material, blockData, applyPhysics); skull.update(true, false); } else if (skullData.playerName != null) { DeprecatedUtils.setOwner(skull, skullData.playerName);
protected void modifyWith(Block block, MaterialAndData brush) { Material previousMaterial = block.getType(); byte previousData = DeprecatedUtils.getData(block); FallingBlock falling = DeprecatedUtils.spawnFallingBlock(block.getLocation(), previousMaterial, previousData); falling.setDropItem(false); if (fallingBlockSpeed != 0) {
@Override public SpellResult perform(CastContext context) { Collection<Material> records = context.getController() .getMaterialSetManager() .fromConfigEmpty(recordList) .getMaterials(); if (records.isEmpty()) { return SpellResult.FAIL; } Random random = context.getRandom(); Material record = Iterables.get(records, random.nextInt(records.size())); Location location = context.getTargetLocation(); location.getWorld().playEffect(location, Effect.RECORD_PLAY, DeprecatedUtils.getId(record)); return SpellResult.CAST; }
if (targetEntity == null) continue; String displayName = DeprecatedUtils.getDisplayName(targetEntity); final Integer slot = entry.getKey(); controller.getSkull(targetEntity, displayName, new ItemUpdatedCallback() {
protected Location checkForHalfBlock(Location location) { // This is a hack, but data-driving would be a pain. boolean isHalfBlock = false; Block downBlock = location.getBlock().getRelative(BlockFace.DOWN); Material material = downBlock.getType(); if (isHalfBlock(material)) { // Drop down to half-steps isHalfBlock = (DeprecatedUtils.getData(downBlock) < 8); } else { isHalfBlock = isHalfBlock(material); } if (isHalfBlock) { location.setY(location.getY() - 0.5); } return location; }
Entity passenger = DeprecatedUtils.getPassenger(entity); com.elmakers.mine.bukkit.magic.Mage mountMage = passenger == null ? null : controller.getRegisteredMage(passenger); if (mountMage != null) {
public MaterialAndData(ItemStack item) { this.material = item.getType(); this.data = item.getDurability(); if (DefaultMaterials.isPlayerSkull(this)) { ItemMeta meta = item.getItemMeta(); Object profile = InventoryUtils.getSkullProfile(meta); extraData = new BlockSkull(profile); } else if (DefaultMaterials.isBanner(this.material)) { ItemMeta meta = item.getItemMeta(); if (meta != null && meta instanceof BannerMeta) { BannerMeta banner = (BannerMeta)meta; extraData = new BlockBanner(banner.getPatterns(), DeprecatedUtils.getBaseColor(banner)); } } else if (this.material == Material.LEATHER_BOOTS || this.material == Material.LEATHER_CHESTPLATE || this.material == Material.LEATHER_HELMET || this.material == Material.LEATHER_LEGGINGS) { ItemMeta meta = item.getItemMeta(); if (meta != null && meta instanceof LeatherArmorMeta) { extraData = new LeatherArmorData(((LeatherArmorMeta)meta).getColor()); } } else if (this.material == Material.POTION) { ItemMeta meta = item.getItemMeta(); if (meta != null && meta instanceof PotionMeta) { extraData = new PotionData(CompatibilityUtils.getColor((PotionMeta)meta)); } } }
int maxLevel = path.getMaxLevel(); int levelRange = maxLevel - minLevel; int[] offered = DeprecatedUtils.getExpLevelCostsOffered(event);
player = DeprecatedUtils.getPlayer(args[0]); if (player == null) { return false;
Entity currentMount = isPassenger ? DeprecatedUtils.getPassenger(mounted) : mounted.getVehicle(); if (currentMount == null) { return SpellResult.CAST; DeprecatedUtils.setPassenger(mounted, mount); } else { DeprecatedUtils.setPassenger(mount, mounted);
case DROPPED_ITEM: Material material = Material.valueOf(configuration.getString("material").toUpperCase()); int id = DeprecatedUtils.getId(material); MiscDisguise itemDisguise = new MiscDisguise(disguiseType, id, configuration.getInt("data")); disguise = itemDisguise;
String itemName = DeprecatedUtils.getDisplayName(li) + " Head"; EntityType replaceType = null;
public boolean createField(Location location, Player player) { ForceFieldManager manager = preciousStones.getForceFieldManager(); Block targetBlock = location.getBlock(); BlockPlaceEvent event = new BlockPlaceEvent(targetBlock, targetBlock.getState(), targetBlock.getRelative(BlockFace.DOWN), new ItemStack(targetBlock.getType(), DeprecatedUtils.getData(targetBlock)), player, true, EquipmentSlot.HAND); manager.add(location.getBlock(), player, event); return !event.isCancelled(); }