public static void applyPotionEffects(LivingEntity entity, Collection<PotionEffect> effects) { for (PotionEffect effect: effects) { applyPotionEffect(entity, effect); } }
public static boolean checkChunk(Chunk chunk) { return checkChunk(chunk, true, true); }
public static ArmorStand createArmorStand(Location location) { return (ArmorStand)createEntity(location, EntityType.ARMOR_STAND); }
@SuppressWarnings("deprecation") public static Material getMaterial(int id, byte data) { Material material = getMaterial(id); if (class_UnsafeValues_fromLegacyDataMethod != null) { if (material != null) { material = fromLegacy(new org.bukkit.material.MaterialData(material, data)); } } if (material == null) { material = Material.AIR; } return material; }
public static boolean removeItemAttribute(ItemStack item, Attribute attribute) { try { Object handle = getHandle(item); if (handle == null) return false; Object tag = getTag(handle); if (tag == null) return false; String attributeName = toMinecraftAttribute(attribute); Object attributesNode = getNode(tag, "AttributeModifiers"); if (attributesNode == null) { return false; } int size = (Integer)class_NBTTagList_sizeMethod.invoke(attributesNode); for (int i = 0; i < size; i++) { Object candidate = class_NBTTagList_getMethod.invoke(attributesNode, i); String key = getMetaString(candidate, "AttributeName"); if (key.equals(attributeName)) { if (size == 1) { removeMeta(tag, "AttributeModifiers"); } else { class_NBTTagList_removeMethod.invoke(attributesNode, i); } return true; } } } catch (Exception ex) { ex.printStackTrace(); return false; } return true; }
public static boolean setItemAttribute(ItemStack item, Attribute attribute, double value, String slot, int attributeOperation) { try { Object handle = getHandle(item); if (handle == null) { return false; Object tag = getTag(handle); if (tag == null) return false; Object attributesNode = getNode(tag, "AttributeModifiers"); Object attributeNode = null; UUID attributeUUID = UUID.randomUUID(); String attributeName = toMinecraftAttribute(attribute); if (attributesNode == null) { attributesNode = class_NBTTagList_constructor.newInstance(); for (int i = 0; i < size; i++) { Object candidate = class_NBTTagList_getMethod.invoke(attributesNode, i); String key = getMetaString(candidate, "AttributeName"); if (key.equals(attributeName)) { attributeNode = candidate; setMeta(attributeNode, "AttributeName", attributeName); setMeta(attributeNode, "Name", "Equipment Modifier"); setMetaInt(attributeNode, "Operation", attributeOperation); setMetaLong(attributeNode, "UUIDMost", attributeUUID.getMostSignificantBits()); setMetaLong(attributeNode, "UUIDLeast", attributeUUID.getLeastSignificantBits()); if (slot != null) { setMeta(attributeNode, "Slot", slot);
ItemStack newItem = CompatibilityUtils.makeReal(item); Object node = InventoryUtils.getTag(item); if (args.length == 1) { int i = 0; while (node != null && i < path.length - 1) { node = CompatibilityUtils.getNode(node, path[i]); i++; return true; if (!CompatibilityUtils.containsNode(node, path[path.length - 1])) { player.sendMessage(ChatColor.RED + "Item does not have tag: " + ChatColor.DARK_RED + tag); return true; CompatibilityUtils.removeMeta(node, path[path.length - 1]); item.setItemMeta(newItem.getItemMeta()); player.sendMessage(ChatColor.GREEN + "Removed: " + ChatColor.DARK_GREEN + tag);
switch (type) { case PAINTING: spawned = CompatibilityUtils.createPainting(location, facing, art); break; case ITEM_FRAME: spawned = CompatibilityUtils.createItemFrame(location, facing, rotation, item); break; case DROPPED_ITEM: break; default: spawned = CompatibilityUtils.createEntity(location, type); isSpawning = true; reason = reason == null ? CreatureSpawnEvent.SpawnReason.CUSTOM : reason; CompatibilityUtils.addToWorld(location.getWorld(), spawned, reason); isSpawning = false;
} else { if (percentage != null) { damage = percentage * CompatibilityUtils.getMaxHealth(targetEntity); } else if (targetEntity instanceof Player) { damage = playerDamage; CompatibilityUtils.magicDamage(targetEntity, damage, mage.getEntity()); } else { CompatibilityUtils.damage(targetEntity, damage, mage.getEntity(), damageType); CompatibilityUtils.magicDamage(targetEntity, damage, mage.getEntity()); } else { mage.sendDebugMessage(ChatColor.RED + "Damaging x " + ChatColor.DARK_RED + mageMultiplier + ChatColor.RED + " to " + ChatColor.BLUE + targetEntity.getType() + ": " + damage, 5); CompatibilityUtils.damage(targetEntity, damage, mage.getEntity());
public static ItemFrame createItemFrame(Location location, BlockFace facing, Rotation rotation, ItemStack item) { ItemFrame newItemFrame = null; try { Object worldHandle = getHandle(location.getWorld()); Object newEntity = null; @SuppressWarnings("unchecked") Enum<?> directionEnum = Enum.valueOf(class_EnumDirection, facing.name()); Object blockLocation = class_BlockPosition_Constructor.newInstance(location.getX(), location.getY(), location.getZ()); newEntity = class_EntityItemFrameConstructor.newInstance(worldHandle, blockLocation, directionEnum); if (newEntity != null) { Entity bukkitEntity = getBukkitEntity(newEntity); if (bukkitEntity == null || !(bukkitEntity instanceof ItemFrame)) return null; newItemFrame = (ItemFrame)bukkitEntity; newItemFrame.setItem(getCopy(item)); newItemFrame.setFacingDirection(facing, true); newItemFrame.setRotation(rotation); } } catch (Throwable ex) { ex.printStackTrace(); } return newItemFrame; }
public static Entity getEntity(UUID uuid) { if (class_Server_getEntityMethod != null) { try { return (Entity)class_Server_getEntityMethod.invoke(Bukkit.getServer(), uuid); } catch (Exception ex) { ex.printStackTrace(); } } for (World world : Bukkit.getWorlds()) { Entity found = getEntity(world, uuid); if (found != null) { return found; } } return null; }
material = CompatibilityUtils.getMaterial(id); } catch (Exception ex) { materialKey = materialKey.toUpperCase(); material = Material.getMaterial(materialKey); if (material == null) { material = CompatibilityUtils.getLegacyMaterial(materialKey);
Material legacyMaterial = getLegacyMaterial(materialName); if (legacyMaterial != null) { org.bukkit.material.MaterialData materialData = new org.bukkit.material.MaterialData(legacyMaterial, data); legacyMaterial = fromLegacy(materialData); if (legacyMaterial != null) { material = legacyMaterial;
damage(target, amount, source); return; damage(target, amount, source); return; Object targetHandle = getHandle(target); if (targetHandle == null) return; Object sourceHandle = getHandle(source); Object potionHandle = getHandle(potion); Object damageSource = class_DamageSource_getMagicSourceMethod.invoke(null, potionHandle, sourceHandle);
double damage = maxSpeed > 0 ? crashDamage * speed / maxSpeed : crashDamage; if (mountedEntity.isValid() && mountedEntity instanceof Damageable) { CompatibilityUtils.damage((Damageable)mountedEntity, damage, mount); double damage = maxSpeed > 0 ? crashVehicleDamage * speed / maxSpeed : crashVehicleDamage; if (mount != null && mount.isValid() && mount instanceof Damageable) { CompatibilityUtils.damage((Damageable)mount, damage, mountedEntity); CompatibilityUtils.applyPotionEffects((LivingEntity)mountedEntity, crashEffects);
int index = x + (y * length + z) * width; Material material = CompatibilityUtils.getMaterial(blockTypes[index], data[index]); if (material != null) String blockData = CompatibilityUtils.getBlockData(material, data[index]); if (blockData != null) { block = new MaterialAndData(material, blockData);
return workPerformed + 20; if (!CompatibilityUtils.isReady(chunk)) { return workPerformed + 5; CompatibilityUtils.applyPhysics(block); return workPerformed + 20; if (!CompatibilityUtils.isReady(chunk)) { return workPerformed + 5;
if (checkChunk && !CompatibilityUtils.checkChunk(block.getChunk())) { return SpellResult.PENDING; CompatibilityUtils.setFallingBlockDamage(falling, fallingBlockFallDamage, fallingBlockMaxDamage); } else { falling.setHurtEntities(fallingBlocksHurt);
@Override public ItemStack getItemStack() { ItemStack item = CompatibilityUtils.getCopy(this.item); if (item != null) { item.setAmount((int)Math.max(1, Math.ceil(amount))); } return item; }
public void setMaterialId(int id) { this.material = CompatibilityUtils.getMaterial(id); }