package team.unstudio.udpl.nms;

import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack;

import team.unstudio.udpl.annotation.Init;
import team.unstudio.udpl.nms.entity.NmsEntity;
import team.unstudio.udpl.nms.inventory.NmsItemStack;
import team.unstudio.udpl.nms.nbt.NmsNBT;
import team.unstudio.udpl.nms.tileentity.NmsTileEntity;

public final class NmsHelper {
	
	private NmsHelper(){}
	
	@Init("nms_manager")
	private static NmsManager NMS_MANAGER;

	/**
	 * 获取 {@link net.minecraft.server} 与  {@link team.unstudio.udpl.nms.nbt} 的帮助类实例
	 */
	public static NmsNBT getNmsNBT(){
		return NMS_MANAGER.getNmsNBT();
	}
	
	
	/**
	 * 创建一个{@link NmsItemStack}对象
	 */
	public static NmsItemStack createNmsItemStack(ItemStack itemStack){
		return NMS_MANAGER.createNmsItemStack(itemStack);
	}
	
	/**
	 * 创建一个{@link NmsEntity}对象
	 */
	public static NmsEntity createNmsEntity(Entity entity){
		return NMS_MANAGER.createNmsEntity(entity);
	}
	
	/**
	 * 创建一个{@link NmsTileEntity}对象
	 */
	public static NmsTileEntity createNmsTileEntity(BlockState blockState){
		return NMS_MANAGER.createNmsTileEntity(blockState);
	}
	
	/**
	 * 获取是否支持Nms操作
	 */
	public static boolean isNmsSupported() {
		return NMS_MANAGER != null;
	}
}

@@ -645,24 +645,48 @@
 tNmsNBT()%7B%0D%0A
+%09%09checkNmsSupported();%0D%0A
 %09%09return NMS
@@ -704,24 +704,24 @@
 tNmsNBT();%0D%0A
-
 %09%7D%0D%0A%09%0D%0A%09%0D%0A%09/
@@ -828,24 +828,48 @@
 temStack)%7B%0D%0A
+%09%09checkNmsSupported();%0D%0A
 %09%09return NMS
@@ -1011,24 +1011,48 @@
 y entity)%7B%0D%0A
+%09%09checkNmsSupported();%0D%0A
 %09%09return NMS
@@ -1212,16 +1212,40 @@
 tate)%7B%0D%0A
+%09%09checkNmsSupported();%0D%0A
 %09%09return
@@ -1370,16 +1370,16 @@
 ed() %7B%0D%0A
-
 %09%09return
@@ -1405,11 +1405,135 @@
 l;%0D%0A%09%7D%0D%0A
+%09%0D%0A%09private static void checkNmsSupported() %7B%0D%0A%09%09if(!isNmsSupported())%0D%0A%09%09%09throw new NmsException(%22Unsupported Nms.%22);%0D%0A%09%7D%0D%0A
 %7D%0D%0A

Update NMS