1
1
mirror of https://github.com/geekfrog/PermissionsTime.git synced 2024-11-22 07:28:47 +00:00

增加称号系统

This commit is contained in:
GeekFrog 2018-06-17 00:29:13 +08:00
parent 24003ed771
commit d236296e69
20 changed files with 834 additions and 81 deletions

View File

@ -14,6 +14,8 @@
经测试支持大部分1.7.10-1.12的服务器. 其他版本未做测试. 经测试支持大部分1.7.10-1.12的服务器. 其他版本未做测试.
本插件增加了称号管理功能,默认情况下为关闭状态.(2018-06-15)
#### 插件截图: #### 插件截图:
![image](http://i.imgur.com/cnnd5hb.jpg) ![image](http://i.imgur.com/cnnd5hb.jpg)
![image](http://i.imgur.com/bqvIVvz.jpg) ![image](http://i.imgur.com/bqvIVvz.jpg)
@ -52,6 +54,7 @@
- **玩家登录时删除过期的或无效数据** - **玩家登录时删除过期的或无效数据**
- **提示剩余时间** - **提示剩余时间**
- **权限包到期可执行自定义命令** - **权限包到期可执行自定义命令**
- **增加称号管理功能**
- 取消前置插件 - 取消前置插件

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>gg.frog.mc</groupId> <groupId>gg.frog.mc</groupId>
<artifactId>permissionstime</artifactId> <artifactId>permissionstime</artifactId>
<version>0.3.3-SNAPSHOT</version> <version>0.4.0-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>PermissionsTime</name> <name>PermissionsTime</name>
<description>支持跨服的权限限时插件</description> <description>支持跨服的权限限时插件</description>

View File

@ -19,6 +19,7 @@ import gg.frog.mc.permissionstime.listener.MainListener;
import gg.frog.mc.permissionstime.utils.FileUtil; import gg.frog.mc.permissionstime.utils.FileUtil;
import gg.frog.mc.permissionstime.utils.StrUtil; import gg.frog.mc.permissionstime.utils.StrUtil;
import gg.frog.mc.permissionstime.utils.UpdateCheck; import gg.frog.mc.permissionstime.utils.UpdateCheck;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.Permission;
public class PluginMain extends JavaPlugin { public class PluginMain extends JavaPlugin {
@ -33,6 +34,7 @@ public class PluginMain extends JavaPlugin {
private PluginMain pm = null; private PluginMain pm = null;
private SqlManager sm = null; private SqlManager sm = null;
private Permission permission = null; private Permission permission = null;
private Chat chat = null;
public PluginMain() { public PluginMain() {
PLUGIN_NAME = getDescription().getName(); PLUGIN_NAME = getDescription().getName();
@ -51,8 +53,8 @@ public class PluginMain extends JavaPlugin {
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + " https://github.com/geekfrog/PermissionsTime/ ")); getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + " https://github.com/geekfrog/PermissionsTime/ "));
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX)); getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX));
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "===============================")); getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "==============================="));
getServer().getScheduler().runTask(pm, new UpdateCheck(pm));
getServer().getScheduler().runTask(pm, new Runnable() { getServer().getScheduler().runTask(pm, new Runnable() {
public void run() { public void run() {
if (!checkPluginDepends()) { if (!checkPluginDepends()) {
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Startup failure!")); getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Startup failure!"));
@ -64,12 +66,12 @@ public class PluginMain extends JavaPlugin {
} }
if (PluginCfg.IS_METRICS) { if (PluginCfg.IS_METRICS) {
try { try {
Metrics metrics = new Metrics(pm); new Metrics(pm);
// metrics.addCustomChart(new Metrics.SimplePie("chart_id", () -> "My value"));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
getServer().getScheduler().runTaskAsynchronously(pm, new UpdateCheck(pm));
} }
}); });
} }
@ -108,6 +110,10 @@ public class PluginMain extends JavaPlugin {
return permission; return permission;
} }
public Chat getChat() {
return chat;
}
private boolean checkPluginDepends() { private boolean checkPluginDepends() {
boolean needDepend = false; boolean needDepend = false;
for (String name : DEPEND_PLUGIN.split(",")) { for (String name : DEPEND_PLUGIN.split(",")) {
@ -120,6 +126,10 @@ public class PluginMain extends JavaPlugin {
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Cann''t hook vault permission")); getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Cann''t hook vault permission"));
needDepend = true; needDepend = true;
} }
if (!needDepend && !setupChat()) {
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Cann''t hook vault chat"));
needDepend = true;
}
if (!needDepend && !setupDatabase()) { if (!needDepend && !setupDatabase()) {
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Cann''t setup database")); getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "&4Cann''t setup database"));
needDepend = true; needDepend = true;
@ -148,6 +158,14 @@ public class PluginMain extends JavaPlugin {
return (permission != null); return (permission != null);
} }
private boolean setupChat() {
RegisteredServiceProvider<Chat> chatProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.chat.Chat.class);
if (chatProvider != null) {
chat = chatProvider.getProvider();
}
return (chat != null);
}
private boolean setupDatabase() { private boolean setupDatabase() {
sm = new SqlManager(pm); sm = new SqlManager(pm);
return sm.updateDatabase(); return sm.updateDatabase();

View File

@ -46,7 +46,13 @@ public class MainCommand implements CommandExecutor, TabCompleter {
if (sender.isOp() || player.hasPermission("permissionstime.reload")) { if (sender.isOp() || player.hasPermission("permissionstime.reload")) {
for (Player p : pm.getServer().getOnlinePlayers()) { for (Player p : pm.getServer().getOnlinePlayers()) {
InventoryView inventory = p.getOpenInventory(); InventoryView inventory = p.getOpenInventory();
if (StrUtil.messageFormat(LangCfg.INVENTORY_NAME + "&r&5&9&2&0&r").equals(inventory.getTitle())) { if (inventory!=null &&
(
StrUtil.messageFormat(LangCfg.INVENTORY_NAME + "&r&5&9&2&0&r").equals(inventory.getTitle())
||
StrUtil.messageFormat(LangCfg.TAG_INVENTORY_NAME + "&r&5&9&2&0&r").equals(inventory.getTitle())
)
) {
inventory.close(); inventory.close();
} }
} }
@ -79,6 +85,15 @@ public class MainCommand implements CommandExecutor, TabCompleter {
if (hasPermission(sender, isPlayer, "permissionstime.me")) { if (hasPermission(sender, isPlayer, "permissionstime.me")) {
MeCmd meCmd = new MeCmd(pm, sender, isPlayer, args); MeCmd meCmd = new MeCmd(pm, sender, isPlayer, args);
new Thread(meCmd).start(); 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")) { } else if (args[0].equalsIgnoreCase("give")) {
if (hasPermission(sender, isPlayer, "permissionstime.give")) { if (hasPermission(sender, isPlayer, "permissionstime.give")) {
@ -124,6 +139,9 @@ public class MainCommand implements CommandExecutor, TabCompleter {
if (isPlayer && (sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".me"))) { if (isPlayer && (sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".me"))) {
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_ME, pm.PLUGIN_NAME_LOWER_CASE)); sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_ME, pm.PLUGIN_NAME_LOWER_CASE));
} }
if (isPlayer && (sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".tag"))) {
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_TAG, pm.PLUGIN_NAME_LOWER_CASE));
}
if (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".packages")) { if (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".packages")) {
sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_PACKAGES, pm.PLUGIN_NAME_LOWER_CASE)); sender.sendMessage(StrUtil.messageFormat(LangCfg.CMD_PACKAGES, pm.PLUGIN_NAME_LOWER_CASE));
} }
@ -171,6 +189,9 @@ public class MainCommand implements CommandExecutor, TabCompleter {
if ("me".startsWith(args[0]) && (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".me"))) { if ("me".startsWith(args[0]) && (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".me"))) {
tipList.add("me"); tipList.add("me");
} }
if ("tag".startsWith(args[0]) && (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".tag"))) {
tipList.add("tag");
}
if ("packages".startsWith(args[0]) && (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".packages"))) { if ("packages".startsWith(args[0]) && (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".packages"))) {
tipList.add("packages"); tipList.add("packages");
} }
@ -201,8 +222,10 @@ public class MainCommand implements CommandExecutor, TabCompleter {
tipList.add(name); tipList.add(name);
} }
} }
} else if ("give".equalsIgnoreCase(args[0]) || "set".equalsIgnoreCase(args[0]) || "get".equalsIgnoreCase(args[0]) || "remove".equalsIgnoreCase(args[0]) || "removeall".equalsIgnoreCase(args[0])) { } else if ("tag".equalsIgnoreCase(args[0]) && (!isPlayer || sender.isOp() || sender.hasPermission(pm.PLUGIN_NAME_LOWER_CASE + ".tag"))) {
return null; tipList.add("c");
tipList.add("p");
tipList.add("s");
} }
} else if (args.length == 3) { } else if (args.length == 3) {
args[0] = args[0].toLowerCase(Locale.ENGLISH); args[0] = args[0].toLowerCase(Locale.ENGLISH);

View File

@ -0,0 +1,70 @@
package gg.frog.mc.permissionstime.command;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.inventory.ItemStack;
import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.permissionstime.config.LangCfg;
import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.permissionstime.config.TagNameCfg;
import gg.frog.mc.permissionstime.config.TagNameCfg.TagType;
import gg.frog.mc.permissionstime.gui.PlayerTagShow;
import gg.frog.mc.permissionstime.utils.StrUtil;
public class TagCmd implements Runnable {
private PluginMain pm;
private String[] args;
private CommandSender sender;
private boolean isPlayer;
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<ItemStack> itemList = new ArrayList<ItemStack>();
TagType type = null;
Map<String, List<ItemStack>> 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));
}
}
OfflinePlayer player = pm.getOfflinePlayer(sender.getName());
PlayerTagShow.show(player.getPlayer(), type, itemList);
} 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."));
}
}
}

