版本更新至:3.78
调整:数据保存提示现在默认关闭了 新增:Language2.yml 新增 [book] 类型示范
This commit is contained in:
		@@ -11,6 +11,9 @@
 | 
			
		||||
#   30: 大标题不兼容当前版本服务器
 | 
			
		||||
#   31: 动作栏不兼容当前版本服务器
 | 
			
		||||
#   40: 语言文件类型异常
 | 
			
		||||
#   50: BOOK 语言类型指定 option 不存在
 | 
			
		||||
#   51: BOOK 语言类型识别异常
 | 
			
		||||
#   52: BOOK 语言类型 url 地址错误(http:// or https://)
 | 
			
		||||
 | 
			
		||||
# 正常提示
 | 
			
		||||
TEXT: '&f正常的提示'
 | 
			
		||||
@@ -89,4 +92,23 @@ SOUND-TEXT:
 | 
			
		||||
- '单行文本 - 1'
 | 
			
		||||
- '单行文本 - 2'
 | 
			
		||||
- '[sound]'
 | 
			
		||||
- 'BLOCK_ANVIL_USE-1-1'
 | 
			
		||||
- 'BLOCK_ANVIL_USE-1-1'
 | 
			
		||||
 | 
			
		||||
# 书本界面
 | 
			
		||||
BOOK-TEXT:
 | 
			
		||||
- '[book]'
 | 
			
		||||
- '书本单行文本'
 | 
			
		||||
- '&4书本单行文本'
 | 
			
		||||
- '&4&l书本单行文本'
 | 
			
		||||
- '[page]'
 | 
			
		||||
- '<@1>'
 | 
			
		||||
- '<@1> | <@1> 单行重复变量'
 | 
			
		||||
- '<@1> | <@2> 单行不同变量'
 | 
			
		||||
- '@option:1'
 | 
			
		||||
- '    text: 文本'
 | 
			
		||||
- '    command: 执行命令'
 | 
			
		||||
- '    showtext: 显示文本'
 | 
			
		||||
- '@option:2'
 | 
			
		||||
- '    text: 测试'
 | 
			
		||||
- '    command: 执行命令'
 | 
			
		||||
- '    showtext: 显示文本'
 | 
			
		||||
@@ -35,7 +35,7 @@ DELETE-VARIABLE: false
 | 
			
		||||
ENABLE-UUID: false
 | 
			
		||||
 | 
			
		||||
# 是否隐藏保存数据的提示
 | 
			
		||||
HIDE-NOTIFY: false
 | 
			
		||||
HIDE-NOTIFY: true
 | 
			
		||||
 | 
			
		||||
# 数据库信息
 | 
			
		||||
MYSQL:
 | 
			
		||||
 
 | 
			
		||||
@@ -6,7 +6,7 @@ website: http://www.15imc.com/index.html
 | 
			
		||||
 | 
			
		||||
main: me.skymc.taboolib.Main
 | 
			
		||||
 | 
			
		||||
version: 3.77
 | 
			
		||||
version: 3.78
 | 
			
		||||
 | 
			
		||||
commands:
 | 
			
		||||
  taboolib:
 | 
			
		||||
 
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							@@ -1,2 +0,0 @@
 | 
			
		||||
#Sat Mar 10 19:32:51 CST 2018
 | 
			
		||||
gradle.version=4.5
 | 
			
		||||
							
								
								
									
										282
									
								
								src/main/java/me/skymc/taboolib/entity/EntityTag.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										282
									
								
								src/main/java/me/skymc/taboolib/entity/EntityTag.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,282 @@
 | 
			
		||||
package me.skymc.taboolib.entity;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
import java.util.concurrent.ConcurrentHashMap;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.entity.Entity;
 | 
			
		||||
import org.bukkit.scheduler.BukkitRunnable;
 | 
			
		||||
 | 
			
		||||
import me.skymc.taboolib.Main;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 伪 - MetaData
 | 
			
		||||
 * 
 | 
			
		||||
 * @author sky
 | 
			
		||||
 * @since 2018-03-11 11:43:41
 | 
			
		||||
 */
 | 
			
		||||
public class EntityTag {
 | 
			
		||||
	
 | 
			
		||||
	private static EntityTag inst;
 | 
			
