feat: re-implement ItemUtils#applyRandomEnchants in NMS submodules

With this the implementation is more stable between version
and easier to maintain.
This commit is contained in:
Christian Koop 2024-09-06 10:48:43 +02:00
parent 265e5864c9
commit 488490de18
No known key found for this signature in database
GPG Key ID: 6A4A09E8ED946113
57 changed files with 735 additions and 11 deletions

View File

@ -1,6 +1,6 @@
package com.craftaro.core.lootables.loot;
import com.craftaro.core.utils.ItemUtils;
import com.craftaro.core.nms.Nms;
import com.craftaro.core.utils.TextUtils;
import com.cryptomorin.xseries.XMaterial;
import com.google.gson.annotations.SerializedName;
@ -151,18 +151,17 @@ public class Loot {
return null;
}
// Create enchantment book
if (item.getType() == Material.ENCHANTED_BOOK) {
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item.getItemMeta();
for (Map.Entry<String, Integer> entry : this.enchants.entrySet()) {
if (entry.getValue() == null) continue;
if (entry.getValue() == null) {
continue;
}
//TODO add random enchants
// if (entry.getKey().equalsIgnoreCase("RANDOM")) {
// item = ItemUtils.applyRandomEnchants(item, entry.getValue());
//
// continue;
// }
if (entry.getKey().equalsIgnoreCase("RANDOM")) {
item = Nms.getImplementations().getItem().copyAndApplyRandomEnchantment(item, entry.getValue());
continue;
}
meta.addStoredEnchant(Enchantment.getByName(entry.getKey()), entry.getValue(), true);
}
@ -177,8 +176,7 @@ public class Loot {
}
if (entry.getKey().equalsIgnoreCase("RANDOM")) {
item = ItemUtils.applyRandomEnchants(item, entry.getValue());
item = Nms.getImplementations().getItem().copyAndApplyRandomEnchantment(item, entry.getValue());
continue;
}

View File

@ -3,6 +3,7 @@ package com.craftaro.core.nms;
import com.craftaro.core.nms.anvil.AnvilCore;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.world.NmsWorldBorder;
import com.craftaro.core.nms.world.WorldCore;
@ -20,4 +21,6 @@ public interface NmsImplementations {
@NotNull AnvilCore getAnvil();
@NotNull NBTCore getNbt();
@NotNull NmsItem getItem();
}

View File

@ -0,0 +1,7 @@
package com.craftaro.core.nms.item;
import org.bukkit.inventory.ItemStack;
public interface NmsItem {
ItemStack copyAndApplyRandomEnchantment(ItemStack item, int level);
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_10_R1;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_10_R1.anvil.AnvilCore;
import com.craftaro.core.nms.v1_10_R1.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_10_R1.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_10_R1.item.NmsItemImpl;
import com.craftaro.core.nms.v1_10_R1.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_10_R1.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_10_R1.world.WorldCoreImpl;
@ -22,6 +24,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -30,6 +33,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -61,4 +65,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,17 @@
package com.craftaro.core.nms.v1_10_R1.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.server.v1_10_R1.EnchantmentManager;
import net.minecraft.server.v1_10_R1.ItemStack;
import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack;
import java.util.concurrent.ThreadLocalRandom;
public class NmsItemImpl implements NmsItem {
@Override
public org.bukkit.inventory.ItemStack copyAndApplyRandomEnchantment(org.bukkit.inventory.ItemStack item, int level) {
ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentManager.a(ThreadLocalRandom.current(), nmsItem, level, false);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_11_R1;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_11_R1.anvil.AnvilCore;
import com.craftaro.core.nms.v1_11_R1.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_11_R1.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_11_R1.item.NmsItemImpl;
import com.craftaro.core.nms.v1_11_R1.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_11_R1.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_11_R1.world.WorldCoreImpl;
@ -22,6 +24,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -30,6 +33,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -61,4 +65,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,17 @@
package com.craftaro.core.nms.v1_11_R1.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.server.v1_11_R1.EnchantmentManager;
import net.minecraft.server.v1_11_R1.ItemStack;
import org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemStack;
import java.util.concurrent.ThreadLocalRandom;
public class NmsItemImpl implements NmsItem {
@Override
public org.bukkit.inventory.ItemStack copyAndApplyRandomEnchantment(org.bukkit.inventory.ItemStack item, int level) {
ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentManager.a(ThreadLocalRandom.current(), nmsItem, level, false);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_12_R1;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_12_R1.anvil.AnvilCore;
import com.craftaro.core.nms.v1_12_R1.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_12_R1.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_12_R1.item.NmsItemImpl;
import com.craftaro.core.nms.v1_12_R1.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_12_R1.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_12_R1.world.WorldCoreImpl;
@ -22,6 +24,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -30,6 +33,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -61,4 +65,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,17 @@
package com.craftaro.core.nms.v1_12_R1.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.server.v1_12_R1.EnchantmentManager;
import net.minecraft.server.v1_12_R1.ItemStack;
import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack;
import java.util.concurrent.ThreadLocalRandom;
public class NmsItemImpl implements NmsItem {
@Override
public org.bukkit.inventory.ItemStack copyAndApplyRandomEnchantment(org.bukkit.inventory.ItemStack item, int level) {
ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentManager.a(ThreadLocalRandom.current(), nmsItem, level, false);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_13_R1;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_13_R1.anvil.AnvilCore;
import com.craftaro.core.nms.v1_13_R1.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_13_R1.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_13_R1.item.NmsItemImpl;
import com.craftaro.core.nms.v1_13_R1.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_13_R1.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_13_R1.world.WorldCoreImpl;
@ -22,6 +24,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -30,6 +33,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -61,4 +65,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,17 @@
package com.craftaro.core.nms.v1_13_R1.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.server.v1_13_R1.EnchantmentManager;
import net.minecraft.server.v1_13_R1.ItemStack;
import org.bukkit.craftbukkit.v1_13_R1.inventory.CraftItemStack;
import java.util.concurrent.ThreadLocalRandom;
public class NmsItemImpl implements NmsItem {
@Override
public org.bukkit.inventory.ItemStack copyAndApplyRandomEnchantment(org.bukkit.inventory.ItemStack item, int level) {
ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentManager.a(ThreadLocalRandom.current(), nmsItem, level, false);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_13_R2;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_13_R2.anvil.AnvilCore;
import com.craftaro.core.nms.v1_13_R2.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_13_R2.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_13_R2.item.NmsItemImpl;
import com.craftaro.core.nms.v1_13_R2.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_13_R2.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_13_R2.world.WorldCoreImpl;
@ -22,6 +24,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -30,6 +33,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -61,4 +65,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,17 @@
package com.craftaro.core.nms.v1_13_R2.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.server.v1_13_R2.EnchantmentManager;
import net.minecraft.server.v1_13_R2.ItemStack;
import org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack;
import java.util.concurrent.ThreadLocalRandom;
public class NmsItemImpl implements NmsItem {
@Override
public org.bukkit.inventory.ItemStack copyAndApplyRandomEnchantment(org.bukkit.inventory.ItemStack item, int level) {
ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentManager.a(ThreadLocalRandom.current(), nmsItem, level, false);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_14_R1;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_14_R1.anvil.AnvilCore;
import com.craftaro.core.nms.v1_14_R1.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_14_R1.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_14_R1.item.NmsItemImpl;
import com.craftaro.core.nms.v1_14_R1.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_14_R1.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_14_R1.world.WorldCoreImpl;
@ -22,6 +24,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -30,6 +33,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -61,4 +65,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,17 @@
package com.craftaro.core.nms.v1_14_R1.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.server.v1_14_R1.EnchantmentManager;
import net.minecraft.server.v1_14_R1.ItemStack;
import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack;
import java.util.concurrent.ThreadLocalRandom;
public class NmsItemImpl implements NmsItem {
@Override
public org.bukkit.inventory.ItemStack copyAndApplyRandomEnchantment(org.bukkit.inventory.ItemStack item, int level) {
ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentManager.a(ThreadLocalRandom.current(), nmsItem, level, false);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_15_R1;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_15_R1.anvil.AnvilCore;
import com.craftaro.core.nms.v1_15_R1.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_15_R1.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_15_R1.item.NmsItemImpl;
import com.craftaro.core.nms.v1_15_R1.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_15_R1.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_15_R1.world.WorldCoreImpl;
@ -22,6 +24,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -30,6 +33,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -61,4 +65,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,17 @@
package com.craftaro.core.nms.v1_15_R1.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.server.v1_15_R1.EnchantmentManager;
import net.minecraft.server.v1_15_R1.ItemStack;
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
import java.util.concurrent.ThreadLocalRandom;
public class NmsItemImpl implements NmsItem {
@Override
public org.bukkit.inventory.ItemStack copyAndApplyRandomEnchantment(org.bukkit.inventory.ItemStack item, int level) {
ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentManager.a(ThreadLocalRandom.current(), nmsItem, level, false);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_16_R1;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_16_R1.anvil.AnvilCore;
import com.craftaro.core.nms.v1_16_R1.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_16_R1.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_16_R1.item.NmsItemImpl;
import com.craftaro.core.nms.v1_16_R1.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_16_R1.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_16_R1.world.WorldCoreImpl;
@ -22,6 +24,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -30,6 +33,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -61,4 +65,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,17 @@
package com.craftaro.core.nms.v1_16_R1.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.server.v1_16_R1.EnchantmentManager;
import net.minecraft.server.v1_16_R1.ItemStack;
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack;
import java.util.concurrent.ThreadLocalRandom;
public class NmsItemImpl implements NmsItem {
@Override
public org.bukkit.inventory.ItemStack copyAndApplyRandomEnchantment(org.bukkit.inventory.ItemStack item, int level) {
ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentManager.a(ThreadLocalRandom.current(), nmsItem, level, false);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_16_R2;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_16_R2.anvil.AnvilCore;
import com.craftaro.core.nms.v1_16_R2.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_16_R2.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_16_R2.item.NmsItemImpl;
import com.craftaro.core.nms.v1_16_R2.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_16_R2.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_16_R2.world.WorldCoreImpl;
@ -22,6 +24,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -30,6 +33,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -61,4 +65,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,17 @@
package com.craftaro.core.nms.v1_16_R2.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.server.v1_16_R2.EnchantmentManager;
import net.minecraft.server.v1_16_R2.ItemStack;
import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack;
import java.util.concurrent.ThreadLocalRandom;
public class NmsItemImpl implements NmsItem {
@Override
public org.bukkit.inventory.ItemStack copyAndApplyRandomEnchantment(org.bukkit.inventory.ItemStack item, int level) {
ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentManager.a(ThreadLocalRandom.current(), nmsItem, level, false);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_16_R3;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_16_R3.anvil.AnvilCore;
import com.craftaro.core.nms.v1_16_R3.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_16_R3.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_16_R3.item.NmsItemImpl;
import com.craftaro.core.nms.v1_16_R3.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_16_R3.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_16_R3.world.WorldCoreImpl;
@ -22,6 +24,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -30,6 +33,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -61,4 +65,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,17 @@
package com.craftaro.core.nms.v1_16_R3.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.server.v1_16_R3.EnchantmentManager;
import net.minecraft.server.v1_16_R3.ItemStack;
import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack;
import java.util.concurrent.ThreadLocalRandom;
public class NmsItemImpl implements NmsItem {
@Override
public org.bukkit.inventory.ItemStack copyAndApplyRandomEnchantment(org.bukkit.inventory.ItemStack item, int level) {
ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentManager.a(ThreadLocalRandom.current(), nmsItem, level, false);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_17_R1;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_17_R1.anvil.AnvilCore;
import com.craftaro.core.nms.v1_17_R1.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_17_R1.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_17_R1.item.NmsItemImpl;
import com.craftaro.core.nms.v1_17_R1.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_17_R1.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_17_R1.world.WorldCoreImpl;
@ -22,6 +24,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -30,6 +33,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -61,4 +65,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,17 @@
package com.craftaro.core.nms.v1_17_R1.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.world.item.enchantment.EnchantmentManager;
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import java.util.concurrent.ThreadLocalRandom;
public class NmsItemImpl implements NmsItem {
@Override
public ItemStack copyAndApplyRandomEnchantment(ItemStack item, int level) {
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentManager.a(ThreadLocalRandom.current(), nmsItem, level, false);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_18_R1;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_18_R1.anvil.AnvilCore;
import com.craftaro.core.nms.v1_18_R1.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_18_R1.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_18_R1.item.NmsItemImpl;
import com.craftaro.core.nms.v1_18_R1.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_18_R1.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_18_R1.world.WorldCoreImpl;
@ -22,6 +24,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -30,6 +33,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -61,4 +65,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,17 @@
package com.craftaro.core.nms.v1_18_R1.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import java.util.concurrent.ThreadLocalRandom;
public class NmsItemImpl implements NmsItem {
@Override
public ItemStack copyAndApplyRandomEnchantment(ItemStack item, int level) {
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentHelper.enchantItem(ThreadLocalRandom.current(), nmsItem, level, false);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_18_R2;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_18_R2.anvil.AnvilCore;
import com.craftaro.core.nms.v1_18_R2.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_18_R2.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_18_R2.item.NmsItemImpl;
import com.craftaro.core.nms.v1_18_R2.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_18_R2.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_18_R2.world.WorldCoreImpl;
@ -22,6 +24,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -30,6 +33,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -61,4 +65,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,17 @@
package com.craftaro.core.nms.v1_18_R2.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import java.util.concurrent.ThreadLocalRandom;
public class NmsItemImpl implements NmsItem {
@Override
public ItemStack copyAndApplyRandomEnchantment(ItemStack item, int level) {
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentHelper.enchantItem(ThreadLocalRandom.current(), nmsItem, level, false);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_19_0;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_19_0.anvil.AnvilCore;
import com.craftaro.core.nms.v1_19_0.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_19_0.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_19_0.item.NmsItemImpl;
import com.craftaro.core.nms.v1_19_0.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_19_0.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_19_0.world.WorldCoreImpl;
@ -22,6 +24,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -30,6 +33,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -61,4 +65,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,18 @@
package com.craftaro.core.nms.v1_19_0.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
public class NmsItemImpl implements NmsItem {
private final RandomSource randomSource = RandomSource.createNewThreadLocalInstance();
@Override
public ItemStack copyAndApplyRandomEnchantment(ItemStack item, int level) {
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentHelper.enchantItem(this.randomSource, nmsItem, level, false);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_19_R1;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_19_R1.anvil.AnvilCore;
import com.craftaro.core.nms.v1_19_R1.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_19_R1.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_19_R1.item.NmsItemImpl;
import com.craftaro.core.nms.v1_19_R1.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_19_R1.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_19_R1.world.WorldCoreImpl;
@ -23,6 +25,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
if (((CraftMagicNumbers) CraftMagicNumbers.INSTANCE).getMappingsVersion().equals("7b9de0da1357e5b251eddde9aa762916")) {
@ -34,6 +37,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = nmsMc1_19_0.getWorldBorder();
this.anvil = nmsMc1_19_0.getAnvil();
this.nbt = nmsMc1_19_0.getNbt();
this.item = nmsMc1_19_0.getItem();
return;
}
@ -44,6 +48,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -75,4 +80,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,18 @@
package com.craftaro.core.nms.v1_19_R1.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
public class NmsItemImpl implements NmsItem {
private final RandomSource randomSource = RandomSource.createNewThreadLocalInstance();
@Override
public ItemStack copyAndApplyRandomEnchantment(ItemStack item, int level) {
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentHelper.enchantItem(this.randomSource, nmsItem, level, false);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_19_R2;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_19_R2.anvil.AnvilCore;
import com.craftaro.core.nms.v1_19_R2.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_19_R2.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_19_R2.item.NmsItemImpl;
import com.craftaro.core.nms.v1_19_R2.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_19_R2.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_19_R2.world.WorldCoreImpl;
@ -21,6 +23,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -29,6 +32,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -60,4 +64,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,18 @@
package com.craftaro.core.nms.v1_19_R2.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
public class NmsItemImpl implements NmsItem {
private final RandomSource randomSource = RandomSource.createNewThreadLocalInstance();
@Override
public ItemStack copyAndApplyRandomEnchantment(ItemStack item, int level) {
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentHelper.enchantItem(this.randomSource, nmsItem, level, false);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_19_R3;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_19_R3.anvil.AnvilCore;
import com.craftaro.core.nms.v1_19_R3.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_19_R3.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_19_R3.item.NmsItemImpl;
import com.craftaro.core.nms.v1_19_R3.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_19_R3.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_19_R3.world.WorldCoreImpl;
@ -21,6 +23,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -29,6 +32,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -60,4 +64,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,18 @@
package com.craftaro.core.nms.v1_19_R3.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import org.bukkit.craftbukkit.v1_19_R3.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
public class NmsItemImpl implements NmsItem {
private final RandomSource randomSource = RandomSource.createNewThreadLocalInstance();
@Override
public ItemStack copyAndApplyRandomEnchantment(ItemStack item, int level) {
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentHelper.enchantItem(this.randomSource, nmsItem, level, false);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_20_R1;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_20_R1.anvil.AnvilCore;
import com.craftaro.core.nms.v1_20_R1.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_20_R1.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_20_R1.item.NmsItemImpl;
import com.craftaro.core.nms.v1_20_R1.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_20_R1.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_20_R1.world.WorldCoreImpl;
@ -21,6 +23,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -29,6 +32,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -60,4 +64,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,18 @@
package com.craftaro.core.nms.v1_20_R1.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
public class NmsItemImpl implements NmsItem {
private final RandomSource randomSource = RandomSource.createNewThreadLocalInstance();
@Override
public ItemStack copyAndApplyRandomEnchantment(ItemStack item, int level) {
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentHelper.enchantItem(this.randomSource, nmsItem, level, false);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_20_R2;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_20_R2.anvil.AnvilCore;
import com.craftaro.core.nms.v1_20_R2.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_20_R2.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_20_R2.item.NmsItemImpl;
import com.craftaro.core.nms.v1_20_R2.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_20_R2.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_20_R2.world.WorldCoreImpl;
@ -21,6 +23,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -29,6 +32,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -60,4 +64,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,18 @@
package com.craftaro.core.nms.v1_20_R2.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import org.bukkit.craftbukkit.v1_20_R2.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
public class NmsItemImpl implements NmsItem {
private final RandomSource randomSource = RandomSource.createNewThreadLocalInstance();
@Override
public ItemStack copyAndApplyRandomEnchantment(ItemStack item, int level) {
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentHelper.enchantItem(this.randomSource, nmsItem, level, false);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_20_R3;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_20_R3.anvil.AnvilCore;
import com.craftaro.core.nms.v1_20_R3.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_20_R3.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_20_R3.item.NmsItemImpl;
import com.craftaro.core.nms.v1_20_R3.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_20_R3.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_20_R3.world.WorldCoreImpl;
@ -21,6 +23,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -29,6 +32,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -60,4 +64,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,18 @@
package com.craftaro.core.nms.v1_20_R3.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import org.bukkit.craftbukkit.v1_20_R3.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
public class NmsItemImpl implements NmsItem {
private final RandomSource randomSource = RandomSource.createNewThreadLocalInstance();
@Override
public ItemStack copyAndApplyRandomEnchantment(ItemStack item, int level) {
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentHelper.enchantItem(this.randomSource, nmsItem, level, false);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_20_R4;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_20_R4.anvil.AnvilCore;
import com.craftaro.core.nms.v1_20_R4.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_20_R4.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_20_R4.item.NmsItemImpl;
import com.craftaro.core.nms.v1_20_R4.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_20_R4.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_20_R4.world.WorldCoreImpl;
@ -21,6 +23,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -29,6 +32,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -60,4 +64,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,19 @@
package com.craftaro.core.nms.v1_20_R4.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.util.RandomSource;
import net.minecraft.world.flag.FeatureFlags;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import org.bukkit.craftbukkit.v1_20_R4.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
public class NmsItemImpl implements NmsItem {
private final RandomSource randomSource = RandomSource.createNewThreadLocalInstance();
@Override
public ItemStack copyAndApplyRandomEnchantment(ItemStack item, int level) {
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentHelper.enchantItem(FeatureFlags.DEFAULT_FLAGS, this.randomSource, nmsItem, level, false);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_21_R1;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_21_R1.anvil.AnvilCore;
import com.craftaro.core.nms.v1_21_R1.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_21_R1.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_21_R1.item.NmsItemImpl;
import com.craftaro.core.nms.v1_21_R1.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_21_R1.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_21_R1.world.WorldCoreImpl;
@ -21,6 +23,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -29,6 +32,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -60,4 +64,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,21 @@
package com.craftaro.core.nms.v1_21_R1.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import org.bukkit.craftbukkit.v1_21_R1.CraftRegistry;
import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import java.util.Optional;
public class NmsItemImpl implements NmsItem {
private final RandomSource randomSource = RandomSource.createNewThreadLocalInstance();
@Override
public ItemStack copyAndApplyRandomEnchantment(ItemStack item, int level) {
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentHelper.enchantItem(this.randomSource, nmsItem, level, CraftRegistry.getMinecraftRegistry(), Optional.empty());
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_8_R1;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_8_R1.anvil.AnvilCore;
import com.craftaro.core.nms.v1_8_R1.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_8_R1.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_8_R1.item.NmsItemImpl;
import com.craftaro.core.nms.v1_8_R1.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_8_R1.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_8_R1.world.WorldCoreImpl;
@ -22,6 +24,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -30,6 +33,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -61,4 +65,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,17 @@
package com.craftaro.core.nms.v1_8_R1.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.server.v1_8_R1.EnchantmentManager;
import net.minecraft.server.v1_8_R1.ItemStack;
import org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack;
import java.util.concurrent.ThreadLocalRandom;
public class NmsItemImpl implements NmsItem {
@Override
public org.bukkit.inventory.ItemStack copyAndApplyRandomEnchantment(org.bukkit.inventory.ItemStack item, int level) {
ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentManager.a(ThreadLocalRandom.current(), nmsItem, level);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_8_R2;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_8_R2.anvil.AnvilCore;
import com.craftaro.core.nms.v1_8_R2.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_8_R2.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_8_R2.item.NmsItemImpl;
import com.craftaro.core.nms.v1_8_R2.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_8_R2.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_8_R2.world.WorldCoreImpl;
@ -22,6 +24,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -30,6 +33,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -61,4 +65,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,17 @@
package com.craftaro.core.nms.v1_8_R2.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.server.v1_8_R2.EnchantmentManager;
import net.minecraft.server.v1_8_R2.ItemStack;
import org.bukkit.craftbukkit.v1_8_R2.inventory.CraftItemStack;
import java.util.concurrent.ThreadLocalRandom;
public class NmsItemImpl implements NmsItem {
@Override
public org.bukkit.inventory.ItemStack copyAndApplyRandomEnchantment(org.bukkit.inventory.ItemStack item, int level) {
ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentManager.a(ThreadLocalRandom.current(), nmsItem, level);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -4,9 +4,11 @@ import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.anvil.AnvilCore;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_8_R3.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_8_R3.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_8_R3.item.NmsItemImpl;
import com.craftaro.core.nms.v1_8_R3.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_8_R3.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_8_R3.world.WorldCoreImpl;
@ -22,6 +24,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -30,6 +33,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new com.craftaro.core.nms.v1_8_R3.anvil.AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -61,4 +65,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,17 @@
package com.craftaro.core.nms.v1_8_R3.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.server.v1_8_R3.EnchantmentManager;
import net.minecraft.server.v1_8_R3.ItemStack;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import java.util.concurrent.ThreadLocalRandom;
public class NmsItemImpl implements NmsItem {
@Override
public org.bukkit.inventory.ItemStack copyAndApplyRandomEnchantment(org.bukkit.inventory.ItemStack item, int level) {
ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentManager.a(ThreadLocalRandom.current(), nmsItem, level);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_9_R1;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_9_R1.anvil.AnvilCore;
import com.craftaro.core.nms.v1_9_R1.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_9_R1.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_9_R1.item.NmsItemImpl;
import com.craftaro.core.nms.v1_9_R1.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_9_R1.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_9_R1.world.WorldCoreImpl;
@ -22,6 +24,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -30,6 +33,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -61,4 +65,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,17 @@
package com.craftaro.core.nms.v1_9_R1.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.server.v1_9_R1.EnchantmentManager;
import net.minecraft.server.v1_9_R1.ItemStack;
import org.bukkit.craftbukkit.v1_9_R1.inventory.CraftItemStack;
import java.util.concurrent.ThreadLocalRandom;
public class NmsItemImpl implements NmsItem {
@Override
public org.bukkit.inventory.ItemStack copyAndApplyRandomEnchantment(org.bukkit.inventory.ItemStack item, int level) {
ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentManager.a(ThreadLocalRandom.current(), nmsItem, level, false);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}

View File

@ -3,10 +3,12 @@ package com.craftaro.core.nms.v1_9_R2;
import com.craftaro.core.nms.NmsImplementations;
import com.craftaro.core.nms.entity.NMSPlayer;
import com.craftaro.core.nms.entity.NmsEntity;
import com.craftaro.core.nms.item.NmsItem;
import com.craftaro.core.nms.nbt.NBTCore;
import com.craftaro.core.nms.v1_9_R2.anvil.AnvilCore;
import com.craftaro.core.nms.v1_9_R2.entity.NMSPlayerImpl;
import com.craftaro.core.nms.v1_9_R2.entity.NmsEntityImpl;
import com.craftaro.core.nms.v1_9_R2.item.NmsItemImpl;
import com.craftaro.core.nms.v1_9_R2.nbt.NBTCoreImpl;
import com.craftaro.core.nms.v1_9_R2.world.NmsWorldBorderImpl;
import com.craftaro.core.nms.v1_9_R2.world.WorldCoreImpl;
@ -22,6 +24,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
private final NmsWorldBorder worldBorder;
private final com.craftaro.core.nms.anvil.AnvilCore anvil;
private final NBTCore nbt;
private final NmsItem item;
public NmsImplementationsImpl() {
this.entity = new NmsEntityImpl();
@ -30,6 +33,7 @@ public class NmsImplementationsImpl implements NmsImplementations {
this.worldBorder = new NmsWorldBorderImpl();
this.anvil = new AnvilCore();
this.nbt = new NBTCoreImpl();
this.item = new NmsItemImpl();
}
@Override
@ -61,4 +65,9 @@ public class NmsImplementationsImpl implements NmsImplementations {
public @NotNull NBTCore getNbt() {
return this.nbt;
}
@Override
public @NotNull NmsItem getItem() {
return this.item;
}
}

View File

@ -0,0 +1,17 @@
package com.craftaro.core.nms.v1_9_R2.item;
import com.craftaro.core.nms.item.NmsItem;
import net.minecraft.server.v1_9_R2.EnchantmentManager;
import net.minecraft.server.v1_9_R2.ItemStack;
import org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack;
import java.util.concurrent.ThreadLocalRandom;
public class NmsItemImpl implements NmsItem {
@Override
public org.bukkit.inventory.ItemStack copyAndApplyRandomEnchantment(org.bukkit.inventory.ItemStack item, int level) {
ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
EnchantmentManager.a(ThreadLocalRandom.current(), nmsItem, level, false);
return CraftItemStack.asBukkitCopy(nmsItem);
}
}