View File

@ -33,6 +33,7 @@ public class ConfigManager {
cfgMap.put("plugin", new PluginCfg(pm)); cfgMap.put("plugin", new PluginCfg(pm));
cfgMap.put("lang", new LangCfg("lang/" + PluginCfg.LANG + ".yml", pm)); cfgMap.put("lang", new LangCfg("lang/" + PluginCfg.LANG + ".yml", pm));
cfgMap.put("packages", new PackagesCfg("packages.yml", pm)); cfgMap.put("packages", new PackagesCfg("packages.yml", pm));
cfgMap.put("tagNames", new TagNameCfg("tagNames.yml", pm));
} }
public void reloadConfig() { public void reloadConfig() {
@ -74,7 +75,7 @@ public class ConfigManager {
@Override @Override
public boolean isProcess(String fileName) { public boolean isProcess(String fileName) {
if (fileName.matches("lang/.+\\.yml") || "config.yml".equals(fileName) || "packages.yml".equals(fileName)) { if (fileName.matches("lang/.+\\.yml") || "config.yml".equals(fileName) || "packages.yml".equals(fileName) || "tagNames.yml".equals(fileName)) {
File f = new File(pm.getDataFolder(), fileName); File f = new File(pm.getDataFolder(), fileName);
if (!f.exists()) { if (!f.exists()) {
return true; return true;

View File

@ -12,11 +12,14 @@ import gg.frog.mc.permissionstime.utils.config.PluginConfig;
public class LangCfg extends PluginConfig { public class LangCfg extends PluginConfig {
public static String INVENTORY_NAME = null; public static String INVENTORY_NAME = null;
public static String TAG_INVENTORY_NAME = null;
public static String EXPIRATION_TIME = null; public static String EXPIRATION_TIME = null;
public static String LEFT_TIME = null; public static String LEFT_TIME = null;
public static String TIME_UNIT_D = null; public static String TIME_UNIT_D = null;
public static String TIME_UNIT_H = null; public static String TIME_UNIT_H = null;
public static String TIME_UNIT_M = null; public static String TIME_UNIT_M = null;
public static String TIME_FOREVER = null;
public static String TAG = null;
public static String MSG_PARAMETER_MISMATCH = null; public static String MSG_PARAMETER_MISMATCH = null;
public static String MSG_TIME_PARAMETER_INCORRECT = null; public static String MSG_TIME_PARAMETER_INCORRECT = null;
@ -47,9 +50,12 @@ public class LangCfg extends PluginConfig {
public static String MSG_EXPIRATION_DATE = null; public static String MSG_EXPIRATION_DATE = null;
public static String MSG_UNKNOWN_PACKAGE = null; public static String MSG_UNKNOWN_PACKAGE = null;
public static String MSG_IS_EXPIRATION_DATE = 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_HELP = null;
public static String CMD_ME = null; public static String CMD_ME = null;
public static String CMD_TAG = null;
public static String CMD_PACKAGES = null; public static String CMD_PACKAGES = null;
public static String CMD_GET = null; public static String CMD_GET = null;
public static String CMD_GIVE = null; public static String CMD_GIVE = null;
@ -68,11 +74,14 @@ public class LangCfg extends PluginConfig {
@Override @Override
protected void loadToDo() { protected void loadToDo() {
INVENTORY_NAME = getConfig().getString("inventoryName", "&4===Permissions Packages==="); 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}"); EXPIRATION_TIME = getConfig().getString("expirationTime", "&4Expiration time: {0}");
LEFT_TIME = getConfig().getString("leftTime", "&4Left time: About {0}{1} {2}{3} {4}{5}"); LEFT_TIME = getConfig().getString("leftTime", "&4Left time: About {0}{1} {2}{3} {4}{5}");
TIME_UNIT_D = getConfig().getString("timeUnitD", "day(s)"); TIME_UNIT_D = getConfig().getString("timeUnitD", "day(s)");
TIME_UNIT_H = getConfig().getString("timeUnitH", "hour(s)"); TIME_UNIT_H = getConfig().getString("timeUnitH", "hour(s)");
TIME_UNIT_M = getConfig().getString("timeUnitM", "minute(s)"); TIME_UNIT_M = getConfig().getString("timeUnitM", "minute(s)");
TIME_FOREVER = getConfig().getString("timeForever", "Forever");
TAG = getConfig().getString("tag", "Tag/Prefix");
MSG_PARAMETER_MISMATCH = getConfig().getString("msg.parameterMismatch", "&4Parameter mismatch."); 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_PARAMETER_INCORRECT = getConfig().getString("msg.timeParameterIncorrect", "&4The number of time is incorrect. Please enter a nonzero integer.");
@ -103,9 +112,12 @@ public class LangCfg extends PluginConfig {
MSG_EXPIRATION_DATE = getConfig().getString("msg.expirationDate", "{0}packages: {1}({2}), Expiration date: {3}, {4}"); MSG_EXPIRATION_DATE = getConfig().getString("msg.expirationDate", "{0}packages: {1}({2}), Expiration date: {3}, {4}");
MSG_UNKNOWN_PACKAGE = getConfig().getString("msg.unknownPackage", "Unknown Packages"); 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_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_HELP = getConfig().getString("cmd.help", "/{0} help \\n&7 - Show commands.");
CMD_ME = getConfig().getString("cmd.me", "&6/{0} me \\n&7 - View self package."); CMD_ME = getConfig().getString("cmd.me", "&6/{0} me \\n&7 - View your packages.");
CMD_TAG = getConfig().getString("cmd.tag", "&6/{0} tag <c/p/s> \\n&7 - View your color/prefix/suffix tags.");
CMD_PACKAGES = getConfig().getString("cmd.packages", "&6/{0} packages [packageName] \\n&7 - View packages."); CMD_PACKAGES = getConfig().getString("cmd.packages", "&6/{0} packages [packageName] \\n&7 - View packages.");
CMD_GET = getConfig().getString("cmd.get", "&6/{0} get <playerName> \\n&7 - View player packages."); CMD_GET = getConfig().getString("cmd.get", "&6/{0} get <playerName> \\n&7 - View player packages.");
CMD_GIVE = getConfig().getString("cmd.give", "&6/{0} give <playerName> <packageName> <time> <timeUnit:d/h/m> \\n&7 - Give player package some time. (Time accumulation.) \\n&7 timeUnit: d=day, h=hour, m=minute"); CMD_GIVE = getConfig().getString("cmd.give", "&6/{0} give <playerName> <packageName> <time> <timeUnit:d/h/m> \\n&7 - Give player package some time. (Time accumulation.) \\n&7 timeUnit: d=day, h=hour, m=minute");

View File

@ -14,6 +14,7 @@ public class PluginCfg extends PluginConfig {
public static String PLUGIN_PREFIX; public static String PLUGIN_PREFIX;
public static boolean IS_METRICS = true; public static boolean IS_METRICS = true;
public static boolean IS_DEBUG = false; public static boolean IS_DEBUG = false;
public static boolean TAG_SYSTEM = false;
public static String LANG; public static String LANG;
public static boolean USE_MYSQL = false; public static boolean USE_MYSQL = false;
public static String SQL_SERVER_ID; public static String SQL_SERVER_ID;
@ -36,6 +37,7 @@ public class PluginCfg extends PluginConfig {
PLUGIN_PREFIX = setGetDefault("pluginPrefix", "&b[" + pm.PLUGIN_NAME + "] ") + "&r"; PLUGIN_PREFIX = setGetDefault("pluginPrefix", "&b[" + pm.PLUGIN_NAME + "] ") + "&r";
IS_DEBUG = setGetDefault("debug", false); IS_DEBUG = setGetDefault("debug", false);
IS_METRICS = setGetDefault("metrics", true); IS_METRICS = setGetDefault("metrics", true);
TAG_SYSTEM = setGetDefault("tagSystem", false);
LANG = setGetDefault("lang", "en"); LANG = setGetDefault("lang", "en");
USE_MYSQL = setGetDefault("mysql.enable", false); USE_MYSQL = setGetDefault("mysql.enable", false);
SQL_SERVER_ID = setGetDefault("mysql.serverId", "default"); SQL_SERVER_ID = setGetDefault("mysql.serverId", "default");

View File

@ -0,0 +1,169 @@
package gg.frog.mc.permissionstime.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.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.permissionstime.model.cfg.PlayerTagBean;
import gg.frog.mc.permissionstime.model.cfg.TagPackageBean;
import gg.frog.mc.permissionstime.utils.StrUtil;
import gg.frog.mc.permissionstime.utils.config.PluginConfig;
import gg.frog.mc.permissionstime.utils.nms.ItemUtil;
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 Map<String, TagPackageBean> PACKAGES = new ConcurrentHashMap<>();
public static Map<String, List<ItemStack>> NAMECOLOR_ITEMS = new ConcurrentHashMap<>();
public static Map<String, List<ItemStack>> PREFIX_ITEMS = new ConcurrentHashMap<>();
public static Map<String, List<ItemStack>> SUFFIX_ITEMS = new ConcurrentHashMap<>();
public static Map<String, List<String>> NAMECOLOR_PERMISSIONS = new ConcurrentHashMap<>();
public static Map<String, List<String>> PREFIX_PERMISSIONS = new ConcurrentHashMap<>();
public static Map<String, List<String>> SUFFIX_PERMISSIONS = new ConcurrentHashMap<>();
public static Map<String, PlayerTagBean> PLAYER_TAG = new ConcurrentHashMap<>();
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() {
DEFAULT_NAMECOLOR = setGetDefault("defaultNamecolor", "");
DEFAULT_PREFIX = setGetDefault("defaultPrefix", "");
DEFAULT_SUFFIX = setGetDefault("defaultSuffix", "");
PACKAGES = getObjMap("packages", TagPackageBean.class);
saveObj("packages", PACKAGES);
if (PluginCfg.IS_DEBUG) {
System.out.println("defaultNamecolor:" + DEFAULT_NAMECOLOR);
System.out.println("defaultPrefix:" + DEFAULT_PREFIX);
System.out.println("defaultSuffix:" + DEFAULT_SUFFIX);
for (Entry<String, TagPackageBean> p : PACKAGES.entrySet()) {
System.out.println(p.getKey() + ":" + p.getValue());
}
}
NAMECOLOR_ITEMS.clear();
PREFIX_ITEMS.clear();
SUFFIX_ITEMS.clear();
NAMECOLOR_PERMISSIONS.clear();
PREFIX_PERMISSIONS.clear();
SUFFIX_PERMISSIONS.clear();
for (Entry<String, TagPackageBean> e : PACKAGES.entrySet()) {
List<ItemStack> 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);
}
}
}
private List<ItemStack> getTagItem(TagType tagType, TagPackageBean tpb) {
List<ItemStack> items = new ArrayList<>();
if (tpb != null) {
List<String> tags = null;
String itemDisplayName = "";
Map<String, List<String>> tagPermissions = null;
if (tagType == TagType.NAMECOLOR_TYPE) {
tags = tpb.getNamecolor();
itemDisplayName = "&6&l昵称效果 &r";
tagPermissions = NAMECOLOR_PERMISSIONS;
} else if (tagType == TagType.PREFIX_TYPE) {
tags = tpb.getPrefix();
itemDisplayName = "&6&l昵称前缀 &r";
tagPermissions = PREFIX_PERMISSIONS;
} else if (tagType == TagType.SUFFIX_TYPE) {
tags = tpb.getSuffix();
itemDisplayName = "&6&l昵称后缀 &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<String> lores = new ArrayList<String>();
lores.add("");
lores.add("");// 效果展示
lores.add("");
lores.add(StrUtil.messageFormat(tpb.getDescription()));// 描述
lores.add("");
lores.add(tag);// 称号
meta.setLore(lores);
item.setItemMeta(meta);
if (skullOwner != null) {
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;
}
}

View File

@ -23,7 +23,7 @@ public class PlayerPermissionShow {
if (pdbList.size() > 0) { if (pdbList.size() > 0) {
inventory = Bukkit.createInventory(null, inventory = Bukkit.createInventory(null,
(pdbList.size() % 9 == 0 ? pdbList.size() : (pdbList.size() / 9 + 1) * 9), (pdbList.size() % 9 == 0 ? pdbList.size() : (pdbList.size() / 9 + 1) * 9),
StrUtil.messageFormat(LangCfg.INVENTORY_NAME + "&r&5&9&2&0&r")); StrUtil.messageFormat(LangCfg.TAG_INVENTORY_NAME + "&r&5&9&2&0&r"));
for (PlayerDataBean pdb : pdbList) { for (PlayerDataBean pdb : pdbList) {
PermissionPackageBean ppb = PackagesCfg.PACKAGES.get(pdb.getPackageName()); PermissionPackageBean ppb = PackagesCfg.PACKAGES.get(pdb.getPackageName());
if (ppb != null && pdb.getGlobal() == ppb.getGlobal()) { if (ppb != null && pdb.getGlobal() == ppb.getGlobal()) {

View File

@ -0,0 +1,60 @@
package gg.frog.mc.permissionstime.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.permissionstime.config.LangCfg;
import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.permissionstime.config.TagNameCfg;
import gg.frog.mc.permissionstime.config.TagNameCfg.TagType;
import gg.frog.mc.permissionstime.model.cfg.PlayerTagBean;
import gg.frog.mc.permissionstime.utils.StrUtil;
public class PlayerTagShow {
public static void show(Player p, TagType tagType, List<ItemStack> itemList) {
Inventory inventory = null;
int size = 0;
if (itemList.size() > 0) {
inventory = Bukkit.createInventory(null,
(itemList.size() % 9 == 0 ? itemList.size() : (itemList.size() / 9 + 1) * 9),
StrUtil.messageFormat(LangCfg.TAG_INVENTORY_NAME + "&r&5&9&2&0&r"));
String uuid = p.getUniqueId().toString();
PlayerTagBean playerTag = null;
if (TagNameCfg.PLAYER_TAG.containsKey(uuid)) {
playerTag = TagNameCfg.PLAYER_TAG.get(uuid);
playerTag = playerTag.clone();
if(playerTag != null) {
for (ItemStack item : itemList) {
ItemStack tItem = item.clone();
ItemMeta meta = tItem.getItemMeta();
List<String> lores = meta.getLore();
String tag = lores.get(5);
if(tagType == TagType.NAMECOLOR_TYPE) {
playerTag.setNamecolor(tag);
}else if(tagType == TagType.PREFIX_TYPE) {
playerTag.setPrefix(tag);
}else if(tagType == TagType.SUFFIX_TYPE) {
playerTag.setSuffix(tag);
}
lores.set(1,"效果展示: "+playerTag.getDisplayNameStr(p));
meta.setLore(lores);
tItem.setItemMeta(meta);
inventory.addItem(tItem);
size++;
}
}
}
}
if (inventory != null && size > 0) {
p.openInventory(inventory);
} else {
p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_NO_DATA));
}
}
}

View File

@ -1,7 +1,9 @@
package gg.frog.mc.permissionstime.listener; package gg.frog.mc.permissionstime.listener;
import java.util.List; import java.util.List;
import java.util.UUID;
import org.bukkit.OfflinePlayer;
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;
@ -13,7 +15,9 @@ import org.bukkit.event.player.PlayerQuitEvent;
import gg.frog.mc.permissionstime.PluginMain; import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.permissionstime.config.LangCfg; import gg.frog.mc.permissionstime.config.LangCfg;
import gg.frog.mc.permissionstime.config.PluginCfg; import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.permissionstime.config.TagNameCfg;
import gg.frog.mc.permissionstime.model.cfg.PermissionPackageBean; import gg.frog.mc.permissionstime.model.cfg.PermissionPackageBean;
import gg.frog.mc.permissionstime.model.cfg.PlayerTagBean;
import gg.frog.mc.permissionstime.model.db.PlayerDataBean; import gg.frog.mc.permissionstime.model.db.PlayerDataBean;
import gg.frog.mc.permissionstime.utils.StrUtil; import gg.frog.mc.permissionstime.utils.StrUtil;
@ -27,6 +31,9 @@ public class MainListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onJoin(PlayerLoginEvent event) { public void onJoin(PlayerLoginEvent event) {
new Thread(new Runnable() {
@Override
public void run() {
try { try {
List<PlayerDataBean> pdbList = pm.getSqlManager().getTime(event.getPlayer().getUniqueId().toString()); List<PlayerDataBean> pdbList = pm.getSqlManager().getTime(event.getPlayer().getUniqueId().toString());
PermissionPackageBean.reloadPlayerPermissions(event.getPlayer(), pdbList, pm, false); PermissionPackageBean.reloadPlayerPermissions(event.getPlayer(), pdbList, pm, false);
@ -34,6 +41,20 @@ public class MainListener implements Listener {
e.printStackTrace(); e.printStackTrace();
event.getPlayer().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_FAIL_SET_PERMISSION)); event.getPlayer().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_FAIL_SET_PERMISSION));
} }
if (PluginCfg.TAG_SYSTEM) {
String uuid = event.getPlayer().getUniqueId().toString();
PlayerTagBean playerTag = null;
if (TagNameCfg.PLAYER_TAG.containsKey(uuid)) {
playerTag = TagNameCfg.PLAYER_TAG.get(uuid);
playerTag.setPlayerDisplayName(event.getPlayer());
} else {
playerTag = new PlayerTagBean("playerTag/" + uuid + ".yml", pm);
playerTag.setPlayerDisplayName(event.getPlayer(), true);
}
TagNameCfg.PLAYER_TAG.put(uuid, playerTag);
}
}
}).start();
} }
public void onQuit(PlayerQuitEvent event) { public void onQuit(PlayerQuitEvent event) {
@ -67,5 +88,29 @@ public class MainListener implements Listener {
if (StrUtil.messageFormat(LangCfg.INVENTORY_NAME + "&r&5&9&2&0&r").equals(event.getInventory().getName())) { if (StrUtil.messageFormat(LangCfg.INVENTORY_NAME + "&r&5&9&2&0&r").equals(event.getInventory().getName())) {
event.setCancelled(true); event.setCancelled(true);
} }
if (StrUtil.messageFormat(LangCfg.TAG_INVENTORY_NAME + "&r&5&9&2&0&r").equals(event.getInventory().getName())) {
OfflinePlayer player = this.pm.getOfflinePlayer(event.getWhoClicked().getName());
UUID uuid = player.getUniqueId();
if (TagNameCfg.PLAYER_TAG.containsKey(uuid.toString()) && event.getCurrentItem() != null) {
List<String> lores = event.getCurrentItem().getItemMeta().getLore();
if (lores.size() == 6) {
String itemName = event.getCurrentItem().getItemMeta().getDisplayName();
PlayerTagBean playerTag = TagNameCfg.PLAYER_TAG.get(uuid.toString());
if (itemName.startsWith(StrUtil.messageFormat("&6&l昵称效果 &r"))) {
playerTag.setNamecolor(lores.get(5));
} else if (itemName.startsWith(StrUtil.messageFormat("&6&l昵称前缀 &r"))) {
playerTag.setPrefix(lores.get(5));
} else if (itemName.startsWith(StrUtil.messageFormat("&6&l昵称后缀 &r"))) {
playerTag.setSuffix(lores.get(5));
} else {
event.setCancelled(true);
}
playerTag.setPlayerDisplayName(player.getPlayer(), true);
playerTag.saveConfig();
event.getWhoClicked().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_TAG_SET_SUCCESS));
}
}
event.setCancelled(true);
}
} }
} }

View File

@ -150,9 +150,7 @@ public class PermissionPackageBean implements IConfigBean {
@Override @Override
public String toString() { public String toString() {
return "PermissionPackageBean [displayName=" + displayName + ", id=" + id + ", type=" + type + ", glowing=" return "PermissionPackageBean [displayName=" + displayName + ", id=" + id + ", type=" + type + ", glowing=" + glowing + ", lores=" + lores + ", global=" + global + ", permissions=" + permissions + ", groups=" + groups + ", expireCommands=" + expireCommands + "]";
+ glowing + ", lores=" + lores + ", global=" + global + ", permissions=" + permissions + ", groups="
+ groups + ", expireCommands=" + expireCommands + "]";
} }
private void givePlayer(OfflinePlayer player, Server server, Permission permission) { private void givePlayer(OfflinePlayer player, Server server, Permission permission) {
@ -227,8 +225,7 @@ public class PermissionPackageBean implements IConfigBean {
reloadPlayerPermissions(player, pdbList, plugin, true); reloadPlayerPermissions(player, pdbList, plugin, true);
} }
public static void reloadPlayerPermissions(OfflinePlayer player, List<PlayerDataBean> pdbList, PluginMain plugin, public static void reloadPlayerPermissions(OfflinePlayer player, List<PlayerDataBean> pdbList, PluginMain plugin, boolean async) {
boolean async) {
long delay = -1; long delay = -1;
long now = new Date().getTime(); long now = new Date().getTime();
PermissionPackageBean addPpb = new PermissionPackageBean(); PermissionPackageBean addPpb = new PermissionPackageBean();
@ -262,8 +259,7 @@ public class PermissionPackageBean implements IConfigBean {
addPpb.givePlayer(player, plugin.getServer(), plugin.getPermission()); addPpb.givePlayer(player, plugin.getServer(), plugin.getPermission());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
player.getPlayer().sendMessage( player.getPlayer().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_FAIL_SET_PERMISSION));
StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_FAIL_SET_PERMISSION));
} }
} }
}); });
@ -308,29 +304,25 @@ public class PermissionPackageBean implements IConfigBean {
for (PlayerDataBean playerData : playerDataList) { for (PlayerDataBean playerData : playerDataList) {
if (playerData.getExpire() < now) { if (playerData.getExpire() < now) {
PermissionPackageBean packageBean = PackagesCfg.PACKAGES.get(playerData.getPackageName()); PermissionPackageBean packageBean = PackagesCfg.PACKAGES.get(playerData.getPackageName());
if ((packageBean == null && !playerData.getGlobal()) if ((packageBean == null && !playerData.getGlobal()) || (packageBean != null && playerData.getGlobal() == packageBean.getGlobal())) {
|| (packageBean != null && playerData.getGlobal() == packageBean.getGlobal())) {
plugin.getServer().getScheduler().runTask(plugin, new Runnable() { plugin.getServer().getScheduler().runTask(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
Player p = player.getPlayer(); Player p = player.getPlayer();
if (p != null) { if (p != null) {
p.sendMessage( p.sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_IS_EXPIRATION_DATE, packageBean != null ? packageBean.getDisplayName() : LangCfg.MSG_UNKNOWN_PACKAGE, playerData.getPackageName()));
StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + LangCfg.MSG_IS_EXPIRATION_DATE, if(packageBean !=null) {
packageBean != null ? packageBean.getDisplayName()
: LangCfg.MSG_UNKNOWN_PACKAGE,
playerData.getPackageName()));
for (String commands : packageBean.getExpireCommands()) { for (String commands : packageBean.getExpireCommands()) {
try { try {
commands = StrUtil.messageFormat(player.getPlayer(), commands); commands = StrUtil.messageFormat(player.getPlayer(), commands);
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), commands);
commands);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
} }
}
}); });
plugin.getSqlManager().delById(playerData.getId()); plugin.getSqlManager().delById(playerData.getId());
} }

View File

@ -0,0 +1,191 @@
package gg.frog.mc.permissionstime.model.cfg;
import java.util.List;
import org.bukkit.World;
import org.bukkit.configuration.MemorySection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
import gg.frog.mc.permissionstime.PluginMain;
import gg.frog.mc.permissionstime.config.PluginCfg;
import gg.frog.mc.permissionstime.config.TagNameCfg;
import gg.frog.mc.permissionstime.utils.StrUtil;
import gg.frog.mc.permissionstime.utils.config.IConfigBean;
import gg.frog.mc.permissionstime.utils.config.PluginConfig;
/**
* 玩家标签包实体类
*
* @author QiaoPengyu
*
*/
public class PlayerTagBean extends PluginConfig implements IConfigBean, Cloneable {
// 名称颜色
private String namecolor;
// 前缀
private String prefix;
// 后缀
private String suffix;
public PlayerTagBean(String fileName, PluginMain pm) {
super(fileName, pm);
if (PluginCfg.IS_DEBUG) {
System.out.println("Player Tag File:" + fileName);
}
}
@Override
protected void init() {
}
@Override
protected void loadToDo() {
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 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) {
Scoreboard scoreboard = pm.getServer().getScoreboardManager().getNewScoreboard();
Team team = scoreboard.getTeam(player.getName());
if (team == null) {
team = scoreboard.registerNewTeam(player.getName());
}
team.setPrefix(StrUtil.messageFormat(player, "&r" + prefix + "&r" + namecolor + "&r"));
team.setSuffix(StrUtil.messageFormat(player, "&r" + suffix + "&r"));
team.addEntry(player.getName());
player.setScoreboard(scoreboard);
List<World> worlds = pm.getServer().getWorlds();
for (World world : worlds) {
pm.getChat().setPlayerInfoString(world.getName(), player, "prefix", StrUtil.messageFormat(player, "&r" + prefix + "&r" + namecolor + "&r"));
pm.getChat().setPlayerInfoString(world.getName(), player, "suffix", StrUtil.messageFormat(player, "&r" + suffix + "&r"));
}
player.setDisplayName(getDisplayNameStr(player));
if (PluginCfg.IS_DEBUG) {
System.out.println("PlayerTagBean:" + playerTag);
}
}
}
});
}
public String getDisplayNameStr(Player player) {
return StrUtil.messageFormat(player, prefix + namecolor + player.getName() + suffix + "&r");
}
@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;
}
@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 + "]";
}
}

View File

@ -0,0 +1,95 @@
package gg.frog.mc.permissionstime.model.cfg;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.configuration.MemorySection;
import org.bukkit.configuration.file.YamlConfiguration;
import gg.frog.mc.permissionstime.utils.config.IConfigBean;
/**
* 标签包实体类
*
* @author QiaoPengyu
*
*/
public class TagPackageBean implements IConfigBean {
//所需权限
private String permissions;
//名称颜色
private List<String> namecolor = new ArrayList<>();
//前缀
private List<String> prefix = new ArrayList<>();
//后缀
private List<String> suffix = new ArrayList<>();
//说明
private String description;
public String getPermissions() {
return permissions;
}
public void setPermissions(String permissions) {
this.permissions = permissions;
}
public List<String> getNamecolor() {
return namecolor;
}
public void setNamecolor(List<String> namecolor) {
this.namecolor = namecolor;
}
public List<String> getPrefix() {
return prefix;
}
public void setPrefix(List<String> prefix) {
this.prefix = prefix;
}
public List<String> getSuffix() {
return suffix;
}
public void setSuffix(List<String> suffix) {
this.suffix = suffix;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public YamlConfiguration toConfig() {
YamlConfiguration config = new YamlConfiguration();
config.set("permissions", permissions);
config.set("namecolor", namecolor);
config.set("prefix", prefix);
config.set("suffix", suffix);
config.set("description", description);
return config;
}
@Override
public void toConfigBean(MemorySection config) {
permissions = config.getString("permissions");
namecolor = config.getStringList("namecolor");
prefix = config.getStringList("prefix");
suffix = config.getStringList("suffix");
description = config.getString("description");
}
@Override
public String toString() {
return "PermissionPackageBean [permissions=" + permissions + ", namecolor=" + namecolor + ", prefix=" + prefix + ", suffix="
+ suffix + ", description=" + description + "]";
}
}

View File

@ -7,6 +7,9 @@ debug: false
# 是否同意插件上传统计信息. # 是否同意插件上传统计信息.
# Whether or not you agree with the plugin to upload statistics. # Whether or not you agree with the plugin to upload statistics.
metrics: true metrics: true
# 开启称号系统.
# Use prefix system.
tagSystem: false
# 语言文件名称 在'lang'文件夹内. # 语言文件名称 在'lang'文件夹内.
# Language file name. # Language file name.
lang: en lang: en
@ -14,7 +17,7 @@ lang: en
# Database settings. # Database settings.
mysql: mysql:
# 是否使用MySQL数据库. # 是否使用MySQL数据库.
# Whether to use the MySQL database. # Use the MySQL database?
enable: false enable: false
# 服务器唯一标识, 用来区分权限是哪个服务器的. # 服务器唯一标识, 用来区分权限是哪个服务器的.
# 想要权限跨服,serverId必须一致. # 想要权限跨服,serverId必须一致.

View File

@ -1,9 +1,12 @@
inventoryName: '&4===Permissions Packages===' inventoryName: '&4===Permissions Packages==='
tagInventoryName: '&4===Tag Packages==='
expirationTime: '&4Expiration date: {0}' expirationTime: '&4Expiration date: {0}'
leftTime: '&4Left time: About {0}{1} {2}{3} {4}{5}' leftTime: '&4Left time: About {0}{1} {2}{3} {4}{5}'
timeUnitD: 'day(s)' timeUnitD: 'day(s)'
timeUnitH: 'hour(s)' timeUnitH: 'hour(s)'
timeUnitM: 'minute(s)' timeUnitM: 'minute(s)'
timeForever: 'Forever'
tag: 'Tag/Prefix'
msg: msg:
parameterMismatch: '&4Parameter mismatch.' parameterMismatch: '&4Parameter mismatch.'
timeParameterIncorrect: '&4The number of time is incorrect. Please enter a nonzero integer.' timeParameterIncorrect: '&4The number of time is incorrect. Please enter a nonzero integer.'
@ -34,9 +37,12 @@ msg:
expirationDate: '{0}packages: {1}({2}), Expiration date: {3}, {4}' expirationDate: '{0}packages: {1}({2}), Expiration date: {3}, {4}'
unknownPackage: 'Unknown Packages' unknownPackage: 'Unknown Packages'
isExpirationDate: 'Your package: {0}({1})&r has expired.' isExpirationDate: 'Your package: {0}({1})&r has expired.'
funcDisabled: '{0} functionality disabled.'
tagSetSuccess: '&2Tag Set Success.'
cmd: cmd:
help: '&6/{0} help \n&7 - Show commands.' help: '&6/{0} help \n&7 - Show commands.'
me: '&6/{0} me \n&7 - View self package.' me: '&6/{0} me \n&7 - View your packages.'
tag: '&6/{0} tag <c/p/s>\n&7 - View your color/prefix/suffix tags.'
packages: '&6/{0} packages [packageName] \n&7 - View server packages.' packages: '&6/{0} packages [packageName] \n&7 - View server packages.'
get: '&6/{0} get <playerName> \n&7 - View player packages.' get: '&6/{0} get <playerName> \n&7 - View player packages.'
give: '&6/{0} give <playerName> <packageName> <time> <timeUnit:d/h/m> \n&7 - Give player package some time. (Time accumulation.) \n&7 timeUnit: d=day, h=hour, m=minute' give: '&6/{0} give <playerName> <packageName> <time> <timeUnit:d/h/m> \n&7 - Give player package some time. (Time accumulation.) \n&7 timeUnit: d=day, h=hour, m=minute'

View File

@ -1,9 +1,12 @@
inventoryName: '&4===权限仓库===' inventoryName: '&4===权限仓库==='
tagInventoryName: '&4===称号仓库==='
expirationTime: '&4到期时间: {0}.' expirationTime: '&4到期时间: {0}.'
leftTime: '&4剩余时间: 大约 {0}{1} {2}{3} {4}{5}' leftTime: '&4剩余时间: 大约 {0}{1} {2}{3} {4}{5}'
timeUnitD: '天' timeUnitD: '天'
timeUnitH: '小时' timeUnitH: '小时'
timeUnitM: '分钟' timeUnitM: '分钟'
timeForever: '永久'
tag: '标签/称号'
msg: msg:
parameterMismatch: '&4参数不匹配.' parameterMismatch: '&4参数不匹配.'
timeParameterIncorrect: '&4时间参数不正确,请输入非零整数.' timeParameterIncorrect: '&4时间参数不正确,请输入非零整数.'
@ -34,9 +37,12 @@ msg:
expirationDate: '{0}权限包: {1}({2}), 到期时间: {3}, {4}' expirationDate: '{0}权限包: {1}({2}), 到期时间: {3}, {4}'
unknownPackage: '未知权限包' unknownPackage: '未知权限包'
isExpirationDate: '你的权限包: {0}({1})&r, 已到期.' isExpirationDate: '你的权限包: {0}({1})&r, 已到期.'
funcDisabled: '&4{0} 功能已被禁用.'
tagSetSuccess: '&2称号设置成功.'
cmd: cmd:
help: '&6/{0} help \n&7 - 显示所有命令.' help: '&6/{0} help \n&7 - 显示所有命令.'
me: '&6/{0} me \n&7 - 显示自己的权限包.' me: '&6/{0} me \n&7 - 显示自己的权限包.'
tag: '&6/{0} tag <c/p/s>\n&7 - 显示你的昵称颜色/称号前缀/称号后缀.'
packages: '&6/{0} packages [权限包名] \n&7 - 查看服务器的(某个)权限包.' packages: '&6/{0} packages [权限包名] \n&7 - 查看服务器的(某个)权限包.'
get: '&6/{0} get <玩家> \n&7 - 查看玩家的权限包.' get: '&6/{0} get <玩家> \n&7 - 查看玩家的权限包.'
give: '&6/{0} give <玩家> <权限包名> <时间> <单位:d或h或m> \n&7 - 给玩家一定时间的权限包. (时间累加.) \n&7 时间单位: d=天, h=小时, m=分钟' give: '&6/{0} give <玩家> <权限包名> <时间> <单位:d或h或m> \n&7 - 给玩家一定时间的权限包. (时间累加.) \n&7 时间单位: d=天, h=小时, m=分钟'

View File

@ -1,5 +1,5 @@
name: PermissionsTime name: PermissionsTime
version: 0.3.3-SNAPSHOT version: 0.4.0-SNAPSHOT
main: gg.frog.mc.permissionstime.PluginMain main: gg.frog.mc.permissionstime.PluginMain
author: GeekFrog author: GeekFrog
softdepend: softdepend:
@ -19,6 +19,7 @@ permissions:
default: op default: op
children: children:
permissionstime.me: true permissionstime.me: true
permissionstime.tag: true
permissionstime.reload: true permissionstime.reload: true
permissionstime.give: true permissionstime.give: true
permissionstime.set: true permissionstime.set: true
@ -27,7 +28,10 @@ permissions:
permissionstime.removeall: true permissionstime.removeall: true
permissionstime.packages: true permissionstime.packages: true
permissionstime.me: permissionstime.me:
description: View himself package. description: View your packages.
default: true
permissionstime.tag:
description: View your color/prefix/suffix tags.
default: true default: true
permissionstime.reload: permissionstime.reload:
description: Reloads the config file. description: Reloads the config file.

View File

@ -0,0 +1,53 @@
# 默认昵称样式.
# Default Name Color.
defaultNamecolor: '&6'
# 默认前缀.
# Default Prefix.
defaultPrefix: ''
# 默认后缀.
# Default Suffix.
defaultSuffix: ''
packages:
# 称号包名称.
# Tag package name.
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'