Taboolib 5.0 fully refactored & Not a plugin now.

This commit is contained in:
坏黑 2019-07-06 00:17:54 +08:00
parent dfae3001ef
commit ab3ed6bebe
335 changed files with 4225 additions and 12881 deletions

View File

@ -5,7 +5,7 @@ plugins {
id 'com.github.johnrengelman.shadow' version '4.0.4' id 'com.github.johnrengelman.shadow' version '4.0.4'
} }
group = 'me.skymc' group = 'me.skymc'
version = '4.86' version = '5.0'
sourceCompatibility = 1.8 sourceCompatibility = 1.8
targetCompatibility = 1.8 targetCompatibility = 1.8
@ -28,14 +28,11 @@ dependencies {
exclude(module: 'log4j') exclude(module: 'log4j')
} }
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.8' compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.8'
shadow group: 'com.zaxxer', name: 'HikariCP', version: '3.1.0'
shadow group: 'org.javalite', name: 'activejdbc', version: '2.0'
compile group: 'org.ow2.asm', name: 'asm', version: '7.0-beta' compile group: 'org.ow2.asm', name: 'asm', version: '7.0-beta'
compile group: 'com.google.code.gson', name: 'gson', version: '2.7' compile group: 'com.google.code.gson', name: 'gson', version: '2.7'
shadow group: 'com.h2database', name: 'h2', version: '1.4.197' shadow group: 'com.zaxxer', name: 'HikariCP', version: '3.1.0'
shadow group: 'me.clip', name: 'placeholderapi', version: '2.8.4'
shadow group: 'net.objecthunter', name: 'exp4j', version: '0.4.8'
shadow group: 'org.scala-lang', name: 'scala-library', version: '2.12.8' shadow group: 'org.scala-lang', name: 'scala-library', version: '2.12.8'
shadow group: 'me.clip', name: 'placeholderapi', version: '2.8.4'
shadow fileTree(dir: 'libs', includes: ['*.jar']) shadow fileTree(dir: 'libs', includes: ['*.jar'])
} }
@ -48,11 +45,11 @@ processResources {
inputs.property "version", project.version inputs.property "version", project.version
from(sourceSets.main.resources.srcDirs) { from(sourceSets.main.resources.srcDirs) {
include 'plugin.yml' include 'version'
expand 'version': project.version expand 'version': project.version
} }
from(sourceSets.main.resources.srcDirs) { from(sourceSets.main.resources.srcDirs) {
exclude 'plugin.yml' exclude 'version'
} }
} }

View File

@ -1,125 +0,0 @@
# UTF-8
# 错误代码:
# 0语言文件不存在
# 1语言文本不存在
# 10: 大标题语言类型识别异常
# 11: 动作栏语言类型识别异常
# 12: 动作栏重复次数异常
# 20: JSON 空文本异常
# 21: JSON 语言类型识别异常
# 30: 大标题不兼容当前版本服务器
# 31: 动作栏不兼容当前版本服务器
# 40: 语言文件类型异常
# 50: BOOK 语言类型指定 option 不存在
# 51: BOOK 语言类型识别异常
# 52: BOOK 语言类型 url 地址错误http:// or https://
# 60: JSON2 语言类型指定 option 不存在
# 61: JSON2 语言类型识别异常
# 正常提示
TEXT: '&f正常的提示'
# 多行正常提示
# 类型 [text] 可以省略不写
TEXT-MULTI:
- '[text]'
- '&f正常的提示 - 1'
- '&f正常的提示 - 2'
# JSON提示 + 占位符
# 占位符注释需要追加到第一行类型末尾
PAPI-TEXT:
- '[json][papi]'
- '&f变量提示, 玩家名称: %player_name%'
# JSON提示
JSON-NORMAL-TEXT:
- '[json]'
- '提示信息 - 1'
- ' text: 这是一个一般提示'
# JSON提示
JSON-COMMAND-TEXT:
- '[json]'
- '提示信息 - 2'
- ' text: 点击执行指令'
- ' command: /say %player% 牛逼'
# JSON提示
JSON-SUGGEST-TEXT:
- '[json]'
- '提示信息 - 3'
- ' text: 点击打印指令'
- ' suggest: /say %player% 牛逼'
# JSON提示
# [breka] 注释为 JSON 提示类型中的换行符
JSON-MULTILINE-TEXT:
- '[json]'
- '提示信息 - 4'
- ' text: 这是一段换行提示1'
- '&a (单行追加内容)'
- '[break]'
- '提示信息 - 6'
- ' text: 这是一段换行提示3'
- '&a (单行追加内容)'
# 大标题提示
TITLE-TEXT:
- '[title]'
- ' title: 大标题'
- ' subtitle: 小标题'
- ' stay: 10|40|10'
# 动作栏提示
ACTION-TEXT:
- '[action]'
- ' text: 动作栏提示'
- ' repeat: 10'
# 多类型混合
TITLE-ACTION-TEXT:
- '[title]'
- ' title: 大标题'
- ' subtitle: 小标题'
- ' stay: 10|40|10'
- '[action]'
- ' text: 动作栏提示'
- ' repeat: 10'
# 音效 + 文本提示
SOUND-TEXT:
- '[text]'
- '单行文本 - 1'
- '单行文本 - 2'
- '[sound]'
- '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: 显示文本'
# JSON2
JSON-NEW:
- '[json2]'
- '新 <@1> 内容 - 1'
- '新 <@1> 内容 - 2'
- '@option:1'
- ' text: JSON'
- ' showtext: 展示文本'

View File

@ -1,66 +0,0 @@
COMMAND-ERROR: '&8[&3&lTLM&8] &4指令错误'
COMMAND-HELP:
- ''
- '&b&l----- &3&lTaooLibraryModule Commands &b&l-----'
- ''
- '&f /tlm kit list &6- &e列出所有礼包'
- '&f /tlm kit reward &8[&7名称] &8<&7名称&8> &6- &e领取礼包'
- '&f /tlm kit reset &8[&7名称] &8<&7玩家&8> &6- &e刷新礼包'
- ''
- '&f /tlm inv list &6- &e列出所有保存的背包'
- '&f /tlm inv info &8[&7名称] &6- &e查看保存背包'
- '&f /tlm inv save &8[&7名称] &6- &e保存当前背包'
- '&f /tlm inv paste &8[&7名称] &8<&7玩家&8> &8<&7-b|a&8> &6- &e覆盖背包'
- '&f /tlm inv delete &8[&7名称] &6- &e删除保存背包'
- ''
- '&f /tlm list &6- &e列出所有模块'
- ''
- '&f /tlm reload &8[&7模块名|TLM|ALL&8] &6- &e列出所有模块'
- ''
# 3.58 增加
NOPERMISSION-HELP: '&8[&3&lTLM&8] &4你没有权限列出帮助命令'
NOPERMISSION-LIST: '&8[&3&lTLM&8] &4你没有权限这么做'
NOPERMISSION-RELOAD: '&8[&3&lTLM&8] &4你没有权限这么做'
NOPERMISSION-KIT-REWARD: '&8[&3&lTLM&8] &4你没有权限这么做'
NOPERMISSION-KIT-RESET: '&8[&3&lTLM&8] &4你没有权限这么做'
# 3.60 新增
NOPERMISSION-KIT-LIST: '&8[&3&lTLM&8] &4你没有权限这么做'
NOPERMISSION-INV: '&8[&3&lTLM&8] &4你没有权限这么做'
# 3.59 增加
KIT-EMPTY: '&8[&3&lTLM&8] &4参数错误'
KIT-NAME: '&8[&3&lTLM&8] &4请输入正确的礼包名称'
KIT-DISABLE: '&8[&3&lTLM&8] &4该模块尚未在配置文件中启用'
KIT-NOTFOUND: '&8[&3&lTLM&8] &4礼包 &c$kit &4不存在'
KIT-OFFLINE: '&8[&3&lTLM&8] &4玩家 &c$name &4不在线'
KIT-CONSOLE: '&8[&3&lTLM&8] &4后台不允许输入这个指令'
KIT-COOLDOWN: '&8[&3&lTLM&8] &4礼包 &c$kit &4正在冷却中'
KIT-DISPOSABLE: '&8[&3&lTLM&8] &4礼包 &c$kit &4只能领取一次'
KIT-RESET-ALL: '&8[&3&lTLM&8] &7礼包 &f$kit &7已刷新'
KIT-RESET-PLAYER: '&8[&3&lTLM&8] &7玩家 &f$player &7的礼包 &f$kit &7已刷新'
KIT-SUCCESS: '&8[&3&lTLM&8] &7礼包 &f$kit &7已领取'
KIT-PLACEHOLDER:
0: '&4模块未启用'
1: '&4礼包不存在'
2: '&8已领取'
3: '&a可领取'
4: '&4冷却中'
5: '&4无权限'
# 3.60 新增
KIT-LIST: '&8[&3&lTLM&8] &7当前礼包: &f$kits'
# 3.60 增加
INV-EMPTY: '&8[&3&lTLM&8] &4参数错误'
INV-DISABLE: '&8[&3&lTLM&8] &4该模块尚未在配置文件中启用'
INV-CONSOLE: '&8[&3&lTLM&8] &4该命令不允许控制台执行'
INV-NAME: '&8[&3&lTLM&8] &4请输入正确的背包名称'
INV-LIST: '&8[&3&lTLM&8] &7当前已保存背包: &f$name'
INV-NOTFOUND: '&8[&3&lTLM&8] &4背包 &c$name &4不存在'
INV-INFO-TITLE: '背包信息: $name'
INV-SAVE: '&8[&3&lTLM&8] &7背包 &f$name &7已保存!'
INV-OFFLINE: '&8[&3&lTLM&8] &4玩家 &c$name &4不在线'
INV-PASTE: '&8[&3&lTLM&8] &7背包 &f$name &7已覆盖到玩家 &f$player&7!'
INV-DELETE: '&8[&3&lTLM&8] &4背包 &c$name &4已删除'

View File

@ -1,14 +0,0 @@
# 指令配置
Commands:
# 配置序号(不可重复)
test:
# 输入命令
Input: '/kit'
# 替换命令
Replace: '/tlm kit'
# 替换模式(省略默认全部)
# ---------- #
# CONSOLE = 后台
# PLAYER = 玩家
# ---------- #
ReplaceMode: 'PLAYER'

View File

@ -1,34 +0,0 @@
# 礼包配置
Kits:
# 礼包名
kit_name:
# 礼包刷新时间
# ---------- #
# 1d = 1天
# 1h = 1小时
# 1m = 1分钟
# 1s = 1秒钟
# 时间之间用 ";" 分隔, 例如 1小时30分钟 = "1h;30m"
# ---------- #
Cooldown: '1d'
# 背包空间不足时物品是否掉落
FullDrop: true
# 是否只能领取一次
Disposable: false
# 礼包领取权限
Permission: 'taboolib.kit.kit_name'
# 礼包领取权限提示
Permission-message: '&4你没有权限领取这个礼包'
# 礼包内容
# 空格左侧为物品名,右侧为物品数量
Items:
- 'UnlimitSword 1'
# 礼包命令
Commands:
- 'say $player 领取了礼包 kit_name!'

View File

@ -1,35 +0,0 @@
# 时间检查器
TimeCycle:
# 检查器名称
cycle_name:
# 检查器周期
# ---------- #
# 1d = 1天
# 1h = 1小时
# 1m = 1分钟
# 1s = 1秒钟
# 时间之间用 ";" 分隔, 例如 1小时30分钟 = "1h;30m"
# ---------- #
Cycle: '1d'
# 更新配置
UpdateCommand:
- 'say 检查器 cycle_name 更新!'
# 初始化配置
Initialise:
# 初始化时间
# 特殊时间
# - DAY_OF_WEEK = 本周第几天 (最小1)
# - DAY_OF_MONTH = 本月第几天 (最小1)
InitialiseDate:
# 初始化时将小时设置为 0
- 'HOUR_OF_DAY=0'
# 初始化时将分钟设置为 0
- 'MINUTE=0'
# 初始化时将秒钟设置为 0
- 'SECOND=0'
# 初始化命令
InitialiseCommand:
- 'say 检查器 cycle_name 初始化完成!'

View File

@ -1,5 +0,0 @@
name: TabooLib
main: me.skymc.taboolib.bungee.TabooLibBungee
version: ${project.version}
author: [lzzelAliz, 坏黑]

View File

@ -1,8 +1,3 @@
# 权限不足时提示
NO-PERMISSION-MESSAGE: '&f&l(&4&l&f&l) &c你没有权利这么做'
# 不满足条件时提示
NO-CLAIM-MESSAGE: '&f&l(&4&l&f&l) &c你现在还不能这么做 &7(%s%&7)'
# 数据储存地址 # 数据储存地址
# 该配置将在启用数据库储存时失效 # 该配置将在启用数据库储存时失效
DATAURL: DATAURL:
@ -10,8 +5,6 @@ DATAURL:
PLAYER-DATA: 'plugins/TabooLib/playerdata/' PLAYER-DATA: 'plugins/TabooLib/playerdata/'
# 插件数据 # 插件数据
SERVER-DATA: 'plugins/TabooLib/serverdata/' SERVER-DATA: 'plugins/TabooLib/serverdata/'
# 物品数据(来自 ItemSave 插件)
ITEMDIR: 'plugins/Skript/scripts/config/item.yml'
# 语言文件相关设置 # 语言文件相关设置
LOCALE: LOCALE:
@ -24,13 +17,6 @@ LOCALE:
# 如果需要开启仍然可以在语言文件中加入 papi: true # 如果需要开启仍然可以在语言文件中加入 papi: true
USE_PAPI: false USE_PAPI: false
# 是否注入 PluginManager关闭后可能会导致部分功能出错。
PLUGIN-INJECTOR:
ENABLE: true
# 检测下面的插件并自动关闭注入
DISABLE-ON-PLUGIN-EXISTS:
- LuckPerms
# 是否在当前服务器启用交流网终端 # 是否在当前服务器启用交流网终端
# 启用后将会收到大量调试信息, 不建议使用 # 启用后将会收到大量调试信息, 不建议使用
SERVER: false SERVER: false
@ -44,18 +30,6 @@ TABLIST-SORT: true
# 玩家列表TAB-API是否自动清理没有成员的队伍 # 玩家列表TAB-API是否自动清理没有成员的队伍
TABLIST-AUTO-CLEAN-TEAM: true TABLIST-AUTO-CLEAN-TEAM: true
# 是否启用发包(禁用后会影响 tagDisplay() 方法的使用)
TABLIST-PACKET: true
# 是否启用更新检测
UPDATE-CHECK: true
# 是否启用自动更新
UPDATE-DOWNLOAD: false
# 是否启用附属插件异常拦截
EXCEPTION-MIRROR: true
# 是否在关闭服务器时清理玩家数据 # 是否在关闭服务器时清理玩家数据
# 该配置将在启用数据库储存时失效 # 该配置将在启用数据库储存时失效
DELETE-DATA: false DELETE-DATA: false
@ -69,30 +43,3 @@ DELETE-VARIABLE: false
# 是否以 UUID 的形式创建玩家数据 # 是否以 UUID 的形式创建玩家数据
# 不建议开启!除非用 TabooLib 储存的插件支持新版储存方式! # 不建议开启!除非用 TabooLib 储存的插件支持新版储存方式!
ENABLE-UUID: false ENABLE-UUID: false
# 是否隐藏保存数据的提示
HIDE-NOTIFY: true
# 数据库信息
# 该功能在当前版本下无法使用,请勿启用
MYSQL:
# 是否启用数据库
ENABLE: false
# 数据库地址
HOST: 'localhost'
# 数据库端口
PORT: 3306
# 数据库用户
USER: root
# 数据库密码
PASSWORD: ''
# 数据库名称
DATABASE: 'test'
# 数据表前缀
PREFIX: 'taboolib'
# 全局变量信息
PluginData:
# 检查更新间隔(单位:秒)
# 检查变量是否被其他服务器更新
CHECK-DELAY: 5

View File

@ -1,51 +0,0 @@
UnlimitSword:
material: DIAMOND_SWORD
name: '&b&nUnlimitSword'
lore:
- ''
- '&8&oAn sword of infinitely durable'
- '&8&oAnd hide attributes lore'
- ''
flags:
- HIDE_ATTRIBUTES
nbt:
Unbreakable: 1
ColorLeather:
material: LEATHER_CHESTPLATE
name: '&aLe&2at&3he&4r C&5he&6st&7pl&8at&9e'
lore:
- ''
- '&8&oA chestplate of colored'
- '&8&oAnd enchanted with &7DURABILITY I'
- ''
enchants:
DURABILITY: 1
color: 255-0-0
SpeedPotion:
material: POTION
name: '&1&nSpeed Potion'
lore:
- ''
- '&8&oA potion of &7SPEED I'
- '&8&oAnd not have Particles'
- ''
potions:
SPEED: 200-5
KingsAxe:
material: GOLD_AXE
name: '&e&nKingsAxe'
lore:
- ''
- '&6&o100 damage !!!'
- '&6&o30% speed !!!'
- ''
- '&e&oA knife a pupil !!!'
- ''
attributes:
mainhand:
damage: 100
speed: 30%

View File

@ -1,8 +1,6 @@
TRY-LOADING-LANG: '插件 {0} 尝试加载 {1} 作为语言文件' SUCCESS-LOADING-LANG-NORMAL: '成功为 {0} 加载 {1} 语言文件, 共 {2} 项'
SUCCESS-LOADING-LANG-NORMAL: '成功加载 {0} 插件的 {1} 语言文件, 共 {2} 项' SUCCESS-LOADING-LANG-UPDATE: '成功为 {0} 加载 {1} 语言文件, 共 {2} 项, 及 {3} 项新条目'
SUCCESS-LOADING-LANG-UPDATE: '成功加载 {0} 插件的 {1} 语言文件, 共 {2} 项, 及 {3} 项新条目'
ERROR-LOADING-LANG: '加载 {0} 插件的语言文件时发生异常:{1}' ERROR-LOADING-LANG: '加载 {0} 插件的语言文件时发生异常:{1}'
RELOADING-LANG: '正在重新载入 {0} 插件的语言文件'
FETCH-LOCALE-ERROR: '语言文件获取失败:{0}' FETCH-LOCALE-ERROR: '语言文件获取失败:{0}'
SEND-LOCALE-ERROR: '语言文件发送失败:{0}' SEND-LOCALE-ERROR: '语言文件发送失败:{0}'
LOCALE-ERROR-REASON: '原因:{0}' LOCALE-ERROR-REASON: '原因:{0}'

View File