		||||
	private static ConcurrentHashMap<UUID, ConcurrentHashMap<String, Object>> entityData = new ConcurrentHashMap<>();
 | 
			
		||||
	
 | 
			
		||||
	private EntityTag() {
 | 
			
		||||
		new BukkitRunnable() {
 | 
			
		||||
			
 | 
			
		||||
			@Override
 | 
			
		||||
			public void run() {
 | 
			
		||||
				for (UUID uuid : entityData.keySet()) {
 | 
			
		||||
					if (EntityUtils.getEntityWithUUID(uuid) == null) {
 | 
			
		||||
						entityData.remove(uuid);
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}.runTaskTimerAsynchronously(Main.getInst(), 20 * 180, 20 * 180);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public static EntityTag getInst() {
 | 
			
		||||
		if (inst == null) {
 | 
			
		||||
			synchronized (EntityTag.class) {
 | 
			
		||||
				if (inst == null) {
 | 
			
		||||
					inst = new EntityTag();
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		return inst;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 设置标签
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param entity 实体
 | 
			
		||||
	 * @param key 键
 | 
			
		||||
	 * @param value 值
 | 
			
		||||
	 */
 | 
			
		||||
	public void set(String key, Object value, Entity entity) {
 | 
			
		||||
		if (contains(entity)) {
 | 
			
		||||
			entityData.get(entity.getUniqueId()).put(key, value);
 | 
			
		||||
		} else {
 | 
			
		||||
			ConcurrentHashMap<String, Object> map = new ConcurrentHashMap<>();
 | 
			
		||||
			map.put(key, value);
 | 
			
		||||
			entityData.put(entity.getUniqueId(), map);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 设置标签
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param key 键
 | 
			
		||||
	 * @param value 值
 | 
			
		||||
	 * @param entity 实体
 | 
			
		||||
	 */
 | 
			
		||||
	public void set(String key, Object value, Entity... entities) {
 | 
			
		||||
		for (Entity entity : entities) set(key, value, entity);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 设置标签
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param key 键
 | 
			
		||||
	 * @param value 值
 | 
			
		||||
	 * @param entity 实体
 | 
			
		||||
	 */
 | 
			
		||||
	public void set(String key, Object value, List<Entity> entities) {
 | 
			
		||||
		for (Entity entity : entities) set(key, value, entity);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 移除标签
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param key 键
 | 
			
		||||
	 * @param value 值
 | 
			
		||||
	 * @param entity 实体
 | 
			
		||||
	 */
 | 
			
		||||
	public void remove(String key, Object value, Entity entity) {
 | 
			
		||||
		if (contains(entity)) {
 | 
			
		||||
			entityData.get(entity.getUniqueId()).remove(key);
 | 
			
		||||
			if (entityData.get(entity.getUniqueId()).size() == 0) {
 | 
			
		||||
				entityData.remove(entity.getUniqueId());
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 移除标签
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param key 键
 | 
			
		||||
	 * @param value 值
 | 
			
		||||
	 * @param entities 实体
 | 
			
		||||
	 */
 | 
			
		||||
	public void remove(String key, Object value, Entity... entities) {
 | 
			
		||||
		for (Entity entity : entities) remove(key, value, entity);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 移除标签
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param key 键
 | 
			
		||||
	 * @param value 值
 | 
			
		||||
	 * @param entities 实体
 | 
			
		||||
	 */
 | 
			
		||||
	public void remove(String key, Object value, List<Entity> entities) {
 | 
			
		||||
		for (Entity entity : entities) remove(key, value, entity);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 检查数据
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param entity 实体
 | 
			
		||||
	 * @return boolean
 | 
			
		||||
	 */
 | 
			
		||||
	public boolean contains(Entity entity) {
 | 
			
		||||
		return entityData.containsKey(entity.getUniqueId());
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 检查标签
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param key 键
 | 
			
		||||
	 * @param entity 实体
 | 
			
		||||
	 * @return boolean
 | 
			
		||||
	 */
 | 
			
		||||
	public boolean hasKey(String key, Entity entity) {
 | 
			
		||||
		if (contains(entity)) {
 | 
			
		||||
			return entityData.get(entity.getUniqueId()).containsKey(key);
 | 
			
		||||
		}
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 获取数据
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param key 键
 | 
			
		||||
	 * @param entity 实体
 | 
			
		||||
	 * @return Object
 | 
			
		||||
	 */
 | 
			
		||||
	public Object get(String key, Entity entity) {
 | 
			
		||||
		if (contains(entity)) {
 | 
			
		||||
			return entityData.get(entity.getUniqueId()).get(key);
 | 
			
		||||
		}
 | 
			
		||||
		return null;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 获取数据
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param key 键
 | 
			
		||||
	 * @param entity 值
 | 
			
		||||
	 * @return String
 | 
			
		||||
	 */
 | 
			
		||||
	public String getString(String key, Entity entity) {
 | 
			
		||||
		Object object = get(key, entity);
 | 
			
		||||
		if (object instanceof String) {
 | 
			
		||||
			return (String) object;
 | 
			
		||||
		}
 | 
			
		||||
		return null;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 获取数据
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param key 键
 | 
			
		||||
	 * @param entity 值
 | 
			
		||||
	 * @return int
 | 
			
		||||
	 */
 | 
			
		||||
	public int getInteger(String key, Entity entity) {
 | 
			
		||||
		Object object = get(key, entity);
 | 
			
		||||
		if (object != null) {
 | 
			
		||||
			return (int) object;
 | 
			
		||||
		}
 | 
			
		||||
		return 0;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 获取数据
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param key 键
 | 
			
		||||
	 * @param entity 值
 | 
			
		||||
	 * @return long
 | 
			
		||||
	 */
 | 
			
		||||
	public long getLong(String key, Entity entity) {
 | 
			
		||||
		Object object = get(key, entity);
 | 
			
		||||
		if (object != null) {
 | 
			
		||||
			return (long) object;
 | 
			
		||||
		}
 | 
			
		||||
		return 0L;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 获取数据
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param key 键
 | 
			
		||||
	 * @param entity 实体
 | 
			
		||||
	 * @return boolean
 | 
			
		||||
	 */
 | 
			
		||||
	public boolean getBoolean(String key, Entity entity) {
 | 
			
		||||
		Object object = get(key, entity);
 | 
			
		||||
		if (object != null) {
 | 
			
		||||
			return (boolean) object;
 | 
			
		||||
		}
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 获取数据 
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param key 键
 | 
			
		||||
	 * @param entity 实体
 | 
			
		||||
	 * @return double
 | 
			
		||||
	 */
 | 
			
		||||
	public double getDouble(String key, Entity entity) {
 | 
			
		||||
		Object object = get(key, entity);
 | 
			
		||||
		if (object != null) {
 | 
			
		||||
			return (double) object;
 | 
			
		||||
		}
 | 
			
		||||
		return 0D;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 获取数据 
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param key 键
 | 
			
		||||
	 * @param entity 实体
 | 
			
		||||
	 * @return float
 | 
			
		||||
	 */
 | 
			
		||||
	public double getFloat(String key, Entity entity) {
 | 
			
		||||
		Object object = get(key, entity);
 | 
			
		||||
		if (object != null) {
 | 
			
		||||
			return (float) object;
 | 
			
		||||
		}
 | 
			
		||||
		return 0F;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 获取数据 
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param key 键
 | 
			
		||||
	 * @param entity 实体
 | 
			
		||||
	 * @return short
 | 
			
		||||
	 */
 | 
			
		||||
	public short getShort(String key, Entity entity) {
 | 
			
		||||
		Object object = get(key, entity);
 | 
			
		||||
		if (object != null) {
 | 
			
		||||
			return (short) object;
 | 
			
		||||
		}
 | 
			
		||||
		return (short) 0;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 获取数据 
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param key 键
 | 
			
		||||
	 * @param entity 实体
 | 
			
		||||
	 * @return byte
 | 
			
		||||
	 */
 | 
			
		||||
	public byte getByte(String key, Entity entity) {
 | 
			
		||||
		Object object = get(key, entity);
 | 
			
		||||
		if (object != null) {
 | 
			
		||||
			return (byte) object;
 | 
			
		||||
		}
 | 
			
		||||
		return (byte) 0;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -16,17 +16,25 @@ import com.comphenix.protocol.ProtocolLibrary;
 | 
			
		||||
import com.comphenix.protocol.events.PacketContainer;
 | 
			
		||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
 | 
			
		||||
 | 
			
		||||
import me.skymc.taboolib.methods.MethodsUtils;
 | 
			
		||||
import lombok.Getter;
 | 
			
		||||
import me.skymc.taboolib.exception.PluginNotFoundException;
 | 
			
		||||
 | 
			
		||||
public class EntityUtils implements Listener{
 | 
			
		||||
public class EntityUtils implements Listener {
 | 
			
		||||
	
 | 
			
		||||
	public static Entity lastSpawned = null;
 | 
			
		||||
	@Getter
 | 
			
		||||
	private static Entity lastSpawnedEntity = null;
 | 
			
		||||
	
 | 
			
		||||
	@EventHandler
 | 
			
		||||
	public void spawn(EntitySpawnEvent e) {
 | 
			
		||||
		lastSpawned = e.getEntity();
 | 
			
		||||
		lastSpawnedEntity = e.getEntity();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 根据 UUID 获取生物
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param u
 | 
			
		||||
	 * @return
 | 
			
		||||
	 */
 | 
			
		||||
	public static Entity getEntityWithUUID(UUID u) {
 | 
			
		||||
		for (World w : Bukkit.getWorlds()) {
 | 
			
		||||
			for (Entity e : w.getLivingEntities()) {
 | 
			
		||||
@@ -38,6 +46,13 @@ public class EntityUtils implements Listener{
 | 
			
		||||
		return null;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 根据 UUID 获取生物(单世界)
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param u
 | 
			
		||||
	 * @param world
 | 
			
		||||
	 * @return
 | 
			
		||||
	 */
 | 
			
		||||
	public static Entity getEntityWithUUID_World(UUID u, World world) {
 | 
			
		||||
		for (Entity e : world.getLivingEntities()) {
 | 
			
		||||
			if (e.getUniqueId().equals(u)) {
 | 
			
		||||
@@ -46,7 +61,7 @@ public class EntityUtils implements Listener{
 | 
			
		||||
		}
 | 
			
		||||
		return null;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 设置生物发光(ProcotolLib)
 | 
			
		||||
	 * 
 | 
			
		||||
@@ -54,6 +69,14 @@ public class EntityUtils implements Listener{
 | 
			
		||||
	 * @param entity
 | 
			
		||||
	 */
 | 
			
		||||
	public static void addGlow(Player player,Entity entity) {
 | 
			
		||||
		if (Bukkit.getPluginManager().getPlugin("ProtocolLib") == null) {
 | 
			
		||||
			try {
 | 
			
		||||
				throw new PluginNotFoundException("缺少前置插件 ProtocolLib");
 | 
			
		||||
			}
 | 
			
		||||
			catch (Exception e) {
 | 
			
		||||
				//
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
        PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_METADATA);
 | 
			
		||||
        packet.getIntegers().write(0, entity.getEntityId());
 | 
			
		||||
        WrappedDataWatcher watcher = new WrappedDataWatcher();
 | 
			
		||||
@@ -75,6 +98,13 @@ public class EntityUtils implements Listener{
 | 
			
		||||
	 * @param entity
 | 
			
		||||
	 */
 | 
			
		||||
    public static void delGlow(Player player,Entity entity) {
 | 
			
		||||
		if (Bukkit.getPluginManager().getPlugin("ProtocolLib") == null) {
 | 
			
		||||
			try {
 | 
			
		||||
				throw new PluginNotFoundException("缺少前置插件 ProtocolLib");
 | 
			
		||||
			} catch (Exception e) {
 | 
			
		||||
				//
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
        PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_METADATA);
 | 
			
		||||
        packet.getIntegers().write(0, entity.getEntityId());
 | 
			
		||||
        WrappedDataWatcher watcher = new WrappedDataWatcher();
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,10 @@
 | 
			
		||||
package me.skymc.taboolib.exception;
 | 
			
		||||
 | 
			
		||||
public class PluginNotFoundException extends Error {
 | 
			
		||||
 | 
			
		||||
	private static final long serialVersionUID = -475540326950009346L;
 | 
			
		||||
 | 
			
		||||
	public PluginNotFoundException(String message) {
 | 
			
		||||
		super(message);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user