diff --git a/README.md b/README.md
index f5b619b..d0c7d3e 100644
--- a/README.md
+++ b/README.md
@@ -1,47 +1,30 @@
# PermissionsTime
-### 支持跨服的权限限时插件(+称号功能)
+### 支持跨服的权限限时插件
+##### PermissionsTime插件下载地址:[https://ci.frog.gg/job/PermissionsTime/](https://ci.frog.gg/job/PermissionsTime/)
##### [插件使用说明](https://github.com/geekfrog/PermissionsTime/wiki/PermissionsTime-%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E)
-##### 构建地址:[http://ci.frog.gg/](http://ci.frog.gg/)
-##### 前置插件Vault下载地址:[https://dev.bukkit.org/projects/vault/](https://dev.bukkit.org/projects/vault/)
-##### 前置插件SQLibrary下载地址:[https://dev.bukkit.org/projects/sqlibrary/](https://dev.bukkit.org/projects/sqlibrary/)
+##### 前置插件FrogsPluginLib(宅宅蛙的插件前置库)
+下载地址:[https://ci.frog.gg/job/FrogsPluginLib/](https://ci.frog.gg/job/FrogsPluginLib/)
+
+##### 前置插件Vault
+下载地址:[https://dev.bukkit.org/projects/vault/](https://dev.bukkit.org/projects/vault/)
+
+### 可选前置插件:
+##### 前置插件PlaceholderAPI下载地址:[https://www.spigotmc.org/resources/placeholderapi.6245/](https://www.spigotmc.org/resources/placeholderapi.6245/)
本插件并非权限插件, 而是权限扩展插件. 可以限制权限和权限组的使用时间.
-使用时必须同时使用Vault及SQLibrary两个前置插件.
+使用时必须同时使用FrogsPluginLib及Vault两个前置插件.
使用跨服权限, 要在配置文件里开启MySQl功能.
经测试支持大部分1.7.10-1.12的服务器. 其他版本未做测试.
-本插件增加了称号管理功能,默认情况下为关闭状态.(2018-06-15)
-
#### 插件截图:
![image](http://i.imgur.com/cnnd5hb.jpg)
![image](http://i.imgur.com/bqvIVvz.jpg)
![image](http://i.imgur.com/NFK3WKa.jpg)
-#### 称号功能:
-
-查看详细
-1.支持Placeholder变量、HolographicDisplays显示称号(解决称号长度限制问题)
-2.可以设置称号功能开关、默认称号、是否 修改displayname、是否使用HolographicDisplays、以及称号刷新时间(使用Placeholder变量的话)
-3.自带Placeholder变量: %pttag_fullname% %pttag_prefix% %pttag_suffix% 来显示displayname、prefix+color、suffix
-
-![image](http://i.imgur.com/o7tZTQp.jpg)
-![image](http://i.imgur.com//E3SNYNj.jpg)
-
-![image](http://i.imgur.com/zRAOpFf.jpg)
-![image](http://i.imgur.com/tP66jxF.jpg)
-
-![image](http://i.imgur.com/FGxa96D.jpg)
-![image](http://i.imgur.com/ovCir3l.jpg)
-![image](http://i.imgur.com/1oel29B.jpg)
-
-![image](http://i.imgur.com/w702i9I.jpg)
-
-
-
#### 已知问题(作者提醒):
- 如果出现问题一般退出服务器重进就能解决。一次不行再来一次。
@@ -74,12 +57,7 @@
- **玩家登录时删除过期的或无效数据**
- **提示剩余时间**
- **权限包到期可执行自定义命令**
-- **增加称号管理功能**
-- 取消前置插件
-
-
- 支持分页?
-- 数据迁移?
#### 使用统计:
[https://bstats.org/plugin/bukkit/PermissionsTime](https://bstats.org/plugin/bukkit/PermissionsTime)
diff --git a/config/config.yml b/config/config.yml
deleted file mode 100644
index 8188c90..0000000
--- a/config/config.yml
+++ /dev/null
@@ -1,33 +0,0 @@
-# 插件前缀.
-# Plugin prefix.
-pluginPrefix: '&4[&bPermissions Time&4] '
-# 是否开启DEBUG模式.
-# Whether to open the DEBUG mode.
-debug: false
-# 是否同意插件上传统计信息.
-# Whether or not you agree with the plugin to upload statistics.
-metrics: true
-# 开启称号系统.
-# Use prefix system.
-tagSystem: false
-# 语言文件名称 在'lang'文件夹内.
-# Language file name.
-lang: zh-cn
-# 数据库相关.
-# Database settings.
-mysql:
- # 是否使用MySQL数据库.
- # Use the MySQL database?
- enable: false
- # 服务器唯一标识, 用来区分权限是哪个服务器的.
- # 想要权限跨服,serverId必须一致.
- # Server ID.
- serverId: default
- hostname: localhost
- port: 3306
- database: minecraft
- username: user
- password: '123456'
- # 数据库表前缀
- # Database table prefix.
- tablePrefix: pt_
diff --git a/config/packages.yml b/config/packages.yml
deleted file mode 100644
index 5a0e5da..0000000
--- a/config/packages.yml
+++ /dev/null
@@ -1,49 +0,0 @@
-# 配置文件版本.
-# Config version.
-version: 1.00
-# 默认权限组.
-# Default permission group.
-defaultGroup: Default
-packages:
-# 权限包名称.
-# Permission package name.
- example1:
- # 权限包显示名称.
- # Permission package display name.
- displayName: '&4Test Package'
- # 显示的物品类型.
- # 可以使用id, 但不可与type同时使用.
- # 可以定义物品的种类, 特殊的如头颅可以指定哪个玩家的头颅.
- # Show the type of item.
- # You can use 'id', but you can't use 'type' at the same time.
- # You can define the type of item, such as skull can set which player's head.
- #id: 397
- #type: SKULL_ITEM:5
- #type: SKULL_ITEM:MHF_Present1
- type: NETHER_STAR
- # 是否有附魔发光的特效
- glowing: false
- # 标签.
- # Lores.
- lores:
- - '&2This is a test lore.'
- # 是否跨服权限?
- # Is multiple server permission?
- global: false
- # 权限包含有的权限 world1、world2、world3是赋值给玩家permission2权限的世界.
- # 如果所有世界都赋值权限则不用注明世界名称如:permission1.
- # Package contain permissions.
- # Add ':world1' at the end can restrict permissions used in 'world1'.
- permissions:
- - permission1
- - permission2:world1:world2:world3
- # 权限包含有的权限组.
- # Package contain groups.
- groups:
- - group1
- - group2:world1
- # 权限包过期后执行的控制台命令
- # Package expire console commands.
- expireCommands:
- - 'say %player% 的权限包到期了.'
- - 'say 请及时续期.'
diff --git a/config/plugin.yml b/config/plugin.yml
deleted file mode 100644
index 54645fc..0000000
--- a/config/plugin.yml
+++ /dev/null
@@ -1,59 +0,0 @@
-name: ${project.name}
-version: 0.4.3-SNAPSHOT-b1005
-main: gg.frog.mc.base.PluginMain
-author:
-- GeekFrog
-description: ${project.description}
-softdepend:
-- SQLibrary
-- Vault
-- PlaceholderAPI
-- HolographicDisplays
-commands:
- permissionstime:
- description: Show all commands.
- usage: /permissionstime [param]
- pt:
- description: Aliases commands for permissionstime.
- usage: /pt [param]
-permissions:
- gg.frog.permissionstime.*:
- description: Gives access to all PermissionsTime commands.
- default: op
- children:
- permissionstime.me: true
- permissionstime.tag: true
- permissionstime.reload: true
- permissionstime.give: true
- permissionstime.set: true
- permissionstime.get: true
- permissionstime.remove: true
- permissionstime.removeall: true
- permissionstime.packages: true
- permissionstime.me:
- description: View your packages.
- default: true
- permissionstime.tag:
- description: Set your color/prefix/suffix of tags.
- default: true
- permissionstime.reload:
- description: Reloads the config file.
- default: op
- permissionstime.give:
- description: Give player package some time.
- default: op
- permissionstime.set:
- description: Set player package some time.
- default: op
- permissionstime.get:
- description: View player packages.
- default: op
- permissionstime.remove:
- description: Remove player package.
- default: op
- permissionstime.removeall:
- description: Remove player all package.
- default: op
- permissionstime.packages:
- description: View packages.
- default: op
\ No newline at end of file
diff --git a/config/tagNames.yml b/config/tagNames.yml
deleted file mode 100644
index 63ee761..0000000
--- a/config/tagNames.yml
+++ /dev/null
@@ -1,86 +0,0 @@
-# 默认昵称样式.
-# Default Name Color.
-defaultNamecolor: '&6'
-# 默认前缀.
-# Default Prefix.
-defaultPrefix: '&3[player]'
-# 默认后缀.
-# Default Suffix.
-defaultSuffix: ''
-# 如果你有其他的插件来修改玩家的displayname, 请禁用此项或禁止其他插件修改. 比如Essentials插件.
-# 如果安装了PlaceholderAPI 可以使用
-# %pttag_fullname% %pttag_prefix% %pttag_suffix% 来显示displayname prefix+color suffix
-# If you have other plugin, to modifies player displayname, please disable this.
-changeDisplayname: true
-# 使用HolographicDisplays显示称号. 称号可以更长,不会被省略.
-# use HolographicDisplays to show Tags. The Tag can be more than 16 char
-useHdPlugin: false
-# 如果使用了HD, 是否一行显示
-# One line display the name and tags.
-oneLineDisplay: true
-# 称号刷新周期(秒).
-# 如果你你的称号使用了PlaceholderAPI请设置此项
-# 推荐600秒以上. 设置-1则禁用刷新.
-# Title refresh cycle (seconds).
-# If you use Placeholder, please set.
-# Recommend more than 600s. Set -1 to disable refresh.
-refreshTagTime: -1
-template:
- lore:
- - '&1-----------------'
- - '&2Preview:'
- - '&3 %displayname%'
- - '&4-----------------'
- - '&5 %description%'
- - '&6-----------------'
-packages:
-# 称号包名称.
-# Tag package name.
- default:
- description: '&4The default tag.'
- permissions: ''
- namecolor:
- - '&6'
- prefix:
- - '&3[player]'
- example1:
- # 称号包描述,可以填写如何获得这些称号.
- # Tag package describes. You can type how to get these tag.
- description: '&4Tag package description.'
- # 称号包所需权限. 不需要权限请留空,输入 ''
- # Tag package needs permission. Keep null to make no permission.
- permissions: ''
- # 称号包所含的昵称样式.
- # Name Colors.
- namecolor:
- - '&3'
- - '&4:SKULL_ITEM:5'
- - '&5:SKULL_ITEM:MHF_Present1'
- # 称号包所含的昵称前缀.
- # Name prefix.
- prefix:
- - '&3[prefix]'
- - '&4[prefix]:1'
- # 称号包所含的昵称后缀.
- # Name suffix.
- suffix:
- - '&3[suffix]'
- - '&4[suffix]:1:6'
- vip:
- description: '&4VIP Tags.'
- permissions: 'player.vip'
- namecolor:
- - '&3&l'
- - '&4&n:SKULL_ITEM:5'
- - '&5&o:SKULL_ITEM:MHF_Present1'
- # 称号包所含的昵称前缀.
- # Name prefix.
- prefix:
- - '&3&l[prefix]'
- - '&4&n[prefix]:1'
- # 称号包所含的昵称后缀.
- # Name suffix.
- suffix:
- - '&3&o[suffix]'
- - '&4&l&n[suffix]:1:6'
-
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 78b5a98..30eb59f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
4.0.0
gg.frog.mc
permissionstime
- 0.4.3-SNAPSHOT-b1005
+ 0.4.3-SNAPSHOT-b1006
jar
PermissionsTime
支持跨服的权限限时插件
@@ -18,12 +18,16 @@
UTF-8
+
+ Frog Nexus Repository
+ https://maven.frog.gg/repository/maven-public/
+
spigotmc-repo
https://hub.spigotmc.org/nexus/content/groups/public/
- dakani
+ dakani-repo
Dakani Nexus Repo
https://repo.dakanilabs.com/repository/public/
@@ -36,15 +40,20 @@
http://repo.bstats.org/content/repositories/releases/
- placeholderapi
+ extendedclip-repo
http://repo.extendedclip.com/content/repositories/placeholderapi/
- HD
+ filoghost-repo
https://ci.filoghost.me/plugin/repository/everything/
+
+ gg.frog.mc
+ base
+ LATEST
+
org.bukkit
bukkit
@@ -87,6 +96,17 @@
src/resources
true
+
+ *.yml
+ lang/*.yml
+
+
+
+ src/resources
+ false
+
+ lib/*.jar
+
.
@@ -137,7 +157,7 @@
- org.bstats
+ org.bstats.bukkit
gg.frog.mc.permissionstime
@@ -158,4 +178,16 @@
Jenkins
http://ci.frog.gg/
+
+
+ nexus-releases
+ Frog Release Repository
+ https://maven.frog.gg/repository/maven-releases/
+
+
+ nexus-snapshots
+ Frog Snapshot Repository
+ https://maven.frog.gg/repository/maven-snapshots/
+
+
diff --git a/src/main/gg/frog/mc/base/listener/BaseListener.java b/src/main/gg/frog/mc/base/listener/BaseListener.java
deleted file mode 100644
index ce7eadc..0000000
--- a/src/main/gg/frog/mc/base/listener/BaseListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package gg.frog.mc.base.listener;
-
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.player.PlayerKickEvent;
-import org.bukkit.event.player.PlayerQuitEvent;
-
-import gg.frog.mc.base.PluginMain;
-
-public class BaseListener implements Listener {
-
- private PluginMain pm;
-
- public BaseListener(PluginMain pm) {
- this.pm = pm;
- }
-
- @EventHandler
- public void onQuit(PlayerQuitEvent event) {
- pm.getOFFLINE_PLAYER_MAP().remove(event.getPlayer().getName());
- }
-
- @EventHandler
- public void onKick(PlayerKickEvent event) {
- pm.getOFFLINE_PLAYER_MAP().remove(event.getPlayer().getName());
- }
-}
diff --git a/src/main/gg/frog/mc/base/utils/FileUtil.java b/src/main/gg/frog/mc/base/utils/FileUtil.java
deleted file mode 100644
index 971d1e0..0000000
--- a/src/main/gg/frog/mc/base/utils/FileUtil.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package gg.frog.mc.base.utils;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URLDecoder;
-import java.nio.charset.Charset;
-import java.util.Enumeration;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-public class FileUtil {
-
- public interface FindFilesDo {
- boolean isProcess(String fileName);
-
- void process(String fileName, InputStream is);
- }
-
- public static void findFilesFromJar(FindFilesDo ffd, Class> jarClazz) {
- JarFile jarFile = null;
- try {
- String jarFilePath = jarClazz.getProtectionDomain().getCodeSource().getLocation().getFile();
- jarFilePath = URLDecoder.decode(jarFilePath, Charset.defaultCharset().name());
- jarFile = new JarFile(jarFilePath);
- Enumeration entries = jarFile.entries();
- while (entries.hasMoreElements()) {
- JarEntry e = entries.nextElement();
- if (ffd.isProcess(e.getName())) {
- InputStream is = jarFile.getInputStream(e);
- ffd.process(e.getName(), is);
- try {
- is.close();
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- if (jarFile != null) {
- try {
- jarFile.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
-
- public static void writeOnFile(String fileName, String content) {
- FileWriter fw;
- try {
- File f = new File(fileName);
- fw = new FileWriter(f, true);
- fw.write(content + "\r\n");
- fw.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/src/main/gg/frog/mc/base/utils/StrUtil.java b/src/main/gg/frog/mc/base/utils/StrUtil.java
deleted file mode 100644
index a6f7d65..0000000
--- a/src/main/gg/frog/mc/base/utils/StrUtil.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package gg.frog.mc.base.utils;
-
-import java.text.MessageFormat;
-import java.util.Date;
-
-import org.apache.commons.lang.time.DateFormatUtils;
-import org.bukkit.entity.Player;
-
-import gg.frog.mc.base.PluginMain;
-import gg.frog.mc.base.config.LangCfg;
-import gg.frog.mc.permissionstime.database.IPlayerDataDao;
-import me.clip.placeholderapi.PlaceholderAPI;
-
-public class StrUtil {
-
- private static final String dfs = "yyyy/MM/dd HH:mm:ss";
- private static final long dt = 24 * 60 * IPlayerDataDao.TIME_UNIT;
- private static final long ht = 60 * IPlayerDataDao.TIME_UNIT;
- private static final long mt = IPlayerDataDao.TIME_UNIT;
-
-
-
- public static String messageFormat(String src, Object... args) {
- return MessageFormat.format(src, args).replaceAll("&", "§").replaceAll("\\\\n", "\n");
- }
-
- public static String messageFormat(Player player, String src, Object... args) {
- String message = MessageFormat.format(src, args).replaceAll("&", "§").replaceAll("\\\\n", "\n").replaceAll("%player%", player.getPlayer().getDisplayName());
- if (PluginMain.enabledPlaceholder) {
- message = PlaceholderAPI.setPlaceholders(player, message);
- }
- return message;
- }
-
- public static String timestampToString(long time) {
- return DateFormatUtils.format(new Date(time), dfs);
- }
-
- public static String dateToString(Date d) {
- return DateFormatUtils.format(d, dfs);
- }
-
- public static String nowTimeString() {
- return DateFormatUtils.format(new Date(), dfs);
- }
-
- public static String getLeftTime(long time) {
- long leftTime = time - new Date().getTime();
- long d = leftTime / dt;
- long h = (leftTime % dt) / ht;
- long m = (leftTime % ht) / mt;
- return messageFormat(LangCfg.LEFT_TIME, d, LangCfg.TIME_UNIT_D, h, LangCfg.TIME_UNIT_H, m, LangCfg.TIME_UNIT_M);
- }
-
-}
diff --git a/src/main/gg/frog/mc/base/utils/UpdateCheck.java b/src/main/gg/frog/mc/base/utils/UpdateCheck.java
deleted file mode 100644
index fd001e3..0000000
--- a/src/main/gg/frog/mc/base/utils/UpdateCheck.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package gg.frog.mc.base.utils;
-
-import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
-import java.net.URL;
-
-import org.bukkit.configuration.file.YamlConfiguration;
-import com.google.common.base.Charsets;
-
-import gg.frog.mc.base.PluginMain;
-import gg.frog.mc.base.config.PluginCfg;
-
-public class UpdateCheck implements Runnable {
-
- private PluginMain pm;
-
- public UpdateCheck(PluginMain pm) {
- this.pm = pm;
- }
-
- @Override
- public void run() {
- try {
- String pluginInfoUrl = "https://raw.githubusercontent.com/geekfrog/PermissionsTime/master/src/resources/plugin.yml";
- URL url = new URL(pluginInfoUrl);
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2");
- connection.setRequestMethod("GET");
- YamlConfiguration tempConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(connection.getInputStream(), Charsets.UTF_8));
- String version = tempConfig.getString("version", pm.PLUGIN_VERSION);
- if (!pm.PLUGIN_VERSION.equals(version)) {
- pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4There is a new version ''{0}'' of the plugin.", version));
- } else {
- pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§2No new version available."));
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/src/main/gg/frog/mc/base/utils/config/IConfigBean.java b/src/main/gg/frog/mc/base/utils/config/IConfigBean.java
deleted file mode 100644
index fe54a39..0000000
--- a/src/main/gg/frog/mc/base/utils/config/IConfigBean.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package gg.frog.mc.base.utils.config;
-
-import org.bukkit.configuration.MemorySection;
-import org.bukkit.configuration.file.YamlConfiguration;
-
-public interface IConfigBean {
-
- YamlConfiguration toConfig();
-
- void toConfigBean(MemorySection config);
-}
diff --git a/src/main/gg/frog/mc/base/utils/config/PluginConfig.java b/src/main/gg/frog/mc/base/utils/config/PluginConfig.java
deleted file mode 100644
index 90ac457..0000000
--- a/src/main/gg/frog/mc/base/utils/config/PluginConfig.java
+++ /dev/null
@@ -1,235 +0,0 @@
-package gg.frog.mc.base.utils.config;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.logging.Level;
-
-import org.bukkit.command.CommandSender;
-import org.bukkit.configuration.InvalidConfigurationException;
-import org.bukkit.configuration.MemorySection;
-import org.bukkit.configuration.file.FileConfiguration;
-import org.bukkit.configuration.file.YamlConfiguration;
-
-import com.google.common.base.Charsets;
-
-import gg.frog.mc.base.PluginMain;
-import gg.frog.mc.base.config.PluginCfg;
-import gg.frog.mc.base.utils.StrUtil;
-
-/**
- * 配置操作
- *
- * @author QiaoPengyu
- *
- */
-public abstract class PluginConfig {
-
- protected PluginMain pm;
- private FileConfiguration config = null;
- private File folder = null;
- private String fileName = null;
- private File configFile = null;
-
- protected PluginConfig(PluginMain pm) {
- this.pm = pm;
- initConfig(pm.getDataFolder(), "config.yml");
- }
-
- protected PluginConfig(String fileName, PluginMain pm) {
- this.pm = pm;
- initConfig(pm.getDataFolder(), fileName);
- }
-
- protected PluginConfig(File folder, String fileName, PluginMain pm) {
- this.pm = pm;
- initConfig(folder, fileName);
- }
-
- /**
- * 初始化
- *
- * @param folder
- * @param fileName
- */
- private void initConfig(File folder, String fileName) {
- this.folder = folder;
- this.fileName = fileName;
- configFile = new File(folder, fileName);
- if (!configFile.exists()) {
- getConfig(folder, fileName).options().copyDefaults(true);
- init();
- saveAndReloadConfig();
- } else {
- reloadConfig();
- }
- }
-
- /**
- * 首次生成文件调用
- */
- protected abstract void init();
-
- /**
- * 加载配置后调用
- */
- protected abstract void loadToDo(CommandSender sender);
-
- /**
- * 获取配置(首次)
- *
- * @return
- */
- private FileConfiguration getConfig(File folder, String fileName) {
- if (config == null) {
- reloadConfig(folder, fileName, true);
- }
- return config;
- }
-
- /**
- * 获取配置
- *
- * @return
- */
- protected FileConfiguration getConfig() {
- return config;
- }
-
- /**
- * 保存配置
- */
- public void saveConfig() {
- try {
- getConfig().save(configFile);
- } catch (IOException ex) {
- PluginMain.LOG.log(Level.SEVERE, StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "Could not save config to " + configFile), ex);
- }
- }
-
- public void saveAndReloadConfig() {
- try {
- getConfig().save(configFile);
- reloadConfig();
- } catch (IOException ex) {
- PluginMain.LOG.log(Level.SEVERE, StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "Could not save config to " + configFile), ex);
- }
- }
-
- /**
- * 配置重载
- */
- public void reloadConfig() {
- reloadConfig(folder, fileName, false);
- }
-
- /**
- * 配置重载
- */
- public void reloadConfig(CommandSender sender) {
- reloadConfig(folder, fileName, false, sender);
- }
-
- /**
- * 配置重载
- */
- private void reloadConfig(File folder, String fileName, boolean useRes) {
- reloadConfig(folder, fileName, useRes, null);
- }
-
- /**
- * 配置重载
- */
- private void reloadConfig(File folder, String fileName, boolean useRes, CommandSender sender) {
- YamlConfiguration tempConfig = new YamlConfiguration();
- try {
- tempConfig.load(configFile);
- config = tempConfig;
- } catch (FileNotFoundException e) {
- } catch (IOException | InvalidConfigurationException e1) {
- tempConfig = null;
- e1.printStackTrace();
- }
- if (config == null) {
- config = new YamlConfiguration();
- }
- if (useRes) {
- final InputStream defConfigStream = pm.getResource(fileName);
- if (defConfigStream == null) {
- return;
- }
- config.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(defConfigStream, Charsets.UTF_8)));
- }
- loadToDo(sender);
- // if (tempConfig != null) {
- // saveConfig();
- // }
- }
-
- protected void setObj(String path, Map o) {
- for (Entry configBean : o.entrySet()) {
- setObj(path + "." + configBean.getKey(), configBean.getValue());
- }
- }
-
- protected void setObj(String path, IConfigBean o) {
- getConfig().set(path, o.toConfig());
- }
-
- protected Map getObjMap(String path, Class clazz) {
- Map map = new HashMap<>();
- MemorySection configMap = (MemorySection) getConfig().get(path);
- if (configMap != null) {
- for (String key : configMap.getKeys(false)) {
- T bean = getObj(path + "." + key, clazz);
- if (bean != null) {
- map.put(key, bean);
- }
- }
- }
- return map;
- }
-
- protected T getObj(String path, Class clazz) {
- Object beanConfig = getConfig().get(path);
- if (beanConfig != null && beanConfig instanceof MemorySection) {
- try {
- T bean = clazz.newInstance();
- bean.toConfigBean((MemorySection) beanConfig);
- return bean;
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- return null;
- }
-
- protected String setGetDefault(String path, String def) {
- if (!getConfig().contains(path)) {
- getConfig().set(path, def);
- return def;
- }
- return getConfig().getString(path);
- }
-
- protected int setGetDefault(String path, int def) {
- if (!getConfig().contains(path)) {
- getConfig().set(path, def);
- return def;
- }
- return getConfig().getInt(path);
- }
-
- protected boolean setGetDefault(String path, boolean def) {
- if (!getConfig().contains(path)) {
- getConfig().set(path, def);
- return def;
- }
- return getConfig().getBoolean(path);
- }
-}
diff --git a/src/main/gg/frog/mc/base/utils/nms/ItemUtil.java b/src/main/gg/frog/mc/base/utils/nms/ItemUtil.java
deleted file mode 100644
index d61e64d..0000000
--- a/src/main/gg/frog/mc/base/utils/nms/ItemUtil.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package gg.frog.mc.base.utils.nms;
-
-import java.lang.reflect.Method;
-
-import org.bukkit.enchantments.Enchantment;
-import org.bukkit.inventory.ItemStack;
-
-import gg.frog.mc.base.PluginMain;
-import gg.frog.mc.base.config.PluginCfg;
-import gg.frog.mc.base.utils.StrUtil;
-
-public class ItemUtil {
-
- private static Class> nbtBaseClass;
- private static Class> nbtTagCompoundClass;
- private static Class> nbtTagStringClass;
- private static Class> nbtTagIntClass;
- // private static Class> nbtTagShortClass;
- // private static Class> nbtTagListClass;
- private static Class> itemstackClass;
- private static Method asNmsCopyMethod;
- private static Method asCraftMirrorMethod;
- private static Method hasTagMethod;
- private static Method getTagMethod;
- private static Method setTagMethod;
- private static Method nbtSetMethod;
- // private static Method nbtListAddSetMethod;
- private static boolean setupOk;
-
- static {
- try {
- try {
- itemstackClass = NMSUtil.getNmsClass("ItemStack");
- nbtBaseClass = NMSUtil.getNmsClass("NBTBase");
- nbtTagStringClass = NMSUtil.getNmsClass("NBTTagString");
- nbtTagIntClass = NMSUtil.getNmsClass("NBTTagInt");
- nbtTagCompoundClass = NMSUtil.getNmsClass("NBTTagCompound");
-
- hasTagMethod = itemstackClass.getMethod("hasTag", new Class[0]);
- getTagMethod = itemstackClass.getMethod("getTag", new Class[0]);
- setTagMethod = itemstackClass.getMethod("setTag", new Class[] { nbtTagCompoundClass });
- nbtSetMethod = nbtTagCompoundClass.getMethod("set", new Class[] { String.class, nbtBaseClass });
- // nbtTagShortClass = NMSUtil.getNmsClass("NBTTagShort");
- // nbtTagListClass = NMSUtil.getNmsClass("NBTTagList");
- // nbtListAddSetMethod = nbtTagListClass.getMethod("add", new Class[]
- // {nbtBaseClass});
- } catch (Exception e) {
- if (NMSUtil.getServerVersion().startsWith("v1_7_R4")) {
- itemstackClass = NMSUtil.getNmClass("item.ItemStack");// add
- nbtBaseClass = NMSUtil.getNmClass("nbt.NBTBase");// dy
- nbtTagStringClass = NMSUtil.getNmClass("nbt.NBTTagString");// dx
- nbtTagIntClass = NMSUtil.getNmClass("nbt.NBTTagInt");// dp
- nbtTagCompoundClass = NMSUtil.getNmClass("nbt.NBTTagCompound");// dh
-
- hasTagMethod = itemstackClass.getMethod("func_77942_o", new Class[0]);// hasTagCompound
- getTagMethod = itemstackClass.getMethod("func_77978_p", new Class[0]);// getTagCompound
- setTagMethod = itemstackClass.getMethod("func_77982_d", new Class[] { nbtTagCompoundClass });// setTagCompound
- nbtSetMethod = nbtTagCompoundClass.getMethod("func_74782_a", new Class[] { String.class, nbtBaseClass });// setTag
- } else {
- throw new Exception("Nbt edit is not support.");
- }
- }
- asNmsCopyMethod = NMSUtil.getObcClass("inventory.CraftItemStack").getMethod("asNMSCopy", new Class[] { ItemStack.class });
- asCraftMirrorMethod = NMSUtil.getObcClass("inventory.CraftItemStack").getMethod("asCraftMirror", new Class[] { itemstackClass });
- setupOk = true;
- } catch (Exception e) {
- e.printStackTrace();
- PluginMain.LOG.warning(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "ItemUtil setup fail. Some functions are unavailable."));
- }
- }
-
- public static ItemStack addEnchantLight(ItemStack item) {
- item.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 0);
- if (!NMSUtil.getServerVersion().startsWith("v1_7_") && setupOk) {
- try {
- Object nmsItemstack = asNmsCopyMethod.invoke(null, new Object[] { item });
- if (nmsItemstack == null) {
- return item;
- }
- Object nbtCompound = null;
- if (((Boolean) hasTagMethod.invoke(nmsItemstack, new Object[0])).booleanValue()) {
- nbtCompound = getTagMethod.invoke(nmsItemstack, new Object[0]);
- } else {
- nbtCompound = nbtTagCompoundClass.newInstance();
- setTagMethod.invoke(nmsItemstack, new Object[] { nbtCompound });
- }
- if (nbtCompound == null) {
- return item;
- }
- Object nbtHideFlags = nbtTagIntClass.getConstructor(int.class).newInstance(1);
- nbtSetMethod.invoke(nbtCompound, new Object[] { "HideFlags", nbtHideFlags });
- return (ItemStack) asCraftMirrorMethod.invoke(null, new Object[] { nmsItemstack });
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- return item;
- }
-
- public static ItemStack addSkullOwner(ItemStack item, String name) {
- if (setupOk) {
- try {
- Object nmsItemstack = asNmsCopyMethod.invoke(null, new Object[] { item });
- if (nmsItemstack == null) {
- return item;
- }
- Object nbtCompound = null;
- if (((Boolean) hasTagMethod.invoke(nmsItemstack, new Object[0])).booleanValue()) {
- nbtCompound = getTagMethod.invoke(nmsItemstack, new Object[0]);
- } else {
- nbtCompound = nbtTagCompoundClass.newInstance();
- setTagMethod.invoke(nmsItemstack, new Object[] { nbtCompound });
- }
- if (nbtCompound == null) {
- return item;
- }
- Object nbtString = nbtTagStringClass.getConstructor(String.class).newInstance(name);
- nbtSetMethod.invoke(nbtCompound, new Object[] { "SkullOwner", nbtString });
- return (ItemStack) asCraftMirrorMethod.invoke(null, new Object[] { nmsItemstack });
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- return item;
- }
-}
diff --git a/src/main/gg/frog/mc/base/utils/nms/NMSUtil.java b/src/main/gg/frog/mc/base/utils/nms/NMSUtil.java
deleted file mode 100644
index 4feb743..0000000
--- a/src/main/gg/frog/mc/base/utils/nms/NMSUtil.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package gg.frog.mc.base.utils.nms;
-
-import org.bukkit.Bukkit;
-
-public class NMSUtil {
-
- private static String serverVersion;
-
- static {
- String packageName = Bukkit.getServer().getClass().getPackage().getName();
- serverVersion = packageName.substring(packageName.lastIndexOf('.') + 1);
- }
-
- public static String getServerVersion() {
- return serverVersion;
- }
-
- public static Class> getNmsClass(String name) throws ClassNotFoundException {
- return Class.forName("net.minecraft.server." + getServerVersion() + "." + name);
- }
-
- public static Class> getObcClass(String name) throws ClassNotFoundException {
- return Class.forName("org.bukkit.craftbukkit." + getServerVersion() + "." + name);
- }
-
- public static Class> getNmClass(String name) throws ClassNotFoundException {
- return Class.forName("net.minecraft." + name);
- }
-
-}
diff --git a/src/main/gg/frog/mc/nametags/command/TagCmd.java b/src/main/gg/frog/mc/nametags/command/TagCmd.java
deleted file mode 100644
index edda9c6..0000000
--- a/src/main/gg/frog/mc/nametags/command/TagCmd.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package gg.frog.mc.nametags.command;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-
-import gg.frog.mc.base.PluginMain;
-import gg.frog.mc.base.config.LangCfg;
-import gg.frog.mc.base.config.PluginCfg;
-import gg.frog.mc.base.utils.StrUtil;
-import gg.frog.mc.nametags.config.TagNameCfg;
-import gg.frog.mc.nametags.config.TagNameCfg.TagType;
-import gg.frog.mc.nametags.gui.PlayerTagShow;
-
-public class TagCmd implements Runnable {
-
- private PluginMain pm;
- private String[] args;
- private CommandSender sender;
- private boolean isPlayer;
- private TagType type = null;
-
- public TagCmd(PluginMain pm, CommandSender sender, boolean isPlayer, String[] args) {
- this.pm = pm;
- this.sender = sender;
- this.isPlayer = isPlayer;
- this.args = args;
- }
-
- @Override
- public void run() {
- if (isPlayer) {
- if (args.length == 2) {
- sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
- List itemList = new ArrayList();
- List disItemList = new ArrayList();
-
- Map> p_i_map;
- if ("c".equals(args[1])) {
- type = TagNameCfg.TagType.NAMECOLOR_TYPE;
- p_i_map = TagNameCfg.NAMECOLOR_ITEMS;
- } else if ("p".equals(args[1])) {
- type = TagNameCfg.TagType.PREFIX_TYPE;
- p_i_map = TagNameCfg.PREFIX_ITEMS;
- } else if ("s".equals(args[1])) {
- type = TagNameCfg.TagType.SUFFIX_TYPE;
- p_i_map = TagNameCfg.SUFFIX_ITEMS;
- } else {
- sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
- sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_TAG, pm.PLUGIN_NAME_LOWER_CASE));
- return;
- }
- for (String p : p_i_map.keySet()) {
- if ("".equals(p) || sender.hasPermission(p)) {
- itemList.addAll(p_i_map.get(p));
- } else {
- disItemList.addAll(p_i_map.get(p));
- }
- }
- PlayerTagShow.show(pm, (Player) sender, type, itemList, disItemList);
- } else {
- sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
- sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_TAG, pm.PLUGIN_NAME_LOWER_CASE));
- }
- } else {
- sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Only player can use this command."));
- }
- }
-}
diff --git a/src/main/gg/frog/mc/nametags/config/TagNameCfg.java b/src/main/gg/frog/mc/nametags/config/TagNameCfg.java
deleted file mode 100644
index 98cf26d..0000000
--- a/src/main/gg/frog/mc/nametags/config/TagNameCfg.java
+++ /dev/null
@@ -1,233 +0,0 @@
-package gg.frog.mc.nametags.config;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.bukkit.Material;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.ItemMeta;
-import org.bukkit.inventory.meta.SkullMeta;
-import org.bukkit.scheduler.BukkitTask;
-import org.bukkit.scoreboard.Scoreboard;
-
-import gg.frog.mc.base.PluginMain;
-import gg.frog.mc.base.config.LangCfg;
-import gg.frog.mc.base.config.PluginCfg;
-import gg.frog.mc.base.utils.StrUtil;
-import gg.frog.mc.base.utils.config.PluginConfig;
-import gg.frog.mc.base.utils.nms.ItemUtil;
-import gg.frog.mc.nametags.model.PlayerTagBean;
-import gg.frog.mc.permissionstime.model.cfg.TagPackageBean;
-
-public class TagNameCfg extends PluginConfig {
-
- public static String DEFAULT_NAMECOLOR = null;
- public static String DEFAULT_PREFIX = null;
- public static String DEFAULT_SUFFIX = null;
- public static boolean CHANGE_DISPLAYNAME = true;
- public static boolean USE_HD_PLUGIN = false;
- public static boolean ONE_LINE_DISPLAY = false;
- public static Integer REFRESH_TAG_TIME = null;
- public static Map PACKAGES = new ConcurrentHashMap<>();
- public static List TEMPLATE_LORE = null;
-
- public static Map> NAMECOLOR_ITEMS = new ConcurrentHashMap<>();
- public static Map> PREFIX_ITEMS = new ConcurrentHashMap<>();
- public static Map> SUFFIX_ITEMS = new ConcurrentHashMap<>();
-
- public static Map> NAMECOLOR_PERMISSIONS = new ConcurrentHashMap<>();
- public static Map> PREFIX_PERMISSIONS = new ConcurrentHashMap<>();
- public static Map> SUFFIX_PERMISSIONS = new ConcurrentHashMap<>();
-
- public static Map PLAYER_TAG = new ConcurrentHashMap<>();
-
- public static Scoreboard scoreboard = null;
-
- private BukkitTask task = null;
-
- public enum TagType {
- NAMECOLOR_TYPE, PREFIX_TYPE, SUFFIX_TYPE
- }
-
- public TagNameCfg(String fileName, PluginMain pm) {
- super(fileName, pm);
- }
-
- @Override
- protected void init() {
- }
-
- @Override
- protected void loadToDo(CommandSender sender) {
- DEFAULT_NAMECOLOR = setGetDefault("defaultNamecolor", "");
- DEFAULT_PREFIX = setGetDefault("defaultPrefix", "");
- DEFAULT_SUFFIX = setGetDefault("defaultSuffix", "");
- CHANGE_DISPLAYNAME = setGetDefault("changeDisplayname", true);
- USE_HD_PLUGIN = setGetDefault("useHdPlugin", false);
- if (USE_HD_PLUGIN && !PluginMain.enabledHdPlugin) {
- USE_HD_PLUGIN = false;
- if (sender != null) {
- sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§eHolographicDisplays is not installed or not enabled. "));
- sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§eBut you enabled some func need HolographicDisplays."));
- } else {
- pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§eHolographicDisplays is not installed or not enabled. "));
- pm.getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§eBut you enabled some func need HolographicDisplays."));
- }
- }
- ONE_LINE_DISPLAY = setGetDefault("oneLineDisplay", true);
- REFRESH_TAG_TIME = setGetDefault("refreshTagTime", -1);
- PACKAGES = getObjMap("packages", TagPackageBean.class);
- TEMPLATE_LORE = getConfig().getStringList("template.lore");
- getConfig().set("template.lore", TEMPLATE_LORE);
- setObj("packages", PACKAGES);
- if (PluginCfg.IS_DEBUG) {
- System.out.println("defaultNamecolor:" + DEFAULT_NAMECOLOR);
- System.out.println("defaultPrefix:" + DEFAULT_PREFIX);
- System.out.println("defaultSuffix:" + DEFAULT_SUFFIX);
- System.out.println("useHdPlugin:" + USE_HD_PLUGIN);
- for (Entry p : PACKAGES.entrySet()) {
- System.out.println(p.getKey() + ":" + p.getValue());
- }
- for (String lore : TEMPLATE_LORE) {
- System.out.println(lore);
- }
- }
- NAMECOLOR_ITEMS.clear();
- PREFIX_ITEMS.clear();
- SUFFIX_ITEMS.clear();
-
- NAMECOLOR_PERMISSIONS.clear();
- PREFIX_PERMISSIONS.clear();
- SUFFIX_PERMISSIONS.clear();
-
- for (Entry e : PACKAGES.entrySet()) {
- List items = getTagItem(TagType.NAMECOLOR_TYPE, e.getValue());
- if (NAMECOLOR_ITEMS.containsKey(e.getValue().getPermissions())) {
- NAMECOLOR_ITEMS.get(e.getValue().getPermissions()).addAll(items);
- } else {
- NAMECOLOR_ITEMS.put(e.getValue().getPermissions(), items);
- }
- items = getTagItem(TagType.PREFIX_TYPE, e.getValue());
- if (PREFIX_ITEMS.containsKey(e.getValue().getPermissions())) {
- PREFIX_ITEMS.get(e.getValue().getPermissions()).addAll(items);
- } else {
- PREFIX_ITEMS.put(e.getValue().getPermissions(), items);
- }
- items = getTagItem(TagType.SUFFIX_TYPE, e.getValue());
- if (SUFFIX_ITEMS.containsKey(e.getValue().getPermissions())) {
- SUFFIX_ITEMS.get(e.getValue().getPermissions()).addAll(items);
- } else {
- SUFFIX_ITEMS.put(e.getValue().getPermissions(), items);
- }
- }
-
- if (task != null) {
- task.cancel();
- }
- refreshTagTask();
- }
-
- private void refreshTagTask() {
- for (Player player : pm.getServer().getOnlinePlayers()) {
- PlayerTagBean.initPlayerTag(player, pm);
- }
- if (REFRESH_TAG_TIME > 0) {
- task = pm.getServer().getScheduler().runTaskLaterAsynchronously(pm, new Runnable() {
- @Override
- public void run() {
- refreshTagTask();
- }
- }, REFRESH_TAG_TIME * 20);
- }
- }
-
- private List getTagItem(TagType tagType, TagPackageBean tpb) {
- List items = new ArrayList<>();
- if (tpb != null) {
- List tags = null;
- String itemDisplayName = "";
- Map> tagPermissions = null;
- if (tagType == TagType.NAMECOLOR_TYPE) {
- tags = tpb.getNamecolor();
- itemDisplayName = LangCfg.TAG_COLOR_ITEM_NAME + "§1§r ";
- tagPermissions = NAMECOLOR_PERMISSIONS;
- } else if (tagType == TagType.PREFIX_TYPE) {
- tags = tpb.getPrefix();
- itemDisplayName = LangCfg.TAG_PREFIX_ITEM_NAME + "§2§r ";
- tagPermissions = PREFIX_PERMISSIONS;
- } else if (tagType == TagType.SUFFIX_TYPE) {
- tags = tpb.getSuffix();
- itemDisplayName = LangCfg.TAG_SUFFIX_ITEM_NAME + "§3§r ";
- tagPermissions = SUFFIX_PERMISSIONS;
- }
- if (tags != null) {
- for (String tag : tags) {
- String[] args = tag.split(":");
- tag = args[0];
- Material type = null;
- int exid = 0;
- String skullOwner = null;
- if (args.length > 1) {
- type = Material.getMaterial(args[1].toUpperCase(Locale.ENGLISH));
- if (type == null) {
- int id = Integer.parseInt(args[1]);
- type = Material.getMaterial(id);
- }
- if (args.length > 2) {
- try {
- exid = Integer.parseInt(args[2]);
- } catch (NumberFormatException e) {
- if (Material.SKULL_ITEM.equals(type)) {
- exid = 3;
- skullOwner = args[2];
- } else {
- e.printStackTrace();
- }
- }
- }
- } else {
- type = Material.getMaterial("NAME_TAG");
- }
- if (type != null) {
- ItemStack item = new ItemStack(type, 1, (short) 0, (byte) exid);
- ItemMeta meta = item.getItemMeta();
- meta.setDisplayName(StrUtil.messageFormat(itemDisplayName + tag));
- List lores = new ArrayList<>(TEMPLATE_LORE);
- for (int i = 0; i < lores.size(); i++) {
- if (lores.get(i).contains("%description%")) {
- lores.set(i, StrUtil.messageFormat(lores.get(i).replaceAll("%description%", tpb.getDescription())));// 描述
- } else {
- lores.set(i, StrUtil.messageFormat(lores.get(i)));
- }
- }
- lores.add("§8§k" + tpb.getPermissions());// 权限
- lores.add("§8" + tag);// 称号
- meta.setLore(lores);
- item.setItemMeta(meta);
- if (skullOwner != null) {
- try {
- ((SkullMeta) meta).setOwner(skullOwner);
- item.setItemMeta(meta);
- } catch (Exception e) {
- e.printStackTrace();
- item = ItemUtil.addSkullOwner(item, skullOwner);
- }
- }
- items.add(item);
- }
- if (!tagPermissions.containsKey(tag)) {
- tagPermissions.put(tag, new ArrayList<>());
- }
- tagPermissions.get(tag).add(tpb.getPermissions());
- }
- }
- }
- return items;
- }
-}
\ No newline at end of file
diff --git a/src/main/gg/frog/mc/nametags/gui/PlayerTagShow.java b/src/main/gg/frog/mc/nametags/gui/PlayerTagShow.java
deleted file mode 100644
index adf5275..0000000
--- a/src/main/gg/frog/mc/nametags/gui/PlayerTagShow.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package gg.frog.mc.nametags.gui;
-
-import java.util.List;
-
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.ItemMeta;
-
-import gg.frog.mc.base.PluginMain;
-import gg.frog.mc.base.config.LangCfg;
-import gg.frog.mc.base.config.PluginCfg;
-import gg.frog.mc.base.utils.StrUtil;
-import gg.frog.mc.base.utils.nms.ItemUtil;
-import gg.frog.mc.nametags.config.TagNameCfg;
-import gg.frog.mc.nametags.config.TagNameCfg.TagType;
-import gg.frog.mc.nametags.model.PlayerTagBean;
-
-public class PlayerTagShow {
-
- public static void show(PluginMain pm, Player p, TagType tagType, List itemList, List disItemList) {
- Inventory inventory = null;
- int size = 0;
- if (itemList.size() > 0) {
- inventory = Bukkit.createInventory(null, ((itemList.size() + disItemList.size()) % 9 == 0 ? (itemList.size() + disItemList.size()) : ((itemList.size() + disItemList.size()) / 9 + 1) * 9), StrUtil.messageFormat(LangCfg.TAG_INVENTORY_NAME + "§r§5§9§2§0§2§r"));
- String uuid = pm.getPlayerUUIDByName(p);
- PlayerTagBean playerTag = null;
- if (uuid != null && TagNameCfg.PLAYER_TAG.containsKey(uuid)) {
- playerTag = TagNameCfg.PLAYER_TAG.get(uuid);
- if (playerTag != null) {
- for (ItemStack item : itemList) {
- playerTag = playerTag.clone();
- ItemStack tItem = item.clone();
- ItemMeta meta = tItem.getItemMeta();
- List lores = meta.getLore();
- String tag = lores.get(lores.size() - 1);
- tag = tag.length() > 2 ? tag.substring(2) : "";
- if (tagType == TagType.NAMECOLOR_TYPE) {
- meta.setDisplayName(meta.getDisplayName() + p.getName());
- playerTag.setNamecolor(tag);
- } else if (tagType == TagType.PREFIX_TYPE) {
- playerTag.setPrefix(tag);
- } else if (tagType == TagType.SUFFIX_TYPE) {
- playerTag.setSuffix(tag);
- }
- for (int i = 0; i < lores.size(); i++) {
- if (lores.get(i).contains("%displayname%")) {
- lores.set(i, lores.get(i).replaceAll("%displayname%", playerTag.getDisplayNameStr(p)));// 效果
- }
- }
- meta.setLore(lores);
- tItem.setItemMeta(meta);
- inventory.addItem(tItem);
- size++;
- }
- for (ItemStack item : disItemList) {
- playerTag = playerTag.clone();
- ItemStack tItem = item.clone();
- ItemMeta meta = tItem.getItemMeta();
- List lores = meta.getLore();
- String tag = lores.get(lores.size() - 1);
- tag = tag.length() > 2 ? tag.substring(2) : "";
- if (tagType == TagType.NAMECOLOR_TYPE) {
- meta.setDisplayName("§6§l§m" + meta.getDisplayName().substring(4) + p.getName());
- playerTag.setNamecolor(tag);
- } else if (tagType == TagType.PREFIX_TYPE) {
- meta.setDisplayName("§6§l§m" + meta.getDisplayName().substring(4));
- playerTag.setPrefix(tag);
- } else if (tagType == TagType.SUFFIX_TYPE) {
- meta.setDisplayName("§6§l§m" + meta.getDisplayName().substring(4));
- playerTag.setSuffix(tag);
- }
- for (int i = 0; i < lores.size(); i++) {
- if (lores.get(i).contains("%displayname%")) {
- lores.set(i, lores.get(i).replaceAll("%displayname%", playerTag.getDisplayNameStr(p)));// 效果
- }
- }
- meta.setLore(lores);
- tItem.setItemMeta(meta);
- tItem = ItemUtil.addEnchantLight(tItem);
- inventory.addItem(tItem);
- size++;
- }
- }
- }
- }
- if (inventory != null && size > 0) {
- p.openInventory(inventory);
- } else {
- p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_TAG_DATA));
- }
- }
-}
diff --git a/src/main/gg/frog/mc/nametags/listener/TagsListener.java b/src/main/gg/frog/mc/nametags/listener/TagsListener.java
deleted file mode 100644
index 5d67f08..0000000
--- a/src/main/gg/frog/mc/nametags/listener/TagsListener.java
+++ /dev/null
@@ -1,120 +0,0 @@
-package gg.frog.mc.nametags.listener;
-
-import java.util.List;
-
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.EventPriority;
-import org.bukkit.event.Listener;
-import org.bukkit.event.inventory.InventoryClickEvent;
-import org.bukkit.event.player.PlayerChangedWorldEvent;
-import org.bukkit.event.player.PlayerKickEvent;
-import org.bukkit.event.player.PlayerLoginEvent;
-import org.bukkit.event.player.PlayerMoveEvent;
-import org.bukkit.event.player.PlayerQuitEvent;
-
-import gg.frog.mc.base.PluginMain;
-import gg.frog.mc.base.config.LangCfg;
-import gg.frog.mc.base.config.PluginCfg;
-import gg.frog.mc.base.utils.StrUtil;
-import gg.frog.mc.nametags.config.TagNameCfg;
-import gg.frog.mc.nametags.model.PlayerTagBean;
-
-public class TagsListener implements Listener {
-
- private PluginMain pm;
-
- public TagsListener(PluginMain pm) {
- this.pm = pm;
- }
-
- @EventHandler(priority = EventPriority.LOWEST)
- public void onJoin(PlayerLoginEvent event) {
- if (PluginCfg.TAG_SYSTEM) {
- pm.getServer().getScheduler().runTaskLaterAsynchronously(pm, new Runnable() {
- @Override
- public void run() {
- PlayerTagBean.initPlayerTag(event.getPlayer(), pm);
- }
- }, 1 * 20);
- }
- }
-
- @EventHandler
- public void onRespawn(PlayerChangedWorldEvent event) {
- if (PluginCfg.TAG_SYSTEM) {
- PlayerTagBean.initPlayerTag(event.getPlayer(), pm);
- }
- }
-
- @EventHandler
- public void onQuit(PlayerQuitEvent event) {
- if (PluginCfg.TAG_SYSTEM && TagNameCfg.USE_HD_PLUGIN) {
- String uuid = pm.getPlayerUUIDByName(event.getPlayer());
- PlayerTagBean playerTag = TagNameCfg.PLAYER_TAG.get(uuid);
- playerTag.delHologramsName();
- }
- }
-
- @EventHandler
- public void onKick(PlayerKickEvent event) {
- if (PluginCfg.TAG_SYSTEM && TagNameCfg.USE_HD_PLUGIN) {
- String uuid = pm.getPlayerUUIDByName(event.getPlayer());
- PlayerTagBean playerTag = TagNameCfg.PLAYER_TAG.get(uuid);
- playerTag.delHologramsName();
- }
- }
-
- @EventHandler
- public void onMove(PlayerMoveEvent event) {
- if (PluginCfg.TAG_SYSTEM && TagNameCfg.USE_HD_PLUGIN) {
- String uuid = this.pm.getPlayerUUIDByName(event.getPlayer());
- PlayerTagBean playerTag = TagNameCfg.PLAYER_TAG.get(uuid);
- if (playerTag != null) {
- playerTag.moveHologramsName(event.getPlayer());
- }
- }
- }
-
- @EventHandler
- public void onPlayerClick(InventoryClickEvent event) {
- if (StrUtil.messageFormat(LangCfg.TAG_INVENTORY_NAME + "§r§5§9§2§0§2§r").equals(event.getInventory().getName())) {
- try {
- if (event.getCurrentItem() != null && event.getCurrentItem().getItemMeta() != null && event.getCurrentItem().getItemMeta().hasLore()) {
- List lores = event.getCurrentItem().getItemMeta().getLore();
- if (lores.size() > 1) {
- String permissions = lores.get(lores.size() - 2);
- permissions = permissions.startsWith("§8§k") ? permissions.substring(4) : "noPermissions";
- String uuid = pm.getPlayerUUIDByName((Player) event.getWhoClicked());
- if (permissions.length() == 0 || event.getWhoClicked().hasPermission(permissions)) {
- if (TagNameCfg.PLAYER_TAG.containsKey(uuid)) {
- String itemName = event.getCurrentItem().getItemMeta().getDisplayName();
- PlayerTagBean playerTag = TagNameCfg.PLAYER_TAG.get(uuid);
- if (itemName.startsWith(StrUtil.messageFormat(LangCfg.TAG_COLOR_ITEM_NAME + "§1§r "))) {
- playerTag.setNamecolor(lores.get(lores.size() - 1).substring(2));
- } else if (itemName.startsWith(StrUtil.messageFormat(LangCfg.TAG_PREFIX_ITEM_NAME + "§2§r "))) {
- playerTag.setPrefix(lores.get(lores.size() - 1).substring(2));
- } else if (itemName.startsWith(StrUtil.messageFormat(LangCfg.TAG_SUFFIX_ITEM_NAME + "§3§r "))) {
- playerTag.setSuffix(lores.get(lores.size() - 1).substring(2));
- } else {
- ((Player) event.getWhoClicked()).sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_PERMISSION));
- event.setCancelled(true);
- return;
- }
- playerTag.setPlayerDisplayName((Player) event.getWhoClicked(), true);
- playerTag.saveConfig();
- ((Player) event.getWhoClicked()).sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_TAG_SET_SUCCESS));
- event.setCancelled(true);
- return;
- }
- }
- ((Player) event.getWhoClicked()).sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_PERMISSION));
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- event.setCancelled(true);
- }
- }
-}
diff --git a/src/main/gg/frog/mc/nametags/model/PlayerTagBean.java b/src/main/gg/frog/mc/nametags/model/PlayerTagBean.java
deleted file mode 100644
index fcaf0f5..0000000
--- a/src/main/gg/frog/mc/nametags/model/PlayerTagBean.java
+++ /dev/null
@@ -1,290 +0,0 @@
-package gg.frog.mc.nametags.model;
-
-import org.bukkit.Location;
-import org.bukkit.command.CommandSender;
-import org.bukkit.configuration.MemorySection;
-import org.bukkit.configuration.file.YamlConfiguration;
-import org.bukkit.entity.Player;
-import org.bukkit.scoreboard.Team;
-
-import com.gmail.filoghost.holographicdisplays.api.Hologram;
-import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
-
-import gg.frog.mc.base.PluginMain;
-import gg.frog.mc.base.config.PluginCfg;
-import gg.frog.mc.base.utils.StrUtil;
-import gg.frog.mc.base.utils.config.IConfigBean;
-import gg.frog.mc.base.utils.config.PluginConfig;
-import gg.frog.mc.base.utils.nms.NMSUtil;
-import gg.frog.mc.nametags.config.TagNameCfg;
-
-/**
- * 玩家标签包实体类
- *
- * @author QiaoPengyu
- *
- */
-public class PlayerTagBean extends PluginConfig implements IConfigBean, Cloneable {
-
- // 名称颜色
- private String namecolor;
- // 前缀
- private String prefix;
- // 后缀
- private String suffix;
- // 当前显示的名称
- private String displayName;
- // 当前显示的前缀
- private String displayPrefix;
- // 当前显示的后缀
- private String displaySuffix;
- // 玩家所在队伍
- private Team team;
- // 不可见的队伍名
- private String invisibleName;
- // hd
- private Hologram holograms;
-
- public PlayerTagBean(String fileName, PluginMain pm) {
- super(fileName, pm);
- }
-
- @Override
- protected void init() {
-
- }
-
- @Override
- protected void loadToDo(CommandSender sender) {
- namecolor = getConfig().getString("namecolor", TagNameCfg.DEFAULT_NAMECOLOR);
- prefix = getConfig().getString("prefix", TagNameCfg.DEFAULT_PREFIX);
- suffix = getConfig().getString("suffix", TagNameCfg.DEFAULT_SUFFIX);
- }
-
- public void saveConfig() {
- getConfig().set("namecolor", namecolor);
- getConfig().set("prefix", prefix);
- getConfig().set("suffix", suffix);
- super.saveConfig();
- }
-
- public static void initPlayerTag(Player player, PluginMain pm) {
- String uuid = pm.getPlayerUUIDByName(player);
- PlayerTagBean playerTag = null;
- if (TagNameCfg.PLAYER_TAG.containsKey(uuid)) {
- playerTag = TagNameCfg.PLAYER_TAG.get(uuid);
- } else {
- playerTag = new PlayerTagBean("playerTag/" + uuid + ".yml", pm);
- TagNameCfg.PLAYER_TAG.put(uuid, playerTag);
- }
- playerTag.setPlayerDisplayName(player, true);
- }
-
- public void setPlayerDisplayName(Player player) {
- setPlayerDisplayName(player, false);
- }
-
- public void setPlayerDisplayName(Player player, boolean forceSet) {
- PlayerTagBean playerTag = this;
- pm.getServer().getScheduler().runTask(pm, new Runnable() {
- @Override
- public void run() {
- boolean namecolor_flag = true;
- boolean prefix_flag = true;
- boolean suffix_flag = true;
- if (!(namecolor.equals(TagNameCfg.DEFAULT_NAMECOLOR) && prefix.equals(TagNameCfg.DEFAULT_PREFIX) && suffix.equals(TagNameCfg.DEFAULT_SUFFIX))) {
- if (TagNameCfg.NAMECOLOR_PERMISSIONS.containsKey(namecolor)) {
- for (String p : TagNameCfg.NAMECOLOR_PERMISSIONS.get(namecolor)) {
- if (p == null || p.length() == 0 || player.hasPermission(p)) {
- namecolor_flag = false;
- break;
- }
- }
- }
- if (namecolor_flag) {
- namecolor = TagNameCfg.DEFAULT_NAMECOLOR;
- }
- if (TagNameCfg.PREFIX_PERMISSIONS.containsKey(prefix)) {
- for (String p : TagNameCfg.PREFIX_PERMISSIONS.get(prefix)) {
- if (p == null || p.length() == 0 || player.hasPermission(p)) {
- prefix_flag = false;
- break;
- }
- }
- }
- if (prefix_flag) {
- prefix = TagNameCfg.DEFAULT_PREFIX;
- }
- if (TagNameCfg.SUFFIX_PERMISSIONS.containsKey(suffix)) {
- for (String p : TagNameCfg.SUFFIX_PERMISSIONS.get(suffix)) {
- if (p == null || p.length() == 0 || player.hasPermission(p)) {
- suffix_flag = false;
- break;
- }
- }
- }
- if (suffix_flag) {
- suffix = TagNameCfg.DEFAULT_SUFFIX;
- }
- }
- if (forceSet || namecolor_flag || prefix_flag || suffix_flag) {
- displayPrefix = StrUtil.messageFormat(player, prefix + "§r" + namecolor);
- displaySuffix = StrUtil.messageFormat(player, "§r" + suffix);
- displayName = "§r" + displayPrefix + player.getName() + displaySuffix + "§r";
- if (TagNameCfg.CHANGE_DISPLAYNAME) {
- player.setDisplayName(displayName);
- }
- if (PluginCfg.IS_DEBUG) {
- System.out.println("PlayerTagBean:" + playerTag);
- }
- try {
- if (TagNameCfg.scoreboard == null) {
- TagNameCfg.scoreboard = pm.getServer().getScoreboardManager().getNewScoreboard();
- }
- if (invisibleName == null) {
- invisibleName = String.valueOf(TagNameCfg.scoreboard.getTeams().size() + 1).replaceAll("", "§");
- }
- if (!TagNameCfg.USE_HD_PLUGIN) {
- team = TagNameCfg.scoreboard.getTeam(player.getName());
- if (team == null) {
- team = TagNameCfg.scoreboard.registerNewTeam(player.getName());
- }
- String teamPrefix = displayPrefix.length() > 16 ? (displayPrefix.substring(0, 7) + ".." + displayPrefix.substring(displayPrefix.length() - 7)) : displayPrefix;
- team.setPrefix(teamPrefix);
- String teamSuffix = displaySuffix.length() > 16 ? (displaySuffix.substring(0, 7) + ".." + displaySuffix.substring(displaySuffix.length() - 7)) : displaySuffix;
- team.setSuffix(teamSuffix);
- if (!(holograms == null || holograms.isDeleted())) {
- holograms.delete();
- }
- } else {
- team = TagNameCfg.scoreboard.getTeam(invisibleName);
- if (team == null) {
- team = TagNameCfg.scoreboard.registerNewTeam(invisibleName);
- }
- team.setPrefix("");
- team.setSuffix("");
- if (NMSUtil.getServerVersion().startsWith("v1_7") || NMSUtil.getServerVersion().startsWith("v1_8")) {
- } else {
- team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.NEVER);
- }
- initHologramsName(player);
- }
- team.addPlayer(player);
- player.setScoreboard(TagNameCfg.scoreboard);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- });
- }
-
- public void initHologramsName(Player player) {
- Location loc = player.getLocation();
- loc = new Location(loc.getWorld(), loc.getX(), loc.getY() + (TagNameCfg.ONE_LINE_DISPLAY ? 2.25 : 2.75), loc.getZ());
- if (holograms == null || holograms.isDeleted()) {
- holograms = HologramsAPI.createHologram(pm, loc);
- } else {
- holograms.teleport(loc);
- }
- holograms.clearLines();
- if (TagNameCfg.ONE_LINE_DISPLAY) {
- holograms.appendTextLine(getDisplayNameStr(player));
- } else {
- holograms.appendTextLine(StrUtil.messageFormat(player, prefix));
- holograms.appendTextLine(StrUtil.messageFormat(player, namecolor + player.getName()));
- holograms.appendTextLine(StrUtil.messageFormat(player, suffix));
- }
- holograms.getVisibilityManager().hideTo(player);
- }
-
- public void moveHologramsName(Player player) {
- if (!(holograms == null || holograms.isDeleted())) {
- Location loc = player.getLocation();
- loc = new Location(loc.getWorld(), loc.getX(), loc.getY() + (TagNameCfg.ONE_LINE_DISPLAY ? 2.25 : 2.75), loc.getZ());
- holograms.teleport(loc);
- }
- }
-
- /**
- * 退出游戏调用
- */
- public void delHologramsName() {
- if (!(holograms == null || holograms.isDeleted())) {
- holograms.delete();
- }
- }
-
- public String getDisplayNameStr(Player player) {
- return StrUtil.messageFormat(player, prefix + "§r" + namecolor + player.getName() + "§r" + suffix);
- }
-
- @Override
- public PlayerTagBean clone() {
- PlayerTagBean t = null;
- try {
- t = (PlayerTagBean) super.clone();
- } catch (CloneNotSupportedException e) {
- e.printStackTrace();
- }
- return t;
- }
-
- public String getNamecolor() {
- return namecolor;
- }
-
- public void setNamecolor(String namecolor) {
- this.namecolor = namecolor;
- }
-
- public String getPrefix() {
- return prefix;
- }
-
- public void setPrefix(String prefix) {
- this.prefix = prefix;
- }
-
- public String getSuffix() {
- return suffix;
- }
-
- public void setSuffix(String suffix) {
- this.suffix = suffix;
- }
-
- public String getDisplayName() {
- return displayName;
- }
-
- public String getDisplayPrefix() {
- return displayPrefix;
- }
-
- public String getDisplaySuffix() {
- return displaySuffix;
- }
-
- @Override
- public YamlConfiguration toConfig() {
- YamlConfiguration config = new YamlConfiguration();
- config.set("namecolor", namecolor);
- config.set("prefix", prefix);
- config.set("suffix", suffix);
- return config;
- }
-
- @Override
- public void toConfigBean(MemorySection config) {
- namecolor = config.getString("namecolor");
- prefix = config.getString("prefix");
- suffix = config.getString("suffix");
- }
-
- @Override
- public String toString() {
- return "PlayerTagBean [namecolor=" + namecolor + ", prefix=" + prefix + ", suffix=" + suffix + ", displayName=" + displayName + ", displayPrefix=" + displayPrefix + ", displaySuffix=" + displaySuffix + ", invisibleName=" + invisibleName + "]";
- }
-
-}
diff --git a/src/main/gg/frog/mc/nametags/placeholder/TagPlaceholder.java b/src/main/gg/frog/mc/nametags/placeholder/TagPlaceholder.java
deleted file mode 100644
index c9f552c..0000000
--- a/src/main/gg/frog/mc/nametags/placeholder/TagPlaceholder.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package gg.frog.mc.nametags.placeholder;
-
-import org.bukkit.entity.Player;
-
-import gg.frog.mc.base.PluginMain;
-import gg.frog.mc.base.config.PluginCfg;
-import gg.frog.mc.nametags.config.TagNameCfg;
-import gg.frog.mc.nametags.model.PlayerTagBean;
-import me.clip.placeholderapi.expansion.PlaceholderExpansion;
-
-public class TagPlaceholder extends PlaceholderExpansion {
-
- private PluginMain pm;
-
- public TagPlaceholder(PluginMain pm) {
- this.pm = pm;
- }
-
- public boolean persist() {
- return true;
- }
-
- public String getIdentifier() {
- return "pttag";
- }
-
- public String getPlugin() {
- return null;
- }
-
- public String getAuthor() {
- return "GeekFrog";
- }
-
- public String getVersion() {
- return pm.PLUGIN_VERSION;
- }
-
- public String onPlaceholderRequest(Player player, String identifier) {
- if (PluginCfg.TAG_SYSTEM && player != null) {
- String uuid = pm.getPlayerUUIDByName(player);
- PlayerTagBean playerTag = TagNameCfg.PLAYER_TAG.get(uuid);
- if (playerTag != null) {
- if (identifier.equalsIgnoreCase("fullname")) {
- return playerTag.getDisplayName();
- } else if (identifier.equalsIgnoreCase("prefix")) {
- return playerTag.getDisplayPrefix();
- } else if (identifier.equalsIgnoreCase("suffix")) {
- return playerTag.getDisplaySuffix();
- }
- }
- }
- return null;
- }
-}
diff --git a/src/main/gg/frog/mc/base/PluginMain.java b/src/main/gg/frog/mc/permissionstime/PluginMain.java
similarity index 57%
rename from src/main/gg/frog/mc/base/PluginMain.java
rename to src/main/gg/frog/mc/permissionstime/PluginMain.java
index 858f504..14f8d10 100644
--- a/src/main/gg/frog/mc/base/PluginMain.java
+++ b/src/main/gg/frog/mc/permissionstime/PluginMain.java
@@ -1,47 +1,31 @@
-package gg.frog.mc.base;
+package gg.frog.mc.permissionstime;
import java.text.MessageFormat;
import java.util.Locale;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Logger;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
-import org.bukkit.OfflinePlayer;
-import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
-import org.bukkit.plugin.java.JavaPlugin;
-import gg.frog.mc.base.config.ConfigManager;
-import gg.frog.mc.base.config.PluginCfg;
-import gg.frog.mc.base.listener.BaseListener;
import gg.frog.mc.base.utils.FileUtil;
import gg.frog.mc.base.utils.StrUtil;
import gg.frog.mc.base.utils.UpdateCheck;
-import gg.frog.mc.nametags.listener.TagsListener;
-import gg.frog.mc.nametags.placeholder.TagPlaceholder;
+import gg.frog.mc.base.utils.PluginBase;
import gg.frog.mc.permissionstime.command.PtCommand;
+import gg.frog.mc.permissionstime.config.ConfigManager;
+import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.permissionstime.database.SqlManager;
import gg.frog.mc.permissionstime.listener.PtListener;
import net.milkbowl.vault.permission.Permission;
-public class PluginMain extends JavaPlugin {
+public class PluginMain extends PluginBase {
- public String PLUGIN_NAME;
- public String PLUGIN_VERSION;
- public String PLUGIN_NAME_LOWER_CASE;
- public static final String DEPEND_PLUGIN = "SQLibrary,Vault";
- public static final Logger LOG = Logger.getLogger("Minecraft");
+ public static final String DEPEND_PLUGIN = "Vault";
private ConfigManager cm = null;
private PluginMain pm = null;
private SqlManager sm = null;
private Permission permission = null;
- public static boolean enabledHdPlugin;
- public static boolean enabledPlaceholder;
- private Map PLAYER_UUID_MAP = new ConcurrentHashMap<>();
- private Map OFFLINE_PLAYER_MAP = new ConcurrentHashMap<>();
public PluginMain() {
PLUGIN_NAME = getDescription().getName();
@@ -77,7 +61,7 @@ public class PluginMain extends JavaPlugin {
e.printStackTrace();
}
}
- getServer().getScheduler().runTaskAsynchronously(pm, new UpdateCheck(pm));
+ getServer().getScheduler().runTaskAsynchronously(pm, new UpdateCheck(pm, "https://raw.githubusercontent.com/geekfrog/PermissionsTime/master/src/resources/plugin.yml"));
}
});
}
@@ -88,9 +72,7 @@ public class PluginMain extends JavaPlugin {
* 这里可以注册多个
*/
private void registerListeners() {
- pm.getServer().getPluginManager().registerEvents(new BaseListener(pm), pm);
pm.getServer().getPluginManager().registerEvents(new PtListener(pm), pm);
- pm.getServer().getPluginManager().registerEvents(new TagsListener(pm), pm);
}
/**
@@ -118,11 +100,7 @@ public class PluginMain extends JavaPlugin {
public Permission getPermission() {
return permission;
}
-
- public Map getOFFLINE_PLAYER_MAP() {
- return OFFLINE_PLAYER_MAP;
- }
-
+
private boolean checkPluginDepends() {
boolean needDepend = false;
for (String name : DEPEND_PLUGIN.split(",")) {
@@ -139,28 +117,6 @@ public class PluginMain extends JavaPlugin {
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Cann''t setup database."));
needDepend = true;
}
- enabledPlaceholder = Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI");
- if (!enabledPlaceholder) {
- getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§ePlaceholder is not installed or not enabled."));
- getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§eSome func will be disabled."));
- } else {
- boolean placeholdersHook = false;
- try {
- placeholdersHook = new TagPlaceholder(pm).register();
- } catch (Exception e) {
-
- }
- if (!placeholdersHook) {
- getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4Cann''t hook placeholders"));
- getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§4The placeholders '%permissionstime_displayname%' Cann''t use."));
- }
- }
- enabledHdPlugin = Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays");
- if (!enabledHdPlugin) {
- getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§eHolographicDisplays is not installed or not enabled."));
- getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "§eSome func will be disabled."));
- }
-
if (needDepend) {
return false;
}
@@ -190,51 +146,6 @@ public class PluginMain extends JavaPlugin {
return sm.updateDatabase();
}
- public OfflinePlayer getOfflinePlayer(String name) {
- if (name != null) {
- OfflinePlayer p = OFFLINE_PLAYER_MAP.get(name);
- if (p != null)
- return p;
- for (OfflinePlayer p2 : getServer().getOfflinePlayers()) {
- if (p2 == null)
- continue;
- if (p2.getName().equalsIgnoreCase(name)) {
- OFFLINE_PLAYER_MAP.put(name, p2);
- return p2;
- }
- }
- }
- return null;
- }
-
- public String getPlayerUUIDByName(Player p) {
- String uuid = getPlayerUUIDByName(p.getName());
- if (uuid == null) {
- return p.getUniqueId().toString();
- }
- return uuid;
- }
-
- public String getPlayerUUIDByName(String name) {
- if (name != null) {
- String uuid = PLAYER_UUID_MAP.get(name);
- if (uuid != null) {
- return uuid;
- } else {
- for (OfflinePlayer p : getServer().getOfflinePlayers()) {
- if (p == null)
- continue;
- if (p.getName().equalsIgnoreCase(name)) {
- uuid = p.getUniqueId().toString();
- PLAYER_UUID_MAP.put(name, uuid);
- return uuid;
- }
- }
- }
- }
- return null;
- }
-
public void writeFailLog(String content, Object... args) {
FileUtil.writeOnFile(getDataFolder() + "/failure.log", "[" + StrUtil.nowTimeString() + "] " + MessageFormat.format(content, args));
}
diff --git a/src/main/gg/frog/mc/permissionstime/command/GetCmd.java b/src/main/gg/frog/mc/permissionstime/command/GetCmd.java
index d03415c..e6942ff 100644
--- a/src/main/gg/frog/mc/permissionstime/command/GetCmd.java
+++ b/src/main/gg/frog/mc/permissionstime/command/GetCmd.java
@@ -4,11 +4,12 @@ import java.util.List;
import org.bukkit.command.CommandSender;
-import gg.frog.mc.base.PluginMain;
-import gg.frog.mc.base.config.LangCfg;
-import gg.frog.mc.base.config.PluginCfg;
+import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.base.utils.StrUtil;
+import gg.frog.mc.base.utils.data.PlayerData;
+import gg.frog.mc.permissionstime.config.LangCfg;
import gg.frog.mc.permissionstime.config.PackagesCfg;
+import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.permissionstime.database.SqlManager;
import gg.frog.mc.permissionstime.model.cfg.PermissionPackageBean;
import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
@@ -31,33 +32,25 @@ public class GetCmd implements Runnable {
public void run() {
if (args.length == 2) {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
- String uuid = pm.getPlayerUUIDByName(args[1]);
+ String uuid = PlayerData.getPlayerUUIDByName(args[1]);
if (uuid != null) {
List ps = sm.getTime(uuid);
if (ps.size() > 0) {
- sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NUM_OF_PACKAGES,
- args[1], ps.size()));
+ sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NUM_OF_PACKAGES, args[1], ps.size()));
for (PlayerDataBean pdb : ps) {
String expireString = StrUtil.timestampToString(pdb.getExpire());
PermissionPackageBean pc = PackagesCfg.PACKAGES.get(pdb.getPackageName());
if (pc != null && pdb.getGlobal() == pc.getGlobal()) {
- sender.sendMessage(
- StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_EXPIRATION_DATE,
- pdb.getGlobal() ? "*" : "", pc.getDisplayName(), pdb.getPackageName(),
- expireString, StrUtil.getLeftTime(pdb.getExpire())));
+ sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_EXPIRATION_DATE, pdb.getGlobal() ? "*" : "", pc.getDisplayName(), pdb.getPackageName(), expireString, PlayerDataBean.getLeftTime(pdb.getExpire())));
} else {
- sender.sendMessage(
- StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_EXPIRATION_DATE,
- pdb.getGlobal() ? "*" : "", LangCfg.MSG_UNKNOWN_PACKAGE,
- pdb.getPackageName(), expireString, StrUtil.getLeftTime(pdb.getExpire())));
+ sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_EXPIRATION_DATE, pdb.getGlobal() ? "*" : "", LangCfg.MSG_UNKNOWN_PACKAGE, pdb.getPackageName(), expireString, PlayerDataBean.getLeftTime(pdb.getExpire())));
}
}
} else {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_DATA));
}
} else {
- sender.sendMessage(
- StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_FIND_PLAYER, args[1]));
+ sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_FIND_PLAYER, args[1]));
}
} else {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PARAMETER_MISMATCH));
diff --git a/src/main/gg/frog/mc/permissionstime/command/GiveCmd.java b/src/main/gg/frog/mc/permissionstime/command/GiveCmd.java
index 2cfc5f7..61b8e70 100644
--- a/src/main/gg/frog/mc/permissionstime/command/GiveCmd.java
+++ b/src/main/gg/frog/mc/permissionstime/command/GiveCmd.java
@@ -6,11 +6,12 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import gg.frog.mc.base.PluginMain;
-import gg.frog.mc.base.config.LangCfg;
-import gg.frog.mc.base.config.PluginCfg;
+import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.base.utils.StrUtil;
+import gg.frog.mc.base.utils.data.PlayerData;
+import gg.frog.mc.permissionstime.config.LangCfg;
import gg.frog.mc.permissionstime.config.PackagesCfg;
+import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.permissionstime.database.SqlManager;
import gg.frog.mc.permissionstime.model.cfg.PermissionPackageBean;
import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
@@ -63,10 +64,10 @@ public class GiveCmd implements Runnable {
}
PermissionPackageBean pack = PackagesCfg.PACKAGES.get(packageName);
if (pack != null) {
- OfflinePlayer player = pm.getOfflinePlayer(playerName);
+ OfflinePlayer player = PlayerData.getOfflinePlayer(playerName);
if (player != null) {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
- String uuid = pm.getPlayerUUIDByName(playerName);
+ String uuid = PlayerData.getPlayerUUIDByName(playerName);
if (PluginCfg.IS_DEBUG) {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + uuid + "\n" + pack.toString() + "\n" + time + unitName + "."));
}
diff --git a/src/main/gg/frog/mc/permissionstime/command/MeCmd.java b/src/main/gg/frog/mc/permissionstime/command/MeCmd.java
index eb02dea..3cc12fd 100644
--- a/src/main/gg/frog/mc/permissionstime/command/MeCmd.java
+++ b/src/main/gg/frog/mc/permissionstime/command/MeCmd.java
@@ -5,10 +5,11 @@ import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import gg.frog.mc.base.PluginMain;
-import gg.frog.mc.base.config.LangCfg;
-import gg.frog.mc.base.config.PluginCfg;
+import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.base.utils.StrUtil;
+import gg.frog.mc.base.utils.data.PlayerData;
+import gg.frog.mc.permissionstime.config.LangCfg;
+import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.permissionstime.database.SqlManager;
import gg.frog.mc.permissionstime.gui.PlayerPermissionShow;
import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
@@ -34,7 +35,7 @@ public class MeCmd implements Runnable {
if (isPlayer) {
if (args.length == 1) {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
- String uuid = pm.getPlayerUUIDByName((Player) sender);
+ String uuid = PlayerData.getPlayerUUIDByName((Player) sender);
List ps = sm.getTime(uuid);
PlayerPermissionShow.show((Player) sender, ps);
} else {
diff --git a/src/main/gg/frog/mc/permissionstime/command/PackagesCmd.java b/src/main/gg/frog/mc/permissionstime/command/PackagesCmd.java
index ea36724..2658cad 100644
--- a/src/main/gg/frog/mc/permissionstime/command/PackagesCmd.java
+++ b/src/main/gg/frog/mc/permissionstime/command/PackagesCmd.java
@@ -4,11 +4,11 @@ import java.util.Map.Entry;
import org.bukkit.command.CommandSender;
-import gg.frog.mc.base.PluginMain;
-import gg.frog.mc.base.config.LangCfg;
-import gg.frog.mc.base.config.PluginCfg;
+import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.base.utils.StrUtil;
+import gg.frog.mc.permissionstime.config.LangCfg;
import gg.frog.mc.permissionstime.config.PackagesCfg;
+import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.permissionstime.model.cfg.PermissionPackageBean;
public class PackagesCmd implements Runnable {
diff --git a/src/main/gg/frog/mc/permissionstime/command/PtCommand.java b/src/main/gg/frog/mc/permissionstime/command/PtCommand.java
index d11c905..c6e7e9e 100644
--- a/src/main/gg/frog/mc/permissionstime/command/PtCommand.java
+++ b/src/main/gg/frog/mc/permissionstime/command/PtCommand.java
@@ -11,11 +11,8 @@ import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
-import gg.frog.mc.base.PluginMain;
-import gg.frog.mc.base.config.LangCfg;
-import gg.frog.mc.base.config.PluginCfg;
import gg.frog.mc.base.utils.StrUtil;
-import gg.frog.mc.nametags.command.TagCmd;
+import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.permissionstime.command.GetCmd;
import gg.frog.mc.permissionstime.command.GiveCmd;
import gg.frog.mc.permissionstime.command.MeCmd;
@@ -23,7 +20,9 @@ import gg.frog.mc.permissionstime.command.PackagesCmd;
import gg.frog.mc.permissionstime.command.RemoveAllCmd;
import gg.frog.mc.permissionstime.command.RemoveCmd;
import gg.frog.mc.permissionstime.command.SetCmd;
+import gg.frog.mc.permissionstime.config.LangCfg;
import gg.frog.mc.permissionstime.config.PackagesCfg;
+import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.permissionstime.database.SqlManager;
public class PtCommand implements CommandExecutor, TabCompleter {
@@ -54,7 +53,7 @@ public class PtCommand implements CommandExecutor, TabCompleter {
if (player.hasPermission("permissionstime.reload")) {
for (Player p : pm.getServer().getOnlinePlayers()) {
InventoryView inventory = p.getOpenInventory();
- if (inventory != null && (StrUtil.messageFormat(LangCfg.INVENTORY_NAME + "§r§5§9§2§0§1§r").equals(inventory.getTitle()) || StrUtil.messageFormat(LangCfg.TAG_INVENTORY_NAME + "§r§5§9§2§0§2§r").equals(inventory.getTitle()))) {
+ if (inventory != null && (StrUtil.messageFormat(LangCfg.INVENTORY_NAME + "§r§5§9§2§0§1§r").equals(inventory.getTitle()))) {
inventory.close();
}
}
@@ -70,7 +69,7 @@ public class PtCommand implements CommandExecutor, TabCompleter {
} else {
for (Player p : pm.getServer().getOnlinePlayers()) {
InventoryView inventory = p.getOpenInventory();
- if (inventory != null && (StrUtil.messageFormat(LangCfg.INVENTORY_NAME + "§r§5§9§2§0§1§r").equals(inventory.getTitle()) || StrUtil.messageFormat(LangCfg.TAG_INVENTORY_NAME + "§r§5§9§2§0§2§r").equals(inventory.getTitle()))) {
+ if (inventory != null && (StrUtil.messageFormat(LangCfg.INVENTORY_NAME + "§r§5§9§2§0§1§r").equals(inventory.getTitle()))) {
inventory.close();
}
}
@@ -86,15 +85,6 @@ public class PtCommand implements CommandExecutor, TabCompleter {
MeCmd meCmd = new MeCmd(pm, sender, isPlayer, args);
new Thread(meCmd).start();
}
- } else if (args[0].equalsIgnoreCase("tag")) {
- if (hasPermission(sender, isPlayer, "permissionstime.tag")) {
- if (PluginCfg.TAG_SYSTEM) {
- TagCmd tagCmd = new TagCmd(pm, sender, isPlayer, args);
- new Thread(tagCmd).start();
- } else {
- sender.sendMessage(StrUtil.messageFormat(LangCfg.MSG_FUNC_DISABLED, LangCfg.TAG));
- }
- }
} else if (args[0].equalsIgnoreCase("give")) {
if (hasPermission(sender, isPlayer, "permissionstime.give")) {
GiveCmd giveCmd = new GiveCmd(pm, sender, args);
@@ -139,9 +129,6 @@ public class PtCommand implements CommandExecutor, TabCompleter {
if (isPlayer && (sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".me"))) {
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_ME, pm.PLUGIN_NAME_LOWER_CASE));
}
- if (isPlayer && (sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".tag"))) {
- sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_TAG, pm.PLUGIN_NAME_LOWER_CASE));
- }
if (!isPlayer || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".packages")) {
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_PACKAGES, pm.PLUGIN_NAME_LOWER_CASE));
}
@@ -189,9 +176,6 @@ public class PtCommand implements CommandExecutor, TabCompleter {
if ("me".startsWith(args[0]) && (!isPlayer || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".me"))) {
tipList.add("me");
}
- if ("tag".startsWith(args[0]) && (!isPlayer || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".tag"))) {
- tipList.add("tag");
- }
if ("packages".startsWith(args[0]) && (!isPlayer || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".packages"))) {
tipList.add("packages");
}
@@ -222,10 +206,6 @@ public class PtCommand implements CommandExecutor, TabCompleter {
tipList.add(name);
}
}
- } else if ("tag".equalsIgnoreCase(args[0]) && (!isPlayer || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".tag"))) {
- tipList.add("c");
- tipList.add("p");
- tipList.add("s");
}
} else if (args.length == 3) {
args[0] = args[0].toLowerCase(Locale.ENGLISH);
diff --git a/src/main/gg/frog/mc/permissionstime/command/RemoveAllCmd.java b/src/main/gg/frog/mc/permissionstime/command/RemoveAllCmd.java
index 3887ce0..2574e53 100644
--- a/src/main/gg/frog/mc/permissionstime/command/RemoveAllCmd.java
+++ b/src/main/gg/frog/mc/permissionstime/command/RemoveAllCmd.java
@@ -6,10 +6,11 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import gg.frog.mc.base.PluginMain;
-import gg.frog.mc.base.config.LangCfg;
-import gg.frog.mc.base.config.PluginCfg;
+import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.base.utils.StrUtil;
+import gg.frog.mc.base.utils.data.PlayerData;
+import gg.frog.mc.permissionstime.config.LangCfg;
+import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.permissionstime.database.SqlManager;
import gg.frog.mc.permissionstime.model.cfg.PermissionPackageBean;
import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
@@ -36,10 +37,10 @@ public class RemoveAllCmd implements Runnable {
if (args.length == 3 && "t".equalsIgnoreCase(args[2]) && PluginCfg.USE_MYSQL) {
delGlobal = true;
}
- OfflinePlayer player = pm.getOfflinePlayer(playerName);
+ OfflinePlayer player = PlayerData.getOfflinePlayer(playerName);
if (player != null) {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
- String uuid = pm.getPlayerUUIDByName(playerName);
+ String uuid = PlayerData.getPlayerUUIDByName(playerName);
if (PluginCfg.IS_DEBUG) {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + uuid));
}
diff --git a/src/main/gg/frog/mc/permissionstime/command/RemoveCmd.java b/src/main/gg/frog/mc/permissionstime/command/RemoveCmd.java
index cd777b4..96cdbb4 100644
--- a/src/main/gg/frog/mc/permissionstime/command/RemoveCmd.java
+++ b/src/main/gg/frog/mc/permissionstime/command/RemoveCmd.java
@@ -6,11 +6,12 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import gg.frog.mc.base.PluginMain;
-import gg.frog.mc.base.config.LangCfg;
-import gg.frog.mc.base.config.PluginCfg;
+import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.base.utils.StrUtil;
+import gg.frog.mc.base.utils.data.PlayerData;
+import gg.frog.mc.permissionstime.config.LangCfg;
import gg.frog.mc.permissionstime.config.PackagesCfg;
+import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.permissionstime.database.SqlManager;
import gg.frog.mc.permissionstime.model.cfg.PermissionPackageBean;
import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
@@ -40,10 +41,10 @@ public class RemoveCmd implements Runnable {
}
PermissionPackageBean pack = PackagesCfg.PACKAGES.get(packageName);
if (pack != null) {
- OfflinePlayer player = pm.getOfflinePlayer(playerName);
+ OfflinePlayer player = PlayerData.getOfflinePlayer(playerName);
if (player != null) {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
- String uuid = pm.getPlayerUUIDByName(playerName);
+ String uuid = PlayerData.getPlayerUUIDByName(playerName);
if (PluginCfg.IS_DEBUG) {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + uuid + "\n" + pack.toString()));
}
diff --git a/src/main/gg/frog/mc/permissionstime/command/SetCmd.java b/src/main/gg/frog/mc/permissionstime/command/SetCmd.java
index 3037354..90cc70d 100644
--- a/src/main/gg/frog/mc/permissionstime/command/SetCmd.java
+++ b/src/main/gg/frog/mc/permissionstime/command/SetCmd.java
@@ -6,11 +6,12 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import gg.frog.mc.base.PluginMain;
-import gg.frog.mc.base.config.LangCfg;
-import gg.frog.mc.base.config.PluginCfg;
+import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.base.utils.StrUtil;
+import gg.frog.mc.base.utils.data.PlayerData;
+import gg.frog.mc.permissionstime.config.LangCfg;
import gg.frog.mc.permissionstime.config.PackagesCfg;
+import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.permissionstime.database.SqlManager;
import gg.frog.mc.permissionstime.model.cfg.PermissionPackageBean;
import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
@@ -63,10 +64,10 @@ public class SetCmd implements Runnable {
}
PermissionPackageBean pack = PackagesCfg.PACKAGES.get(packageName);
if (pack != null) {
- OfflinePlayer player = pm.getOfflinePlayer(playerName);
+ OfflinePlayer player = PlayerData.getOfflinePlayer(playerName);
if (player != null) {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_PROCESSING));
- String uuid = pm.getPlayerUUIDByName(playerName);
+ String uuid = PlayerData.getPlayerUUIDByName(playerName);
if (PluginCfg.IS_DEBUG) {
sender.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + uuid + "\n" + pack.toString() + "\n" + time + unitName + " ."));
}
diff --git a/src/main/gg/frog/mc/base/config/ConfigManager.java b/src/main/gg/frog/mc/permissionstime/config/ConfigManager.java
similarity index 65%
rename from src/main/gg/frog/mc/base/config/ConfigManager.java
rename to src/main/gg/frog/mc/permissionstime/config/ConfigManager.java
index acb059f..21476d8 100644
--- a/src/main/gg/frog/mc/base/config/ConfigManager.java
+++ b/src/main/gg/frog/mc/permissionstime/config/ConfigManager.java
@@ -1,23 +1,19 @@
-package gg.frog.mc.base.config;
+package gg.frog.mc.permissionstime.config;
import java.io.File;
-import java.io.FileOutputStream;
import java.io.InputStream;
-import java.io.OutputStream;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.command.CommandSender;
-import gg.frog.mc.base.PluginMain;
-import gg.frog.mc.base.config.LangCfg;
-import gg.frog.mc.base.config.PluginCfg;
import gg.frog.mc.base.utils.FileUtil;
import gg.frog.mc.base.utils.FileUtil.FindFilesDo;
import gg.frog.mc.base.utils.config.PluginConfig;
-import gg.frog.mc.nametags.config.TagNameCfg;
-import gg.frog.mc.permissionstime.config.PackagesCfg;
+import gg.frog.mc.permissionstime.PluginMain;
+import gg.frog.mc.permissionstime.config.LangCfg;
+import gg.frog.mc.permissionstime.config.PluginCfg;
/**
* 配置文件管理
@@ -40,7 +36,6 @@ public class ConfigManager {
public void initConfig() {
cfgMap.put("lang", new LangCfg("lang/" + PluginCfg.LANG + ".yml", pm));
cfgMap.put("packages", new PackagesCfg("packages.yml", pm));
- cfgMap.put("tagNames", new TagNameCfg("tagNames.yml", pm));
}
public void reloadConfig(CommandSender sender) {
@@ -62,27 +57,12 @@ public class ConfigManager {
@Override
public void process(String fileName, InputStream is) {
File f = new File(pm.getDataFolder(), fileName);
- File parentFolder = f.getParentFile();
- if (!parentFolder.exists()) {
- parentFolder.mkdirs();
- }
- try {
- OutputStream os = new FileOutputStream(f);
- int bytesRead = 0;
- byte[] buffer = new byte[8192];
- while ((bytesRead = is.read(buffer, 0, 8192)) != -1) {
- os.write(buffer, 0, bytesRead);
- }
- os.close();
- is.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
+ FileUtil.writeFile(f, is);
}
@Override
public boolean isProcess(String fileName) {
- if (fileName.matches("lang/.+\\.yml") || "config.yml".equals(fileName) || "packages.yml".equals(fileName) || "tagNames.yml".equals(fileName)) {
+ if (fileName.matches("lang/.+\\.yml") || "config.yml".equals(fileName) || "packages.yml".equals(fileName)) {
File f = new File(pm.getDataFolder(), fileName);
if (!f.exists()) {
return true;
diff --git a/src/main/gg/frog/mc/base/config/LangCfg.java b/src/main/gg/frog/mc/permissionstime/config/LangCfg.java
similarity index 86%
rename from src/main/gg/frog/mc/base/config/LangCfg.java
rename to src/main/gg/frog/mc/permissionstime/config/LangCfg.java
index b61c3b5..2a608b1 100644
--- a/src/main/gg/frog/mc/base/config/LangCfg.java
+++ b/src/main/gg/frog/mc/permissionstime/config/LangCfg.java
@@ -1,8 +1,8 @@
-package gg.frog.mc.base.config;
+package gg.frog.mc.permissionstime.config;
import org.bukkit.command.CommandSender;
-import gg.frog.mc.base.PluginMain;
+import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.base.utils.config.PluginConfig;
/**
@@ -14,24 +14,18 @@ import gg.frog.mc.base.utils.config.PluginConfig;
public class LangCfg extends PluginConfig {
public static String INVENTORY_NAME = null;
- public static String TAG_INVENTORY_NAME = null;
public static String EXPIRATION_TIME = null;
public static String LEFT_TIME = null;
public static String TIME_UNIT_D = null;
public static String TIME_UNIT_H = null;
public static String TIME_UNIT_M = null;
public static String TIME_FOREVER = null;
- public static String TAG = null;
- public static String TAG_COLOR_ITEM_NAME = null;
- public static String TAG_PREFIX_ITEM_NAME = null;
- public static String TAG_SUFFIX_ITEM_NAME = null;
public static String MSG_PARAMETER_MISMATCH = null;
public static String MSG_TIME_PARAMETER_INCORRECT = null;
public static String MSG_TIME_UNIT_PARAMETER_INCORRECT = null;
public static String MSG_PROCESSING = null;
public static String MSG_NO_DATA = null;
- public static String MSG_NO_TAG_DATA = null;
public static String MSG_PACKAGE_NUM = null;
public static String MSG_PACKAGE_LIST = null;
public static String MSG_PACKAGE_DETAIL = null;
@@ -57,11 +51,9 @@ public class LangCfg extends PluginConfig {
public static String MSG_UNKNOWN_PACKAGE = null;
public static String MSG_IS_EXPIRATION_DATE = null;
public static String MSG_FUNC_DISABLED = null;
- public static String MSG_TAG_SET_SUCCESS = null;
public static String CMD_HELP = null;
public static String CMD_ME = null;
- public static String CMD_TAG = null;
public static String CMD_PACKAGES = null;
public static String CMD_GET = null;
public static String CMD_GIVE = null;
@@ -81,29 +73,23 @@ public class LangCfg extends PluginConfig {
@Override
protected void loadToDo(CommandSender sender) {
INVENTORY_NAME = getConfig().getString("inventoryName", "&4===Permissions Packages===");
- TAG_INVENTORY_NAME = getConfig().getString("tagInventoryName", "&4===Tag Packages===");
EXPIRATION_TIME = getConfig().getString("expirationTime", "&4Expiration time: {0}");
LEFT_TIME = getConfig().getString("leftTime", "&4Left time: About {0}{1} {2}{3} {4}{5}");
TIME_UNIT_D = getConfig().getString("timeUnitD", "day(s)");
TIME_UNIT_H = getConfig().getString("timeUnitH", "hour(s)");
TIME_UNIT_M = getConfig().getString("timeUnitM", "minute(s)");
TIME_FOREVER = getConfig().getString("timeForever", "Forever");
- TAG = getConfig().getString("tag", "Tag/Prefix");
- TAG_COLOR_ITEM_NAME = getConfig().getString("tagColorItemName", "&6&lName Style");
- TAG_PREFIX_ITEM_NAME = getConfig().getString("tagPrefixItemName", "&6&lTag Prefix");
- TAG_SUFFIX_ITEM_NAME = getConfig().getString("tagSuffixItemName", "&6&lTag Suffix");
MSG_PARAMETER_MISMATCH = getConfig().getString("msg.parameterMismatch", "&4Parameter mismatch.");
MSG_TIME_PARAMETER_INCORRECT = getConfig().getString("msg.timeParameterIncorrect", "&4The number of time is incorrect. Please enter a nonzero integer.");
MSG_TIME_UNIT_PARAMETER_INCORRECT = getConfig().getString("msg.timeUnitParameterIncorrect", "&4The number of time unit is incorrect. Please use d/h/m. (d=day, h=hour, m=minute)");
MSG_PROCESSING = getConfig().getString("msg.processing", "&2Please wait for processing...");
MSG_NO_DATA = getConfig().getString("msg.noData", "&4No data for packages.");
- MSG_NO_TAG_DATA = getConfig().getString("msg.noTagData", "&4No data for tag packages.");
MSG_PACKAGE_NUM = getConfig().getString("msg.packageNum", "&4There are {0} kinds of permissions packages.");
MSG_PACKAGE_LIST = getConfig().getString("msg.packageList", "{0}packageName: {1}, displayName: {2}");
MSG_PACKAGE_DETAIL = getConfig().getString("msg.packageDetail", "packageName: {0}, displayName: {1}&r\\nPermissions: {2}\\nGroups: {3}");
MSG_NO_PERMISSION = getConfig().getString("msg.nopermission", "&4You do not have permission to do this.");
- MSG_CONFIG_RELOADED = getConfig().getString("msg.configReloaded", "&2Configuration overload is complete.");
+ MSG_CONFIG_RELOADED = getConfig().getString("msg.configReloaded", "&2Configuration reload is complete.");
MSG_FAIL_SET_PERMISSION = getConfig().getString("msg.failSetPermission", "&4Failed to modify permissions. Please re-enter the server!");
MSG_NO_FIND_PLAYER = getConfig().getString("msg.noFindPlayer", "&4Can not find player named &2{0}");
MSG_NO_FIND_PACKAGE = getConfig().getString("msg.noFindPackage", "&4Can not find package named &2{0}");
@@ -124,11 +110,9 @@ public class LangCfg extends PluginConfig {
MSG_UNKNOWN_PACKAGE = getConfig().getString("msg.unknownPackage", "Unknown Packages");
MSG_IS_EXPIRATION_DATE = getConfig().getString("msg.isExpirationDate", "Your package: {0}({1})&r has expired.");
MSG_FUNC_DISABLED = getConfig().getString("msg.funcDisabled", "{0} functionality disabled.");
- MSG_TAG_SET_SUCCESS = getConfig().getString("msg.tagSetSuccess", "&2Tag Set Success.");
CMD_HELP = getConfig().getString("cmd.help", "/{0} help \\n&7 - Show commands.");
CMD_ME = getConfig().getString("cmd.me", "&6/{0} me \\n&7 - View your packages.");
- CMD_TAG = getConfig().getString("cmd.tag", "&6/{0} tag \\n&7 - Set your color/prefix/suffix of tags.");
CMD_PACKAGES = getConfig().getString("cmd.packages", "&6/{0} packages [packageName] \\n&7 - View packages.");
CMD_GET = getConfig().getString("cmd.get", "&6/{0} get \\n&7 - View player packages.");
CMD_GIVE = getConfig().getString("cmd.give", "&6/{0} give