diff --git a/pom.xml b/pom.xml index a99d290a..c28729fb 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ org.spigotmc spigot-api - 1.15.2-R0.1-SNAPSHOT + 1.16.1-R0.1-SNAPSHOT provided diff --git a/src/main/java/com/gamingmesh/jobs/nmsUtil/v1_16.java b/src/main/java/com/gamingmesh/jobs/nmsUtil/v1_16.java new file mode 100644 index 00000000..c6593e08 --- /dev/null +++ b/src/main/java/com/gamingmesh/jobs/nmsUtil/v1_16.java @@ -0,0 +1,59 @@ +package com.gamingmesh.jobs.nmsUtil; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.OfflinePlayer; +import org.bukkit.attribute.Attribute; +import org.bukkit.block.Block; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockPistonRetractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.Damageable; +import org.bukkit.inventory.meta.SkullMeta; + +import com.gamingmesh.jobs.NMS; + +public class v1_16 implements NMS { + + @Override + public List getPistonRetractBlocks(BlockPistonRetractEvent event) { + List blocks = new ArrayList<>(); + blocks.addAll(event.getBlocks()); + return blocks; + } + + @Override + public String getRealType(Entity entity) { + return entity.getType().name(); + } + + @Override + public ItemStack getItemInMainHand(Player player) { + return player.getInventory().getItemInMainHand(); + } + + @Override + public void setItemInMainHand(Player player, ItemStack item) { + player.getInventory().setItemInMainHand(item); + } + + @Override + public double getMaxHealth(LivingEntity entity) { + return entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue(); + } + + @Override + public short getDurability(ItemStack item) { + return (short) ((Damageable) item.getItemMeta()).getDamage(); + } + + @Override + public void setSkullOwner(SkullMeta meta, OfflinePlayer player) { + if (meta != null && player != null) { + meta.setOwningPlayer(player); + } + } +}