@ -1,21 +1,3 @@
TLIB:
INJECTION-SUCCESS: '注入成功'
INJECTION-FAILED:
- '注入失败'
- '&c提前加载依赖于 TabooLib 的所有插件的相关功能'
INJECTION-DISABLED:
- '关闭注入'
- '&c提前加载依赖于 TabooLib 的所有插件的相关功能'
LOAD-FAIL-OFFLINE:
- '**********************************************'
- '** TabooLib-{0} 无法在您的服务器上使用'
- '**'
- '** 您的服务器尚未连接互联网导致本插件无法正常载入'
- '** 请使用离线版本或是手动下载依赖库文件'
- '**'
- '** 详情查阅: https://github.com/Bkm016/TabooLib'
- '**********************************************'
DEPENDENCY: DEPENDENCY:
DOWNLOAD-OFFLINE: '已启用离线模式, 将不会下载第三方依赖库' DOWNLOAD-OFFLINE: '已启用离线模式, 将不会下载第三方依赖库'
DOWNLOAD-CONNECTED: ' 正在下载 {0} 大小 {1}' DOWNLOAD-CONNECTED: ' 正在下载 {0} 大小 {1}'
@ -27,38 +9,7 @@ DEPENDENCY:
PLUGIN-AUTOLOAD-FAIL: '{0} 所依赖的插件 {1} 尝试自动加载失败,请尝试手动下载' PLUGIN-AUTOLOAD-FAIL: '{0} 所依赖的插件 {1} 尝试自动加载失败,请尝试手动下载'
PLUGIN-LOAD-SUCCESS: ' {0} 请求的插件 {1} 加载成功' PLUGIN-LOAD-SUCCESS: ' {0} 请求的插件 {1} 加载成功'
PLUGIN-LOAD-FAIL: ' {0} 请求的插件 {1} 加载失败' PLUGIN-LOAD-FAIL: ' {0} 请求的插件 {1} 加载失败'
LOADING-START: '正在加载 {0} 插件所需的依赖'
# LIBRARY-LOAD-SUCCESS: ' {0} 请求的库文件 {1} 加载成功'
LIBRARY-LOAD-FAIL: ' {0} 请求的库文件 {1} 加载失败' LIBRARY-LOAD-FAIL: ' {0} 请求的库文件 {1} 加载失败'
LOAD-COMPLETE: '依赖加载完成'
# LOAD-CLASSES: '&7缓存 &f{0} &7插件的 &f{1} &7个类耗时&f {2} &7毫秒.'
CONFIG:
LOAD-FAIL-NO-ANNOTATION: '插件 {0} 的配置类 {1} 加载失败:没有 @Config 注解'
LOAD-FAIL: '插件 {0} 的配置类 {1} 加载失败:没有 @Config 注解'
LOAD-FAIL-NO-FILE: '插件 {0} 的配置类 {1} 加载失败:没有 @Config 注解或文件不存在'
LOAD-SUCCESS: '插件 {0} 的 {1} 配置文件成功加载'
SAVE-FAIL-NO-ANNOTATION: '插件 {0} 的配置类 {1} 序列化失败:没有 @Config 注解'
SAVE-FAIL: '插件 {0} 的配置类 {1} 加载失败:没有 @Config 注解'
SAVE-SUCCESS: '插件 {0} 的配置 {1} 已保存'
RELOAD-SUCCESS: '插件 {0} 的配置 {1} 成功重载'
RELOAD-FAIL: '插件 {0} 的配置 {1} 成功重载'
LISTEN-START: '开始监听 {0} 插件的 {1} 配置文件'
NOTIFY:
ERROR-SERVER-KEY: '&4检测到本服序列号与其他服务器相同, 已重新生成!'
ERROR-CONNECTION-FAIL: '&4数据库连接失败, 请检查配置是否正确!'
SUCCESS-LOADED:
- '§7插件载入完成!'
- '§7插件作者: §f{0}'
- '§7插件版本: §f{1}'
- '§7游戏版本: §f{2}'
SUCCESS-DISABLE:
- '&c插件已卸载, 感谢您使用&4禁忌书库'
- '&c插件作者: &4坏黑'
FAIL-DISABLE:
- '&c插件尚未启动完成, 已跳过卸载代码'
- '&c插件作者: &4坏黑'
LOCALE: LOCALE:
TITLE-SEND-TO-NON-PLAYER: '该语言类型只能发送给玩家:{0}' TITLE-SEND-TO-NON-PLAYER: '该语言类型只能发送给玩家:{0}'
@ -74,27 +25,10 @@ MISC:
FIELD-COPY-FAILED: '拷贝 {0} 对象失败' FIELD-COPY-FAILED: '拷贝 {0} 对象失败'
FIELD-COPY-ERROR: '拷贝 {0} 对象出错:{1}' FIELD-COPY-ERROR: '拷贝 {0} 对象出错:{1}'
#COOLDOWNPACK:
# PACK-REGISTER: '注册冷却包: {0}, 时间: {1} 秒 ({2})'
# PACK-REGISTER-ANONYMOUS: '注册冷却包: {0}, 时间: {1} 秒 (匿名注册)'
# PACK-UNREGISTER: '注销冷却包: {0} (主动注销)'
# PACK-UNREGISTER-AUTO: '注销冷却包: {0} (自动注销)'
GLOBAL-DATAMANAGER:
ERROR-CHECK-VARIABLE: '&4变量 &c{0} &4载入异常: &c{1}'
SUCCESS-LOADED-VARIABLE: '&7从数据库中获取 &f{0} &7个变量, 耗时: &f{1} &7(ms)'
PLAYER-DATAMANAGER: PLAYER-DATAMANAGER:
ERROR-STORAGE-SQL: '不允许在储存模式为数据库的情况下获取离线玩家数据'
ERROR-PLAYER-DATA: '&4玩家 &c{0} &4的数据载入出现异常: &c{1}' ERROR-PLAYER-DATA: '&4玩家 &c{0} &4的数据载入出现异常: &c{1}'
SUCCESS-SAVE-DATA: '&7保存 &f{0} &7条玩家数据, 耗时: &f{1} &7(ms)' SUCCESS-SAVE-DATA: '&7保存 &f{0} &7条玩家数据, 耗时: &f{1} &7(ms)'
ENTITY-UTILS:
NOTFOUND-PROTOCOLLIB: '缺少前置插件 ProtocolLib'
FILE-UTILS:
FAIL-LOAD-CONFIGURATION: '&4配置文件载入失败!, 插件: &c{0}&4, 文件: &c{1}'
DATA-UTILS: DATA-UTILS:
SUCCESS-SAVE-DATA: '&7保存 &f{0} &7条插件数据, 耗时: &f{1} &7(ms)' SUCCESS-SAVE-DATA: '&7保存 &f{0} &7条插件数据, 耗时: &f{1} &7(ms)'
FAIL-SAVE-FILE: '&4文件 &c{0}&4 保存失败, 原因: &c{1}' FAIL-SAVE-FILE: '&4文件 &c{0}&4 保存失败, 原因: &c{1}'
@ -106,53 +40,14 @@ ITEM-UTILS:
FAIL-LOAD-POTION: '&c{0} &4不是一个有效的药水名称, 输入 &c/tlib potions&4 查看所有药水' FAIL-LOAD-POTION: '&c{0} &4不是一个有效的药水名称, 输入 &c/tlib potions&4 查看所有药水'
FAIL-LOAD-FLAG: '&c{0} &4不是一个有效的标签名称, 输入 &c/tlib flags&4 查看所有标签' FAIL-LOAD-FLAG: '&c{0} &4不是一个有效的标签名称, 输入 &c/tlib flags&4 查看所有标签'
FAIL-SAVE-EXISTS: '无法载入载入物品 &4{0}&c, 因为它已经存在了' FAIL-SAVE-EXISTS: '无法载入载入物品 &4{0}&c, 因为它已经存在了'
# SUCCESS-LOAD-CACHES: '&7载入 &f{0} &7项缓存物品'
# SUCCESS-LOAD-NAMES: '&7载入 &f{0} &7项物品名称'
EMPTY-ITEM: '空' EMPTY-ITEM: '空'
LANGUAGE2:
FAIL-NOTFOUND-FILE: '语言文件 {0} 不存在'
TIMECYCLE:
FAIL-CYCLE-EXISTS: '注册周期管理器 &8{0}&c 失败, 原因: &4名称重复'
UPDATETASK:
VERSION-FAIL: '&4更新记录获取失败, 请检查网络连接!'
VERSION-LATEST: '&7插件已是最新版, 无需更新!'
VERSION-OUTDATED:
- '&8####################################################'
- '&7 检测到有新的版本更新!'
- '&7 当前版本: &f{0}'
- '&7 最新版本: &f{1}'
- '&7 下载地址: &fhttp://www.mcbbs.net/thread-773065-1-1.html'
- '&7 开源地址: &fhttps://github.com/Bkm016/TabooLib/'
- '&8####################################################'
MYSQL-CONNECTION:
FAIL-CONNECT: '&4数据库 &c{0} &4连接失败, 原因: &c{0}'
FAIL-NOTFOUND-DRIVE: '&7驱动器获取失败, 无法连接到数据库'
FAIL-NOTFOUND-CONNECTION: '&7警告! 数据库尚未连接, 请检查配置文件后重启服务器! ({0})'
FAIL-COMMAND-NORMAL: '&4数据库命令执行出错, 错误原因: &c{0}'
FAIL-COMMAND-DETAIL: '&4数据库命令执行出错, 错误代码: &c{0}&4, 错误原因: &c{1}'
FAIL-EXECUTE-TASK: '异步任务失败, 执行方式改为同步执行'
SUCCESS-REGISTERED: '&7插件 &f{0}&7 注册新的数据库连接'
SUCCESS-REGISTERED-EXISTS: '&7插件 &f{0}&7 引用插件 &f{1}&7 注册的数据库连接'
SUCCESS-REGISTERED-LISTENER: '&7启动数据库连接监控'
SUCCESS-CONNECTION-CANCEL: '已停止插件 &f{0}&7 的 &f{1}&7 条数据库连接'
NOTIFY-CONNECTING: '&7正在连接数据库, 地址: &f{0}'
NOTIFY-CONNECTED: '&7数据库连接成功 ({0}ms)'
MYSQL-HIKARI: MYSQL-HIKARI:
CREATE-SUCCESS: '&7插件 &f{0}&7 注册新的数据库连接: &f{1}' CREATE-SUCCESS: '&7插件 &f{0}&7 注册新的数据库连接: &f{1}'
CREATE-EXISTS: '&7插件 &f{0}&7 引用插件 &f{1}&7 注册的数据库连接' CREATE-EXISTS: '&7插件 &f{0}&7 引用插件 &f{1}&7 注册的数据库连接'
CLOSE-SUCCESS: '&7插件 &f{0} &7注册的数据库连接 &f{1} &7已被注销!' CLOSE-SUCCESS: '&7插件 &f{0} &7注册的数据库连接 &f{1} &7已被注销!'
CLOSE-FAIL: '&7插件 &f{0} &7注册的数据库连接正在被 &f{1} &7个插件使用, 无法注销!' CLOSE-FAIL: '&7插件 &f{0} &7注册的数据库连接正在被 &f{1} &7个插件使用, 无法注销!'
TABOOLIB-MODULE:
SUCCESS-LOADED: '&7载入 &f{0} &7个 &fTLM &7模块'
FAIL-LOADED: '&4模块载入异常: &c{0}&4, 模块: &c{1}&4, 位于: &c{2}'
FAIL-RUNTIME: '&4模块运行异常: &c{0}&4, 模块: &c{1}&4, 位于: &c{2}'
COMMANDS: COMMANDS:
GLOBAL: GLOBAL:
ONLY-PLAYER: '&8[&3&lTabooLib&8] &4控制台无法这么做' ONLY-PLAYER: '&8[&3&lTabooLib&8] &4控制台无法这么做'
@ -169,9 +64,7 @@ COMMANDS:
- '&8[&3&lTabooLib&8] &7指令 &f{0} &7不存在' - '&8[&3&lTabooLib&8] &7指令 &f{0} &7不存在'
- '&8[&3&lTabooLib&8] &7你可能想要:' - '&8[&3&lTabooLib&8] &7你可能想要:'
- '&8[&3&lTabooLib&8] &7{1}' - '&8[&3&lTabooLib&8] &7{1}'
COMMAND-CREATE-FAILED: '&7插件 &f{0} &7的 &f{1} &7命令注册失败: &c{2}' COMMAND-CREATE-FAILED: '&c插件 &7{0} &c的 &7{1} &c命令注册失败: &7{2}'
# COMMAND-CREATE: '&7自动为插件 &f{0} &7的 &f{1} &7命令注册到服务器'
# COMMAND-REGISTER: '&7自动为插件 &f{0} &7的 &f{1} &7命令注册 &f{2} &7条子命令'
COMMAND-HELP: ' §f/{0} {1} {2}§6- §e{3}' COMMAND-HELP: ' §f/{0} {1} {2}§6- §e{3}'
COMMAND-HELP-EMPTY: ' §f/{0} {1} {2}' COMMAND-HELP-EMPTY: ' §f/{0} {1} {2}'
COMMAND-ARGUMENT: '§7<§8{0}§7>' COMMAND-ARGUMENT: '§7<§8{0}§7>'
@ -179,285 +72,6 @@ COMMANDS:
PARAMETER: PARAMETER:
UNKNOWN: '&8[&3&lTabooLib&8] &4指令错误' UNKNOWN: '&8[&3&lTabooLib&8] &4指令错误'
INSUFFICIENT: '&8[&3&lTabooLib&8] &4参数不足' INSUFFICIENT: '&8[&3&lTabooLib&8] &4参数不足'
RELOAD:
LOADING: '&8[&3&lTabooLib&8] &7重载中...'
SUCCESS-NORMAL: '&8[&3&lTabooLib&8] &7重载成功'
SUCCESS-ELAPSED-TIME: '&8[&3&lTabooLib&8] &7重载成功, 耗时: &f{0} ms'
TABOOLIB:
COMMAND-TITLE: '&e&l----- &6&lTabooLib Commands &e&l-----'
SAVE:
DESCRIPTION: '载入插件'
ARGUMENTS:
0: '名称'
INVALID-NAME: '&8[&3&lTabooLib&8] &4请输入正确的名称'
INVALID-ITEM: '&8[&3&lTabooLib&8] &4请手持正确的物品'
INVALID-ITEM-FINAL-EXISTS: '&8[&3&lTabooLib&8] &4该名称所对应的物品保存于固定物品库中, 无法覆盖'
GUIDE-EXISTS: '&8[&3&lTabooLib&8] &4你有一个正在进行的聊天引导, 请完成后在这么做'
GUIDE-BEFORE: '&8[&3&lTabooLib&8] &7物品 &f{0}&7 已存在, 如果你想要覆盖它, 请在聊天框中输入 "&fYES&7"'
GUIDE-QUIT: '&8[&3&lTabooLib&8] &7退出引导'
SUCCESS: '&8[&3&lTabooLib&8] &7物品 &f{0} &7已替换'
ITEM:
DESCRIPTION: '给予玩家物品'
ARGUMENTS:
0: '名称'
1: '玩家'
2: '数量'
INVALID-NAME: '&8[&3&lTabooLib&8] &4请输入正确的名称'
INVALID-ITEM: '&8[&3&lTabooLib&8] &4物品 &c{0} &4不存在'
INVALID-PLAYER: '&8[&3&lTabooLib&8] &4玩家 &c{0} &4不在线'
INVALID-NUMBER: '&8[&3&lTabooLib&8] &4数量必须大于0'
SUCCESS: '&8[&3&lTabooLib&8] &7物品已发送至玩家 &f{0} &7的背包中'
ITEMRELOAD:
DESCRIPTION: '重载物品缓存'
SUCCESS-RELOAD: '&8[&3&lTabooLib&8] &7重载成功'
VARIABLE:
DESCRIPTION:
GET: '查看变量'
SET: '设置变量'
ARGUMENTS:
GET:
0: '-s|-a'
1: '键'
SET:
0: '-s|-a'
1: '键'
2: '值'
WRITE-ERROR-TYPE: '&8[&3&lTabooLib&8] &4请输入正确的写入方式: &c-s&4、&c-a'
WRITE-SUCCESS: '&8[&3&lTabooLib&8] &7写入完成, 耗时: &f{0} &7(ms)'
READ-ERROR-TYPE: '&8[&3&lTabooLib&8] &4请输入正确的写入方式: &c-s&4、&c-a'
READ-RESULT: '&8[&3&lTabooLib&8] &7变量 &f{0} &7的值为: &f{1}'
READ-SUCCESS: '&8[&3&lTabooLib&8] &7写入完成, 耗时: &f{0} &7(ms)'
IMPORTDATA:
DESCRIPTION: '&4向数据库导入本地数据 &8(该操作将会清空数据库)'
CLEARING: '&8[&3&lTabooLib&8] &7正在清空数据库...'
EMPTYDATA: '&8[&3&lTabooLib&8] &4没有玩家数据可以导入'
IMPORTING-START: '&8[&3&lTabooLib&8] &7开始导入 &f{0} &7项玩家数据'
IMPORTING-PROGRESS: '&8[&3&lTabooLib&8] &7导入玩家数据: &f{0} &7进度: &f{1}/{2}'
SUCCESS: '&8[&3&lTabooLib&8] &7导入完成'
UPDATEPLUGIN:
DESCRIPTION: '&4更新插件 &8(谨防非正规途径的插件获取方式)'
UPDATE-NOT-FOUND: '&8[&3&lTabooLib&8] &7插件已是最新版, 无需更新!'
UPDATE-NOT-FOUND-SIZE: '&8[&3&lTabooLib&8] &4文件长度获取失败.'
UPDATE-NOT-SUPPORT: '&8[&3&lTabooLib&8] &4您的服务器不支持在线更新!'
UPDATE-SUCCESS: '&8[&3&lTabooLib&8] &7最新版下载完成, 服务器即将重启!'
UPDATE-FAILED: '&8[&3&lTabooLib&8] &4最新版下载失败.'
FILE-NOT-FOUND: '&8[&3&lTabooLib&8] &4尚未寻找到插件文件.'
PLAYER-ONLINE: '&8[&3&lTabooLib&8] &4服务器有玩家在线无法更新插件.'
ARGUMENTS:
0: '-f'
PLAYERTAG:
DESCRIPTION:
DISPLAY: '设置玩家展示名称'
PREFIX: '设置玩家头顶前缀'
SUFFIX: '设置玩家头顶后缀'
DELETE: '删除玩家称号数据'
ARGUMENTS:
DISPLAY:
0: '玩家'
1: '文本'
PREFIX:
0: '玩家'
1: '文本'
SUFFIX:
0: '玩家'
1: '文本'
DELETE:
0: '玩家'
INVALID-PLAYER: '&8[&3&lTabooLib&8] &4玩家 &c{0} &4不在线'
SUCCESS-DISPLAY-SET: '&8[&3&lTabooLib&8] &7设置玩家 &f{0} &7的名称为 &f{1}'
SUCCESS-PREFIX-SET: '&8[&3&lTabooLib&8] &7设置玩家 &f{0} &7的前缀为 &f{1}'
SUCCESS-SUFFIX-SET: '&8[&3&lTabooLib&8] &7设置玩家 &f{0} &7的后缀为 &f{1}'
SUCCESS-DELETE: '&8[&3&lTabooLib&8] &7删除玩家 &f{0} &7的称号数据'
LAGSERVER:
DESCRIPTION: '休眠主线程'
ARGUMENTS:
0: '毫秒'
INVALID-TIME: '&8[&3&lTabooLib&8] &4休眠时间不可超过 &c30000 &4毫秒'
START: '&8[&3&lTabooLib&8] &7线程休眠开始.'
STOP: '&8[&3&lTabooLib&8] &7线程休眠结束.'
INFO:
DESCRIPTION: '查看物品信息'
INVALID-ITEM: '&8[&3&lTabooLib&8] &4请手持正确的物品'
ITEM-INFO:
- ==: JSON
text:
- ''
- '&b&l----- &3&lItemStack Info &b&l-----'
- ''
- '&7 - 物品材质: &f<{0}@type>'
- '&7 - 物品名称: &f<{1}@name>'
- '&7 - 物品序号: &f<{2}@id>'
- '&7 - 物品数据: &f<NBT@nbt>'
- ''
args:
type:
hover: '&f点击复制'
suggest: '{0}'
name:
hover: '&f点击复制'
suggest: '{1}'
id:
hover: '&f点击复制'
suggest: '{2}'
nbt:
hover: '{3}'
ITEMLIST:
DESCRIPTION: '查看所有物品'
MENU:
TITLE: '物品库 {0}'
NEXT: '&f上一页'
BACK: '&f下一页'
LORE:
- ''
- '&f&m '
- '&f序列号: &8{0}'
SOUNDS:
DESCRIPTION: '查看所有音效'
MENU:
TITLE: '音效库 {0}'
NEXT: '&f上一页'
BACK: '&f下一页'
LORE:
- ''
- '&fQ键: &70 音调'
- '&f左键: &71 音调'
- '&f右键: &72 音调'
- '&f中键: &7复制名称'
RESULT:
SEARCH:
- '&7查询名称: &f{0}'
- '&7查询结果: &f{1}'
COPY:
- ==: JSON
text: '&7点击复制: <&f&n{0}@sound>'
args:
sound:
hover: 点击复制音效
suggest: '{0}'
TIMECYCLE:
DESCRIPTION:
LIST: '列出所有时间检查器'
INFO: '查询检查器信息'
RESET: '初始化时间检查器'
UPDATE: '更新时间检查器'
ARGUMENTS:
INFO:
0: '名称'
RESET:
0: '名称'
UPDATE:
0: '名称'
INVALID-CYCLE: '&8[&3&lTabooLib&8] &4检查器 &c{0} &4不存在'
CYCLE-UPDATE: '&8[&3&lTabooLib&8] &7检查器 &f{0} &7已更新'
CYCLE-RESET: '&8[&3&lTabooLib&8] &7检查器 &f{0} &7初始化完成'
CYCLE-INFO:
- ''
- '&b&l----- &3&lTimeCycle Info &b&l-----'
- ''
- ' &f- &7注册周期: &f{0}'
- ' &f- &7注册插件: &f{1}'
- ' &f- &7上次刷新时间: &f{2}'
- ' &f- &7下次刷新时间: &f{3}'
- ''
LIST:
HEAD:
- ''
- '&b&l----- &3&lTimeCycle List &b&l-----'
- ''
BODY:
- ==: JSON
text: ' &7- &f{0} <&8(点击复制)@copy>'
args:
copy:
hover: '&f点击复制'
suggest: '{0}'
FOOT:
- ''
ATTRIBUTES:
DESCRIPTION: '查看所有属性'
HEAD:
- ''
- '&b&l----- &3&lItemStack Attributes &b&l-----'
- ''
BODY:
- ==: JSON
text: ' &7- &f{0} <&8(点击复制)@copy>'
args:
copy:
hover: '&f点击复制'
suggest: '{0}'
FOOT:
- ''
ENCHANTS:
DESCRIPTION: '查看所有附魔'
HEAD:
- ''
- '&b&l----- &3&lItemStack Enchantments &b&l-----'
- ''
BODY:
- ==: JSON
text: ' &7- &f{0}. {1} <&8(点击复制)@copy>'
args:
copy:
hover: '&f点击复制'
suggest: '{1}'
FOOT:
- ''
POTIONS:
DESCRIPTION: '查看所有药水'
HEAD:
- ''
- '&b&l----- &3&lItemStack PotionEffects &b&l-----'
- ''
BODY:
- ==: JSON
text: ' &7- &f{0}. {1} <&8(点击复制)@copy>'
args:
copy:
hover: '&f点击复制'
suggest: '{1}'
FOOT:
- ''
FLAGS:
DESCRIPTION: '查看所有标签'
HEAD:
- ''
- '&b&l----- &3&lItemStack Flags &b&l-----'
- ''
BODY:
- ==: JSON
text: ' &7- &f{0} <&8(点击复制)@copy>'
args:
copy:
hover: '&f点击复制'
suggest: '{0}'
FOOT:
- ''
SLOTS:
DESCRIPTION: '查看所有部位'
HEAD:
- ''
- '&b&l----- &3&lItemStack Slots &b&l-----'
- ''
BODY:
- ==: JSON
text: ' &7- &f{0} <&8(点击复制)@copy>'
args:
copy:
hover: '&f点击复制'
suggest: '{0}'
FOOT:
- ''
LANGUAGE2:
INVALID-PLAYER: '&8[&3&lTabooLib&8] &4玩家 &c{0} &4不在线'
SUCCESS-SEND: '&8[&3&lTabooLib&8] &7信息已发送, 耗时&f: {0}'
HELP:
- ''
- '&e&l----- &6&lLanguage2 Commands &e&l-----'
- ''
- '&f /{0} send &8[&7玩家/ALL&8] &8[&7语言&8] &8<&7变量&8> &6- &e发送语言提示'
- '&f /{0} reload &6- &e重载语言库'
- ''
TLOCALE: TLOCALE:
COMMAND-TITLE: '&e&l----- &6&lTabooLibLoacle Commands &e&l-----' COMMAND-TITLE: '&e&l----- &6&lTabooLibLoacle Commands &e&l-----'
SEND: SEND:
@ -517,15 +131,6 @@ COMMANDS:
INVALID-PLUGIN: '&8[&3&lTabooLib&8] &4插件 &c{0} &4不存在' INVALID-PLUGIN: '&8[&3&lTabooLib&8] &4插件 &c{0} &4不存在'
INVALID-PLUGIN-IGNORED: '&8[&3&lTabooLib&8] &4插件 &c{0} &4无法操作' INVALID-PLUGIN-IGNORED: '&8[&3&lTabooLib&8] &4插件 &c{0} &4无法操作'
TRY-RELOAD: '&8[&3&lTabooLib&8] &7尝试重载插件...' TRY-RELOAD: '&8[&3&lTabooLib&8] &7尝试重载插件...'
TRANSLATE-UUID:
COMMAND-TITLE: '&e&l----- &6&lTranslateUUID Commands &e&l-----'
IMPORTLOCAL:
DESCRIPTION: '导入本地数据到数据库'
DISABLED: '&8[&3&lTabooLib&8] &4该功能尚未启用'
SUCCESS: '&8[&3&lTabooLib&8] &7请求已发送, 详细信息请查看控制台'
RELOAD:
DESCRIPTION: '重载配置及数据库'
SUCCESS: '&8[&3&lTabooLib&8] &7请求已发送, 详细信息请查看控制台'
TEXECUTE: TEXECUTE:
COMMAND-TITLE: '&e&l----- &6&lTabooLibExecute Commands &e&l-----' COMMAND-TITLE: '&e&l----- &6&lTabooLibExecute Commands &e&l-----'
CHAT: CHAT:
@ -566,81 +171,6 @@ COMMANDS:
0: '目录' 0: '目录'
1: '内容' 1: '内容'
SUCCESS: '&8[&3&lTabooLib&8] &7写入完成.' SUCCESS: '&8[&3&lTabooLib&8] &7写入完成.'
TCLOUD:
COMMAND-TITLE: '&e&l----- &6&lTabooLibCloud Commands &e&l-----'
REFRESH:
DESCRIPTION: '刷新扩展列表'
SUCCESS: '&8[&3&lTabooLib&8] &7请求已发送. &8(详细信息请在控制台查看)'
STATUS:
DESCRIPTION: '查看扩展统计'
STATUS:
- '&8[&3&lTabooLib&8] &7当前总共 &f{0} &7项扩展被 &fTCLOUD &7录入, 其中包含:'
- '&8[&3&lTabooLib&8] &7内置扩展 &f{1} &7项'
- '&8[&3&lTabooLib&8] &7插件扩展 &f{2} &7项'
CONNECT-FAILED: '&8[&3&lTabooLib&8] &c尚未获取扩展列表.'
INFO:
DESCRIPTION: '查看扩展信息'
ARGUMENTS:
0: '名称'
EXPANSION-NOT-FOUND: '&8[&3&lTabooLib&8] &c扩展 &4{0} &c不存在.'
EXPANSION-INFO:
- '&8[&3&lTabooLib&8] &7扩展 &f{0} &7信息:'
- '&8[&3&lTabooLib&8] &7作者 &f{1}'
- '&8[&3&lTabooLib&8] &7版本 &f{2}'
- '&8[&3&lTabooLib&8] &7描述 &f{3}'
- '&8[&3&lTabooLib&8] &7最后更新时间 &f{4}'
- '&8[&3&lTabooLib&8] &7最后更新内容 &f{5}'
EXPANSION-INFO-DETAIL:
0: '&8[&3&lTabooLib&8] &7详细描述'
1: '&8[&3&lTabooLib&8] &7- &f{0}'
DOWNLOAD:
DESCRIPTION: '下载扩展'
ARGUMENTS:
0: '名称'
EXPANSION-NOT-FOUND: '&8[&3&lTabooLib&8] &c扩展 &4{0} &c不存在.'
EXPANSION-EXISTS: '&8[&3&lTabooLib&8] &c扩展 &4{0} &c已存在.'
EXPANSION-VERSION: '&8[&3&lTabooLib&8] &c扩展 &4{0} &c需要 &4TabooLib v{1}&c 版本才可以使用!'
DOWNLOAD-START:
- '&8[&3&lTabooLib&8] &7扩展 &f{0} &7开始下载:'
- '&8[&3&lTabooLib&8] &7地址 &f{1}'
DOWNLOAD-SUCCESS: '&8[&3&lTabooLib&8] &7扩展 &f{0} &7下载完成, 请重启服务器.'
UPDATE:
DESCRIPTION: '更新扩展'
ARGUMENTS:
0: '名称'
EXPANSION-NOT-FOUND: '&8[&3&lTabooLib&8] &c扩展 &4{0} &c不存在.'
EXPANSION-NOT-EXISTS: '&8[&3&lTabooLib&8] &c扩展 &4{0} &c尚未下载.'
EXPANSION-NO-UPDATE: '&8[&3&lTabooLib&8] &7扩展 &f{0} &7已是最新版本.'
EXPANSION-VERSION: '&8[&3&lTabooLib&8] &c扩展 &4{0} &c需要 &4TabooLib v{1}&c 版本才可以使用!'
UPDATE-START:
- '&8[&3&lTabooLib&8] &7扩展 &f{0} &7开始更新:'
- '&8[&3&lTabooLib&8] &7版本 &f{1}'
- '&8[&3&lTabooLib&8] &7地址 &f{2}'
UPDATE-SUCCESS: '&8[&3&lTabooLib&8] &7扩展 &f{0} &7更新完成, 请重启服务器.'
LIST:
DESCRIPTION: '查看扩展列表'
ARGUMENTS:
0: 'PLUGINS/INTERNAL'
1: '页数'
INVALID-TYPE:
0: '&8[&3&lTabooLib&8] &c错误的扩展类型. &4(PLUGINS、INTERNAL)'
1: '&8[&3&lTabooLib&8] &c错误的页数.'
LIST-HEAD:
- ''
- '&e&l----- &6&lTabooLibCloud Expansions : &f{0} &6&l: &f{1}/{2} &e&l-----'
- ''
LIST-EXPANSION:
0: ' &f{0}. &8{1} &7{2}'
1: ' &f{0}. &c{1} &7{2}'
2: ' &f{0}. &a{1} &7{2}'
LIST-BOTTOM:
- ''
- ' &f> &8[未安装] &a[已安装] &c[可更新]'
- ''
DATABASE:
CONNECTION-ESTABLISHED: '成功连接到 {0} 数据库,连接池大小 {1}'
CONNECTION-ERROR: '连接到数据库错误:{0}'
COMMUNICATION: COMMUNICATION:
FAILED-LOAD-SETTINGS: '§8[§3§lTabooLibClient§8] &4配置载入失败: {0}' FAILED-LOAD-SETTINGS: '§8[§3§lTabooLibClient§8] &4配置载入失败: {0}'
@ -658,42 +188,3 @@ UTIL:
DOWNLOAD-PROGRESS: ' 下载速度 {0} 进度 {1}' DOWNLOAD-PROGRESS: ' 下载速度 {0} 进度 {1}'
DOWNLOAD-SUCCESS: '下载 {0} 完成!' DOWNLOAD-SUCCESS: '下载 {0} 完成!'
DOWNLOAD-FAILED: '下载 {0} 失败!' DOWNLOAD-FAILED: '下载 {0} 失败!'
TCLOUD:
LIST-LOAD-SUCCESS: '载入 &fTCLOUD &7扩展列表完成! 耗时 &f{0} &7毫秒'
LIST-LOAD-FAILED: '载入 &4{0} &c扩展数据失败: &4{1}'
LIST-PARSE-FAILED: '读取 &4TCLOUD &c扩展列表失败: &4{0}'
LIST-CONNECT-FAILED: '获取 &4TCLOUD &c扩展列表失败!'
TFILTER:
EXCEPTION-MIRROR:
EVENT:
HEAD:
- '&c插件 &4{0} &c执行事件时出现异常! &7(处理耗时: {1}ms)'
- '&c异常事件: &4{2}'
- '&c异常类型: &4{3}'
- '&c异常内容: &4{4}'
- '&c异常位置:'
STACK-TRACE: '&7 {0}. &4{1}'
COMMAND:
HEAD:
- '&c插件 &4{0} &c执行命令时出现异常! &7(处理耗时: {1}ms)'
- '&c异常命令: &4{2}'
- '&c异常类型: &4{3}'
- '&c异常内容: &4{4}'
- '&c异常位置:'
STACK-TRACE: '&7 {0}. &4{1}'
SCHEDULE:
HEAD:
- '&c插件 &4{0} &c执行任务时出现异常! &7(处理耗时: {1}ms)'
- '&c异常类型: &4{2}'
- '&c异常内容: &4{3}'
- '&c异常位置:'
STACK-TRACE: '&7 {0}. &4{1}'
OTHER:
HEAD:
- '&c插件 &4{0} &c运行时出现异常! &7(处理耗时: {1}ms)'
- '&c异常类型: &4{2}'
- '&c异常内容: &4{3}'
- '&c异常位置:'
STACK-TRACE: '&7 {0}. &4{1}'

