TabooLib v4.26
+ 调整 TConfiguration 类,增加 runListener 方法运行重载任务 + 调整 ItemBuilder 类,增加玩家皮肤头构造方法 + 调整 TagDataHandler 类,兼容了弱智 BedwarsRel 的计分板冲突 + 调整 SupportWorldGuard 类,新增了获取所有区域的方法。 + 重构 ItemUtils 类,现在更加整洁了。。 + SkullUtils 被赋予尊贵的 @Deprecated + 优化本地通讯网,修复了心跳包的语法错误问题,并新增了 /tclient 命令用于简单的操作通讯网络。
This commit is contained in:
parent
40aa95e17b
commit
5b5a96464f
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>me.skymc</groupId>
|
<groupId>me.skymc</groupId>
|
||||||
<artifactId>TabooLib</artifactId>
|
<artifactId>TabooLib</artifactId>
|
||||||
<version>4.25</version>
|
<version>4.26</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
@ -112,7 +112,7 @@ public class Main extends JavaPlugin {
|
|||||||
// 载入权限
|
// 载入权限
|
||||||
PermissionUtils.loadRegisteredServiceProvider();
|
PermissionUtils.loadRegisteredServiceProvider();
|
||||||
// 物品名称
|
// 物品名称
|
||||||
ItemUtils.LoadLib();
|
ItemUtils.init();
|
||||||
// 低层工具
|
// 低层工具
|
||||||
DabItemUtils.getInstance();
|
DabItemUtils.getInstance();
|
||||||
// 载入周期管理器
|
// 载入周期管理器
|
||||||
|
@ -25,25 +25,27 @@ public class TConfiguration extends YamlConfiguration {
|
|||||||
TLib.getTLib().getConfigWatcher().addSimpleListener(this.file, this::reload);
|
TLib.getTLib().getConfigWatcher().addSimpleListener(this.file, this::reload);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 释放文件监听
|
|
||||||
*/
|
|
||||||
public void release() {
|
public void release() {
|
||||||
TLib.getTLib().getConfigWatcher().removeListener(file);
|
TLib.getTLib().getConfigWatcher().removeListener(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 重新载入配置
|
|
||||||
*/
|
|
||||||
public void reload() {
|
public void reload() {
|
||||||
try {
|
try {
|
||||||
load(file);
|
load(file);
|
||||||
Optional.ofNullable(runnable).ifPresent(Runnable::run);
|
runListener();
|
||||||
} catch (IOException | InvalidConfigurationException e) {
|
} catch (IOException | InvalidConfigurationException e) {
|
||||||
TLogger.getGlobalLogger().warn("Cannot load configuration from stream: " + e.toString());
|
TLogger.getGlobalLogger().warn("Cannot load configuration from stream: " + e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void runListener() {
|
||||||
|
try {
|
||||||
|
Optional.ofNullable(runnable).ifPresent(Runnable::run);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建配置文件
|
* 创建配置文件
|
||||||
*
|
*
|
||||||
|
@ -4,13 +4,13 @@ import com.ilummc.tlib.resources.TLocale;
|
|||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import me.skymc.taboolib.Main;
|
import me.skymc.taboolib.Main;
|
||||||
import me.skymc.taboolib.TabooLib;
|
import me.skymc.taboolib.TabooLib;
|
||||||
|
import me.skymc.taboolib.common.configuration.TConfiguration;
|
||||||
import me.skymc.taboolib.fileutils.ConfigUtils;
|
import me.skymc.taboolib.fileutils.ConfigUtils;
|
||||||
import me.skymc.taboolib.itemnbtapi.NBTItem;
|
import me.skymc.taboolib.itemnbtapi.NBTItem;
|
||||||
import me.skymc.taboolib.itemnbtapi.NBTList;
|
import me.skymc.taboolib.itemnbtapi.NBTList;
|
||||||
import me.skymc.taboolib.itemnbtapi.NBTListCompound;
|
import me.skymc.taboolib.itemnbtapi.NBTListCompound;
|
||||||
import me.skymc.taboolib.itemnbtapi.NBTType;
|
import me.skymc.taboolib.itemnbtapi.NBTType;
|
||||||
import me.skymc.taboolib.other.NumberUtils;
|
import me.skymc.taboolib.other.NumberUtils;
|
||||||
import me.skymc.taboolib.string.Language;
|
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
@ -39,74 +39,59 @@ import java.util.stream.IntStream;
|
|||||||
*/
|
*/
|
||||||
public class ItemUtils {
|
public class ItemUtils {
|
||||||
|
|
||||||
private static FileConfiguration itemdir = null;
|
|
||||||
|
|
||||||
private static FileConfiguration itemCache = null;
|
|
||||||
|
|
||||||
private static File finalItemsFolder;
|
private static File finalItemsFolder;
|
||||||
|
private static FileConfiguration itemDir;
|
||||||
private static LinkedHashMap<String, String> itemlib = new LinkedHashMap<>();
|
private static FileConfiguration itemCache;
|
||||||
|
private static TConfiguration itemName;
|
||||||
|
private static LinkedHashMap<String, String> itemLib = new LinkedHashMap<>();
|
||||||
private static LinkedHashMap<String, ItemStack> itemCaches = new LinkedHashMap<>();
|
private static LinkedHashMap<String, ItemStack> itemCaches = new LinkedHashMap<>();
|
||||||
|
|
||||||
private static LinkedHashMap<String, ItemStack> itemCachesFinal = new LinkedHashMap<>();
|
private static LinkedHashMap<String, ItemStack> itemCachesFinal = new LinkedHashMap<>();
|
||||||
|
|
||||||
public static FileConfiguration getItemdir() {
|
public static void init() {
|
||||||
return itemdir;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FileConfiguration getItemCache() {
|
|
||||||
return itemCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File getFinalItemsFolder() {
|
|
||||||
return finalItemsFolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LinkedHashMap<String, String> getItemlib() {
|
|
||||||
return itemlib;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LinkedHashMap<String, ItemStack> getItemCaches() {
|
|
||||||
return itemCaches;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LinkedHashMap<String, ItemStack> getItemCachesFinal() {
|
|
||||||
return itemCachesFinal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取物品缓存
|
|
||||||
* 检测顺序:
|
|
||||||
* 1. 固定物品库
|
|
||||||
* 2. 动态物品库
|
|
||||||
*
|
|
||||||
* @param name 物品名称
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static ItemStack getCacheItem(String name) {
|
|
||||||
// 检测固定物品库是否存在该物品
|
|
||||||
if (itemCachesFinal.containsKey(name)) {
|
|
||||||
return itemCachesFinal.get(name);
|
|
||||||
}
|
|
||||||
// 返回动态物品库
|
|
||||||
return itemCaches.get(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isExists(String name) {
|
|
||||||
return itemCachesFinal.containsKey(name) || itemCaches.containsKey(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void LoadLib() {
|
|
||||||
try {
|
try {
|
||||||
|
reloadItemDir();
|
||||||
reloadItemName();
|
reloadItemName();
|
||||||
reloadItemCache();
|
reloadItemCache();
|
||||||
itemdir = YamlConfiguration.loadConfiguration(new File(Main.getInst().getConfig().getString("DATAURL.ITEMDIR")));
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
TLocale.Logger.error("ITEM-UTILS.FAIL-LOAD-ITEMS", e.toString());
|
TLocale.Logger.error("ITEM-UTILS.FAIL-LOAD-ITEMS", e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void reloadItemDir() {
|
||||||
|
File file = new File(Main.getInst().getConfig().getString("DATAURL.ITEMDIR"));
|
||||||
|
if (file.exists()) {
|
||||||
|
itemDir = YamlConfiguration.loadConfiguration(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void reloadItemName() {
|
||||||
|
itemName = TConfiguration.createInResource(Main.getInst(), "Language/ITEM_NAME.yml");
|
||||||
|
itemName.listener(() -> {
|
||||||
|
itemName.getConfigurationSection("").getKeys(false).forEach(a -> itemLib.put(a, itemName.getString(a)));
|
||||||
|
TLocale.Logger.info("ITEM-UTILS.SUCCESS-LOAD-NAMES", String.valueOf(itemLib.size()));
|
||||||
|
}).runListener();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void reloadItemCache() {
|
||||||
|
itemCaches.clear();
|
||||||
|
itemCachesFinal.clear();
|
||||||
|
loadItemsFile(getItemCacheFile(), false);
|
||||||
|
finalItemsFolder = new File(Main.getInst().getDataFolder(), "FinalItems");
|
||||||
|
if (!finalItemsFolder.exists()) {
|
||||||
|
finalItemsFolder.mkdir();
|
||||||
|
}
|
||||||
|
Arrays.stream(finalItemsFolder.listFiles()).forEach(file -> loadItemsFile(file, true));
|
||||||
|
TLocale.Logger.info("ITEM-UTILS.SUCCESS-LOAD-CACHES", String.valueOf(itemCaches.size() + itemCachesFinal.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static File getItemCacheFile() {
|
||||||
|
File itemCacheFile = new File(Main.getInst().getDataFolder(), "items.yml");
|
||||||
|
if (!itemCacheFile.exists()) {
|
||||||
|
Main.getInst().saveResource("items.yml", true);
|
||||||
|
}
|
||||||
|
return itemCacheFile;
|
||||||
|
}
|
||||||
|
|
||||||
public static void loadItemsFile(File file, boolean finalFile) {
|
public static void loadItemsFile(File file, boolean finalFile) {
|
||||||
FileConfiguration conf = ConfigUtils.load(Main.getInst(), file);
|
FileConfiguration conf = ConfigUtils.load(Main.getInst(), file);
|
||||||
for (String name : conf.getConfigurationSection("").getKeys(false)) {
|
for (String name : conf.getConfigurationSection("").getKeys(false)) {
|
||||||
@ -120,33 +105,22 @@ public class ItemUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reloadItemCache() {
|
// *********************************
|
||||||
itemCaches.clear();
|
//
|
||||||
itemCachesFinal.clear();
|
// API
|
||||||
loadItemsFile(getItemCacheFile(), false);
|
//
|
||||||
// 创建固定物品库
|
// *********************************
|
||||||
finalItemsFolder = new File(Main.getInst().getDataFolder(), "FinalItems");
|
|
||||||
if (!finalItemsFolder.exists()) {
|
public static boolean isExists(String name) {
|
||||||
finalItemsFolder.mkdir();
|
return itemCachesFinal.containsKey(name) || itemCaches.containsKey(name);
|
||||||
}
|
|
||||||
// 检查固定物品库中的物品
|
|
||||||
Arrays.stream(finalItemsFolder.listFiles()).forEach(file -> loadItemsFile(file, true));
|
|
||||||
TLocale.Logger.info("ITEM-UTILS.SUCCESS-LOAD-CACHES", String.valueOf(itemCaches.size() + itemCachesFinal.size()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reloadItemName() {
|
public static ItemStack getCacheItem(String name) {
|
||||||
FileConfiguration conf = new Language("ITEM_NAME", Main.getInst(), true).getConfiguration();
|
return itemCachesFinal.containsKey(name) ? itemCachesFinal.get(name) : itemCaches.get(name);
|
||||||
itemlib.clear();
|
|
||||||
conf.getConfigurationSection("").getKeys(false).forEach(a -> itemlib.put(a, conf.getString(a)));
|
|
||||||
TLocale.Logger.info("ITEM-UTILS.SUCCESS-LOAD-NAMES", String.valueOf(itemlib.size()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File getItemCacheFile() {
|
public static ItemStack getItemFromDir(String name) {
|
||||||
File itemCacheFile = new File(Main.getInst().getDataFolder(), "items.yml");
|
return itemDir != null ? itemDir.getItemStack("item." + name) : null;
|
||||||
if (!itemCacheFile.exists()) {
|
|
||||||
Main.getInst().saveResource("items.yml", true);
|
|
||||||
}
|
|
||||||
return itemCacheFile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCustomName(ItemStack item) {
|
public static String getCustomName(ItemStack item) {
|
||||||
@ -154,19 +128,7 @@ public class ItemUtils {
|
|||||||
return TLocale.asString("ITEM-UTILS.EMPTY-ITEM");
|
return TLocale.asString("ITEM-UTILS.EMPTY-ITEM");
|
||||||
}
|
}
|
||||||
int data = item.getType().getMaxDurability() == 0 ? item.getDurability() : 0;
|
int data = item.getType().getMaxDurability() == 0 ? item.getDurability() : 0;
|
||||||
return item.getItemMeta().hasDisplayName() ? item.getItemMeta().getDisplayName() : itemlib.get(item.getType() + ":" + data) == null ? item.getType().toString() : itemlib.get(item.getType() + ":" + data);
|
return item.getItemMeta().hasDisplayName() ? item.getItemMeta().getDisplayName() : itemLib.get(item.getType() + ":" + data) == null ? item.getType().toString() : itemLib.get(item.getType() + ":" + data);
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemStack getItemFromDir(String name) {
|
|
||||||
if (itemdir != null) {
|
|
||||||
return itemdir.getItemStack("item." + name);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public static ItemStack item(int n, int a, int d) {
|
|
||||||
return new ItemStack(n, a, (short) d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack setName(ItemStack i, String n) {
|
public static ItemStack setName(ItemStack i, String n) {
|
||||||
@ -176,7 +138,7 @@ public class ItemUtils {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack Enchant(ItemStack i, Enchantment e, int l) {
|
public static ItemStack enchant(ItemStack i, Enchantment e, int l) {
|
||||||
ItemMeta meta = i.getItemMeta();
|
ItemMeta meta = i.getItemMeta();
|
||||||
meta.addEnchant(e, l, false);
|
meta.addEnchant(e, l, false);
|
||||||
i.setItemMeta(meta);
|
i.setItemMeta(meta);
|
||||||
@ -203,10 +165,7 @@ public class ItemUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String asString(String args, Player placeholderPlayer) {
|
public static String asString(String args, Player placeholderPlayer) {
|
||||||
if (placeholderPlayer == null) {
|
return placeholderPlayer == null ? args.replace("&", "§") : PlaceholderAPI.setPlaceholders(placeholderPlayer, args.replace("&", "§"));
|
||||||
return args.replace("&", "§");
|
|
||||||
}
|
|
||||||
return PlaceholderAPI.setPlaceholders(placeholderPlayer, args.replace("&", "§"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> asString(List<String> args, Player placeholderPlayer) {
|
public static List<String> asString(List<String> args, Player placeholderPlayer) {
|
||||||
@ -281,58 +240,30 @@ public class ItemUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static int getLore(ItemStack i, String a) {
|
||||||
* 包含介绍
|
return isLored(i) ? IntStream.range(0, i.getItemMeta().getLore().size()).filter(j -> i.getItemMeta().getLore().get(j).contains(a)).findFirst().orElse(0) : 0;
|
||||||
*
|
}
|
||||||
* @param i 物品
|
|
||||||
* @param a 关键字
|
|
||||||
*/
|
|
||||||
public static boolean hasLore(ItemStack i, String a) {
|
public static boolean hasLore(ItemStack i, String a) {
|
||||||
return isLored(i) && i.getItemMeta().getLore().toString().contains(a);
|
return isLored(i) && i.getItemMeta().getLore().toString().contains(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果已描述
|
|
||||||
*
|
|
||||||
* @param i
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static boolean isLored(ItemStack i) {
|
public static boolean isLored(ItemStack i) {
|
||||||
return i != null && i.getItemMeta() != null && i.getItemMeta().getLore() != null;
|
return i != null && i.getItemMeta() != null && i.getItemMeta().getLore() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 如果已命名
|
|
||||||
*
|
|
||||||
* @param i
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static boolean isNamed(ItemStack i) {
|
public static boolean isNamed(ItemStack i) {
|
||||||
return i != null && i.getItemMeta() != null && i.getItemMeta().getDisplayName() != null;
|
return i != null && i.getItemMeta() != null && i.getItemMeta().getDisplayName() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static ItemStack addLore(ItemStack is, String line) {
|
||||||
* 添加描述
|
|
||||||
*
|
|
||||||
* @param is 物品
|
|
||||||
* @param lore 描述
|
|
||||||
*/
|
|
||||||
public static ItemStack addLore(ItemStack is, String lore) {
|
|
||||||
ItemMeta meta = is.getItemMeta();
|
ItemMeta meta = is.getItemMeta();
|
||||||
|
List<String> lore = meta.hasLore() ? meta.getLore() : Collections.emptyList();
|
||||||
List<String> _lore = meta.hasLore() ? meta.getLore() : Collections.emptyList();
|
lore.add(TLocale.Translate.setColored(line));
|
||||||
_lore.add(lore.replaceAll("&", "§"));
|
|
||||||
|
|
||||||
is.setItemMeta(meta);
|
is.setItemMeta(meta);
|
||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 移除描述
|
|
||||||
*
|
|
||||||
* @param is 物品
|
|
||||||
* @param line 行数
|
|
||||||
*/
|
|
||||||
public static ItemStack delLore(ItemStack is, int line) {
|
public static ItemStack delLore(ItemStack is, int line) {
|
||||||
ItemMeta meta = is.getItemMeta();
|
ItemMeta meta = is.getItemMeta();
|
||||||
if (meta.hasLore()) {
|
if (meta.hasLore()) {
|
||||||
@ -346,40 +277,7 @@ public class ItemUtils {
|
|||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static ItemStack replaceLore(ItemStack i, String l1, String l2) {
|
||||||
* 获取介绍所在行数
|
|
||||||
*
|
|
||||||
* @param i 物品
|
|
||||||
* @param a 关键字
|
|
||||||
*/
|
|
||||||
public static int getLore(ItemStack i, String a) {
|
|
||||||
return isLored(i) ? IntStream.range(0, i.getItemMeta().getLore().size()).filter(j -> i.getItemMeta().getLore().get(j).contains(a)).findFirst().orElse(0) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加耐久
|
|
||||||
*
|
|
||||||
* @param i 物品
|
|
||||||
* @param d 耐久
|
|
||||||
*/
|
|
||||||
public static ItemStack addDurability(ItemStack i, int d) {
|
|
||||||
i.setDurability((short) (i.getDurability() + d));
|
|
||||||
int min = i.getDurability();
|
|
||||||
int max = i.getType().getMaxDurability();
|
|
||||||
if (min >= max) {
|
|
||||||
i.setType(Material.AIR);
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 替换描述
|
|
||||||
*
|
|
||||||
* @param i 物品
|
|
||||||
* @param l1 关键字1
|
|
||||||
* @param l2 关键字2
|
|
||||||
*/
|
|
||||||
public static ItemStack repalceLore(ItemStack i, String l1, String l2) {
|
|
||||||
if (!isLored(i)) {
|
if (!isLored(i)) {
|
||||||
return i;
|
return i;
|
||||||
} else {
|
} else {
|
||||||
@ -392,6 +290,16 @@ public class ItemUtils {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ItemStack addDurability(ItemStack i, int d) {
|
||||||
|
i.setDurability((short) (i.getDurability() + d));
|
||||||
|
int min = i.getDurability();
|
||||||
|
int max = i.getType().getMaxDurability();
|
||||||
|
if (min >= max) {
|
||||||
|
i.setType(Material.AIR);
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
public static ItemStack loadItem(FileConfiguration f, String s) {
|
public static ItemStack loadItem(FileConfiguration f, String s) {
|
||||||
return loadItem(f, s, null);
|
return loadItem(f, s, null);
|
||||||
}
|
}
|
||||||
@ -552,6 +460,62 @@ public class ItemUtils {
|
|||||||
return nbt;
|
return nbt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// *********************************
|
||||||
|
//
|
||||||
|
// Getter and Setter
|
||||||
|
//
|
||||||
|
// *********************************
|
||||||
|
|
||||||
|
public static FileConfiguration getItemDir() {
|
||||||
|
return itemDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LinkedHashMap<String, String> getItemLib() {
|
||||||
|
return itemLib;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FileConfiguration getItemCache() {
|
||||||
|
return itemCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static File getFinalItemsFolder() {
|
||||||
|
return finalItemsFolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LinkedHashMap<String, ItemStack> getItemCaches() {
|
||||||
|
return itemCaches;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LinkedHashMap<String, ItemStack> getItemCachesFinal() {
|
||||||
|
return itemCachesFinal;
|
||||||
|
}
|
||||||
|
|
||||||
|
// *********************************
|
||||||
|
//
|
||||||
|
// Deprecated
|
||||||
|
//
|
||||||
|
// *********************************
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public static FileConfiguration getItemdir() {
|
||||||
|
return itemDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public static LinkedHashMap<String, String> getItemlib() {
|
||||||
|
return itemLib;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public static ItemStack item(int n, int a, int d) {
|
||||||
|
return new ItemStack(n, a, (short) d);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public static ItemStack repalceLore(ItemStack i, String l1, String l2) {
|
||||||
|
return replaceLore(i, l1, l2);
|
||||||
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void putO(ItemStack item, Inventory inv, int i) {
|
public static void putO(ItemStack item, Inventory inv, int i) {
|
||||||
inv.setItem(i, item);
|
inv.setItem(i, item);
|
||||||
|
@ -3,8 +3,10 @@ package me.skymc.taboolib.inventory.builder;
|
|||||||
import com.ilummc.tlib.resources.TLocale;
|
import com.ilummc.tlib.resources.TLocale;
|
||||||
import me.skymc.taboolib.TabooLib;
|
import me.skymc.taboolib.TabooLib;
|
||||||
import me.skymc.taboolib.string.ArrayUtils;
|
import me.skymc.taboolib.string.ArrayUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.block.banner.Pattern;
|
import org.bukkit.block.banner.Pattern;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
@ -20,7 +22,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @Author sky
|
* @Author sky
|
||||||
* @Since 2018-08-22 11:37
|
* @Since 2018-08-22 11:37
|
||||||
* @BuilderVersion 1.0
|
* @BuilderVersion 1.1
|
||||||
*/
|
*/
|
||||||
public class ItemBuilder {
|
public class ItemBuilder {
|
||||||
|
|
||||||
@ -40,6 +42,11 @@ public class ItemBuilder {
|
|||||||
itemMeta = itemStack.getItemMeta();
|
itemMeta = itemStack.getItemMeta();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemBuilder(OfflinePlayer player) {
|
||||||
|
this(Material.SKULL_ITEM, 1, 3);
|
||||||
|
this.skullOwner(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
public ItemBuilder material(int id) {
|
public ItemBuilder material(int id) {
|
||||||
itemStack.setType(Material.getMaterial(id));
|
itemStack.setType(Material.getMaterial(id));
|
||||||
return this;
|
return this;
|
||||||
@ -147,6 +154,13 @@ public class ItemBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemBuilder skullOwner(String name) {
|
||||||
|
if (itemMeta instanceof SkullMeta) {
|
||||||
|
((SkullMeta) itemMeta).setOwner(name);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public ItemBuilder unbreakable(boolean value) {
|
public ItemBuilder unbreakable(boolean value) {
|
||||||
if (TabooLib.getVersionNumber() >= 12000) {
|
if (TabooLib.getVersionNumber() >= 12000) {
|
||||||
itemMeta.setUnbreakable(value);
|
itemMeta.setUnbreakable(value);
|
||||||
|
@ -2,6 +2,7 @@ package me.skymc.taboolib.itagapi;
|
|||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import me.skymc.taboolib.Main;
|
import me.skymc.taboolib.Main;
|
||||||
|
import me.skymc.taboolib.TabooLib;
|
||||||
import me.skymc.taboolib.packet.PacketUtils;
|
import me.skymc.taboolib.packet.PacketUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -132,7 +133,10 @@ public class TagDataHandler implements Listener {
|
|||||||
entryTeam.addEntry(playerData.getNameDisplay());
|
entryTeam.addEntry(playerData.getNameDisplay());
|
||||||
entryTeam.setPrefix(playerData.getPrefix());
|
entryTeam.setPrefix(playerData.getPrefix());
|
||||||
entryTeam.setSuffix(playerData.getSuffix());
|
entryTeam.setSuffix(playerData.getSuffix());
|
||||||
TagUtils.cleanEmptyTeamInScoreboard(scoreboard);
|
// 傻逼 BedWarsRel 我草你妈的
|
||||||
|
if (TabooLib.instance().getConfig().getBoolean("TABLIST-AUTO-CLEAN-TEAM", true)) {
|
||||||
|
TagUtils.cleanEmptyTeamInScoreboard(scoreboard);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cancelPlayerVariable(Player player, TagPlayerData playerData) {
|
private void cancelPlayerVariable(Player player, TagPlayerData playerData) {
|
||||||
@ -142,7 +146,10 @@ public class TagDataHandler implements Listener {
|
|||||||
for (Player online : Bukkit.getOnlinePlayers()) {
|
for (Player online : Bukkit.getOnlinePlayers()) {
|
||||||
Scoreboard scoreboard = TagUtils.getScoreboardComputeIfAbsent(player);
|
Scoreboard scoreboard = TagUtils.getScoreboardComputeIfAbsent(player);
|
||||||
TagUtils.cleanEntryInScoreboard(scoreboard, playerData.getNameDisplay());
|
TagUtils.cleanEntryInScoreboard(scoreboard, playerData.getNameDisplay());
|
||||||
TagUtils.cleanEmptyTeamInScoreboard(scoreboard);
|
// 傻逼 BedWarsRel 我草你妈的
|
||||||
|
if (TabooLib.instance().getConfig().getBoolean("TABLIST-AUTO-CLEAN-TEAM", true)) {
|
||||||
|
TagUtils.cleanEmptyTeamInScoreboard(scoreboard);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +164,7 @@ public class TagDataHandler implements Listener {
|
|||||||
downloadPlayerVariable(e.getPlayer());
|
downloadPlayerVariable(e.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler (priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onQuit(PlayerQuitEvent e) {
|
public void onQuit(PlayerQuitEvent e) {
|
||||||
cancelPlayerVariable(e.getPlayer(), unregisterPlayerData(e.getPlayer()));
|
cancelPlayerVariable(e.getPlayer(), unregisterPlayerData(e.getPlayer()));
|
||||||
}
|
}
|
||||||
|
@ -1,36 +1,19 @@
|
|||||||
package me.skymc.taboolib.skull;
|
package me.skymc.taboolib.skull;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import me.skymc.taboolib.inventory.builder.ItemBuilder;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public class SkullUtils {
|
public class SkullUtils {
|
||||||
|
|
||||||
public static ItemStack getItme(OfflinePlayer p ) {
|
public static ItemStack getItme(OfflinePlayer p) {
|
||||||
SkullMeta s = (SkullMeta) Bukkit.getItemFactory().getItemMeta(Material.SKULL_ITEM);
|
return new ItemBuilder(p).build();
|
||||||
s.setOwner(p.getName());
|
}
|
||||||
|
|
||||||
ItemStack i = new ItemStack(Material.SKULL_ITEM);
|
public static ItemStack getOnlineItem(OfflinePlayer p) {
|
||||||
i.setDurability((short) 3);
|
return p.isOnline() ? new ItemBuilder(p).build() : new ItemStack(Material.SKULL_ITEM);
|
||||||
i.setItemMeta(s);
|
}
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemStack getOnlineItem(OfflinePlayer p ) {
|
|
||||||
if (p.isOnline())
|
|
||||||
{
|
|
||||||
SkullMeta s = (SkullMeta) Bukkit.getItemFactory().getItemMeta(Material.SKULL_ITEM);
|
|
||||||
s.setOwner(p.getName());
|
|
||||||
|
|
||||||
ItemStack i = new ItemStack(Material.SKULL_ITEM);
|
|
||||||
i.setDurability((short) 3);
|
|
||||||
i.setItemMeta(s);
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
return new ItemStack(Material.SKULL_ITEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,13 @@ package me.skymc.taboolib.socket;
|
|||||||
|
|
||||||
import com.ilummc.tlib.resources.TLocale;
|
import com.ilummc.tlib.resources.TLocale;
|
||||||
import me.skymc.taboolib.TabooLib;
|
import me.skymc.taboolib.TabooLib;
|
||||||
|
import me.skymc.taboolib.commands.builder.SimpleCommandBuilder;
|
||||||
import me.skymc.taboolib.other.NumberUtils;
|
import me.skymc.taboolib.other.NumberUtils;
|
||||||
import me.skymc.taboolib.socket.packet.Packet;
|
import me.skymc.taboolib.socket.packet.Packet;
|
||||||
import me.skymc.taboolib.socket.packet.PacketSerializer;
|
import me.skymc.taboolib.socket.packet.PacketSerializer;
|
||||||
|
import me.skymc.taboolib.socket.packet.impl.PacketCommand;
|
||||||
|
import me.skymc.taboolib.socket.packet.impl.PacketMessage;
|
||||||
|
import me.skymc.taboolib.string.ArrayUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
@ -83,6 +87,23 @@ public class TabooLibClient {
|
|||||||
TLocale.sendToConsole("COMMUNICATION.FAILED-READING-PACKET", e.getMessage());
|
TLocale.sendToConsole("COMMUNICATION.FAILED-READING-PACKET", e.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
SimpleCommandBuilder.create("TabooLibClient", TabooLib.instance())
|
||||||
|
.aliases("tclient")
|
||||||
|
.permission("*")
|
||||||
|
.execute((sender, args) -> {
|
||||||
|
if (args.length == 0) {
|
||||||
|
sender.sendMessage("§c[TabooLibClient] §f/tclient message §7[TEXT] §8- §7发送测试信息");
|
||||||
|
sender.sendMessage("§c[TabooLibClient] §f/tclient command §7[TEXT] §8- §7发送测试命令");
|
||||||
|
} else if (args[0].equalsIgnoreCase("message") && args.length > 1) {
|
||||||
|
sendPacket(new PacketMessage(ArrayUtils.arrayJoin(args, 1)));
|
||||||
|
} else if (args[0].equalsIgnoreCase("command") && args.length > 1) {
|
||||||
|
sendPacket(new PacketCommand(ArrayUtils.arrayJoin(args, 1)));
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("§c[TabooLibClient] §7指令错误.");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
// *********************************
|
// *********************************
|
||||||
|
@ -55,7 +55,7 @@ public class TabooLibServer {
|
|||||||
/*
|
/*
|
||||||
检测无效的客户端连接,如果超过 5000 毫秒没有收到客户端的回应(上一次心跳包的回应)则注销链接
|
检测无效的客户端连接,如果超过 5000 毫秒没有收到客户端的回应(上一次心跳包的回应)则注销链接
|
||||||
*/
|
*/
|
||||||
client.entrySet().stream().filter(connection -> connection.getValue().isAlive()).map(connection -> new PacketQuit(connection.getKey(), "Lost connection")).forEach(TabooLibServer::sendPacket);
|
client.entrySet().stream().filter(connection -> !connection.getValue().isAlive()).map(connection -> new PacketQuit(connection.getKey(), "Lost connection")).forEach(TabooLibServer::sendPacket);
|
||||||
}, 0, 1, TimeUnit.SECONDS);
|
}, 0, 1, TimeUnit.SECONDS);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -76,7 +76,6 @@ public class TabooLibServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void sendPacket(String origin) {
|
public static void sendPacket(String origin) {
|
||||||
println("Packet sending: " + origin + ", online: " + client.size());
|
|
||||||
// 在服务端尝试解析动作并运行
|
// 在服务端尝试解析动作并运行
|
||||||
Optional.ofNullable(PacketSerializer.unSerialize(origin)).ifPresent(Packet::readOnServer);
|
Optional.ofNullable(PacketSerializer.unSerialize(origin)).ifPresent(Packet::readOnServer);
|
||||||
// 将动作发送至所有客户端
|
// 将动作发送至所有客户端
|
||||||
|
@ -0,0 +1,51 @@
|
|||||||
|
package me.skymc.taboolib.socket.packet.impl;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.ilummc.tlib.resources.TLocale;
|
||||||
|
import me.skymc.taboolib.socket.TabooLibServer;
|
||||||
|
import me.skymc.taboolib.socket.packet.Packet;
|
||||||
|
import me.skymc.taboolib.socket.packet.PacketType;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author sky
|
||||||
|
* @Since 2018-08-22 23:01
|
||||||
|
*/
|
||||||
|
@PacketType(name = "command")
|
||||||
|
public class PacketCommand extends Packet {
|
||||||
|
|
||||||
|
private String command;
|
||||||
|
|
||||||
|
public PacketCommand(int port) {
|
||||||
|
super(port);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PacketCommand(String command) {
|
||||||
|
super(Bukkit.getPort());
|
||||||
|
this.command = command;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readOnServer() {
|
||||||
|
String[] args = command.split(" ");
|
||||||
|
if (args[0].equalsIgnoreCase("online")) {
|
||||||
|
TabooLibServer.sendPacket(new PacketMessage(0, "Online: " + TabooLibServer.getClient().size()));
|
||||||
|
} else {
|
||||||
|
TabooLibServer.sendPacket(new PacketMessage(0, "Invalid arguments."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readOnClient() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serialize(JsonObject json) {
|
||||||
|
json.addProperty("command", this.command);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unSerialize(JsonObject json) {
|
||||||
|
this.command = json.get("command").getAsString();
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@ package me.skymc.taboolib.socket.packet.impl;
|
|||||||
import me.skymc.taboolib.socket.TabooLibClient;
|
import me.skymc.taboolib.socket.TabooLibClient;
|
||||||
import me.skymc.taboolib.socket.packet.Packet;
|
import me.skymc.taboolib.socket.packet.Packet;
|
||||||
import me.skymc.taboolib.socket.packet.PacketType;
|
import me.skymc.taboolib.socket.packet.PacketType;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author sky
|
* @Author sky
|
||||||
|
@ -5,6 +5,7 @@ import com.ilummc.tlib.resources.TLocale;
|
|||||||
import me.skymc.taboolib.socket.TabooLibServer;
|
import me.skymc.taboolib.socket.TabooLibServer;
|
||||||
import me.skymc.taboolib.socket.packet.Packet;
|
import me.skymc.taboolib.socket.packet.Packet;
|
||||||
import me.skymc.taboolib.socket.packet.PacketType;
|
import me.skymc.taboolib.socket.packet.PacketType;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author sky
|
* @Author sky
|
||||||
@ -24,9 +25,14 @@ public class PacketMessage extends Packet {
|
|||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PacketMessage(String message) {
|
||||||
|
super(Bukkit.getPort());
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readOnServer() {
|
public void readOnServer() {
|
||||||
TabooLibServer.println(message);
|
TabooLibServer.println(getPort() + ": " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -46,7 +46,7 @@ public class ClientConnection implements Runnable {
|
|||||||
/*
|
/*
|
||||||
连接丢失,客户端退出
|
连接丢失,客户端退出
|
||||||
*/
|
*/
|
||||||
TabooLibServer.sendPacket(new PacketQuit(socket.getPort(), e.getMessage()));
|
TabooLibServer.sendPacket(new PacketQuit(socket.getPort(), "SocketException: " + e.getMessage()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
TabooLibServer.println("Client running failed: " + e.toString());
|
TabooLibServer.println("Client running failed: " + e.toString());
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.skymc.taboolib.support;
|
package me.skymc.taboolib.support;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
@ -9,60 +10,59 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author AgarthaLib
|
||||||
|
*/
|
||||||
public class SupportWorldGuard {
|
public class SupportWorldGuard {
|
||||||
|
|
||||||
String Source_code_from_AgarthaLib;
|
|
||||||
private WorldGuardPlugin worldGuard;
|
private WorldGuardPlugin worldGuard;
|
||||||
|
|
||||||
public SupportWorldGuard() {
|
public SupportWorldGuard() {
|
||||||
final Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
|
Preconditions.checkNotNull(Bukkit.getServer().getPluginManager().getPlugin("WorldGuard"), "WorldGuard was not found.");
|
||||||
if (plugin != null) {
|
worldGuard = WorldGuardPlugin.inst();
|
||||||
this.worldGuard = (WorldGuardPlugin) plugin;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final WorldGuardPlugin getWorldGuard() {
|
public WorldGuardPlugin getWorldGuard() {
|
||||||
return this.worldGuard;
|
return this.worldGuard;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final RegionManager getRegionManager(final World world) {
|
public RegionManager getRegionManager(World world) {
|
||||||
return this.worldGuard.getRegionManager(world);
|
return this.worldGuard.getRegionManager(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isRegionManagerExists(final World world) {
|
public boolean isRegionManagerExists(World world) {
|
||||||
return this.getRegionManager(world) != null;
|
return this.getRegionManager(world) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Collection<String> getRegionIDs(final World world) {
|
public Collection<String> getRegionIDs(World world) {
|
||||||
final RegionManager regionManager = this.getRegionManager(world);
|
return getRegionManager(world).getRegions().keySet();
|
||||||
return regionManager.getRegions().keySet();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Collection<ProtectedRegion> getRegions(final World world) {
|
public Collection<ProtectedRegion> getRegions(World world) {
|
||||||
final RegionManager regionManager = this.getRegionManager(world);
|
return getRegionManager(world).getRegions().values();
|
||||||
return regionManager.getRegions().values();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ProtectedRegion getRegion(final World world, final String id) {
|
public List<String> getRegionsAtLocation(World world, Location location) {
|
||||||
final RegionManager regionManager = this.getRegionManager(world);
|
return getRegions(world).stream().filter(protectedRegion -> protectedRegion.contains(location.getBlockX(), location.getBlockY(), location.getBlockZ())).map(ProtectedRegion::getId).collect(Collectors.toList());
|
||||||
if (regionManager != null) {
|
|
||||||
for (final String key : regionManager.getRegions().keySet()) {
|
|
||||||
if (key.equalsIgnoreCase(id)) {
|
|
||||||
return regionManager.getRegion(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isRegionExists(final World world, final String id) {
|
public ProtectedRegion getRegion(World world, String id) {
|
||||||
|
RegionManager regionManager = this.getRegionManager(world);
|
||||||
|
return regionManager != null ? regionManager.getRegions().keySet().stream().filter(key -> key.equalsIgnoreCase(id)).findFirst().map(regionManager::getRegion).orElse(null) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRegionExists(World world, String id) {
|
||||||
return this.getRegion(world, id) != null;
|
return this.getRegion(world, id) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isPlayerInsideRegion(final ProtectedRegion region, final Player player) {
|
public boolean isPlayerInsideRegion(ProtectedRegion region, Player player) {
|
||||||
final Location location = player.getLocation();
|
Location location = player.getLocation();
|
||||||
return region.contains(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
return region.contains(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,9 +34,11 @@ LOCALE:
|
|||||||
# 如果需要开启仍然可以在语言文件中加入 papi: true
|
# 如果需要开启仍然可以在语言文件中加入 papi: true
|
||||||
USE_PAPI: false
|
USE_PAPI: false
|
||||||
|
|
||||||
# 玩家列表(TAB)是否根据前缀排序
|
# 玩家列表(TAB-API)是否根据前缀排序
|
||||||
# 启用后将会导致部分通过计分板获取玩家数据的插件出错(BedwarsRel、SkyWars)
|
TABLIST-SORT: true
|
||||||
TABLIST-SORT: false
|
|
||||||
|
# 玩家列表(TAB-API)是否自动清理没有成员的队伍
|
||||||
|
TABLIST-AUTO-CLEAN-TEAM: true
|
||||||
|
|
||||||
# 是否启用更新检测
|
# 是否启用更新检测
|
||||||
UPDATE-CHECK: true
|
UPDATE-CHECK: true
|
||||||
|
@ -569,6 +569,7 @@ COMMUNICATION:
|
|||||||
FAILED-CONNECT-CLIENT: '§8[§3§lTabooLibClient§8] &4本地通讯网络连接出错: {0}'
|
FAILED-CONNECT-CLIENT: '§8[§3§lTabooLibClient§8] &4本地通讯网络连接出错: {0}'
|
||||||
FAILED-READING-PACKET: '§8[§3§lTabooLibClient§8] &4本地通讯网络数据包读取失败: {0}'
|
FAILED-READING-PACKET: '§8[§3§lTabooLibClient§8] &4本地通讯网络数据包读取失败: {0}'
|
||||||
SUCCESS-CONNECTED: '§8[§3§lTabooLibClient§8] &7本地通讯网络连接成功.'
|
SUCCESS-CONNECTED: '§8[§3§lTabooLibClient§8] &7本地通讯网络连接成功.'
|
||||||
CLIENT-JOINED: '§8[§3§lTabooLibClient§8] &7服务器 &flocalhost:{0} &7加入本地通讯网络.'
|
CLIENT-JOINED: '§8[§3§lTabooLibClient§8] &7服务器 &f{0} &7加入本地通讯网络.'
|
||||||
CLIENT-QUITED: '§8[§3§lTabooLibClient§8] &7服务器 &flocalhost:{0} &7退出本地通讯网络.'
|
CLIENT-QUITED: '§8[§3§lTabooLibClient§8] &7服务器 &f{0} &7退出本地通讯网络.'
|
||||||
PACKET-MESSAGE: '§8[§3§lTabooLibClient§8] &7服务器 &flocalhost:{0} &7发送信息: &f{1}'
|
PACKET-MESSAGE: '§8[§3§lTabooLibClient§8] &7服务器 &f{0} &7发送信息: &f{1}'
|
||||||
|
PACKET-COMMAND: '§8[§3§lTabooLibClient§8] &7服务器 &f{0} &7运行命令: &f{1}'
|
Loading…
Reference in New Issue
Block a user