mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-25 11:35:34 +01:00
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:
parent
265e5864c9
commit
488490de18
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
package com.craftaro.core.nms.item;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public interface NmsItem {
|
||||
ItemStack copyAndApplyRandomEnchantment(ItemStack item, int level);
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user