View File

@ -1,10 +0,0 @@
# 语言文件
Language: 'zh_CN'
# 启用模块
# 该配置需要重启服务器才会生效
EnableModule:
#- 'Kits'
#- 'TimeCycle'
#- 'CommandChanger'
#- 'InventorySave'

View File

@ -1,10 +0,0 @@
§r
§r
§b________ §b______ §f______§8___________
§b___ __/§3_____ §b___ /§3_____________§f___ /§8___(_)__ /_
§b__ / §3_ __ `/§b_ __ \§3 __ \ __ \§f_ / §8__ /__ __ \
§b_ / §3/ /_/ /§b_ /_/ /§3 /_/ / /_/ /§f /___§8 / _ /_/ /
§b/_/ §3\__,_/ §b/_.___/§3\____/\____/§f/_____/§8_/ /_.___/
§r
§8version §f{0}
§r

View File

@ -1,14 +0,0 @@
name: TabooLib
main: me.skymc.taboolib.Main
version: ${version}
api-version: 1.13
authors:
- 坏黑
- lzzelAliz
softdepend:
- Vault
- PlaceholderAPI
- Skript
- MassiveLag

View File

@ -1,11 +0,0 @@
# 是否启用
Enable: false
# 数据库地址
Database:
host: 'localhost'
port: '3306'
user: 'root'
password: ''
database: 'test'
table: 'taboolib_translate_uuid_database'

View File

@ -0,0 +1 @@
${version}

View File

@ -1,114 +0,0 @@
package com.ilummc.tlib;
import com.ilummc.tlib.annotations.TConfig;
import com.ilummc.tlib.bean.Property;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.util.concurrent.TimeUnit;
@TConfig(name = "cfg.yml", charset = "GBK")
public class ExampleMain extends JavaPlugin {
private Property<Boolean> update = Property.of(false);
public static void main(String[] args) {
MemoryMXBean bean = ManagementFactory.getMemoryMXBean();
System.out.println(bean.getHeapMemoryUsage().toString());
System.out.println(bean.getNonHeapMemoryUsage().toString());
for (int i = 0; i < 10; i++) {
for (GarbageCollectorMXBean mxBean : ManagementFactory.getGarbageCollectorMXBeans()) {
System.out.println(mxBean.getName());
System.out.println(mxBean.getCollectionCount());
System.out.println(mxBean.getCollectionTime());
for (String s : mxBean.getMemoryPoolNames()) {
System.out.println(s);
}
System.out.println(mxBean.getObjectName().toString());
}
System.gc();
}
for (String s : ManagementFactory.getRuntimeMXBean().getInputArguments()) {
System.out.println(s);
}
}
@Override
public void onEnable() {
update.addListener(((oldVal, newVal) -> {
Bukkit.getLogger().info("配置项 enableUpdate 的值由 " + oldVal + " 变为了 " + newVal);
if (newVal) {
Updater.start();
} else {
Updater.stop();
}
}));
}
private static class Updater {
public static void start() {
}
public static void stop() {
}
}
private static class CD {
final long start, period;
final TimeUnit unit;
final Runnable onStart, onFinish, onTimer;
CD(long start, long period, TimeUnit unit, Runnable onStart, Runnable onFinish, Runnable onTimer) {
this.start = start;
this.period = period;
this.unit = unit;
this.onStart = onStart;
this.onFinish = onFinish;
this.onTimer = onTimer;
}
public static void main(String[] args) {
CD.builder().setOnStart(() -> {
}).setOnFinish(() -> {
}).setOnTimer(1000, TimeUnit.MILLISECONDS, () -> {
}).build();
}
public static CdBuilder builder() {
return new CdBuilder();
}
private static class CdBuilder {
private long start, period;
private TimeUnit unit;
private Runnable onStart, onFinish, onTimer;
public CdBuilder setOnStart(Runnable runnable) {
this.onStart = runnable;
return this;
}
public CdBuilder setOnFinish(Runnable runnable) {
this.onFinish = runnable;
return this;
}
public CdBuilder setOnTimer(long period, TimeUnit timeUnit, Runnable runnable) {
this.period = period;
this.unit = timeUnit;
this.onTimer = runnable;
return this;
}
public CD build() {
return new CD(start, period, unit, onStart, onFinish, onTimer);
}
}
}
}

View File

@ -1,137 +0,0 @@
package com.ilummc.tlib;
import com.ilummc.tlib.annotations.Dependency;
import com.ilummc.tlib.compat.PlaceholderHook;
import com.ilummc.tlib.config.TLibConfig;
import com.ilummc.tlib.db.Pool;
import com.ilummc.tlib.inject.TConfigWatcher;
import com.ilummc.tlib.inject.TDependencyInjector;
import com.ilummc.tlib.inject.TPluginManager;
import com.ilummc.tlib.logger.TLogger;
import com.ilummc.tlib.resources.TLocale;
import com.ilummc.tlib.resources.TLocaleLoader;
import com.ilummc.tlib.util.IO;
import me.skymc.taboolib.Main;
import me.skymc.taboolib.TabooLib;
import me.skymc.taboolib.fileutils.FileUtils;
import me.skymc.taboolib.plugin.PluginUtils;
import org.bukkit.Bukkit;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.nio.charset.Charset;
import java.util.Arrays;
@Dependency(type = Dependency.Type.LIBRARY, maven = "com.zaxxer:HikariCP:3.1.0")
@Dependency(type = Dependency.Type.LIBRARY, maven = "org.slf4j:slf4j-api:1.7.25")
@Dependency(type = Dependency.Type.LIBRARY, maven = "org.javalite:activejdbc:2.0")
@Dependency(type = Dependency.Type.LIBRARY, maven = "org.javalite:javalite-common:2.0")
@Dependency(type = Dependency.Type.LIBRARY, maven = "org.javalite:app-config:2.0")
@Dependency(type = Dependency.Type.LIBRARY, maven = "org.codehaus.jackson:jackson-mapper-asl:1.9.13")
@Dependency(type = Dependency.Type.LIBRARY, maven = "org.codehaus.jackson:jackson-core-asl:1.9.13")
@Dependency(type = Dependency.Type.LIBRARY, maven = "jaxen:jaxen:1.1.6")
@Dependency(type = Dependency.Type.LIBRARY, maven = "dom4j:dom4j:1.6.1")
@Dependency(type = Dependency.Type.LIBRARY, maven = "xml-apis:xml-apis:1.0.b2")
@Dependency(type = Dependency.Type.LIBRARY, maven = "org.ehcache:ehcache:3.5.2")
@Dependency(type = Dependency.Type.LIBRARY, maven = "com.h2database:h2:1.4.197")
public class TLib {
private static TLib tLib;
private static YamlConfiguration internalLanguage;
private TLogger logger = new TLogger("§8[§3§lTabooLib§8][§r{1}§8] §f{2}", Main.getInst(), TLogger.FINE);
private TLibConfig config;
private TConfigWatcher configWatcher = new TConfigWatcher();
private File libsFolder;
private TLib() {
libsFolder = new File(Main.getInst().getDataFolder(), "/libs");
if (!libsFolder.exists()) {
libsFolder.mkdirs();
}
try {
String yamlText = new String(IO.readFully(FileUtils.getResource("lang/internal.yml")), Charset.forName("utf-8"));
internalLanguage = new YamlConfiguration();
internalLanguage.loadFromString(yamlText);
} catch (IOException | InvalidConfigurationException ignored) {
}
}
public static void init() {
tLib = new TLib();
TLocaleLoader.init();
PlaceholderHook.init();
TLocaleLoader.load(Main.getInst(), false);
}
public static void initPost() {
TDependencyInjector.inject(Main.getInst(), TLib.getTLib());
try {
Pool.init();
} catch (Throwable ignored) {
}
}
public static void unload() {
try {
Pool.unload();
} catch (Throwable ignored) {
}
tLib.getConfigWatcher().unregisterAll();
TDependencyInjector.eject(Main.getInst(), tLib);
}
public static void injectPluginManager() {
if (!tLib.isInjectEnabled() || tLib.isBlackListPluginExists()) {
TLocale.Logger.warn("TLIB.INJECTION-DISABLED");
Arrays.stream(Bukkit.getPluginManager().getPlugins()).filter(plugin -> plugin != Main.getInst()).forEach(plugin -> TDependencyInjector.inject(plugin, plugin));
return;
}
try {
Field field = Bukkit.getServer().getClass().getDeclaredField("pluginManager");
field.setAccessible(true);
field.set(Bukkit.getServer(), new TPluginManager());
TLocale.Logger.info("TLIB.INJECTION-SUCCESS");
} catch (NoSuchFieldException | IllegalAccessException | IllegalArgumentException ignored) {
TLocale.Logger.error("TLIB.INJECTION-FAILED");
Arrays.stream(Bukkit.getPluginManager().getPlugins()).filter(plugin -> !TabooLib.isTabooLib(plugin)).forEach(plugin -> TDependencyInjector.inject(plugin, plugin));
}
}
public static TLib getTLib() {
return tLib;
}
public static YamlConfiguration getInternalLanguage() {
return internalLanguage;
}
public TLogger getLogger() {
return logger;
}
public TLibConfig getConfig() {
return config;
}
public TConfigWatcher getConfigWatcher() {
return configWatcher;
}
public File getLibsFolder() {
return libsFolder;
}
public boolean isInjectEnabled() {
return Main.getInst().getConfig().getBoolean("PLUGIN-INJECTOR.ENABLE", true);
}
public boolean isBlackListPluginExists() {
return Main.getInst().getConfig().getStringList("PLUGIN-INJECTOR.DISABLE-ON-PLUGIN-EXISTS").stream().anyMatch(PluginUtils::isPluginExists);
}
}

View File

@ -1,16 +0,0 @@
package com.ilummc.tlib.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Logger {
String value() default "[{0}|{1}§f] {2}";
int level() default com.ilummc.tlib.logger.TLogger.INFO;
}

View File

@ -1,13 +0,0 @@
package com.ilummc.tlib.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface PluginInstance {
String value();
}

View File

@ -1,29 +0,0 @@
package com.ilummc.tlib.annotations;
import com.ilummc.tlib.util.Ref;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Modifier;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface TConfig {
String name() default "config.yml";
boolean fromJar() default false;
boolean saveOnExit() default false;
boolean readOnly() default true;
String charset() default "UTF-8";
boolean listenChanges() default false;
int excludeModifiers() default Modifier.STATIC | Modifier.TRANSIENT | Ref.ACC_SYNTHETIC | Ref.ACC_BRIDGE;
}

View File

@ -1,11 +0,0 @@
package com.ilummc.tlib.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface TLocalePlugin {
}

View File

@ -1,17 +0,0 @@
package com.ilummc.tlib.annotations.clr;
import java.lang.annotation.*;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(CommandHandlers.class)
public @interface CommandHandler {
/**
* Name of the command
*
* @return Name of the command
*/
String value();
}

View File

@ -1,14 +0,0 @@
package com.ilummc.tlib.annotations.clr;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface CommandHandlers {
CommandHandler[] value();
}

View File

@ -1,14 +0,0 @@
package com.ilummc.tlib.annotations.clr;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Sub {
String value();
}

View File

@ -1,11 +0,0 @@
package com.ilummc.tlib.annotations.db;
public @interface Database {
boolean sharedPool() default true;
int poolSize() default 8;
Class<?> configClass();
}

View File

@ -1,4 +0,0 @@
package com.ilummc.tlib.annotations.db;
public @interface DatabasePassword {
}

View File

@ -1,4 +0,0 @@
package com.ilummc.tlib.annotations.db;
public @interface DatabaseType {
}

View File

@ -1,4 +0,0 @@
package com.ilummc.tlib.annotations.db;
public @interface DatabaseUrl {
}

View File

@ -1,4 +0,0 @@
package com.ilummc.tlib.annotations.db;
public @interface DatabaseUser {
}

View File

@ -1,14 +0,0 @@
package com.ilummc.tlib.annotations.db;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface SQLTable {
String value();
}

View File

@ -1,43 +0,0 @@
package com.ilummc.tlib.bean;
import java.util.ArrayList;
import java.util.List;
import java.util.function.BiConsumer;
public class Property<T> {
private Property(T value) {
this.value = value;
}
private List<BiConsumer<T, T>> consumers;
private T value;
public void set(T value) {
if (value != this.value) {
if (consumers != null) {
for (BiConsumer<T, T> consumer : consumers) {
consumer.accept(this.value, value);
}
}
this.value = value;
}
}
public T get() {
return value;
}
public void addListener(BiConsumer<T, T> consumer) {
if (consumers == null) {
consumers = new ArrayList<>();
}
consumers.add(consumer);
}
public static <T> Property<T> of(T value) {
return new Property<>(value);
}
}

View File

@ -1,16 +0,0 @@
package com.ilummc.tlib.bean;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import java.lang.reflect.Type;
public class PropertyTypeAdaptor implements JsonDeserializer<Property> {
@Override
public Property deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException {
return null;
}
}

View File

@ -1,7 +0,0 @@
package com.ilummc.tlib.clr;
public class CommandLineResolver {
}

View File

@ -1,59 +0,0 @@
package com.ilummc.tlib.config;
import com.ilummc.tlib.annotations.TConfig;
import java.util.HashMap;
import java.util.Map;
/**
* @author sky
* @since 2018-04-22 14:31:11
*/
@TConfig(name = "tlib.yml")
public class TLibConfig {
private String dataSourceClassName;
private String jdbcUrl = "jdbc:h2:file:~/plugins/TabooLib/h2";
private String driverClassName;
private String username = "";
private String password = "";
private int maximumPoolSize = 4;
private Map<String, Object> settings = new HashMap<String, Object>() {{
put("cachePrepStmts", true);
put("useServerPrepStmts", true);
}};
public String getDataSourceClassName() {
return dataSourceClassName;
}
public String getJdbcUrl() {
return jdbcUrl;
}
public String getDriverClassName() {
return driverClassName;
}
public String getUsername() {
return username;
}
public String getPassword() {
return password;
}
public int getMaximumPoolSize() {
return maximumPoolSize;
}
public Map<String, Object> getSettings() {
return settings;
}
}

View File

@ -1,63 +0,0 @@
package com.ilummc.tlib.db;
import com.ilummc.tlib.TLib;
import com.ilummc.tlib.resources.TLocale;
import org.javalite.activejdbc.Base;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
public final class Pool extends ThreadPoolExecutor {
private static final AtomicInteger number = new AtomicInteger(1);
private static final Pool singleton = new Pool();
private final TLibDataSource dataSource;
private Pool() {
super(TLib.getTLib().getConfig().getMaximumPoolSize(),
TLib.getTLib().getConfig().getMaximumPoolSize(),
0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>());
try {
dataSource = new TLibDataSource();
this.setThreadFactory(r -> new Thread(() -> {
Base.open(dataSource.getDataSource());
r.run();
}, "TabooLib-DbPool-" + number.getAndIncrement()));
prestartAllCoreThreads();
TLocale.sendToConsole("DATABASE.CONNECTION-ESTABLISHED", dataSource.getDataSource().getConnection().getMetaData().getDatabaseProductName(),
String.valueOf(TLib.getTLib().getConfig().getMaximumPoolSize()));
} catch (Exception e) {
TLocale.sendToConsole("DATABASE.CONNECTION-ERROR", e.toString());
throw new RuntimeException();
}
}
public static void run(Runnable runnable) {
instance().execute(runnable);
}
public static void init() {
}
public static void unload() {
instance().dataSource.disconnect();
instance().shutdown();
}
public static Pool instance() {
return singleton;
}
@Override
protected void afterExecute(Runnable r, Throwable t) {
if (t != null) {
Base.close();
}
}
}

View File

@ -1,35 +0,0 @@
package com.ilummc.tlib.db;
import com.ilummc.tlib.TLib;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.javalite.activejdbc.Base;
import javax.sql.DataSource;
import java.util.Properties;
public class TLibDataSource {
private final HikariDataSource dataSource;
TLibDataSource() {
Properties properties = new Properties();
properties.put("jdbcUrl", TLib.getTLib().getConfig().getJdbcUrl());
properties.put("username", TLib.getTLib().getConfig().getUsername());
properties.put("password", TLib.getTLib().getConfig().getPassword());
properties.put("dataSourceClassName", TLib.getTLib().getConfig().getDataSourceClassName());
properties.put("driverClassName", TLib.getTLib().getConfig().getDriverClassName());
TLib.getTLib().getConfig().getSettings().forEach((k, v) -> properties.put("dataSource." + k, v));
dataSource = new HikariDataSource(new HikariConfig(properties));
Base.open(dataSource);
}
public DataSource getDataSource() {
return dataSource;
}
public void disconnect() {
Base.close();
}
}

View File

@ -1,80 +0,0 @@
package com.ilummc.tlib.dependency;
import com.ilummc.eagletdl.EagletTask;
import com.ilummc.eagletdl.ProgressEvent;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.Main;
import java.io.File;
import java.util.concurrent.atomic.AtomicBoolean;
public class TDependency {
// 阿里 http://maven.aliyun.com/nexus/content/groups/public
// Maven Central
public static final String MAVEN_REPO = "http://repo1.maven.org/maven2";
/**
* 请求一个插件作为依赖这个插件将会在所有已经添加的 Jenkins 仓库Maven 仓库寻找
* <p>
* 阻塞线程进行下载/加载
*
* @param args 插件名称下载地址可选
* @return 是否成功加载了依赖
*/
public static boolean requestPlugin(String... args) {
return false;
}
/**
* 请求一个库作为依赖这个库将会在 Maven Centraloss.sonatype 以及自定义的 Maven 仓库寻找
* <p>
* 阻塞线程进行下载/加载
*
* @param type 依赖名格式为 groupId:artifactId:version
* @return 是否成功加载库如果加载成功插件将可以任意调用使用的类
*/
public static boolean requestLib(String type, String repo, String url) {
if (type.matches(".*:.*:.*")) {
String[] arr = type.split(":");
File file = new File(Main.getInst().getDataFolder(), "/libs/" + String.join("-", arr) + ".jar");
if (file.exists()) {
TDependencyLoader.addToPath(Main.getInst(), file);
return true;
} else {
if (downloadMaven(repo, arr[0], arr[1], arr[2], file, url)) {
TDependencyLoader.addToPath(Main.getInst(), file);
return true;
} else {
return false;
}
}
}
return false;
}
private static boolean downloadMaven(String url, String groupId, String artifactId, String version, File target, String dl) {
if (Main.isOfflineVersion()) {
TLocale.Logger.warn("DEPENDENCY.DOWNLOAD-OFFLINE");
return false;
}
AtomicBoolean failed = new AtomicBoolean(false);
String link = dl.length() == 0 ? url + "/" + groupId.replace('.', '/') + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + ".jar" : dl;
new EagletTask()
.url(link)
.file(target)
.setThreads(1)
.setOnError(event -> event.getException().printStackTrace())
.setOnConnected(event -> TLocale.Logger.info("DEPENDENCY.DOWNLOAD-CONNECTED", String.join(":", new String[] {groupId, artifactId, version}), ProgressEvent.format(event.getContentLength())))
.setOnProgress(event -> TLocale.Logger.info("DEPENDENCY.DOWNLOAD-PROGRESS", event.getSpeedFormatted(), event.getPercentageFormatted()))
.setOnComplete(event -> {
if (event.isSuccess()) {
TLocale.Logger.info("DEPENDENCY.DOWNLOAD-SUCCESS", String.join(":", new String[] {groupId, artifactId, version}));
} else {
failed.set(true);
TLocale.Logger.error("DEPENDENCY.DOWNLOAD-FAILED", String.join(":", new String[] {groupId, artifactId, version}), link, target.getName());
}
}).start().waitUntil();
return !failed.get();
}
}

View File

@ -1,32 +0,0 @@
package com.ilummc.tlib.dependency;
import org.bukkit.plugin.Plugin;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
public class TDependencyLoader {
public static synchronized void addToPath(Plugin plugin, URL url) {
try {
Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
method.setAccessible(true);
method.invoke(plugin.getClass().getClassLoader(), url);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
}
public static synchronized void addToPath(Plugin plugin, File file) {
try {
addToPath(plugin, file.toURI().toURL());
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
}

View File

@ -1,102 +0,0 @@
package com.ilummc.tlib.filter;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.ilummc.tlib.filter.impl.FilterConfiguration;
import com.ilummc.tlib.filter.impl.FilterInvalidPluginLoader;
import me.skymc.taboolib.TabooLib;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.logging.Filter;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
/**
* @author Bkm016
* @since 2018-04-22
*/
public class TLoggerFilter implements Filter {
private Filter filter;
private Logger logger;
private static List<TLoggerFilterHandler> handlers = Lists.newLinkedList();
private static Map<String, TLoggerFilter> pluginFilter = Maps.newHashMap();
private static TLoggerFilter globalFilter;
private static String playerConnectionName;
static {
handlers.add(new FilterConfiguration());
handlers.add(new FilterInvalidPluginLoader());
// handlers.add(new FilterExceptionMirror());
}
public static void preInit() {
inject(new TLoggerFilter(), Bukkit.getLogger());
inject(new TLoggerFilter(), TabooLib.instance().getLogger());
try {
playerConnectionName = Class.forName("net.minecraft.server." + TabooLib.getVersion() + ".PlayerConnection").getName();
} catch (Exception ignored) {
}
}
public static void postInit() {
Arrays.stream(Bukkit.getPluginManager().getPlugins()).filter(TabooLib::isDependTabooLib).forEach(plugin -> inject(new TLoggerFilter(), plugin.getLogger()));
}
public static void inject0() {
inject(new TLoggerFilter(), Logger.getLogger(playerConnectionName));
}
public static void inject(TLoggerFilter filter, Logger logger) {
if (!(logger.getFilter() instanceof TLoggerFilter)) {
try {
filter.filter = logger.getFilter();
filter.logger = logger;
logger.setFilter(filter);
} catch (Exception e) {
e.printStackTrace();
}
}
}
public static void eject(Plugin plugin) {
try {
if (plugin.getLogger().getFilter() instanceof TLoggerFilter) {
((TLoggerFilter) plugin.getLogger().getFilter()).filter = null;
((TLoggerFilter) plugin.getLogger().getFilter()).logger = null;
plugin.getLogger().setFilter(null);
}
} catch (Throwable t) {
t.printStackTrace();
}
}
public static TLoggerFilter getGlobalFilter() {
return globalFilter;
}
public static Map<String, TLoggerFilter> getPluginFilter() {
return pluginFilter;
}
public static List<TLoggerFilterHandler> getHandlers() {
return handlers;
}
public Filter getFilter() {
return filter;
}
public Logger getLogger() {
return logger;
}
@Override
public boolean isLoggable(LogRecord e) {
return handlers.stream().allMatch(filter -> filter.isLoggable(e)) && (filter == null || filter.isLoggable(e));
}
}

View File

@ -1,13 +0,0 @@
package com.ilummc.tlib.filter;
import java.util.logging.LogRecord;
/**
* @Author 坏黑
* @Since 2018-11-29 11:42
*/
public abstract class TLoggerFilterHandler {
abstract public boolean isLoggable(LogRecord e);
}

View File

@ -1,28 +0,0 @@
package com.ilummc.tlib.filter.impl;
import com.ilummc.tlib.filter.TLoggerFilterHandler;
import java.util.Arrays;
import java.util.logging.LogRecord;
/**
* @Author 坏黑
* @Since 2018-11-29 11:47
*/
public class FilterConfiguration extends TLoggerFilterHandler {
@Override
public boolean isLoggable(LogRecord e) {
if (String.valueOf(e.getMessage()).contains("Cannot load configuration from stream")) {
StackTraceElement[] elements = Thread.currentThread().getStackTrace();
for (StackTraceElement element : elements) {
if (element.getClassName().contains("ConfigUtils")) {
// Bukkit 拦截异常我再扔一个
System.out.println(Arrays.asList(e.getParameters()));
}
}
return false;
}
return true;
}
}

View File

@ -1,119 +0,0 @@
package com.ilummc.tlib.filter.impl;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.ilummc.tlib.filter.TLoggerFilterHandler;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.Main;
import me.skymc.taboolib.TabooLib;
import org.bukkit.command.CommandException;
import org.bukkit.event.EventException;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.LogRecord;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @Author 坏黑
* @Since 2018-11-29 11:42
*/
public class FilterExceptionMirror extends TLoggerFilterHandler {
interface ArgumentsCallback {
String[] run();
}
private static Pattern patternEvent = Pattern.compile("Could not pass event (.+?) to (.+?)");
private static Pattern patternCommand = Pattern.compile("Unhandled exception executing command '(.+?)' in plugin (.+?)");
/**
* 判断是否为调度器异常
*/
public boolean isScheduleException(LogRecord log) {
return String.valueOf(log.getMessage()).contains("generated an exception");
}
/**
* 是否为可捕捉异常
*/
public boolean isValidException(Throwable throwable) {
return throwable.getCause() != null && throwable.getCause().getStackTrace() != null && throwable.getCause().getStackTrace().length > 0;
}
/**
* 向控制台打印捕捉到的异常
*
* @param stackTraceElements 堆栈
* @param message 信息类型
* @param args 信息参数
* @return 是否成功捕捉并打印
*/
public boolean printException(AtomicReference<Plugin> plugin, StackTraceElement[] stackTraceElements, String message, ArgumentsCallback args) {
Set<Plugin> plugins = Sets.newHashSet();
List<StackTraceElement> stackTraces = Lists.newLinkedList();
for (StackTraceElement stack : stackTraceElements) {
try {
plugins.add(JavaPlugin.getProvidingPlugin(Class.forName(stack.getClassName())));
stackTraces.add(stack);
} catch (Exception ignored) {
}
}
if (!plugins.isEmpty() && plugins.stream().allMatch(p -> TabooLib.isTabooLib(p) || TabooLib.isDependTabooLib(p))) {
plugin.set(plugins.iterator().next());
TLocale.Logger.error("TFILTER.EXCEPTION-MIRROR." + message + ".HEAD", args.run());
for (int i = 0; i < stackTraces.size(); i++) {
StackTraceElement stack = stackTraces.get(i);
TLocale.Logger.error("TFILTER.EXCEPTION-MIRROR." + message + ".STACK-TRACE", String.valueOf(i), stack.toString());
}
return true;
}
return false;
}
@Override
public boolean isLoggable(LogRecord e) {
if (!Main.getInst().getConfig().getBoolean("EXCEPTION-MIRROR", true) || e.getThrown() == null) {
return true;
}
// 是否为调度器异常
if (isScheduleException(e)) {
long time = System.currentTimeMillis();
AtomicReference<Plugin> plugin = new AtomicReference<>();
return !printException(plugin, e.getThrown().getStackTrace(), "SCHEDULE", () -> new String[] {plugin.get().getName(), String.valueOf(System.currentTimeMillis() - time), e.getThrown().getClass().getSimpleName(), String.valueOf(e.getThrown().getMessage())});
}
// 是否为其他可捕捉异常
else if (isValidException(e.getThrown())) {
// 事件异常
if (e.getThrown() instanceof EventException) {
Matcher matcher = patternEvent.matcher(e.getMessage());
if (matcher.find()) {
long time = System.currentTimeMillis();
AtomicReference<Plugin> plugin = new AtomicReference<>();
return !printException(plugin, e.getThrown().getCause().getStackTrace(), "EVENT", () -> new String[] {plugin.get().getName(), String.valueOf(System.currentTimeMillis() - time), matcher.group(1), e.getThrown().getCause().getClass().getSimpleName(), String.valueOf(e.getThrown().getCause().getMessage())});
}
}
// 命令异常
else if (e.getThrown() instanceof CommandException) {
Matcher matcher = patternCommand.matcher(e.getThrown().getMessage());
if (matcher.find()) {
long time = System.currentTimeMillis();
AtomicReference<Plugin> plugin = new AtomicReference<>();
return !printException(plugin, e.getThrown().getCause().getStackTrace(), "COMMAND", () -> new String[] {plugin.get().getName(), String.valueOf(System.currentTimeMillis() - time), matcher.group(1), e.getThrown().getCause().getClass().getSimpleName(), String.valueOf(e.getThrown().getCause().getMessage())});
}
}
// 其他异常
else {
long time = System.currentTimeMillis();
AtomicReference<Plugin> plugin = new AtomicReference<>();
return !printException(plugin, e.getThrown().getCause().getStackTrace(), "OTHER", () -> new String[] {plugin.get().getName(), String.valueOf(System.currentTimeMillis() - time), e.getThrown().getCause().getClass().getSimpleName(), String.valueOf(e.getThrown().getCause().getMessage())});
}
}
return true;
}
}

View File

@ -1,18 +0,0 @@
package com.ilummc.tlib.filter.impl;
import com.ilummc.tlib.filter.TLoggerFilterHandler;
import java.util.logging.LogRecord;
/**
* @Author 坏黑
* @Since 2018-11-29 11:47
*/
public class FilterInvalidPluginLoader extends TLoggerFilterHandler {
@Override
public boolean isLoggable(LogRecord e) {
// 屏蔽插件加载器注入导致的警告信息
return !String.valueOf(e.getMessage()).contains("Enabled plugin with unregistered PluginClassLoader");
}
}

View File

@ -1,143 +0,0 @@
package com.ilummc.tlib.inject;
import com.google.common.io.Files;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.ilummc.tlib.annotations.TConfig;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.fileutils.ConfigUtils;
import org.apache.commons.lang3.Validate;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import org.yaml.snakeyaml.DumperOptions;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;
public class TConfigInjector {
public static void fixUnicode(YamlConfiguration configuration) {
try {
Field field = YamlConfiguration.class.getDeclaredField("yamlOptions");
field.setAccessible(true);
field.set(configuration, NoUnicodeDumperOption.INSTANCE);
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
}
private static final class NoUnicodeDumperOption extends DumperOptions {
private static final NoUnicodeDumperOption INSTANCE = new NoUnicodeDumperOption();
@Override
public void setAllowUnicode(boolean allowUnicode) {
super.setAllowUnicode(false);
}
@Override
public boolean isAllowUnicode() {
return false;
}
@Override
public void setLineBreak(LineBreak lineBreak) {
super.setLineBreak(LineBreak.getPlatformLineBreak());
}
}
public static Object loadConfig(Plugin plugin, Class<?> clazz) {
try {
TConfig config = clazz.getAnnotation(TConfig.class);
Validate.notNull(config);
File file = new File(plugin.getDataFolder(), config.name());
if (!file.exists()) {
if (config.fromJar()) {
plugin.saveResource(config.name(), true);
} else {
saveConfig(plugin, clazz.newInstance());
}
}
Object obj = unserialize(plugin, clazz);
if (config.readOnly()) {
saveConfig(plugin, obj);
}
return obj;
} catch (NullPointerException e) {
TLocale.Logger.warn("CONFIG.LOAD-FAIL-NO-ANNOTATION", plugin.toString(), clazz.getSimpleName());
} catch (Exception e) {
TLocale.Logger.warn("CONFIG.LOAD-FAIL", plugin.toString(), clazz.getSimpleName());
}
return null;
}
public static void reloadConfig(Plugin plugin, Object object) {
try {
TConfig config = object.getClass().getAnnotation(TConfig.class);
Validate.notNull(config);
File file = new File(plugin.getDataFolder(), config.name());
Map<String, Object> map = ConfigUtils.confToMap(ConfigUtils.loadYaml(plugin, file));
Object obj = ConfigUtils.mapToObj(map, object);
if (config.readOnly()) {
saveConfig(plugin, obj);
}
} catch (NullPointerException e) {
TLocale.Logger.warn("CONFIG.LOAD-FAIL-NO-ANNOTATION", plugin.toString(), object.getClass().getSimpleName());
} catch (Exception e) {
TLocale.Logger.warn("CONFIG.LOAD-FAIL", plugin.toString(), object.getClass().getSimpleName());
}
}
public static Object unserialize(Plugin plugin, Class<?> clazz) {
try {
TConfig config = clazz.getAnnotation(TConfig.class);
Validate.notNull(config);
return ConfigUtils.confToObj(
ConfigUtils.mapToConf(
ConfigUtils.yamlToMap(
Files.toString(new File(plugin.getDataFolder(), config.name()), Charset.forName(config.charset())))), clazz);
} catch (NullPointerException e) {
TLocale.Logger.warn("CONFIG.LOAD-FAIL-NO-FILE", plugin.toString(), clazz.getSimpleName());
return null;
} catch (Exception e) {
try {
return clazz.newInstance();
} catch (InstantiationException | IllegalAccessException e1) {
TLocale.Logger.warn("CONFIG.LOAD-FAIL", plugin.toString(), clazz.getSimpleName());
return null;
}
}
}
public static Map<String, Object> serialize(Plugin plugin, Object object) {
try {
TConfig config = object.getClass().getAnnotation(TConfig.class);
Validate.notNull(config);
return ConfigUtils.objToMap(ConfigUtils.objToConf(object).getValues(false), config.excludeModifiers());
} catch (NullPointerException e) {
TLocale.Logger.warn("CONFIG.SAVE-FAIL-NO-ANNOTATION", plugin.toString(), object.getClass().getSimpleName());
} catch (Exception e) {
TLocale.Logger.warn("CONFIG.SAVE-FAIL", plugin.toString(), object.getClass().getSimpleName());
}
return null;
}
public static void saveConfig(Plugin plugin, Object object) throws IOException, NullPointerException {
TConfig config = object.getClass().getAnnotation(TConfig.class);
Validate.notNull(config);
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
Map map = gson.fromJson(gson.toJson(object), HashMap.class);
YamlConfiguration configuration = (YamlConfiguration) ConfigUtils.mapToConf(map);
File target = new File(plugin.getDataFolder(), config.name());
if (!target.exists()) {
target.createNewFile();
}
byte[] arr = configuration.saveToString().getBytes(config.charset());
Files.write(arr, target);
}
}

View File

@ -1,188 +0,0 @@
package com.ilummc.tlib.inject;
import com.ilummc.tlib.TLib;
import com.ilummc.tlib.annotations.*;
import com.ilummc.tlib.dependency.TDependency;
import com.ilummc.tlib.resources.TLocale;
import com.ilummc.tlib.resources.TLocaleLoader;
import com.ilummc.tlib.util.Ref;
import me.skymc.taboolib.TabooLib;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
/**
* @author Izzel_Aliz
*/
public class TDependencyInjector {
private static List<String> injected = new ArrayList<>();
static void injectOnEnable(Plugin plugin) {
inject(plugin, plugin);
}
static void ejectOnDisable(Plugin plugin) {
eject(plugin, plugin);
}
public static boolean injected(Plugin plugin) {
return injected.contains(plugin.getName());
}
public static void inject(Plugin plugin, Object o) {
if (!injected.contains(plugin.getName())) {
injected.add(plugin.getName());
TLocaleLoader.load(plugin, true);
injectDependencies(plugin, o);
injectLogger(plugin, o);
injectConfig(plugin, o);
injectPluginInstance(plugin, o);
}
}
public static void eject(Plugin plugin, Object o) {
try {
injected.remove(plugin.getName());
ejectConfig(plugin, o);
} catch (Throwable ignored) {
}
}
public static Dependency[] getDependencies(Object o) {
Dependency[] dependencies = new Dependency[0];
Dependencies d = o.getClass().getAnnotation(Dependencies.class);
if (d != null) {
dependencies = d.value();
}
Dependency d2 = o.getClass().getAnnotation(Dependency.class);
if (d2 != null) {
dependencies = new Dependency[] {d2};
}
return dependencies;
}
private static void ejectConfig(Plugin plugin, Object o) {
for (Field field : Ref.getDeclaredFields(o.getClass())) {
TConfig config;
if ((config = field.getType().getAnnotation(TConfig.class)) != null && config.saveOnExit()) {
try {
field.setAccessible(true);
TConfigInjector.saveConfig(plugin, field.get(o));
TLocale.Logger.info("CONFIG.SAVE-SUCCESS", plugin.toString(), config.name());
} catch (Exception e) {
TLocale.Logger.warn("CONFIG.SAVE-FAIL", plugin.toString(), config.name());
e.printStackTrace();
}
}
}
}
private static void injectConfig(Plugin plugin, Object o) {
for (Field field : Ref.getDeclaredFields(o.getClass())) {
try {
TConfig config;
if ((config = field.getType().getAnnotation(TConfig.class)) != null) {
field.setAccessible(true);
Object obj = TConfigInjector.loadConfig(plugin, field.getType());
if (obj != null) {
TLocale.Logger.info("CONFIG.LOAD-SUCCESS", plugin.toString(), config.name());
field.set(o, obj);
if (config.listenChanges()) {
TLocale.Logger.info("CONFIG.LISTEN-START", plugin.toString(), config.name());
TLib.getTLib().getConfigWatcher().addOnListen(
new File(plugin.getDataFolder(), config.name()),
obj,
object -> {
try {
TConfigInjector.reloadConfig(plugin, object);
TLocale.Logger.info("CONFIG.RELOAD-SUCCESS", plugin.toString(), config.name());
} catch (Exception ignored) {
TLocale.Logger.warn("CONFIG.RELOAD-FAIL", plugin.toString(), config.name());
}
}
);
}
}
}
} catch (Exception ignored) {
}
}
}
private static void injectLogger(Plugin plugin, Object o) {
for (Field field : Ref.getDeclaredFields(o.getClass())) {
try {
Logger logger;
if ((logger = field.getAnnotation(Logger.class)) != null) {
field.getType().asSubclass(com.ilummc.tlib.logger.TLogger.class);
com.ilummc.tlib.logger.TLogger tLogger = new com.ilummc.tlib.logger.TLogger(logger.value(), plugin, logger.level());
if (!field.isAccessible()) {
field.setAccessible(true);
}
field.set(o, tLogger);
TLoggerManager.setDefaultLogger(plugin, tLogger);
}
} catch (Exception ignored2) {
}
}
}
private static void injectPluginInstance(Plugin plugin, Object o) {
for (Field field : Ref.getDeclaredFields(o.getClass())) {
try {
PluginInstance instance;
if ((instance = field.getAnnotation(PluginInstance.class)) != null) {
if (!field.isAccessible()) {
field.setAccessible(true);
}
field.getType().asSubclass(JavaPlugin.class);
Plugin pl;
if ((pl = Bukkit.getPluginManager().getPlugin(instance.value())) == null) {
if (!TDependency.requestPlugin(instance.value())) {
TLocale.Logger.warn("PLUGIN-AUTOLOAD-FAIL", plugin.getName(), instance.value());
return;
} else {
pl = Bukkit.getPluginManager().getPlugin(instance.value());
}
}
if (pl != null) {
field.set(o, pl);
}
}
} catch (Exception ignored) {
}
}
}
private static void injectDependencies(Plugin plugin, Object o) {
Dependency[] dependencies = getDependencies(o);
if (dependencies.length != 0) {
TLocale.Logger.info("DEPENDENCY.LOADING-START", plugin.getName());
for (Dependency dependency : dependencies) {
if (dependency.type() == Dependency.Type.PLUGIN) {
if (TDependency.requestPlugin(dependency.plugin())) {
TabooLib.debug(" Loaded " + dependency.plugin() + " (" + plugin.getName() + ")");
// TLocale.Logger.info("DEPENDENCY.PLUGIN-LOAD-SUCCESS", plugin.getName(), dependency.plugin());
} else {
TLocale.Logger.warn("DEPENDENCY.PLUGIN-LOAD-FAIL", plugin.getName(), dependency.plugin());
}
}
if (dependency.type() == Dependency.Type.LIBRARY) {
if (TDependency.requestLib(dependency.maven(), dependency.mavenRepo(), dependency.url())) {
TabooLib.debug(" Loaded " + String.join(":", dependency.maven()) + " (" + plugin.getName() + ")");
// TLocale.Logger.info("DEPENDENCY.LIBRARY-LOAD-SUCCESS", plugin.getName(), String.join(":", dependency.maven()));
} else {
TLocale.Logger.warn("DEPENDENCY.LIBRARY-LOAD-FAIL", plugin.getName(), String.join(":", dependency.maven()));
}
}
}
TLocale.Logger.info("DEPENDENCY.LOAD-COMPLETE");
}
}
}

View File

@ -1,231 +0,0 @@
package com.ilummc.tlib.inject;
import com.ilummc.tlib.resources.TLocale;
import me.skymc.taboolib.Main;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.event.Event;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.permissions.Permissible;
import org.bukkit.permissions.Permission;
import org.bukkit.plugin.*;
import java.io.File;
import java.lang.reflect.Field;
import java.util.*;
import java.util.regex.Pattern;
@SuppressWarnings("unused")
public class TPluginManager implements PluginManager {
private static TPluginManager singleton;
private final PluginManager instance;
private final Main main = (Main) Main.getInst();
private static File updateDirectory = null;
private Server server;
private Map<Pattern, PluginLoader> fileAssociations = new HashMap<>();
private List<Plugin> plugins = new ArrayList<>();
private Map<String, Plugin> lookupNames = new HashMap<>();
private SimpleCommandMap commandMap;
private Map<String, Permission> permissions = new HashMap<>();
private Map<Boolean, Set<Permission>> defaultPerms = new LinkedHashMap<>();
private Map<String, Map<Permissible, Boolean>> permSubs = new HashMap<>();
private Map<Boolean, Map<Permissible, Boolean>> defSubs = new HashMap<>();
private boolean useTimings = false;
private List<Plugin> delayedDisable = new ArrayList<>();
public static void delayDisable(Plugin plugin) {
if (!singleton.delayedDisable.contains(plugin)) {
singleton.delayedDisable.add(plugin);
}
}
public TPluginManager() {
instance = Bukkit.getPluginManager();
// clone all Field in SimplePluginManager
cloneField("updateDirectory");
cloneField("server");
cloneField("fileAssociations");
cloneField("plugins");
cloneField("lookupNames");
cloneField("commandMap");
cloneField("permissions");
cloneField("defaultPerms");
cloneField("permSubs");
cloneField("defSubs");
cloneField("useTimings");
singleton = this;
}
private void cloneField(String bukkitName) {
try {
Field bukkitField = instance.getClass().getDeclaredField(bukkitName);
Field thisFiled = this.getClass().getDeclaredField(bukkitName);
if (bukkitField == null || thisFiled == null) {
TLocale.Logger.warn("MISC.FIELD-COPY-FAILED", bukkitName);
return;
}
bukkitField.setAccessible(true);
thisFiled.setAccessible(true);
thisFiled.set(this, bukkitField.get(instance));
} catch (Exception e) {
TLocale.Logger.error("MISC.FIELD-COPY-ERROR", bukkitName, e.toString());
}
}
@Override
public void registerInterface(Class<? extends PluginLoader> aClass) throws IllegalArgumentException {
instance.registerInterface(aClass);
}
@Override
public Plugin getPlugin(String s) {
return instance.getPlugin(s);
}
@Override
public Plugin[] getPlugins() {
return instance.getPlugins();
}
@Override
public boolean isPluginEnabled(String s) {
return instance.isPluginEnabled(s);
}
@Override
public boolean isPluginEnabled(Plugin plugin) {
return instance.isPluginEnabled(plugin);
}
@Override
public Plugin loadPlugin(File file) throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException {
return instance.loadPlugin(file);
}
@Override
public Plugin[] loadPlugins(File file) {
return instance.loadPlugins(file);
}
@Override
public void disablePlugins() {
for (Plugin plugin : getPlugins()) {
if (plugin != main && !delayedDisable.contains(plugin)) {
disablePlugin(plugin);
}
}
Collections.reverse(delayedDisable);
delayedDisable.forEach(singleton::disablePlugin);
disablePlugin(main);
}
@Override
public void clearPlugins() {
instance.clearPlugins();
}
@Override
public void callEvent(Event event) throws IllegalStateException {
instance.callEvent(event);
}
@Override
public void registerEvents(Listener listener, Plugin plugin) {
instance.registerEvents(listener, plugin);
}
@Override
public void registerEvent(Class<? extends Event> aClass, Listener listener, EventPriority eventPriority, EventExecutor eventExecutor, Plugin plugin) {
instance.registerEvent(aClass, listener, eventPriority, eventExecutor, plugin);
}
@Override
public void registerEvent(Class<? extends Event> aClass, Listener listener, EventPriority eventPriority, EventExecutor eventExecutor, Plugin plugin, boolean b) {
instance.registerEvent(aClass, listener, eventPriority, eventExecutor, plugin, b);
}
@Override
public void enablePlugin(Plugin plugin) {
TDependencyInjector.injectOnEnable(plugin);
instance.enablePlugin(plugin);
}
@Override
public void disablePlugin(Plugin plugin) {
TDependencyInjector.ejectOnDisable(plugin);
instance.disablePlugin(plugin);
}
@Override
public Permission getPermission(String s) {
return instance.getPermission(s);
}
@Override
public void addPermission(Permission permission) {
instance.addPermission(permission);
}
@Override
public void removePermission(Permission permission) {
instance.removePermission(permission);
}
@Override
public void removePermission(String s) {
instance.removePermission(s);
}
@Override
public Set<Permission> getDefaultPermissions(boolean b) {
return instance.getDefaultPermissions(b);
}
@Override
public void recalculatePermissionDefaults(Permission permission) {
instance.recalculatePermissionDefaults(permission);
}
@Override
public void subscribeToPermission(String s, Permissible permissible) {
instance.subscribeToPermission(s, permissible);
}
@Override
public void unsubscribeFromPermission(String s, Permissible permissible) {
instance.unsubscribeFromPermission(s, permissible);
}
@Override
public Set<Permissible> getPermissionSubscriptions(String s) {
return instance.getPermissionSubscriptions(s);
}
@Override
public void subscribeToDefaultPerms(boolean b, Permissible permissible) {
instance.subscribeToDefaultPerms(b, permissible);
}
@Override
public void unsubscribeFromDefaultPerms(boolean b, Permissible permissible) {
instance.unsubscribeFromDefaultPerms(b, permissible);
}
@Override
public Set<Permissible> getDefaultPermSubscriptions(boolean b) {
return instance.getDefaultPermSubscriptions(b);
}
@Override
public Set<Permission> getPermissions() {
return instance.getPermissions();
}
@Override
public boolean useTimings() {
return instance.useTimings();
}
}

View File

@ -1,47 +0,0 @@
package com.ilummc.tlib.nms;
import com.ilummc.tlib.util.asm.AsmClassTransformer;
import me.skymc.taboolib.TabooLib;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public abstract class ActionBar {
private static ActionBar instance;
static {
if (TabooLib.getVerint() > 11100) {
instance = (ActionBar) AsmClassTransformer.builder().from(Impl_1_12.class).fromVersion("v1_12_R1")
.toVersion(Bukkit.getServer().getClass().getName().split("\\.")[3]).build().transform();
} else {
instance = (ActionBar) AsmClassTransformer.builder().from(Impl_1_8.class).fromVersion("v1_8_R3")
.toVersion(Bukkit.getServer().getClass().getName().split("\\.")[3]).build().transform();
}
}
public static void sendActionBar(Player player, String text) {
instance.send(player, text);
}
public abstract void send(Player player, String text);
public static class Impl_1_8 extends ActionBar {
@Override
public void send(Player player, String text) {
net.minecraft.server.v1_8_R3.ChatComponentText component = new net.minecraft.server.v1_8_R3.ChatComponentText(text);
net.minecraft.server.v1_8_R3.PacketPlayOutChat packet = new net.minecraft.server.v1_8_R3.PacketPlayOutChat(component, (byte) 2);
((org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}
public static class Impl_1_12 extends ActionBar {
@Override
public void send(Player player, String text) {
net.minecraft.server.v1_12_R1.ChatComponentText component = new net.minecraft.server.v1_12_R1.ChatComponentText(text);
net.minecraft.server.v1_12_R1.PacketPlayOutChat packet = new net.minecraft.server.v1_12_R1.PacketPlayOutChat(component, net.minecraft.server.v1_12_R1.ChatMessageType.a((byte) 2));
((org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}
}

View File

@ -1,169 +0,0 @@
package com.ilummc.tlib.resources;
import com.ilummc.tlib.TLib;
import com.ilummc.tlib.annotations.TLocalePlugin;
import com.ilummc.tlib.logger.TLogger;
import com.ilummc.tlib.resources.type.*;
import com.ilummc.tlib.util.IO;
import com.ilummc.tlib.util.Strings;
import me.skymc.taboocode.TabooCodeLang;
import me.skymc.taboolib.Main;
import me.skymc.taboolib.TabooLib;
import me.skymc.taboolib.fileutils.ConfigUtils;
import me.skymc.taboolib.fileutils.FileUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
import org.bukkit.plugin.Plugin;
import java.io.File;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
public class TLocaleLoader {
private static final Map<String, TLocaleInstance> map = new ConcurrentHashMap<>();
public static void init() {
ConfigurationSerialization.registerClass(TLocaleText.class, "TEXT");
ConfigurationSerialization.registerClass(TLocaleJson.class, "JSON");
ConfigurationSerialization.registerClass(TLocaleBook.class, "BOOK");
ConfigurationSerialization.registerClass(TLocaleSound.class, "SOUND");
ConfigurationSerialization.registerClass(TLocaleTitle.class, "TITLE");
ConfigurationSerialization.registerClass(TLocaleBossBar.class, "BAR");
ConfigurationSerialization.registerClass(TLocaleActionBar.class, "ACTION");
}
public static void sendTo(Plugin plugin, String path, CommandSender sender, String... args) {
TabooLib.debug(plugin, "TLocaleLoader.sendTo: " + plugin + ", path: " + path + ", sender: " + sender + ", args: " + Arrays.asList(args));
if (Bukkit.isPrimaryThread()) {
Optional.ofNullable(map.get(plugin.getName())).ifPresent(localeInstance -> localeInstance.sendTo(path, sender, args));
} else {
synchronized (TLocaleLoader.class) {
Optional.ofNullable(map.get(plugin.getName())).ifPresent(localeInstance -> localeInstance.sendTo(path, sender, args));
}
}
}
public static String asString(Plugin plugin, String path, String... args) {
TabooLib.debug(plugin, "TLocaleLoader.asString: " + plugin.getName() + ", path: " + path + ", args: " + Arrays.asList(args));
TLocaleInstance tLocaleInstance = map.get(plugin.getName());
if (tLocaleInstance != null) {
return tLocaleInstance.asString(path, args);
} else {
return "";
}
}
public static List<String> asStringList(Plugin plugin, String path, String... args) {
TabooLib.debug(plugin, "TLocaleLoader.asStringList: " + plugin + ", path: " + path + ", args: " + Arrays.asList(args));
TLocaleInstance tLocaleInstance = map.get(plugin.getName());
if (tLocaleInstance != null) {
return tLocaleInstance.asStringList(path, args);
} else {
return Collections.emptyList();
}
}
/**
* 载入语言文件
*
* @param plugin 载入插件
* @param isCover 是否覆盖
*/
public static void load(Plugin plugin, boolean isCover) {
try {
if (isLoadLocale(plugin, isCover)) {
// 获取文件
File localeFile = getLocaleFile(plugin);
if (localeFile == null) {
return;
}
// 加载文件
infoLogger("TRY-LOADING-LANG", plugin.getName(), localeFile.getName());
YamlConfiguration localeConfiguration = ConfigUtils.loadYaml(plugin, localeFile);
YamlConfiguration localeConfigurationAtStream = getLocaleAtStream(plugin, localeFile);
// 载入配置
loadPluginLocale(plugin, localeFile, localeConfiguration, localeConfigurationAtStream);
// 注册监听
TLib.getTLib().getConfigWatcher().removeListener(localeFile);
TLib.getTLib().getConfigWatcher().addListener(localeFile, null, obj -> {
infoLogger("RELOADING-LANG", plugin.getName());
loadPluginLocale(plugin, localeFile, ConfigUtils.loadYaml(plugin, localeFile), getLocaleAtStream(plugin, localeFile));
});
}
} catch (Exception e) {
errorLogger("ERROR-LOADING-LANG", plugin.getName(), e.toString() + "\n" + e.getStackTrace()[0].toString());
}
}
public static boolean isLocaleLoaded(Plugin plugin) {
return map.containsKey(plugin.getName());
}
public static boolean isDependWithTabooLib(Plugin plugin) {
return plugin.getClass().getAnnotation(TLocalePlugin.class) != null || plugin.getDescription().getDepend().contains(Main.getInst().getName()) || plugin.getDescription().getSoftDepend().contains(Main.getInst().getName());
}
public static List<String> getLocalePriority() {
return Main.getInst().getConfig().contains("LOCALE.PRIORITY") ? Main.getInst().getConfig().getStringList("LOCALE.PRIORITY") : Collections.singletonList("zh_CN");
}
private static boolean isLoadLocale(Plugin plugin, boolean isCover) {
return (isCover || !isLocaleLoaded(plugin)) && (plugin.equals(Main.getInst()) || isDependWithTabooLib(plugin));
}
private static void infoLogger(String path, String... args) {
TLogger.getGlobalLogger().info(Strings.replaceWithOrder(TLib.getInternalLanguage().getString(path), args));
}
private static void errorLogger(String path, String... args) {
TLogger.getGlobalLogger().error(Strings.replaceWithOrder(TLib.getInternalLanguage().getString(path), args));
}
private static File getLocaleFile(Plugin plugin) {
releaseLocales(plugin);
return getLocalePriority().stream().map(localeName -> new File(plugin.getDataFolder(), "lang/" + localeName + ".yml")).filter(File::exists).findFirst().orElse(null);
}
private static void releaseLocales(Plugin plugin) {
getLocalePriority().stream().filter(localeName -> !new File(plugin.getDataFolder(), "lang/" + localeName + ".yml").exists() && plugin.getResource("lang/" + localeName + ".yml") != null).forEach(localeName -> plugin.saveResource("lang/" + localeName + ".yml", true));
}
private static TLocaleInstance getLocaleInstance(Plugin plugin) {
TLocaleInstance instance = new TLocaleInstance(plugin);
map.put(plugin.getName(), instance);
return instance;
}
private static YamlConfiguration getLocaleAtStream(Plugin plugin, File localeFile) {
InputStream localeInputSteam = FileUtils.getResource(plugin, "lang/" + localeFile.getName());
try {
String yamlText = new String(IO.readFully(localeInputSteam), Charset.forName("utf-8"));
YamlConfiguration yaml = new YamlConfiguration();
yaml.loadFromString(yamlText);
return yaml;
} catch (Exception ignored) {
return null;
}
}
private static void loadPluginLocale(Plugin plugin, File localeFile, YamlConfiguration localeConfiguration, YamlConfiguration localeConfigurationAtStream) {
TLocaleInstance localeInstance = getLocaleInstance(plugin);
if (localeConfigurationAtStream != null) {
localeInstance.load(localeConfigurationAtStream);
}
localeInstance.load(localeConfiguration);
if (localeInstance.getLatestUpdateNodes().get() <= 0) {
infoLogger("SUCCESS-LOADING-LANG-NORMAL", plugin.getName(), localeFile.getName().split("\\.")[0], String.valueOf(localeInstance.size()));
} else {
infoLogger("SUCCESS-LOADING-LANG-UPDATE", plugin.getName(), localeFile.getName().split("\\.")[0], String.valueOf(localeInstance.size()), String.valueOf(localeInstance.getLatestUpdateNodes().get()));
}
}
}

View File

@ -1,37 +0,0 @@
package com.ilummc.tlib.resources;
import org.bukkit.command.CommandSender;
import java.util.List;
/**
* @Author sky
* @Since 2018-05-12 13:58
*/
public interface TLocaleSender {
/**
* 发送信息
*
* @param sender 发送目标
* @param args 参数
*/
void sendTo(CommandSender sender, String... args);
/**
* 获取文本
*
* @param args 参数
* @return 文本
*/
String asString(String... args);
/**
* 获取文本集合
*
* @param args 参数
* @return 文本集合
*/
List<String> asStringList(String... args);
}

View File

@ -1,18 +0,0 @@
package com.ilummc.tlib.util;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
public class IO {
public static byte[] readFully(InputStream inputStream) throws IOException {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int len = 0;
while ((len = inputStream.read(buf)) > 0) {
stream.write(buf, 0, len);
}
return stream.toByteArray();
}
}

View File

@ -1,48 +0,0 @@
package com.ilummc.tlib.util;
public class Strings {
public static boolean isBlank(String var) {
return var == null || var.trim().isEmpty();
}
public static boolean isEmpty(CharSequence var) {
return var == null || var.length() == 0;
}
/**
* 优化过的 String#replace比默认快了大概 5
*
* @param template 模板替换文件
* @param args 替换的参数
* @return 替换好的字符串
*/
public static String replaceWithOrder(String template, Object... args) {
if (args.length == 0 || template.length() == 0) {
return template;
}
char[] arr = template.toCharArray();
StringBuilder stringBuilder = new StringBuilder(template.length());
for (int i = 0; i < arr.length; i++) {
if (arr[i] == '{' && Character.isDigit(arr[Math.min(i + 1, arr.length - 1)])
&& arr[Math.min(i + 1, arr.length - 1)] - '0' < args.length
&& arr[Math.min(i + 2, arr.length - 1)] == '}') {
stringBuilder.append(args[arr[i + 1] - '0']);
i += 2;
} else {
stringBuilder.append(arr[i]);
}
}
return stringBuilder.toString();
}
// *********************************
//
// Deprecated
//
// *********************************
public static String replaceWithOrder(String template, String... args) {
return replaceWithOrder(template, (Object[]) args);
}
}

View File

@ -1,30 +0,0 @@
package com.ilummc.tlibscala.runtime
import me.skymc.taboolib.Main
import me.skymc.taboolib.economy.EcoUtils
import me.skymc.taboolib.inventory.builder.ItemBuilder
import org.bukkit.OfflinePlayer
import org.bukkit.inventory.ItemStack
class RichOfflinePlayer(private val offlinePlayer: OfflinePlayer) {
def getSkullItem: ItemStack = new ItemBuilder(offlinePlayer).build()
def getMoney: Double = EcoUtils.get(offlinePlayer)
def withdraw(x: Double): Boolean = Main.getEconomy.withdrawPlayer(offlinePlayer, x).transactionSuccess
def deposit(x: Double): Boolean = Main.getEconomy.depositPlayer(offlinePlayer, x).transactionSuccess
def hasMoney(x: Double): Boolean = Main.getEconomy.has(offlinePlayer, x)
}
object RichOfflinePlayer {
implicit def player2rich(player: OfflinePlayer): RichOfflinePlayer = new RichOfflinePlayer(player)
implicit def rich2player(player: RichOfflinePlayer): OfflinePlayer = player.offlinePlayer
}

View File

@ -1,68 +0,0 @@
package com.ilummc.tlibscala.runtime
import com.ilummc.tlib.resources.TLocale
import me.skymc.taboolib.anvil.AnvilContainerAPI
import me.skymc.taboolib.display.{ActionUtils, TitleUtils}
import me.skymc.taboolib.permission.PermissionUtils
import me.skymc.taboolib.player.PlayerUtils
import me.skymc.taboolib.scoreboard.ScoreboardUtil
import me.skymc.taboolib.sign.SignUtils
import org.bukkit.block.Block
import org.bukkit.entity.Player
import scala.collection.JavaConverters._
class RichPlayer(private val player: Player) extends RichOfflinePlayer(player) {
def sendActionBar(x: String): Unit = ActionUtils.send(player, x)
def getFishTicks: Int = PlayerUtils.getFishingTicks(PlayerUtils.getPlayerHookedFish(player))
def setFishTicks(x: Int): Unit = PlayerUtils.setFishingTicks(PlayerUtils.getPlayerHookedFish(player), x)
def resetData(): Unit = PlayerUtils.resetData(player, false)
def resetData(scoreboard: Boolean): Unit = PlayerUtils.resetData(player, scoreboard)
def displaySidebar(title: String, elements: Map[String, Integer]): Unit = ScoreboardUtil.rankedSidebarDisplay(player, title, mapAsJavaMap(elements))
def displaySidebarUnranked(title: String, elements: Array[String]): Unit = ScoreboardUtil.unrankedSidebarDisplay(player, elements: _*)
def displaySidebarUnranked(title: String, elements: List[String]): Unit = ScoreboardUtil.unrankedSidebarDisplay(player, elements: _*)
def displaySidebarUnranked(title: String, elements: String*): Unit = ScoreboardUtil.unrankedSidebarDisplay(player, elements: _*)
def openSign(block: Block): Unit = SignUtils.openSign(player, block)
def openSign(lines: Array[String], id: String): Unit = SignUtils.openSign(player, lines, id)
//todo TagDataHandler
def addPermission(perm: String): Unit = PermissionUtils.addPermission(player, perm)
def removePermission(perm: String): Unit = PermissionUtils.removePermission(player, perm)
def sendTitle(title: String, subtitle: String, fadein: Int, stay: Int, fadeout: Int): Unit = TitleUtils.sendTitle(player, title, subtitle, fadein, stay, fadeout)
def sendTitle(p: Player, title: String, fadeint: Int, stayt: Int, fadeoutt: Int, subtitle: String, fadeinst: Int, stayst: Int, fadeoutst: Int): Unit = TitleUtils.sendTitle(p, title, fadeint, stayt, fadeoutt, subtitle, fadeinst, stayst, fadeoutst)
def openAnvil(): Unit = AnvilContainerAPI.openAnvil(player)
def sendLocalizedMessage(node: String, params: String*): Unit = TLocale.sendTo(player, node, params: _*)
def locale(node: String, params: String*): Unit = sendLocalizedMessage(node, params: _*)
def <<(text: String): RichPlayer = {
player.sendMessage(text)
this
}
}
object RichPlayer {
implicit def player2rich(player: Player): RichPlayer = new RichPlayer(player)
implicit def rich2player(player: RichPlayer): Player = player.player
}

View File

@ -1,11 +1,11 @@
package me.skymc.taboolib.bstats; package io.izzel.taboolib;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.ServicePriority; import org.bukkit.plugin.ServicePriority;
import org.bukkit.plugin.java.JavaPlugin;
import org.json.simple.JSONArray; import org.json.simple.JSONArray;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
@ -55,7 +55,7 @@ public class Metrics {
} }
// The plugin // The plugin
private final JavaPlugin plugin; private final Plugin plugin;
// A list with all custom charts // A list with all custom charts
private final List<CustomChart> charts = new ArrayList<>(); private final List<CustomChart> charts = new ArrayList<>();
@ -65,7 +65,7 @@ public class Metrics {
* *
* @param plugin The plugin which stats should be submitted. * @param plugin The plugin which stats should be submitted.
*/ */
public Metrics(JavaPlugin plugin) { public Metrics(Plugin plugin) {
if (plugin == null) { if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null!"); throw new IllegalArgumentException("Plugin cannot be null!");
} }
@ -78,27 +78,17 @@ public class Metrics {
// Check if the config file exists // Check if the config file exists
if (!config.isSet("serverUuid")) { if (!config.isSet("serverUuid")) {
// Add default values // Add default values
config.addDefault("enabled", true); config.addDefault("enabled", true);
// Every server gets it's unique random id. // Every server gets it's unique random id.
config.addDefault("serverUuid", UUID.randomUUID().toString()); config.addDefault("serverUuid", UUID.randomUUID().toString());
// Should failed request be logged? // Should failed request be logged?
config.addDefault("logFailedRequests", false); config.addDefault("logFailedRequests", false);
// Inform the server owners about bStats
config.options().header(
"bStats collects some data for plugin authors like how many servers are using their plugins.\n" +
"To honor their work, you should not disable it.\n" +
"This has nearly no effect on the server performance!\n" +
"Check out https://bStats.org/ to learn more :)"
).copyDefaults(true);
try { try {
config.save(configFile); config.save(configFile);
} catch (IOException ignored) { } catch (IOException ignored) {
} }
} }
// Load the data // Load the data
serverUUID = config.getString("serverUuid"); serverUUID = config.getString("serverUuid");
logFailedRequests = config.getBoolean("logFailedRequests", false); logFailedRequests = config.getBoolean("logFailedRequests", false);

View File

@ -0,0 +1,109 @@
package io.izzel.taboolib;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import io.izzel.taboolib.locale.TLocaleLoader;
import io.izzel.taboolib.module.command.TCommandHandler;
import io.izzel.taboolib.module.config.TConfig;
import io.izzel.taboolib.module.config.TConfigWatcher;
import io.izzel.taboolib.module.dependency.TDependencyInjector;
import io.izzel.taboolib.module.inject.TListenerHandler;
import io.izzel.taboolib.module.mysql.IHost;
import io.izzel.taboolib.module.mysql.hikari.HikariHandler;
import io.izzel.taboolib.origin.database.PluginDataManager;
import org.bukkit.plugin.Plugin;
import java.util.List;
import java.util.Optional;
import java.util.Set;
/**
* @Author 坏黑
* @Since 2019-07-05 15:14
*/
public abstract class PluginLoader {
private static List<PluginLoader> registerLoader = Lists.newArrayList();
private static Set<String> plugins = Sets.newHashSet();
static {
registerLoader.add(new PluginLoader() {
@Override
public void onLoading(Plugin plugin) {
// 加载语言文件
TLocaleLoader.load(plugin, false);
// 注入依赖
TDependencyInjector.inject(plugin, plugin.getClass());
// 读取插件类
TabooLibLoader.setupClasses(plugin);
// 加载插件类
TabooLibLoader.getPluginClassSafely(plugin).forEach(c -> TabooLibLoader.preLoadClass(plugin, c));
}
@Override
public void onStarting(Plugin plugin) {
// 加载监听器
TListenerHandler.setupListener(plugin);
// 加载插件类
TabooLibLoader.getPluginClassSafely(plugin).forEach(c -> TabooLibLoader.postLoadClass(plugin, c));
// 注册插件命令
TCommandHandler.registerCommand(plugin);
}
@Override
public void onActivated(Plugin plugin) {
// 注册监听器
TListenerHandler.registerListener(plugin);
}
@Override
public void onStopping(Plugin plugin) {
// 注销监听器
TListenerHandler.cancelListener(plugin);
// 储存插件数据
PluginDataManager.saveAllCaches(plugin, true);
// 注销数据库连接
Sets.newHashSet(HikariHandler.getDataSource().keySet()).stream().filter(IHost::isAutoClose).forEach(HikariHandler::closeDataSource);
// 释放文检动态读取
Optional.ofNullable(TConfig.getFiles().remove(plugin.getName())).ifPresent(files -> files.forEach(file -> TConfigWatcher.getInst().removeListener(file)));
}
});
}
public void onLoading(Plugin plugin) {
}
public void onStarting(Plugin plugin) {
}
public void onActivated(Plugin plugin) {
}
public void onStopping(Plugin plugin) {
}
public static void addPlugin(Plugin plugin) {
plugins.add(plugin.getName());
}
public static void load(Plugin plugin) {
registerLoader.forEach(loader -> loader.onLoading(plugin));
}
public static void start(Plugin plugin) {
registerLoader.forEach(loader -> loader.onStarting(plugin));
}
public static void active(Plugin plugin) {
registerLoader.forEach(loader -> loader.onActivated(plugin));
}
public static void stop(Plugin plugin) {
registerLoader.forEach(loader -> loader.onStopping(plugin));
}
public static boolean isPlugin(Plugin plugin) {
return plugins.contains(plugin.getName());
}
}

View File

@ -0,0 +1,137 @@
package io.izzel.taboolib;
import io.izzel.taboolib.locale.TLocaleLoader;
import io.izzel.taboolib.module.config.TConfig;
import io.izzel.taboolib.module.config.TConfigWatcher;
import io.izzel.taboolib.module.dependency.Dependency;
import io.izzel.taboolib.module.logger.TLogger;
import io.izzel.taboolib.module.mysql.hikari.HikariHandler;
import io.izzel.taboolib.module.nms.NMSHandler;
import io.izzel.taboolib.origin.database.PlayerDataManager;
import io.izzel.taboolib.origin.database.PluginDataManager;
import io.izzel.taboolib.plugin.InternalPlugin;
import io.izzel.taboolib.util.Files;
import io.izzel.taboolib.util.IO;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.util.NumberConversions;
import java.io.File;
import java.nio.charset.Charset;
import java.util.concurrent.Executors;
/**
* @Author 坏黑
* @Since 2019-07-05 10:39
* <p>
* 注意与 TabooLib4.x 版本的兼容
* 可能存在同时运行的情况
*/
@Dependency(type = Dependency.Type.LIBRARY, maven = "org.slf4j:slf4j-api:1.7.25", url = "https://skymc.oss-cn-shanghai.aliyuncs.com/libs/org.slf4j-slf4j-api-1.7.25.jar")
@Dependency(type = Dependency.Type.LIBRARY, maven = "com.zaxxer:HikariCP:3.1.0", url = "https://skymc.oss-cn-shanghai.aliyuncs.com/libs/com.zaxxer-HikariCP-3.1.0.jar")
@Dependency(type = Dependency.Type.LIBRARY, maven = "org.scala-lang:scala-library:2.12.8", url = "https://skymc.oss-cn-shanghai.aliyuncs.com/libs/scala-library-2.12.8.jar")
public class TabooLib {
private static TabooLib inst = new TabooLib();
private static TLogger logger;
private static TConfig config;
private static double version;
// 第三方依赖下载位置
private File libsFolder;
private File playerDataFolder;
private File serverDataFolder;
// 内部语言文件
private YamlConfiguration internal = new YamlConfiguration();
public TabooLib() {
// 创建配置
inst = this;
logger = TLogger.getUnformatted("TabooLib");
config = TConfig.create(getPlugin(), "config.yml");
libsFolder = Files.folder("plugins/TabooLib/libs");
playerDataFolder = Files.folder(config.getString("DATAURL.PLAYER-DATA"));
serverDataFolder = Files.folder(config.getString("DATAURL.SERVER-DATA"));
// 加载版本号
try {
version = NumberConversions.toDouble(IO.readFully(Files.getResource("version"), Charset.forName("utf-8")));
} catch (Throwable t) {
t.printStackTrace();
}
// 加载内部语言文件
try {
internal.loadFromString(IO.readFully(Files.getResource("lang/internal.yml"), Charset.forName("utf-8")));
} catch (Throwable t) {
t.printStackTrace();
}
// 加载 TabooLib 语言文件
TLocaleLoader.load(getPlugin(), false);
// 加载 TabooLib
TabooLibLoader.init();
// 创建 TabooLib 插件数据
PluginDataManager.addPluginData("TabooLib", null);
PluginDataManager.addPluginData("TabooLibrary", null);
// 创建线程检测服务器是否关闭
Executors.newSingleThreadExecutor().submit(() -> {
while (NMSHandler.getHandler().isRunning()) {
}
// 关闭连接池
HikariHandler.closeDataSourceForce();
// 保存数据
PlayerDataManager.saveAllPlayers(false, true);
PluginDataManager.saveAllCaches();
// 插件关闭
PluginLoader.stop(getPlugin());
// 清理数据
if (config.getBoolean("DELETE-DATA")) {
Files.deepDelete(getPlayerDataFolder());
}
});
}
public void cancel() {
TConfigWatcher.getInst().unregisterAll();
}
public static InternalPlugin getPlugin() {
return InternalPlugin.getPlugin();
}
// *********************************
//
// Getter and Setter
//
// *********************************
public static TabooLib getInst() {
return inst;
}
public static TLogger getLogger() {
return logger;
}
public static TConfig getConfig() {
return config;
}
public static double getVersion() {
return version;
}
public File getLibsFolder() {
return libsFolder;
}
public File getPlayerDataFolder() {
return playerDataFolder;
}
public File getServerDataFolder() {
return serverDataFolder;
}
public YamlConfiguration getInternal() {
return internal;
}
}

View File

@ -0,0 +1,91 @@
package io.izzel.taboolib;
import io.izzel.taboolib.module.nms.NMSHandler;
import io.izzel.taboolib.origin.database.PluginDataManager;
import io.izzel.taboolib.util.Strings;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.server.ServerCommandEvent;
import org.bukkit.plugin.Plugin;
/**
* @Author 坏黑
* @Since 2019-07-05 14:31
*/
public class TabooLibAPI {
private static boolean bukkit;
private static boolean originLoaded;
static {
try {
// 判断是否基于 Bukkit 运行
bukkit = Class.forName("org.bukkit.Bukkit") != null;
// 获取 TabooLib4.x 版本是否载入
originLoaded = Bukkit.getPluginManager().getPlugin("TabooLib") != null;
} catch (Exception ignored) {
}
}
public static boolean isBukkit() {
return bukkit;
}
public static boolean isOriginLoaded() {
return originLoaded;
}
public static boolean isDependTabooLib(Plugin plugin) {
return PluginLoader.isPlugin(plugin);
}
public static double[] getTPS() {
return NMSHandler.getHandler().getTPS();
}
public static boolean isDebug() {
return PluginDataManager.getPluginData("TabooLibrary", TabooLib.getPlugin()).getBoolean("debug");
}
public static void setDebug(boolean debug) {
PluginDataManager.getPluginData("TabooLibrary", TabooLib.getPlugin()).set("debug", debug);
}
public static void debug(String... args) {
debug(TabooLib.getPlugin(), args);
}
public static void debug(Plugin plugin, String... args) {
if (!isDebug()) {
return;
}
for (String line : args) {
Bukkit.getConsoleSender().sendMessage("§4[" + plugin.getName() + "][DEBUG] §c" + line);
}
}
public static boolean dispatchCommand(CommandSender sender, String command) {
try {
if ((sender instanceof Player)) {
PlayerCommandPreprocessEvent e = new PlayerCommandPreprocessEvent((Player) sender, "/" + command);
Bukkit.getPluginManager().callEvent(e);
if (e.isCancelled() || Strings.isBlank(e.getMessage()) || !e.getMessage().startsWith("/")) {
return false;
}
return Bukkit.dispatchCommand(e.getPlayer(), e.getMessage().substring(1));
} else {
ServerCommandEvent e = new ServerCommandEvent(sender, command);
Bukkit.getPluginManager().callEvent(e);
if (e.isCancelled() || Strings.isBlank(e.getCommand())) {
return false;
}
return Bukkit.dispatchCommand(e.getSender(), e.getCommand());
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
}

View File

@ -0,0 +1,159 @@
package io.izzel.taboolib;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import io.izzel.taboolib.module.dependency.TDependencyInjector;
import io.izzel.taboolib.module.inject.TSchedule;
import io.izzel.taboolib.origin.client.TabooLibClient;
import io.izzel.taboolib.origin.client.TabooLibServer;
import io.izzel.taboolib.origin.database.PlayerDataManager;
import io.izzel.taboolib.origin.database.PluginDataManager;
import io.izzel.taboolib.util.Files;
import io.izzel.taboolib.util.Reflection;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author 坏黑
* @Since 2019-07-05 15:30
*/
public class TabooLibLoader {
static Map<String, List<Class>> pluginClasses = Maps.newHashMap();
static List<Loader> loaders = Lists.newArrayList();
@TSchedule(period = 20 * 60, async = true)
static void save() {
PluginDataManager.saveAllCaches();
PlayerDataManager.saveAllCaches(true, false);
}
@TSchedule
static void start() {
PluginLoader.active(TabooLib.getPlugin());
// 通讯网络服务器
if (TabooLib.getConfig().getBoolean("SERVER")) {
TabooLibServer.main(new String[0]);
}
// 通讯网络客户端
TabooLibClient.init();
}
static void init() {
// 加载依赖
TDependencyInjector.inject("TabooLib", TabooLib.class);
// 插件统计
Metrics metrics = new Metrics(TabooLib.getPlugin());
metrics.addCustomChart(new Metrics.SingleLineChart("plugins_using_taboolib", () -> Math.toIntExact(Arrays.stream(Bukkit.getPluginManager().getPlugins()).filter(TabooLibAPI::isDependTabooLib).count())));
// 读取插件类
setupClasses(TabooLib.getPlugin());
// 读取加载器
pluginClasses.get("TabooLib").stream().filter(TabooLibLoader::isLoader).forEach(pluginClass -> {
try {
loaders.add((Loader) Reflection.instantiateObject(pluginClass));
} catch (Exception e) {
e.printStackTrace();
}
loaders.sort(Comparator.comparingInt(Loader::priority));
});
// 加载插件
PluginLoader.load(TabooLib.getPlugin());
PluginLoader.start(TabooLib.getPlugin());
}
public static Optional<List<Class>> getPluginClasses(Plugin plugin) {
return Optional.ofNullable(pluginClasses.get(plugin.getName()));
}
public static List<Class> getPluginClassSafely(Plugin plugin) {
List<Class> classes = pluginClasses.get(plugin.getName());
return classes == null ? new ArrayList<>() : new ArrayList<>(classes);
}
static boolean isLoader(Class pluginClass) {
return !Loader.class.equals(pluginClass) && Loader.class.isAssignableFrom(pluginClass);
}
static void setupClasses(Plugin plugin) {
try {
long time = System.currentTimeMillis();
List<Class> classes;
IgnoreClasses annotation = plugin.getClass().getAnnotation(IgnoreClasses.class);
if (annotation != null) {
classes = Files.getClasses(plugin, annotation.value());
} else {
classes = Files.getClasses(plugin);
}
if (plugin.getName().equals("TabooLib")) {
classes = classes.stream().filter(c -> c.getName().startsWith("io.izzel")).collect(Collectors.toList());
}
TabooLibAPI.debug("Saved " + classes.size() + " classes (" + plugin.getName() + ") (" + (System.currentTimeMillis() - time) + "ms)");
pluginClasses.put(plugin.getName(), classes);
} catch (Exception ignored) {
}
}
static void preLoadClass(Plugin plugin, Class<?> loadClass) {
loaders.forEach(loader -> {
try {
loader.preLoad(plugin, loadClass);
} catch (NoClassDefFoundError ignore) {
} catch (Throwable e) {
e.printStackTrace();
}
});
}
static void postLoadClass(Plugin plugin, Class<?> loadClass) {
loaders.forEach(loader -> {
try {
loader.postLoad(plugin, loadClass);
} catch (NoClassDefFoundError ignore) {
} catch (Throwable e) {
e.printStackTrace();
}
});
}
static void unloadClass(Plugin plugin, Class<?> loadClass) {
loaders.forEach(loader -> {
try {
loader.unload(plugin, loadClass);
} catch (NoClassDefFoundError ignore) {
} catch (Throwable e) {
e.printStackTrace();
}
});
}
public interface Loader {
default void preLoad(org.bukkit.plugin.Plugin plugin, Class<?> loadClass) {
}
default void postLoad(org.bukkit.plugin.Plugin plugin, Class<?> loadClass) {
}
default void unload(Plugin plugin, Class<?> cancelClass) {
}
default int priority() {
return 0;
}
}
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface IgnoreClasses {
String[] value();
}
}

View File

@ -0,0 +1,57 @@
package io.izzel.taboolib;
import org.bukkit.Bukkit;
/**
* @Author 坏黑
* @Since 2019-07-05 14:42
*/
public enum Version {
v1_7(10700), v1_8(10800), v1_9(10900), v1_10(11000), v1_11(11100), v1_12(11200), v1_13(11300), v1_14(11400), vNull(0);
private int versionInt;
Version(int versionInt) {
this.versionInt = versionInt;
}
public int getVersionInt() {
return versionInt;
}
public static boolean isAfter(Version in) {
return getCurrentVersion().getVersionInt() >= in.getVersionInt();
}
public static boolean isBefore(Version in) {
return getCurrentVersion().getVersionInt() < in.getVersionInt();
}
public static String getBukkitVersion() {
return Bukkit.getServer().getClass().getName().split("\\.")[3];
}
public static Version getCurrentVersion() {
String nmsVersion = getBukkitVersion();
if (nmsVersion.startsWith("v1_7")) {
return v1_7;
} else if (nmsVersion.startsWith("v1_8")) {
return v1_8;
} else if (nmsVersion.startsWith("v1_9")) {
return v1_9;
} else if (nmsVersion.startsWith("v1_10")) {
return v1_10;
} else if (nmsVersion.startsWith("v1_11")) {
return v1_11;
} else if (nmsVersion.startsWith("v1_12")) {
return v1_12;
} else if (nmsVersion.startsWith("v1_13")) {
return v1_13;
} else if (nmsVersion.startsWith("v1_14")) {
return v1_14;
} else {
return vNull;
}
}
}

View File

@ -1,19 +1,17 @@
package me.skymc.taboolib.commands; package io.izzel.taboolib.command;
import com.ilummc.tlib.resources.TLocale; import io.izzel.taboolib.TabooLibAPI;
import com.ilummc.tlib.util.Strings; import io.izzel.taboolib.locale.TLocale;
import me.skymc.taboolib.commands.internal.BaseMainCommand; import io.izzel.taboolib.module.command.base.BaseMainCommand;
import me.skymc.taboolib.commands.internal.BaseSubCommand; import io.izzel.taboolib.module.command.base.BaseSubCommand;
import me.skymc.taboolib.commands.internal.TCommand; import io.izzel.taboolib.module.command.TCommand;
import me.skymc.taboolib.commands.internal.type.CommandArgument; import io.izzel.taboolib.module.command.base.CommandArgument;
import me.skymc.taboolib.commands.internal.type.CommandRegister; import io.izzel.taboolib.module.command.base.CommandRegister;
import me.skymc.taboolib.string.ArrayUtils; import io.izzel.taboolib.util.ArrayUtil;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.server.ServerCommandEvent;
/** /**
* @Author sky * @Author sky
@ -33,6 +31,7 @@ public class TabooLibExecuteCommand extends BaseMainCommand {
@CommandRegister(priority = 1) @CommandRegister(priority = 1)
BaseSubCommand chat = new BaseSubCommand() { BaseSubCommand chat = new BaseSubCommand() {
@Override @Override
public String getLabel() { public String getLabel() {
return "chat"; return "chat";
@ -58,7 +57,7 @@ public class TabooLibExecuteCommand extends BaseMainCommand {
TLocale.sendTo(sender, "INVALID-PLAYER-OFFLINE", args[0]); TLocale.sendTo(sender, "INVALID-PLAYER-OFFLINE", args[0]);
return; return;
} }
player.chat(ArrayUtils.arrayJoin(args, 1)); player.chat(ArrayUtil.arrayJoin(args, 1));
} }
}; };
@ -69,6 +68,11 @@ public class TabooLibExecuteCommand extends BaseMainCommand {
return "command"; return "command";
} }
@Override
public String[] getAliases() {
return new String[] {"cmd"};
}
@Override @Override
public String getDescription() { public String getDescription() {
return TLocale.asString("COMMANDS.TEXECUTE.COMMAND.DESCRIPTION"); return TLocale.asString("COMMANDS.TEXECUTE.COMMAND.DESCRIPTION");
@ -85,7 +89,7 @@ public class TabooLibExecuteCommand extends BaseMainCommand {
@Override @Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) { public void onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args[0].equalsIgnoreCase("console")) { if (args[0].equalsIgnoreCase("console")) {
dispatchCommand(Bukkit.getConsoleSender(), ArrayUtils.arrayJoin(args, 1)); TabooLibAPI.dispatchCommand(Bukkit.getConsoleSender(), ArrayUtil.arrayJoin(args, 1));
return; return;
} }
Player player = Bukkit.getPlayerExact(args[0]); Player player = Bukkit.getPlayerExact(args[0]);
@ -93,17 +97,23 @@ public class TabooLibExecuteCommand extends BaseMainCommand {
TLocale.sendTo(sender, "INVALID-TARGET-NOT-FOUND", args[0]); TLocale.sendTo(sender, "INVALID-TARGET-NOT-FOUND", args[0]);
return; return;
} }
dispatchCommand(player, ArrayUtils.arrayJoin(args, 1)); TabooLibAPI.dispatchCommand(player, ArrayUtil.arrayJoin(args, 1));
} }
}; };
@CommandRegister(priority = 2) @CommandRegister(priority = 2)
BaseSubCommand commandAsOp = new BaseSubCommand() { BaseSubCommand commandAsOp = new BaseSubCommand() {
@Override @Override
public String getLabel() { public String getLabel() {
return "commandAsOp"; return "commandAsOp";
} }
@Override
public String[] getAliases() {
return new String[] {"op"};
}
@Override @Override
public String getDescription() { public String getDescription() {
return TLocale.asString("COMMANDS.TEXECUTE.COMMAND-AS-OP.DESCRIPTION"); return TLocale.asString("COMMANDS.TEXECUTE.COMMAND-AS-OP.DESCRIPTION");
@ -120,7 +130,7 @@ public class TabooLibExecuteCommand extends BaseMainCommand {
@Override @Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) { public void onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args[0].equalsIgnoreCase("console")) { if (args[0].equalsIgnoreCase("console")) {
dispatchCommand(Bukkit.getConsoleSender(), ArrayUtils.arrayJoin(args, 1)); TabooLibAPI.dispatchCommand(Bukkit.getConsoleSender(), ArrayUtil.arrayJoin(args, 1));
return; return;
} }
Player player = Bukkit.getPlayerExact(args[0]); Player player = Bukkit.getPlayerExact(args[0]);
@ -131,33 +141,10 @@ public class TabooLibExecuteCommand extends BaseMainCommand {
boolean isOp = player.isOp(); boolean isOp = player.isOp();
player.setOp(true); player.setOp(true);
try { try {
dispatchCommand(player, ArrayUtils.arrayJoin(args, 1)); TabooLibAPI.dispatchCommand(player, ArrayUtil.arrayJoin(args, 1));
} catch (Exception ignored) { } catch (Exception ignored) {
} }
player.setOp(isOp); player.setOp(isOp);
} }
}; };
public static boolean dispatchCommand(CommandSender sender, String command) {
try {
if ((sender instanceof Player)) {
PlayerCommandPreprocessEvent e = new PlayerCommandPreprocessEvent((Player) sender, "/" + command);
Bukkit.getPluginManager().callEvent(e);
if (e.isCancelled() || Strings.isBlank(e.getMessage()) || !e.getMessage().startsWith("/")) {
return false;
}
return Bukkit.dispatchCommand(e.getPlayer(), e.getMessage().substring(1));
} else {
ServerCommandEvent e = new ServerCommandEvent(sender, command);
Bukkit.getPluginManager().callEvent(e);
if (e.isCancelled() || Strings.isBlank(e.getCommand())) {
return false;
}
return Bukkit.dispatchCommand(e.getSender(), e.getCommand());
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
} }

View File

@ -1,12 +1,12 @@
package me.skymc.taboolib.commands.locale; package io.izzel.taboolib.command;
import com.ilummc.tlib.resources.TLocale; import io.izzel.taboolib.locale.TLocale;
import com.ilummc.tlib.resources.TLocaleLoader; import io.izzel.taboolib.locale.TLocaleLoader;
import me.skymc.taboolib.commands.internal.BaseMainCommand; import io.izzel.taboolib.module.command.base.BaseMainCommand;
import me.skymc.taboolib.commands.internal.BaseSubCommand; import io.izzel.taboolib.module.command.base.BaseSubCommand;
import me.skymc.taboolib.commands.internal.TCommand; import io.izzel.taboolib.module.command.TCommand;
import me.skymc.taboolib.commands.internal.type.CommandArgument; import io.izzel.taboolib.module.command.base.CommandArgument;
import me.skymc.taboolib.commands.internal.type.CommandRegister; import io.izzel.taboolib.module.command.base.CommandRegister;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -1,17 +1,18 @@
package me.skymc.taboolib.commands.plugin; package io.izzel.taboolib.command;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.ilummc.tlib.resources.TLocale; import io.izzel.taboolib.TabooLibAPI;
import me.skymc.taboolib.commands.internal.BaseMainCommand; import io.izzel.taboolib.locale.TLocale;
import me.skymc.taboolib.commands.internal.BaseSubCommand; import io.izzel.taboolib.module.command.TCommand;
import me.skymc.taboolib.commands.internal.TCommand; import io.izzel.taboolib.module.command.base.BaseMainCommand;
import me.skymc.taboolib.commands.internal.type.CommandArgument; import io.izzel.taboolib.module.command.base.BaseSubCommand;
import me.skymc.taboolib.commands.internal.type.CommandRegister; import io.izzel.taboolib.module.command.base.CommandArgument;
import me.skymc.taboolib.plugin.PluginLoadState; import io.izzel.taboolib.module.command.base.CommandRegister;
import me.skymc.taboolib.plugin.PluginLoadStateType; import io.izzel.taboolib.origin.plugin.PluginLoadState;
import me.skymc.taboolib.plugin.PluginUnloadState; import io.izzel.taboolib.origin.plugin.PluginLoadStateType;
import me.skymc.taboolib.plugin.PluginUtils; import io.izzel.taboolib.origin.plugin.PluginUnloadState;
import me.skymc.taboolib.string.ArrayUtils; import io.izzel.taboolib.origin.plugin.PluginUtils;
import io.izzel.taboolib.util.ArrayUtil;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -37,17 +38,6 @@ public class TabooLibPluginCommand extends BaseMainCommand {
return TLocale.asString("COMMANDS.TPLUGIN.COMMAND-TITLE"); return TLocale.asString("COMMANDS.TPLUGIN.COMMAND-TITLE");
} }
// @Override
// public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] args) {
// if (args.length == 1) {
// return getSubCommands().stream().filter(internalCommandExecutor -> internalCommandExecutor != null && (args[0].isEmpty() || internalCommandExecutor.getLabel().toLowerCase().startsWith(args[0].toLowerCase()))).map(BaseSubCommand::getLabel).collect(Collectors.toList());
// } else if (args.length > 1 && isPluginCommand(args[0])) {
// return Arrays.stream(Bukkit.getPluginManager().getPlugins()).filter(x -> !PluginUtils.isIgnored(x)).collect(Collectors.toList()).stream().filter(plugin -> args[1].isEmpty() || plugin.getName().toLowerCase().startsWith(args[1].toLowerCase())).map(Plugin::getName).collect(Collectors.toList());
// } else {
// return null;
// }
// }
@CommandRegister(priority = 1) @CommandRegister(priority = 1)
BaseSubCommand load = new BaseSubCommand() { BaseSubCommand load = new BaseSubCommand() {
@ -68,7 +58,7 @@ public class TabooLibPluginCommand extends BaseMainCommand {
@Override @Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) { public void onCommand(CommandSender sender, Command command, String label, String[] args) {
String name = ArrayUtils.arrayJoin(args, 0); String name = ArrayUtil.arrayJoin(args, 0);
if (PluginUtils.getPluginByName(name) != null) { if (PluginUtils.getPluginByName(name) != null) {
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.LOAD.INVALID-PLUGIN", name, name + " already loaded!"); TLocale.sendTo(sender, "COMMANDS.TPLUGIN.LOAD.INVALID-PLUGIN", name, name + " already loaded!");
} else { } else {
@ -114,13 +104,13 @@ public class TabooLibPluginCommand extends BaseMainCommand {
@Override @Override
public CommandArgument[] getArguments() { public CommandArgument[] getArguments() {
return new CommandArgument[] {new CommandArgument(TLocale.asString("COMMANDS.TPLUGIN.UNLOAD.ARGUMENTS.0"), true, () -> { return new CommandArgument[] {new CommandArgument(TLocale.asString("COMMANDS.TPLUGIN.UNLOAD.ARGUMENTS.0"), true, () -> {
return Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toList()); return java.util.Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toList());
})}; })};
} }
@Override @Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) { public void onCommand(CommandSender sender, Command command, String label, String[] args) {
String name = ArrayUtils.arrayJoin(args, 0); String name = ArrayUtil.arrayJoin(args, 0);
Plugin plugin = PluginUtils.getPluginByName(name); Plugin plugin = PluginUtils.getPluginByName(name);
if (plugin == null) { if (plugin == null) {
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.UNLOAD.INVALID-PLUGIN", name); TLocale.sendTo(sender, "COMMANDS.TPLUGIN.UNLOAD.INVALID-PLUGIN", name);
@ -164,15 +154,15 @@ public class TabooLibPluginCommand extends BaseMainCommand {
@Override @Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) { public void onCommand(CommandSender sender, Command command, String label, String[] args) {
String name = ArrayUtils.arrayJoin(args, 0); String name = ArrayUtil.arrayJoin(args, 0);
Plugin plugin = PluginUtils.getPluginByName(name); Plugin plugin = PluginUtils.getPluginByName(name);
if (plugin == null) { if (plugin == null) {
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.RELOAD.INVALID-PLUGIN", name); TLocale.sendTo(sender, "COMMANDS.TPLUGIN.RELOAD.INVALID-PLUGIN", name);
} else if (PluginUtils.isIgnored(plugin)) { } else if (PluginUtils.isIgnored(plugin)) {
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.RELOAD.INVALID-PLUGIN-IGNORED", name); TLocale.sendTo(sender, "COMMANDS.TPLUGIN.RELOAD.INVALID-PLUGIN-IGNORED", name);
} else { } else {
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.RELOAD.TRY-RELOAD"); TabooLibAPI.dispatchCommand(sender, "taboolibplugin unload " + plugin.getName());
PluginUtils.reload(plugin); TabooLibAPI.dispatchCommand(sender, "taboolibplugin load " + plugin.getName());
} }
} }
}; };
@ -192,12 +182,14 @@ public class TabooLibPluginCommand extends BaseMainCommand {
@Override @Override
public CommandArgument[] getArguments() { public CommandArgument[] getArguments() {
return new CommandArgument[] {new CommandArgument(TLocale.asString("COMMANDS.TPLUGIN.INFO.ARGUMENTS.0"), true)}; return new CommandArgument[] {new CommandArgument(TLocale.asString("COMMANDS.TPLUGIN.INFO.ARGUMENTS.0"), true, () -> {
return Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toList());
})};
} }
@Override @Override
public void onCommand(CommandSender sender, Command command, String label, String[] args) { public void onCommand(CommandSender sender, Command command, String label, String[] args) {
String name = ArrayUtils.arrayJoin(args, 0); String name = ArrayUtil.arrayJoin(args, 0);
Plugin plugin = PluginUtils.getPluginByName(name); Plugin plugin = PluginUtils.getPluginByName(name);
if (plugin == null) { if (plugin == null) {
TLocale.sendTo(sender, "COMMANDS.TPLUGIN.INFO.INVALID-PLUGIN", name); TLocale.sendTo(sender, "COMMANDS.TPLUGIN.INFO.INVALID-PLUGIN", name);

View File

@ -1,7 +1,6 @@
package me.skymc.taboolib.listener; package io.izzel.taboolib.listener;
import me.skymc.taboolib.Main; import io.izzel.taboolib.module.inject.TListener;
import me.skymc.taboolib.message.MsgUtils;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -14,11 +13,9 @@ import pw.yumc.Yum.events.PluginNetworkEvent;
@TListener(depend = "YUM") @TListener(depend = "YUM")
public class ListenerNetWork implements Listener { public class ListenerNetWork implements Listener {
public static final String GG = "本监听只是为了防止本插件的更新检测被 YUM 插件阻止,别无它用。";
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onNetWork(PluginNetworkEvent e) { public void onNetWork(PluginNetworkEvent e) {
if (e.getPlugin() != null && e.getPlugin().equals(Main.getInst())) { if (e.getPlugin() != null && e.getPlugin().getName().equals("TabooLib")) {
e.setCancelled(false); e.setCancelled(false);
} }
} }

View File

@ -0,0 +1,59 @@
package io.izzel.taboolib.listener;
import io.izzel.taboolib.TabooLibAPI;
import io.izzel.taboolib.Version;
import io.izzel.taboolib.module.inject.TListener;
import io.izzel.taboolib.module.item.Items;
import io.izzel.taboolib.module.logger.TLogger;
import io.izzel.taboolib.module.tellraw.TellrawJson;
import io.izzel.taboolib.origin.database.PlayerDataManager;
import io.izzel.taboolib.origin.database.PluginDataManager;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.server.ServerCommandEvent;
/**
* @author sky
*/
@TListener
public class ListenerPlayerCommand implements Listener {
@EventHandler
public void cmd(ServerCommandEvent e) {
if (e.getCommand().equalsIgnoreCase("saveFiles")) {
if (Version.isAfter(Version.v1_8)) {
e.setCancelled(true);
}
PluginDataManager.saveAllCaches();
PlayerDataManager.saveAllCaches(true, false);
TLogger.getGlobalLogger().info("Successfully.");
} else if (e.getCommand().equalsIgnoreCase("tDebug")) {
if (Version.isAfter(Version.v1_8)) {
e.setCancelled(true);
}
if (TabooLibAPI.isDebug()) {
TabooLibAPI.setDebug(false);
TLogger.getGlobalLogger().info("&cDisabled.");
} else {
TabooLibAPI.setDebug(true);
TLogger.getGlobalLogger().info("&aEnabled.");
}
} else if (e.getCommand().equalsIgnoreCase("tExceptionEvent")) {
e.setCancelled(true);
throw new IllegalStateException("TabooLib Example Exception");
}
}
@EventHandler
public void cmd(PlayerCommandPreprocessEvent e) {
if (e.getMessage().equals("/tellrawTest") && e.getPlayer().hasPermission("taboolib.tellraw")) {
e.setCancelled(true);
TellrawJson.create()
.append("§8[§3§lTabooLib§8] §7TellrawJson Test: §f[")
.append(Items.getName(e.getPlayer().getItemInHand())).hoverItem(e.getPlayer().getItemInHand())
.append("§f]")
.send(e.getPlayer());
}
}
}

View File

@ -1,6 +1,7 @@
package me.skymc.taboolib.listener; package io.izzel.taboolib.listener;
import me.skymc.taboolib.events.PlayerJumpEvent; import io.izzel.taboolib.module.inject.TListener;
import io.izzel.taboolib.origin.event.PlayerJumpEvent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
@ -30,7 +31,7 @@ public class ListenerPlayerJump implements Listener {
PlayerJumpEvent evt = new PlayerJumpEvent(event.isCancelled(), event.getPlayer()); PlayerJumpEvent evt = new PlayerJumpEvent(event.isCancelled(), event.getPlayer());
Bukkit.getPluginManager().callEvent(evt); Bukkit.getPluginManager().callEvent(evt);
if (evt.isCancelled()) { if (evt.isCancelled()) {
event.setCancelled(true); event.setTo(event.getFrom());
} }
} else if (this.cooldown.get(event.getPlayer()) <= System.currentTimeMillis()) { } else if (this.cooldown.get(event.getPlayer()) <= System.currentTimeMillis()) {
this.cooldown.put(event.getPlayer(), System.currentTimeMillis() + 350L); this.cooldown.put(event.getPlayer(), System.currentTimeMillis() + 350L);
@ -38,7 +39,7 @@ public class ListenerPlayerJump implements Listener {
Bukkit.getPluginManager().callEvent(evt); Bukkit.getPluginManager().callEvent(evt);
if (evt.isCancelled()) { if (evt.isCancelled()) {
event.setCancelled(true); event.setTo(event.getFrom());
} }
} }
} }

View File

@ -1,16 +1,15 @@
package com.ilummc.tlib.resources; package io.izzel.taboolib.locale;
import com.ilummc.tlib.TLib; import io.izzel.taboolib.TabooLib;
import com.ilummc.tlib.bungee.api.ChatColor; import io.izzel.taboolib.module.logger.TLoggerManager;
import com.ilummc.tlib.bungee.api.chat.TextComponent; import io.izzel.taboolib.module.nms.NMSHandler;
import com.ilummc.tlib.bungee.chat.ComponentSerializer; import io.izzel.taboolib.module.tellraw.TellrawCreator;
import com.ilummc.tlib.inject.TLoggerManager; import io.izzel.taboolib.util.Ref;
import com.ilummc.tlib.util.Ref; import io.izzel.taboolib.util.Strings;
import com.ilummc.tlib.util.Strings; import io.izzel.taboolib.util.chat.ChatColor;
import io.izzel.taboolib.util.chat.ComponentSerializer;
import io.izzel.taboolib.util.chat.TextComponent;
import me.clip.placeholderapi.PlaceholderAPI; import me.clip.placeholderapi.PlaceholderAPI;
import me.skymc.taboolib.Main;
import me.skymc.taboolib.common.nms.NMSHandler;
import me.skymc.taboolib.json.tellraw.TellrawCreator;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -58,19 +57,19 @@ public class TLocale {
public static String asString(String path, String... args) { public static String asString(String path, String... args) {
try { try {
return asString(path, Ref.getCallerClass(3).orElse(Main.class), args); return asString(path, Ref.getCallerClass(3).orElse(TabooLib.class), args);
} catch (Exception e) { } catch (Exception e) {
TLib.getTLib().getLogger().error(Strings.replaceWithOrder(TLib.getInternalLanguage().getString("FETCH-LOCALE-ERROR"), path)); TabooLib.getLogger().error(Strings.replaceWithOrder(TabooLib.getInst().getInternal().getString("FETCH-LOCALE-ERROR"), path));
TLib.getTLib().getLogger().error(Strings.replaceWithOrder(TLib.getInternalLanguage().getString("LOCALE-ERROR-REASON"), e.getMessage())); TabooLib.getLogger().error(Strings.replaceWithOrder(TabooLib.getInst().getInternal().getString("LOCALE-ERROR-REASON"), e.getMessage()));
return "§4<" + path + "§4>"; return "§4<" + path + "§4>";
} }
} }
public static List<String> asStringList(String path, String... args) { public static List<String> asStringList(String path, String... args) {
try { try {
return asStringList(path, Ref.getCallerClass(3).orElse(Main.class), args); return asStringList(path, Ref.getCallerClass(3).orElse(TabooLib.class), args);
} catch (Exception e) { } catch (Exception e) {
TLib.getTLib().getLogger().error(Strings.replaceWithOrder(TLib.getInternalLanguage().getString("LOCALE-ERROR-REASON"), e.getMessage())); TabooLib.getLogger().error(Strings.replaceWithOrder(TabooLib.getInst().getInternal().getString("LOCALE-ERROR-REASON"), e.getMessage()));
return Collections.singletonList("§4<" + path + "§4>"); return Collections.singletonList("§4<" + path + "§4>");
} }
} }
@ -108,7 +107,7 @@ public class TLocale {
public static final class Translate extends TLocale { public static final class Translate extends TLocale {
public static boolean isPlaceholderUseDefault() { public static boolean isPlaceholderUseDefault() {
return Main.getInst().getConfig().getBoolean("LOCALE.USE_PAPI", false); return TabooLib.getConfig().getBoolean("LOCALE.USE_PAPI", false);
} }
public static boolean isPlaceholderPluginEnabled() { public static boolean isPlaceholderPluginEnabled() {

View File

@ -1,10 +1,9 @@
package com.ilummc.tlib.resources; package io.izzel.taboolib.locale;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.ilummc.tlib.TLib; import io.izzel.taboolib.TabooLib;
import com.ilummc.tlib.resources.type.TLocaleText; import io.izzel.taboolib.locale.type.TLocaleText;
import com.ilummc.tlib.util.Strings; import io.izzel.taboolib.util.Strings;
import me.skymc.taboolib.TabooLib;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -12,7 +11,10 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import javax.annotation.concurrent.ThreadSafe; import javax.annotation.concurrent.ThreadSafe;
import java.util.*; import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -59,8 +61,8 @@ class TLocaleInstance {
} }
}); });
} catch (Exception | Error e) { } catch (Exception | Error e) {
TLib.getTLib().getLogger().error(Strings.replaceWithOrder(TLib.getInternalLanguage().getString("SEND-LOCALE-ERROR"), path)); TabooLib.getLogger().error(Strings.replaceWithOrder(TabooLib.getInst().getInternal().getString("SEND-LOCALE-ERROR"), path));
TLib.getTLib().getLogger().error(Strings.replaceWithOrder(TLib.getInternalLanguage().getString("LOCALE-ERROR-REASON"), e.toString())); TabooLib.getLogger().error(Strings.replaceWithOrder(TabooLib.getInst().getInternal().getString("LOCALE-ERROR-REASON"), e.toString()));
} }
} }

View File

@ -0,0 +1,19 @@
package io.izzel.taboolib.locale;
import org.bukkit.command.CommandSender;
import java.util.List;
/**
* @Author sky
* @Since 2018-05-12 13:58
*/
public interface TLocaleSender {
void sendTo(CommandSender sender, String... args);
String asString(String... args);
List<String> asStringList(String... args);
}

View File

@ -1,4 +1,4 @@
package com.ilummc.tlib.resources; package io.izzel.taboolib.locale;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.ConfigurationSerializable;

View File

@ -1,11 +1,10 @@
package com.ilummc.tlib.resources.type; package io.izzel.taboolib.locale.type;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.ilummc.tlib.compat.PlaceholderHook; import io.izzel.taboolib.locale.TLocale;
import com.ilummc.tlib.resources.TLocale; import io.izzel.taboolib.locale.TLocaleSerialize;
import com.ilummc.tlib.resources.TLocaleSerialize; import io.izzel.taboolib.module.compat.PlaceholderHook;
import com.ilummc.tlib.util.Strings; import io.izzel.taboolib.util.Strings;
import me.skymc.taboolib.display.ActionUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.serialization.SerializableAs; import org.bukkit.configuration.serialization.SerializableAs;

View File

@ -1,14 +1,14 @@
package com.ilummc.tlib.resources.type; package io.izzel.taboolib.locale.type;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.ilummc.tlib.bungee.chat.ComponentSerializer; import io.izzel.taboolib.TabooLib;
import com.ilummc.tlib.resources.TLocale; import io.izzel.taboolib.locale.TLocale;
import com.ilummc.tlib.resources.TLocaleSerialize; import io.izzel.taboolib.locale.TLocaleSerialize;
import com.ilummc.tlib.util.Strings; import io.izzel.taboolib.module.tellraw.TellrawJson;
import me.skymc.taboolib.Main; import io.izzel.taboolib.origin.book.BookFormatter;
import me.skymc.taboolib.bookformatter.BookFormatter; import io.izzel.taboolib.origin.book.builder.BookBuilder;
import me.skymc.taboolib.bookformatter.builder.BookBuilder; import io.izzel.taboolib.util.Strings;
import me.skymc.taboolib.json.tellraw.TellrawJson; import io.izzel.taboolib.util.chat.ComponentSerializer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.serialization.SerializableAs; import org.bukkit.configuration.serialization.SerializableAs;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -77,9 +77,9 @@ public class TLocaleBook extends TLocaleSerialize {
public void run() { public void run() {
BookFormatter.forceOpen((Player) sender, bookBuilder.build()); BookFormatter.forceOpen((Player) sender, bookBuilder.build());
} }
}.runTask(Main.getInst()); }.runTask(TabooLib.getPlugin());
} }
}.runTaskAsynchronously(Main.getInst()); }.runTaskAsynchronously(TabooLib.getPlugin());
} }
private String format(TellrawJson jsonPage, CommandSender sender, String[] args) { private String format(TellrawJson jsonPage, CommandSender sender, String[] args) {

View File

@ -1,14 +1,14 @@
package com.ilummc.tlib.resources.type; package io.izzel.taboolib.locale.type;
import com.ilummc.tlib.resources.TLocale; import io.izzel.taboolib.locale.TLocale;
import com.ilummc.tlib.resources.TLocaleSerialize; import io.izzel.taboolib.locale.TLocaleSerialize;
import com.ilummc.tlib.util.Strings; import io.izzel.taboolib.util.Strings;
import me.skymc.taboolib.other.NumberUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.serialization.SerializableAs; import org.bukkit.configuration.serialization.SerializableAs;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.NumberConversions;
import org.inventivetalent.bossbar.BossBar; import org.inventivetalent.bossbar.BossBar;
import org.inventivetalent.bossbar.BossBarAPI; import org.inventivetalent.bossbar.BossBarAPI;
@ -72,7 +72,14 @@ public class TLocaleBossBar extends TLocaleSerialize {
} }
public static TLocaleBossBar valueOf(Map<String, Object> map) { public static TLocaleBossBar valueOf(Map<String, Object> map) {
return new TLocaleBossBar(map.getOrDefault("text", "§4* Invalid Text*").toString(), getColor(String.valueOf(map.get("color"))), getStyle(String.valueOf(map.get("style"))), (float) NumberUtils.getDouble(String.valueOf(map.getOrDefault("progress", 1))), NumberUtils.getInteger(String.valueOf(map.getOrDefault("timeout", 20))), NumberUtils.getInteger(String.valueOf(map.getOrDefault("timeout-interval", 2))), isPlaceholderEnabled(map)); return new TLocaleBossBar(
map.getOrDefault("text", "§4* Invalid Text*").toString(),
getColor(String.valueOf(map.get("color"))),
getStyle(String.valueOf(map.get("style"))),
NumberConversions.toFloat(map.getOrDefault("progress", 1)),
NumberConversions.toInt(map.getOrDefault("timeout", 20)),
NumberConversions.toInt(map.getOrDefault("timeout-interval", 2)),
isPlaceholderEnabled(map));
} }
private static BossBarAPI.Color getColor(String color) { private static BossBarAPI.Color getColor(String color) {

View File

@ -1,21 +1,19 @@
package com.ilummc.tlib.resources.type; package io.izzel.taboolib.locale.type;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.ilummc.tlib.TLib; import io.izzel.taboolib.TabooLib;
import com.ilummc.tlib.bungee.api.chat.*; import io.izzel.taboolib.locale.TLocale;
import com.ilummc.tlib.bungee.chat.ComponentSerializer; import io.izzel.taboolib.locale.TLocaleSerialize;
import com.ilummc.tlib.compat.PlaceholderHook; import io.izzel.taboolib.module.compat.PlaceholderHook;
import com.ilummc.tlib.resources.TLocale; import io.izzel.taboolib.module.tellraw.TellrawJson;
import com.ilummc.tlib.resources.TLocaleSerialize; import io.izzel.taboolib.util.Strings;
import com.ilummc.tlib.util.Strings; import io.izzel.taboolib.util.Variables;
import me.skymc.taboolib.inventory.ItemUtils; import io.izzel.taboolib.util.chat.*;
import me.skymc.taboolib.json.tellraw.TellrawJson;
import me.skymc.taboolib.other.NumberUtils;
import me.skymc.taboolib.string.VariableFormatter;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.serialization.SerializableAs; import org.bukkit.configuration.serialization.SerializableAs;
import org.bukkit.util.NumberConversions;
import javax.annotation.concurrent.ThreadSafe; import javax.annotation.concurrent.ThreadSafe;
import java.util.*; import java.util.*;
@ -88,7 +86,7 @@ public class TLocaleJson extends TLocaleSerialize {
} else { } else {
// 这个参数节点并没有找到于是随便放点字符串进去 // 这个参数节点并没有找到于是随便放点字符串进去
builder.addAll(Arrays.asList(TextComponent.fromLegacyText(text))); builder.addAll(Arrays.asList(TextComponent.fromLegacyText(text)));
TLib.getTLib().getLogger().warn(Strings.replaceWithOrder(TLib.getInternalLanguage().getString("MISSING-ARGUMENT"), node)); TabooLib.getLogger().warn(Strings.replaceWithOrder(TabooLib.getInst().getInternal().getString("MISSING-ARGUMENT"), node));
} }
// 有可能一开头就是 <@xxx>然后 split 出来就少了一些于是直接加上 // 有可能一开头就是 <@xxx>然后 split 出来就少了一些于是直接加上
if (index < template.length) { if (index < template.length) {
@ -171,7 +169,7 @@ public class TLocaleJson extends TLocaleSerialize {
// 遍历本页文本 // 遍历本页文本
for (int i = 0; i < textList.size(); i++) { for (int i = 0; i < textList.size(); i++) {
// 捕捉变量 // 捕捉变量
for (VariableFormatter.Variable variable : new VariableFormatter(TLocale.Translate.setColored(textList.get(i)), pattern).find().getVariableList()) { for (Variables.Variable variable : new Variables(TLocale.Translate.setColored(textList.get(i)), pattern).find().getVariableList()) {
// 如果是变量 // 如果是变量
if (variable.isVariable()) { if (variable.isVariable()) {
String[] split = variable.getText().split("@"); String[] split = variable.getText().split("@");
@ -199,9 +197,6 @@ public class TLocaleJson extends TLocaleSerialize {
// 文本 // 文本
pageJson.append(args.getOrDefault("text", text).toString()); pageJson.append(args.getOrDefault("text", text).toString());
// 功能 // 功能
if (args.containsKey("item")) {
pageJson.hoverItem(ItemUtils.getCacheItem(args.get("item").toString()));
}
if (args.containsKey("hover")) { if (args.containsKey("hover")) {
pageJson.hoverText(args.get("hover").toString()); pageJson.hoverText(args.get("hover").toString());
} }
@ -212,7 +207,7 @@ public class TLocaleJson extends TLocaleSerialize {
pageJson.clickCommand(args.get("command").toString()); pageJson.clickCommand(args.get("command").toString());
} }
if (args.containsKey("page")) { if (args.containsKey("page")) {
pageJson.clickChangePage(NumberUtils.getInteger(args.get("page").toString())); pageJson.clickChangePage(NumberConversions.toInt(args.get("page").toString()));
} }
if (args.containsKey("url")) { if (args.containsKey("url")) {
pageJson.clickOpenURL(args.get("url").toString()); pageJson.clickOpenURL(args.get("url").toString());

View File

@ -1,8 +1,8 @@
package com.ilummc.tlib.resources.type; package io.izzel.taboolib.locale.type;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.ilummc.tlib.resources.TLocaleSerialize; import io.izzel.taboolib.locale.TLocaleSerialize;
import me.skymc.taboolib.sound.SoundPack; import io.izzel.taboolib.origin.lite.Sounds;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.serialization.SerializableAs; import org.bukkit.configuration.serialization.SerializableAs;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -21,19 +21,19 @@ import java.util.stream.Collectors;
@SerializableAs("ACTION") @SerializableAs("ACTION")
public class TLocaleSound extends TLocaleSerialize { public class TLocaleSound extends TLocaleSerialize {
private final List<SoundPack> soundPacks; private final List<Sounds> soundPacks;
public TLocaleSound(List<SoundPack> soundPacks) { public TLocaleSound(List<Sounds> soundPacks) {
this.soundPacks = soundPacks; this.soundPacks = soundPacks;
} }
public static TLocaleSound valueOf(Map<String, Object> map) { public static TLocaleSound valueOf(Map<String, Object> map) {
List<SoundPack> soundPacks = new ArrayList<>(); List<Sounds> soundPacks = new ArrayList<>();
Object sounds = map.containsKey("sounds") ? map.get("sounds") : map.getOrDefault("sound", ""); Object sounds = map.containsKey("sounds") ? map.get("sounds") : map.getOrDefault("sound", "");
if (sounds instanceof List) { if (sounds instanceof List) {
soundPacks = ((List<String>) sounds).stream().map(SoundPack::new).collect(Collectors.toList()); soundPacks = ((List<String>) sounds).stream().map(Sounds::new).collect(Collectors.toList());
} else { } else {
soundPacks.add(new SoundPack(sounds.toString())); soundPacks.add(new Sounds(sounds.toString()));
} }
return new TLocaleSound(soundPacks); return new TLocaleSound(soundPacks);
} }
@ -61,7 +61,7 @@ public class TLocaleSound extends TLocaleSerialize {
if (soundPacks.size() == 1) { if (soundPacks.size() == 1) {
map.put("sounds", soundPacks.get(0).toString()); map.put("sounds", soundPacks.get(0).toString());
} else if (soundPacks.size() > 1) { } else if (soundPacks.size() > 1) {
map.put("sounds", soundPacks.stream().map(SoundPack::toString).collect(Collectors.toList())); map.put("sounds", soundPacks.stream().map(Sounds::toString).collect(Collectors.toList()));
} }
return map; return map;
} }

View File

@ -1,13 +1,11 @@
package com.ilummc.tlib.resources.type; package io.izzel.taboolib.locale.type;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.ilummc.tlib.compat.PlaceholderHook; import io.izzel.taboolib.locale.TLocale;
import com.ilummc.tlib.resources.TLocale; import io.izzel.taboolib.locale.TLocaleSerialize;
import com.ilummc.tlib.resources.TLocaleSerialize; import io.izzel.taboolib.util.Strings;
import com.ilummc.tlib.util.Strings;
import me.skymc.taboolib.Main;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.serialization.SerializableAs; import org.bukkit.configuration.serialization.SerializableAs;

View File

@ -1,10 +1,9 @@
package com.ilummc.tlib.resources.type; package io.izzel.taboolib.locale.type;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.ilummc.tlib.resources.TLocale; import io.izzel.taboolib.locale.TLocale;
import com.ilummc.tlib.resources.TLocaleSerialize; import io.izzel.taboolib.locale.TLocaleSerialize;
import com.ilummc.tlib.util.Strings; import io.izzel.taboolib.util.Strings;
import me.skymc.taboolib.display.TitleUtils;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.serialization.SerializableAs; import org.bukkit.configuration.serialization.SerializableAs;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -1,4 +1,4 @@
package me.skymc.taboolib.common.pathfinder; package io.izzel.taboolib.module.ai;
/** /**
* @Author sky * @Author sky

View File

@ -1,4 +1,4 @@
package me.skymc.taboolib.common.pathfinder; package io.izzel.taboolib.module.ai;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;

View File

@ -1,4 +1,4 @@
package me.skymc.taboolib.common.pathfinder; package io.izzel.taboolib.module.ai;
/** /**
* @Author sky * @Author sky

View File

@ -1,22 +1,22 @@
package me.skymc.taboolib.common.pathfinder; package io.izzel.taboolib.module.ai;
import me.skymc.taboolib.common.loader.Instantiable; import io.izzel.taboolib.module.inject.TFunction;
import me.skymc.taboolib.common.versioncontrol.SimpleVersionControl; import io.izzel.taboolib.module.lite.SimpleVersionControl;
/** /**
* @Author sky * @Author sky
* @Since 2018-09-19 20:31 * @Since 2018-09-19 20:31
*/ */
@Instantiable("SimpleAiSelector") @TFunction(enable = "init")
public class SimpleAiSelector { public class SimpleAiSelector {
private static PathfinderCreator internalPathfinderCreator; private static PathfinderCreator internalPathfinderCreator;
private static PathfinderExecutor internalPathfinderExecutor; private static PathfinderExecutor internalPathfinderExecutor;
public SimpleAiSelector() { static void init() {
try { try {
internalPathfinderCreator = (PathfinderCreator) SimpleVersionControl.createNMS("me.skymc.taboolib.common.pathfinder.internal.InternalPathfinderCreator").translate().newInstance(); internalPathfinderCreator = (PathfinderCreator) SimpleVersionControl.createNMS("io.izzel.taboolib.module.ai.internal.InternalPathfinderCreator").translate().newInstance();
internalPathfinderExecutor = (PathfinderExecutor) SimpleVersionControl.createNMS("me.skymc.taboolib.common.pathfinder.internal.InternalPathfinderExecutor").translate().newInstance(); internalPathfinderExecutor = (PathfinderExecutor) SimpleVersionControl.createNMS("io.izzel.taboolib.module.ai.internal.InternalPathfinderExecutor").translate().newInstance();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -1,7 +1,7 @@
package me.skymc.taboolib.common.pathfinder.internal; package io.izzel.taboolib.module.ai.internal;
import me.skymc.taboolib.common.pathfinder.PathfinderCreator; import io.izzel.taboolib.module.ai.PathfinderCreator;
import me.skymc.taboolib.common.pathfinder.SimpleAi; import io.izzel.taboolib.module.ai.SimpleAi;
/** /**
* 该类仅用作生成 ASM 代码无任何意义 * 该类仅用作生成 ASM 代码无任何意义

View File

@ -1,9 +1,9 @@
package me.skymc.taboolib.common.pathfinder.internal; package io.izzel.taboolib.module.ai.internal;
import me.skymc.taboolib.common.pathfinder.PathfinderExecutor; import io.izzel.taboolib.module.ai.PathfinderExecutor;
import me.skymc.taboolib.common.pathfinder.SimpleAi; import io.izzel.taboolib.module.ai.SimpleAi;
import me.skymc.taboolib.common.pathfinder.SimpleAiSelector; import io.izzel.taboolib.module.ai.SimpleAiSelector;
import me.skymc.taboolib.nms.NMSUtils; import io.izzel.taboolib.module.lite.SimpleReflection;
import net.minecraft.server.v1_8_R3.*; import net.minecraft.server.v1_8_R3.*;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
@ -27,18 +27,17 @@ public class InternalPathfinderExecutor extends PathfinderExecutor {
public InternalPathfinderExecutor() { public InternalPathfinderExecutor() {
try { try {
pathfinderGoalSelectorSet = NMSUtils.getNMSClass("PathfinderGoalSelector").getDeclaredField("b"); SimpleReflection.saveField(PathfinderGoalSelector.class);
pathfinderGoalSelectorSet.setAccessible(true); SimpleReflection.saveField(ControllerJump.class);
controllerJumpCurrent = NMSUtils.getNMSClass("ControllerJump").getDeclaredField("a"); pathfinderGoalSelectorSet =SimpleReflection.getField(PathfinderGoalSelector.class, "b");
controllerJumpCurrent.setAccessible(true); controllerJumpCurrent = SimpleReflection.getField(ControllerJump.class, "a");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
try { try {
Class<?> pathEntityClass = NMSUtils.getNMSClass("PathEntity"); SimpleReflection.saveField(NavigationAbstract.class);
for (Field field : NMSUtils.getNMSClass("NavigationAbstract").getDeclaredFields()) { for (Field field : SimpleReflection.getFields(NavigationAbstract.class).values()) {
if (field.getType().equals(pathEntityClass)) { if (field.getType().equals(PathEntity.class)) {
field.setAccessible(true);
pathEntity = field; pathEntity = field;
return; return;
} }

View File

@ -1,10 +1,9 @@
package me.skymc.taboolib.commands.internal; package io.izzel.taboolib.module.command;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import java.util.List;
/** /**
* @Author sky * @Author sky

View File

@ -1,18 +1,15 @@
package me.skymc.taboolib.commands.internal; package io.izzel.taboolib.module.command;
import com.ilummc.tlib.inject.TPluginManager; import io.izzel.taboolib.TabooLibAPI;
import com.ilummc.tlib.resources.TLocale; import io.izzel.taboolib.locale.TLocale;
import me.skymc.taboolib.TabooLib; import io.izzel.taboolib.module.command.base.BaseMainCommand;
import me.skymc.taboolib.common.util.SimpleReflection; import io.izzel.taboolib.module.inject.TFunction;
import me.skymc.taboolib.fileutils.FileUtils; import io.izzel.taboolib.module.lite.SimpleReflection;
import me.skymc.taboolib.listener.TListener; import io.izzel.taboolib.util.ArrayUtil;
import me.skymc.taboolib.methods.ReflectionUtils; import io.izzel.taboolib.util.Files;
import me.skymc.taboolib.string.ArrayUtils; import io.izzel.taboolib.util.Reflection;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.*; import org.bukkit.command.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.SimplePluginManager; import org.bukkit.plugin.SimplePluginManager;
@ -26,30 +23,17 @@ import java.util.stream.Collectors;
* @Author sky * @Author sky
* @Since 2018-05-23 2:43 * @Since 2018-05-23 2:43
*/ */
@TListener @TFunction(enable = "init")
public class TCommandHandler implements Listener { public class TCommandHandler {
private static SimpleCommandMap commandMap; private static SimpleCommandMap commandMap;
private static Map<String, Command> knownCommands; private static Map<String, Command> knownCommands;
public TCommandHandler() { static void init() {
SimpleReflection.saveField(Bukkit.getPluginManager() instanceof TPluginManager ? TPluginManager.class : SimplePluginManager.class, "commandMap"); SimpleReflection.saveField(SimplePluginManager.class, "commandMap");
SimpleReflection.saveField(SimpleCommandMap.class, "knownCommands"); SimpleReflection.saveField(SimpleCommandMap.class, "knownCommands");
commandMap = (SimpleCommandMap) SimpleReflection.getFieldValue(Bukkit.getPluginManager() instanceof TPluginManager ? TPluginManager.class : SimplePluginManager.class, Bukkit.getPluginManager(), "commandMap"); commandMap = (SimpleCommandMap) SimpleReflection.getFieldValue(SimplePluginManager.class, Bukkit.getPluginManager(), "commandMap");
knownCommands = (Map<String, Command>) SimpleReflection.getFieldValue(SimpleCommandMap.class, commandMap, "knownCommands"); knownCommands = (Map<String, Command>) SimpleReflection.getFieldValue(SimpleCommandMap.class, commandMap, "knownCommands");
try {
registerCommands();
} catch (Exception e) {
e.printStackTrace();
}
}
@EventHandler
public void onEnable(PluginEnableEvent e) {
try {
registerCommand(e.getPlugin());
} catch (Exception ignored) {
}
} }
public static boolean registerPluginCommand(Plugin plugin, String command, CommandExecutor commandExecutor) { public static boolean registerPluginCommand(Plugin plugin, String command, CommandExecutor commandExecutor) {
@ -72,8 +56,11 @@ public class TCommandHandler implements Listener {
return registerPluginCommand(plugin, command, description, usage, aliases, null, null, commandExecutor, tabCompleter); return registerPluginCommand(plugin, command, description, usage, aliases, null, null, commandExecutor, tabCompleter);
} }
public static boolean registerPluginCommand(Plugin plugin, String command, String description, String usage, List<String> aliases, String permission, String permissionMessage, CommandExecutor commandExecutor, TabCompleter tabCompleter) { /**
return registerPluginCommand(plugin, command, description, usage, aliases, permission, permissionMessage, commandExecutor, tabCompleter, false); * 获取插件注册的命令
*/
public static Command getPluginCommand(String command) {
return commandMap.getCommand(command);
} }
/** /**
@ -88,27 +75,23 @@ public class TCommandHandler implements Listener {
* @param permissionMessage 权限提示 * @param permissionMessage 权限提示
* @param commandExecutor 命令执行器 * @param commandExecutor 命令执行器
* @param tabCompleter 补全执行器 * @param tabCompleter 补全执行器
* @param silence 是否屏蔽提示
* @return 注册结果(boolean) * @return 注册结果(boolean)
*/ */
public static boolean registerPluginCommand(Plugin plugin, String command, String description, String usage, List<String> aliases, String permission, String permissionMessage, CommandExecutor commandExecutor, TabCompleter tabCompleter, boolean silence) { public static boolean registerPluginCommand(Plugin plugin, String command, String description, String usage, List<String> aliases, String permission, String permissionMessage, CommandExecutor commandExecutor, TabCompleter tabCompleter) {
try { try {
Constructor<PluginCommand> constructor = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class); Constructor<PluginCommand> constructor = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class);
constructor.setAccessible(true); constructor.setAccessible(true);
PluginCommand pluginCommand = constructor.newInstance(command, plugin); PluginCommand pluginCommand = constructor.newInstance(command, plugin);
pluginCommand.setExecutor(commandExecutor); pluginCommand.setExecutor(commandExecutor);
pluginCommand.setTabCompleter(tabCompleter); pluginCommand.setTabCompleter(tabCompleter);
ReflectionUtils.setValue(pluginCommand, pluginCommand.getClass().getSuperclass(), true, "description", description); Reflection.setValue(pluginCommand, pluginCommand.getClass().getSuperclass(), true, "description", description);
ReflectionUtils.setValue(pluginCommand, pluginCommand.getClass().getSuperclass(), true, "usageMessage", usage); Reflection.setValue(pluginCommand, pluginCommand.getClass().getSuperclass(), true, "usageMessage", usage);
ReflectionUtils.setValue(pluginCommand, pluginCommand.getClass().getSuperclass(), true, "aliases", aliases.stream().map(String::toLowerCase).collect(Collectors.toList())); Reflection.setValue(pluginCommand, pluginCommand.getClass().getSuperclass(), true, "aliases", aliases.stream().map(String::toLowerCase).collect(Collectors.toList()));
ReflectionUtils.setValue(pluginCommand, pluginCommand.getClass().getSuperclass(), true, "activeAliases", aliases.stream().map(String::toLowerCase).collect(Collectors.toList())); Reflection.setValue(pluginCommand, pluginCommand.getClass().getSuperclass(), true, "activeAliases", aliases.stream().map(String::toLowerCase).collect(Collectors.toList()));
ReflectionUtils.setValue(pluginCommand, pluginCommand.getClass().getSuperclass(), true, "permission", permission); Reflection.setValue(pluginCommand, pluginCommand.getClass().getSuperclass(), true, "permission", permission);
ReflectionUtils.setValue(pluginCommand, pluginCommand.getClass().getSuperclass(), true, "permissionMessage", permissionMessage); Reflection.setValue(pluginCommand, pluginCommand.getClass().getSuperclass(), true, "permissionMessage", permissionMessage);
commandMap.register(plugin.getName(), pluginCommand); commandMap.register(plugin.getName(), pluginCommand);
TabooLib.debug("Command " + command + " created. (" + plugin.getName() + ")"); TabooLibAPI.debug("Command " + command + " created. (" + plugin.getName() + ")");
// if (!TabooLib.isTabooLib(plugin) && !silence) {
// TLocale.Logger.info("COMMANDS.INTERNAL.COMMAND-CREATE", plugin.getName(), command);
// }
return true; return true;
} catch (Exception e) { } catch (Exception e) {
TLocale.Logger.error("COMMANDS.INTERNAL.COMMAND-CREATE-FAILED", plugin.getName(), command, e.toString()); TLocale.Logger.error("COMMANDS.INTERNAL.COMMAND-CREATE-FAILED", plugin.getName(), command, e.toString());
@ -129,40 +112,23 @@ public class TCommandHandler implements Listener {
registerPluginCommand( registerPluginCommand(
plugin, plugin,
command, command,
ArrayUtils.skipEmpty(tCommand.description(), "Registered by TabooLib."), ArrayUtil.skipEmpty(tCommand.description(), "Registered by TabooLib."),
ArrayUtils.skipEmpty(tCommand.usage(), "/" + command), ArrayUtil.skipEmpty(tCommand.usage(), "/" + command),
ArrayUtils.skipEmpty(ArrayUtils.asList(tCommand.aliases()), new ArrayList<>()), ArrayUtil.skipEmpty(ArrayUtil.asList(tCommand.aliases()), new ArrayList<>()),
ArrayUtils.skipEmpty(tCommand.permission()), ArrayUtil.skipEmpty(tCommand.permission()),
ArrayUtils.skipEmpty(tCommand.permissionMessage()), ArrayUtil.skipEmpty(tCommand.permissionMessage()),
baseMainCommand, baseMainCommand,
baseMainCommand); baseMainCommand);
} }
return BaseMainCommand.createCommandExecutor(command, baseMainCommand); return BaseMainCommand.createCommandExecutor(command, baseMainCommand);
} }
/**
* 注册所有插件的所有 TCommand 命令
*/
public static void registerCommands() {
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
try {
registerCommand(plugin);
} catch (Exception e) {
e.printStackTrace();
}
}
}
/** /**
* 注册插件的所有 TCommand 命令 * 注册插件的所有 TCommand 命令
*
* @param plugin 插件
*/ */
public static void registerCommand(Plugin plugin) { public static void registerCommand(Plugin plugin) {
if (!(plugin.equals(TabooLib.instance()) || TabooLib.isDependTabooLib(plugin))) { for (Class pluginClass : Files.getClasses(plugin)) {
return;
}
for (Class pluginClass : FileUtils.getClasses(plugin)) {
if (BaseMainCommand.class.isAssignableFrom(pluginClass) && pluginClass.isAnnotationPresent(TCommand.class)) { if (BaseMainCommand.class.isAssignableFrom(pluginClass) && pluginClass.isAnnotationPresent(TCommand.class)) {
TCommand tCommand = (TCommand) pluginClass.getAnnotation(TCommand.class); TCommand tCommand = (TCommand) pluginClass.getAnnotation(TCommand.class);
try { try {
@ -174,16 +140,6 @@ public class TCommandHandler implements Listener {
} }
} }
/**
* 获取插件注册的命令
*
* @param command 命令名称
* @return {@link Command}
*/
public static Command getPluginCommand(String command) {
return commandMap.getCommand(command);
}
// ********************************* // *********************************
// //
// Getter and Setter // Getter and Setter

View File

@ -1,22 +1,25 @@
package me.skymc.taboolib.commands.internal; package io.izzel.taboolib.module.command.base;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.ilummc.tlib.resources.TLocale; import io.izzel.taboolib.TabooLib;
import me.skymc.taboolib.Main; import io.izzel.taboolib.TabooLibAPI;
import me.skymc.taboolib.TabooLib; import io.izzel.taboolib.Version;
import me.skymc.taboolib.commands.internal.type.*; import io.izzel.taboolib.locale.TLocale;
import me.skymc.taboolib.string.ArrayUtils; import io.izzel.taboolib.util.ArrayUtil;
import me.skymc.taboolib.string.StringUtils; import io.izzel.taboolib.util.Strings;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.*; import org.bukkit.command.*;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.*; import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -28,7 +31,7 @@ public abstract class BaseMainCommand implements CommandExecutor, TabExecutor {
private PluginCommand registerCommand; private PluginCommand registerCommand;
private List<Class<?>> linkClasses = new CopyOnWriteArrayList<>(); private List<Class<?>> linkClasses = new CopyOnWriteArrayList<>();
private List<BaseSubCommand> subCommands = new CopyOnWriteArrayList<>(); private List<io.izzel.taboolib.module.command.base.BaseSubCommand> subCommands = new CopyOnWriteArrayList<>();
public static BaseMainCommand createCommandExecutor(String command, BaseMainCommand baseMainCommand) { public static BaseMainCommand createCommandExecutor(String command, BaseMainCommand baseMainCommand) {
Preconditions.checkArgument(Bukkit.getPluginCommand(command) != null, "PluginCommand \"" + command + "\" not found"); Preconditions.checkArgument(Bukkit.getPluginCommand(command) != null, "PluginCommand \"" + command + "\" not found");
@ -46,7 +49,7 @@ public abstract class BaseMainCommand implements CommandExecutor, TabExecutor {
public static void loadCommandRegister(BaseMainCommand baseMainCommand) { public static void loadCommandRegister(BaseMainCommand baseMainCommand) {
List<Method> methods = new ArrayList<>(); List<Method> methods = new ArrayList<>();
List<CommandField> fields = new ArrayList<>(); List<CommandField> fields = new ArrayList<>();
baseMainCommand.getLinkClasses().forEach(clazz -> Arrays.stream(clazz.getDeclaredMethods()).filter(method -> method.getAnnotation(CommandRegister.class) != null).forEach(methods::add)); baseMainCommand.getLinkClasses().forEach(clazz -> java.util.Arrays.stream(clazz.getDeclaredMethods()).filter(method -> method.getAnnotation(CommandRegister.class) != null).forEach(methods::add));
if (methods.size() > 0) { if (methods.size() > 0) {
methods.sort(Comparator.comparingDouble(a -> a.getAnnotation(CommandRegister.class).priority())); methods.sort(Comparator.comparingDouble(a -> a.getAnnotation(CommandRegister.class).priority()));
methods.forEach(x -> { methods.forEach(x -> {
@ -57,13 +60,13 @@ public abstract class BaseMainCommand implements CommandExecutor, TabExecutor {
} }
}); });
} }
baseMainCommand.getLinkClasses().forEach(clazz -> Arrays.stream(clazz.getDeclaredFields()).filter(field -> field.getAnnotation(CommandRegister.class) != null && field.getType().equals(BaseSubCommand.class)).forEach(field -> fields.add(new CommandField(field, clazz)))); baseMainCommand.getLinkClasses().forEach(clazz -> java.util.Arrays.stream(clazz.getDeclaredFields()).filter(field -> field.getAnnotation(CommandRegister.class) != null && field.getType().equals(io.izzel.taboolib.module.command.base.BaseSubCommand.class)).forEach(field -> fields.add(new CommandField(field, clazz))));
if (fields.size() > 0) { if (fields.size() > 0) {
fields.sort(Comparator.comparingDouble(commandField -> commandField.getField().getAnnotation(CommandRegister.class).priority())); fields.sort(Comparator.comparingDouble(commandField -> commandField.getField().getAnnotation(CommandRegister.class).priority()));
fields.forEach(commandField -> { fields.forEach(commandField -> {
try { try {
commandField.getField().setAccessible(true); commandField.getField().setAccessible(true);
BaseSubCommand subCommand = (BaseSubCommand) commandField.getField().get(commandField.getParent().newInstance()); io.izzel.taboolib.module.command.base.BaseSubCommand subCommand = (io.izzel.taboolib.module.command.base.BaseSubCommand) commandField.getField().get(commandField.getParent().newInstance());
subCommand.setLabel(commandField.getField().getName()); subCommand.setLabel(commandField.getField().getName());
baseMainCommand.registerSubCommand(subCommand); baseMainCommand.registerSubCommand(subCommand);
} catch (Exception ignored) { } catch (Exception ignored) {
@ -71,8 +74,7 @@ public abstract class BaseMainCommand implements CommandExecutor, TabExecutor {
}); });
} }
if (methods.size() + fields.size() > 0) { if (methods.size() + fields.size() > 0) {
TabooLib.debug("Registered " + (methods.size() + fields.size()) + " sub-command with " + baseMainCommand.getRegisterCommand().getName() + " (" + baseMainCommand.getRegisterCommand().getPlugin().getName() + ")"); TabooLibAPI.debug("Registered " + (methods.size() + fields.size()) + " sub-command with " + baseMainCommand.getRegisterCommand().getName() + " (" + baseMainCommand.getRegisterCommand().getPlugin().getName() + ")");
// TLocale.Logger.info("COMMANDS.INTERNAL.COMMAND-REGISTER", baseMainCommand.getRegisterCommand().getPlugin().getName(), baseMainCommand.getRegisterCommand().getName(), String.valueOf(methods.size() + fields.size()));
} }
} }
@ -88,11 +90,11 @@ public abstract class BaseMainCommand implements CommandExecutor, TabExecutor {
return linkClasses; return linkClasses;
} }
public List<BaseSubCommand> getSubCommands() { public List<io.izzel.taboolib.module.command.base.BaseSubCommand> getSubCommands() {
return subCommands; return subCommands;
} }
public void registerSubCommand(BaseSubCommand subCommand) { public void registerSubCommand(io.izzel.taboolib.module.command.base.BaseSubCommand subCommand) {
if (subCommand != null) { if (subCommand != null) {
Preconditions.checkArgument(subCommand.getLabel() != null, "Command label can not be null"); Preconditions.checkArgument(subCommand.getLabel() != null, "Command label can not be null");
Preconditions.checkArgument(subCommand.getArguments() != null, "Command arguments can not be null"); Preconditions.checkArgument(subCommand.getArguments() != null, "Command arguments can not be null");
@ -120,7 +122,7 @@ public abstract class BaseMainCommand implements CommandExecutor, TabExecutor {
}); });
return label.stream().filter(l -> args[0].isEmpty() || l.toLowerCase().startsWith(args[0].toLowerCase())).collect(Collectors.toList()); return label.stream().filter(l -> args[0].isEmpty() || l.toLowerCase().startsWith(args[0].toLowerCase())).collect(Collectors.toList());
} }
for (BaseSubCommand subCommand : subCommands) { for (io.izzel.taboolib.module.command.base.BaseSubCommand subCommand : subCommands) {
CommandArgument[] arguments = subCommand.getArguments(); CommandArgument[] arguments = subCommand.getArguments();
if (args[0].equalsIgnoreCase(subCommand.getLabel()) && args.length - 1 <= arguments.length) { if (args[0].equalsIgnoreCase(subCommand.getLabel()) && args.length - 1 <= arguments.length) {
CommandTab commandTab = arguments[args.length - 2].getTab(); CommandTab commandTab = arguments[args.length - 2].getTab();
@ -137,15 +139,15 @@ public abstract class BaseMainCommand implements CommandExecutor, TabExecutor {
if (args.length == 0) { if (args.length == 0) {
onCommandHelp(sender, command, label, args); onCommandHelp(sender, command, label, args);
} else { } else {
for (BaseSubCommand subCommand : subCommands) { for (io.izzel.taboolib.module.command.base.BaseSubCommand subCommand : subCommands) {
if (subCommand == null || !(args[0].equalsIgnoreCase(subCommand.getLabel()) || Arrays.stream(subCommand.getAliases()).anyMatch(args[0]::equalsIgnoreCase)) || !hasPermission(sender, subCommand)) { if (subCommand == null || !(args[0].equalsIgnoreCase(subCommand.getLabel()) || java.util.Arrays.stream(subCommand.getAliases()).anyMatch(args[0]::equalsIgnoreCase)) || !hasPermission(sender, subCommand)) {
continue; continue;
} }
if (!isConfirmType(sender, subCommand.getType())) { if (!isConfirmType(sender, subCommand.getType())) {
TLocale.sendTo(sender, "COMMANDS.INTERNAL.TYPE-ERROR", args[0], TLocale.asString("COMMANDS.INTERNAL.TYPE-" + subCommand.getType())); TLocale.sendTo(sender, "COMMANDS.INTERNAL.TYPE-ERROR", args[0], TLocale.asString("COMMANDS.INTERNAL.TYPE-" + subCommand.getType()));
return true; return true;
} }
String[] subCommandArgs = ArrayUtils.removeFirst(args); String[] subCommandArgs = ArrayUtil.removeFirst(args);
if (subCommand.isParameterConform(subCommandArgs)) { if (subCommand.isParameterConform(subCommandArgs)) {
subCommand.onCommand(sender, command, label, subCommand.ignoredLabel() ? subCommandArgs : args); subCommand.onCommand(sender, command, label, subCommand.ignoredLabel() ? subCommandArgs : args);
} else { } else {
@ -157,12 +159,12 @@ public abstract class BaseMainCommand implements CommandExecutor, TabExecutor {
@Override @Override
public void run() { public void run() {
List<BaseSubCommand> commandCompute = subCommands.stream().filter(x -> x != null && hasPermission(sender, x)).sorted((b, a) -> Double.compare(StringUtils.similarDegree(args[0], a.getLabel()), StringUtils.similarDegree(args[0], b.getLabel()))).collect(Collectors.toList()); List<io.izzel.taboolib.module.command.base.BaseSubCommand> commandCompute = subCommands.stream().filter(x -> x != null && hasPermission(sender, x)).sorted((b, a) -> Double.compare(Strings.similarDegree(args[0], a.getLabel()), Strings.similarDegree(args[0], b.getLabel()))).collect(Collectors.toList());
if (commandCompute.size() > 0) { if (commandCompute.size() > 0) {
TLocale.sendTo(sender, "COMMANDS.INTERNAL.ERROR-COMMAND", args[0], commandCompute.get(0).getCommandString(label).trim()); TLocale.sendTo(sender, "COMMANDS.INTERNAL.ERROR-COMMAND", args[0], commandCompute.get(0).getCommandString(label).trim());
} }
} }
}.runTaskAsynchronously(Main.getInst()); }.runTaskAsynchronously(TabooLib.getPlugin());
} }
return true; return true;
} }
@ -196,7 +198,7 @@ public abstract class BaseMainCommand implements CommandExecutor, TabExecutor {
// ********************************* // *********************************
private String getEmptyLine() { private String getEmptyLine() {
return TabooLib.getVerint() < 10800 ? "~" : ""; return Version.isAfter(Version.v1_8) ? "" : "~";
} }
private boolean isConfirmType(CommandSender sender, CommandType commandType) { private boolean isConfirmType(CommandSender sender, CommandType commandType) {
@ -206,10 +208,10 @@ public abstract class BaseMainCommand implements CommandExecutor, TabExecutor {
} }
private void disguisedPlugin() { private void disguisedPlugin() {
linkClasses.forEach(clazz -> disguisedPlugin(clazz, (JavaPlugin) registerCommand.getPlugin())); linkClasses.forEach(clazz -> disguisedPlugin(clazz, registerCommand.getPlugin()));
} }
private void disguisedPlugin(Class<?> targetClass, JavaPlugin plugin) { private void disguisedPlugin(Class<?> targetClass, Plugin plugin) {
try { try {
Field pluginField = targetClass.getClassLoader().getClass().getDeclaredField("plugin"); Field pluginField = targetClass.getClassLoader().getClass().getDeclaredField("plugin");
pluginField.setAccessible(true); pluginField.setAccessible(true);
@ -218,7 +220,7 @@ public abstract class BaseMainCommand implements CommandExecutor, TabExecutor {
} }
} }
private boolean hideInHelp(BaseSubCommand baseSubCommand) { private boolean hideInHelp(io.izzel.taboolib.module.command.base.BaseSubCommand baseSubCommand) {
return baseSubCommand != null && baseSubCommand.hideInHelp(); return baseSubCommand != null && baseSubCommand.hideInHelp();
} }

View File

@ -1,8 +1,6 @@
package me.skymc.taboolib.commands.internal; package io.izzel.taboolib.module.command.base;
import com.ilummc.tlib.resources.TLocale; import io.izzel.taboolib.locale.TLocale;
import me.skymc.taboolib.commands.internal.type.CommandArgument;
import me.skymc.taboolib.commands.internal.type.CommandType;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -1,6 +1,6 @@
package me.skymc.taboolib.commands.internal.type; package io.izzel.taboolib.module.command.base;
import com.ilummc.tlib.resources.TLocale; import io.izzel.taboolib.locale.TLocale;
import java.util.Objects; import java.util.Objects;

View File

@ -1,4 +1,4 @@
package me.skymc.taboolib.commands.internal.type; package io.izzel.taboolib.module.command.base;
import java.lang.reflect.Field; import java.lang.reflect.Field;

View File

@ -1,4 +1,4 @@
package me.skymc.taboolib.commands.internal.type; package io.izzel.taboolib.module.command.base;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;

View File

@ -1,4 +1,4 @@
package me.skymc.taboolib.commands.internal.type; package io.izzel.taboolib.module.command.base;
import java.util.List; import java.util.List;

View File

@ -1,4 +1,4 @@
package me.skymc.taboolib.commands.internal.type; package io.izzel.taboolib.module.command.base;
/** /**
* @author Bkm016 * @author Bkm016

View File

@ -1,4 +1,4 @@
package me.skymc.taboolib.commands.builder.type; package io.izzel.taboolib.module.command.lite;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -9,6 +9,6 @@ import org.bukkit.command.CommandSender;
*/ */
public interface CompleterCommand { public interface CompleterCommand {
boolean execute(CommandSender sender, String[] args); void execute(CommandSender sender, String[] args);
} }

View File

@ -1,4 +1,4 @@
package me.skymc.taboolib.commands.builder.type; package io.izzel.taboolib.module.command.lite;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -1,11 +1,8 @@
package me.skymc.taboolib.commands.builder; package io.izzel.taboolib.module.command.lite;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.Lists; import io.izzel.taboolib.module.command.TCommandHandler;
import me.skymc.taboolib.commands.builder.type.CompleterCommand; import io.izzel.taboolib.util.ArrayUtil;
import me.skymc.taboolib.commands.builder.type.CompleterTab;
import me.skymc.taboolib.commands.internal.TCommandHandler;
import me.skymc.taboolib.string.ArrayUtils;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import java.util.ArrayList; import java.util.ArrayList;
@ -19,7 +16,7 @@ import java.util.List;
public class SimpleCommandBuilder { public class SimpleCommandBuilder {
public static final CompleterTab EMPTY_COMPLETER_TAB = ((sender, args) -> new ArrayList<>()); public static final CompleterTab EMPTY_COMPLETER_TAB = ((sender, args) -> new ArrayList<>());
public static final CompleterCommand EMPTY_COMPLETER_COMMAND = ((sender, args) -> false); public static final CompleterCommand EMPTY_COMPLETER_COMMAND = ((sender, args) -> {});
private String command; private String command;
private Plugin plugin; private Plugin plugin;
@ -30,7 +27,6 @@ public class SimpleCommandBuilder {
private String permissionMessage; private String permissionMessage;
private CompleterTab completerTab = EMPTY_COMPLETER_TAB; private CompleterTab completerTab = EMPTY_COMPLETER_TAB;
private CompleterCommand completerCommand = EMPTY_COMPLETER_COMMAND; private CompleterCommand completerCommand = EMPTY_COMPLETER_COMMAND;
private boolean silence;
private boolean forceRegister; private boolean forceRegister;
private boolean build; private boolean build;
@ -40,7 +36,6 @@ public class SimpleCommandBuilder {
this.description = ""; this.description = "";
this.usage = "/" + command; this.usage = "/" + command;
this.aliases = new ArrayList<>(); this.aliases = new ArrayList<>();
this.silence = false;
this.build = false; this.build = false;
} }
@ -69,7 +64,7 @@ public class SimpleCommandBuilder {
} }
public SimpleCommandBuilder aliases(String... aliases) { public SimpleCommandBuilder aliases(String... aliases) {
this.aliases = ArrayUtils.asList(aliases); this.aliases = ArrayUtil.asList(aliases);
return this; return this;
} }
@ -93,12 +88,6 @@ public class SimpleCommandBuilder {
return this; return this;
} }
@Deprecated
public SimpleCommandBuilder silence() {
this.silence = true;
return this;
}
public SimpleCommandBuilder forceRegister() { public SimpleCommandBuilder forceRegister() {
this.forceRegister = true; this.forceRegister = true;
return this; return this;
@ -121,12 +110,8 @@ public class SimpleCommandBuilder {
permission, permission,
permissionMessage, permissionMessage,
(sender, command, s, args) -> { (sender, command, s, args) -> {
try { completerCommand.execute(sender, args);
return completerCommand.execute(sender, args); return true;
} catch (Throwable t) {
t.printStackTrace();
}
return false;
}, },
(sender, command, s, args) -> { (sender, command, s, args) -> {
try { try {
@ -134,9 +119,8 @@ public class SimpleCommandBuilder {
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(); t.printStackTrace();
} }
return Lists.newArrayList(); return null;
}, });
silence);
build = true; build = true;
return this; return this;
} }
@ -183,10 +167,6 @@ public class SimpleCommandBuilder {
return completerCommand; return completerCommand;
} }
public boolean isSilence() {
return silence;
}
public boolean isForceRegister() { public boolean isForceRegister() {
return forceRegister; return forceRegister;
} }

View File

@ -0,0 +1,55 @@
package io.izzel.taboolib.module.compat;
import io.izzel.taboolib.module.inject.TFunction;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.plugin.RegisteredServiceProvider;
/**
* @Author 坏黑
* @Since 2019-07-05 18:50
*/
@TFunction(enable = "init")
public class EconomyHook {
private static Economy economy;
static void init() {
if (Bukkit.getPluginManager().getPlugin("Vault") == null) {
return;
}
RegisteredServiceProvider<Economy> l = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
if (l != null) {
economy = l.getProvider();
}
}
public static void remove(OfflinePlayer p, double d) {
economy.withdrawPlayer(p, d);
}
public static void add(OfflinePlayer p, double d) {
economy.depositPlayer(p, d);
}
public static void set(OfflinePlayer p, double d) {
add(p, d - get(p));
}
public static double get(OfflinePlayer p) {
return economy.getBalance(p);
}
public static void create(OfflinePlayer p) {
economy.createPlayerAccount(p);
}
public static boolean exists() {
return economy != null;
}
public static net.milkbowl.vault.economy.Economy getEconomy() {
return economy;
}
}

View File

@ -0,0 +1,39 @@
package io.izzel.taboolib.module.compat;
import io.izzel.taboolib.module.inject.TFunction;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
import java.util.Arrays;
@TFunction(enable = "init")
public class PermissionHook {
private static Permission perms;
static void init() {
if (Bukkit.getPluginManager().getPlugin("Vault") == null) {
return;
}
RegisteredServiceProvider<Permission> rsp = Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
perms = rsp.getProvider();
}
public static Permission getPermission() {
return perms;
}
public static void addPermission(Player player, String perm) {
perms.playerAdd(player, perm);
}
public static void removePermission(Player player, String perm) {
perms.playerRemove(player, perm);
}
public static boolean hasPermission(Player player, String perm) {
return perms.playerHas(player, perm) || Arrays.stream(perms.getPlayerGroups(player)).anyMatch(group -> perms.groupHas(player.getWorld(), group, perm));
}
}

View File

@ -1,15 +1,17 @@
package com.ilummc.tlib.compat; package io.izzel.taboolib.module.compat;
import me.clip.placeholderapi.PlaceholderAPI; import me.clip.placeholderapi.PlaceholderAPI;
import io.izzel.taboolib.module.inject.TFunction;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@TFunction(enable = "init")
public abstract class PlaceholderHook { public abstract class PlaceholderHook {
private static PlaceholderHook impl; private static PlaceholderHook impl;
public static void init() { static void init() {
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) { if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
impl = new PlaceholderImpl(); impl = new PlaceholderImpl();
} else { } else {

Some files were not shown because too many files have changed in this diff Show More